Skip to content

Commit 0794511

Browse files
authored
Merge branch 'main' into codeql-ci/atm/release-0.4.9
2 parents a82aaea + b3fa844 commit 0794511

File tree

7,441 files changed

+818409
-396453
lines changed

Some content is hidden

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

7,441 files changed

+818409
-396453
lines changed

.github/ISSUE_TEMPLATE/lgtm-com---false-positive.md

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

.github/ISSUE_TEMPLATE/ql---general.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ assignees: ''
1010
**Description of the issue**
1111

1212
<!-- Please explain briefly what is the problem.
13-
If it is about an LGTM project, please include its URL.-->
13+
If it is about a GitHub project, please include its URL. -->
1414

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
name: CodeQL false positive
3+
about: Report CodeQL alerts that you think should not have been detected (not applicable, not exploitable, etc.)
4+
title: False positive
5+
labels: false-positive
6+
assignees: ''
7+
8+
---
9+
10+
**Description of the false positive**
11+
12+
<!-- Please explain briefly why you think it shouldn't be included. -->
13+
14+
**Code samples or links to source code**
15+
16+
<!--
17+
For open source code: file links with line numbers on GitHub, for example:
18+
https://github.com/github/codeql/blob/dc440aaee6695deb0d9676b87e06ea984e1b4ae5/javascript/ql/test/query-tests/Security/CWE-078/CommandInjection/exec-sh2.js#L10
19+
20+
For closed source code: (redacted) code samples that illustrate the problem, for example:
21+
22+
```
23+
function execSh(command, options) {
24+
return cp.spawn(getShell(), ["-c", command], options) // <- command line injection
25+
};
26+
```
27+
-->
28+
29+
**URL to the alert on GitHub code scanning (optional)**
30+
31+
<!--
32+
1. Open the project on GitHub.com.
33+
2. Switch to the `Security` tab.
34+
3. Browse to the alert that you would like to report.
35+
4. Copy and paste the page URL here.
36+
-->
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
name: Cache query compilation
2+
description: Caches CodeQL compilation caches - should be run both on PRs and pushes to main.
3+
4+
inputs:
5+
key:
6+
description: 'The cache key to use - should be unique to the workflow'
7+
required: true
8+
9+
outputs:
10+
cache-dir:
11+
description: "The directory where the cache was stored"
12+
value: ${{ steps.output-compilation-dir.outputs.compdir }}
13+
14+
runs:
15+
using: composite
16+
steps:
17+
# calculate the merge-base with main, in a way that works both on PRs and pushes to main.
18+
- name: Calculate merge-base
19+
shell: bash
20+
if: ${{ github.event_name == 'pull_request' }}
21+
env:
22+
BASE_BRANCH: ${{ github.base_ref }}
23+
run: |
24+
MERGE_BASE=$(git cat-file commit $GITHUB_SHA | grep '^parent ' | head -1 | cut -f 2 -d " ")
25+
echo "merge_base=$MERGE_BASE" >> $GITHUB_ENV
26+
- name: Restore cache (PR)
27+
if: ${{ github.event_name == 'pull_request' }}
28+
uses: actions/cache/restore@v3
29+
with:
30+
path: |
31+
**/.cache
32+
~/.codeql/compile-cache
33+
key: codeql-compile-${{ inputs.key }}-pr-${{ github.sha }}
34+
restore-keys: |
35+
codeql-compile-${{ inputs.key }}-${{ github.base_ref }}-${{ env.merge_base }}
36+
codeql-compile-${{ inputs.key }}-${{ github.base_ref }}-
37+
codeql-compile-${{ inputs.key }}-main-
38+
- name: Fill cache (only branch push)
39+
if: ${{ github.event_name != 'pull_request' }}
40+
uses: actions/cache@v3
41+
with:
42+
path: |
43+
**/.cache
44+
~/.codeql/compile-cache
45+
key: codeql-compile-${{ inputs.key }}-${{ github.ref_name }}-${{ github.sha }} # just fill on main
46+
restore-keys: | # restore the latest cache if the exact cache is unavailable, to speed up compilation.
47+
codeql-compile-${{ inputs.key }}-${{ github.ref_name }}-
48+
codeql-compile-${{ inputs.key }}-main-
49+
- name: Output-compilationdir
50+
id: output-compilation-dir
51+
shell: bash
52+
run: |
53+
echo "compdir=${COMBINED_CACHE_DIR}" >> $GITHUB_OUTPUT
54+
env:
55+
COMBINED_CACHE_DIR: ${{ runner.temp }}/compilation-dir
56+
- name: Fill compilation cache directory
57+
id: fill-compilation-dir
58+
uses: actions/github-script@v6
59+
env:
60+
COMBINED_CACHE_DIR: ${{ runner.temp }}/compilation-dir
61+
with:
62+
script: |
63+
// # Move all the existing cache into another folder, so we only preserve the cache for the current queries.
64+
// mkdir -p ${COMBINED_CACHE_DIR}
65+
// rm -f **/.cache/{lock,size} # -f to avoid errors if the cache is empty.
66+
// # copy the contents of the .cache folders into the combined cache folder.
67+
// cp -r **/.cache/* ${COMBINED_CACHE_DIR}/ || : # ignore missing files
68+
// # clean up the .cache folders
69+
// rm -rf **/.cache/*
70+
71+
const fs = require("fs");
72+
const path = require("path");
73+
const os = require("os");
74+
75+
// the first argv is the cache folder to create.
76+
const COMBINED_CACHE_DIR = process.env.COMBINED_CACHE_DIR;
77+
78+
function* walkCaches(dir) {
79+
const files = fs.readdirSync(dir, { withFileTypes: true });
80+
for (const file of files) {
81+
if (file.isDirectory()) {
82+
const filePath = path.join(dir, file.name);
83+
yield* walkCaches(filePath);
84+
if (file.name === ".cache") {
85+
yield filePath;
86+
}
87+
}
88+
}
89+
}
90+
91+
async function copyDir(src, dest) {
92+
for await (const file of await fs.promises.readdir(src, { withFileTypes: true })) {
93+
const srcPath = path.join(src, file.name);
94+
const destPath = path.join(dest, file.name);
95+
if (file.isDirectory()) {
96+
if (!fs.existsSync(destPath)) {
97+
fs.mkdirSync(destPath);
98+
}
99+
await copyDir(srcPath, destPath);
100+
} else {
101+
await fs.promises.copyFile(srcPath, destPath);
102+
}
103+
}
104+
}
105+
106+
async function main() {
107+
const cacheDirs = [...walkCaches(".")];
108+
109+
for (const dir of cacheDirs) {
110+
console.log(`Found .cache dir at ${dir}`);
111+
}
112+
113+
const globalCacheDir = path.join(os.homedir(), ".codeql", "compile-cache");
114+
if (fs.existsSync(globalCacheDir)) {
115+
console.log("Found global home dir: " + globalCacheDir);
116+
cacheDirs.push(globalCacheDir);
117+
}
118+
119+
if (cacheDirs.length === 0) {
120+
console.log("No cache dirs found");
121+
return;
122+
}
123+
124+
// mkdir -p ${COMBINED_CACHE_DIR}
125+
fs.mkdirSync(COMBINED_CACHE_DIR, { recursive: true });
126+
127+
// rm -f **/.cache/{lock,size} # -f to avoid errors if the cache is empty.
128+
await Promise.all(
129+
cacheDirs.map((cacheDir) =>
130+
(async function () {
131+
await fs.promises.rm(path.join(cacheDir, "lock"), { force: true });
132+
await fs.promises.rm(path.join(cacheDir, "size"), { force: true });
133+
})()
134+
)
135+
);
136+
137+
// # copy the contents of the .cache folders into the combined cache folder.
138+
// cp -r **/.cache/* ${COMBINED_CACHE_DIR}/ || : # ignore missing files
139+
await Promise.all(
140+
cacheDirs.map((cacheDir) => copyDir(cacheDir, COMBINED_CACHE_DIR))
141+
);
142+
143+
// # clean up the .cache folders
144+
// rm -rf **/.cache/*
145+
await Promise.all(
146+
cacheDirs.map((cacheDir) => fs.promises.rm(cacheDir, { recursive: true }))
147+
);
148+
}
149+
main();

