Skip to content

Commit aa646b8

Browse files
authored
Merge branch 'main' into michaelrfairhurst/implement-banned2-rule-package-rule-21-24
2 parents b9474d5 + 7736c34 commit aa646b8

File tree

52 files changed

+414
-187
lines changed

Some content is hidden

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

52 files changed

+414
-187
lines changed

.github/workflows/codeql_unit_tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ jobs:
151151
file.close()
152152
153153
- name: Upload test results
154-
uses: actions/upload-artifact@v3
154+
uses: actions/upload-artifact@v4
155155
with:
156156
name: ${{ matrix.language }}-test-results-${{ runner.os }}-${{ matrix.codeql_cli }}-${{ matrix.codeql_standard_library_ident }}
157157
path: |
@@ -171,7 +171,7 @@ jobs:
171171
script: |
172172
core.setFailed('Test run job failed')
173173
- name: Collect test results
174-
uses: actions/download-artifact@v3
174+
uses: actions/download-artifact@v4
175175

176176
- name: Validate test results
177177
run: |

.github/workflows/dispatch-matrix-check.yml

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

.github/workflows/dispatch-matrix-test-on-comment.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,19 @@ jobs:
2626
owner: ${{ github.repository_owner }}
2727
repositories: "codeql-coding-standards-release-engineering"
2828

29-
- name: Dispatch Matrix Testing Job
29+
- name: Invoke matrix testing job
3030
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '/test-matrix') && steps.check-write-permission.outputs.has-permission }}
31-
uses: peter-evans/repository-dispatch@v2
32-
with:
33-
token: ${{ steps.generate-token.outputs.token }}
34-
repository: github/codeql-coding-standards-release-engineering
35-
event-type: matrix-test
36-
client-payload: '{"pr": "${{ github.event.issue.number }}"}'
31+
env:
32+
ISSUE_NR: ${{ github.event.issue.number }}
33+
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
34+
run: |
35+
jq -n \
36+
--arg issue_nr "$ISSUE_NR" \
37+
'{"issue-nr": $issue_nr}' \
38+
| \
39+
gh workflow run pr-compiler-validation.yml \
40+
--json \
41+
-R github/codeql-coding-standards-release-engineering
3742
3843
- uses: actions/github-script@v6
3944
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '/test-matrix') && steps.check-write-permission.outputs.has-permission }}

.github/workflows/dispatch-release-performance-check.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,19 @@ jobs:
2626
owner: ${{ github.repository_owner }}
2727
repositories: "codeql-coding-standards-release-engineering"
2828

29-
- name: Dispatch Performance Testing Job
29+
- name: Invoke performance test
3030
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '/test-performance') && steps.check-write-permission.outputs.has-permission }}
31-
uses: peter-evans/repository-dispatch@v2
32-
with:
33-
token: ${{ steps.generate-token.outputs.token }}
34-
repository: github/codeql-coding-standards-release-engineering
35-
event-type: performance-test
36-
client-payload: '{"pr": "${{ github.event.issue.number }}"}'
31+
env:
32+
ISSUE_NR: ${{ github.event.issue.number }}
33+
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
34+
run: |
35+
jq -n \
36+
--arg issue_nr "$ISSUE_NR" \
37+
'{"issue-nr": $issue_nr}' \
38+
| \
39+
gh workflow run pr-performance-testing.yml \
40+
--json \
41+
-R github/codeql-coding-standards-release-engineering
3742
3843
- uses: actions/github-script@v6
3944
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '/test-performance') && steps.check-write-permission.outputs.has-permission }}

.github/workflows/standard_library_upgrade_tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ jobs:
143143
}, test_summary_file)
144144
145145
- name: Upload test results
146-
uses: actions/upload-artifact@v3
146+
uses: actions/upload-artifact@v4
147147
with:
148148
name: test-results-${{runner.os}}-${{matrix.codeql_cli}}-${{matrix.codeql_standard_library_ident}}
149149
path: |
@@ -162,7 +162,7 @@ jobs:
162162
python-version: "3.9"
163163

164164
- name: Collect test results
165-
uses: actions/download-artifact@v2
165+
uses: actions/download-artifact@v4
166166

