mirror of
https://github.com/github/codeql.git
synced 2025-12-20 10:46:30 +01:00
python: add simple test for AWS lambda
made space for other serverless frameworks in the directory `serverless`
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
failures
|
||||
testFailures
|
||||
@@ -0,0 +1,20 @@
|
||||
import python
|
||||
import TestUtilities.InlineExpectationsTest
|
||||
|
||||
private module RemoteFlowTest implements TestSig {
|
||||
private import semmle.python.dataflow.new.RemoteFlowSources
|
||||
private import semmle.python.dataflow.new.internal.PrintNode
|
||||
|
||||
string getARelevantTag() { result = "remoteFlow" }
|
||||
|
||||
predicate hasActualResult(Location location, string element, string tag, string value) {
|
||||
exists(RemoteFlowSource source |
|
||||
location = source.getLocation() and
|
||||
tag = "remoteFlow" and
|
||||
value = prettyNode(source) and
|
||||
element = source.toString()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
import MakeTest<RemoteFlowTest>
|
||||
@@ -0,0 +1,5 @@
|
||||
def handler1(event, context): # $ MISSING: remoteFlow=event, remoteFlow=context
|
||||
return "Hello World!"
|
||||
|
||||
def handler2(event, context): # $ MISSING: remoteFlow=event, remoteFlow=context
|
||||
return "Hello World!"
|
||||
@@ -0,0 +1,2 @@
|
||||
def lambda_handler(event, context): # $ MISSING: remoteFlow=event, remoteFlow=context
|
||||
return "OK"
|
||||
@@ -0,0 +1,62 @@
|
||||
# inspired by https://github.com/awsdocs/aws-lambda-developer-guide/blob/main/sample-apps/blank-python/template.yml
|
||||
# but we have added extra handlers
|
||||
AWSTemplateFormatVersion: '2010-09-09'
|
||||
Transform: 'AWS::Serverless-2016-10-31'
|
||||
Description: An AWS Lambda application that calls the Lambda API.
|
||||
Resources:
|
||||
function:
|
||||
Type: AWS::Serverless::Function
|
||||
Properties:
|
||||
Handler: lambda_function.lambda_handler
|
||||
Runtime: python3.8
|
||||
CodeUri: function/.
|
||||
Description: Call the AWS Lambda API
|
||||
Timeout: 10
|
||||
# Function's execution role
|
||||
Policies:
|
||||
- AWSLambdaBasicExecutionRole
|
||||
- AWSLambda_ReadOnlyAccess
|
||||
- AWSXrayWriteOnlyAccess
|
||||
Tracing: Active
|
||||
Layers:
|
||||
- !Ref libs
|
||||
function:
|
||||
Type: AWS::Serverless::Function
|
||||
Properties:
|
||||
Handler: extra_lambdas.handler1
|
||||
Runtime: python3.8
|
||||
CodeUri: function/.
|
||||
Description: Call the AWS Lambda API
|
||||
Timeout: 10
|
||||
# Function's execution role
|
||||
Policies:
|
||||
- AWSLambdaBasicExecutionRole
|
||||
- AWSLambda_ReadOnlyAccess
|
||||
- AWSXrayWriteOnlyAccess
|
||||
Tracing: Active
|
||||
Layers:
|
||||
- !Ref libs
|
||||
function:
|
||||
Type: AWS::Serverless::Function
|
||||
Properties:
|
||||
Handler: extra_lambdas.handler2
|
||||
Runtime: python3.8
|
||||
CodeUri: function/.
|
||||
Description: Call the AWS Lambda API
|
||||
Timeout: 10
|
||||
# Function's execution role
|
||||
Policies:
|
||||
- AWSLambdaBasicExecutionRole
|
||||
- AWSLambda_ReadOnlyAccess
|
||||
- AWSXrayWriteOnlyAccess
|
||||
Tracing: Active
|
||||
Layers:
|
||||
- !Ref libs
|
||||
libs:
|
||||
Type: AWS::Serverless::LayerVersion
|
||||
Properties:
|
||||
LayerName: blank-python-lib
|
||||
Description: Dependencies for the blank-python sample app.
|
||||
ContentUri: package/.
|
||||
CompatibleRuntimes:
|
||||
- python3.8
|
||||
@@ -0,0 +1 @@
|
||||
semmle-extractor-options: -R .
|
||||
Reference in New Issue
Block a user