Skip to content

Modernize qlpacks #179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 43 commits into from
Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
dfc95c1
Modernize qlpacks and update to CodeQL 2.8.5
jketema Jul 14, 2022
3b7a5e0
Update to CodeQL 2.9.4
jketema Jul 14, 2022
8c2be28
Standardize on Python 3.9 per the user manual
jketema Jul 15, 2022
4d698bc
Bump codeql submodule
jketema Jul 14, 2022
a1750a6
Update test expectations for new flow paths
jketema Jul 14, 2022
487c371
Fix braced initialization detection in A8-5-3
jketema Jul 15, 2022
5c63296
Update symbol location in expected test output
jketema Jul 15, 2022
e85a16f
Fix M0-1-4 to ignore compiler-generated accesses
jketema Jul 15, 2022
498f72c
Bump codeql submodule
jketema Jul 14, 2022
6bd668a
Update c/cert/src/qlpack.yml
mbaluda Aug 31, 2022
41ce019
Update change notes
mbaluda Aug 31, 2022
b4b935d
Update change notes
mbaluda Aug 31, 2022
1a6a71e
Bump to 2.9.0-dev
mbaluda Sep 9, 2022
6022aa1
Merge branch 'main' into mbaluda/updateql2.9.4
mbaluda Sep 9, 2022
1394c95
merge with main
mbaluda Jan 27, 2023
d3f3624
Update qlpack name in query suites
mbaluda Jan 27, 2023
6549297
Merge fix
mbaluda Jan 27, 2023
55ff603
Fix deprecated libraries
mbaluda Jan 27, 2023
e40d933
Revert "Fix deprecated libraries"
jketema Feb 2, 2023
104a317
Modernize the `scripts/generate_modules/queries` qlpack
jketema Feb 2, 2023
8398907
Fix path filter in verify standard library dependencies workflow
jketema Feb 2, 2023
9cd9638
Install codeql packs in "Run analysis report tests" workflow
jketema Feb 2, 2023
c7c00f9
Merge branch 'main' into mbaluda/updateql2.9.4
mbaluda Feb 3, 2023
9c20bfc
Update development_handbook.md
mbaluda Feb 3, 2023
78acc97
Add properties to qlpack.yml files
mbaluda Feb 6, 2023
74ff65d
Replace .codeqlmanifest.json with codeql-workspace.yml
mbaluda Feb 6, 2023
70c4184
remove .codeqlmanifest.json
mbaluda Feb 6, 2023
3cf49f1
Update codeql_unit_tests.yml
mbaluda Feb 6, 2023
f7572ed
Build codeql pack
mbaluda Feb 7, 2023
871a52c
Update code-scanning-pack-gen.yml
mbaluda Feb 7, 2023
fae4944
Revert "remove .codeqlmanifest.json"
mbaluda Feb 7, 2023
febe990
Revert commit 74ff65d
mbaluda Feb 7, 2023
f1ccade
Update code-scanning-pack-gen.yml
mbaluda Feb 7, 2023
25638c8
Revert "Update code-scanning-pack-gen.yml"
mbaluda Feb 7, 2023
588efba
Add .codeqlmanifest.json back
mbaluda Feb 7, 2023
f235db6
Delete .codeqlmanifest.json
mbaluda Feb 7, 2023
1a6d68e
Delete .codeqlmanifest.json
mbaluda Feb 7, 2023
1c9a91e
Remove defaultSuite property
mbaluda Feb 8, 2023
f515ab5
Replace .codeqlmanifest.json with codeql-workspace.yml
mbaluda Feb 8, 2023
d3d4bd3
Revert "Replace .codeqlmanifest.json with codeql-workspace.yml"
mbaluda Feb 8, 2023
995d6f5
Merge branch 'main' into mbaluda/updateql2.9.4
mbaluda Feb 27, 2023
6467c68
Merge branch 'main' into mbaluda/updateql2.9.4
mbaluda Feb 27, 2023
9fffa55
Merge branch 'main' into mbaluda/updateql2.9.4
jsinglet Feb 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .codeqlmanifest.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "provide": [ "codeql_modules/*/.codeqlmanifest.json", "cpp/.codeqlmanifest.json", "c/.codeqlmanifest.json"] }
{ "provide": [ "cpp/*/src/qlpack.yml", "cpp/*/test/qlpack.yml", "c/*/src/qlpack.yml", "c/*/test/qlpack.yml", "scripts/generate_modules/queries/qlpack.yml" ] }
25 changes: 25 additions & 0 deletions .github/actions/install-codeql-packs/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Install CodeQL library pack dependencies
description: |
Downloads any necessary CodeQL library packs needed by packs in the repo.
inputs:
cli_path:
description: |
The path to the CodeQL CLI directory.
required: false

