From 88e68b1d3a28851a662f22d68918057f77104a6f Mon Sep 17 00:00:00 2001 From: Hans Ott Date: Fri, 16 Feb 2024 12:12:28 +0100 Subject: [PATCH] Improve lambda docs --- docs/lambda.md | 5 ++--- library/src/sources/Lambda.ts | 7 +------ 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/docs/lambda.md b/docs/lambda.md index 72f118fe8..8a271b1da 100644 --- a/docs/lambda.md +++ b/docs/lambda.md @@ -11,7 +11,7 @@ const dependency = require("dependency"); preventPrototypePollution(); // <-- Call this after your main imports -exports.handler = protect(async (event, context) => { +exports.handler = protect(async (event, context) => { // <-- Wrap your handler with protect // ... }); ``` @@ -27,8 +27,7 @@ import { lambda, preventPrototypePollution } from '@aikidosec/guard'; In order for the guard to work properly, we need the following event properties to be present: * `event.body` -* `event.httpMethod` (optional) -* `event.headers` (optional) +* `event.headers` That's it! Your AWS Lambda function is now protected by Aikido guard. diff --git a/library/src/sources/Lambda.ts b/library/src/sources/Lambda.ts index bf4671c68..3d783782e 100644 --- a/library/src/sources/Lambda.ts +++ b/library/src/sources/Lambda.ts @@ -89,12 +89,7 @@ function isJsonContentType(contentType: string) { } function isProxyEvent(event: unknown): event is APIGatewayProxyEvent { - return ( - isPlainObject(event) && - "httpMethod" in event && - "requestContext" in event && - "headers" in event - ); + return isPlainObject(event) && "httpMethod" in event && "headers" in event; } export function createLambdaWrapper<