Skip to content

Commit 55ce976

Browse files
authored
Merge branch 'main' into swift/case-let-dataflow
2 parents 2a5f29c + b00104e commit 55ce976

File tree

100 files changed

+1487
-724
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+1487
-724
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: fix
3+
---
4+
* Fixed some accidental predicate visibility in the backwards-compatible wrapper for data flow configurations. In particular `DataFlow::hasFlowPath`, `DataFlow::hasFlow`, `DataFlow::hasFlowTo`, and `DataFlow::hasFlowToExpr` were accidentally exposed in a single version.

cpp/ql/lib/experimental/semmle/code/cpp/semantic/analysis/RangeAnalysisStage.qll

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,29 @@ module RangeStage<DeltaSig D, BoundSig<D> Bounds, LangSig<D> LangParam, UtilSig<
10391039
or
10401040
b = bRight and origdelta = odRight and reason = rRight and bLeft instanceof SemZeroBound
10411041
)
1042+
or
1043+
exists(
1044+
SemRemExpr rem, SemZeroBound b1, SemZeroBound b2, D::Delta d_max, D::Delta d1, D::Delta d2,
1045+
boolean fbe1, boolean fbe2, D::Delta od1, D::Delta od2, SemReason r1, SemReason r2
1046+
|
1047+
rem = e and
1048+
not (upper = true and semPositive(rem.getRightOperand())) and
1049+
not (upper = true and semPositive(rem.getLeftOperand())) and
1050+
boundedRemExpr(rem, b1, true, d1, fbe1, od1, r1) and
1051+
boundedRemExpr(rem, b2, false, d2, fbe2, od2, r2) and
1052+
(
1053+
if D::toFloat(d1).abs() > D::toFloat(d2).abs()
1054+
then (
1055+
b = b1 and d_max = d1 and fromBackEdge = fbe1 and origdelta = od1 and reason = r1
1056+
) else (
1057+
b = b2 and d_max = d2 and fromBackEdge = fbe2 and origdelta = od2 and reason = r2
1058+
)
1059+
)
1060+
|
1061+
upper = true and delta = D::fromFloat(D::toFloat(d_max).abs() - 1)
1062+
or
1063+
upper = false and delta = D::fromFloat(-D::toFloat(d_max).abs() + 1)
1064+
)
10421065
)
10431066
}
10441067

@@ -1065,4 +1088,11 @@ module RangeStage<DeltaSig D, BoundSig<D> Bounds, LangSig<D> LangParam, UtilSig<
10651088
bounded(add.getRightOperand(), b, delta, upper, fromBackEdge, origdelta, reason)
10661089
)
10671090
}
1091+
1092+
private predicate boundedRemExpr(
1093+
SemRemExpr rem, SemZeroBound b, boolean upper, D::Delta delta, boolean fromBackEdge,
1094+
D::Delta origdelta, SemReason reason
1095+
) {
1096+
bounded(rem.getRightOperand(), b, delta, upper, fromBackEdge, origdelta, reason)
1097+
}
10681098
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,6 @@ private module Config implements FullStateConfigSig {
328328
}
329329

330330
private import Impl<Config> as I
331-
import I
332331

