Skip to content

Commit b683a3c

Browse files
authored
Merge branch 'main' into jb1/16-cryptography-models-libraries-and-queries-migration
2 parents 25203db + d258f69 commit b683a3c

File tree

738 files changed

+88710
-90241
lines changed

Some content is hidden

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

738 files changed

+88710
-90241
lines changed

.github/workflows/csharp-qltest.yml

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ jobs:
5353
slice: ["1/2", "2/2"]
5454
steps:
5555
- uses: actions/checkout@v4
56-
- uses: ./.github/actions/fetch-codeql
5756
- uses: ./csharp/actions/create-extractor-pack
5857
- name: Cache compilation cache
5958
id: query-cache
@@ -62,16 +61,14 @@ jobs:
6261
key: csharp-qltest-${{ matrix.slice }}
6362
- name: Run QL tests
6463
run: |
65-
CODEQL_PATH=$(gh codeql version --format=json | jq -r .unpackedLocation)
66-
# The legacy ASP extractor is not in this repo, so take the one from the nightly build
67-
mv "$CODEQL_PATH/csharp/tools/extractor-asp.jar" "${{ github.workspace }}/csharp/extractor-pack/tools"
68-
# Safe guard against using the bundled extractor
69-
rm -rf "$CODEQL_PATH/csharp"
70-
codeql test run --threads=0 --ram 50000 --slice ${{ matrix.slice }} --search-path "${{ github.workspace }}/csharp/extractor-pack" --check-databases --check-undefined-labels --check-repeated-labels --check-redefined-labels --consistency-queries ql/consistency-queries ql/test --compilation-cache "${{ steps.query-cache.outputs.cache-dir }}"
64+
codeql test run --threads=0 --ram 50000 --slice ${{ matrix.slice }} --search-path extractor-pack --check-databases --check-undefined-labels --check-repeated-labels --check-redefined-labels --consistency-queries ql/consistency-queries ql/test --compilation-cache "${{ steps.query-cache.outputs.cache-dir }}"
7165
env:
7266
GITHUB_TOKEN: ${{ github.token }}
7367
unit-tests:
74-
runs-on: ubuntu-latest
68+
strategy:
69+
matrix:
70+
os: [ubuntu-latest, windows-2019]
71+
runs-on: ${{ matrix.os }}
7572
steps:
7673
- uses: actions/checkout@v4
7774
- name: Setup dotnet
@@ -80,7 +77,25 @@ jobs:
8077
dotnet-version: 7.0.102
8178
- name: Extractor unit tests
8279
run: |
83-
dotnet test -p:RuntimeFrameworkVersion=7.0.2 "${{ github.workspace }}/csharp/extractor/Semmle.Util.Tests"
84-
dotnet test -p:RuntimeFrameworkVersion=7.0.2 "${{ github.workspace }}/csharp/extractor/Semmle.Extraction.Tests"
85-
dotnet test -p:RuntimeFrameworkVersion=7.0.2 "${{ github.workspace }}/csharp/autobuilder/Semmle.Autobuild.CSharp.Tests"
80+
dotnet test -p:RuntimeFrameworkVersion=7.0.2 extractor/Semmle.Util.Tests
81+
dotnet test -p:RuntimeFrameworkVersion=7.0.2 extractor/Semmle.Extraction.Tests
82+
dotnet test -p:RuntimeFrameworkVersion=7.0.2 autobuilder/Semmle.Autobuild.CSharp.Tests
8683
dotnet test -p:RuntimeFrameworkVersion=7.0.2 "${{ github.workspace }}/cpp/autobuilder/Semmle.Autobuild.Cpp.Tests"
84+
shell: bash
85+
stubgentest:
86+
runs-on: ubuntu-latest
87+
steps:
88+
- uses: actions/checkout@v4
89+
- uses: ./csharp/actions/create-extractor-pack
90+
- name: Run stub generator tests
91+
run: |
92+
# Generate (Asp)NetCore stubs
93+
STUBS_PATH=stubs_output
94+
python3 ql/src/Stubs/make_stubs_nuget.py webapp Swashbuckle.AspNetCore.Swagger latest "$STUBS_PATH"
95+
rm -rf ql/test/resources/stubs/_frameworks
96+
# Update existing stubs in the repo with the freshly generated ones
97+
mv "$STUBS_PATH/output/stubs/_frameworks" ql/test/resources/stubs/
98+
git status
99+
codeql test run --threads=0 --search-path extractor-pack --check-databases --check-undefined-labels --check-repeated-labels --check-redefined-labels --consistency-queries ql/consistency-queries -- ql/test/library-tests/dataflow/flowsources/aspremote
100+
env:
101+
GITHUB_TOKEN: ${{ github.token }}

