Skip to content

Commit 348b20c

Browse files
authored
Merge branch 'main' of https://github.com/github/codeql into python-a-few-minor-cleanups
2 parents 9351688 + 081fd28 commit 348b20c

File tree

655 files changed

+17448
-1701
lines changed

Some content is hidden

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

655 files changed

+17448
-1701
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Check framework coverage changes
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- '.github/workflows/csv-coverage-pr-comment.yml'
7+
- '*/ql/src/**/*.ql'
8+
- '*/ql/src/**/*.qll'
9+
- 'misc/scripts/library-coverage/*.py'
10+
# input data files
11+
- '*/documentation/library-coverage/cwe-sink.csv'
12+
- '*/documentation/library-coverage/frameworks.csv'
13+
branches:
14+
- main
15+
- 'rc/*'
16+
17+
jobs:
18+
generate:
19+
name: Generate framework coverage artifacts
20+
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- name: Dump GitHub context
25+
env:
26+
GITHUB_CONTEXT: ${{ toJSON(github.event) }}
27+
run: echo "$GITHUB_CONTEXT"
28+
- name: Clone self (github/codeql) - MERGE
29+
uses: actions/checkout@v2
30+
with:
31+
path: merge
32+
- name: Clone self (github/codeql) - BASE
33+
uses: actions/checkout@v2
34+
with:
35+
ref: ${{ github.event.pull_request.base.sha }}
36+
path: base
37+
- name: Set up Python 3.8
38+
uses: actions/setup-python@v2
39+
with:
40+
python-version: 3.8
41+
- name: Download CodeQL CLI
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
run: |
45+
gh release download --repo "github/codeql-cli-binaries" --pattern "codeql-linux64.zip"
46+
- name: Unzip CodeQL CLI
47+
run: unzip -d codeql-cli codeql-linux64.zip
48+
- name: Generate CSV files on merge and base of the PR
49+
run: |
50+
echo "Running generator on ${{github.sha}}"
51+
PATH="$PATH:codeql-cli/codeql" python merge/misc/scripts/library-coverage/generate-report.py ci merge merge
52+
mkdir out_merge
53+
cp framework-coverage-*.csv out_merge/
54+
cp framework-coverage-*.rst out_merge/
55+
56+
echo "Running generator on ${{github.event.pull_request.base.sha}}"
57+
PATH="$PATH:codeql-cli/codeql" python base/misc/scripts/library-coverage/generate-report.py ci base base
58+
mkdir out_base
59+
cp framework-coverage-*.csv out_base/
60+
cp framework-coverage-*.rst out_base/
61+
- name: Upload CSV package list
62+
uses: actions/upload-artifact@v2
63+
with:
64+
name: csv-framework-coverage-merge
65+
path: |
66+
out_merge/framework-coverage-*.csv
67+
out_merge/framework-coverage-*.rst
68+
- name: Upload CSV package list
69+
uses: actions/upload-artifact@v2
70+
with:
71+
name: csv-framework-coverage-base
72+
path: |
73+
out_base/framework-coverage-*.csv
74+
out_base/framework-coverage-*.rst
75+
- name: Save PR number
76+
run: |
77+
mkdir -p pr
78+
echo ${{ github.event.pull_request.number }} > pr/NR
79+
- name: Upload PR number
80+
uses: actions/upload-artifact@v2
81+
with:
82+
name: pr
83+
path: pr/
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Comment on PR with framework coverage changes
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Check framework coverage changes"]
6+
types:
7+
- completed
8+
9+
jobs:
10+
check:
11+
name: Check framework coverage differences and comment
12+
runs-on: ubuntu-latest
13+
if: >
14+
${{ github.event.workflow_run.event == 'pull_request' &&
15+
github.event.workflow_run.conclusion == 'success' }}
16+
17+
steps:
18+
- name: Dump GitHub context
19+
env:
20+
GITHUB_CONTEXT: ${{ toJSON(github.event) }}
21+
run: echo "$GITHUB_CONTEXT"
22+
- name: Clone self (github/codeql)
23+
uses: actions/checkout@v2
24+
- name: Set up Python 3.8
25+
uses: actions/setup-python@v2
26+
with:
27+
python-version: 3.8
28+
29+
# download artifacts from the PR job:
30+
31+
- name: Download artifact - MERGE
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
RUN_ID: ${{ github.event.workflow_run.id }}
35+
run: |
36+
gh run download --name "csv-framework-coverage-merge" --dir "out_merge" "$RUN_ID"
37+
38+
- name: Download artifact - BASE
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
RUN_ID: ${{ github.event.workflow_run.id }}
42+
run: |
43+
gh run download --name "csv-framework-coverage-base" --dir "out_base" "$RUN_ID"
44+
45+
- name: Download artifact - PR
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
RUN_ID: ${{ github.event.workflow_run.id }}
49+
run: |
50+
gh run download --name "pr" --dir "pr" "$RUN_ID"
51+
52+
- name: Check coverage files
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
RUN_ID: ${{ github.event.workflow_run.id }}
56+
run: |
57+
PR=$(cat "pr/NR")
58+
python misc/scripts/library-coverage/compare-files-comment-pr.py \
59+
out_merge out_base comparison.md "$GITHUB_REPOSITORY" "$PR" "$RUN_ID"
60+
- name: Upload comparison results
61+
uses: actions/upload-artifact@v2
62+
with:
63+
name: comparison
64+
path: |
65+
comparison.md
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Build framework coverage timeseries reports
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
build:
8+
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Clone self (github/codeql)
13+
uses: actions/checkout@v2
14+
with:
15+
path: script
16+
- name: Clone self (github/codeql) for analysis
17+
uses: actions/checkout@v2
18+
with:
19+
path: codeqlModels
20+
fetch-depth: 0
21+
- name: Set up Python 3.8
22+
uses: actions/setup-python@v2
23+
with:
24+
python-version: 3.8
25+
- name: Download CodeQL CLI
26+
env:
27+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
run: |
29+
gh release download --repo "github/codeql-cli-binaries" --pattern "codeql-linux64.zip"
30+
- name: Unzip CodeQL CLI
31+
run: unzip -d codeql-cli codeql-linux64.zip
32+
- name: Build modeled package list
33+
run: |
34+
CLI=$(realpath "codeql-cli/codeql")
35+
echo $CLI
36+
PATH="$PATH:$CLI" python script/misc/scripts/library-coverage/generate-timeseries.py codeqlModels
37+
- name: Upload timeseries CSV
38+
uses: actions/upload-artifact@v2
39+
with:
40+
name: framework-coverage-timeseries
41+
path: framework-coverage-timeseries-*.csv
42+

