Skip to content

Commit e7c4766

Browse files
authored
Merge branch 'main' into typo-script-help-message
2 parents b94ab82 + 041150a commit e7c4766

File tree

129 files changed

+1827
-744
lines changed

Some content is hidden

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

129 files changed

+1827
-744
lines changed

.github/workflows/code-scanning-pack-gen.yml

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ on:
88
- main
99
- next
1010
- "rc/**"
11-
1211
push:
1312
branches:
1413
- main
@@ -98,15 +97,36 @@ jobs:
9897
CODEQL_HOME: ${{ github.workspace }}/codeql_home
9998
run: |
10099
PATH=$PATH:$CODEQL_HOME/codeql
101-
102-
codeql query compile --precompile --threads 0 cpp
103-
codeql query compile --precompile --threads 0 c
100+
# Precompile all queries, and use a compilation cache larger than default
101+
# to ensure we cache all the queries for later steps
102+
codeql query compile --precompile --threads 0 --compilation-cache-size=1024 cpp c
104103
105104
cd ..
106105
zip -r codeql-coding-standards/code-scanning-cpp-query-pack.zip codeql-coding-standards/c/ codeql-coding-standards/cpp/ codeql-coding-standards/.codeqlmanifest.json codeql-coding-standards/supported_codeql_configs.json codeql-coding-standards/scripts/configuration codeql-coding-standards/scripts/reports codeql-coding-standards/scripts/shared codeql-coding-standards/scripts/guideline_recategorization codeql-coding-standards/schemas
107106
108107
- name: Upload GHAS Query Pack
109-
uses: actions/upload-artifact@v3
108+
uses: actions/upload-artifact@v4
110109
with:
111110
name: code-scanning-cpp-query-pack.zip
112111
path: code-scanning-cpp-query-pack.zip
112+
113+
- name: Create qlpack bundles
114+
env:
115+
CODEQL_HOME: ${{ github.workspace }}/codeql_home
116+
run: |
117+
PATH=$PATH:$CODEQL_HOME/codeql
118+
119+
codeql pack bundle --output=common-cpp-coding-standards.tgz cpp/common/src
120+
codeql pack bundle --output=common-c-coding-standards.tgz c/common/src
121+
codeql pack bundle --output=misra-c-coding-standards.tgz c/misra/src
122+
codeql pack bundle --output=cert-c-coding-standards.tgz c/cert/src
123+
codeql pack bundle --output=cert-cpp-coding-standards.tgz cpp/cert/src
124+
codeql pack bundle --output=autosar-cpp-coding-standards.tgz cpp/autosar/src
125+
codeql pack bundle --output=misra-cpp-coding-standards.tgz cpp/misra/src
126+
codeql pack bundle --output=report-coding-standards.tgz cpp/report/src
127+
128+
- name: Upload qlpack bundles
129+
uses: actions/upload-artifact@v4
130+
with:
131+
name: coding-standards-codeql-packs
132+
path: '*-coding-standards.tgz'

apply-configuration/action.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Applies Coding Standard configuration files in the repository
2+
description: |
3+
Installs Python and indexes the CodeQL Coding Standard configuration files in the repository
4+
5+
runs:
6+
using: composite
7+
steps:
8+
- name: Install Python
9+
id: cs-install-python
10+
uses: actions/setup-python@v5
11+
with:
12+
python-version: 3.9
13+
update-environment: false
14+
- name: Install dependencies and process files
15+
shell: bash
16+
run: |
17+
install_dir=$(dirname $(dirname "${{ steps.cs-install-python.outputs.python-path }}"))
18+
if [[ -z "$LD_LIBRARY_PATH" ]]; then
19+
export LD_LIBRARY_PATH="$install_dir/lib"
20+
else
21+
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$install_dir/lib"
22+
fi
23+
${{ steps.cs-install-python.outputs.python-path }} -m pip install -r ${GITHUB_ACTION_PATH}/../scripts/configuration/requirements.txt
24+
${{ steps.cs-install-python.outputs.python-path }} ${GITHUB_ACTION_PATH}/../scripts/configuration/process_coding_standards_config.py

c/cert/src/codeql-pack.lock.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
lockVersion: 1.0.0
33
dependencies:
44
codeql/cpp-all:
5-
version: 0.12.2
5+
version: 0.12.9
66
codeql/dataflow:
7-
version: 0.1.5
7+
version: 0.2.3
88
codeql/rangeanalysis:
9-
version: 0.0.4
9+
version: 0.0.11
1010
codeql/ssa:
11-
version: 0.2.5
11+
version: 0.2.12
1212
codeql/tutorial:
13-
version: 0.2.5
13+
version: 0.2.12
1414
codeql/typetracking:
15-
version: 0.2.5
15+
version: 0.2.12
1616
codeql/util:
17-
version: 0.2.5
17+
version: 0.2.12
1818
compiled: false

