Skip to content

Commit d929b13

Browse files
Addressing API::Node feedback for all predicates
1 parent 64343e0 commit d929b13

File tree

1 file changed

+42
-7
lines changed

1 file changed

+42
-7
lines changed

python/ql/src/experimental/Security/CWE-327/Azure/UnsafeUsageOfClientSideEncryptionVersion.ql

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,54 @@ import python
1414
import semmle.python.ApiGraphs
1515

1616
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
1837
astmt.getATarget() = a and
19-
a.getAttr() in ["key_encryption_key", "key_resolver_function"] and
2038
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
2148
node.strictlyReaches(ctrlFlowNode) and
2249
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+
|
2754
uc = astmt2.getValue() and
2855
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
3065
a2.getAFlowNode() = encryptionVersionSet and
3166
encryptionVersionSet.strictlyReaches(ctrlFlowNode)
3267
)

0 commit comments

Comments
 (0)