Skip to content

Commit 125c013

Browse files
authored
Merge branch 'main' into skip-safe-conversions-in-range-analysis
2 parents 61bafd3 + 86cc59e commit 125c013

File tree

367 files changed

+8481
-3745
lines changed

Some content is hidden

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

367 files changed

+8481
-3745
lines changed

.github/workflows/check-change-note.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
- "*/ql/src/**/*.qll"
99
- "*/ql/lib/**/*.ql"
1010
- "*/ql/lib/**/*.qll"
11+
- "*/ql/lib/**/*.yml"
1112
- "!**/experimental/**"
1213
- "!ql/**"
1314
- "!swift/**"

.github/workflows/close-stale.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313

1414
steps:
15-
- uses: actions/stale@v7
15+
- uses: actions/stale@v8
1616
with:
1717
repo-token: ${{ secrets.GITHUB_TOKEN }}
1818
stale-issue-message: 'This issue is stale because it has been open 14 days with no activity. Comment or remove the `Stale` label in order to avoid having this issue closed in 7 days.'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
---
22
category: deprecated
33
---
4-
* The `SslContextCallAbstractConfig`, `SslContextCallConfig`, `SslContextCallBannedProtocolConfig`, `SslContextCallTls12ProtocolConfig`, `SslContextCallTls13ProtocolConfig`, `SslContextCallTlsProtocolConfig`, `SslContextFlowsToSetOptionConfig`, `SslOptionConfig` dataflow configurations from `BoostorgAsio` have been deprecated. Please use `SslContextCallConfigSig`, `SslContextCallMake`, `SslContextCallFlow`, `SslContextCallBannedProtocolFlow`, `SslContextCallTls12ProtocolFlow`, `SslContextCallTls13ProtocolFlow`, `SslContextCallTlsProtocolFlow`, `SslContextFlowsToSetOptionFlow`.
4+
* The `SslContextCallAbstractConfig`, `SslContextCallConfig`, `SslContextCallBannedProtocolConfig`, `SslContextCallTls12ProtocolConfig`, `SslContextCallTls13ProtocolConfig`, `SslContextCallTlsProtocolConfig`, `SslContextFlowsToSetOptionConfig`, `SslOptionConfig` dataflow configurations from `BoostorgAsio` have been deprecated. Please use `SslContextCallConfigSig`, `SslContextCallGlobal`, `SslContextCallFlow`, `SslContextCallBannedProtocolFlow`, `SslContextCallTls12ProtocolFlow`, `SslContextCallTls13ProtocolFlow`, `SslContextCallTlsProtocolFlow`, `SslContextFlowsToSetOptionFlow`.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
category: deprecated
3+
---
4+
* The recently introduced new data flow and taint tracking APIs have had a
5+
number of module and predicate renamings. The old APIs remain in place for
6+
now.

cpp/ql/lib/experimental/semmle/code/cpp/rangeanalysis/ExtendedRangeAnalysis.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ import semmle.code.cpp.rangeanalysis.SimpleRangeAnalysis
33
// Import each extension we want to enable
44
import extensions.SubtractSelf
55
import extensions.ConstantBitwiseAndExprRange
6+
import extensions.StrlenLiteralRangeExpr
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
private import cpp
2+
private import experimental.semmle.code.cpp.models.interfaces.SimpleRangeAnalysisExpr
3+
4+
/**
5+
* Provides range analysis information for calls to `strlen` on literal strings.
6+
* For example, the range of `strlen("literal")` will be 7.
7+
*/
8+
class StrlenLiteralRangeExpr extends SimpleRangeAnalysisExpr, FunctionCall {
9+
StrlenLiteralRangeExpr() {
10+
getTarget().hasGlobalOrStdName("strlen") and getArgument(0).isConstant()
11+
}
12+
13+
override int getLowerBounds() { result = getArgument(0).getValue().length() }
14+
15+
override int getUpperBounds() { result = getArgument(0).getValue().length() }
16+
17+
override predicate dependsOnChild(Expr e) { none() }
18+
}

cpp/ql/lib/experimental/semmle/code/cpp/security/PrivateCleartextWrite.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ module PrivateCleartextWrite {
5454
predicate isBarrier(DataFlow::Node node) { node instanceof Sanitizer }
5555
}
5656

57-
module WriteFlow = TaintTracking::Make<WriteConfig>;
57+
module WriteFlow = TaintTracking::Global<WriteConfig>;
5858

