Skip to content

Commit da5a719

Browse files
committed
Refactor UnsafeUsageOfClientSideEncryptionVersion
1 parent e880a5f commit da5a719

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

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

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,34 +50,31 @@ predicate isCreatingAzureClientSideEncryptionObjectNewVersion(Call call, Class c
5050
/**
5151
* A dataflow config that tracks `EncryptedBlobClientBuilder.version` argument initialization.
5252
*/
53-
private class EncryptedBlobClientBuilderSafeEncryptionVersionConfig extends DataFlow::Configuration {
54-
EncryptedBlobClientBuilderSafeEncryptionVersionConfig() {
55-
this = "EncryptedBlobClientBuilderSafeEncryptionVersionConfig"
56-
}
57-
58-
override predicate isSource(DataFlow::Node source) {
53+
private module EncryptedBlobClientBuilderSafeEncryptionVersionConfig implements DataFlow::ConfigSig {
54+
predicate isSource(DataFlow::Node source) {
5955
exists(FieldRead fr, Field f | fr = source.asExpr() |
6056
f.getAnAccess() = fr and
6157
f.hasQualifiedName("com.azure.storage.blob.specialized.cryptography", "EncryptionVersion",
6258
"V2")
6359
)
6460
}
6561

66-
override predicate isSink(DataFlow::Node sink) {
62+
predicate isSink(DataFlow::Node sink) {
6763
isCreatingAzureClientSideEncryptionObjectNewVersion(_, _, sink.asExpr())
6864
}
6965
}
7066

67+
private module EncryptedBlobClientBuilderSafeEncryptionVersionFlow =
68+
DataFlow::Global<EncryptedBlobClientBuilderSafeEncryptionVersionConfig>;
69+
7170
/**
7271
* Holds if `call` is an object creation for a class `EncryptedBlobClientBuilder`
7372
* that takes `versionArg` as the argument specifying the encryption version, and that version is safe.
7473
*/
7574
predicate isCreatingSafeAzureClientSideEncryptionObject(Call call, Class c, Expr versionArg) {
7675
isCreatingAzureClientSideEncryptionObjectNewVersion(call, c, versionArg) and
77-
exists(EncryptedBlobClientBuilderSafeEncryptionVersionConfig config, DataFlow::Node sink |
78-
sink.asExpr() = versionArg
79-
|
80-
config.hasFlow(_, sink)
76+
exists(DataFlow::Node sink | sink.asExpr() = versionArg |
77+
EncryptedBlobClientBuilderSafeEncryptionVersionFlow::flowTo(sink)
8178
)
8279
}
8380

0 commit comments

Comments
 (0)