Skip to content

Commit b4df557

Browse files
committed
Merge branch 'main' into redsun82/swift-do-not-extract-inactive-ifconfig-clauses
2 parents 3fd8136 + 4614074 commit b4df557

File tree

683 files changed

+39027
-2942
lines changed

Some content is hidden

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

683 files changed

+39027
-2942
lines changed

.bazelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
build --repo_env=CC=clang --repo_env=CXX=clang++ --copt="-std=c++17"
1+
build --repo_env=CC=clang --repo_env=CXX=clang++ --cxxopt="-std=c++17"
22

33
try-import %workspace%/local.bazelrc

.github/workflows/swift-codegen.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ on:
44
pull_request:
55
paths:
66
- "swift/**"
7+
- "misc/bazel/**"
8+
- "*.bazel*"
79
- .github/workflows/swift-codegen.yml
810
- .github/actions/fetch-codeql/action.yml
911
branches:

.github/workflows/swift-integration-tests.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ on:
44
pull_request:
55
paths:
66
- "swift/**"
7+
- "misc/bazel/**"
8+
- "*.bazel*"
79
- .github/workflows/swift-integration-tests.yml
810
- .github/actions/fetch-codeql/action.yml
911
- codeql-workspace.yml
@@ -30,6 +32,14 @@ jobs:
3032
- name: Build Swift extractor
3133
run: |
3234
bazel run //swift:create-extractor-pack
35+
- name: Get Swift version
36+
id: get_swift_version
37+
run: |
38+
VERSION=$(bazel run //swift/extractor -- --version | sed -ne 's/.*version \(\S*\).*/\1/p')
39+
echo "::set-output name=version::$VERSION"
40+
- uses: swift-actions/setup-swift@v1
41+
with:
42+
swift-version: "${{steps.get_swift_version.outputs.version}}"
3343
- name: Run integration tests
3444
run: |
3545
python integration-tests/runner.py

.github/workflows/swift-qltest.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ on:
44
pull_request:
55
paths:
66
- "swift/**"
7+
- "misc/bazel/**"
8+
- "*.bazel*"
79
- .github/workflows/swift-qltest.yml
810
- .github/actions/fetch-codeql/action.yml
911
- codeql-workspace.yml

config/identical-files.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,11 @@
7373
"ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowImplConsistency.qll",
7474
"swift/ql/lib/codeql/swift/dataflow/internal/DataFlowImplConsistency.qll"
7575
],
76-
"DataFlow Java/C# Flow Summaries": [
76+
"DataFlow Java/C#/Ruby/Python/Swift Flow Summaries": [
7777
"java/ql/lib/semmle/code/java/dataflow/internal/FlowSummaryImpl.qll",
7878
"csharp/ql/lib/semmle/code/csharp/dataflow/internal/FlowSummaryImpl.qll",
7979
"ruby/ql/lib/codeql/ruby/dataflow/internal/FlowSummaryImpl.qll",
80+
"python/ql/lib/semmle/python/dataflow/new/internal/FlowSummaryImpl.qll",
8081
"swift/ql/lib/codeql/swift/dataflow/internal/FlowSummaryImpl.qll"
8182
],
8283
"SsaReadPosition Java/C#": [
@@ -532,7 +533,7 @@
532533
"java/ql/lib/semmle/code/java/dataflow/internal/AccessPathSyntax.qll",
533534
"javascript/ql/lib/semmle/javascript/frameworks/data/internal/AccessPathSyntax.qll",
534535
"ruby/ql/lib/codeql/ruby/dataflow/internal/AccessPathSyntax.qll",
535-
"python/ql/lib/semmle/python/frameworks/data/internal/AccessPathSyntax.qll",
536+
"python/ql/lib/semmle/python/dataflow/new/internal/AccessPathSyntax.qll",
536537
"swift/ql/lib/codeql/swift/dataflow/internal/AccessPathSyntax.qll"
537538
],
538539
"IncompleteUrlSubstringSanitization": [
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
category: deprecated
3+
---
4+
* Some classes/modules with upper-case acronyms in their name have been renamed to follow our style-guide.
5+
The old name still exists as a deprecated alias.

cpp/ql/lib/experimental/semmle/code/cpp/dataflow/ProductFlow.qll

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import semmle.code.cpp.ir.dataflow.DataFlow
2-
import semmle.code.cpp.ir.dataflow.DataFlow2
1+
import experimental.semmle.code.cpp.ir.dataflow.DataFlow
2+
import experimental.semmle.code.cpp.ir.dataflow.DataFlow2
33

44
module ProductFlow {
55
abstract class Configuration extends string {
@@ -11,14 +11,43 @@ module ProductFlow {
1111
*
1212
* `source1` and `source2` must belong to the same callable.
1313
*/
14-
abstract predicate isSourcePair(DataFlow::Node source1, DataFlow::Node source2);
14+
predicate isSourcePair(DataFlow::Node source1, DataFlow::Node source2) { none() }
15+
16+
/**
17+
* Holds if `(source1, source2)` is a relevant data flow source with initial states `state1`
18+
* and `state2`, respectively.
19+
*
20+
* `source1` and `source2` must belong to the same callable.
21+
*/
22+
predicate isSourcePair(
23+
DataFlow::Node source1, string state1, DataFlow::Node source2, string state2
24+
) {
25+
state1 = "" and
26+
state2 = "" and
27+
this.isSourcePair(source1, source2)
28+
}
1529

1630
/**
1731
* Holds if `(sink1, sink2)` is a relevant data flow sink.
1832
*
1933
* `sink1` and `sink2` must belong to the same callable.
2034
*/
21-
abstract predicate isSinkPair(DataFlow::Node sink1, DataFlow::Node sink2);
35+
predicate isSinkPair(DataFlow::Node sink1, DataFlow::Node sink2) { none() }
36+
37+
/**
38+
* Holds if `(sink1, sink2)` is a relevant data flow sink with final states `state1`
39+
* and `state2`, respectively.
40+
*
41+
* `sink1` and `sink2` must belong to the same callable.
42+
*/
43+
predicate isSinkPair(
44+
DataFlow::Node sink1, DataFlow::FlowState state1, DataFlow::Node sink2,
45+
DataFlow::FlowState state2
46+
) {
47+
state1 = "" and
48+
state2 = "" and
49+
this.isSinkPair(sink1, sink2)
50+
}
2251

2352
predicate hasFlowPath(
2453
DataFlow::PathNode source1, DataFlow2::PathNode source2, DataFlow::PathNode sink1,
@@ -34,28 +63,28 @@ module ProductFlow {
3463
class Conf1 extends DataFlow::Configuration {
3564
Conf1() { this = "Conf1" }
3665

37-
override predicate isSource(DataFlow::Node source) {
38-
exists(Configuration conf | conf.isSourcePair(source, _))
66+
override predicate isSource(DataFlow::Node source, string state) {
67+
exists(Configuration conf | conf.isSourcePair(source, state, _, _))
3968
}
4069

41-
override predicate isSink(DataFlow::Node sink) {
42-
exists(Configuration conf | conf.isSinkPair(sink, _))
70+
override predicate isSink(DataFlow::Node sink, string state) {
71+
exists(Configuration conf | conf.isSinkPair(sink, state, _, _))
4372
}
4473
}
4574

4675
class Conf2 extends DataFlow2::Configuration {
4776
Conf2() { this = "Conf2" }
4877

49-
override predicate isSource(DataFlow::Node source) {
78+
override predicate isSource(DataFlow::Node source, string state) {
5079
exists(Configuration conf, DataFlow::Node source1 |
51-
conf.isSourcePair(source1, source) and
80+
conf.isSourcePair(source1, _, source, state) and
5281
any(Conf1 c).hasFlow(source1, _)
5382
)
5483
}
5584

56-
override predicate isSink(DataFlow::Node sink) {
85+
override predicate isSink(DataFlow::Node sink, string state) {
5786
exists(Configuration conf, DataFlow::Node sink1 |
58-
conf.isSinkPair(sink1, sink) and any(Conf1 c).hasFlow(_, sink1)
87+
conf.isSinkPair(sink1, _, sink, state) and any(Conf1 c).hasFlow(_, sink1)
5988
)
6089
}
6190
}
@@ -65,7 +94,7 @@ module ProductFlow {
6594
Configuration conf, DataFlow::PathNode source1, DataFlow2::PathNode source2,
6695
DataFlow::PathNode node1, DataFlow2::PathNode node2
6796
) {
68-
conf.isSourcePair(node1.getNode(), node2.getNode()) and
97+
conf.isSourcePair(node1.getNode(), _, node2.getNode(), _) and
6998
node1 = source1 and
7099
node2 = source2
71100
or
@@ -128,7 +157,7 @@ module ProductFlow {
128157
) {
129158
exists(DataFlow::PathNode mid1, DataFlow2::PathNode mid2 |
130159
reachableInterprocEntry(conf, source1, source2, mid1, mid2) and
131-
conf.isSinkPair(sink1.getNode(), sink2.getNode()) and
160+
conf.isSinkPair(sink1.getNode(), _, sink2.getNode(), _) and
132161
localPathStep1*(mid1, sink1) and
133162
localPathStep2*(mid2, sink2)
134163
)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* Provides a library for local (intra-procedural) and global (inter-procedural)
3+
* data flow analysis: deciding whether data can flow from a _source_ to a
4+
* _sink_. This library differs from the one in `semmle.code.cpp.dataflow` in that
5+
* this library uses the IR (Intermediate Representation) library, which provides
6+
* a more precise semantic representation of the program, whereas the other dataflow
7+
* library uses the more syntax-oriented ASTs. This library should provide more accurate
8+
* results than the AST-based library in most scenarios.
9+
*
10+
* Unless configured otherwise, _flow_ means that the exact value of
11+
* the source may reach the sink. We do not track flow across pointer
12+
* dereferences or array indexing.
13+
*
14+
* To use global (interprocedural) data flow, extend the class
15+
* `DataFlow::Configuration` as documented on that class. To use local
16+
* (intraprocedural) data flow between expressions, call
17+
* `DataFlow::localExprFlow`. For more general cases of local data flow, call
18+
* `DataFlow::localFlow` or `DataFlow::localFlowStep` with arguments of type
19+
* `DataFlow::Node`.
20+
*/
21+
22+
import cpp
23+
24+
module DataFlow {
25+
import experimental.semmle.code.cpp.ir.dataflow.internal.DataFlowImpl
26+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* Provides a `DataFlow2` module, which is a copy of the `DataFlow` module. Use
3+
* this class when data-flow configurations must depend on each other. Two
4+
* classes extending `DataFlow::Configuration` should never depend on each
5+
* other, but one of them should instead depend on a
6+
* `DataFlow2::Configuration`, a `DataFlow3::Configuration`, or a
7+
* `DataFlow4::Configuration`.
8+
*
9+
* See `semmle.code.cpp.ir.dataflow.DataFlow` for the full documentation.
10+
*/
11+
12+
import cpp
13+
14+
module DataFlow2 {
15+
import experimental.semmle.code.cpp.ir.dataflow.internal.DataFlowImpl2
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* Provides a `DataFlow3` module, which is a copy of the `DataFlow` module. Use
3+
* this class when data-flow configurations must depend on each other. Two
4+
* classes extending `DataFlow::Configuration` should never depend on each
5+
* other, but one of them should instead depend on a
6+
* `DataFlow2::Configuration`, a `DataFlow3::Configuration`, or a
7+
* `DataFlow4::Configuration`.
8+
*
9+
* See `semmle.code.cpp.ir.dataflow.DataFlow` for the full documentation.
10+
*/
11+
12+
import cpp
13+
14+
module DataFlow3 {
15+
import experimental.semmle.code.cpp.ir.dataflow.internal.DataFlowImpl3
16+
}

0 commit comments

Comments
 (0)