Skip to content

Commit f6d1621

Browse files
committed
Go: Adapt to changes in FlowSummaryImpl
1 parent 73cd0e8 commit f6d1621

File tree

4 files changed

+24
-39
lines changed

4 files changed

+24
-39
lines changed

go/ql/lib/semmle/go/dataflow/ExternalFlow.qll

Lines changed: 14 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -503,44 +503,23 @@ predicate barrierNode(DataFlow::Node node, string kind) { barrierNode(node, kind
503503

504504
// adapter class for converting Mad summaries to `SummarizedCallable`s
505505
private class SummarizedCallableAdapter extends Public::SummarizedCallable {
506-
SummarizedCallableAdapter() { summaryElement(this, _, _, _, _, _) }
506+
string input_;
507+
string output_;
508+
string kind;
509+
Public::Provenance p_;
510+
string model_;
507511

508-
private predicate relevantSummaryElementManual(
509-
string input, string output, string kind, string model
510-
) {
511-
exists(Public::Provenance provenance |
512-
summaryElement(this, input, output, kind, provenance, model) and
513-
provenance.isManual()
514-
)
515-
}
516-
517-
private predicate relevantSummaryElementGenerated(
518-
string input, string output, string kind, string model
519-
) {
520-
exists(Public::Provenance provenance |
521-
summaryElement(this, input, output, kind, provenance, model) and
522-
provenance.isGenerated()
523-
) and
524-
not exists(Public::Provenance provenance |
525-
neutralElement(this, "summary", provenance) and
526-
provenance.isManual()
527-
)
528-
}
512+
SummarizedCallableAdapter() { summaryElement(this, input_, output_, kind, p_, model_) }
529513

530514
override predicate propagatesFlow(
531-
string input, string output, boolean preservesValue, string model
515+
string input, string output, boolean preservesValue, Public::Provenance p, boolean isExact,
516+
string model
532517
) {
533-
exists(string kind |
534-
this.relevantSummaryElementManual(input, output, kind, model)
535-
or
536-
not this.relevantSummaryElementManual(_, _, _, _) and
537-
this.relevantSummaryElementGenerated(input, output, kind, model)
538-
|
539-
if kind = "value" then preservesValue = true else preservesValue = false
540-
)
541-
}
542-
543-
override predicate hasProvenance(Public::Provenance provenance) {
544-
summaryElement(this, _, _, _, provenance, _)
518+
input = input_ and
519+
output = output_ and
520+
(if kind = "value" then preservesValue = true else preservesValue = false) and
521+
p = p_ and
522+
isExact = true and
523+
model = model_
545524
}
546525
}

go/ql/lib/semmle/go/dataflow/FlowSummary.qll

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ deprecated class SummaryComponentStack = Impl::Private::SummaryComponentStack;
1818

1919
deprecated module SummaryComponentStack = Impl::Private::SummaryComponentStack;
2020

21-
class SummarizedCallable = Impl::Public::SummarizedCallable;
21+
/** Provides the `Range` class used to define the extent of `SummarizedCallable`. */
22+
module SummarizedCallable {
23+
class Range = Impl::Public::SummarizedCallable;
24+
}
25+
26+
class SummarizedCallable = Impl::Public::RelevantSummarizedCallable;
2227

2328
deprecated class RequiredSummaryComponentStack = Impl::Private::RequiredSummaryComponentStack;

go/ql/lib/semmle/go/dataflow/internal/FlowSummaryImpl.qll

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,16 @@ module Input implements InputSig<Location, DataFlowImplSpecific::GoDataFlow> {
2929

3030
class SinkBase = Void;
3131

32+
predicate callableFromSource(SummarizedCallableBase c) { exists(c.getFuncDef()) }
33+
3234
predicate neutralElement(
3335
Input::SummarizedCallableBase c, string kind, string provenance, boolean isExact
3436
) {
3537
exists(string namespace, string type, string name, string signature |
3638
neutralModel(namespace, type, name, signature, kind, provenance) and
3739
c.asFunction() = interpretElement(namespace, type, false, name, signature, "").asEntity()
3840
) and
39-
// isExact is not needed for Go.
40-
isExact = false
41+
isExact = true
4142
}
4243

4344
ArgumentPosition callbackSelfParameterPosition() { result = -1 }

go/ql/lib/semmle/go/frameworks/stdlib/NetHttp.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ module NetHttp {
157157
|
158158
this = call.getASyntacticArgument() and
159159
callable = call.getACalleeIncludingExternals() and
160-
callable.propagatesFlow(input, output, _, _)
160+
callable.propagatesFlow(input, output, _, _, _, _)
161161
|
162162
// A modeled function conveying taint from some input to the response writer,
163163
// e.g. `io.Copy(responseWriter, someTaintedReader)`

0 commit comments

Comments
 (0)