Skip to content

Commit 6f0ddaa

Browse files
committed
Merge branch 'main' into alexdenisov/swift-first-extractor-test
2 parents 5b20d58 + 85d5b12 commit 6f0ddaa

File tree

766 files changed

+8200
-1661
lines changed

Some content is hidden

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

766 files changed

+8200
-1661
lines changed

.github/workflows/check-qldoc.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ jobs:
3030
shell: bash
3131
run: |
3232
EXIT_CODE=0
33-
changed_lib_packs="$(git diff --name-only --diff-filter=ACMRT HEAD^ HEAD | { grep -o '^[a-z]*/ql/lib' || true; } | sort -u)"
33+
# TODO: remove the swift exception from the regex when we fix generated QLdoc
34+
changed_lib_packs="$(git diff --name-only --diff-filter=ACMRT HEAD^ HEAD | { grep -Po '^(?!swift)[a-z]*/ql/lib' || true; } | sort -u)"
3435
for pack_dir in ${changed_lib_packs}; do
3536
lang="${pack_dir%/ql/lib}"
3637
gh codeql generate library-doc-coverage --output="${RUNNER_TEMP}/${lang}-current.txt" --dir="${pack_dir}"

.github/workflows/swift-codegen.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: "Swift: Check code generation"
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "swift/**"
7+
- .github/workflows/swift-codegen.yml
8+
branches:
9+
- main
10+
11+
jobs:
12+
codegen:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
- uses: actions/setup-python@v3
17+
with:
18+
python-version: '~3.7'
19+
cache: 'pip'
20+
- uses: ./.github/actions/fetch-codeql
21+
- uses: bazelbuild/setup-bazelisk@v2
22+
- name: Check code generation
23+
run: |
24+
pip install -r swift/codegen/requirements.txt
25+
bazel run //swift/codegen
26+
git add swift
27+
git diff --exit-code --stat HEAD

.github/workflows/swift-qltest.yml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,7 @@ jobs:
2828
steps:
2929
- uses: actions/checkout@v2
3030
- uses: ./.github/actions/fetch-codeql
31-
- name: Install bazelisk - Linux
32-
if: runner.os == 'Linux'
33-
run: |
34-
sudo apt-get update
35-
sudo apt-get install -y wget clang
36-
wget https://github.com/bazelbuild/bazelisk/releases/download/v1.11.0/bazelisk-linux-amd64
37-
mv bazelisk-linux-amd64 /usr/local/bin/bazel
38-
chmod +x /usr/local/bin/bazel
39-
- name: Install bazelisk - macOS
40-
if: runner.os == 'MacOS'
41-
run: |
42-
brew install bazelisk
31+
- uses: bazelbuild/setup-bazelisk@v2
4332
- name: Build Swift extractor
4433
run: |
4534
bazel run //swift:create-extractor-pack
@@ -51,4 +40,3 @@ jobs:
5140
codeql test run --threads=0 --ram 5000 --search-path "${{ github.workspace }}/swift/extractor-pack" --check-databases --check-unused-labels --check-repeated-labels --check-redefined-labels --check-use-before-definition ql/test
5241
env:
5342
GITHUB_TOKEN: ${{ github.token }}
54-

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ repos:
3636

