5
5
import javascript
6
6
7
7
module 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
-
64
8
/**
65
9
* Holds if the `i`th argument of `invk` is an object hash for `AWS.Config`.
66
10
*/
67
11
private predicate takesConfigurationObject ( DataFlow:: InvokeNode invk , int i ) {
68
- exists ( API :: Node mod | mod = getAwsImport ( ) |
12
+ exists ( DataFlow :: ModuleImportNode mod | mod . getPath ( ) = "aws-sdk" |
69
13
// `AWS.config.update(nd)`
70
- invk = mod .getMember ( "config" ) .getMember ( "update" ) . getACall ( ) and
14
+ invk = mod .getAPropertyRead ( "config" ) .getAMemberCall ( "update" ) and
71
15
i = 0
72
16
or
73
- exists ( DataFlow:: SourceNode cfg |
74
- cfg = mod .getMember ( "Config" ) .getAnInstantiation ( ) .getReturn ( ) .asSource ( )
75
- |
17
+ exists ( DataFlow:: SourceNode cfg | cfg = mod .getAConstructorInvocation ( "Config" ) |
76
18
// `new AWS.Config(nd)`
77
19
invk = cfg and
78
20
i = 0
@@ -94,42 +36,11 @@ module AWS {
94
36
exists ( string prop , DataFlow:: InvokeNode invk , int i |
95
37
takesConfigurationObject ( invk , i ) and
96
38
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 )
102
39
|
103
40
prop = "accessKeyId" and kind = "user name"
104
41
or
105
42
prop = "secretAccessKey" and kind = "password"
106
43
)
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
- )
133
44
}
134
45
135
46
override string getCredentialsKind ( ) { result = kind }
0 commit comments