Skip to content

Commit 131cf68

Browse files
committed
Shared: Prefer source/sink models with manual provenance over generated
1 parent 6f27863 commit 131cf68

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

shared/dataflow/codeql/dataflow/internal/FlowSummaryImpl.qll

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -662,16 +662,38 @@ module Make<
662662
unsupportedCallable(callable, _, _, _)
663663
}
664664

665+
private predicate isRelevantSource(
666+
SourceElement e, string output, string kind, Provenance provenance, string model
667+
) {
668+
e.isSource(output, kind, provenance, model) and
669+
(
670+
provenance.isManual()
671+
or
672+
not exists(Provenance p | p.isManual() and e.isSource(_, kind, p, _))
673+
)
674+
}
675+
676+
private predicate isRelevantSink(
677+
SinkElement e, string input, string kind, Provenance provenance, string model
678+
) {
679+
e.isSink(input, kind, provenance, model) and
680+
(
681+
provenance.isManual()
682+
or
683+
not exists(Provenance p | p.isManual() and e.isSink(_, kind, p, _))
684+
)
685+
}
686+
665687
private predicate summarySpec(string spec) {
666688
exists(SummarizedCallable c |
667689
c.propagatesFlow(spec, _, _, _)
668690
or
669691
c.propagatesFlow(_, spec, _, _)
670692
)
671693
or
672-
any(SourceElement s).isSource(spec, _, _, _)
694+
isRelevantSource(_, spec, _, _, _)
673695
or
674-
any(SinkElement s).isSink(spec, _, _, _)
696+
isRelevantSink(_, spec, _, _, _)
675697
}
676698

677699
import AccessPathSyntax::AccessPath<summarySpec/1>
@@ -1034,7 +1056,7 @@ module Make<
10341056
SourceElement source, SummaryComponentStack s, string kind, string model
10351057
) {
10361058
exists(string outSpec |
1037-
source.isSource(outSpec, kind, _, model) and
1059+
isRelevantSource(source, outSpec, kind, _, model) and
10381060
External::interpretSpec(outSpec, s)
10391061
)
10401062
}
@@ -1057,7 +1079,7 @@ module Make<
10571079
SinkElement sink, SummaryComponentStack s, string kind, string model
10581080
) {
10591081
exists(string inSpec |
1060-
sink.isSink(inSpec, kind, _, model) and
1082+
isRelevantSink(sink, inSpec, kind, _, model) and
10611083
External::interpretSpec(inSpec, s)
10621084
)
10631085
}

0 commit comments

Comments
 (0)