Skip to content

Commit 4e91359

Browse files
committed
Merge branch 'main' into cpp-non-constant-format-as-path-query
2 parents 2eb8d13 + 664dac6 commit 4e91359

File tree

491 files changed

+45794
-47630
lines changed

Some content is hidden

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

491 files changed

+45794
-47630
lines changed

.bazelrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
common --enable_platform_specific_config
2+
common --enable_bzlmod
3+
# because we use --override_module with `%workspace%`, the lock file is not stable
4+
common --lockfile_mode=off
5+
6+
# when building from this repository in isolation, the internal repository will not be found at ..
7+
# where `MODULE.bazel` looks for it. The following will get us past the module loading phase, so
8+
# that we can build things that do not rely on that
9+
common --override_module=semmle_code=%workspace%/misc/bazel/semmle_code_stub
210

311
build --repo_env=CC=clang --repo_env=CXX=clang++
412

.bazelversion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6.3.1
1+
7.0.2

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,7 @@ javascript/ql/experimental/adaptivethreatmodeling/test/endpoint_large_scale/auto
7474

7575
# Auto-generated modeling for Python
7676
python/ql/lib/semmle/python/frameworks/data/internal/subclass-capture/*.yml linguist-generated=true
77+
78+
# auto-generated bazel lock file
79+
ruby/extractor/cargo-bazel-lock.json linguist-generated=true
80+
ruby/extractor/cargo-bazel-lock.json -merge

.github/workflows/compile-queries.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
with:
2929
key: all-queries
3030
- name: check formatting
31-
run: find */ql -type f \( -name "*.qll" -o -name "*.ql" \) -print0 | xargs -0 -n 3000 -P 10 codeql query format -q --check-only
31+
run: find shared */ql -type f \( -name "*.qll" -o -name "*.ql" \) -print0 | xargs -0 -n 3000 -P 10 codeql query format -q --check-only
3232
- name: compile queries - check-only
3333
# run with --check-only if running in a PR (github.sha != main)
3434
if : ${{ github.event_name == 'pull_request' }}

.github/workflows/ruby-build.yml