.github/workflows/csv-coverage.yml

Lines changed: 10 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,11 @@
1-
name: Build/check CSV flow coverage report
1+
name: Build framework coverage reports
22

33
on:
44
workflow_dispatch:
55
inputs:
66
qlModelShaOverride:
77
description: 'github/codeql repo SHA used for looking up the CSV models'
88
required: false
9-
push:
10-
branches:
11-
- main
12-
- 'rc/**'
13-
pull_request:
14-
paths:
15-
- '.github/workflows/csv-coverage.yml'
16-
- '*/ql/src/**/*.ql'
17-
- '*/ql/src/**/*.qll'
18-
- 'misc/scripts/library-coverage/*.py'
19-
# input data files
20-
- '*/documentation/library-coverage/cwe-sink.csv'
21-
- '*/documentation/library-coverage/frameworks.csv'
22-
# coverage report files
23-
- '*/documentation/library-coverage/flow-model-coverage.csv'
24-
- '*/documentation/library-coverage/flow-model-coverage.rst'
259

2610
jobs:
2711
build:
@@ -33,28 +17,20 @@ jobs:
3317
uses: actions/checkout@v2
3418
with:
3519
path: script
36-
- name: Clone self (github/codeql) at a given SHA for analysis
37-
if: github.event.inputs.qlModelShaOverride != ''
38-
uses: actions/checkout@v2
39-
with:
40-
path: codeqlModels
41-
ref: github.event.inputs.qlModelShaOverride
4220
- name: Clone self (github/codeql) for analysis
43-
if: github.event.inputs.qlModelShaOverride == ''
4421
uses: actions/checkout@v2
4522
with:
4623
path: codeqlModels
24+
ref: ${{ github.event.inputs.qlModelShaOverride || github.ref }}
4725
- name: Set up Python 3.8
4826
uses: actions/setup-python@v2
4927
with:
5028
python-version: 3.8
5129
- name: Download CodeQL CLI
52-
uses: dsaltares/fetch-gh-release-asset@aa37ae5c44d3c9820bc12fe675e8670ecd93bd1c
53-
with:
54-
repo: "github/codeql-cli-binaries"
55-
version: "latest"
56-
file: "codeql-linux64.zip"
57-
token: ${{ secrets.GITHUB_TOKEN }}
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
run: |
33+
gh release download --repo "github/codeql-cli-binaries" --pattern "codeql-linux64.zip"
5834
- name: Unzip CodeQL CLI
5935
run: unzip -d codeql-cli codeql-linux64.zip
6036
- name: Build modeled package list
@@ -63,15 +39,11 @@ jobs:
6339
- name: Upload CSV package list
6440
uses: actions/upload-artifact@v2
6541
with:
66-
name: csv-flow-model-coverage
67-
path: flow-model-coverage-*.csv
42+
name: framework-coverage-csv
43+
path: framework-coverage-*.csv
6844
- name: Upload RST package list
6945
uses: actions/upload-artifact@v2
7046
with:
71-
name: rst-flow-model-coverage
72-
path: flow-model-coverage-*.rst
73-
# - name: Check coverage files
74-
# if: github.event.pull_request
75-
# run: |
76-
# python script/misc/scripts/library-coverage/compare-files.py codeqlModels
47+
name: framework-coverage-rst
48+
path: framework-coverage-*.rst
7749

