Skip to content

Commit ca169de

Browse files
authored
Merge branch 'main' into Memory1
2 parents 56e6ebd + 0e9bcdd commit ca169de

File tree

235 files changed

+6094
-463
lines changed

Some content is hidden

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

235 files changed

+6094
-463
lines changed

.codeqlmanifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "provide": [ "codeql_modules/*/.codeqlmanifest.json", "cpp/.codeqlmanifest.json", "c/.codeqlmanifest.json"] }
1+
{ "provide": [ "cpp/*/src/qlpack.yml", "cpp/*/test/qlpack.yml", "c/*/src/qlpack.yml", "c/*/test/qlpack.yml", "scripts/generate_modules/queries/qlpack.yml" ] }
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Install CodeQL library pack dependencies
2+
description: |
3+
Downloads any necessary CodeQL library packs needed by packs in the repo.
4+
inputs:
5+
cli_path:
6+
description: |
7+
The path to the CodeQL CLI directory.
8+
required: false
9+
10+
mode:
11+
description: |
12+
The `--mode` option to `codeql pack install`.
13+
required: true
14+
default: verify
15+
16+
runs:
17+
using: composite
18+
steps:
19+
- name: Install CodeQL library packs
20+
shell: bash
21+
env:
22+
CODEQL_CLI: ${{ inputs.cli_path }}
23+
run: |
24+
PATH=$PATH:$CODEQL_CLI
25+
python scripts/install-packs.py --mode ${{ inputs.mode }}

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ jobs:
5959
codeql-home: ${{ github.workspace }}/codeql_home
6060
add-to-path: false
6161

62+
- name: Install CodeQL packs
63+
uses: ./.github/actions/install-codeql-packs
64+
with:
65+
cli_path: ${{ github.workspace }}/codeql_home/codeql
66+
6267
- name: Checkout external help files
6368
continue-on-error: true
6469
id: checkout-external-help-files
@@ -82,8 +87,8 @@ jobs:
8287
run: |
8388
PATH=$PATH:$CODEQL_HOME/codeql
8489
85-
codeql query compile --search-path cpp --threads 0 cpp
86-
codeql query compile --search-path c --search-path cpp --threads 0 c
90+
codeql query compile --threads 0 cpp
91+
codeql query compile --threads 0 c
8792
8893
cd ..
8994
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/scripts/shared codeql-coding-standards/scripts/schemas

.github/workflows/codeql_unit_tests.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ jobs:
4747
uses: actions/setup-python@v4
4848
with:
4949
python-version: "3.9"
50+
51+
- name: Install Python dependencies
52+
run: pip install -r scripts/requirements.txt
5053

5154
- name: Cache CodeQL
5255
id: cache-codeql
@@ -66,11 +69,15 @@ jobs:
6669
codeql-home: ${{ github.workspace }}/codeql_home
6770
add-to-path: false
6871

