mirror of
https://github.com/github/codeql.git
synced 2026-02-11 20:51:06 +01:00
Go: Adapt to changes in FlowSummaryImpl
This commit is contained in:
@@ -503,44 +503,23 @@ predicate barrierNode(DataFlow::Node node, string kind) { barrierNode(node, kind
|
||||
|
||||
// adapter class for converting Mad summaries to `SummarizedCallable`s
|
||||
private class SummarizedCallableAdapter extends Public::SummarizedCallable {
|
||||
SummarizedCallableAdapter() { summaryElement(this, _, _, _, _, _) }
|
||||
string input_;
|
||||
string output_;
|
||||
string kind;
|
||||
Public::Provenance p_;
|
||||
string model_;
|
||||
|
||||
private predicate relevantSummaryElementManual(
|
||||
string input, string output, string kind, string model
|
||||
) {
|
||||
exists(Public::Provenance provenance |
|
||||
summaryElement(this, input, output, kind, provenance, model) and
|
||||
provenance.isManual()
|
||||
)
|
||||
}
|
||||
|
||||
private predicate relevantSummaryElementGenerated(
|
||||
string input, string output, string kind, string model
|
||||
) {
|
||||
exists(Public::Provenance provenance |
|
||||
summaryElement(this, input, output, kind, provenance, model) and
|
||||
provenance.isGenerated()
|
||||
) and
|
||||
not exists(Public::Provenance provenance |
|
||||
neutralElement(this, "summary", provenance) and
|
||||
provenance.isManual()
|
||||
)
|
||||
}
|
||||
SummarizedCallableAdapter() { summaryElement(this, input_, output_, kind, p_, model_) }
|
||||
|
||||
override predicate propagatesFlow(
|
||||
string input, string output, boolean preservesValue, string model
|
||||
string input, string output, boolean preservesValue, Public::Provenance p, boolean isExact,
|
||||
string model
|
||||
) {
|
||||
exists(string kind |
|
||||
this.relevantSummaryElementManual(input, output, kind, model)
|
||||
or
|
||||
not this.relevantSummaryElementManual(_, _, _, _) and
|
||||
this.relevantSummaryElementGenerated(input, output, kind, model)
|
||||
|
|
||||
if kind = "value" then preservesValue = true else preservesValue = false
|
||||
)
|
||||
}
|
||||
|
||||
override predicate hasProvenance(Public::Provenance provenance) {
|
||||
summaryElement(this, _, _, _, provenance, _)
|
||||
input = input_ and
|
||||
output = output_ and
|
||||
(if kind = "value" then preservesValue = true else preservesValue = false) and
|
||||
p = p_ and
|
||||
isExact = true and
|
||||
model = model_
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,11 @@ deprecated class SummaryComponentStack = Impl::Private::SummaryComponentStack;
|
||||
|
||||
deprecated module SummaryComponentStack = Impl::Private::SummaryComponentStack;
|
||||
|
||||
class SummarizedCallable = Impl::Public::SummarizedCallable;
|
||||
/** Provides the `Range` class used to define the extent of `SummarizedCallable`. */
|
||||
module SummarizedCallable {
|
||||
class Range = Impl::Public::SummarizedCallable;
|
||||
}
|
||||
|
||||
class SummarizedCallable = Impl::Public::RelevantSummarizedCallable;
|
||||
|
||||
deprecated class RequiredSummaryComponentStack = Impl::Private::RequiredSummaryComponentStack;
|
||||
|
||||
@@ -29,6 +29,8 @@ module Input implements InputSig<Location, DataFlowImplSpecific::GoDataFlow> {
|
||||
|
||||
class SinkBase = Void;
|
||||
|
||||
predicate callableFromSource(SummarizedCallableBase c) { exists(c.getFuncDef()) }
|
||||
|
||||
predicate neutralElement(
|
||||
Input::SummarizedCallableBase c, string kind, string provenance, boolean isExact
|
||||
) {
|
||||
@@ -36,8 +38,7 @@ module Input implements InputSig<Location, DataFlowImplSpecific::GoDataFlow> {
|
||||
neutralModel(namespace, type, name, signature, kind, provenance) and
|
||||
c.asFunction() = interpretElement(namespace, type, false, name, signature, "").asEntity()
|
||||
) and
|
||||
// isExact is not needed for Go.
|
||||
isExact = false
|
||||
isExact = true
|
||||
}
|
||||
|
||||
ArgumentPosition callbackSelfParameterPosition() { result = -1 }
|
||||
|
||||
@@ -157,7 +157,7 @@ module NetHttp {
|
||||
|
|
||||
this = call.getASyntacticArgument() and
|
||||
callable = call.getACalleeIncludingExternals() and
|
||||
callable.propagatesFlow(input, output, _, _)
|
||||
callable.propagatesFlow(input, output, _, _, _, _)
|
||||
|
|
||||
// A modeled function conveying taint from some input to the response writer,
|
||||
// e.g. `io.Copy(responseWriter, someTaintedReader)`
|
||||
|
||||
Reference in New Issue
Block a user