Skip to content

Commit 890c596

Browse files
committed
Go: Adapt to changes in FlowSummaryImpl
1 parent cc38156 commit 890c596

File tree

3 files changed

+18
-38
lines changed

3 files changed

+18
-38
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/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) { none() } // todo
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)