Skip to content

Commit 0e60fc5

Browse files
committed
Merge branch 'main' into alias-html
2 parents 51ddb55 + f8f926a commit 0e60fc5

File tree

473 files changed

+34272
-3274
lines changed

Some content is hidden

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

473 files changed

+34272
-3274
lines changed

.github/actions/cache-query-compilation/action.yml

Lines changed: 103 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ inputs:
99
outputs:
1010
cache-dir:
1111
description: "The directory where the cache was stored"
12-
value: ${{ steps.fill-compilation-dir.outputs.compdir }}
12+
value: ${{ steps.output-compilation-dir.outputs.compdir }}
1313

1414
runs:
1515
using: composite
@@ -27,7 +27,9 @@ runs:
2727
if: ${{ github.event_name == 'pull_request' }}
2828
uses: actions/cache/restore@v3
2929
with:
30-
path: '**/.cache'
30+
path: |
31+
**/.cache
32+
~/.codeql/compile-cache
3133
key: codeql-compile-${{ inputs.key }}-pr-${{ github.sha }}
3234
restore-keys: |
3335
codeql-compile-${{ inputs.key }}-${{ github.base_ref }}-${{ env.merge_base }}
@@ -37,18 +39,111 @@ runs:
3739
if: ${{ github.event_name != 'pull_request' }}
3840
uses: actions/cache@v3
3941
with:
40-
path: '**/.cache'
42+
path: |
43+
**/.cache
44+
~/.codeql/compile-cache
4145
key: codeql-compile-${{ inputs.key }}-${{ github.ref_name }}-${{ github.sha }} # just fill on main
4246
restore-keys: | # restore the latest cache if the exact cache is unavailable, to speed up compilation.
4347
codeql-compile-${{ inputs.key }}-${{ github.ref_name }}-
4448
codeql-compile-${{ inputs.key }}-main-
45-
- name: Fill compilation cache directory
46-
id: fill-compilation-dir
49+
- name: Output-compilationdir
50+
id: output-compilation-dir
4751
shell: bash
4852
run: |
49-
# Move all the existing cache into another folder, so we only preserve the cache for the current queries.
50-
node $GITHUB_WORKSPACE/.github/actions/cache-query-compilation/move-caches.js ${COMBINED_CACHE_DIR}
51-
5253
echo "compdir=${COMBINED_CACHE_DIR}" >> $GITHUB_OUTPUT
5354
env:
5455
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/cache-query-compilation/move-caches.js

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

.github/workflows/compile-queries.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ jobs:
2424
with:
2525
key: all-queries
2626
- name: check formatting
27-
run: find */ql -type f \( -name "*.qll" -o -name "*.ql" \) -print0 | xargs -0 codeql query format --check-only
27+
run: find */ql -type f \( -name "*.qll" -o -name "*.ql" \) -print0 | xargs -0 -n 3000 -P 10 codeql query format -q --check-only
2828
- name: compile queries - check-only
2929
# run with --check-only if running in a PR (github.sha != main)
3030
if : ${{ github.event_name == 'pull_request' }}
3131
shell: bash
32-
run: codeql query compile -j0 */ql/{src,examples} --keep-going --warnings=error --check-only --compilation-cache "${{ steps.query-cache.outputs.cache-dir }}"
32+
run: codeql query compile -q -j0 */ql/{src,examples} --keep-going --warnings=error --check-only --compilation-cache "${{ steps.query-cache.outputs.cache-dir }}"
3333
- name: compile queries - full
3434
# do full compile if running on main - this populates the cache
3535
if : ${{ github.event_name != 'pull_request' }}
3636
shell: bash
37-
run: codeql query compile -j0 */ql/{src,examples} --keep-going --warnings=error --compilation-cache "${{ steps.query-cache.outputs.cache-dir }}"
37+
run: codeql query compile -q -j0 */ql/{src,examples} --keep-going --warnings=error --compilation-cache "${{ steps.query-cache.outputs.cache-dir }}"