.github/actions/fetch-codeql/action.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,6 @@ runs:
1919
gh extension install github/gh-codeql
2020
gh codeql set-channel "$CHANNEL"
2121
gh codeql version
22+
printf "CODEQL_FETCHED_CODEQL_PATH=" >> "${GITHUB_ENV}"
23+
gh codeql version --format=json | jq -r .unpackedLocation >> "${GITHUB_ENV}"
2224
gh codeql version --format=json | jq -r .unpackedLocation >> "${GITHUB_PATH}"

.github/actions/os-version/action.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: OS Version
2+
description: Get OS version.
3+
4+
outputs:
5+
version:
6+
description: "OS version"
7+
value: ${{ steps.version.outputs.version }}
8+
9+
runs:
10+
using: composite
11+
steps:
12+
- if: runner.os == 'Linux'
13+
shell: bash
14+
run: |
15+
. /etc/os-release
16+
echo "VERSION=${NAME} ${VERSION}" >> $GITHUB_ENV
17+
- if: runner.os == 'Windows'
18+
shell: powershell
19+
run: |
20+
$objects = systeminfo.exe /FO CSV | ConvertFrom-Csv
21+
"VERSION=$($objects.'OS Name') $($objects.'OS Version')" >> $env:GITHUB_ENV
22+
- if: runner.os == 'macOS'
23+
shell: bash
24+
run: |
25+
echo "VERSION=$(sw_vers -productName) $(sw_vers -productVersion)" >> $GITHUB_ENV
26+
- name: Emit OS version
27+
id: version
28+
shell: bash
29+
run: |
30+
echo "$VERSION"
31+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
32+