333332
/**
334333
* A `Node` augmented with a call context (except for sinks), an access path, and a configuration.
@@ -379,6 +378,8 @@ class PathNode instanceof I::PathNode {
379378
final predicate isSinkGroup(string group) { super.isSinkGroup(group) }
380379
}
381380

381+
module PathGraph = I::PathGraph;
382+
382383
private predicate hasFlow(Node source, Node sink, Configuration config) {
383384
exists(PathNode source0, PathNode sink0 |
384385
hasFlowPath(source0, sink0, config) and
@@ -388,7 +389,7 @@ private predicate hasFlow(Node source, Node sink, Configuration config) {
388389
}
389390

390391
private predicate hasFlowPath(PathNode source, PathNode sink, Configuration config) {
391-
flowPath(source, sink) and source.getConfiguration() = config
392+
I::flowPath(source, sink) and source.getConfiguration() = config
392393
}
393394

394395
private predicate hasFlowTo(Node sink, Configuration config) { hasFlow(_, sink, config) }

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,6 @@ private module Config implements FullStateConfigSig {
328328
}
329329

330330
private import Impl<Config> as I
331-
import I
332331

333332
/**
334333
* A `Node` augmented with a call context (except for sinks), an access path, and a configuration.
@@ -379,6 +378,8 @@ class PathNode instanceof I::PathNode {
379378
final predicate isSinkGroup(string group) { super.isSinkGroup(group) }
380379
}
381380

381+
module PathGraph = I::PathGraph;
382+
382383
private predicate hasFlow(Node source, Node sink, Configuration config) {
383384
exists(PathNode source0, PathNode sink0 |
384385
hasFlowPath(source0, sink0, config) and
@@ -388,7 +389,7 @@ private predicate hasFlow(Node source, Node sink, Configuration config) {
388389
}
389390

390391
private predicate hasFlowPath(PathNode source, PathNode sink, Configuration config) {
391-
flowPath(source, sink) and source.getConfiguration() = config
392+
I::flowPath(source, sink) and source.getConfiguration() = config
392393
}
393394

394395
private predicate hasFlowTo(Node sink, Configuration config) { hasFlow(_, sink, config) }

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,6 @@ private module Config implements FullStateConfigSig {
328328
}
329329

330330
private import Impl<Config> as I
331-
import I
332331

333332
/**
334333
* A `Node` augmented with a call context (except for sinks), an access path, and a configuration.
@@ -379,6 +378,8 @@ class PathNode instanceof I::PathNode {
379378
final predicate isSinkGroup(string group) { super.isSinkGroup(group) }
380379
}
381380

381+
module PathGraph = I::PathGraph;
382+
382383
private predicate hasFlow(Node source, Node sink, Configuration config) {
383384
exists(PathNode source0, PathNode sink0 |
384385
hasFlowPath(source0, sink0, config) and
@@ -388,7 +389,7 @@ private predicate hasFlow(Node source, Node sink, Configuration config) {
388389
}
389390

390391
private predicate hasFlowPath(PathNode source, PathNode sink, Configuration config) {
391-
flowPath(source, sink) and source.getConfiguration() = config
392+
I::flowPath(source, sink) and source.getConfiguration() = config
392393
}
393394

394395
private predicate hasFlowTo(Node sink, Configuration config) { hasFlow(_, sink, config) }

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,6 @@ private module Config implements FullStateConfigSig {
328328
}
329329

330330
private import Impl<Config> as I
331-
import I
332331

333332
/**
334333
* A `Node` augmented with a call context (except for sinks), an access path, and a configuration.
@@ -379,6 +378,8 @@ class PathNode instanceof I::PathNode {
379378
final predicate isSinkGroup(string group) { super.isSinkGroup(group) }
380379
}
381380

381+
module PathGraph = I::PathGraph;
382+
382383
private predicate hasFlow(Node source, Node sink, Configuration config) {
383384
exists(PathNode source0, PathNode sink0 |
384385
hasFlowPath(source0, sink0, config) and
@@ -388,7 +389,7 @@ private predicate hasFlow(Node source, Node sink, Configuration config) {
388389
}
389390

390391
private predicate hasFlowPath(PathNode source, PathNode sink, Configuration config) {
391-
flowPath(source, sink) and source.getConfiguration() = config
392+
I::flowPath(source, sink) and source.getConfiguration() = config
392393
}
393394

394395
private predicate hasFlowTo(Node sink, Configuration config) { hasFlow(_, sink, config) }

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,6 @@ private module Config implements FullStateConfigSig {
328328
}
329329

330330
private import Impl<Config> as I
331-
import I
332331

333332
/**
334333
* A `Node` augmented with a call context (except for sinks), an access path, and a configuration.
@@ -379,6 +378,8 @@ class PathNode instanceof I::PathNode {
379378
final predicate isSinkGroup(string group) { super.isSinkGroup(group) }
380379
}
381380

381+
module PathGraph = I::PathGraph;
382+
382383
private predicate hasFlow(Node source, Node sink, Configuration config) {
383384
exists(PathNode source0, PathNode sink0 |
384385
hasFlowPath(source0, sink0, config) and
@@ -388,7 +389,7 @@ private predicate hasFlow(Node source, Node sink, Configuration config) {
388389
}
389390

390391
private predicate hasFlowPath(PathNode source, PathNode sink, Configuration config) {
391-
flowPath(source, sink) and source.getConfiguration() = config
392+
I::flowPath(source, sink) and source.getConfiguration() = config
392393
}
393394

394395
private predicate hasFlowTo(Node sink, Configuration config) { hasFlow(_, sink, config) }

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl1.qll

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,6 @@ private module Config implements FullStateConfigSig {
328328
}
329329

330330
private import Impl<Config> as I
331-
import I
332331

333332
/**
334333
* A `Node` augmented with a call context (except for sinks), an access path, and a configuration.
@@ -379,6 +378,8 @@ class PathNode instanceof I::PathNode {
379378
final predicate isSinkGroup(string group) { super.isSinkGroup(group) }
380379
}
381380

381+
module PathGraph = I::PathGraph;
382+
382383
private predicate hasFlow(Node source, Node sink, Configuration config) {
383384
exists(PathNode source0, PathNode sink0 |
384385
hasFlowPath(source0, sink0, config) and
@@ -388,7 +389,7 @@ private predicate hasFlow(Node source, Node sink, Configuration config) {
388389
}
389390

390391
private predicate hasFlowPath(PathNode source, PathNode sink, Configuration config) {
391-
flowPath(source, sink) and source.getConfiguration() = config
392+
I::flowPath(source, sink) and source.getConfiguration() = config
392393
}
393394

394395
private predicate hasFlowTo(Node sink, Configuration config) { hasFlow(_, sink, config) }

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl2.qll

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,6 @@ private module Config implements FullStateConfigSig {
328328
}
329329

330330
private import Impl<Config> as I
331-
import I
332331

333332
/**
334333
* A `Node` augmented with a call context (except for sinks), an access path, and a configuration.
@@ -379,6 +378,8 @@ class PathNode instanceof I::PathNode {
379378
final predicate isSinkGroup(string group) { super.isSinkGroup(group) }
380379
}
381380

381+
module PathGraph = I::PathGraph;
382+
382383
private predicate hasFlow(Node source, Node sink, Configuration config) {
383384
exists(PathNode source0, PathNode sink0 |
384385
hasFlowPath(source0, sink0, config) and
@@ -388,7 +389,7 @@ private predicate hasFlow(Node source, Node sink, Configuration config) {
388389
}
389390

390391
private predicate hasFlowPath(PathNode source, PathNode sink, Configuration config) {
391-
flowPath(source, sink) and source.getConfiguration() = config
392+
I::flowPath(source, sink) and source.getConfiguration() = config
392393
}
393394

394395
private predicate hasFlowTo(Node sink, Configuration config) { hasFlow(_, sink, config) }

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowImpl3.qll

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,6 @@ private module Config implements FullStateConfigSig {
328328
}
329329

330330
private import Impl<Config> as I
331-
import I
332331

333332
/**
334333
* A `Node` augmented with a call context (except for sinks), an access path, and a configuration.
@@ -379,6 +378,8 @@ class PathNode instanceof I::PathNode {
379378
final predicate isSinkGroup(string group) { super.isSinkGroup(group) }
380379
}
381380

381+
module PathGraph = I::PathGraph;
382+
382383
private predicate hasFlow(Node source, Node sink, Configuration config) {
383384
exists(PathNode source0, PathNode sink0 |
384385
hasFlowPath(source0, sink0, config) and
@@ -388,7 +389,7 @@ private predicate hasFlow(Node source, Node sink, Configuration config) {
388389
}
389390

390391
private predicate hasFlowPath(PathNode source, PathNode sink, Configuration config) {
391-
flowPath(source, sink) and source.getConfiguration() = config
392+
I::flowPath(source, sink) and source.getConfiguration() = config
392393
}
393394

394395
private predicate hasFlowTo(Node sink, Configuration config) { hasFlow(_, sink, config) }

0 commit comments

Comments
 (0)