72+
- name: Install CodeQL packs
73+
uses: ./.github/actions/install-codeql-packs
74+
with:
75+
cli_path: ${{ github.workspace }}/codeql_home/codeql
76+
6977
- name: Pre-Compile Queries
7078
id: pre-compile-queries
7179
run: |
72-
${{ github.workspace }}/codeql_home/codeql/codeql query compile --search-path cpp --threads 0 cpp
73-
${{ github.workspace }}/codeql_home/codeql/codeql query compile --search-path c --search-path cpp --threads 0 c
80+
${{ github.workspace }}/codeql_home/codeql/codeql query compile --threads 0 ${{ matrix.language }}
7481
7582
7683
- name: Run test suites
@@ -122,18 +129,11 @@ jobs:
122129
os.makedirs(os.path.dirname(test_report_path), exist_ok=True)
123130
test_report_file = open(test_report_path, 'w')
124131
files_to_close.append(test_report_file)
125-
if "${{ matrix.language }}".casefold() == "c".casefold():
126-
# c tests require cpp -- but we don't want c things on the cpp
127-
# path in case of design errors.
128-
cpp_language_root = Path(workspace, 'cpp')
129-
procs.append(subprocess.Popen([codeql_bin, "test", "run", "--failing-exitcode=122", f"--slice={slice}/{num_slices}", "--ram=2048", "--format=json", f'--search-path={cpp_language_root}', f'--search-path={language_root}', *test_roots], stdout=test_report_file, stderr=subprocess.PIPE))
130-
else:
131-
procs.append(subprocess.Popen([codeql_bin, "test", "run", "--failing-exitcode=122", f"--slice={slice}/{num_slices}", "--ram=2048", "--format=json", f'--search-path={language_root}', f'--search-path={language_root}', *test_roots], stdout=test_report_file, stderr=subprocess.PIPE))
132+
procs.append(subprocess.Popen([codeql_bin, "test", "run", "--failing-exitcode=122", f"--slice={slice}/{num_slices}", "--ram=2048", "--format=json", *test_roots], stdout=test_report_file, stderr=subprocess.PIPE))
132133
133134
for p in procs:
134-
p.wait()
135+
_, err = p.communicate()
135136
if p.returncode != 0:
136-
_, err = p.communicate()
137137
if p.returncode == 122:
138138
# Failed because a test case failed, so just print the regular output.
139139
# This will allow us to proceed to validate-test-results, which will fail if
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: 🤖 Run Matrix Check
2+
3+
on:
4+
pull_request_target:
5+
types: [synchronize,opened]
6+
branches:
7+
- "**"
8+
workflow_dispatch:
9+
10+
jobs:
11+
dispatch-matrix-check:
12+
runs-on: ubuntu-latest
13+
steps:
14+
15+
- name: Test Variables
16+
shell: pwsh
17+
run: |
18+
Write-Host "Running as: ${{github.actor}}"
19+
20+
- name: Dispatch Matrix Testing Job
21+
if: ${{ contains(fromJSON('["jsinglet", "mbaluda", "lcartey", "rvermeulen", "ravikprasad", "jeongsoolee09", "hohn", "knewbury01", "kraiouchkine"]'), github.actor) }}
22+
uses: peter-evans/repository-dispatch@v2
23+
with:
24+
token: ${{ secrets.RELEASE_ENGINEERING_TOKEN }}
25+
repository: github/codeql-coding-standards-release-engineering
26+
event-type: matrix-test
27+
client-payload: '{"pr": "${{ github.event.number }}"}'
28+
29+
30+
- uses: actions/github-script@v6
31+
if: ${{ contains(fromJSON('["jsinglet", "mbaluda", "lcartey", "rvermeulen", "ravikprasad", "jeongsoolee09", "hohn", "knewbury01", "kraiouchkine"]'), github.actor) }}
32+
with:
33+
script: |
34+
github.rest.issues.createComment({
35+
issue_number: context.issue.number,
36+
owner: context.repo.owner,
37+
repo: context.repo.repo,
38+
body: '🤖 Beep Boop! Matrix Testing for this PR has been initiated. Please check back later for results. <br><br> :bulb: If you do not hear back from me please check my status! **I will report even if this PR does not contain files eligible for matrix testing.**'
39+
})
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: 🏁 Run Release Performance Check
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
branches:
7+
- main
8+
- "rc/**"
9+
- next
10+
11+
jobs:
12+
dispatch-matrix-check:
13+
runs-on: ubuntu-latest
14+
steps:
15+
16+
- name: Test Variables
17+
shell: pwsh
18+
run: |
19+
Write-Host "Running as: ${{github.actor}}"
20+
21+
$actor = "${{github.actor}}"
22+
23+
$acl = @("jsinglet","mbaluda", "lcartey", "rvermeulen", "ravikprasad", "jeongsoolee09", "hohn", "knewbury01", "kraiouchkine")
24+
25+
if(-not ($actor -in $acl)){
26+
throw "Refusing to run workflow for user not in acl."
27+
}
28+
29+
- name: Dispatch Performance Testing Job
30+
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '/test-performance') }}
31+
uses: peter-evans/repository-dispatch@v2
32+
with:
33+
token: ${{ secrets.RELEASE_ENGINEERING_TOKEN }}
34+
repository: github/codeql-coding-standards-release-engineering
35+
event-type: performance-test
36+
client-payload: '{"pr": "${{ github.event.issue.number }}"}'
37+
38+
39+
- uses: actions/github-script@v6
40+
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '/test-performance') }}
41+
with:
42+
script: |
43+
github.rest.issues.createComment({
44+
issue_number: context.issue.number,
45+
owner: context.repo.owner,
46+
repo: context.repo.repo,
47+
body: '🏁 Beep Boop! Performance testing for this PR has been initiated. Please check back later for results. Note that the query package generation step must complete before testing will start so it might be a minute. <br><br> :bulb: If you do not hear back from me please check my status! **I will report even if I fail!**'
48+
})

