mirror of
https://github.com/github/codeql.git
synced 2026-04-25 08:45:14 +02:00
Merge pull request #17007 from michaelnebel/shared/neutralimplementation
C#/Java/Go: Neutrals are split into separate classes.
This commit is contained in:
@@ -636,21 +636,6 @@ private class SummarizedCallableAdapter extends SummarizedCallable {
|
||||
override predicate hasExactModel() { summaryElement(this, _, _, _, _, _, true) }
|
||||
}
|
||||
|
||||
// adapter class for converting Mad neutrals to `NeutralCallable`s
|
||||
private class NeutralCallableAdapter extends NeutralCallable {
|
||||
string kind;
|
||||
string provenance_;
|
||||
boolean exact;
|
||||
|
||||
NeutralCallableAdapter() { neutralElement(this, kind, provenance_, exact) }
|
||||
|
||||
override string getKind() { result = kind }
|
||||
|
||||
override predicate hasProvenance(Provenance provenance) { provenance = provenance_ }
|
||||
|
||||
override predicate hasExactModel() { exact = true }
|
||||
}
|
||||
|
||||
/**
|
||||
* A callable where there exists a MaD sink model that applies to it.
|
||||
*/
|
||||
|
||||
@@ -29,6 +29,15 @@ private string positionToString(int pos) {
|
||||
module Input implements InputSig<Location, DataFlowImplSpecific::JavaDataFlow> {
|
||||
class SummarizedCallableBase = FlowSummary::SummarizedCallableBase;
|
||||
|
||||
predicate neutralElement(
|
||||
Input::SummarizedCallableBase c, string kind, string provenance, boolean isExact
|
||||
) {
|
||||
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)
|
||||
)
|
||||
}
|
||||
|
||||
ArgumentPosition callbackSelfParameterPosition() { result = -1 }
|
||||
|
||||
ReturnKind getStandardReturnValueKind() { any() }
|
||||
@@ -332,18 +341,7 @@ module Private {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if a neutral model exists for `c` of kind `kind`
|
||||
* and with provenance `provenance`.
|
||||
*/
|
||||
predicate neutralElement(
|
||||
Input::SummarizedCallableBase c, string kind, string provenance, boolean isExact
|
||||
) {
|
||||
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)
|
||||
)
|
||||
}
|
||||
predicate neutralElement = Input::neutralElement/4;
|
||||
}
|
||||
|
||||
/** Provides predicates for constructing summary components. */
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
extensions:
|
||||
- addsTo:
|
||||
pack: codeql/java-all
|
||||
extensible: neutralModel
|
||||
data:
|
||||
- [ "p", "Sinks", "nosink", "(Object)", "sink", "manual"]
|
||||
- [ "p", "Sinks", "nosink", "(Object)", "summary", "df-generated"]
|
||||
@@ -21,6 +21,10 @@ public class Sinks {
|
||||
// neutral=p;Sinks;sink2;(Object);summary;df-generated
|
||||
public void sink2(Object o) {}
|
||||
|
||||
// Defined as sink neutral in the file next to the neutral summary test.
|
||||
// neutral=p;Sinks;nosink;(Object);summary;df-generated
|
||||
public void nosink(Object o) {}
|
||||
|
||||
// sink=p;Sinks;true;copyFileToDirectory;(Path,Path,CopyOption[]);;Argument[0];path-injection;df-generated
|
||||
// sink=p;Sinks;true;copyFileToDirectory;(Path,Path,CopyOption[]);;Argument[1];path-injection;df-generated
|
||||
// neutral=p;Sinks;copyFileToDirectory;(Path,Path,CopyOption[]);summary;df-generated
|
||||
|
||||
Reference in New Issue
Block a user