55import javascript
66
77module AWS {
8- /**
9- * Gets the name of a supported AWS service.
10- */
11- private string getAwsServiceName ( ) {
12- result =
13- [
14- "EC2" , "Lambda" , "ECS" , "EKS" , "Batch" , "ElasticBeanstalk" , "Lightsail" , "AppRunner" , "S3" ,
15- "EFS" , "Glacier" , "S3Control" , "StorageGateway" , "Backup" , "DynamoDB" , "DynamoDBStreams" ,
16- "RDS" , "Redshift" , "ElastiCache" , "Neptune" , "QLDB" , "Athena" , "Route53" , "CloudFront" ,
17- "APIGateway" , "ApiGatewayV2" , "DirectConnect" , "GlobalAccelerator" , "CloudWatch" ,
18- "CloudFormation" , "CloudTrail" , "Config" , "Organizations" , "ServiceCatalog" , "SSM" ,
19- "ResourceGroups" , "IAM" , "CognitoIdentity" , "CognitoIdentityServiceProvider" , "GuardDuty" ,
20- "Inspector" , "KMS" , "SecretsManager" , "SecurityHub" , "STS" , "WAF" , "WAFRegional" ,
21- "SageMaker" , "Rekognition" , "Comprehend" , "Textract" , "Translate" , "Polly" ,
22- "LexModelBuildingService" , "MachineLearning" , "Personalize" , "EMR" , "Kinesis" ,
23- "KinesisAnalytics" , "KinesisVideo" , "QuickSight" , "DataPipeline" , "Glue" , "LakeFormation" ,
24- "SNS" , "SQS" , "SES" , "Pinpoint" , "Chime" , "Connect" , "Amplify" , "AppSync" , "DeviceFarm" ,
25- "IoTAnalytics" , "IoTEvents" , "IoT1ClickDevicesService" , "IoTSiteWise" , "MediaConvert" ,
26- "MediaLive" , "MediaPackage" , "MediaStore" , "ElasticTranscoder" , "EventBridge" , "MQ" , "SWF" ,
27- "StepFunctions"
28- ]
29- }
30-
31- /**
32- * Gets a node representing an import of the AWS SDK.
33- */
34- private API:: Node getAwsImport ( ) { result = API:: moduleImport ( "aws-sdk" ) }
35-
36- /**
37- * Gets a data flow node representing an instantiation of an AWS service.
38- */
39- private DataFlow:: Node getServiceInstantation ( ) {
40- result =
41- getAwsImport ( ) .getMember ( getAwsServiceName ( ) ) .getAnInstantiation ( ) .getReturn ( ) .asSource ( )
42- }
43-
44- /**
45- * Gets a node representing the AWS global config object.
46- */
47- private API:: Node getAwsConfig ( ) { result = getAwsImport ( ) .getMember ( "config" ) }
48-
49- /**
50- * Gets a property write to the AWS config object.
51- * This captures assignments to AWS.config properties.
52- */
53- private DataFlow:: PropWrite configAssigment ( ) {
54- result = getAwsConfig ( ) .asSource ( ) .getAPropertyWrite ( )
55- }
56-
57- /**
58- * Gets a data flow node representing an instance of `new AWS.Credentials(accessKeyId, secretAccessKey)`.
59- */
60- private DataFlow:: Node getCredentialsCreationNode ( ) {
61- result = getAwsImport ( ) .getMember ( "Credentials" ) .getAnInstantiation ( ) .getReturn ( ) .asSource ( )
62- }
63-
648 /**
659 * Holds if the `i`th argument of `invk` is an object hash for `AWS.Config`.
6610 */
6711 private predicate takesConfigurationObject ( DataFlow:: InvokeNode invk , int i ) {
68- exists ( API :: Node mod | mod = getAwsImport ( ) |
12+ exists ( DataFlow :: ModuleImportNode mod | mod . getPath ( ) = "aws-sdk" |
6913 // `AWS.config.update(nd)`
70- invk = mod .getMember ( "config" ) .getMember ( "update" ) . getACall ( ) and
14+ invk = mod .getAPropertyRead ( "config" ) .getAMemberCall ( "update" ) and
7115 i = 0
7216 or
73- exists ( DataFlow:: SourceNode cfg |
74- cfg = mod .getMember ( "Config" ) .getAnInstantiation ( ) .getReturn ( ) .asSource ( )
75- |
17+ exists ( DataFlow:: SourceNode cfg | cfg = mod .getAConstructorInvocation ( "Config" ) |
7618 // `new AWS.Config(nd)`
7719 invk = cfg and
7820 i = 0
@@ -94,42 +36,11 @@ module AWS {
9436 exists ( string prop , DataFlow:: InvokeNode invk , int i |
9537 takesConfigurationObject ( invk , i ) and
9638 this = invk .getOptionArgument ( i , prop )
97- or
98- // `new AWS.ServiceName({ accessKeyId: <user>, secretAccessKey: <password> })`
99- invk = getServiceInstantation ( ) and
100- i = 0 and
101- this = invk .getOptionArgument ( i , prop )
10239 |
10340 prop = "accessKeyId" and kind = "user name"
10441 or
10542 prop = "secretAccessKey" and kind = "password"
10643 )
107- or
108- // `AWS.config.accessKeyId = <user>` or `AWS.config.secretAccessKey = <password>`
109- exists ( string prop , DataFlow:: PropWrite propWrite |
110- propWrite = configAssigment ( ) and
111- this = propWrite .getRhs ( ) and
112- prop = propWrite .getPropertyName ( ) and
113- (
114- kind = "user name" and
115- prop = "accessKeyId"
116- or
117- kind = "password" and
118- prop = "secretAccessKey"
119- )
120- )
121- or
122- // `new AWS.Credentials({ accessKeyId: <user>, secretAccessKey: <password> })`
123- exists ( DataFlow:: InvokeNode invk |
124- invk = getCredentialsCreationNode ( ) and
125- (
126- this = invk .getArgument ( 0 ) and
127- kind = "user name"
128- or
129- this = invk .getArgument ( 1 ) and
130- kind = "password"
131- )
132- )
13344 }
13445
13546 override string getCredentialsKind ( ) { result = kind }
0 commit comments