mode:
description: |
The `--mode` option to `codeql pack install`.
required: true
default: verify

runs:
using: composite
steps:
- name: Install CodeQL library packs
shell: bash
env:
CODEQL_CLI: ${{ inputs.cli_path }}
run: |
PATH=$PATH:$CODEQL_CLI
python scripts/install-packs.py --mode ${{ inputs.mode }}
9 changes: 7 additions & 2 deletions .github/workflows/code-scanning-pack-gen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ jobs:
codeql-home: ${{ github.workspace }}/codeql_home
add-to-path: false

- name: Install CodeQL packs
uses: ./.github/actions/install-codeql-packs
with:
cli_path: ${{ github.workspace }}/codeql_home/codeql

- name: Checkout external help files
continue-on-error: true
id: checkout-external-help-files
Expand All @@ -82,8 +87,8 @@ jobs:
run: |
PATH=$PATH:$CODEQL_HOME/codeql

codeql query compile --search-path cpp --threads 0 cpp
codeql query compile --search-path c --search-path cpp --threads 0 c
codeql query compile --threads 0 cpp
codeql query compile --threads 0 c

cd ..
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
Expand Down
23 changes: 12 additions & 11 deletions .github/workflows/codeql_unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: "3.9"

- name: Install Python dependencies
run: pip install -r scripts/requirements.txt

- name: Cache CodeQL
id: cache-codeql
Expand All @@ -66,11 +69,16 @@ jobs:
codeql-home: ${{ github.workspace }}/codeql_home
add-to-path: false

- name: Install CodeQL packs
uses: ./.github/actions/install-codeql-packs
with:
cli_path: ${{ github.workspace }}/codeql_home/codeql

- name: Pre-Compile Queries
id: pre-compile-queries
run: |
${{ github.workspace }}/codeql_home/codeql/codeql query compile --search-path cpp --threads 0 cpp
${{ github.workspace }}/codeql_home/codeql/codeql query compile --search-path c --search-path cpp --threads 0 c
${{ github.workspace }}/codeql_home/codeql/codeql query compile --threads 0 cpp
${{ github.workspace }}/codeql_home/codeql/codeql query compile --threads 0 c


- name: Run test suites
Expand Down Expand Up @@ -122,18 +130,11 @@ jobs:
os.makedirs(os.path.dirname(test_report_path), exist_ok=True)
test_report_file = open(test_report_path, 'w')
files_to_close.append(test_report_file)
if "${{ matrix.language }}".casefold() == "c".casefold():
# c tests require cpp -- but we don't want c things on the cpp
# path in case of design errors.
cpp_language_root = Path(workspace, 'cpp')
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))
else:
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))
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))

for p in procs:
p.wait()
_, err = p.communicate()
if p.returncode != 0:
_, err = p.communicate()
if p.returncode == 122:
# Failed because a test case failed, so just print the regular output.
# This will allow us to proceed to validate-test-results, which will fail if
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/standard_library_upgrade_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ jobs:
stdlib_path = os.path.join(codeql_home, 'codeql-stdlib')
cpp_test_root = Path(stdlib_path, 'cpp/ql/test')
print(f"Executing tests found (recursively) in the directory '{cpp_test_root}'")
cp = subprocess.run([codeql_bin, "test", "run", "--format=json", f'--search-path={stdlib_path}', cpp_test_root], stdout=test_report_file, stderr=subprocess.PIPE)
cp = subprocess.run([codeql_bin, "test", "run", "--format=json", cpp_test_root], stdout=test_report_file, stderr=subprocess.PIPE)
if cp.returncode != 0:
print_error_and_fail(f"Failed to run tests with return code {cp.returncode} and error {cp.stderr}")

Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/tooling-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ jobs:
codeql-home: ${{ github.workspace }}/codeql_home
add-to-path: false

- name: Install CodeQL packs
uses: ./.github/actions/install-codeql-packs
with:
cli_path: ${{ github.workspace }}/codeql_home/codeql

- name: Run PyTest
env:
CODEQL_HOME: ${{ github.workspace }}/codeql_home
Expand Down
79 changes: 79 additions & 0 deletions .github/workflows/verify-standard-library-dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Verify Standard Library Dependencies

