Skip to content

Commit

Permalink
Merge pull request #17604 from aschackmull/java/neutral-overrides
Browse files Browse the repository at this point in the history
Java/C#: Add overrides to the interpretation of neutral MaD models.
  • Loading branch information
aschackmull authored Oct 1, 2024
2 parents cb0b388 + 5c4b4d6 commit 6081ba5
Show file tree
Hide file tree
Showing 7 changed files with 1,204 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ private predicate elementSpec(
or
summaryModel(namespace, type, subtypes, name, signature, ext, _, _, _, _, _)
or
neutralModel(namespace, type, name, signature, _, _) and ext = "" and subtypes = false
neutralModel(namespace, type, name, signature, _, _) and ext = "" and subtypes = true
}

private predicate elementSpec(
Expand Down Expand Up @@ -602,7 +602,7 @@ private predicate interpretSummary(
predicate interpretNeutral(UnboundCallable c, string kind, string provenance) {
exists(string namespace, string type, string name, string signature |
neutralModel(namespace, type, name, signature, kind, provenance) and
c = interpretElement(namespace, type, false, name, signature, "")
c = interpretElement(namespace, type, true, name, signature, "")
)
}

Expand Down
1,198 changes: 1,198 additions & 0 deletions csharp/ql/test/library-tests/dataflow/library/FlowSummaries.expected

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion java/ql/lib/ext/java.lang.model.yml
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ extensions:
- ["java.lang", "Object", "equals", "(Object)", "summary", "manual"]
- ["java.lang", "Object", "getClass", "()", "summary", "manual"]
- ["java.lang", "Object", "hashCode", "()", "summary", "manual"]
- ["java.lang", "Object", "toString", "()", "summary", "manual"]
- ["java.lang", "Runtime", "getRuntime", "()", "summary", "manual"]
- ["java.lang", "String", "compareTo", "(String)", "summary", "manual"]
- ["java.lang", "String", "contains", "(CharSequence)", "summary", "manual"]
Expand Down
2 changes: 1 addition & 1 deletion java/ql/lib/semmle/code/java/dataflow/ExternalFlow.qll
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ private predicate elementSpec(
or
summaryModel(package, type, subtypes, name, signature, ext, _, _, _, _, _)
or
neutralModel(package, type, name, signature, _, _) and ext = "" and subtypes = false
neutralModel(package, type, name, signature, _, _) and ext = "" and subtypes = true
}

private string getNestedName(Type t) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module Input implements InputSig<Location, DataFlowImplSpecific::JavaDataFlow> {
) {
exists(string namespace, string type, string name, string signature |
neutralModel(namespace, type, name, signature, kind, provenance) and
c.asCallable() = interpretElement(namespace, type, false, name, signature, "", isExact)
c.asCallable() = interpretElement(namespace, type, true, name, signature, "", isExact)
)
}

Expand Down
2 changes: 1 addition & 1 deletion java/ql/src/utils/modeleditor/ModelEditor.qll
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class Endpoint extends Callable {
predicate isNeutral() {
exists(string namespace, string type, string name, string signature |
neutralModel(namespace, type, name, signature, _, _) and
this = interpretElement(namespace, type, false, name, signature, "", _)
this = interpretElement(namespace, type, true, name, signature, "", _)
)
}

Expand Down
1 change: 1 addition & 0 deletions java/ql/test/ext/TopJdkApis/TopJdkApisTest.expected
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
| java.lang.Object#toString() | no manual model |
| java.lang.Runnable#run() | no manual model |
| java.util.Comparator#comparing(Function) | no manual model |
| java.util.function.BiConsumer#accept(Object,Object) | no manual model |
Expand Down

0 comments on commit 6081ba5

Please sign in to comment.