Skip to content

Commit 78f911a

Browse files
committed
Java: Add test showing missing model for thenExpand
1 parent 02c2f26 commit 78f911a

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

java/ql/test/library-tests/dataflow/kdf/KDFDataflowTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,17 @@ public static void testCleanUsage() throws Exception {
7171
byte[] cleanResult = kdf.deriveData(spec);
7272
sink(cleanResult); // Safe - no taint
7373
}
74+
75+
public static void testThenExpand(byte[] cleanIKM) throws Exception {
76+
String userInput = source("");
77+
byte[] taintedInfo = userInput.getBytes();
78+
79+
HKDFParameterSpec.Builder builder = HKDFParameterSpec.ofExtract();
80+
builder.addIKM(cleanIKM);
81+
HKDFParameterSpec spec = builder.thenExpand(taintedInfo, 32);
82+
83+
KDF kdf = KDF.getInstance("HKDF-SHA256");
84+
byte[] result = kdf.deriveData(spec);
85+
sink(result); // $ hasTaintFlow
86+
}
7487
}

java/ql/test/library-tests/dataflow/kdf/test.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,4 @@ nodes
8787
| KDFDataflowTest.java:60:14:60:19 | result | semmle.label | result |
8888
subpaths
8989
testFailures
90+
| KDFDataflowTest.java:85:23:85:39 | // $ hasTaintFlow | Missing result: hasTaintFlow |

0 commit comments

Comments
 (0)