.github/workflows/standard_library_upgrade_tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ jobs:
116116
stdlib_path = os.path.join(codeql_home, 'codeql-stdlib')
117117
cpp_test_root = Path(stdlib_path, 'cpp/ql/test')
118118
print(f"Executing tests found (recursively) in the directory '{cpp_test_root}'")
119-
cp = subprocess.run([codeql_bin, "test", "run", "--format=json", f'--search-path={stdlib_path}', cpp_test_root], stdout=test_report_file, stderr=subprocess.PIPE)
119+
cp = subprocess.run([codeql_bin, "test", "run", "--format=json", cpp_test_root], stdout=test_report_file, stderr=subprocess.PIPE)
120120
if cp.returncode != 0:
121121
print_error_and_fail(f"Failed to run tests with return code {cp.returncode} and error {cp.stderr}")
122122

.github/workflows/tooling-unit-tests.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ jobs:
6464
codeql-home: ${{ github.workspace }}/codeql_home
6565
add-to-path: false
6666

67+
- name: Install CodeQL packs
68+
uses: ./.github/actions/install-codeql-packs
69+
with:
70+
cli_path: ${{ github.workspace }}/codeql_home/codeql
71+
6772
- name: Run PyTest
6873
env:
6974
CODEQL_HOME: ${{ github.workspace }}/codeql_home
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Verify Standard Library Dependencies
2+
3+
# Run this workflow every time the "supported_codeql_configs.json" file or a "qlpack.yml" file is changed
4+
on:
5+
pull_request:
6+
branches:
7+
- main
8+
- "rc/**"
9+
- next
10+
paths:
11+
- "supported_codeql_configs.json"
12+
- "**/qlpack.yml"
13+
workflow_dispatch:
14+
15+
jobs:
16+
prepare-matrix:
17+
name: Prepare CodeQL configuration matrix
18+
runs-on: ubuntu-latest
19+
outputs:
20+
matrix: ${{ steps.export-matrix.outputs.matrix }}
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v2
24+
25+
- name: Export unit test matrix
26+
id: export-matrix
27+
run: |
28+
echo "::set-output name=matrix::$(
29+
jq --compact-output \
30+
'.supported_environment | map([.+{os: "ubuntu-20.04-xl", codeql_standard_library_ident : .codeql_standard_library | sub("\/"; "_")}]) | flatten | {include: .}' \
31+
supported_codeql_configs.json
32+
)"
33+
34+
verify-dependencies:
35+
name: Verify dependencies
36+
needs: prepare-matrix
37+
38+
runs-on: ${{ matrix.os }}
39+
strategy:
40+
fail-fast: false
41+
matrix: ${{fromJSON(needs.prepare-matrix.outputs.matrix)}}
42+
43+
steps:
44+
- name: Checkout repository
45+
uses: actions/checkout@v2
46+
47+
- name: Setup Python 3
48+
uses: actions/setup-python@v4
49+
with:
50+
python-version: "3.9"
51+
52+
- name: Cache CodeQL
53+
id: cache-codeql
54+
uses: actions/cache@v2.1.3
55+
with:
56+
# A list of files, directories, and wildcard patterns to cache and restore
57+
path: ${{github.workspace}}/codeql_home
58+
# An explicit key for restoring and saving the cache
59+
key: codeql-home-${{matrix.os}}-${{matrix.codeql_cli}}-${{matrix.codeql_standard_library}}
60+
61+
- name: Install CodeQL
62+
if: steps.cache-codeql.outputs.cache-hit != 'true'
63+
uses: ./.github/actions/install-codeql
64+
with:
65+
codeql-cli-version: ${{matrix.codeql_cli}}
66+
codeql-stdlib-version: ${{matrix.codeql_standard_library}}
67+
codeql-home: ${{ github.workspace }}/codeql_home
68+
69+
- name: Verify dependencies
70+
shell: bash
71+
env:
72+
CLI_PATH: ${{ github.workspace }}/codeql_home/codeql
73+
STDLIB_PATH: ${{ github.workspace }}/codeql_home/codeql-stdlib
74+
run: |
75+
PATH=$PATH:$CLI_PATH
76+
ls $STDLIB_PATH
77+
pip install -r scripts/requirements.txt
78+
python3 scripts/verify-standard-library-version.py --codeql-repo $STDLIB_PATH --mode verify
79+

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@
2020
# C/C++ build artifacts
2121
*.o
2222
/databases/
23+
24+
# CodeQL build artifacts
25+
**/.codeql/**

.vscode/tasks.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,11 @@
193193
"Classes",
194194
"Comments",
195195
"Contracts1",
196+
"Contracts2",
197+
"Contracts3",
198+
"Contracts4",
199+
"Contracts5",
200+
"Contracts6",
196201
"Concurrency",
197202
"Concurrency",
198203
"Concurrency1",
@@ -211,6 +216,7 @@
211216
"Declarations5",
212217
"Declarations6",
213218
"Declarations7",
219+
"Declarations8",
214220
"Exceptions1",
215221
"Exceptions2",
216222
"Expressions",
@@ -244,6 +250,7 @@
244250
"Pointers",
245251
"Pointers1",
246252
"Pointers2",
253+
"Pointers3",
247254
"Scope",
248255
"SideEffects1",
249256
"SideEffects2",

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ _Carnegie Mellon and CERT are registered trademarks of Carnegie Mellon Universit
99
This repository contains CodeQL queries and libraries which support various Coding Standards for the [C++14](https://www.iso.org/standard/64029.html) programming language.
1010

1111
The following coding standards are supported:
12-
- [AUTOSAR - Guidelines for the use of C++14 language in critical and safety-related systems Release 20-11](https://www.autosar.org/fileadmin/user_upload/standards/adaptive/20-11/AUTOSAR_RS_CPP14Guidelines.pdf)
12+
- [AUTOSAR - Guidelines for the use of C++14 language in critical and safety-related systems Release 20-11](https://www.autosar.org/fileadmin/standards/adaptive/20-11/AUTOSAR_RS_CPP14Guidelines.pdf)
1313
- [MISRA C++:2008](https://www.misra.org.uk) (support limited to the rules specified in AUTOSAR 20-11).
1414
- [SEI CERT C++ Coding Standard: Rules for Developing Safe, Reliable, and Secure Systems (2016 Edition)](https://resources.sei.cmu.edu/library/asset-view.cfm?assetID=494932)
1515

c/.codeqlmanifest.json

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

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
dependencies:
3+
codeql/cpp-all:
4+
version: 0.2.3
5+
compiled: false
6+
lockVersion: 1.0.0

c/cert/src/codeql-suites/cert-default.qls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
- description: CERT C 2016 (Default)
2-
- qlpack: cert-c-coding-standards
2+
- qlpack: codeql/cert-c-coding-standards
33
- include:
44
kind:
55
- problem

c/cert/src/qlpack.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
name: cert-c-coding-standards
2-
version: 2.13.0-dev
1+
name: codeql/cert-c-coding-standards
2+
version: 2.14.0-dev
3+
description: CERT C 2016
34
suites: codeql-suites
4-
libraryPathDependencies: common-c-coding-standards
5+
license: MIT
6+
dependencies:
7+
codeql/common-c-coding-standards: '*'
8+
codeql/cpp-all: 0.2.3

0 commit comments

Comments
 (0)