.github/workflows/js-ml-tests.yml

Lines changed: 0 additions & 65 deletions
This file was deleted.

cpp/ql/lib/semmle/code/cpp/File.qll

Lines changed: 20 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -5,155 +5,35 @@
55
import semmle.code.cpp.Element
66
import semmle.code.cpp.Declaration
77
import semmle.code.cpp.metrics.MetricFile
8+
private import codeql.util.FileSystem
89

9-
/** A file or folder. */
10-
class Container extends Locatable, @container {
11-
/**
12-
* Gets the absolute, canonical path of this container, using forward slashes
13-
* as path separator.
14-
*
15-
* The path starts with a _root prefix_ followed by zero or more _path
16-
* segments_ separated by forward slashes.
17-
*
18-
* The root prefix is of one of the following forms:
19-
*
20-
* 1. A single forward slash `/` (Unix-style)
21-
* 2. An upper-case drive letter followed by a colon and a forward slash,
22-
* such as `C:/` (Windows-style)
23-
* 3. Two forward slashes, a computer name, and then another forward slash,
24-
* such as `//FileServer/` (UNC-style)
25-
*
26-
* Path segments are never empty (that is, absolute paths never contain two
27-
* contiguous slashes, except as part of a UNC-style root prefix). Also, path
28-
* segments never contain forward slashes, and no path segment is of the
29-
* form `.` (one dot) or `..` (two dots).
30-
*
31-
* Note that an absolute path never ends with a forward slash, except if it is
32-
* a bare root prefix, that is, the path has no path segments. A container
33-
* whose absolute path has no segments is always a `Folder`, not a `File`.
34-
*/
35-
string getAbsolutePath() { none() } // overridden by subclasses
10+
private module Input implements InputSig {
11+
abstract class ContainerBase extends @container {
12+
abstract string getAbsolutePath();
3613

37-
/**
38-
* Gets the relative path of this file or folder from the root folder of the
39-
* analyzed source location. The relative path of the root folder itself is
40-
* the empty string.
41-
*
42-
* This has no result if the container is outside the source root, that is,
43-
* if the root folder is not a reflexive, transitive parent of this container.
44-
*/
45-
string getRelativePath() {
46-
exists(string absPath, string pref |
47-
absPath = this.getAbsolutePath() and sourceLocationPrefix(pref)
48-
|
49-
absPath = pref and result = ""
50-
or
51-
absPath = pref.regexpReplaceAll("/$", "") + "/" + result and
52-
not result.matches("/%")
53-
)
54-
}
14+
ContainerBase getParentContainer() {
15+
containerparent(unresolveElement(result), underlyingElement(this))
16+
}
5517

56-
/**
57-
* Gets the base name of this container including extension, that is, the last
58-
* segment of its absolute path, or the empty string if it has no segments.
59-
*
60-
* Here are some examples of absolute paths and the corresponding base names
61-
* (surrounded with quotes to avoid ambiguity):
62-
*
63-
* <table border="1">
64-
* <tr><th>Absolute path</th><th>Base name</th></tr>
65-
* <tr><td>"/tmp/tst.js"</td><td>"tst.js"</td></tr>
66-
* <tr><td>"C:/Program Files (x86)"</td><td>"Program Files (x86)"</td></tr>
67-
* <tr><td>"/"</td><td>""</td></tr>
68-
* <tr><td>"C:/"</td><td>""</td></tr>
69-
* <tr><td>"D:/"</td><td>""</td></tr>
70-
* <tr><td>"//FileServer/"</td><td>""</td></tr>
71-
* </table>
72-
*/
73-
string getBaseName() {
74-
result = this.getAbsolutePath().regexpCapture(".*/(([^/]*?)(?:\\.([^.]*))?)", 1)
18+
string toString() { result = this.getAbsolutePath() }
7519
}
7620

77-
/**
78-
* Gets the extension of this container, that is, the suffix of its base name
79-
* after the last dot character, if any.
80-
*
81-
* In particular,
82-
*
83-
* - if the name does not include a dot, there is no extension, so this
84-
* predicate has no result;
85-
* - if the name ends in a dot, the extension is the empty string;
86-
* - if the name contains multiple dots, the extension follows the last dot.
87-
*
88-
* Here are some examples of absolute paths and the corresponding extensions
89-
* (surrounded with quotes to avoid ambiguity):
90-
*
91-
* <table border="1">
92-
* <tr><th>Absolute path</th><th>Extension</th></tr>
93-
* <tr><td>"/tmp/tst.js"</td><td>"js"</td></tr>
94-
* <tr><td>"/tmp/.classpath"</td><td>"classpath"</td></tr>
95-
* <tr><td>"/bin/bash"</td><td>not defined</td></tr>
96-
* <tr><td>"/tmp/tst2."</td><td>""</td></tr>
97-
* <tr><td>"/tmp/x.tar.gz"</td><td>"gz"</td></tr>
98-
* </table>
99-
*/
100-
string getExtension() {
101-
result = this.getAbsolutePath().regexpCapture(".*/([^/]*?)(\\.([^.]*))?", 3)
102-
}
103-
104-
/**
105-
* Gets the stem of this container, that is, the prefix of its base name up to
106-
* (but not including) the last dot character if there is one, or the entire
107-
* base name if there is not.
108-
*
109-
* Here are some examples of absolute paths and the corresponding stems
110-
* (surrounded with quotes to avoid ambiguity):
111-
*
112-
* <table border="1">
113-
* <tr><th>Absolute path</th><th>Stem</th></tr>
114-
* <tr><td>"/tmp/tst.js"</td><td>"tst"</td></tr>
115-
* <tr><td>"/tmp/.classpath"</td><td>""</td></tr>
116-
* <tr><td>"/bin/bash"</td><td>"bash"</td></tr>
117-
* <tr><td>"/tmp/tst2."</td><td>"tst2"</td></tr>
118-
* <tr><td>"/tmp/x.tar.gz"</td><td>"x.tar"</td></tr>
119-
* </table>
120-
*/
121-
string getStem() {
122-
result = this.getAbsolutePath().regexpCapture(".*/([^/]*?)(?:\\.([^.]*))?", 1)
123-
}
124-
125-
/** Gets the parent container of this file or folder, if any. */
126-
Container getParentContainer() {
127-
containerparent(unresolveElement(result), underlyingElement(this))
21+
class FolderBase extends ContainerBase, @folder {
22+
override string getAbsolutePath() { folders(underlyingElement(this), result) }
12823
}
12924

130-
/** Gets a file or sub-folder in this container. */
131-
Container getAChildContainer() { this = result.getParentContainer() }
132-
133-
/** Gets a file in this container. */
134-
File getAFile() { result = this.getAChildContainer() }
135-
136-
/** Gets the file in this container that has the given `baseName`, if any. */
137-
File getFile(string baseName) {
138-
result = this.getAFile() and
139-
result.getBaseName() = baseName
25+
class FileBase extends ContainerBase, @file {
26+
override string getAbsolutePath() { files(underlyingElement(this), result) }
14027
}
14128

142-
/** Gets a sub-folder in this container. */
143-
Folder getAFolder() { result = this.getAChildContainer() }
29+
predicate hasSourceLocationPrefix = sourceLocationPrefix/1;
30+
}
14431

145-
/** Gets the sub-folder in this container that has the given `baseName`, if any. */
146-
Folder getFolder(string baseName) {
147-
result = this.getAFolder() and
148-
result.getBaseName() = baseName
149-
}
32+
private module Impl = Make<Input>;
15033

151-
/**
152-
* Gets a textual representation of the path of this container.
153-
*
154-
* This is the absolute path of the container.
155-
*/
156-
override string toString() { result = this.getAbsolutePath() }
34+
/** A file or folder. */
35+
class Container extends Locatable, Impl::Container {
36+
override string toString() { result = Impl::Container.super.toString() }
15737
}
15838

15939
/**
@@ -166,9 +46,7 @@ class Container extends Locatable, @container {
16646
*
16747
* To get the full path, use `getAbsolutePath`.
16848
*/
169-
class Folder extends Container, @folder {
170-
override string getAbsolutePath() { folders(underlyingElement(this), result) }
171-
49+
class Folder extends Container, Impl::Folder {
17250
override Location getLocation() {
17351
result.getContainer() = this and
17452
result.hasLocationInfo(_, 0, 0, 0, 0)
@@ -189,9 +67,7 @@ class Folder extends Container, @folder {
18967
* The base name further decomposes into the _stem_ and _extension_ -- see
19068
* `getStem` and `getExtension`. To get the full path, use `getAbsolutePath`.
19169
*/
192-
class File extends Container, @file {
193-
override string getAbsolutePath() { files(underlyingElement(this), result) }
194-
70+
class File extends Container, Impl::File {
19571
override string getAPrimaryQlClass() { result = "File" }
19672

19773
override Location getLocation() {

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,3 @@ class ArgumentPosition extends int {
7979
/** Holds if arguments at position `apos` match parameters at position `ppos`. */
8080
pragma[inline]
8181
predicate parameterMatch(ParameterPosition ppos, ArgumentPosition apos) { ppos = apos }
82-
83-
/**
84-
* Holds if flow from `call`'s argument `arg` to parameter `p` is permissible.
85-
*
86-
* This is a temporary hook to support technical debt in the Go language; do not use.
87-
*/
88-
pragma[inline]
89-
predicate golangSpecificParamArgFilter(DataFlowCall call, ParameterNode p, ArgumentNode arg) {
90-
any()
91-
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,10 @@ private module Config implements FullStateConfigSig {
297297

298298
predicate isBarrierOut(Node node) { any(Configuration config).isBarrierOut(node) }
299299

300+
predicate isBarrierIn(Node node, FlowState state) { none() }
301+
302+
predicate isBarrierOut(Node node, FlowState state) { none() }
303+
300304
predicate isAdditionalFlowStep(Node node1, Node node2) {
301305
singleConfiguration() and
302306
any(Configuration config).isAdditionalFlowStep(node1, node2)

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,10 @@ private module Config implements FullStateConfigSig {
297297

298298
predicate isBarrierOut(Node node) { any(Configuration config).isBarrierOut(node) }
299299

300+
predicate isBarrierIn(Node node, FlowState state) { none() }
301+
302+
predicate isBarrierOut(Node node, FlowState state) { none() }
303+
300304
predicate isAdditionalFlowStep(Node node1, Node node2) {
301305
singleConfiguration() and
302306
any(Configuration config).isAdditionalFlowStep(node1, node2)

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,10 @@ private module Config implements FullStateConfigSig {
297297

298298
predicate isBarrierOut(Node node) { any(Configuration config).isBarrierOut(node) }
299299

300+
predicate isBarrierIn(Node node, FlowState state) { none() }
301+
302+
predicate isBarrierOut(Node node, FlowState state) { none() }
303+
300304
predicate isAdditionalFlowStep(Node node1, Node node2) {
301305
singleConfiguration() and
302306
any(Configuration config).isAdditionalFlowStep(node1, node2)

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,10 @@ private module Config implements FullStateConfigSig {
297297

298298
predicate isBarrierOut(Node node) { any(Configuration config).isBarrierOut(node) }
299299

300+
predicate isBarrierIn(Node node, FlowState state) { none() }
301+
302+
predicate isBarrierOut(Node node, FlowState state) { none() }
303+
300304
predicate isAdditionalFlowStep(Node node1, Node node2) {
301305
singleConfiguration() and
302306
any(Configuration config).isAdditionalFlowStep(node1, node2)

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,10 @@ private module Config implements FullStateConfigSig {
297297

298298
predicate isBarrierOut(Node node) { any(Configuration config).isBarrierOut(node) }
299299

300+
predicate isBarrierIn(Node node, FlowState state) { none() }
301+
302+
predicate isBarrierOut(Node node, FlowState state) { none() }
303+
300304
predicate isAdditionalFlowStep(Node node1, Node node2) {
301305
singleConfiguration() and
302306
any(Configuration config).isAdditionalFlowStep(node1, node2)

0 commit comments

Comments
 (0)