5959
class PrivateDataSource extends Source {
6060
PrivateDataSource() { this.getExpr() instanceof PrivateDataExpr }

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

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Provides an implementation of global (interprocedural) data flow. This file
33
* re-exports the local (intraprocedural) data flow analysis from
44
* `DataFlowImplSpecific::Public` and adds a global analysis, mainly exposed
5-
* through the `Make` and `MakeWithState` modules.
5+
* through the `Global` and `GlobalWithState` modules.
66
*/
77

88
private import DataFlowImplCommon
@@ -73,10 +73,10 @@ signature module ConfigSig {
7373
*/
7474
default FlowFeature getAFeature() { none() }
7575

76-
/** Holds if sources should be grouped in the result of `hasFlowPath`. */
76+
/** Holds if sources should be grouped in the result of `flowPath`. */
7777
default predicate sourceGrouping(Node source, string sourceGroup) { none() }
7878

79-
/** Holds if sinks should be grouped in the result of `hasFlowPath`. */
79+
/** Holds if sinks should be grouped in the result of `flowPath`. */
8080
default predicate sinkGrouping(Node sink, string sinkGroup) { none() }
8181

8282
/**
@@ -166,10 +166,10 @@ signature module StateConfigSig {
166166
*/
167167
default FlowFeature getAFeature() { none() }
168168

169-
/** Holds if sources should be grouped in the result of `hasFlowPath`. */
169+
/** Holds if sources should be grouped in the result of `flowPath`. */
170170
default predicate sourceGrouping(Node source, string sourceGroup) { none() }
171171

172-
/** Holds if sinks should be grouped in the result of `hasFlowPath`. */
172+
/** Holds if sinks should be grouped in the result of `flowPath`. */
173173
default predicate sinkGrouping(Node sink, string sinkGroup) { none() }
174174

175175
/**
@@ -182,15 +182,15 @@ signature module StateConfigSig {
182182
}
183183

184184
/**
185-
* Gets the exploration limit for `hasPartialFlow` and `hasPartialFlowRev`
185+
* Gets the exploration limit for `partialFlow` and `partialFlowRev`
186186
* measured in approximate number of interprocedural steps.
187187
*/
188188
signature int explorationLimitSig();
189189

190190
/**
191-
* The output of a data flow computation.
191+
* The output of a global data flow computation.
192192
*/
193-
signature module DataFlowSig {
193+
signature module GlobalFlowSig {
194194
/**
195195
* A `Node` augmented with a call context (except for sinks) and an access path.
196196
* Only those `PathNode`s that are reachable from a source, and which can reach a sink, are generated.
@@ -203,28 +203,28 @@ signature module DataFlowSig {
203203
* The corresponding paths are generated from the end-points and the graph
204204
* included in the module `PathGraph`.
205205
*/
206-
predicate hasFlowPath(PathNode source, PathNode sink);
206+
predicate flowPath(PathNode source, PathNode sink);
207207

208208
/**
209209
* Holds if data can flow from `source` to `sink`.
210210
*/
211-
predicate hasFlow(Node source, Node sink);
211+
predicate flow(Node source, Node sink);
212212

213213
/**
214214
* Holds if data can flow from some source to `sink`.
215215
*/
216-
predicate hasFlowTo(Node sink);
216+
predicate flowTo(Node sink);
217217

218218
/**
219219
* Holds if data can flow from some source to `sink`.
220220
*/
221-
predicate hasFlowToExpr(DataFlowExpr sink);
221+
predicate flowToExpr(DataFlowExpr sink);
222222
}
223223

224224
/**
225-
* Constructs a standard data flow computation.
225+
* Constructs a global data flow computation.
226226
*/
227-
module Make<ConfigSig Config> implements DataFlowSig {
227+
module Global<ConfigSig Config> implements GlobalFlowSig {
228228
private module C implements FullStateConfigSig {
229229
import DefaultState<Config>
230230
import Config
@@ -233,17 +233,27 @@ module Make<ConfigSig Config> implements DataFlowSig {
233233
import Impl<C>
234234
}
235235

236+
/** DEPRECATED: Use `Global` instead. */
237+
deprecated module Make<ConfigSig Config> implements GlobalFlowSig {
238+
import Global<Config>
239+
}
240+
236241
/**
237-
* Constructs a data flow computation using flow state.
242+
* Constructs a global data flow computation using flow state.
238243
*/
239-
module MakeWithState<StateConfigSig Config> implements DataFlowSig {
244+
module GlobalWithState<StateConfigSig Config> implements GlobalFlowSig {
240245
private module C implements FullStateConfigSig {
241246
import Config
242247
}
243248

244249
import Impl<C>
245250
}
246251

252+
/** DEPRECATED: Use `GlobalWithState` instead. */
253+
deprecated module MakeWithState<StateConfigSig Config> implements GlobalFlowSig {
254+
import GlobalWithState<Config>
255+
}
256+
247257
signature class PathNodeSig {
248258
/** Gets a textual representation of this element. */
249259
string toString();

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

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ signature module FullStateConfigSig {
9191
*/
9292
FlowFeature getAFeature();
9393

94-
/** Holds if sources should be grouped in the result of `hasFlowPath`. */
94+
/** Holds if sources should be grouped in the result of `flowPath`. */
9595
predicate sourceGrouping(Node source, string sourceGroup);
9696

97-
/** Holds if sinks should be grouped in the result of `hasFlowPath`. */
97+
/** Holds if sinks should be grouped in the result of `flowPath`. */
9898
predicate sinkGrouping(Node sink, string sinkGroup);
9999

100100
/**
@@ -445,11 +445,7 @@ module Impl<FullStateConfigSig Config> {
445445
}
446446

447447
private module Stage1 implements StageSig {
448-
class Ap extends int {
449-
// workaround for bad functionality-induced joins (happens when using `Unit`)
450-
pragma[nomagic]
451-
Ap() { this in [0 .. 1] and this < 1 }
452-
}
448+
class Ap = Unit;
453449

454450
private class Cc = boolean;
455451

@@ -3633,7 +3629,7 @@ module Impl<FullStateConfigSig Config> {
36333629
* The corresponding paths are generated from the end-points and the graph
36343630
* included in the module `PathGraph`.
36353631
*/
3636-
predicate hasFlowPath(PathNode source, PathNode sink) {
3632+
predicate flowPath(PathNode source, PathNode sink) {
36373633
exists(PathNodeImpl flowsource, PathNodeImpl flowsink |
36383634
source = flowsource and sink = flowsink
36393635
|
@@ -3643,6 +3639,9 @@ module Impl<FullStateConfigSig Config> {
36433639
)
36443640
}
36453641

3642+
/** DEPRECATED: Use `flowPath` instead. */
3643+
deprecated predicate hasFlowPath = flowPath/2;
3644+
36463645
private predicate flowsTo(PathNodeImpl flowsource, PathNodeSink flowsink, Node source, Node sink) {
36473646
flowsource.isSource() and
36483647
flowsource.getNodeEx().asNode() = source and
@@ -3653,17 +3652,26 @@ module Impl<FullStateConfigSig Config> {
36533652
/**
36543653
* Holds if data can flow from `source` to `sink`.
36553654
*/
3656-
predicate hasFlow(Node source, Node sink) { flowsTo(_, _, source, sink) }
3655+
predicate flow(Node source, Node sink) { flowsTo(_, _, source, sink) }
3656+
3657+
/** DEPRECATED: Use `flow` instead. */
3658+
deprecated predicate hasFlow = flow/2;
36573659

36583660
/**
36593661
* Holds if data can flow from some source to `sink`.
36603662
*/
3661-
predicate hasFlowTo(Node sink) { sink = any(PathNodeSink n).getNodeEx().asNode() }
3663+
predicate flowTo(Node sink) { sink = any(PathNodeSink n).getNodeEx().asNode() }
3664+
3665+
/** DEPRECATED: Use `flowTo` instead. */
3666+
deprecated predicate hasFlowTo = flowTo/1;
36623667

36633668
/**
36643669
* Holds if data can flow from some source to `sink`.
36653670
*/
3666-
predicate hasFlowToExpr(DataFlowExpr sink) { hasFlowTo(exprNode(sink)) }
3671+
predicate flowToExpr(DataFlowExpr sink) { flowTo(exprNode(sink)) }
3672+
3673+
/** DEPRECATED: Use `flowToExpr` instead. */
3674+
deprecated predicate hasFlowToExpr = flowToExpr/1;
36673675

36683676
private predicate finalStats(
36693677
boolean fwd, int nodes, int fields, int conscand, int states, int tuples
@@ -4574,7 +4582,7 @@ module Impl<FullStateConfigSig Config> {
45744582
*
45754583
* To use this in a `path-problem` query, import the module `PartialPathGraph`.
45764584
*/
4577-
predicate hasPartialFlow(PartialPathNode source, PartialPathNode node, int dist) {
4585+
predicate partialFlow(PartialPathNode source, PartialPathNode node, int dist) {
45784586
partialFlow(source, node) and
45794587
dist = node.getSourceDistance()
45804588
}
@@ -4594,7 +4602,7 @@ module Impl<FullStateConfigSig Config> {
45944602
* Note that reverse flow has slightly lower precision than the corresponding
45954603
* forward flow, as reverse flow disregards type pruning among other features.
45964604
*/
4597-
predicate hasPartialFlowRev(PartialPathNode node, PartialPathNode sink, int dist) {
4605+
predicate partialFlowRev(PartialPathNode node, PartialPathNode sink, int dist) {
45984606
revPartialFlow(node, sink) and
45994607
dist = node.getSinkDistance()
46004608
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* DEPRECATED: Use `Make` and `MakeWithState` instead.
2+
* DEPRECATED: Use `Global` and `GlobalWithState` instead.
33
*
44
* Provides a `Configuration` class backwards-compatible interface to the data
55
* flow library.
@@ -388,7 +388,7 @@ private predicate hasFlow(Node source, Node sink, Configuration config) {
388388
}
389389

390390
private predicate hasFlowPath(PathNode source, PathNode sink, Configuration config) {
391-
hasFlowPath(source, sink) and source.getConfiguration() = config
391+
flowPath(source, sink) and source.getConfiguration() = config
392392
}
393393

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

0 commit comments

Comments
 (0)