|
11 | 11 | */
|
12 | 12 |
|
13 | 13 | import java
|
| 14 | +import semmle.code.java.dataflow.DataFlow |
14 | 15 |
|
15 | 16 | /**
|
16 | 17 | * Holds if the call `call` is an object creation for a class `EncryptedBlobClientBuilder`
|
@@ -46,16 +47,37 @@ predicate isCreatingAzureClientSideEncryptionObjectNewVersion(Call call, Class c
|
46 | 47 | )
|
47 | 48 | }
|
48 | 49 |
|
| 50 | +/** |
| 51 | + * A config that tracks `EncryptedBlobClientBuilder.version` argument initialization. |
| 52 | + */ |
| 53 | +private class EncryptedBlobClientBuilderEncryptionVersionConfig extends DataFlow::Configuration { |
| 54 | + EncryptedBlobClientBuilderEncryptionVersionConfig() { |
| 55 | + this = "EncryptedBlobClientBuilderEncryptionVersionConfig" |
| 56 | + } |
| 57 | + |
| 58 | + override predicate isSource(DataFlow::Node source) { |
| 59 | + exists(FieldRead fr, Field f | fr = source.asExpr() | |
| 60 | + f.getAnAccess() = fr and |
| 61 | + f.hasQualifiedName("com.azure.storage.blob.specialized.cryptography", "EncryptionVersion", |
| 62 | + "V2") |
| 63 | + ) |
| 64 | + } |
| 65 | + |
| 66 | + override predicate isSink(DataFlow::Node sink) { |
| 67 | + isCreatingAzureClientSideEncryptionObjectNewVersion(_, _, sink.asExpr()) |
| 68 | + } |
| 69 | +} |
| 70 | + |
49 | 71 | /**
|
50 | 72 | * Holds if the call `call` is an object creation for a class `EncryptedBlobClientBuilder`
|
51 | 73 | * that takes `versionArg` as the argument for the version, and the version number is safe
|
52 | 74 | */
|
53 | 75 | predicate isCreatingSafeAzureClientSideEncryptionObject(Call call, Class c, Expr versionArg) {
|
54 | 76 | isCreatingAzureClientSideEncryptionObjectNewVersion(call, c, versionArg) and
|
55 |
| - exists(FieldRead fr, Field f | |
56 |
| - fr = versionArg and |
57 |
| - f.getAnAccess() = fr and |
58 |
| - f.hasQualifiedName("com.azure.storage.blob.specialized.cryptography", "EncryptionVersion", "V2") |
| 77 | + exists(EncryptedBlobClientBuilderEncryptionVersionConfig config, DataFlow::Node sink | |
| 78 | + sink.asExpr() = versionArg |
| 79 | + | |
| 80 | + config.hasFlow(_, sink) |
59 | 81 | )
|
60 | 82 | }
|
61 | 83 |
|
|
0 commit comments