From 78a374960197d67aeb0f02c83005a87425331839 Mon Sep 17 00:00:00 2001 From: Mathew Payne Date: Wed, 10 May 2023 12:35:15 +0100 Subject: [PATCH 1/8] feat: Add Amazon Lambda testing stubs --- .../2.1.0/Amazon.Lambda.APIGatewayEvents.cs | 46 +++++++++++ .../Amazon.Lambda/2.1.0/Amazon.Lambda.Core.cs | 81 +++++++++++++++++++ .../Amazon.Lambda/2.1.0/Amazon.Lambda.csproj | 13 +++ 3 files changed, 140 insertions(+) create mode 100644 csharp/ql/test/resources/stubs/Amazon.Lambda/2.1.0/Amazon.Lambda.APIGatewayEvents.cs create mode 100644 csharp/ql/test/resources/stubs/Amazon.Lambda/2.1.0/Amazon.Lambda.Core.cs create mode 100644 csharp/ql/test/resources/stubs/Amazon.Lambda/2.1.0/Amazon.Lambda.csproj diff --git a/csharp/ql/test/resources/stubs/Amazon.Lambda/2.1.0/Amazon.Lambda.APIGatewayEvents.cs b/csharp/ql/test/resources/stubs/Amazon.Lambda/2.1.0/Amazon.Lambda.APIGatewayEvents.cs new file mode 100644 index 00000000000..22cf74a3420 --- /dev/null +++ b/csharp/ql/test/resources/stubs/Amazon.Lambda/2.1.0/Amazon.Lambda.APIGatewayEvents.cs @@ -0,0 +1,46 @@ + +using System; +using System.Collections.Generic; +using System.Text; + +namespace Amazon.Lambda.APIGatewayEvents +{ + public class APIGatewayHttpApiV2ProxyRequest + { + public string RawPath { get; set; } + + public string RawQueryString { get; set; } + + public string[] Cookies { get; set; } + + public IDictionary Headers { get; set; } + + public IDictionary QueryStringParameters { get; set; } + + public ProxyRequestContext RequestContext { get; set; } + + public string Body { get; set; } + + public IDictionary PathParameters { get; set; } + + public bool IsBase64Encoded { get; set; } + + public IDictionary StageVariables { get; set; } + + public class ProxyRequestContext + { + public string AccountId { get; set; } + + public string ApiId { get; set; } + } + } + + public class APIGatewayProxyResponse + { + public int StatusCode { get; set; } + + public IDictionary Headers { get; set; } + + public string Body { get; set; } + } +} diff --git a/csharp/ql/test/resources/stubs/Amazon.Lambda/2.1.0/Amazon.Lambda.Core.cs b/csharp/ql/test/resources/stubs/Amazon.Lambda/2.1.0/Amazon.Lambda.Core.cs new file mode 100644 index 00000000000..60d6854f93a --- /dev/null +++ b/csharp/ql/test/resources/stubs/Amazon.Lambda/2.1.0/Amazon.Lambda.Core.cs @@ -0,0 +1,81 @@ + +using System.Collections.Generic; + +namespace Amazon.Lambda.Core +{ + public interface ILambdaContext + { + string AwsRequestId { get; } + + IClientContext ClientContext { get; } + + string FunctionName { get; } + + string FunctionVersion { get; } + + string InvokedFunctionArn { get; } + + ILambdaLogger Logger { get; } + + string LogGroupName { get; } + + string LogStreamName { get; } + + int MemoryLimitInMB { get; } + } + + public interface IClientContext + { + IDictionary Environment { get; } + + IClientApplication Client { get; } + + IDictionary Custom { get; } + } + + public interface IClientApplication + { + string AppPackageName { get; } + + string AppTitle { get; } + + string AppVersionCode { get; } + + string AppVersionName { get; } + + string InstallationId { get; } + } + + public enum LogLevel + { + Trace = 0, + Debug = 1, + Information = 2, + Warning = 3, + Error = 4, + Critical = 5 + } + + public interface ILambdaLogger + { + void Log(string message); + + void LogLine(string message); + + void Log(string level, string message) => throw null; + + void Log(LogLevel level, string message) => throw null; + + void LogTrace(string message) => throw null; + + void LogDebug(string message) => throw null; + + void LogInformation(string message) => throw null; + + void LogWarning(string message) => throw null; + + void LogError(string message) => throw null; + + void LogCritical(string message) => throw null; + } +} \ No newline at end of file diff --git a/csharp/ql/test/resources/stubs/Amazon.Lambda/2.1.0/Amazon.Lambda.csproj b/csharp/ql/test/resources/stubs/Amazon.Lambda/2.1.0/Amazon.Lambda.csproj new file mode 100644 index 00000000000..2a636095b51 --- /dev/null +++ b/csharp/ql/test/resources/stubs/Amazon.Lambda/2.1.0/Amazon.Lambda.csproj @@ -0,0 +1,13 @@ + + + net7.0 + enable + enable + true + Lambda + + true + + true + + \ No newline at end of file From 2f5cb1ab295513412a452ae07809577f58839df6 Mon Sep 17 00:00:00 2001 From: Mathew Payne Date: Wed, 10 May 2023 12:36:15 +0100 Subject: [PATCH 2/8] feat: Add initial tests for AWS Lambda support --- .../library-tests/frameworks/Aws/lambda.cs | 27 +++++++++++++++++++ .../library-tests/frameworks/Aws/lambda.ql | 4 +++ .../test/library-tests/frameworks/Aws/options | 1 + 3 files changed, 32 insertions(+) create mode 100644 csharp/ql/test/library-tests/frameworks/Aws/lambda.cs create mode 100644 csharp/ql/test/library-tests/frameworks/Aws/lambda.ql create mode 100644 csharp/ql/test/library-tests/frameworks/Aws/options diff --git a/csharp/ql/test/library-tests/frameworks/Aws/lambda.cs b/csharp/ql/test/library-tests/frameworks/Aws/lambda.cs new file mode 100644 index 00000000000..3e01d048ca1 --- /dev/null +++ b/csharp/ql/test/library-tests/frameworks/Aws/lambda.cs @@ -0,0 +1,27 @@ +using System.Net; +using System.Collections.Generic; + +using Amazon.Lambda.Core; +using Amazon.Lambda.APIGatewayEvents; + + +namespace LambdaTests { + public class Functions { + public APIGatewayProxyResponse Get(APIGatewayHttpApiV2ProxyRequest request, ILambdaContext context) { + string body = request.Body; // source + string cookie = request.Cookies[0]; // source + + string rawpath = request.RawPath; // source + string rawquery = request.RawQueryString; // source + request.PathParameters.TryGetValue("x", out var pathparameter); // source + + string header = request.Headers["test"]; // source + request.Headers.TryGetValue("test", out var header2); // source + + + return new APIGatewayProxyResponse { + StatusCode = 200 + }; + } + } +} \ No newline at end of file diff --git a/csharp/ql/test/library-tests/frameworks/Aws/lambda.ql b/csharp/ql/test/library-tests/frameworks/Aws/lambda.ql new file mode 100644 index 00000000000..44230402f32 --- /dev/null +++ b/csharp/ql/test/library-tests/frameworks/Aws/lambda.ql @@ -0,0 +1,4 @@ +import csharp +import semmle.code.csharp.dataflow.ExternalFlow + +query predicate awsRemoteSources(DataFlow::ExprNode node) { sourceNode(node, "remote") } diff --git a/csharp/ql/test/library-tests/frameworks/Aws/options b/csharp/ql/test/library-tests/frameworks/Aws/options new file mode 100644 index 00000000000..93914ab6418 --- /dev/null +++ b/csharp/ql/test/library-tests/frameworks/Aws/options @@ -0,0 +1 @@ +semmle-extractor-options: --load-sources-from-project:${testdir}/../../../resources/stubs/Amazon.Lambda/2.1.0/Amazon.Lambda.csproj \ No newline at end of file From 6c138ae48508a35caf3ab7ffae6af24a3734fc13 Mon Sep 17 00:00:00 2001 From: Mathew Payne Date: Wed, 10 May 2023 12:36:42 +0100 Subject: [PATCH 3/8] feat: Add models and expected --- csharp/ql/lib/ext/Amazon.Lambda.model.yml | 21 +++++++++++++++++++ .../frameworks/Aws/lambda.expected | 7 +++++++ 2 files changed, 28 insertions(+) create mode 100644 csharp/ql/lib/ext/Amazon.Lambda.model.yml create mode 100644 csharp/ql/test/library-tests/frameworks/Aws/lambda.expected diff --git a/csharp/ql/lib/ext/Amazon.Lambda.model.yml b/csharp/ql/lib/ext/Amazon.Lambda.model.yml new file mode 100644 index 00000000000..c7fd9376b3f --- /dev/null +++ b/csharp/ql/lib/ext/Amazon.Lambda.model.yml @@ -0,0 +1,21 @@ +extensions: + - addsTo: + pack: codeql/csharp-all + extensible: sourceModel + data: + - ["Amazon.Lambda.APIGatewayEvents","APIGatewayHttpApiV2ProxyRequest",true,"get_Headers","()","","ReturnValue","remote","manual"] + - ["Amazon.Lambda.APIGatewayEvents","APIGatewayHttpApiV2ProxyRequest",true,"get_Body","()","","ReturnValue","remote","manual"] + - ["Amazon.Lambda.APIGatewayEvents","APIGatewayHttpApiV2ProxyRequest",true,"get_RawPath","()","","ReturnValue","remote","manual"] + - ["Amazon.Lambda.APIGatewayEvents","APIGatewayHttpApiV2ProxyRequest",true,"get_RawQueryString","()","","ReturnValue","remote","manual"] + - ["Amazon.Lambda.APIGatewayEvents","APIGatewayHttpApiV2ProxyRequest",true,"get_Cookies","()","","ReturnValue","remote","manual"] + - ["Amazon.Lambda.APIGatewayEvents","APIGatewayHttpApiV2ProxyRequest",true,"get_PathParameters","()","","ReturnValue","remote","manual"] + + - addsTo: + pack: codeql/csharp-all + extensible: sinkModel + data: [] + + - addsTo: + pack: codeql/csharp-all + extensible: summaryModel + data: [] diff --git a/csharp/ql/test/library-tests/frameworks/Aws/lambda.expected b/csharp/ql/test/library-tests/frameworks/Aws/lambda.expected new file mode 100644 index 00000000000..fdda60649fb --- /dev/null +++ b/csharp/ql/test/library-tests/frameworks/Aws/lambda.expected @@ -0,0 +1,7 @@ +| lambda.cs:11:27:11:38 | access to property Body | +| lambda.cs:12:29:12:43 | access to property Cookies | +| lambda.cs:14:30:14:44 | access to property RawPath | +| lambda.cs:15:31:15:52 | access to property RawQueryString | +| lambda.cs:16:13:16:34 | access to property PathParameters | +| lambda.cs:18:29:18:43 | access to property Headers | +| lambda.cs:19:13:19:27 | access to property Headers | From 2e0ac264e7866c23f8cd141907c76baf6060e900 Mon Sep 17 00:00:00 2001 From: Mathew Payne Date: Wed, 10 May 2023 14:15:58 +0100 Subject: [PATCH 4/8] feat: Add AWS Lambda logging --- csharp/ql/lib/ext/Amazon.Lambda.model.yml | 12 +++++++++++- .../test/library-tests/frameworks/Aws/lambda.cs | 15 +++++++++++++++ .../library-tests/frameworks/Aws/lambda.expected | 12 ++++++++++++ .../test/library-tests/frameworks/Aws/lambda.ql | 2 ++ 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/csharp/ql/lib/ext/Amazon.Lambda.model.yml b/csharp/ql/lib/ext/Amazon.Lambda.model.yml index c7fd9376b3f..a80c99ff687 100644 --- a/csharp/ql/lib/ext/Amazon.Lambda.model.yml +++ b/csharp/ql/lib/ext/Amazon.Lambda.model.yml @@ -13,7 +13,17 @@ extensions: - addsTo: pack: codeql/csharp-all extensible: sinkModel - data: [] + data: + - ["Amazon.Lambda.Core","ILambdaLogger",true,"Log","(System.String)","","Argument[0]","log-injection","manual"] + - ["Amazon.Lambda.Core","ILambdaLogger",true,"LogLine","(System.String)","","Argument[0]","log-injection","manual"] + - ["Amazon.Lambda.Core","ILambdaLogger",true,"LogTrace","(System.String)","","Argument[0]","log-injection","manual"] + - ["Amazon.Lambda.Core","ILambdaLogger",true,"LogDebug","(System.String)","","Argument[0]","log-injection","manual"] + - ["Amazon.Lambda.Core","ILambdaLogger",true,"LogInformation","(System.String)","","Argument[0]","log-injection","manual"] + - ["Amazon.Lambda.Core","ILambdaLogger",true,"LogWarning","(System.String)","","Argument[0]","log-injection","manual"] + - ["Amazon.Lambda.Core","ILambdaLogger",true,"LogError","(System.String)","","Argument[0]","log-injection","manual"] + - ["Amazon.Lambda.Core","ILambdaLogger",true,"LogCritical","(System.String)","","Argument[0]","log-injection","manual"] + - ["Amazon.Lambda.Core","ILambdaLogger",true,"Log","(System.String,System.String)","","Argument[1]","log-injection","manual"] + - ["Amazon.Lambda.Core","ILambdaLogger",true,"Log","(Amazon.Lambda.Core.LogLevel,System.String)","","Argument[1]","log-injection","manual"] - addsTo: pack: codeql/csharp-all diff --git a/csharp/ql/test/library-tests/frameworks/Aws/lambda.cs b/csharp/ql/test/library-tests/frameworks/Aws/lambda.cs index 3e01d048ca1..eb8cf9a7e05 100644 --- a/csharp/ql/test/library-tests/frameworks/Aws/lambda.cs +++ b/csharp/ql/test/library-tests/frameworks/Aws/lambda.cs @@ -23,5 +23,20 @@ namespace LambdaTests { StatusCode = 200 }; } + + public void Logging(ILambdaContext context, string data) + { + // logging + context.Logger.Log($"Log Data :: {data}"); + context.Logger.LogLine($"Log Data :: {data}"); + context.Logger.Log("Information", $"Log Data :: {data}"); + context.Logger.Log(LogLevel.Information, $"Log Data :: {data}"); + context.Logger.LogTrace($"Log Data :: {data}"); + context.Logger.LogDebug($"Log Data :: {data}"); + context.Logger.LogInformation($"Log Data :: {data}"); + context.Logger.LogWarning($"Log Data :: {data}"); + context.Logger.LogError($"Log Data :: {data}"); + context.Logger.LogCritical($"Log Data :: {data}"); + } } } \ No newline at end of file diff --git a/csharp/ql/test/library-tests/frameworks/Aws/lambda.expected b/csharp/ql/test/library-tests/frameworks/Aws/lambda.expected index fdda60649fb..999370e89d1 100644 --- a/csharp/ql/test/library-tests/frameworks/Aws/lambda.expected +++ b/csharp/ql/test/library-tests/frameworks/Aws/lambda.expected @@ -1,3 +1,4 @@ +awsRemoteSources | lambda.cs:11:27:11:38 | access to property Body | | lambda.cs:12:29:12:43 | access to property Cookies | | lambda.cs:14:30:14:44 | access to property RawPath | @@ -5,3 +6,14 @@ | lambda.cs:16:13:16:34 | access to property PathParameters | | lambda.cs:18:29:18:43 | access to property Headers | | lambda.cs:19:13:19:27 | access to property Headers | +awsLoggingSinks +| lambda.cs:30:32:30:52 | $"..." | +| lambda.cs:31:36:31:56 | $"..." | +| lambda.cs:32:47:32:67 | $"..." | +| lambda.cs:33:54:33:74 | $"..." | +| lambda.cs:34:37:34:57 | $"..." | +| lambda.cs:35:37:35:57 | $"..." | +| lambda.cs:36:43:36:63 | $"..." | +| lambda.cs:37:39:37:59 | $"..." | +| lambda.cs:38:37:38:57 | $"..." | +| lambda.cs:39:40:39:60 | $"..." | diff --git a/csharp/ql/test/library-tests/frameworks/Aws/lambda.ql b/csharp/ql/test/library-tests/frameworks/Aws/lambda.ql index 44230402f32..9d3597a4e9f 100644 --- a/csharp/ql/test/library-tests/frameworks/Aws/lambda.ql +++ b/csharp/ql/test/library-tests/frameworks/Aws/lambda.ql @@ -2,3 +2,5 @@ import csharp import semmle.code.csharp.dataflow.ExternalFlow query predicate awsRemoteSources(DataFlow::ExprNode node) { sourceNode(node, "remote") } + +query predicate awsLoggingSinks(DataFlow::ExprNode node) { sinkNode(node, "log-injection") } From f336ff0063920e9f32d2e73638726dbfc4bf34cd Mon Sep 17 00:00:00 2001 From: Mathew Payne Date: Thu, 22 Jun 2023 17:01:07 +0100 Subject: [PATCH 5/8] Add change notes --- csharp/ql/lib/change-notes/2023-06-22-aws-lambda-models.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 csharp/ql/lib/change-notes/2023-06-22-aws-lambda-models.md diff --git a/csharp/ql/lib/change-notes/2023-06-22-aws-lambda-models.md b/csharp/ql/lib/change-notes/2023-06-22-aws-lambda-models.md new file mode 100644 index 00000000000..9943af0797f --- /dev/null +++ b/csharp/ql/lib/change-notes/2023-06-22-aws-lambda-models.md @@ -0,0 +1,4 @@ +--- +category: minorAnalysis +--- +* Additional support for `Amazon.Lambda` SDK \ No newline at end of file From fa4f91988f3cfbd468e8a5fdfbad9da05c50da9f Mon Sep 17 00:00:00 2001 From: Michael Nebel Date: Mon, 27 Nov 2023 14:09:12 +0100 Subject: [PATCH 6/8] C#: Add autogenerated stubs for Aws.Lambda.Core and Aws.Lambda.APIGatewayEvents. --- .../2.7.0/Amazon.Lambda.APIGatewayEvents.cs | 282 ++++++++++++++++++ .../Amazon.Lambda.APIGatewayEvents.csproj | 12 + .../2.2.0/Amazon.Lambda.Core.cs | 81 +++++ .../2.2.0/Amazon.Lambda.Core.csproj | 12 + .../2.1.0/Amazon.Lambda.APIGatewayEvents.cs | 46 --- .../Amazon.Lambda/2.1.0/Amazon.Lambda.Core.cs | 81 ----- .../Amazon.Lambda/2.1.0/Amazon.Lambda.csproj | 13 - 7 files changed, 387 insertions(+), 140 deletions(-) create mode 100644 csharp/ql/test/resources/stubs/Amazon.Lambda.APIGatewayEvents/2.7.0/Amazon.Lambda.APIGatewayEvents.cs create mode 100644 csharp/ql/test/resources/stubs/Amazon.Lambda.APIGatewayEvents/2.7.0/Amazon.Lambda.APIGatewayEvents.csproj create mode 100644 csharp/ql/test/resources/stubs/Amazon.Lambda.Core/2.2.0/Amazon.Lambda.Core.cs create mode 100644 csharp/ql/test/resources/stubs/Amazon.Lambda.Core/2.2.0/Amazon.Lambda.Core.csproj delete mode 100644 csharp/ql/test/resources/stubs/Amazon.Lambda/2.1.0/Amazon.Lambda.APIGatewayEvents.cs delete mode 100644 csharp/ql/test/resources/stubs/Amazon.Lambda/2.1.0/Amazon.Lambda.Core.cs delete mode 100644 csharp/ql/test/resources/stubs/Amazon.Lambda/2.1.0/Amazon.Lambda.csproj diff --git a/csharp/ql/test/resources/stubs/Amazon.Lambda.APIGatewayEvents/2.7.0/Amazon.Lambda.APIGatewayEvents.cs b/csharp/ql/test/resources/stubs/Amazon.Lambda.APIGatewayEvents/2.7.0/Amazon.Lambda.APIGatewayEvents.cs new file mode 100644 index 00000000000..5cebdcec1fa --- /dev/null +++ b/csharp/ql/test/resources/stubs/Amazon.Lambda.APIGatewayEvents/2.7.0/Amazon.Lambda.APIGatewayEvents.cs @@ -0,0 +1,282 @@ +// This file contains auto-generated code. +// Generated from `Amazon.Lambda.APIGatewayEvents, Version=1.0.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604`. +namespace Amazon +{ + namespace Lambda + { + namespace APIGatewayEvents + { + public class APIGatewayCustomAuthorizerContext : System.Collections.Generic.Dictionary + { + public bool? BoolKey { get => throw null; set { } } + public System.Collections.Generic.Dictionary Claims { get => throw null; set { } } + public APIGatewayCustomAuthorizerContext() => throw null; + public int? NumKey { get => throw null; set { } } + public string PrincipalId { get => throw null; set { } } + public string StringKey { get => throw null; set { } } + } + public class APIGatewayCustomAuthorizerContextOutput : System.Collections.Generic.Dictionary + { + public bool? BoolKey { get => throw null; set { } } + public APIGatewayCustomAuthorizerContextOutput() => throw null; + public int? NumKey { get => throw null; set { } } + public string StringKey { get => throw null; set { } } + } + public class APIGatewayCustomAuthorizerPolicy + { + public APIGatewayCustomAuthorizerPolicy() => throw null; + public class IAMPolicyStatement + { + public System.Collections.Generic.HashSet Action { get => throw null; set { } } + public IAMPolicyStatement() => throw null; + public string Effect { get => throw null; set { } } + public System.Collections.Generic.HashSet Resource { get => throw null; set { } } + } + public System.Collections.Generic.List Statement { get => throw null; set { } } + public string Version { get => throw null; set { } } + } + public class APIGatewayCustomAuthorizerRequest + { + public string AuthorizationToken { get => throw null; set { } } + public APIGatewayCustomAuthorizerRequest() => throw null; + public System.Collections.Generic.IDictionary Headers { get => throw null; set { } } + public string HttpMethod { get => throw null; set { } } + public string MethodArn { get => throw null; set { } } + public string Path { get => throw null; set { } } + public System.Collections.Generic.IDictionary PathParameters { get => throw null; set { } } + public System.Collections.Generic.IDictionary QueryStringParameters { get => throw null; set { } } + public Amazon.Lambda.APIGatewayEvents.APIGatewayProxyRequest.ProxyRequestContext RequestContext { get => throw null; set { } } + public System.Collections.Generic.IDictionary StageVariables { get => throw null; set { } } + public string Type { get => throw null; set { } } + } + public class APIGatewayCustomAuthorizerResponse + { + public Amazon.Lambda.APIGatewayEvents.APIGatewayCustomAuthorizerContextOutput Context { get => throw null; set { } } + public APIGatewayCustomAuthorizerResponse() => throw null; + public Amazon.Lambda.APIGatewayEvents.APIGatewayCustomAuthorizerPolicy PolicyDocument { get => throw null; set { } } + public string PrincipalID { get => throw null; set { } } + public string UsageIdentifierKey { get => throw null; set { } } + } + public class APIGatewayCustomAuthorizerV2IamResponse + { + public System.Collections.Generic.Dictionary Context { get => throw null; set { } } + public APIGatewayCustomAuthorizerV2IamResponse() => throw null; + public Amazon.Lambda.APIGatewayEvents.APIGatewayCustomAuthorizerPolicy PolicyDocument { get => throw null; set { } } + public string PrincipalID { get => throw null; set { } } + } + public class APIGatewayCustomAuthorizerV2Request + { + public System.Collections.Generic.List Cookies { get => throw null; set { } } + public APIGatewayCustomAuthorizerV2Request() => throw null; + public System.Collections.Generic.Dictionary Headers { get => throw null; set { } } + public System.Collections.Generic.List IdentitySource { get => throw null; set { } } + public System.Collections.Generic.Dictionary PathParameters { get => throw null; set { } } + public System.Collections.Generic.Dictionary QueryStringParameters { get => throw null; set { } } + public string RawPath { get => throw null; set { } } + public string RawQueryString { get => throw null; set { } } + public Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyRequest.ProxyRequestContext RequestContext { get => throw null; set { } } + public string RouteArn { get => throw null; set { } } + public string RouteKey { get => throw null; set { } } + public System.Collections.Generic.Dictionary StageVariables { get => throw null; set { } } + public string Type { get => throw null; set { } } + } + public class APIGatewayCustomAuthorizerV2SimpleResponse + { + public System.Collections.Generic.Dictionary Context { get => throw null; set { } } + public APIGatewayCustomAuthorizerV2SimpleResponse() => throw null; + public bool IsAuthorized { get => throw null; set { } } + } + public class APIGatewayHttpApiV2ProxyRequest + { + public class AuthorizerDescription + { + public class CognitoIdentityDescription + { + public System.Collections.Generic.IList AMR { get => throw null; set { } } + public CognitoIdentityDescription() => throw null; + public string IdentityId { get => throw null; set { } } + public string IdentityPoolId { get => throw null; set { } } + } + public AuthorizerDescription() => throw null; + public Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyRequest.AuthorizerDescription.IAMDescription IAM { get => throw null; set { } } + public class IAMDescription + { + public string AccessKey { get => throw null; set { } } + public string AccountId { get => throw null; set { } } + public string CallerId { get => throw null; set { } } + public Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyRequest.AuthorizerDescription.CognitoIdentityDescription CognitoIdentity { get => throw null; set { } } + public IAMDescription() => throw null; + public string PrincipalOrgId { get => throw null; set { } } + public string UserARN { get => throw null; set { } } + public string UserId { get => throw null; set { } } + } + public Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyRequest.AuthorizerDescription.JwtDescription Jwt { get => throw null; set { } } + public class JwtDescription + { + public System.Collections.Generic.IDictionary Claims { get => throw null; set { } } + public JwtDescription() => throw null; + public string[] Scopes { get => throw null; set { } } + } + public System.Collections.Generic.IDictionary Lambda { get => throw null; set { } } + } + public string Body { get => throw null; set { } } + public class ClientCertValidity + { + public ClientCertValidity() => throw null; + public string NotAfter { get => throw null; set { } } + public string NotBefore { get => throw null; set { } } + } + public string[] Cookies { get => throw null; set { } } + public APIGatewayHttpApiV2ProxyRequest() => throw null; + public System.Collections.Generic.IDictionary Headers { get => throw null; set { } } + public class HttpDescription + { + public HttpDescription() => throw null; + public string Method { get => throw null; set { } } + public string Path { get => throw null; set { } } + public string Protocol { get => throw null; set { } } + public string SourceIp { get => throw null; set { } } + public string UserAgent { get => throw null; set { } } + } + public bool IsBase64Encoded { get => throw null; set { } } + public System.Collections.Generic.IDictionary PathParameters { get => throw null; set { } } + public class ProxyRequestAuthentication + { + public Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyRequest.ProxyRequestClientCert ClientCert { get => throw null; set { } } + public ProxyRequestAuthentication() => throw null; + } + public class ProxyRequestClientCert + { + public string ClientCertPem { get => throw null; set { } } + public ProxyRequestClientCert() => throw null; + public string IssuerDN { get => throw null; set { } } + public string SerialNumber { get => throw null; set { } } + public string SubjectDN { get => throw null; set { } } + public Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyRequest.ClientCertValidity Validity { get => throw null; set { } } + } + public class ProxyRequestContext + { + public string AccountId { get => throw null; set { } } + public string ApiId { get => throw null; set { } } + public Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyRequest.ProxyRequestAuthentication Authentication { get => throw null; set { } } + public Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyRequest.AuthorizerDescription Authorizer { get => throw null; set { } } + public ProxyRequestContext() => throw null; + public string DomainName { get => throw null; set { } } + public string DomainPrefix { get => throw null; set { } } + public Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyRequest.HttpDescription Http { get => throw null; set { } } + public string RequestId { get => throw null; set { } } + public string RouteId { get => throw null; set { } } + public string RouteKey { get => throw null; set { } } + public string Stage { get => throw null; set { } } + public string Time { get => throw null; set { } } + public long TimeEpoch { get => throw null; set { } } + } + public System.Collections.Generic.IDictionary QueryStringParameters { get => throw null; set { } } + public string RawPath { get => throw null; set { } } + public string RawQueryString { get => throw null; set { } } + public Amazon.Lambda.APIGatewayEvents.APIGatewayHttpApiV2ProxyRequest.ProxyRequestContext RequestContext { get => throw null; set { } } + public string RouteKey { get => throw null; set { } } + public System.Collections.Generic.IDictionary StageVariables { get => throw null; set { } } + public string Version { get => throw null; set { } } + } + public class APIGatewayHttpApiV2ProxyResponse + { + public string Body { get => throw null; set { } } + public string[] Cookies { get => throw null; set { } } + public APIGatewayHttpApiV2ProxyResponse() => throw null; + public System.Collections.Generic.IDictionary Headers { get => throw null; set { } } + public bool IsBase64Encoded { get => throw null; set { } } + public void SetHeaderValues(string headerName, string value, bool append) => throw null; + public void SetHeaderValues(string headerName, System.Collections.Generic.IEnumerable values, bool append) => throw null; + public int StatusCode { get => throw null; set { } } + } + public class APIGatewayProxyRequest + { + public string Body { get => throw null; set { } } + public class ClientCertValidity + { + public ClientCertValidity() => throw null; + public string NotAfter { get => throw null; set { } } + public string NotBefore { get => throw null; set { } } + } + public APIGatewayProxyRequest() => throw null; + public System.Collections.Generic.IDictionary Headers { get => throw null; set { } } + public string HttpMethod { get => throw null; set { } } + public bool IsBase64Encoded { get => throw null; set { } } + public System.Collections.Generic.IDictionary> MultiValueHeaders { get => throw null; set { } } + public System.Collections.Generic.IDictionary> MultiValueQueryStringParameters { get => throw null; set { } } + public string Path { get => throw null; set { } } + public System.Collections.Generic.IDictionary PathParameters { get => throw null; set { } } + public class ProxyRequestClientCert + { + public string ClientCertPem { get => throw null; set { } } + public ProxyRequestClientCert() => throw null; + public string IssuerDN { get => throw null; set { } } + public string SerialNumber { get => throw null; set { } } + public string SubjectDN { get => throw null; set { } } + public Amazon.Lambda.APIGatewayEvents.APIGatewayProxyRequest.ClientCertValidity Validity { get => throw null; set { } } + } + public class ProxyRequestContext + { + public string AccountId { get => throw null; set { } } + public string ApiId { get => throw null; set { } } + public Amazon.Lambda.APIGatewayEvents.APIGatewayCustomAuthorizerContext Authorizer { get => throw null; set { } } + public long ConnectedAt { get => throw null; set { } } + public string ConnectionId { get => throw null; set { } } + public ProxyRequestContext() => throw null; + public string DomainName { get => throw null; set { } } + public string DomainPrefix { get => throw null; set { } } + public string Error { get => throw null; set { } } + public string EventType { get => throw null; set { } } + public string ExtendedRequestId { get => throw null; set { } } + public string HttpMethod { get => throw null; set { } } + public Amazon.Lambda.APIGatewayEvents.APIGatewayProxyRequest.RequestIdentity Identity { get => throw null; set { } } + public string IntegrationLatency { get => throw null; set { } } + public string MessageDirection { get => throw null; set { } } + public string MessageId { get => throw null; set { } } + public string OperationName { get => throw null; set { } } + public string Path { get => throw null; set { } } + public string RequestId { get => throw null; set { } } + public string RequestTime { get => throw null; set { } } + public long RequestTimeEpoch { get => throw null; set { } } + public string ResourceId { get => throw null; set { } } + public string ResourcePath { get => throw null; set { } } + public string RouteKey { get => throw null; set { } } + public string Stage { get => throw null; set { } } + public string Status { get => throw null; set { } } + } + public System.Collections.Generic.IDictionary QueryStringParameters { get => throw null; set { } } + public Amazon.Lambda.APIGatewayEvents.APIGatewayProxyRequest.ProxyRequestContext RequestContext { get => throw null; set { } } + public class RequestIdentity + { + public string AccessKey { get => throw null; set { } } + public string AccountId { get => throw null; set { } } + public string ApiKey { get => throw null; set { } } + public string ApiKeyId { get => throw null; set { } } + public string Caller { get => throw null; set { } } + public Amazon.Lambda.APIGatewayEvents.APIGatewayProxyRequest.ProxyRequestClientCert ClientCert { get => throw null; set { } } + public string CognitoAuthenticationProvider { get => throw null; set { } } + public string CognitoAuthenticationType { get => throw null; set { } } + public string CognitoIdentityId { get => throw null; set { } } + public string CognitoIdentityPoolId { get => throw null; set { } } + public RequestIdentity() => throw null; + public string SourceIp { get => throw null; set { } } + public string User { get => throw null; set { } } + public string UserAgent { get => throw null; set { } } + public string UserArn { get => throw null; set { } } + } + public string Resource { get => throw null; set { } } + public System.Collections.Generic.IDictionary StageVariables { get => throw null; set { } } + } + public class APIGatewayProxyResponse + { + public string Body { get => throw null; set { } } + public APIGatewayProxyResponse() => throw null; + public System.Collections.Generic.IDictionary Headers { get => throw null; set { } } + public bool IsBase64Encoded { get => throw null; set { } } + public System.Collections.Generic.IDictionary> MultiValueHeaders { get => throw null; set { } } + public int StatusCode { get => throw null; set { } } + } + } + } +} diff --git a/csharp/ql/test/resources/stubs/Amazon.Lambda.APIGatewayEvents/2.7.0/Amazon.Lambda.APIGatewayEvents.csproj b/csharp/ql/test/resources/stubs/Amazon.Lambda.APIGatewayEvents/2.7.0/Amazon.Lambda.APIGatewayEvents.csproj new file mode 100644 index 00000000000..dffed49d346 --- /dev/null +++ b/csharp/ql/test/resources/stubs/Amazon.Lambda.APIGatewayEvents/2.7.0/Amazon.Lambda.APIGatewayEvents.csproj @@ -0,0 +1,12 @@ + + + net7.0 + true + bin\ + false + + + + + + diff --git a/csharp/ql/test/resources/stubs/Amazon.Lambda.Core/2.2.0/Amazon.Lambda.Core.cs b/csharp/ql/test/resources/stubs/Amazon.Lambda.Core/2.2.0/Amazon.Lambda.Core.cs new file mode 100644 index 00000000000..4a8928822a1 --- /dev/null +++ b/csharp/ql/test/resources/stubs/Amazon.Lambda.Core/2.2.0/Amazon.Lambda.Core.cs @@ -0,0 +1,81 @@ +// This file contains auto-generated code. +// Generated from `Amazon.Lambda.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604`. +namespace Amazon +{ + namespace Lambda + { + namespace Core + { + public interface IClientApplication + { + string AppPackageName { get; } + string AppTitle { get; } + string AppVersionCode { get; } + string AppVersionName { get; } + string InstallationId { get; } + } + public interface IClientContext + { + Amazon.Lambda.Core.IClientApplication Client { get; } + System.Collections.Generic.IDictionary Custom { get; } + System.Collections.Generic.IDictionary Environment { get; } + } + public interface ICognitoIdentity + { + string IdentityId { get; } + string IdentityPoolId { get; } + } + public interface ILambdaContext + { + string AwsRequestId { get; } + Amazon.Lambda.Core.IClientContext ClientContext { get; } + string FunctionName { get; } + string FunctionVersion { get; } + Amazon.Lambda.Core.ICognitoIdentity Identity { get; } + string InvokedFunctionArn { get; } + Amazon.Lambda.Core.ILambdaLogger Logger { get; } + string LogGroupName { get; } + string LogStreamName { get; } + int MemoryLimitInMB { get; } + System.TimeSpan RemainingTime { get; } + } + public interface ILambdaLogger + { + void Log(string message); + virtual void Log(string level, string message) => throw null; + virtual void Log(Amazon.Lambda.Core.LogLevel level, string message) => throw null; + virtual void LogCritical(string message) => throw null; + virtual void LogDebug(string message) => throw null; + virtual void LogError(string message) => throw null; + virtual void LogInformation(string message) => throw null; + void LogLine(string message); + virtual void LogTrace(string message) => throw null; + virtual void LogWarning(string message) => throw null; + } + public interface ILambdaSerializer + { + T Deserialize(System.IO.Stream requestStream); + void Serialize(T response, System.IO.Stream responseStream); + } + public static class LambdaLogger + { + public static void Log(string message) => throw null; + } + [System.AttributeUsage((System.AttributeTargets)65, AllowMultiple = false)] + public sealed class LambdaSerializerAttribute : System.Attribute + { + public LambdaSerializerAttribute(System.Type serializerType) => throw null; + public System.Type SerializerType { get => throw null; set { } } + } + public enum LogLevel + { + Trace = 0, + Debug = 1, + Information = 2, + Warning = 3, + Error = 4, + Critical = 5, + } + } + } +} diff --git a/csharp/ql/test/resources/stubs/Amazon.Lambda.Core/2.2.0/Amazon.Lambda.Core.csproj b/csharp/ql/test/resources/stubs/Amazon.Lambda.Core/2.2.0/Amazon.Lambda.Core.csproj new file mode 100644 index 00000000000..dffed49d346 --- /dev/null +++ b/csharp/ql/test/resources/stubs/Amazon.Lambda.Core/2.2.0/Amazon.Lambda.Core.csproj @@ -0,0 +1,12 @@ + + + net7.0 + true + bin\ + false + + + + + + diff --git a/csharp/ql/test/resources/stubs/Amazon.Lambda/2.1.0/Amazon.Lambda.APIGatewayEvents.cs b/csharp/ql/test/resources/stubs/Amazon.Lambda/2.1.0/Amazon.Lambda.APIGatewayEvents.cs deleted file mode 100644 index 22cf74a3420..00000000000 --- a/csharp/ql/test/resources/stubs/Amazon.Lambda/2.1.0/Amazon.Lambda.APIGatewayEvents.cs +++ /dev/null @@ -1,46 +0,0 @@ - -using System; -using System.Collections.Generic; -using System.Text; - -namespace Amazon.Lambda.APIGatewayEvents -{ - public class APIGatewayHttpApiV2ProxyRequest - { - public string RawPath { get; set; } - - public string RawQueryString { get; set; } - - public string[] Cookies { get; set; } - - public IDictionary Headers { get; set; } - - public IDictionary QueryStringParameters { get; set; } - - public ProxyRequestContext RequestContext { get; set; } - - public string Body { get; set; } - - public IDictionary PathParameters { get; set; } - - public bool IsBase64Encoded { get; set; } - - public IDictionary StageVariables { get; set; } - - public class ProxyRequestContext - { - public string AccountId { get; set; } - - public string ApiId { get; set; } - } - } - - public class APIGatewayProxyResponse - { - public int StatusCode { get; set; } - - public IDictionary Headers { get; set; } - - public string Body { get; set; } - } -} diff --git a/csharp/ql/test/resources/stubs/Amazon.Lambda/2.1.0/Amazon.Lambda.Core.cs b/csharp/ql/test/resources/stubs/Amazon.Lambda/2.1.0/Amazon.Lambda.Core.cs deleted file mode 100644 index 60d6854f93a..00000000000 --- a/csharp/ql/test/resources/stubs/Amazon.Lambda/2.1.0/Amazon.Lambda.Core.cs +++ /dev/null @@ -1,81 +0,0 @@ - -using System.Collections.Generic; - -namespace Amazon.Lambda.Core -{ - public interface ILambdaContext - { - string AwsRequestId { get; } - - IClientContext ClientContext { get; } - - string FunctionName { get; } - - string FunctionVersion { get; } - - string InvokedFunctionArn { get; } - - ILambdaLogger Logger { get; } - - string LogGroupName { get; } - - string LogStreamName { get; } - - int MemoryLimitInMB { get; } - } - - public interface IClientContext - { - IDictionary Environment { get; } - - IClientApplication Client { get; } - - IDictionary Custom { get; } - } - - public interface IClientApplication - { - string AppPackageName { get; } - - string AppTitle { get; } - - string AppVersionCode { get; } - - string AppVersionName { get; } - - string InstallationId { get; } - } - - public enum LogLevel - { - Trace = 0, - Debug = 1, - Information = 2, - Warning = 3, - Error = 4, - Critical = 5 - } - - public interface ILambdaLogger - { - void Log(string message); - - void LogLine(string message); - - void Log(string level, string message) => throw null; - - void Log(LogLevel level, string message) => throw null; - - void LogTrace(string message) => throw null; - - void LogDebug(string message) => throw null; - - void LogInformation(string message) => throw null; - - void LogWarning(string message) => throw null; - - void LogError(string message) => throw null; - - void LogCritical(string message) => throw null; - } -} \ No newline at end of file diff --git a/csharp/ql/test/resources/stubs/Amazon.Lambda/2.1.0/Amazon.Lambda.csproj b/csharp/ql/test/resources/stubs/Amazon.Lambda/2.1.0/Amazon.Lambda.csproj deleted file mode 100644 index 2a636095b51..00000000000 --- a/csharp/ql/test/resources/stubs/Amazon.Lambda/2.1.0/Amazon.Lambda.csproj +++ /dev/null @@ -1,13 +0,0 @@ - - - net7.0 - enable - enable - true - Lambda - - true - - true - - \ No newline at end of file From c6a6a9f631ade2494a00d84d57ce294ece9a20fc Mon Sep 17 00:00:00 2001 From: Michael Nebel Date: Mon, 27 Nov 2023 14:09:47 +0100 Subject: [PATCH 7/8] C#: Update Aws test files. --- csharp/ql/test/library-tests/frameworks/Aws/lambda.ql | 2 +- csharp/ql/test/library-tests/frameworks/Aws/options | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/csharp/ql/test/library-tests/frameworks/Aws/lambda.ql b/csharp/ql/test/library-tests/frameworks/Aws/lambda.ql index 9d3597a4e9f..bbf78a8a0d9 100644 --- a/csharp/ql/test/library-tests/frameworks/Aws/lambda.ql +++ b/csharp/ql/test/library-tests/frameworks/Aws/lambda.ql @@ -1,5 +1,5 @@ import csharp -import semmle.code.csharp.dataflow.ExternalFlow +import semmle.code.csharp.dataflow.internal.ExternalFlow query predicate awsRemoteSources(DataFlow::ExprNode node) { sourceNode(node, "remote") } diff --git a/csharp/ql/test/library-tests/frameworks/Aws/options b/csharp/ql/test/library-tests/frameworks/Aws/options index 93914ab6418..ae93bf17212 100644 --- a/csharp/ql/test/library-tests/frameworks/Aws/options +++ b/csharp/ql/test/library-tests/frameworks/Aws/options @@ -1 +1,3 @@ -semmle-extractor-options: --load-sources-from-project:${testdir}/../../../resources/stubs/Amazon.Lambda/2.1.0/Amazon.Lambda.csproj \ No newline at end of file +semmle-extractor-options: /nostdlib /noconfig +semmle-extractor-options: --load-sources-from-project:${testdir}/../../../resources/stubs/Amazon.Lambda.Core/2.2.0/Amazon.Lambda.Core.csproj +semmle-extractor-options: --load-sources-from-project:${testdir}/../../../resources/stubs/Amazon.Lambda.APIGatewayEvents/2.7.0/Amazon.Lambda.APIGatewayEvents.csproj From 3b9737fa88eb32b3a03fb1b3a7cbf346432fc54f Mon Sep 17 00:00:00 2001 From: Michael Nebel Date: Wed, 13 Dec 2023 13:11:31 +0100 Subject: [PATCH 8/8] C#: Update Amazon stubs to use .NET 8 as target framework. --- .../2.7.0/Amazon.Lambda.APIGatewayEvents.csproj | 2 +- .../stubs/Amazon.Lambda.Core/2.2.0/Amazon.Lambda.Core.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/csharp/ql/test/resources/stubs/Amazon.Lambda.APIGatewayEvents/2.7.0/Amazon.Lambda.APIGatewayEvents.csproj b/csharp/ql/test/resources/stubs/Amazon.Lambda.APIGatewayEvents/2.7.0/Amazon.Lambda.APIGatewayEvents.csproj index dffed49d346..61622bc5296 100644 --- a/csharp/ql/test/resources/stubs/Amazon.Lambda.APIGatewayEvents/2.7.0/Amazon.Lambda.APIGatewayEvents.csproj +++ b/csharp/ql/test/resources/stubs/Amazon.Lambda.APIGatewayEvents/2.7.0/Amazon.Lambda.APIGatewayEvents.csproj @@ -1,6 +1,6 @@ - net7.0 + net8.0 true bin\ false diff --git a/csharp/ql/test/resources/stubs/Amazon.Lambda.Core/2.2.0/Amazon.Lambda.Core.csproj b/csharp/ql/test/resources/stubs/Amazon.Lambda.Core/2.2.0/Amazon.Lambda.Core.csproj index dffed49d346..61622bc5296 100644 --- a/csharp/ql/test/resources/stubs/Amazon.Lambda.Core/2.2.0/Amazon.Lambda.Core.csproj +++ b/csharp/ql/test/resources/stubs/Amazon.Lambda.Core/2.2.0/Amazon.Lambda.Core.csproj @@ -1,6 +1,6 @@ - net7.0 + net8.0 true bin\ false