Skip to content

Commit 9a0a949

Browse files
authored
Merge branch 'main' into add-activerecord-annotate
2 parents e8e8da1 + 2aaedac commit 9a0a949

File tree

71 files changed

+5331
-2321
lines changed

Some content is hidden

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

71 files changed

+5331
-2321
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010
- "*/ql/lib/**/*.qll"
1111
- "!**/experimental/**"
1212
- "!ql/**"
13+
- "!swift/**"
1314
- ".github/workflows/check-change-note.yml"
1415

1516
jobs:

.github/workflows/ql-for-ql-build.yml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ jobs:
5050
path: ${{ runner.temp }}/query-pack.zip
5151

5252
extractors:
53-
strategy:
54-
fail-fast: false
55-
5653
runs-on: ubuntu-latest
5754

5855
steps:
@@ -195,9 +192,36 @@ jobs:
195192
category: "ql-for-ql-${{ matrix.folder }}"
196193
- name: Copy sarif file to CWD
197194
run: cp ../results/ql.sarif ./${{ matrix.folder }}.sarif
195+
- name: Fixup the $scema in sarif # Until https://github.com/microsoft/sarif-vscode-extension/pull/436/ is part in a stable release
196+
run: |
197+
sed -i 's/\$schema.*/\$schema": "https:\/\/raw.githubusercontent.com\/oasis-tcs\/sarif-spec\/master\/Schemata\/sarif-schema-2.1.0",/' ${{ matrix.folder }}.sarif
198198
- name: Sarif as artifact
199199
uses: actions/upload-artifact@v3
200200
with:
201201
name: ${{ matrix.folder }}.sarif
202202
path: ${{ matrix.folder }}.sarif
203203

204+
combine:
205+
runs-on: ubuntu-latest
206+
needs:
207+
- analyze
208+
209+
steps:
210+
- uses: actions/checkout@v3
211+
- name: Make a folder for artifacts.
212+
run: mkdir -p results
213+
- name: Download all sarif files
214+
uses: actions/download-artifact@v3
215+
with:
216+
path: results
217+
- uses: actions/setup-node@v3
218+
with:
219+
node-version: 16
220+
- name: Combine all sarif files
221+
run: |
222+
node ./ql/scripts/merge-sarif.js results/**/*.sarif combined.sarif
223+
- name: Upload combined sarif file
224+
uses: actions/upload-artifact@v3
225+
with:
226+
name: combined.sarif
227+
path: combined.sarif

.github/workflows/ql-for-ql-dataset_measure.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
ql/target
3737
key: ${{ runner.os }}-qltest-cargo-${{ hashFiles('ql/**/Cargo.lock') }}
3838
- name: Build Extractor
39-
run: cd ql; env "PATH=$PATH:`dirname ${CODEQL}`" ./create-extractor-pack.sh
39+
run: cd ql; env "PATH=$PATH:`dirname ${CODEQL}`" ./scripts/create-extractor-pack.sh
4040
env:
4141
CODEQL: ${{ steps.find-codeql.outputs.codeql-path }}
4242
- name: Checkout ${{ matrix.repo }}