# Run this workflow every time the "supported_codeql_configs.json" file or a "qlpack.yml" file is changed
on:
pull_request:
branches:
- main
- "rc/**"
- next
paths:
- "supported_codeql_configs.json"
- "**/qlpack.yml"
workflow_dispatch:

jobs:
prepare-matrix:
name: Prepare CodeQL configuration matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.export-matrix.outputs.matrix }}
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Export unit test matrix
id: export-matrix
run: |
echo "::set-output name=matrix::$(
jq --compact-output \
'.supported_environment | map([.+{os: "ubuntu-20.04-xl", codeql_standard_library_ident : .codeql_standard_library | sub("\/"; "_")}]) | flatten | {include: .}' \
supported_codeql_configs.json
)"

verify-dependencies:
name: Verify dependencies
needs: prepare-matrix

runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix: ${{fromJSON(needs.prepare-matrix.outputs.matrix)}}

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Setup Python 3
uses: actions/setup-python@v4
with:
python-version: "3.9"

- name: Cache CodeQL
id: cache-codeql
uses: actions/cache@v2.1.3
with:
# A list of files, directories, and wildcard patterns to cache and restore
path: ${{github.workspace}}/codeql_home
# An explicit key for restoring and saving the cache
key: codeql-home-${{matrix.os}}-${{matrix.codeql_cli}}-${{matrix.codeql_standard_library}}

- name: Install CodeQL
if: steps.cache-codeql.outputs.cache-hit != 'true'
uses: ./.github/actions/install-codeql
with:
codeql-cli-version: ${{matrix.codeql_cli}}
codeql-stdlib-version: ${{matrix.codeql_standard_library}}
codeql-home: ${{ github.workspace }}/codeql_home

- name: Verify dependencies
shell: bash
env:
CLI_PATH: ${{ github.workspace }}/codeql_home/codeql
STDLIB_PATH: ${{ github.workspace }}/codeql_home/codeql-stdlib
run: |
PATH=$PATH:$CLI_PATH
ls $STDLIB_PATH
pip install -r scripts/requirements.txt
python3 scripts/verify-standard-library-version.py --codeql-repo $STDLIB_PATH --mode verify

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@
# C/C++ build artifacts
*.o
/databases/

