Skip to content

Commit d98abfe

Browse files
committed
Rust: Source/sink/barrier MaD trait models apply to implementations
1 parent c8783c1 commit d98abfe

18 files changed

Lines changed: 352 additions & 309 deletions

File tree

cpp/ql/lib/semmle/code/cpp/dataflow/internal/FlowSummaryImpl.qll

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ module Input implements InputSig<Location, DataFlowImplSpecific::CppDataFlow> {
1717

1818
class SummarizedCallableBase = Function;
1919

20-
class SourceBase = Function;
21-
22-
class SinkBase = Function;
23-
2420
class FlowSummaryCallBase = CallInstruction;
2521

2622
predicate callableFromSource(SummarizedCallableBase c) { exists(c.getBlock()) }
@@ -232,7 +228,7 @@ private module Input2 implements Impl::Private::InputSig2 {
232228

233229
bindingset[source, sc]
234230
SourceSinkReportingElement getASourceReportingElement(
235-
Input::SourceBase source, Impl::Private::SummaryComponent sc
231+
Input::SummarizedCallableBase source, Impl::Private::SummaryComponent sc
236232
) {
237233
exists(Call call | call.getTarget() = source |
238234
sc = Impl::Private::SummaryComponent::return(_) and
@@ -312,7 +308,7 @@ private module Input2 implements Impl::Private::InputSig2 {
312308

313309
bindingset[sink, sc]
314310
SourceSinkReportingElement getASinkReportingElement(
315-
Input::SinkBase sink, Impl::Private::SummaryComponent sc
311+
Input::SummarizedCallableBase sink, Impl::Private::SummaryComponent sc
316312
) {
317313
exists(Call call, ArgumentPosition pos |
318314
call.getTarget() = sink and
@@ -525,9 +521,10 @@ private class SourceModelFunction extends Public::SourceElement instanceof Funct
525521
}
526522

527523
override predicate isSource(
528-
string output, string kind, Public::Provenance provenance, string model
524+
string output, string kind, Public::Provenance provenance, boolean isExact, string model
529525
) {
530-
sourceModel(namespace, type, subtypes, name, signature, ext, output, kind, provenance, model)
526+
sourceModel(namespace, type, subtypes, name, signature, ext, output, kind, provenance, model) and
527+
isExact = true
531528
}
532529
}
533530

@@ -544,7 +541,10 @@ private class SinkModelFunction extends Public::SinkElement instanceof Function
544541
this = interpretElement(namespace, type, subtypes, name, signature, ext)
545542
}
546543

547-
override predicate isSink(string input, string kind, Public::Provenance provenance, string model) {
548-
sinkModel(namespace, type, subtypes, name, signature, ext, input, kind, provenance, model)
544+
override predicate isSink(
545+
string input, string kind, Public::Provenance provenance, boolean isExact, string model
546+
) {
547+
sinkModel(namespace, type, subtypes, name, signature, ext, input, kind, provenance, model) and
548+
isExact = true
549549
}
550550
}

csharp/ql/lib/semmle/code/csharp/dataflow/internal/FlowSummaryImpl.qll

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,10 @@ module Input implements InputSig<Location, DataFlowImplSpecific::CsharpDataFlow>
3030
)
3131
}
3232

33-
class SourceBase extends Void {
33+
class FlowSummaryCallBase extends Void {
3434
Location getLocation() { none() }
3535
}
3636

37-
class SinkBase = SourceBase;
38-
39-
class FlowSummaryCallBase = SourceBase;
40-
4137
DataFlowCallable getSummarizedCallableAsDataFlowCallable(SummarizedCallableBase c) {
4238
result.asSummarizedCallable() = c
4339
}

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,10 @@ module Input implements InputSig<Location, DataFlowImplSpecific::GoDataFlow> {
2727

2828
class SummarizedCallableBase = Callable;
2929

30-
class SourceBase extends Void {
30+
class FlowSummaryCallBase extends Void {
3131
Location getLocation() { none() }
3232
}
3333

34-
class SinkBase = SourceBase;
35-
36-
class FlowSummaryCallBase = SourceBase;
37-
3834
predicate callableFromSource(SummarizedCallableBase c) { exists(c.getFuncDef()) }
3935

4036
DataFlowCallable getSummarizedCallableAsDataFlowCallable(SummarizedCallableBase c) {

java/ql/lib/semmle/code/java/dataflow/internal/FlowSummaryImpl.qll

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,10 @@ module Input implements InputSig<Location, DataFlowImplSpecific::JavaDataFlow> {
3737
sc.asCallable() = any(Callable c | c.fromSource() and not c.isStub())
3838
}
3939

40-
class SourceBase extends Void {
40+
class FlowSummaryCallBase extends Void {
4141
Location getLocation() { none() }
4242
}
4343

44-
class SinkBase = SourceBase;
45-
46-
class FlowSummaryCallBase = SourceBase;
47-
4844
DataFlowCallable getSummarizedCallableAsDataFlowCallable(SummarizedCallableBase c) {
4945
result.asSummarizedCallable() = c
5046
}

javascript/ql/lib/semmle/javascript/dataflow/internal/FlowSummaryPrivate.qll

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,10 @@ class SummarizedCallableBase extends string {
2424
Location getLocation() { none() }
2525
}
2626

27-
class SourceBase extends Void {
27+
class FlowSummaryCallBase extends Void {
2828
Location getLocation() { none() }
2929
}
3030

31-
class SinkBase = SourceBase;
32-
33-
class FlowSummaryCallBase = SourceBase;
34-
3531
DataFlowCallable getSummarizedCallableAsDataFlowCallable(SummarizedCallableBase c) {
3632
result.asLibraryCallable() = c
3733
}

python/ql/lib/semmle/python/dataflow/new/internal/FlowSummaryImpl.qll

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,10 @@ module Input implements InputSig<Location, DataFlowImplSpecific::PythonDataFlow>
2121
Location getLocation() { none() }
2222
}
2323

24-
class SourceBase extends Void {
24+
class FlowSummaryCallBase extends Void {
2525
Location getLocation() { none() }
2626
}
2727

28-
class SinkBase = SourceBase;
29-
30-
class FlowSummaryCallBase = SourceBase;
31-
3228
predicate callableFromSource(SummarizedCallableBase c) { none() }
3329

3430
DataFlowCallable getSummarizedCallableAsDataFlowCallable(SummarizedCallableBase c) {

ruby/ql/lib/codeql/ruby/dataflow/internal/FlowSummaryImpl.qll

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,10 @@ module Input implements InputSig<Location, DataFlowImplSpecific::RubyDataFlow> {
2020
Location getLocation() { result instanceof EmptyLocation }
2121
}
2222

23-
class SourceBase extends Void {
23+
class FlowSummaryCallBase extends Void {
2424
Location getLocation() { none() }
2525
}
2626

27-
class SinkBase = SourceBase;
28-
29-
class FlowSummaryCallBase = SourceBase;
30-
3127
predicate callableFromSource(SummarizedCallableBase c) { none() }
3228

3329
DataFlowCallable getSummarizedCallableAsDataFlowCallable(SummarizedCallableBase c) {

rust/ql/lib/codeql/rust/dataflow/FlowBarrier.qll

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ module FlowBarrier {
4444
Range() { any() }
4545

4646
override predicate isBarrier(
47-
string output, string kind, Impl::Public::Provenance provenance, string model
47+
string output, string kind, Impl::Public::Provenance provenance, boolean isExact, string model
4848
) {
49-
this.isBarrier(output, kind) and provenance = "manual" and model = ""
49+
this.isBarrier(output, kind) and provenance = "manual" and isExact = true and model = ""
5050
}
5151

5252
/**
@@ -67,9 +67,13 @@ module FlowBarrierGuard {
6767
Range() { any() }
6868

6969
override predicate isBarrierGuard(
70-
string input, string branch, string kind, Impl::Public::Provenance provenance, string model
70+
string input, string branch, string kind, Impl::Public::Provenance provenance,
71+
boolean isExact, string model
7172
) {
72-
this.isBarrierGuard(input, branch, kind) and provenance = "manual" and model = ""
73+
this.isBarrierGuard(input, branch, kind) and
74+
provenance = "manual" and
75+
isExact = true and
76+
model = ""
7377
}
7478

7579
/**

rust/ql/lib/codeql/rust/dataflow/FlowSink.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ module FlowSink {
3636
Range() { any() }
3737

3838
override predicate isSink(
39-
string input, string kind, Impl::Public::Provenance provenance, string model
39+
string input, string kind, Impl::Public::Provenance provenance, boolean isExact, string model
4040
) {
41-
this.isSink(input, kind) and provenance = "manual" and model = ""
41+
this.isSink(input, kind) and provenance = "manual" and isExact = true and model = ""
4242
}
4343

4444
/**

rust/ql/lib/codeql/rust/dataflow/FlowSource.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ module FlowSource {
4242
Range() { any() }
4343

4444
override predicate isSource(
45-
string output, string kind, Impl::Public::Provenance provenance, string model
45+
string output, string kind, Impl::Public::Provenance provenance, boolean isExact, string model
4646
) {
47-
this.isSource(output, kind) and provenance = "manual" and model = ""
47+
this.isSource(output, kind) and provenance = "manual" and isExact = true and model = ""
4848
}
4949

5050
/**

0 commit comments

Comments
 (0)