@@ -14,19 +14,54 @@ import python
14
14
import semmle.python.ApiGraphs
15
15
16
16
predicate isUnsafeClientSideAzureStorageEncryptionViaAttributes ( Call call , AttrNode node ) {
17
- exists ( ControlFlowNode ctrlFlowNode , AssignStmt astmt , Attribute a |
17
+ exists (
18
+ API:: Node n , API:: Node n2 , Attribute a , AssignStmt astmt , API:: Node uploadBlob ,
19
+ ControlFlowNode ctrlFlowNode , string s
20
+ |
21
+ s in [ "key_encryption_key" , "key_resolver_function" ] and
22
+ n =
23
+ API:: moduleImport ( "azure" )
24
+ .getMember ( "storage" )
25
+ .getMember ( "blob" )
26
+ .getMember ( "BlobClient" )
27
+ .getReturn ( )
28
+ .getMember ( s ) and
29
+ n2 =
30
+ API:: moduleImport ( "azure" )
31
+ .getMember ( "storage" )
32
+ .getMember ( "blob" )
33
+ .getMember ( "BlobClient" )
34
+ .getReturn ( )
35
+ .getMember ( "upload_blob" ) and
36
+ n .getAUse ( ) .asExpr ( ) = a and
18
37
astmt .getATarget ( ) = a and
19
- a .getAttr ( ) in [ "key_encryption_key" , "key_resolver_function" ] and
20
38
a .getAFlowNode ( ) = node and
39
+ uploadBlob =
40
+ API:: moduleImport ( "azure" )
41
+ .getMember ( "storage" )
42
+ .getMember ( "blob" )
43
+ .getMember ( "BlobClient" )
44
+ .getReturn ( )
45
+ .getMember ( "upload_blob" ) and
46
+ uploadBlob .getACall ( ) .asExpr ( ) = call and
47
+ ctrlFlowNode = call .getAFlowNode ( ) and
21
48
node .strictlyReaches ( ctrlFlowNode ) and
22
49
node != ctrlFlowNode and
23
- call . getAChildNode ( ) . ( Attribute ) . getAttr ( ) = "upload_blob" and
24
- ctrlFlowNode = call . getAFlowNode ( ) and
25
- not astmt . getValue ( ) instanceof None and
26
- not exists ( AssignStmt astmt2 , Attribute a2 , AttrNode encryptionVersionSet , StrConst uc |
50
+ not exists (
51
+ AssignStmt astmt2 , Attribute a2 , AttrNode encryptionVersionSet , StrConst uc ,
52
+ API :: Node encryptionVersion
53
+ |
27
54
uc = astmt2 .getValue ( ) and
28
55
uc .getText ( ) in [ "'2.0'" , "2.0" ] and
29
- a2 .getAttr ( ) = "encryption_version" and
56
+ encryptionVersion =
57
+ API:: moduleImport ( "azure" )
58
+ .getMember ( "storage" )
59
+ .getMember ( "blob" )
60
+ .getMember ( "BlobClient" )
61
+ .getReturn ( )
62
+ .getMember ( "encryption_version" ) and
63
+ encryptionVersion .getAUse ( ) .asExpr ( ) = a2 and
64
+ astmt2 .getATarget ( ) = a2 and
30
65
a2 .getAFlowNode ( ) = encryptionVersionSet and
31
66
encryptionVersionSet .strictlyReaches ( ctrlFlowNode )
32
67
)
0 commit comments