Skip to content

Commit 3c6604d

Browse files
committed
Java: Fix subtypes interpretation.
1 parent 6813a79 commit 3c6604d

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

java/ql/src/semmle/code/java/dataflow/ExternalFlow.qll

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -586,14 +586,6 @@ private predicate elementSpec(
586586
summaryModel(namespace, type, subtypes, name, signature, ext, _, _, _)
587587
}
588588

589-
bindingset[namespace, type, subtypes]
590-
private RefType interpretType(string namespace, string type, boolean subtypes) {
591-
exists(RefType t |
592-
t.hasQualifiedName(namespace, type) and
593-
if subtypes = true then result.getASourceSupertype*() = t else result = t
594-
)
595-
}
596-
597589
private string paramsStringPart(Callable c, int i) {
598590
i = -1 and result = "("
599591
or
@@ -614,9 +606,13 @@ private Element interpretElement0(
614606
string namespace, string type, boolean subtypes, string name, string signature
615607
) {
616608
elementSpec(namespace, type, subtypes, name, signature, _) and
617-
exists(RefType t | t = interpretType(namespace, type, subtypes) |
609+
exists(RefType t | t.hasQualifiedName(namespace, type) |
618610
exists(Member m |
619-
result = m and
611+
(
612+
result = m
613+
or
614+
subtypes = true and result.(SrcMethod).overridesOrInstantiates+(m)
615+
) and
620616
m.getDeclaringType() = t and
621617
m.hasName(name)
622618
|
@@ -625,7 +621,7 @@ private Element interpretElement0(
625621
paramsString(m) = signature
626622
)
627623
or
628-
result = t and
624+
(if subtypes = true then result.(SrcRefType).getASourceSupertype*() = t else result = t) and
629625
name = "" and
630626
signature = ""
631627
)

java/ql/test/library-tests/frameworks/JaxWs/JakartaRsFlow.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ void testAbstractMultivaluedMap(Map<String, List<String>> map1, Map<String, List
169169

170170
AbstractMultivaluedMap<String, String> amm3 = new MyAbstractMultivaluedMapJak<String, String>(null);
171171
amm3.put("key", list);
172-
sink(amm3.get("key").get(0)); // $ MISSING: hasValueFlow
172+
sink(amm3.get("key").get(0)); // $ hasValueFlow
173173
}
174174

175175
void testMultivaluedHashMap(Map<String, String> map1, Map<String, String> map2,

0 commit comments

Comments
 (0)