Lines changed: 8 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,11 @@ jobs:
5151
run: |
5252
brew install gnu-tar
5353
echo "/usr/local/opt/gnu-tar/libexec/gnubin" >> $GITHUB_PATH
54-
- name: Install cargo-cross
55-
if: runner.os == 'Linux'
56-
run: cargo install cross --version 0.2.5
54+
- name: Prepare Windows
55+
if: runner.os == 'Windows'
56+
shell: powershell
57+
run: |
58+
git config --global core.longpaths true
5759
- uses: ./.github/actions/os-version
5860
id: os_version
5961
- name: Cache entire extractor
@@ -82,16 +84,8 @@ jobs:
8284
- name: Run tests
8385
if: steps.cache-extractor.outputs.cache-hit != 'true'
8486
run: cd extractor && cargo test --verbose
85-
# On linux, build the extractor via cross in a centos7 container.
86-
# This ensures we don't depend on glibc > 2.17.
87-
- name: Release build (linux)
88-
if: steps.cache-extractor.outputs.cache-hit != 'true' && runner.os == 'Linux'
89-
run: |
90-
cd extractor
91-
cross build --release
92-
mv target/x86_64-unknown-linux-gnu/release/codeql-extractor-ruby target/release/
93-
- name: Release build (windows and macos)
94-
if: steps.cache-extractor.outputs.cache-hit != 'true' && runner.os != 'Linux'
87+
- name: Release build
88+
if: steps.cache-extractor.outputs.cache-hit != 'true'
9589
run: cd extractor && cargo build --release
9690
- name: Generate dbscheme
9791
if: ${{ matrix.os == 'ubuntu-latest' && steps.cache-extractor.outputs.cache-hit != 'true'}}
@@ -123,7 +117,7 @@ jobs:
123117
- name: Cache compilation cache
124118
id: query-cache
125119
uses: ./.github/actions/cache-query-compilation
126-
with:
120+
with:
127121
key: ruby-build
128122
- name: Build Query Pack
129123
run: |
@@ -235,54 +229,3 @@ jobs:
235229
shell: bash
236230
run: |
237231
codeql database analyze --search-path "${{ runner.temp }}/ruby-bundle" --format=sarifv2.1.0 --output=out.sarif ../database ruby-code-scanning.qls
238-
239-
# This is a copy of the 'test' job that runs in a centos7 container.
240-
# This tests that the extractor works correctly on systems with an old glibc.
241-
test-centos7:
242-
defaults:
243-
run:
244-
working-directory: ${{ github.workspace }}
245-
strategy:
246-
fail-fast: false
247-
runs-on: ubuntu-latest
248-
container:
249-
image: centos:centos7
250-
env:
251-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
252-
needs: [package]
253-
steps:
254-
- name: Install gh cli
255-
run: |
256-
yum-config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo
257-
# fetch-codeql requires unzip and jq
258-
# jq is available in epel-release (https://docs.fedoraproject.org/en-US/epel/)
259-
yum install -y gh unzip epel-release
260-
yum install -y jq
261-
- uses: actions/checkout@v3
262-
- name: Fetch CodeQL
263-
uses: ./.github/actions/fetch-codeql
264-
265-
# Due to a bug in Actions, we can't use runner.temp in the run blocks here.
266-
# https://github.com/actions/runner/issues/2185
267-
268-
- name: Download Ruby bundle
269-
uses: actions/download-artifact@v3
270-
with:
271-
name: codeql-ruby-bundle
272-
path: ${{ runner.temp }}
273-
- name: Unzip Ruby bundle
274-
shell: bash
275-
run: unzip -q -d "$RUNNER_TEMP"/ruby-bundle "$RUNNER_TEMP"/codeql-ruby-bundle.zip
276-
277-
- name: Run QL test
278-
shell: bash
279-
run: |
280-
codeql test run --search-path "$RUNNER_TEMP"/ruby-bundle --additional-packs "$RUNNER_TEMP"/ruby-bundle ruby/ql/test/library-tests/ast/constants/
281-
- name: Create database
282-
shell: bash
283-
run: |
284-
codeql database create --search-path "$RUNNER_TEMP"/ruby-bundle --language ruby --source-root ruby/ql/test/library-tests/ast/constants/ ../database
285-
- name: Analyze database
286-
shell: bash
287-
run: |
288-
codeql database analyze --search-path "$RUNNER_TEMP"/ruby-bundle --format=sarifv2.1.0 --output=out.sarif ../database ruby-code-scanning.qls

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
# local bazel options
4040
/local.bazelrc
4141