cpp/ql/src/Best Practices/Likely Errors/OffsetUseBeforeRangeCheck.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* @kind problem
66
* @id cpp/offset-use-before-range-check
77
* @problem.severity warning
8-
* @security-severity 5.9
8+
* @security-severity 8.2
99
* @precision medium
1010
* @tags reliability
1111
* security

cpp/ql/src/Critical/DescriptorMayNotBeClosed.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @kind problem
55
* @id cpp/descriptor-may-not-be-closed
66
* @problem.severity warning
7-
* @security-severity 5.9
7+
* @security-severity 7.8
88
* @tags efficiency
99
* security
1010
* external/cwe/cwe-775

cpp/ql/src/Critical/DescriptorNeverClosed.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @kind problem
55
* @id cpp/descriptor-never-closed
66
* @problem.severity warning
7-
* @security-severity 5.9
7+
* @security-severity 7.8
88
* @tags efficiency
99
* security
1010
* external/cwe/cwe-775

cpp/ql/src/Critical/FileMayNotBeClosed.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @kind problem
55
* @id cpp/file-may-not-be-closed
66
* @problem.severity warning
7-
* @security-severity 5.9
7+
* @security-severity 7.8
88
* @tags efficiency
99
* security
1010
* external/cwe/cwe-775

cpp/ql/src/Critical/FileNeverClosed.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @kind problem
55
* @id cpp/file-never-closed
66
* @problem.severity warning
7-
* @security-severity 5.9
7+
* @security-severity 7.8
88
* @tags efficiency
99
* security
1010
* external/cwe/cwe-775

cpp/ql/src/Critical/GlobalUseBeforeInit.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @kind problem
55
* @id cpp/global-use-before-init
66
* @problem.severity warning
7-
* @security-severity 6.9
7+
* @security-severity 7.8
88
* @tags reliability
99
* security
1010
* external/cwe/cwe-457

0 commit comments

Comments
 (0)