c/cert/src/qlpack.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
name: codeql/cert-c-coding-standards
2-
version: 2.36.0-dev
2+
version: 2.38.0-dev
33
description: CERT C 2016
44
suites: codeql-suites
55
license: MIT
66
dependencies:
77
codeql/common-c-coding-standards: '*'
8-
codeql/cpp-all: 0.12.2
8+
codeql/cpp-all: 0.12.9

c/cert/src/rules/DCL40-C/IncompatibleFunctionDeclarations.ql

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,32 @@
1616

1717
import cpp
1818
import codingstandards.c.cert
19+
import codingstandards.cpp.Compatible
1920
import ExternalIdentifiers
2021

21-
//checks if they are incompatible based on return type, number of parameters and parameter types
22-
predicate checkMatchingFunction(FunctionDeclarationEntry d, FunctionDeclarationEntry d2) {
23-
not d.getType() = d2.getType()
24-
or
25-
not d.getNumberOfParameters() = d2.getNumberOfParameters()
26-
or
27-
exists(ParameterDeclarationEntry p, ParameterDeclarationEntry p2, int i |
28-
d.getParameterDeclarationEntry(i) = p and
29-
d2.getParameterDeclarationEntry(i) = p2 and
30-
not p.getType() = p2.getType()
31-
)
32-
}
33-
3422
from ExternalIdentifiers d, FunctionDeclarationEntry f1, FunctionDeclarationEntry f2
3523
where
3624
not isExcluded(f1, Declarations2Package::incompatibleFunctionDeclarationsQuery()) and
3725
not isExcluded(f2, Declarations2Package::incompatibleFunctionDeclarationsQuery()) and
38-
f1 = d.getADeclarationEntry() and
39-
f2 = d.getADeclarationEntry() and
4026
not f1 = f2 and
41-
f1.getLocation().getStartLine() >= f2.getLocation().getStartLine() and
27+
f1.getDeclaration() = d and
28+
f2.getDeclaration() = d and
4229
f1.getName() = f2.getName() and
43-
checkMatchingFunction(f1, f2)
30+
(
31+
//return type check
32+
not typesCompatible(f1.getType(), f2.getType())
33+
or
34+
//parameter type check
35+
parameterTypesIncompatible(f1, f2)
36+
or
37+
not f1.getNumberOfParameters() = f2.getNumberOfParameters()
38+
) and
39+
// Apply ordering on start line, trying to avoid the optimiser applying this join too early
40+
// in the pipeline
41+
exists(int f1Line, int f2Line |
42+
f1.getLocation().hasLocationInfo(_, f1Line, _, _, _) and
43+
f2.getLocation().hasLocationInfo(_, f2Line, _, _, _) and
44+
f1Line >= f2Line
45+
)
4446
select f1, "The object $@ is not compatible with re-declaration $@", f1, f1.getName(), f2,
4547
f2.getName()

c/cert/src/rules/MSC39-C/DoNotCallVaArgOnAVaListThatHasAnIndeterminateValue.ql

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,19 @@ predicate sameSource(VaAccess e1, VaAccess e2) {
7171
)
7272
}
7373

74+
/**
75+
* Extracted to avoid poor magic join ordering on the `isExcluded` predicate.
76+
*/
77+
predicate query(VaAccess va_acc, VaArgArg va_arg, FunctionCall fc) {
78+
sameSource(va_acc, va_arg) and
79+
fc = preceedsFC(va_acc) and
80+
fc.getTarget().calls*(va_arg.getEnclosingFunction())
81+
}
82+
7483
from VaAccess va_acc, VaArgArg va_arg, FunctionCall fc
7584
where
7685
not isExcluded(va_acc,
7786
Contracts7Package::doNotCallVaArgOnAVaListThatHasAnIndeterminateValueQuery()) and
78-
sameSource(va_acc, va_arg) and
79-
fc = preceedsFC(va_acc) and
80-
fc.getTarget().calls*(va_arg.getEnclosingFunction())
87+
query(va_acc, va_arg, fc)
8188
select va_acc, "The value of " + va_acc.toString() + " is indeterminate after the $@.", fc,
8289
fc.toString()

