Don't consider subtypes of fields

This commit is contained in:
Tony Torralba
2021-07-01 17:34:09 +02:00
parent 47002a3bd7
commit a3b25f0eb5

View File

@@ -33,6 +33,14 @@ public class EntryPointTypesTest {
}
}
static class ChildObject extends ParameterizedTestObject<TestObject, Object> {
public Object field9;
}
class UnrelatedObject {
public String safeField;
}
private static void sink(String sink) {}
public static void test(TestObject source) {
@@ -50,4 +58,16 @@ public class EntryPointTypesTest {
sink(source.getField8().field4); // $hasTaintFlow
sink(source.getField8().getField5()); // $hasTaintFlow
}
public static void testSubtype(ParameterizedTestObject<?, ?> source) {
ChildObject subtypeSource = (ChildObject) source;
sink(subtypeSource.field6); // $hasTaintFlow
sink(subtypeSource.field7.field1); // $hasTaintFlow
sink(subtypeSource.field7.getField2()); // $hasTaintFlow
sink((String) subtypeSource.getField8()); // $hasTaintFlow
sink((String) subtypeSource.field9); // $hasTaintFlow
// Ensure that we are not tainting every subclass of Object
UnrelatedObject unrelated = (UnrelatedObject) subtypeSource.getField8();
sink(unrelated.safeField); // Safe
}
}