42+
# generated cmake directory
43+
/.bazel-cmake
44+
4245
# CLion project files
4346
/.clwb
4447

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
# Bazel (excluding BUILD.bazel files)
2727
WORKSPACE.bazel @github/codeql-ci-reviewers
28+
MODULE.bazel @github/codeql-ci-reviewers
2829
.bazelversion @github/codeql-ci-reviewers
2930
.bazelrc @github/codeql-ci-reviewers
3031
**/*.bzl @github/codeql-ci-reviewers

MODULE.bazel

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
module(
2+
name = "codeql",
3+
version = "0.0",
4+
)
5+
6+
# this points to our internal repository when `codeql` is checked out as a submodule thereof
7+
# when building things from `codeql` independently this is stubbed out in `.bazelrc`
8+
bazel_dep(name = "semmle_code", version = "0.0")
9+
local_path_override(
10+
module_name = "semmle_code",
11+
path = "..",
12+
)
13+
14+
# see https://registry.bazel.build/ for a list of available packages
15+
16+
bazel_dep(name = "platforms", version = "0.0.8")
17+
bazel_dep(name = "rules_pkg", version = "0.9.1")
18+
bazel_dep(name = "rules_nodejs", version = "6.0.3")
19+
bazel_dep(name = "rules_python", version = "0.31.0")
20+
bazel_dep(name = "bazel_skylib", version = "1.5.0")
21+
bazel_dep(name = "abseil-cpp", version = "20240116.0", repo_name = "absl")
22+
bazel_dep(name = "nlohmann_json", version = "3.11.3", repo_name = "json")
23+
bazel_dep(name = "fmt", version = "10.0.0")
24+
25+
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
26+
pip.parse(
27+
hub_name = "codegen_deps",
28+
python_version = "3.11",
29+
requirements_lock = "//misc/codegen:requirements_lock.txt",
30+
)
31+
use_repo(pip, "codegen_deps")
32+
33+
swift_deps = use_extension("//swift/third_party:load.bzl", "swift_deps")
34+
use_repo(
35+
swift_deps,
36+
"binlog",
37+
"picosha2",
38+
"swift_prebuilt_darwin_x86_64",
39+
"swift_prebuilt_linux",
40+
"swift_toolchain_linux",
41+
"swift_toolchain_macos",
42+
)
43+
44+
node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node")
45+
node.toolchain(
46+
name = "nodejs",
47+
node_version = "18.15.0",
48+
)
49+
use_repo(node, "nodejs", "nodejs_toolchains")
50+
51+
register_toolchains(
52+
"@nodejs_toolchains//:all",
53+
)

WORKSPACE.bazel

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,2 @@
1-
# Please notice that any bazel targets and definitions in this repository are currently experimental
2-
# and for internal use only.
3-
4-
workspace(name = "codeql")
5-
6-
load("//misc/bazel:workspace.bzl", "codeql_workspace")
7-
8-
codeql_workspace()
9-
10-
load("//misc/bazel:workspace_deps.bzl", "codeql_workspace_deps")
11-
12-
codeql_workspace_deps()
1+
# please use MODULE.bazel to add dependencies
2+
# this empty file is required by internal repositories, don't remove it

config/identical-files.json

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -431,13 +431,6 @@
431431
"java/ql/src/experimental/Security/CWE/CWE-400/LocalThreadResourceAbuse.qhelp",
432432
"java/ql/src/experimental/Security/CWE/CWE-400/ThreadResourceAbuse.qhelp"
433433
],
434-
"IDE Contextual Queries": [
435-
"cpp/ql/lib/IDEContextual.qll",
436-
"csharp/ql/lib/IDEContextual.qll",
437-
"java/ql/lib/IDEContextual.qll",
438-
"javascript/ql/lib/IDEContextual.qll",
439-
"python/ql/lib/analysis/IDEContextual.qll"
440-
],
441434
"CryptoAlgorithms Python/JS/Ruby": [
442435
"javascript/ql/lib/semmle/javascript/security/CryptoAlgorithms.qll",
443436
"python/ql/lib/semmle/python/concepts/CryptoAlgorithms.qll",

cpp/ql/lib/IDEContextual.qll

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,13 @@
33
*/
44

55
import semmle.files.FileSystem
6+
private import codeql.util.FileSystem
67

78
/**
89
* Returns the `File` matching the given source file name as encoded by the VS
910
* Code extension.
1011
*/
1112
cached
1213
File getFileBySourceArchiveName(string name) {
13-
// The name provided for a file in the source archive by the VS Code extension
14-
// has some differences from the absolute path in the database:
15-
// 1. colons are replaced by underscores
16-
// 2. there's a leading slash, even for Windows paths: "C:/foo/bar" ->
17-
// "/C_/foo/bar"
18-
// 3. double slashes in UNC prefixes are replaced with a single slash
19-
// We can handle 2 and 3 together by unconditionally adding a leading slash
20-
// before replacing double slashes.
21-
name = ("/" + result.getAbsolutePath().replaceAll(":", "_")).replaceAll("//", "/")
14+
result = IdeContextual<File>::getFileBySourceArchiveName(name)
2215
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* Added destructors for named objects to the intermediate representation.

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,6 @@ Element exprEnclosingElement(Expr e) {
6060
)
6161
else result = de.getDeclaration()
6262
)
63+
or
64+
result.(Stmt).getAnImplicitDestructorCall() = e
6365
}