.github/dependabot.yml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
11
version: 2
22
updates:
33
- package-ecosystem: "cargo"
4-
directory: "ruby/node-types"
5-
schedule:
6-
interval: "daily"
7-
- package-ecosystem: "cargo"
8-
directory: "ruby/generator"
9-
schedule:
10-
interval: "daily"
11-
- package-ecosystem: "cargo"
12-
directory: "ruby/extractor"
4+
directory: "ruby"
135
schedule:
146
interval: "daily"
7+
158
- package-ecosystem: "cargo"
16-
directory: "ruby/autobuilder"
9+
directory: "ql"
1710
schedule:
1811
interval: "daily"
1912

.github/workflows/atm-check-query-suite.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313

1414
jobs:
1515
atm-check-query-suite:
16-
runs-on: ubuntu-latest
16+
runs-on: ubuntu-latest-xl
1717

1818
steps:
1919
- uses: actions/checkout@v3
@@ -23,6 +23,12 @@ jobs:
2323
with:
2424
channel: release
2525

26+
- name: Cache compilation cache
27+
id: query-cache
28+
uses: ./.github/actions/cache-query-compilation
29+
with:
30+
key: atm-suite
31+
2632
- name: Install ATM model
2733
run: |
2834
set -exu
@@ -50,10 +56,13 @@ jobs:
5056
echo "SARIF_PATH=${SARIF_PATH}" >> "${GITHUB_ENV}"
5157
5258
codeql database analyze \
59+
--threads=0 \
60+
--ram 50000 \
5361
--format sarif-latest \
5462
--output "${SARIF_PATH}" \
5563
--sarif-group-rules-by-pack \
5664
-vv \
65+
--compilation-cache "${{ steps.query-cache.outputs.cache-dir }}" \
5766
-- \
5867
"${DB_PATH}" \
5968
"${QUERY_PACK}/${QUERY_SUITE}"

.github/workflows/check-change-note.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,9 @@ jobs:
2626
run: |
2727
gh api 'repos/${{github.repository}}/pulls/${{github.event.number}}/files' --paginate --jq 'any(.[].filename ; test("/change-notes/.*[.]md$"))' |
2828
grep true -c
29+
- name: Fail if the change note filename doesn't match the expected format. The file name must be of the form 'YYYY-MM-DD.md' or 'YYYY-MM-DD-{title}.md', where '{title}' is arbitrary text.
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
run: |
33+
gh api 'repos/${{github.repository}}/pulls/${{github.event.number}}/files' --paginate --jq '[.[].filename | select(test("/change-notes/.*[.]md$"))] | all(test("/change-notes/[0-9]{4}-[0-9]{2}-[0-9]{2}.*[.]md$"))' |
34+
grep true -c

.github/workflows/check-qldoc.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ jobs:
2626
shell: bash
2727
run: |
2828
EXIT_CODE=0
29-
# TODO: remove the swift exception from the regex when we fix generated QLdoc
3029
# TODO: remove the shared exception from the regex when coverage of qlpacks without dbschemes is supported
31-
changed_lib_packs="$(git diff --name-only --diff-filter=ACMRT HEAD^ HEAD | { grep -Po '^(?!(swift|shared))[a-z]*/ql/lib' || true; } | sort -u)"
30+
changed_lib_packs="$(git diff --name-only --diff-filter=ACMRT HEAD^ HEAD | { grep -Po '^(?!(shared))[a-z]*/ql/lib' || true; } | sort -u)"
3231
for pack_dir in ${changed_lib_packs}; do
3332
lang="${pack_dir%/ql/lib}"
3433
codeql generate library-doc-coverage --output="${RUNNER_TEMP}/${lang}-current.txt" --dir="${pack_dir}"

0 commit comments

Comments
 (0)