3737
- id: swift-codegen
3838
name: Run Swift checked in code generation
39-
files: ^swift/(codegen/|.*/generated/|ql/lib/swift\.dbscheme$)
39+
files: ^swift/(codegen/|.*/generated/|ql/lib/(swift\.dbscheme$|codeql/swift/elements))
4040
language: system
4141
entry: bazel run //swift/codegen
4242
pass_filenames: false

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
We welcome contributions to our CodeQL libraries and queries. Got an idea for a new check, or how to improve an existing query? Then please go ahead and open a pull request! Contributions to this project are [released](https://help.github.com/articles/github-terms-of-service/#6-contributions-under-repository-license) to the public under the [project's open source license](LICENSE).
44

5-
There is lots of useful documentation to help you write queries, ranging from information about query file structure to tutorials for specific target languages. For more information on the documentation available, see [CodeQL queries](https://help.semmle.com/QL/learn-ql/writing-queries/writing-queries.html) on [help.semmle.com](https://help.semmle.com).
5+
There is lots of useful documentation to help you write queries, ranging from information about query file structure to tutorials for specific target languages. For more information on the documentation available, see [CodeQL queries](https://codeql.github.com/docs/writing-codeql-queries/codeql-queries) on [codeql.github.com](https://codeql.github.com).
66

77
## Change notes
88

@@ -40,7 +40,7 @@ If you have an idea for a query that you would like to share with other CodeQL u
4040

4141
3. **Formatting**
4242

43-
- The queries and libraries must be autoformatted, for example using the "Format Document" command in [CodeQL for Visual Studio Code](https://help.semmle.com/codeql/codeql-for-vscode/procedures/about-codeql-for-vscode.html).
43+
- The queries and libraries must be autoformatted, for example using the "Format Document" command in [CodeQL for Visual Studio Code](https://codeql.github.com/docs/codeql-for-visual-studio-code/about-codeql-for-visual-studio-code).
4444

4545
If you prefer, you can either:
4646
1. install the [pre-commit framework](https://pre-commit.com/) and install the configured hooks on this repo via `pre-commit install`, or

config/identical-files.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"csharp/ql/lib/semmle/code/csharp/dataflow/internal/tainttracking5/TaintTrackingImpl.qll",
5252
"java/ql/lib/semmle/code/java/dataflow/internal/tainttracking1/TaintTrackingImpl.qll",
5353
"java/ql/lib/semmle/code/java/dataflow/internal/tainttracking2/TaintTrackingImpl.qll",
54+
"java/ql/lib/semmle/code/java/dataflow/internal/tainttracking3/TaintTrackingImpl.qll",
5455
"python/ql/lib/semmle/python/dataflow/new/internal/tainttracking1/TaintTrackingImpl.qll",
5556
"python/ql/lib/semmle/python/dataflow/new/internal/tainttracking2/TaintTrackingImpl.qll",
5657
"python/ql/lib/semmle/python/dataflow/new/internal/tainttracking3/TaintTrackingImpl.qll",
@@ -550,4 +551,4 @@
550551
"javascript/ql/lib/semmle/javascript/security/dataflow/HttpToFileAccessCustomizations.qll",
551552
"ruby/ql/lib/codeql/ruby/security/HttpToFileAccessCustomizations.qll"
552553
]
553-
}
554+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* The `semmle.code.cpp.commons.Buffer` library has been enhanced to handle array members of classes that do not specify a size.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: breaking
3+
---
4+
The signature of `allowImplicitRead` on `DataFlow::Configuration` and `TaintTracking::Configuration` has changed from `allowImplicitRead(DataFlow::Node node, DataFlow::Content c)` to `allowImplicitRead(DataFlow::Node node, DataFlow::ContentSet c)`.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* More Windows pool allocation functions are now detected as `AllocationFunction`s.

cpp/ql/lib/semmle/code/cpp/commons/Buffer.qll

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,18 @@ import semmle.code.cpp.dataflow.DataFlow
1010
* char data[1]; // v
1111
* };
1212
* ```
13-
* This requires that `v` is an array of size 0 or 1.
13+
* or
14+
* ```
15+
* struct myStruct { // c
16+
* int amount;
17+
* char data[]; // v
18+
* };
19+
* ```
20+
* This requires that `v` is an array of size 0 or 1, or that the array has no size.
1421
*/
1522
predicate memberMayBeVarSize(Class c, MemberVariable v) {
1623
c = v.getDeclaringType() and
17-
v.getUnspecifiedType().(ArrayType).getArraySize() <= 1
24+
exists(ArrayType t | t = v.getUnspecifiedType() | not t.getArraySize() > 1)
1825
}
1926

2027
/**
@@ -40,13 +47,18 @@ int getBufferSize(Expr bufferExpr, Element why) {
4047
result = why.(Expr).getType().(ArrayType).getSize() and
4148
not exists(bufferVar.getUnspecifiedType().(ArrayType).getSize())
4249
or
43-
exists(Class parentClass, VariableAccess parentPtr |
50+
exists(Class parentClass, VariableAccess parentPtr, int bufferSize |
4451
// buffer is the parentPtr->bufferVar of a 'variable size struct'
4552
memberMayBeVarSize(parentClass, bufferVar) and
4653
why = bufferVar and
4754
parentPtr = bufferExpr.(VariableAccess).getQualifier() and
4855
parentPtr.getTarget().getUnspecifiedType().(PointerType).getBaseType() = parentClass and
49-
result = getBufferSize(parentPtr, _) + bufferVar.getType().getSize() - parentClass.getSize()
56+
(
57+
if exists(bufferVar.getType().getSize())
58+
then bufferSize = bufferVar.getType().getSize()
59+
else bufferSize = 0
60+
) and
61+
result = getBufferSize(parentPtr, _) + bufferSize - parentClass.getSize()
5062
)
5163
)
5264
or

0 commit comments

Comments
 (0)