cpp/ql/lib/semmle/code/cpp/controlflow/SubBasicBlocks.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// NOTE: There are two copies of this file, and they must be kept identical:
22
// - semmle/code/cpp/controlflow/SubBasicBlocks.qll
3-
// - semmle/code/cpp/dataflow/internal/SubBasicBlocks.qll
3+
// - semmle/code/cpp/dataflow/internal/SubBasicBlocks.qll [now DEPRECATED]
44
//
55
// The second one is a private copy of the `SubBasicBlocks` library for
66
// internal use by the data flow library. Having an extra copy prevents

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/**
2+
* DEPRECATED: Use `semmle.code.cpp.dataflow.new.DataFlow` instead.
3+
*
24
* Provides a local analysis for identifying where a variable address
35
* is effectively taken. Array-like offsets are allowed to pass through but
46
* not field-like offsets.

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* DEPRECATED: Use `semmle.code.cpp.dataflow.new.DataFlow` instead.
3+
*/
4+
15
private import cpp
26
private import DataFlowPrivate
37
private import DataFlowUtil
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* DEPRECATED: Use `semmle.code.cpp.dataflow.new.DataFlow` instead.
3+
*/
4+
15
private import DataFlowImplSpecific
26
private import codeql.dataflow.internal.DataFlowImpl
37
import MakeImpl<CppOldDataFlow>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* DEPRECATED: Use `semmle.code.cpp.dataflow.new.DataFlow` instead.
3+
*/
4+
15
private import DataFlowImplSpecific
26
private import codeql.dataflow.internal.DataFlowImplCommon
37
import MakeImplCommon<CppOldDataFlow>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/**
2+
* DEPRECATED: Use `semmle.code.cpp.dataflow.new.DataFlow` instead.
3+
*
24
* Provides consistency queries for checking invariants in the language-specific
35
* data-flow classes and predicates.
46
*/

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/**
2+
* DEPRECATED: Use `semmle.code.cpp.dataflow.new.DataFlow` instead.
3+
*
24
* Provides C++-specific definitions for use in the data flow library.
35
*/
46

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* DEPRECATED: Use `semmle.code.cpp.dataflow.new.DataFlow` instead.
3+
*/
4+
15
private import cpp
26
private import DataFlowUtil
37
private import DataFlowDispatch

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/**
2+
* DEPRECATED: Use `semmle.code.cpp.dataflow.new.DataFlow` instead.
3+
*
24
* Provides C++-specific definitions for use in the data flow library.
35
*/
46

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/**
2+
* DEPRECATED: Use `semmle.code.cpp.dataflow.new.DataFlow` instead.
3+
*
24
* Provides a class for handling variables in the data flow analysis.
35
*/
46

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// NOTE: There are two copies of this file, and they must be kept identical:
22
// - semmle/code/cpp/controlflow/SubBasicBlocks.qll
3-
// - semmle/code/cpp/dataflow/internal/SubBasicBlocks.qll
3+
// - semmle/code/cpp/dataflow/internal/SubBasicBlocks.qll [now DEPRECATED]
44
//
55
// The second one is a private copy of the `SubBasicBlocks` library for
66
// internal use by the data flow library. Having an extra copy prevents

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/**
2+
* DEPRECATED: Use `semmle.code.cpp.dataflow.new.DataFlow` instead.
3+
*
24
* Provides C++-specific definitions for use in the taint tracking library.
35
*/
46

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/**
2+
* DEPRECATED: Use `semmle.code.cpp.dataflow.new.DataFlow` instead.
3+
*
24
* Provides classes for performing local (intra-procedural) and
35
* global (inter-procedural) taint-tracking analyses.
46
*

cpp/ql/lib/semmle/code/cpp/dataflow/internal/tainttracking1/TaintTrackingParameter.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* DEPRECATED: Use `Global` and `GlobalWithState` instead.
3+
*/
4+
15
import semmle.code.cpp.dataflow.internal.TaintTrackingUtil as Public
26

37
module Private {

cpp/ql/lib/semmle/code/cpp/dataflow/internal/tainttracking2/TaintTrackingParameter.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* DEPRECATED: Use `Global` and `GlobalWithState` instead.
3+
*/
4+
15
import semmle.code.cpp.dataflow.internal.TaintTrackingUtil as Public
26

37
module Private {

0 commit comments

Comments
 (0)