# CodeQL build artifacts
**/.codeql/**
3 changes: 0 additions & 3 deletions c/.codeqlmanifest.json

This file was deleted.

6 changes: 6 additions & 0 deletions c/cert/src/codeql-pack.lock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
dependencies:
codeql/cpp-all:
version: 0.2.3
compiled: false
lockVersion: 1.0.0
2 changes: 1 addition & 1 deletion c/cert/src/codeql-suites/cert-default.qls
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- description: CERT C 2016 (Default)
- qlpack: cert-c-coding-standards
- qlpack: codeql/cert-c-coding-standards
- include:
kind:
- problem
Expand Down
8 changes: 6 additions & 2 deletions c/cert/src/qlpack.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
name: cert-c-coding-standards
name: codeql/cert-c-coding-standards
version: 2.14.0-dev
description: CERT C 2016
suites: codeql-suites
libraryPathDependencies: common-c-coding-standards
license: MIT
dependencies:
codeql/common-c-coding-standards: '*'
codeql/cpp-all: 0.2.3
6 changes: 6 additions & 0 deletions c/cert/test/codeql-pack.lock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
dependencies:
codeql/cpp-all:
version: 0.2.3
compiled: false
lockVersion: 1.0.0
8 changes: 5 additions & 3 deletions c/cert/test/qlpack.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
name: cert-c-coding-standards-tests
name: codeql/cert-c-coding-standards-tests
version: 2.14.0-dev
libraryPathDependencies: cert-c-coding-standards
extractor: cpp
extractor: cpp
license: MIT
dependencies:
codeql/cert-c-coding-standards: '*'
6 changes: 6 additions & 0 deletions c/common/src/codeql-pack.lock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
dependencies:
codeql/cpp-all:
version: 0.2.3
compiled: false
lockVersion: 1.0.0
7 changes: 5 additions & 2 deletions c/common/src/qlpack.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
name: common-c-coding-standards
name: codeql/common-c-coding-standards
version: 2.14.0-dev
libraryPathDependencies: common-cpp-coding-standards
license: MIT
dependencies:
codeql/common-cpp-coding-standards: '*'
codeql/cpp-all: 0.2.3
6 changes: 6 additions & 0 deletions c/common/test/codeql-pack.lock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
dependencies:
codeql/cpp-all:
version: 0.2.3
compiled: false
lockVersion: 1.0.0
6 changes: 4 additions & 2 deletions c/common/test/qlpack.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
name: common-c-coding-standards-tests
name: codeql/common-c-coding-standards-tests
version: 2.14.0-dev
libraryPathDependencies: common-c-coding-standards
extractor: cpp
license: MIT
dependencies:
codeql/common-c-coding-standards: '*'
6 changes: 6 additions & 0 deletions c/misra/src/codeql-pack.lock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
dependencies:
codeql/cpp-all:
version: 0.2.3
compiled: false
lockVersion: 1.0.0
2 changes: 1 addition & 1 deletion c/misra/src/codeql-suites/misra-default.qls
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- description: MISRA C 2012 (Default)
- qlpack: misra-c-coding-standards
- qlpack: codeql/misra-c-coding-standards
- include:
kind:
- problem
Expand Down
8 changes: 6 additions & 2 deletions c/misra/src/qlpack.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
name: misra-c-coding-standards
name: codeql/misra-c-coding-standards
version: 2.14.0-dev
description: MISRA C 2012
suites: codeql-suites
libraryPathDependencies: common-c-coding-standards
license: MIT
dependencies:
codeql/common-c-coding-standards: '*'
codeql/cpp-all: 0.2.3
6 changes: 6 additions & 0 deletions c/misra/test/codeql-pack.lock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
dependencies:
codeql/cpp-all:
version: 0.2.3
compiled: false
lockVersion: 1.0.0
8 changes: 5 additions & 3 deletions c/misra/test/qlpack.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
name: misra-c-coding-standards-tests
name: codeql/misra-c-coding-standards-tests
version: 2.14.0-dev
libraryPathDependencies: misra-c-coding-standards
extractor: cpp
extractor: cpp
license: MIT
dependencies:
codeql/misra-c-coding-standards: '*'
3 changes: 0 additions & 3 deletions cpp/.codeqlmanifest.json

This file was deleted.

6 changes: 6 additions & 0 deletions cpp/autosar/src/codeql-pack.lock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
dependencies:
codeql/cpp-all:
version: 0.2.3
compiled: false
lockVersion: 1.0.0
2 changes: 1 addition & 1 deletion cpp/autosar/src/codeql-suites/autosar-advisory.qls
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- description: AUTOSAR C++14 Guidelines 20-11 (Advisory)
- qlpack: autosar-cpp-coding-standards
- qlpack: codeql/autosar-cpp-coding-standards
- include:
kind:
- problem
Expand Down
2 changes: 1 addition & 1 deletion cpp/autosar/src/codeql-suites/autosar-audit.qls
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- description: AUTOSAR C++14 Guidelines 20-11 (Audit)
- qlpack: autosar-cpp-coding-standards
- qlpack: codeql/autosar-cpp-coding-standards
- include:
kind:
- problem
Expand Down
2 changes: 1 addition & 1 deletion cpp/autosar/src/codeql-suites/autosar-default.qls
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- description: AUTOSAR C++14 Guidelines 20-11 (Default)
- qlpack: autosar-cpp-coding-standards
- qlpack: codeql/autosar-cpp-coding-standards
- include:
kind:
- problem
Expand Down
2 changes: 1 addition & 1 deletion cpp/autosar/src/codeql-suites/autosar-required.qls
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- description: AUTOSAR C++14 Guidelines 20-11 (Required)
- qlpack: autosar-cpp-coding-standards
- qlpack: codeql/autosar-cpp-coding-standards
- include:
kind:
- problem
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- description: AUTOSAR C++14 Guidelines 20-11 (Single Translation Unit)
- qlpack: autosar-cpp-coding-standards
- qlpack: codeql/autosar-cpp-coding-standards
- include:
kind:
- problem
Expand Down
8 changes: 6 additions & 2 deletions cpp/autosar/src/qlpack.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
name: autosar-cpp-coding-standards
name: codeql/autosar-cpp-coding-standards
version: 2.14.0-dev
description: AUTOSAR C++14 Guidelines 20-11
suites: codeql-suites
libraryPathDependencies: common-cpp-coding-standards
license: MIT
dependencies:
codeql/common-cpp-coding-standards: '*'
codeql/cpp-all: 0.2.3
6 changes: 6 additions & 0 deletions cpp/autosar/test/codeql-pack.lock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
dependencies:
codeql/cpp-all:
version: 0.2.3
compiled: false
lockVersion: 1.0.0
Loading