File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
java/ql/test/library-tests/dataflow/entrypoint-types Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,14 @@ public K getField8() {
3333 }
3434 }
3535
36+ static class ChildObject extends ParameterizedTestObject <TestObject , Object > {
37+ public Object field9 ;
38+ }
39+
40+ class UnrelatedObject {
41+ public String safeField ;
42+ }
43+
3644 private static void sink (String sink ) {}
3745
3846 public static void test (TestObject source ) {
@@ -50,4 +58,16 @@ public static void testParameterized(
5058 sink (source .getField8 ().field4 ); // $hasTaintFlow
5159 sink (source .getField8 ().getField5 ()); // $hasTaintFlow
5260 }
61+
62+ public static void testSubtype (ParameterizedTestObject <?, ?> source ) {
63+ ChildObject subtypeSource = (ChildObject ) source ;
64+ sink (subtypeSource .field6 ); // $hasTaintFlow
65+ sink (subtypeSource .field7 .field1 ); // $hasTaintFlow
66+ sink (subtypeSource .field7 .getField2 ()); // $hasTaintFlow
67+ sink ((String ) subtypeSource .getField8 ()); // $hasTaintFlow
68+ sink ((String ) subtypeSource .field9 ); // $hasTaintFlow
69+ // Ensure that we are not tainting every subclass of Object
70+ UnrelatedObject unrelated = (UnrelatedObject ) subtypeSource .getField8 ();
71+ sink (unrelated .safeField ); // Safe
72+ }
5373}
You can’t perform that action at this time.
0 commit comments