167167
- name: Validate test results
168168
shell: python

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22
lockVersion: 1.0.0
33
dependencies:
44
codeql/cpp-all:
5-
version: 0.9.3
5+
version: 0.12.2
66
codeql/dataflow:
7+
version: 0.1.5
8+
codeql/rangeanalysis:
79
version: 0.0.4
810
codeql/ssa:
9-
version: 0.1.5
11+
version: 0.2.5
1012
codeql/tutorial:
11-
version: 0.1.5
13+
version: 0.2.5
14+
codeql/typetracking:
15+
version: 0.2.5
1216
codeql/util:
13-
version: 0.1.5
17+
version: 0.2.5
1418
compiled: false

c/cert/src/qlpack.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ suites: codeql-suites
55
license: MIT
66
dependencies:
77
codeql/common-c-coding-standards: '*'
8-
codeql/cpp-all: 0.9.3
8+
codeql/cpp-all: 0.12.2

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22
lockVersion: 1.0.0
33
dependencies:
44
codeql/cpp-all:
5-
version: 0.9.3
5+
version: 0.12.2
66
codeql/dataflow:
7+
version: 0.1.5
8+
codeql/rangeanalysis:
79
version: 0.0.4
810
codeql/ssa:
9-
version: 0.1.5
11+
version: 0.2.5
1012
codeql/tutorial:
11-
version: 0.1.5
13+
version: 0.2.5
14+
codeql/typetracking:
15+
version: 0.2.5
1216
codeql/util:
13-
version: 0.1.5
17+
version: 0.2.5
1418
compiled: false

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22
lockVersion: 1.0.0
33
dependencies:
44
codeql/cpp-all:
5-
version: 0.9.3
5+
version: 0.12.2
66
codeql/dataflow:
7+
version: 0.1.5
8+
codeql/rangeanalysis:
79
version: 0.0.4
810
codeql/ssa:
9-
version: 0.1.5
11+
version: 0.2.5
1012
codeql/tutorial:
11-
version: 0.1.5
13+
version: 0.2.5
14+
codeql/typetracking:
15+
version: 0.2.5
1216
codeql/util:
13-
version: 0.1.5
17+
version: 0.2.5
1418
compiled: false

c/common/src/qlpack.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ version: 2.36.0-dev
33
license: MIT
44
dependencies:
55
codeql/common-cpp-coding-standards: '*'
6-
codeql/cpp-all: 0.9.3
6+
codeql/cpp-all: 0.12.2

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22
lockVersion: 1.0.0
33
dependencies:
44
codeql/cpp-all:
5-
version: 0.9.3
5+
version: 0.12.2
66
codeql/dataflow:
7+
version: 0.1.5
8+
codeql/rangeanalysis:
79
version: 0.0.4
810
codeql/ssa:
9-
version: 0.1.5
11+
version: 0.2.5
1012
codeql/tutorial:
11-
version: 0.1.5
13+
version: 0.2.5
14+
codeql/typetracking:
15+
version: 0.2.5
1216
codeql/util:
13-
version: 0.1.5
17+
version: 0.2.5
1418
compiled: false

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22
lockVersion: 1.0.0
33
dependencies:
44
codeql/cpp-all:
5-
version: 0.9.3
5+
version: 0.12.2
66
codeql/dataflow:
7+
version: 0.1.5
8+
codeql/rangeanalysis:
79
version: 0.0.4
810
codeql/ssa:
9-
version: 0.1.5
11+
version: 0.2.5
1012
codeql/tutorial:
11-
version: 0.1.5
13+
version: 0.2.5
14+
codeql/typetracking:
15+
version: 0.2.5
1216
codeql/util:
13-
version: 0.1.5
17+
version: 0.2.5
1418
compiled: false

c/misra/src/qlpack.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ license: MIT
66
default-suite-file: codeql-suites/misra-c-default.qls
77
dependencies:
88
codeql/common-c-coding-standards: '*'
9-
codeql/cpp-all: 0.9.3
9+
codeql/cpp-all: 0.12.2

c/misra/src/rules/RULE-10-1/OperandsOfAnInappropriateEssentialType.ql

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import cpp
1616
import codingstandards.c.misra
1717
import codingstandards.c.misra.EssentialTypes
18-
import codingstandards.cpp.Bitwise
1918

