Skip to content

Commit b0fbe36

Browse files
author
Sebastian Bauersfeld
committed
Add java.lang.String taint tests.
1 parent 93fc952 commit b0fbe36

File tree

1 file changed

+28
-0
lines changed
  • java/ql/test/library-tests/dataflow/taint

1 file changed

+28
-0
lines changed

java/ql/test/library-tests/dataflow/taint/B.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,4 +189,32 @@ public StringWrapper(String s) {
189189
public static boolean safe() {
190190
return true;
191191
}
192+
193+
public static void extendedTests(){
194+
String s = taint()[0];
195+
196+
String replReceiver = s.replace("irrelevant", "irrelevant");
197+
sink(replReceiver);
198+
199+
String replChar = "a".replace('a', s.charAt(0));
200+
sink(replChar);
201+
202+
String replCharReceiver = s.replace('a', 'b');
203+
sink(replCharReceiver);
204+
205+
String charAt = "";
206+
for(int i = 0; i < 10; i++)
207+
charAt = charAt + s.charAt(i);
208+
sink(charAt);
209+
210+
byte[] bytes = new byte[10];
211+
s.getBytes(0, 1, bytes, 0);
212+
sink(bytes);
213+
214+
String replAll = s.replaceAll("irrelevant", "irrelevant");
215+
sink(replAll);
216+
217+
String replFirst = s.replaceFirst("irrelevant", "irrelevant");
218+
sink(replFirst);
219+
}
192220
}

0 commit comments

Comments
 (0)