.github/workflows/ql-for-ql-build.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@ on:
55
branches: [main]
66
pull_request:
77
branches: [main]
8-
paths:
9-
- "ql/**"
10-
- "**.qll"
11-
- "**.ql"
12-
- "**.dbscheme"
13-
- "**/qlpack.yml"
14-
- ".github/workflows/ql-for-ql-build.yml"
158

169
env:
1710
CARGO_TERM_COLOR: always
@@ -22,6 +15,8 @@ jobs:
2215
steps:
2316
### Build the queries ###
2417
- uses: actions/checkout@v3
18+
with:
19+
fetch-depth: 0
2520
- name: Find codeql
2621
id: find-codeql
2722
uses: github/codeql-action/init@v2
@@ -34,7 +29,9 @@ jobs:
3429
id: cache-extractor
3530
uses: actions/cache@v3
3631
with:
37-
path: ql/extractor-pack/
32+
path: |
33+
ql/extractor-pack/
34+
ql/target/release/buramu
3835
key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-extractor-${{ hashFiles('ql/**/Cargo.lock') }}-${{ hashFiles('ql/**/*.rs') }}
3936
- name: Cache cargo
4037
if: steps.cache-extractor.outputs.cache-hit != 'true'
@@ -57,6 +54,7 @@ jobs:
5754
key: run-ql-for-ql
5855
- name: Make database and analyze
5956
run: |
57+
./ql/target/release/buramu | tee deprecated.blame # Add a blame file for the extractor to parse.
6058
${CODEQL} database create -l=ql --search-path ql/extractor-pack ${DB}
6159
${CODEQL} database analyze -j0 --format=sarif-latest --output=ql-for-ql.sarif ${DB} ql/ql/src/codeql-suites/ql-code-scanning.qls --compilation-cache "${{ steps.query-cache.outputs.cache-dir }}"
6260
env:
@@ -65,6 +63,7 @@ jobs:
6563
LGTM_INDEX_FILTERS: |
6664
exclude:ql/ql/test
6765
exclude:*/ql/lib/upgrades/
66+
exclude:java/ql/integration-tests
6867
- name: Upload sarif to code-scanning
6968
uses: github/codeql-action/upload-sarif@v2
7069
with:

CODEOWNERS

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
/csharp/ @github/codeql-csharp
33
/go/ @github/codeql-go
44
/java/ @github/codeql-java
5-
/javascript/ @github/codeql-javascript
6-
/python/ @github/codeql-python
7-
/ruby/ @github/codeql-ruby
5+
/javascript/ @github/codeql-dynamic
6+
/python/ @github/codeql-dynamic
7+
/ruby/ @github/codeql-dynamic
88
/swift/ @github/codeql-swift
99
/java/kotlin-extractor/ @github/codeql-kotlin
1010
/java/kotlin-explorer/ @github/codeql-kotlin

cpp/autobuilder/Semmle.Autobuild.Cpp.Tests/BuildScripts.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,14 @@ IEnumerable<string> IBuildActions.EnumerateDirectories(string dir)
131131

132132
bool IBuildActions.IsWindows() => IsWindows;
133133

134+
public bool IsMacOs { get; set; }
135+
136+
bool IBuildActions.IsMacOs() => IsMacOs;
137+
138+
public bool IsArm { get; set; }
139+
140+
bool IBuildActions.IsArm() => IsArm;
141+
134142
string IBuildActions.PathCombine(params string[] parts)
135143
{
136144
return string.Join(IsWindows ? '\\' : '/', parts.Where(p => !string.IsNullOrWhiteSpace(p)));

cpp/ql/lib/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.5.3
2+
3+
No user-facing changes.
4+
15
## 0.5.2
26

37
No user-facing changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 0.5.3
2+
3+
No user-facing changes.

cpp/ql/lib/codeql-pack.release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
lastReleaseVersion: 0.5.2
2+
lastReleaseVersion: 0.5.3

cpp/ql/lib/qlpack.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: codeql/cpp-all
2-
version: 0.5.3-dev
2+
version: 0.5.4-dev
33
groups: cpp
44
dbscheme: semmlecode.cpp.dbscheme
55
extractor: cpp

0 commit comments

Comments
 (0)