2019
/**
2120
* Holds if the operator `operator` has an operand `child` that is of an inappropriate essential type
@@ -179,8 +178,7 @@ predicate isInappropriateEssentialType(
179178
child =
180179
[
181180
operator.(BinaryBitwiseOperation).getAnOperand(),
182-
operator.(Bitwise::AssignBitwiseOperation).getAnOperand(),
183-
operator.(ComplementExpr).getAnOperand()
181+
operator.(AssignBitwiseOperation).getAnOperand(), operator.(ComplementExpr).getAnOperand()
184182
] and
185183
not operator instanceof LShiftExpr and
186184
not operator instanceof RShiftExpr and
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* @id c/misra/function-addresses-should-address-operator
3+
* @name RULE-17-12: A function identifier should only be called with a parenthesized parameter list or used with a &
4+
* @description A function identifier should only be called with a parenthesized parameter list or
5+
* used with a & (address-of).
6+
* @kind problem
7+
* @precision very-high
8+
* @problem.severity error
9+
* @tags external/misra/id/rule-17-12
10+
* readability
11+
* external/misra/c/2012/amendment3
12+
* external/misra/obligation/advisory
13+
*/
14+
15+
import cpp
16+
import codingstandards.c.misra
17+
18+
predicate isImplicitlyAddressed(FunctionAccess access) {
19+
not access.getParent() instanceof AddressOfExpr and
20+
// Note: the following *seems* to only exist in c++ codebases, for instance,
21+
// when calling a member. In c, this syntax should always extract as a
22+
// [FunctionCall] rather than a [ExprCall] of a [FunctionAccess]. Still, this
23+
// is a good pattern to be defensive against.
24+
not exists(ExprCall call | call.getExpr() = access)
25+
}
26+
27+
from FunctionAccess funcAccess
28+
where
29+
not isExcluded(funcAccess, FunctionTypesPackage::functionAddressesShouldAddressOperatorQuery()) and
30+
isImplicitlyAddressed(funcAccess)
31+
select funcAccess,
32+
"The address of function " + funcAccess.getTarget().getName() +
33+
" is taken without the & operator."

c/misra/src/rules/RULE-8-2/FunctionTypesNotInPrototypeForm.ql

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,9 @@ where
4949
msg = "Function " + f + " does not specify void for no parameters present."
5050
or
5151
//parameters declared in declaration list (not in function signature)
52-
//have placeholder file location associated only
53-
exists(Parameter p |
54-
p.getFunction() = f and
55-
not p.getFile() = f.getFile() and
56-
msg = "Function " + f + " declares parameter in unsupported declaration list."
57-
)
52+
//have no prototype
53+
not f.isPrototyped() and
54+
not hasZeroParamDecl(f) and
55+
msg = "Function " + f + " declares parameter in unsupported declaration list."
5856
)
5957
select f, msg

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22
lockVersion: 1.0.0
33
dependencies:
44
codeql/cpp-all:
5-
version: 0.9.3
5+
version: 0.12.2
66
codeql/dataflow:
7+
version: 0.1.5
8+
codeql/rangeanalysis:
79
version: 0.0.4
810
codeql/ssa:
9-
version: 0.1.5
11+
version: 0.2.5
1012
codeql/tutorial:
11-
version: 0.1.5
13+
version: 0.2.5
14+
codeql/typetracking:
15+
version: 0.2.5
1216
codeql/util:
13-
version: 0.1.5
17+
version: 0.2.5
1418
compiled: false
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
| test.c:14:25:14:29 | func2 | The address of function func2 is taken without the & operator. |
2+
| test.c:15:25:15:29 | func3 | The address of function func3 is taken without the & operator. |
3+
| test.c:21:12:21:16 | func1 | The address of function func1 is taken without the & operator. |
4+
| test.c:38:3:38:7 | func1 | The address of function func1 is taken without the & operator. |
5+
| test.c:39:3:39:7 | func2 | The address of function func2 is taken without the & operator. |
6+
| test.c:57:13:57:17 | func1 | The address of function func1 is taken without the & operator. |
7+
| test.c:58:21:58:25 | func2 | The address of function func2 is taken without the & operator. |
8+
| test.c:59:13:59:17 | func1 | The address of function func1 is taken without the & operator. |
9+
| test.c:59:20:59:24 | func2 | The address of function func2 is taken without the & operator. |
10+
| test.c:67:11:67:15 | func1 | The address of function func1 is taken without the & operator. |
11+
| test.c:68:12:68:16 | func1 | The address of function func1 is taken without the & operator. |
12+
| test.c:69:12:69:16 | func1 | The address of function func1 is taken without the & operator. |
13+
| test.c:71:18:71:22 | func1 | The address of function func1 is taken without the & operator. |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rules/RULE-17-12/FunctionAddressesShouldAddressOperator.ql

0 commit comments

Comments
 (0)