c/cert/test/codeql-pack.lock.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
lockVersion: 1.0.0
33
dependencies:
44
codeql/cpp-all:
5-
version: 0.12.2
5+
version: 0.12.9
66
codeql/dataflow:
7-
version: 0.1.5
7+
version: 0.2.3
88
codeql/rangeanalysis:
9-
version: 0.0.4
9+
version: 0.0.11
1010
codeql/ssa:
11-
version: 0.2.5
11+
version: 0.2.12
1212
codeql/tutorial:
13-
version: 0.2.5
13+
version: 0.2.12
1414
codeql/typetracking:
15-
version: 0.2.5
15+
version: 0.2.12
1616
codeql/util:
17-
version: 0.2.5
17+
version: 0.2.12
1818
compiled: false

c/cert/test/qlpack.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/cert-c-coding-standards-tests
2-
version: 2.36.0-dev
2+
version: 2.38.0-dev
33
extractor: cpp
44
license: MIT
55
dependencies:

c/cert/test/rules/ARR37-C/DoNotUsePointerArithmeticOnNonArrayObjectPointers.expected

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
edges
2-
| test.c:14:38:14:39 | p1 | test.c:18:10:18:11 | v1 |
3-
| test.c:14:38:14:39 | p1 | test.c:19:10:19:11 | v2 |
4-
| test.c:14:38:14:39 | p1 | test.c:20:10:20:11 | p1 |
5-
| test.c:14:38:14:39 | p1 | test.c:21:10:21:11 | p1 |
6-
| test.c:14:38:14:39 | p1 | test.c:22:9:22:10 | p1 |
7-
| test.c:14:38:14:39 | p1 | test.c:23:13:23:14 | p1 |
8-
| test.c:14:38:14:39 | p1 | test.c:24:9:24:10 | p1 |
9-
| test.c:14:38:14:39 | p1 | test.c:25:9:25:10 | p1 |
10-
| test.c:51:30:51:38 | & ... | test.c:14:38:14:39 | p1 |
2+
| test.c:14:38:14:39 | p1 | test.c:18:10:18:11 | v1 | provenance | |
3+
| test.c:14:38:14:39 | p1 | test.c:19:10:19:11 | v2 | provenance | |
4+
| test.c:14:38:14:39 | p1 | test.c:20:10:20:11 | p1 | provenance | |
5+
| test.c:14:38:14:39 | p1 | test.c:21:10:21:11 | p1 | provenance | |
6+
| test.c:14:38:14:39 | p1 | test.c:22:9:22:10 | p1 | provenance | |
7+
| test.c:14:38:14:39 | p1 | test.c:23:13:23:14 | p1 | provenance | |
8+
| test.c:14:38:14:39 | p1 | test.c:24:9:24:10 | p1 | provenance | |
9+
| test.c:14:38:14:39 | p1 | test.c:25:9:25:10 | p1 | provenance | |
10+
| test.c:51:30:51:38 | & ... | test.c:14:38:14:39 | p1 | provenance | |
1111
nodes
1212
| test.c:14:38:14:39 | p1 | semmle.label | p1 |
1313
| test.c:18:10:18:11 | v1 | semmle.label | v1 |

c/cert/test/rules/ARR39-C/DoNotAddOrSubtractAScaledIntegerToAPointer.expected

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
edges
2-
| test.c:7:13:7:14 | p1 | test.c:9:9:9:10 | p1 |
3-
| test.c:16:19:16:41 | ... - ... | test.c:18:26:18:31 | offset |
4-
| test.c:16:19:16:41 | ... - ... | test.c:29:6:29:11 | offset |
5-
| test.c:17:17:17:26 | sizeof(<expr>) | test.c:23:9:23:12 | size |
6-
| test.c:29:6:29:11 | offset | test.c:7:13:7:14 | p1 |
2+
| test.c:7:13:7:14 | p1 | test.c:9:9:9:10 | p1 | provenance | |
3+
| test.c:16:19:16:41 | ... - ... | test.c:18:26:18:31 | offset | provenance | |
4+
| test.c:16:19:16:41 | ... - ... | test.c:29:6:29:11 | offset | provenance | |
5+
| test.c:17:17:17:26 | sizeof(<expr>) | test.c:23:9:23:12 | size | provenance | |
6+
| test.c:29:6:29:11 | offset | test.c:7:13:7:14 | p1 | provenance | |
77
nodes
88
| test.c:7:13:7:14 | p1 | semmle.label | p1 |
99
| test.c:9:9:9:10 | p1 | semmle.label | p1 |

0 commit comments

Comments
 (0)