.github/workflows/ql-for-ql-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
run: |
3737
cd ql;
3838
codeqlpath=$(dirname ${{ steps.find-codeql.outputs.codeql-path }});
39-
env "PATH=$PATH:$codeqlpath" ./create-extractor-pack.sh
39+
env "PATH=$PATH:$codeqlpath" ./scripts/create-extractor-pack.sh
4040
- name: Run QL tests
4141
run: |
4242
"${CODEQL}" test run --check-databases --check-unused-labels --check-repeated-labels --check-redefined-labels --check-use-before-definition --search-path "${{ github.workspace }}/ql/extractor-pack" --consistency-queries ql/ql/consistency-queries ql/ql/test
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* `AnalysedExpr::isNullCheck` and `AnalysedExpr::isValidCheck` have been updated to handle variable accesses on the left-hand side of the the C++ logical and variable declarations in conditions.

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ predicate nullCheckExpr(Expr checkExpr, Variable var) {
4646
or
4747
exists(LogicalAndExpr op, AnalysedExpr child |
4848
expr = op and
49-
op.getRightOperand() = child and
49+
op.getAnOperand() = child and
5050
nullCheckExpr(child, v)
5151
)
5252
or
@@ -99,7 +99,7 @@ predicate validCheckExpr(Expr checkExpr, Variable var) {
9999
or
100100
exists(LogicalAndExpr op, AnalysedExpr child |
101101
expr = op and
102-
op.getRightOperand() = child and
102+
op.getAnOperand() = child and
103103
validCheckExpr(child, v)
104104
)
105105
or
@@ -169,7 +169,10 @@ class AnalysedExpr extends Expr {
169169
*/
170170
predicate isDef(LocalScopeVariable v) {
171171
this.inCondition() and
172-
this.(Assignment).getLValue() = v.getAnAccess()
172+
(
173+
this.(Assignment).getLValue() = v.getAnAccess() or
174+
this.(ConditionDeclExpr).getVariableAccess() = v.getAnAccess()
175+
)
173176
}
174177

175178
/**

cpp/ql/lib/semmle/code/cpp/exprs/Call.qll

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,10 @@ class FunctionCall extends Call, @funbindexpr {
255255
/**
256256
* Gets the function called by this call.
257257
*
258-
* In the case of virtual function calls, the result is the most-specific function in the override tree (as
259-
* determined by the compiler) such that the target at runtime will be one of `result.getAnOverridingFunction*()`.
258+
* In the case of virtual function calls, the result is the most-specific function in the override tree
259+
* such that the target at runtime will be one of `result.getAnOverridingFunction*()`. The most-specific
260+
* function is determined by the compiler based on the compile time type of the object the function is a
261+
* member of.
260262
*/
261263
override Function getTarget() { funbind(underlyingElement(this), unresolveElement(result)) }
262264

cpp/ql/src/Likely Bugs/Conversion/LossyFunctionResultCast.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ predicate whiteListWrapped(FunctionCall fc) {
4444

4545
from FunctionCall c, FloatingPointType t1, IntegralType t2
4646
where
47-
t1 = c.getTarget().getType().getUnderlyingType() and
47+
pragma[only_bind_into](t1) = c.getTarget().getType().getUnderlyingType() and
4848
t2 = c.getActualType() and
4949
c.hasImplicitConversion() and
5050
not whiteListWrapped(c)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
| test.cpp:9:9:9:9 | v | test.cpp:5:13:5:13 | v | is not null | is valid |
2+
| test.cpp:10:9:10:10 | ! ... | test.cpp:5:13:5:13 | v | is null | is not valid |
3+
| test.cpp:11:9:11:14 | ... == ... | test.cpp:5:13:5:13 | v | is null | is not valid |
4+
| test.cpp:12:9:12:17 | ... == ... | test.cpp:5:13:5:13 | v | is not null | is valid |
5+
| test.cpp:13:9:13:14 | ... != ... | test.cpp:5:13:5:13 | v | is not null | is valid |
6+
| test.cpp:14:9:14:17 | ... != ... | test.cpp:5:13:5:13 | v | is null | is not valid |
7+
| test.cpp:15:8:15:23 | call to __builtin_expect | test.cpp:5:13:5:13 | v | is not null | is valid |
8+
| test.cpp:16:8:16:23 | call to __builtin_expect | test.cpp:5:13:5:13 | v | is null | is not valid |
9+
| test.cpp:17:9:17:17 | ... && ... | test.cpp:5:13:5:13 | v | is not null | is valid |
10+
| test.cpp:18:9:18:17 | ... && ... | test.cpp:5:13:5:13 | v | is not null | is valid |
11+
| test.cpp:19:9:19:18 | ... && ... | test.cpp:5:13:5:13 | v | is null | is not valid |
12+
| test.cpp:20:9:20:18 | ... && ... | test.cpp:5:13:5:13 | v | is null | is not valid |
13+
| test.cpp:21:9:21:14 | ... = ... | test.cpp:5:13:5:13 | v | is null | is not valid |
14+
| test.cpp:21:9:21:14 | ... = ... | test.cpp:7:10:7:10 | b | is not null | is valid |
15+
| test.cpp:22:9:22:14 | ... = ... | test.cpp:5:13:5:13 | v | is not null | is not valid |
16+
| test.cpp:22:9:22:14 | ... = ... | test.cpp:7:13:7:13 | c | is not null | is not valid |
17+
| test.cpp:22:17:22:17 | c | test.cpp:7:13:7:13 | c | is not null | is valid |
18+
| test.cpp:23:21:23:21 | x | test.cpp:23:14:23:14 | x | is not null | is valid |
19+
| test.cpp:24:9:24:18 | (condition decl) | test.cpp:5:13:5:13 | v | is not null | is not valid |
20+
| test.cpp:24:9:24:18 | (condition decl) | test.cpp:24:14:24:14 | y | is not null | is valid |
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import cpp
2+
3+
from AnalysedExpr a, LocalScopeVariable v, string isNullCheck, string isValidCheck
4+
where
5+
v.getAnAccess().getEnclosingStmt() = a.getParent() and
6+
(if a.isNullCheck(v) then isNullCheck = "is null" else isNullCheck = "is not null") and
7+
(if a.isValidCheck(v) then isValidCheck = "is valid" else isValidCheck = "is not valid")
8+
select a, v, isNullCheck, isValidCheck

0 commit comments

Comments
 (0)