-
Notifications
You must be signed in to change notification settings - Fork 14
[python_lambda] Add scenario for testing the python tracer for AWS Lambda #4891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
florentinl
merged 14 commits into
main
from
florentin.labelle/APPSEC-58014/scenario-for-lambda-python-api-gateway
Aug 20, 2025
Merged
[python_lambda] Add scenario for testing the python tracer for AWS Lambda #4891
florentinl
merged 14 commits into
main
from
florentin.labelle/APPSEC-58014/scenario-for-lambda-python-api-gateway
Aug 20, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60a9891 to
37ead8a
Compare
a556702 to
1c39ec9
Compare
d00a7a0 to
7053105
Compare
7ab8293 to
90f59e3
Compare
christophe-papazian
approved these changes
Aug 6, 2025
b0f990a to
b23b513
Compare
11 tasks
6e1e64a to
9546648
Compare
9546648 to
219f30f
Compare
11 tasks
cbeauchesne
reviewed
Aug 21, 2025
| scenario_groups=[scenario_groups.appsec], | ||
| ) | ||
| appsec_lambda_api_security = LambdaScenario( | ||
| "APPSEC_LAMBDA_API_SECURITY", |
Collaborator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This scenario is not in the CI, so it's not tested
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
In the context of my internship, I am implementing Appsec for AWS Lambda through the python tracer to replace the current implementation which relies on the extension (the agent in the context of lambda).
The goal of this pull request is to be able to do end-to-end testing of the python tracer in the context of AWS Lambda.
To avoid relying on provisioning resources in AWS, I am attempting to emulate the AWS Lambda behaviour using a system-test Docker scenario.
A typical AWS Serverless deployment works with an AWS Managed Load Balancer such as APIGateway, ALB, or the Lambda Function Url service, the load balancer converts the incoming HTTP request to a json representation called an
Eventthat is passed to the AWS Lambda runtime to execute the function.graph LR A[Incoming HTTP Request] -->|HTTP| B[AWS Managed Load Balancer] B -->|event: request as JSON| C[AWS Lambda]AWS Provides the AWS Lambda Runtime Interface Emulator to simulate the Lambda runtime inside a Docker container and a cli to emulate a local APIGateway (AWS SAM cli).
Leveraging these two tools, we can envision a DockerScenario with the following architecture:
graph LR A[Incoming HTTP Request] -->|HTTP| B[LambdaProxy] B -->|event: request as JSON| C[LambdaWeblog]With the following components:
A specificity of this scenario is that the extension runs inside the LambdaWeblog because it needs access to the Lambda Runtime API, this requires the proxy to be able to send traces back to the weblog instead of sending them to a dedicated agent.
As a first step, this PR contains a single scenario to test Appsec capabilities for the APIGateway Rest API event type. The goal would be to eventually (in following PRs) emulate all other types of http events that a Lambda can receive: APIGateway HTTP API, Application Load Balancer, Lambda Function Url.
Changes
Additions:
LambdaProxyto relay system-test http request to invoke the Lambda Runtime InterfaceLambdaScenarioto orchestrate the two containers and configure the ProxyModifications:
LambdaScenario:appsec_lambda_deafultand add to it all appsec related tests of thedefaultscenarioWorkflow
🚀 Once your PR is reviewed and the CI green, you can merge it!
🛟 #apm-shared-testing 🛟
Reviewer checklist
[<language>], double-check that only<language>is impacted by the changebuild-XXX-imagelabel is present