mirror of
https://github.com/github/codeql-action.git
synced 2025-12-17 21:09:40 +08:00
Compare commits
74 Commits
v4.31.7
...
copilot/up
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
056581e05b | ||
|
|
9c5588d006 | ||
|
|
3765106c90 | ||
|
|
e052dbd57d | ||
|
|
32795b3c52 | ||
|
|
b88acb2f6c | ||
|
|
241948c698 | ||
|
|
1fe89fe9cb | ||
|
|
6dba00881c | ||
|
|
d4d47c0d3d | ||
|
|
6c6e810910 | ||
|
|
5d4e8d1aca | ||
|
|
1dc115f17a | ||
|
|
998798e34d | ||
|
|
393c074965 | ||
|
|
c3dc529aef | ||
|
|
fc2bbb041e | ||
|
|
89753aa84b | ||
|
|
5eb751966f | ||
|
|
d29eddb39b | ||
|
|
aff7998c4a | ||
|
|
e9626872ef | ||
|
|
19c7f96922 | ||
|
|
ae5de9a20d | ||
|
|
0cb86337c5 | ||
|
|
c07cc0d3a9 | ||
|
|
7a5748cf0d | ||
|
|
db75d46248 | ||
|
|
a0fc644617 | ||
|
|
a2ee53c0d3 | ||
|
|
b5e1a28b8a | ||
|
|
c2d4383e64 | ||
|
|
d0ad1da72a | ||
|
|
07cd437640 | ||
|
|
a682bbe410 | ||
|
|
7fd7db3f26 | ||
|
|
d6c1a791b7 | ||
|
|
034374eb3f | ||
|
|
6dbc22c93f | ||
|
|
a539068a61 | ||
|
|
e1058e4d74 | ||
|
|
d4f39b0766 | ||
|
|
b30cb9ae2a | ||
|
|
009fe6b0c1 | ||
|
|
b1dea65f65 | ||
|
|
7e0b77e3a8 | ||
|
|
0264b51610 | ||
|
|
2ac846d41e | ||
|
|
5d063dd3af | ||
|
|
8e921c3145 | ||
|
|
4b675e451b | ||
|
|
65bad627f3 | ||
|
|
4564f5e482 | ||
|
|
1b168cd394 | ||
|
|
120f277b16 | ||
|
|
1b0b941e1f | ||
|
|
db812c1ae6 | ||
|
|
2930dba17a | ||
|
|
805b7e1790 | ||
|
|
da501245d4 | ||
|
|
1fc7d3785d | ||
|
|
7a55ffeaf1 | ||
|
|
c43362b91a | ||
|
|
002a7f25fd | ||
|
|
5b7e7fcc9c | ||
|
|
cd48547da5 | ||
|
|
44570be32d | ||
|
|
b73d396b48 | ||
|
|
0ffebf72b2 | ||
|
|
149d184a51 | ||
|
|
97c2630b10 | ||
|
|
b93926dc35 | ||
|
|
c4efbda299 | ||
|
|
dd8914320f |
2
.github/pull_request_template.md
vendored
2
.github/pull_request_template.md
vendored
@@ -34,7 +34,7 @@ Products:
|
|||||||
|
|
||||||
Environments:
|
Environments:
|
||||||
|
|
||||||
- **Dotcom** - Impacts CodeQL workflows on `github.com`.
|
- **Dotcom** - Impacts CodeQL workflows on `github.com` and/or GitHub Enterprise Cloud with Data Residency.
|
||||||
- **GHES** - Impacts CodeQL workflows on GitHub Enterprise Server.
|
- **GHES** - Impacts CodeQL workflows on GitHub Enterprise Server.
|
||||||
- **Testing/None** - This change does not impact any CodeQL workflows in production.
|
- **Testing/None** - This change does not impact any CodeQL workflows in production.
|
||||||
|
|
||||||
|
|||||||
2
.github/workflows/__bundle-zstd.yml
generated
vendored
2
.github/workflows/__bundle-zstd.yml
generated
vendored
@@ -79,7 +79,7 @@ jobs:
|
|||||||
output: ${{ runner.temp }}/results
|
output: ${{ runner.temp }}/results
|
||||||
upload-database: false
|
upload-database: false
|
||||||
- name: Upload SARIF
|
- name: Upload SARIF
|
||||||
uses: actions/upload-artifact@v5
|
uses: actions/upload-artifact@v6
|
||||||
with:
|
with:
|
||||||
name: ${{ matrix.os }}-zstd-bundle.sarif
|
name: ${{ matrix.os }}-zstd-bundle.sarif
|
||||||
path: ${{ runner.temp }}/results/javascript.sarif
|
path: ${{ runner.temp }}/results/javascript.sarif
|
||||||
|
|||||||
2
.github/workflows/__config-export.yml
generated
vendored
2
.github/workflows/__config-export.yml
generated
vendored
@@ -67,7 +67,7 @@ jobs:
|
|||||||
output: ${{ runner.temp }}/results
|
output: ${{ runner.temp }}/results
|
||||||
upload-database: false
|
upload-database: false
|
||||||
- name: Upload SARIF
|
- name: Upload SARIF
|
||||||
uses: actions/upload-artifact@v5
|
uses: actions/upload-artifact@v6
|
||||||
with:
|
with:
|
||||||
name: config-export-${{ matrix.os }}-${{ matrix.version }}.sarif.json
|
name: config-export-${{ matrix.os }}-${{ matrix.version }}.sarif.json
|
||||||
path: ${{ runner.temp }}/results/javascript.sarif
|
path: ${{ runner.temp }}/results/javascript.sarif
|
||||||
|
|||||||
2
.github/workflows/__diagnostics-export.yml
generated
vendored
2
.github/workflows/__diagnostics-export.yml
generated
vendored
@@ -78,7 +78,7 @@ jobs:
|
|||||||
output: ${{ runner.temp }}/results
|
output: ${{ runner.temp }}/results
|
||||||
upload-database: false
|
upload-database: false
|
||||||
- name: Upload SARIF
|
- name: Upload SARIF
|
||||||
uses: actions/upload-artifact@v5
|
uses: actions/upload-artifact@v6
|
||||||
with:
|
with:
|
||||||
name: diagnostics-export-${{ matrix.os }}-${{ matrix.version }}.sarif.json
|
name: diagnostics-export-${{ matrix.os }}-${{ matrix.version }}.sarif.json
|
||||||
path: ${{ runner.temp }}/results/javascript.sarif
|
path: ${{ runner.temp }}/results/javascript.sarif
|
||||||
|
|||||||
2
.github/workflows/__export-file-baseline-information.yml
generated
vendored
2
.github/workflows/__export-file-baseline-information.yml
generated
vendored
@@ -99,7 +99,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
output: ${{ runner.temp }}/results
|
output: ${{ runner.temp }}/results
|
||||||
- name: Upload SARIF
|
- name: Upload SARIF
|
||||||
uses: actions/upload-artifact@v5
|
uses: actions/upload-artifact@v6
|
||||||
with:
|
with:
|
||||||
name: with-baseline-information-${{ matrix.os }}-${{ matrix.version }}.sarif.json
|
name: with-baseline-information-${{ matrix.os }}-${{ matrix.version }}.sarif.json
|
||||||
path: ${{ runner.temp }}/results/javascript.sarif
|
path: ${{ runner.temp }}/results/javascript.sarif
|
||||||
|
|||||||
2
.github/workflows/__job-run-uuid-sarif.yml
generated
vendored
2
.github/workflows/__job-run-uuid-sarif.yml
generated
vendored
@@ -64,7 +64,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
output: ${{ runner.temp }}/results
|
output: ${{ runner.temp }}/results
|
||||||
- name: Upload SARIF
|
- name: Upload SARIF
|
||||||
uses: actions/upload-artifact@v5
|
uses: actions/upload-artifact@v6
|
||||||
with:
|
with:
|
||||||
name: ${{ matrix.os }}-${{ matrix.version }}.sarif.json
|
name: ${{ matrix.os }}-${{ matrix.version }}.sarif.json
|
||||||
path: ${{ runner.temp }}/results/javascript.sarif
|
path: ${{ runner.temp }}/results/javascript.sarif
|
||||||
|
|||||||
6
.github/workflows/__quality-queries.yml
generated
vendored
6
.github/workflows/__quality-queries.yml
generated
vendored
@@ -83,7 +83,7 @@ jobs:
|
|||||||
post-processed-sarif-path: ${{ runner.temp }}/post-processed
|
post-processed-sarif-path: ${{ runner.temp }}/post-processed
|
||||||
- name: Upload security SARIF
|
- name: Upload security SARIF
|
||||||
if: contains(matrix.analysis-kinds, 'code-scanning')
|
if: contains(matrix.analysis-kinds, 'code-scanning')
|
||||||
uses: actions/upload-artifact@v5
|
uses: actions/upload-artifact@v6
|
||||||
with:
|
with:
|
||||||
name: |
|
name: |
|
||||||
quality-queries-${{ matrix.os }}-${{ matrix.version }}-${{ matrix.analysis-kinds }}.sarif.json
|
quality-queries-${{ matrix.os }}-${{ matrix.version }}-${{ matrix.analysis-kinds }}.sarif.json
|
||||||
@@ -91,14 +91,14 @@ jobs:
|
|||||||
retention-days: 7
|
retention-days: 7
|
||||||
- name: Upload quality SARIF
|
- name: Upload quality SARIF
|
||||||
if: contains(matrix.analysis-kinds, 'code-quality')
|
if: contains(matrix.analysis-kinds, 'code-quality')
|
||||||
uses: actions/upload-artifact@v5
|
uses: actions/upload-artifact@v6
|
||||||
with:
|
with:
|
||||||
name: |
|
name: |
|
||||||
quality-queries-${{ matrix.os }}-${{ matrix.version }}-${{ matrix.analysis-kinds }}.quality.sarif.json
|
quality-queries-${{ matrix.os }}-${{ matrix.version }}-${{ matrix.analysis-kinds }}.quality.sarif.json
|
||||||
path: ${{ runner.temp }}/results/javascript.quality.sarif
|
path: ${{ runner.temp }}/results/javascript.quality.sarif
|
||||||
retention-days: 7
|
retention-days: 7
|
||||||
- name: Upload post-processed SARIF
|
- name: Upload post-processed SARIF
|
||||||
uses: actions/upload-artifact@v5
|
uses: actions/upload-artifact@v6
|
||||||
with:
|
with:
|
||||||
name: |
|
name: |
|
||||||
post-processed-${{ matrix.os }}-${{ matrix.version }}-${{ matrix.analysis-kinds }}.sarif.json
|
post-processed-${{ matrix.os }}-${{ matrix.version }}-${{ matrix.analysis-kinds }}.sarif.json
|
||||||
|
|||||||
2
.github/workflows/__rubocop-multi-language.yml
generated
vendored
2
.github/workflows/__rubocop-multi-language.yml
generated
vendored
@@ -56,7 +56,7 @@ jobs:
|
|||||||
use-all-platform-bundle: 'false'
|
use-all-platform-bundle: 'false'
|
||||||
setup-kotlin: 'true'
|
setup-kotlin: 'true'
|
||||||
- name: Set up Ruby
|
- name: Set up Ruby
|
||||||
uses: ruby/setup-ruby@8aeb6ff8030dd539317f8e1769a044873b56ea71 # v1.268.0
|
uses: ruby/setup-ruby@ac793fdd38cc468a4dd57246fa9d0e868aba9085 # v1.270.0
|
||||||
with:
|
with:
|
||||||
ruby-version: 2.6
|
ruby-version: 2.6
|
||||||
- name: Install Code Scanning integration
|
- name: Install Code Scanning integration
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Download all artifacts
|
- name: Download all artifacts
|
||||||
uses: actions/download-artifact@v6
|
uses: actions/download-artifact@v7
|
||||||
- name: Check expected artifacts exist
|
- name: Check expected artifacts exist
|
||||||
run: |
|
run: |
|
||||||
LANGUAGES="cpp csharp go java javascript python"
|
LANGUAGES="cpp csharp go java javascript python"
|
||||||
|
|||||||
2
.github/workflows/debug-artifacts-safe.yml
vendored
2
.github/workflows/debug-artifacts-safe.yml
vendored
@@ -77,7 +77,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Download all artifacts
|
- name: Download all artifacts
|
||||||
uses: actions/download-artifact@v6
|
uses: actions/download-artifact@v7
|
||||||
- name: Check expected artifacts exist
|
- name: Check expected artifacts exist
|
||||||
run: |
|
run: |
|
||||||
VERSIONS="stable-v2.20.3 default linked nightly-latest"
|
VERSIONS="stable-v2.20.3 default linked nightly-latest"
|
||||||
|
|||||||
2
.github/workflows/post-release-mergeback.yml
vendored
2
.github/workflows/post-release-mergeback.yml
vendored
@@ -142,7 +142,7 @@ jobs:
|
|||||||
token: "${{ secrets.GITHUB_TOKEN }}"
|
token: "${{ secrets.GITHUB_TOKEN }}"
|
||||||
|
|
||||||
- name: Generate token
|
- name: Generate token
|
||||||
uses: actions/create-github-app-token@v2.2.0
|
uses: actions/create-github-app-token@v2.2.1
|
||||||
id: app-token
|
id: app-token
|
||||||
with:
|
with:
|
||||||
app-id: ${{ vars.AUTOMATION_APP_ID }}
|
app-id: ${{ vars.AUTOMATION_APP_ID }}
|
||||||
|
|||||||
2
.github/workflows/rollback-release.yml
vendored
2
.github/workflows/rollback-release.yml
vendored
@@ -137,7 +137,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Generate token
|
- name: Generate token
|
||||||
if: github.event_name == 'workflow_dispatch'
|
if: github.event_name == 'workflow_dispatch'
|
||||||
uses: actions/create-github-app-token@v2.2.0
|
uses: actions/create-github-app-token@v2.2.1
|
||||||
id: app-token
|
id: app-token
|
||||||
with:
|
with:
|
||||||
app-id: ${{ vars.AUTOMATION_APP_ID }}
|
app-id: ${{ vars.AUTOMATION_APP_ID }}
|
||||||
|
|||||||
2
.github/workflows/update-release-branch.yml
vendored
2
.github/workflows/update-release-branch.yml
vendored
@@ -93,7 +93,7 @@ jobs:
|
|||||||
pull-requests: write # needed to create pull request
|
pull-requests: write # needed to create pull request
|
||||||
steps:
|
steps:
|
||||||
- name: Generate token
|
- name: Generate token
|
||||||
uses: actions/create-github-app-token@v2.2.0
|
uses: actions/create-github-app-token@v2.2.1
|
||||||
id: app-token
|
id: app-token
|
||||||
with:
|
with:
|
||||||
app-id: ${{ vars.AUTOMATION_APP_ID }}
|
app-id: ${{ vars.AUTOMATION_APP_ID }}
|
||||||
|
|||||||
12
CHANGELOG.md
12
CHANGELOG.md
@@ -2,6 +2,18 @@
|
|||||||
|
|
||||||
See the [releases page](https://github.com/github/codeql-action/releases) for the relevant changes to the CodeQL CLI and language packs.
|
See the [releases page](https://github.com/github/codeql-action/releases) for the relevant changes to the CodeQL CLI and language packs.
|
||||||
|
|
||||||
|
## [UNRELEASED]
|
||||||
|
|
||||||
|
No user facing changes.
|
||||||
|
|
||||||
|
## 4.31.9 - 16 Dec 2025
|
||||||
|
|
||||||
|
No user facing changes.
|
||||||
|
|
||||||
|
## 4.31.8 - 11 Dec 2025
|
||||||
|
|
||||||
|
- Update default CodeQL bundle version to 2.23.8. [#3354](https://github.com/github/codeql-action/pull/3354)
|
||||||
|
|
||||||
## 4.31.7 - 05 Dec 2025
|
## 4.31.7 - 05 Dec 2025
|
||||||
|
|
||||||
- Update default CodeQL bundle version to 2.23.7. [#3343](https://github.com/github/codeql-action/pull/3343)
|
- Update default CodeQL bundle version to 2.23.7. [#3343](https://github.com/github/codeql-action/pull/3343)
|
||||||
|
|||||||
42552
lib/analyze-action-post.js
generated
42552
lib/analyze-action-post.js
generated
File diff suppressed because it is too large
Load Diff
37473
lib/analyze-action.js
generated
37473
lib/analyze-action.js
generated
File diff suppressed because it is too large
Load Diff
35975
lib/autobuild-action.js
generated
35975
lib/autobuild-action.js
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"bundleVersion": "codeql-bundle-v2.23.7",
|
"bundleVersion": "codeql-bundle-v2.23.8",
|
||||||
"cliVersion": "2.23.7",
|
"cliVersion": "2.23.8",
|
||||||
"priorBundleVersion": "codeql-bundle-v2.23.6",
|
"priorBundleVersion": "codeql-bundle-v2.23.7",
|
||||||
"priorCliVersion": "2.23.6"
|
"priorCliVersion": "2.23.7"
|
||||||
}
|
}
|
||||||
|
|||||||
42635
lib/init-action-post.js
generated
42635
lib/init-action-post.js
generated
File diff suppressed because it is too large
Load Diff
37407
lib/init-action.js
generated
37407
lib/init-action.js
generated
File diff suppressed because it is too large
Load Diff
35960
lib/resolve-environment-action.js
generated
35960
lib/resolve-environment-action.js
generated
File diff suppressed because it is too large
Load Diff
35969
lib/setup-codeql-action.js
generated
35969
lib/setup-codeql-action.js
generated
File diff suppressed because it is too large
Load Diff
42519
lib/start-proxy-action-post.js
generated
42519
lib/start-proxy-action-post.js
generated
File diff suppressed because it is too large
Load Diff
36315
lib/start-proxy-action.js
generated
36315
lib/start-proxy-action.js
generated
File diff suppressed because it is too large
Load Diff
36006
lib/upload-lib.js
generated
36006
lib/upload-lib.js
generated
File diff suppressed because it is too large
Load Diff
42443
lib/upload-sarif-action-post.js
generated
42443
lib/upload-sarif-action-post.js
generated
File diff suppressed because it is too large
Load Diff
35989
lib/upload-sarif-action.js
generated
35989
lib/upload-sarif-action.js
generated
File diff suppressed because it is too large
Load Diff
1216
package-lock.json
generated
1216
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
22
package.json
22
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "codeql",
|
"name": "codeql",
|
||||||
"version": "4.31.7",
|
"version": "4.31.10",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "CodeQL action",
|
"description": "CodeQL action",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -24,12 +24,12 @@
|
|||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/artifact": "^4.0.0",
|
"@actions/artifact": "^5.0.1",
|
||||||
"@actions/artifact-legacy": "npm:@actions/artifact@^1.1.2",
|
"@actions/artifact-legacy": "npm:@actions/artifact@^1.1.2",
|
||||||
"@actions/cache": "^4.1.0",
|
"@actions/cache": "^5.0.1",
|
||||||
"@actions/core": "^1.11.1",
|
"@actions/core": "^2.0.1",
|
||||||
"@actions/exec": "^1.1.1",
|
"@actions/exec": "^2.0.0",
|
||||||
"@actions/github": "^6.0.0",
|
"@actions/github": "^6.0.1",
|
||||||
"@actions/glob": "^0.5.0",
|
"@actions/glob": "^0.5.0",
|
||||||
"@actions/http-client": "^3.0.0",
|
"@actions/http-client": "^3.0.0",
|
||||||
"@actions/io": "^2.0.0",
|
"@actions/io": "^2.0.0",
|
||||||
@@ -43,7 +43,7 @@
|
|||||||
"js-yaml": "^4.1.1",
|
"js-yaml": "^4.1.1",
|
||||||
"jsonschema": "1.4.1",
|
"jsonschema": "1.4.1",
|
||||||
"long": "^5.3.2",
|
"long": "^5.3.2",
|
||||||
"node-forge": "^1.3.2",
|
"node-forge": "^1.3.3",
|
||||||
"semver": "^7.7.3",
|
"semver": "^7.7.3",
|
||||||
"uuid": "^13.0.0"
|
"uuid": "^13.0.0"
|
||||||
},
|
},
|
||||||
@@ -51,7 +51,7 @@
|
|||||||
"@ava/typescript": "6.0.0",
|
"@ava/typescript": "6.0.0",
|
||||||
"@eslint/compat": "^2.0.0",
|
"@eslint/compat": "^2.0.0",
|
||||||
"@eslint/eslintrc": "^3.3.3",
|
"@eslint/eslintrc": "^3.3.3",
|
||||||
"@eslint/js": "^9.39.1",
|
"@eslint/js": "^9.39.2",
|
||||||
"@microsoft/eslint-formatter-sarif": "^3.1.0",
|
"@microsoft/eslint-formatter-sarif": "^3.1.0",
|
||||||
"@octokit/types": "^16.0.0",
|
"@octokit/types": "^16.0.0",
|
||||||
"@types/archiver": "^7.0.0",
|
"@types/archiver": "^7.0.0",
|
||||||
@@ -61,16 +61,16 @@
|
|||||||
"@types/node-forge": "^1.3.14",
|
"@types/node-forge": "^1.3.14",
|
||||||
"@types/semver": "^7.7.1",
|
"@types/semver": "^7.7.1",
|
||||||
"@types/sinon": "^21.0.0",
|
"@types/sinon": "^21.0.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.48.0",
|
"@typescript-eslint/eslint-plugin": "^8.49.0",
|
||||||
"@typescript-eslint/parser": "^8.48.0",
|
"@typescript-eslint/parser": "^8.48.0",
|
||||||
"ava": "^6.4.1",
|
"ava": "^6.4.1",
|
||||||
"esbuild": "^0.27.0",
|
"esbuild": "^0.27.1",
|
||||||
"eslint": "^8.57.1",
|
"eslint": "^8.57.1",
|
||||||
"eslint-import-resolver-typescript": "^3.8.7",
|
"eslint-import-resolver-typescript": "^3.8.7",
|
||||||
"eslint-plugin-filenames": "^1.3.2",
|
"eslint-plugin-filenames": "^1.3.2",
|
||||||
"eslint-plugin-github": "^5.1.8",
|
"eslint-plugin-github": "^5.1.8",
|
||||||
"eslint-plugin-import": "2.29.1",
|
"eslint-plugin-import": "2.29.1",
|
||||||
"eslint-plugin-jsdoc": "^61.4.1",
|
"eslint-plugin-jsdoc": "^61.5.0",
|
||||||
"eslint-plugin-no-async-foreach": "^0.1.1",
|
"eslint-plugin-no-async-foreach": "^0.1.1",
|
||||||
"glob": "^11.1.0",
|
"glob": "^11.1.0",
|
||||||
"nock": "^14.0.10",
|
"nock": "^14.0.10",
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ steps:
|
|||||||
output: ${{ runner.temp }}/results
|
output: ${{ runner.temp }}/results
|
||||||
upload-database: false
|
upload-database: false
|
||||||
- name: Upload SARIF
|
- name: Upload SARIF
|
||||||
uses: actions/upload-artifact@v5
|
uses: actions/upload-artifact@v6
|
||||||
with:
|
with:
|
||||||
name: ${{ matrix.os }}-zstd-bundle.sarif
|
name: ${{ matrix.os }}-zstd-bundle.sarif
|
||||||
path: ${{ runner.temp }}/results/javascript.sarif
|
path: ${{ runner.temp }}/results/javascript.sarif
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ steps:
|
|||||||
output: "${{ runner.temp }}/results"
|
output: "${{ runner.temp }}/results"
|
||||||
upload-database: false
|
upload-database: false
|
||||||
- name: Upload SARIF
|
- name: Upload SARIF
|
||||||
uses: actions/upload-artifact@v5
|
uses: actions/upload-artifact@v6
|
||||||
with:
|
with:
|
||||||
name: config-export-${{ matrix.os }}-${{ matrix.version }}.sarif.json
|
name: config-export-${{ matrix.os }}-${{ matrix.version }}.sarif.json
|
||||||
path: "${{ runner.temp }}/results/javascript.sarif"
|
path: "${{ runner.temp }}/results/javascript.sarif"
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ steps:
|
|||||||
output: "${{ runner.temp }}/results"
|
output: "${{ runner.temp }}/results"
|
||||||
upload-database: false
|
upload-database: false
|
||||||
- name: Upload SARIF
|
- name: Upload SARIF
|
||||||
uses: actions/upload-artifact@v5
|
uses: actions/upload-artifact@v6
|
||||||
with:
|
with:
|
||||||
name: diagnostics-export-${{ matrix.os }}-${{ matrix.version }}.sarif.json
|
name: diagnostics-export-${{ matrix.os }}-${{ matrix.version }}.sarif.json
|
||||||
path: "${{ runner.temp }}/results/javascript.sarif"
|
path: "${{ runner.temp }}/results/javascript.sarif"
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ steps:
|
|||||||
with:
|
with:
|
||||||
output: "${{ runner.temp }}/results"
|
output: "${{ runner.temp }}/results"
|
||||||
- name: Upload SARIF
|
- name: Upload SARIF
|
||||||
uses: actions/upload-artifact@v5
|
uses: actions/upload-artifact@v6
|
||||||
with:
|
with:
|
||||||
name: with-baseline-information-${{ matrix.os }}-${{ matrix.version }}.sarif.json
|
name: with-baseline-information-${{ matrix.os }}-${{ matrix.version }}.sarif.json
|
||||||
path: "${{ runner.temp }}/results/javascript.sarif"
|
path: "${{ runner.temp }}/results/javascript.sarif"
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ steps:
|
|||||||
with:
|
with:
|
||||||
output: "${{ runner.temp }}/results"
|
output: "${{ runner.temp }}/results"
|
||||||
- name: Upload SARIF
|
- name: Upload SARIF
|
||||||
uses: actions/upload-artifact@v5
|
uses: actions/upload-artifact@v6
|
||||||
with:
|
with:
|
||||||
name: ${{ matrix.os }}-${{ matrix.version }}.sarif.json
|
name: ${{ matrix.os }}-${{ matrix.version }}.sarif.json
|
||||||
path: "${{ runner.temp }}/results/javascript.sarif"
|
path: "${{ runner.temp }}/results/javascript.sarif"
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ steps:
|
|||||||
post-processed-sarif-path: "${{ runner.temp }}/post-processed"
|
post-processed-sarif-path: "${{ runner.temp }}/post-processed"
|
||||||
- name: Upload security SARIF
|
- name: Upload security SARIF
|
||||||
if: contains(matrix.analysis-kinds, 'code-scanning')
|
if: contains(matrix.analysis-kinds, 'code-scanning')
|
||||||
uses: actions/upload-artifact@v5
|
uses: actions/upload-artifact@v6
|
||||||
with:
|
with:
|
||||||
name: |
|
name: |
|
||||||
quality-queries-${{ matrix.os }}-${{ matrix.version }}-${{ matrix.analysis-kinds }}.sarif.json
|
quality-queries-${{ matrix.os }}-${{ matrix.version }}-${{ matrix.analysis-kinds }}.sarif.json
|
||||||
@@ -47,14 +47,14 @@ steps:
|
|||||||
retention-days: 7
|
retention-days: 7
|
||||||
- name: Upload quality SARIF
|
- name: Upload quality SARIF
|
||||||
if: contains(matrix.analysis-kinds, 'code-quality')
|
if: contains(matrix.analysis-kinds, 'code-quality')
|
||||||
uses: actions/upload-artifact@v5
|
uses: actions/upload-artifact@v6
|
||||||
with:
|
with:
|
||||||
name: |
|
name: |
|
||||||
quality-queries-${{ matrix.os }}-${{ matrix.version }}-${{ matrix.analysis-kinds }}.quality.sarif.json
|
quality-queries-${{ matrix.os }}-${{ matrix.version }}-${{ matrix.analysis-kinds }}.quality.sarif.json
|
||||||
path: "${{ runner.temp }}/results/javascript.quality.sarif"
|
path: "${{ runner.temp }}/results/javascript.quality.sarif"
|
||||||
retention-days: 7
|
retention-days: 7
|
||||||
- name: Upload post-processed SARIF
|
- name: Upload post-processed SARIF
|
||||||
uses: actions/upload-artifact@v5
|
uses: actions/upload-artifact@v6
|
||||||
with:
|
with:
|
||||||
name: |
|
name: |
|
||||||
post-processed-${{ matrix.os }}-${{ matrix.version }}-${{ matrix.analysis-kinds }}.sarif.json
|
post-processed-${{ matrix.os }}-${{ matrix.version }}-${{ matrix.analysis-kinds }}.sarif.json
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ description: "Tests using RuboCop to analyze a multi-language repository and the
|
|||||||
versions: ["default"]
|
versions: ["default"]
|
||||||
steps:
|
steps:
|
||||||
- name: Set up Ruby
|
- name: Set up Ruby
|
||||||
uses: ruby/setup-ruby@8aeb6ff8030dd539317f8e1769a044873b56ea71 # v1.268.0
|
uses: ruby/setup-ruby@ac793fdd38cc468a4dd57246fa9d0e868aba9085 # v1.270.0
|
||||||
with:
|
with:
|
||||||
ruby-version: 2.6
|
ruby-version: 2.6
|
||||||
- name: Install Code Scanning integration
|
- name: Install Code Scanning integration
|
||||||
|
|||||||
@@ -19,20 +19,18 @@ import { getApiDetails, getGitHubVersion } from "./api-client";
|
|||||||
import { runAutobuild } from "./autobuild";
|
import { runAutobuild } from "./autobuild";
|
||||||
import { getTotalCacheSize, shouldStoreCache } from "./caching-utils";
|
import { getTotalCacheSize, shouldStoreCache } from "./caching-utils";
|
||||||
import { getCodeQL } from "./codeql";
|
import { getCodeQL } from "./codeql";
|
||||||
|
import { Config, getConfig } from "./config-utils";
|
||||||
import {
|
import {
|
||||||
Config,
|
cleanupAndUploadDatabases,
|
||||||
getConfig,
|
DatabaseUploadResult,
|
||||||
isCodeQualityEnabled,
|
} from "./database-upload";
|
||||||
isCodeScanningEnabled,
|
|
||||||
} from "./config-utils";
|
|
||||||
import { cleanupAndUploadDatabases } from "./database-upload";
|
|
||||||
import {
|
import {
|
||||||
DependencyCacheUploadStatusReport,
|
DependencyCacheUploadStatusReport,
|
||||||
uploadDependencyCaches,
|
uploadDependencyCaches,
|
||||||
} from "./dependency-caching";
|
} from "./dependency-caching";
|
||||||
import { getDiffInformedAnalysisBranches } from "./diff-informed-analysis-utils";
|
import { getDiffInformedAnalysisBranches } from "./diff-informed-analysis-utils";
|
||||||
import { EnvVar } from "./environment";
|
import { EnvVar } from "./environment";
|
||||||
import { Feature, Features } from "./feature-flags";
|
import { Features } from "./feature-flags";
|
||||||
import { KnownLanguage } from "./languages";
|
import { KnownLanguage } from "./languages";
|
||||||
import { getActionsLogger, Logger } from "./logging";
|
import { getActionsLogger, Logger } from "./logging";
|
||||||
import { cleanupAndUploadOverlayBaseDatabaseToCache } from "./overlay-database-utils";
|
import { cleanupAndUploadOverlayBaseDatabaseToCache } from "./overlay-database-utils";
|
||||||
@@ -59,15 +57,13 @@ interface AnalysisStatusReport
|
|||||||
extends uploadLib.UploadStatusReport,
|
extends uploadLib.UploadStatusReport,
|
||||||
QueriesStatusReport {}
|
QueriesStatusReport {}
|
||||||
|
|
||||||
interface DependencyCachingUploadStatusReport {
|
|
||||||
dependency_caching_upload_results?: DependencyCacheUploadStatusReport;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface FinishStatusReport
|
interface FinishStatusReport
|
||||||
extends StatusReportBase,
|
extends StatusReportBase,
|
||||||
DatabaseCreationTimings,
|
DatabaseCreationTimings,
|
||||||
AnalysisStatusReport,
|
AnalysisStatusReport {
|
||||||
DependencyCachingUploadStatusReport {}
|
dependency_caching_upload_results?: DependencyCacheUploadStatusReport;
|
||||||
|
database_upload_results: DatabaseUploadResult[];
|
||||||
|
}
|
||||||
|
|
||||||
interface FinishWithTrapUploadStatusReport extends FinishStatusReport {
|
interface FinishWithTrapUploadStatusReport extends FinishStatusReport {
|
||||||
/** Size of TRAP caches that we uploaded, in bytes. */
|
/** Size of TRAP caches that we uploaded, in bytes. */
|
||||||
@@ -86,6 +82,7 @@ async function sendStatusReport(
|
|||||||
didUploadTrapCaches: boolean,
|
didUploadTrapCaches: boolean,
|
||||||
trapCacheCleanup: TrapCacheCleanupStatusReport | undefined,
|
trapCacheCleanup: TrapCacheCleanupStatusReport | undefined,
|
||||||
dependencyCacheResults: DependencyCacheUploadStatusReport | undefined,
|
dependencyCacheResults: DependencyCacheUploadStatusReport | undefined,
|
||||||
|
databaseUploadResults: DatabaseUploadResult[],
|
||||||
logger: Logger,
|
logger: Logger,
|
||||||
) {
|
) {
|
||||||
const status = getActionsStatus(error, stats?.analyze_failure_language);
|
const status = getActionsStatus(error, stats?.analyze_failure_language);
|
||||||
@@ -106,6 +103,7 @@ async function sendStatusReport(
|
|||||||
...(dbCreationTimings || {}),
|
...(dbCreationTimings || {}),
|
||||||
...(trapCacheCleanup || {}),
|
...(trapCacheCleanup || {}),
|
||||||
dependency_caching_upload_results: dependencyCacheResults,
|
dependency_caching_upload_results: dependencyCacheResults,
|
||||||
|
database_upload_results: databaseUploadResults,
|
||||||
};
|
};
|
||||||
if (config && didUploadTrapCaches) {
|
if (config && didUploadTrapCaches) {
|
||||||
const trapCacheUploadStatusReport: FinishWithTrapUploadStatusReport = {
|
const trapCacheUploadStatusReport: FinishWithTrapUploadStatusReport = {
|
||||||
@@ -223,6 +221,7 @@ async function run() {
|
|||||||
let dbCreationTimings: DatabaseCreationTimings | undefined = undefined;
|
let dbCreationTimings: DatabaseCreationTimings | undefined = undefined;
|
||||||
let didUploadTrapCaches = false;
|
let didUploadTrapCaches = false;
|
||||||
let dependencyCacheResults: DependencyCacheUploadStatusReport | undefined;
|
let dependencyCacheResults: DependencyCacheUploadStatusReport | undefined;
|
||||||
|
let databaseUploadResults: DatabaseUploadResult[] = [];
|
||||||
util.initializeEnvironment(actionsUtil.getActionVersion());
|
util.initializeEnvironment(actionsUtil.getActionVersion());
|
||||||
|
|
||||||
// Make inputs accessible in the `post` step, details at
|
// Make inputs accessible in the `post` step, details at
|
||||||
@@ -358,7 +357,6 @@ async function run() {
|
|||||||
const checkoutPath = actionsUtil.getRequiredInput("checkout_path");
|
const checkoutPath = actionsUtil.getRequiredInput("checkout_path");
|
||||||
const category = actionsUtil.getOptionalInput("category");
|
const category = actionsUtil.getOptionalInput("category");
|
||||||
|
|
||||||
if (await features.getValue(Feature.AnalyzeUseNewUpload)) {
|
|
||||||
uploadResults = await postProcessAndUploadSarif(
|
uploadResults = await postProcessAndUploadSarif(
|
||||||
logger,
|
logger,
|
||||||
features,
|
features,
|
||||||
@@ -368,36 +366,6 @@ async function run() {
|
|||||||
category,
|
category,
|
||||||
actionsUtil.getOptionalInput("post-processed-sarif-path"),
|
actionsUtil.getOptionalInput("post-processed-sarif-path"),
|
||||||
);
|
);
|
||||||
} else if (uploadKind === "always") {
|
|
||||||
uploadResults = {};
|
|
||||||
|
|
||||||
if (isCodeScanningEnabled(config)) {
|
|
||||||
uploadResults[analyses.AnalysisKind.CodeScanning] =
|
|
||||||
await uploadLib.uploadFiles(
|
|
||||||
outputDir,
|
|
||||||
checkoutPath,
|
|
||||||
category,
|
|
||||||
features,
|
|
||||||
logger,
|
|
||||||
analyses.CodeScanning,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isCodeQualityEnabled(config)) {
|
|
||||||
uploadResults[analyses.AnalysisKind.CodeQuality] =
|
|
||||||
await uploadLib.uploadFiles(
|
|
||||||
outputDir,
|
|
||||||
checkoutPath,
|
|
||||||
category,
|
|
||||||
features,
|
|
||||||
logger,
|
|
||||||
analyses.CodeQuality,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
uploadResults = {};
|
|
||||||
logger.info("Not uploading results");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set the SARIF id outputs only if we have results for them, to avoid
|
// Set the SARIF id outputs only if we have results for them, to avoid
|
||||||
// having keys with empty values in the action output.
|
// having keys with empty values in the action output.
|
||||||
@@ -425,7 +393,7 @@ async function run() {
|
|||||||
// Possibly upload the database bundles for remote queries.
|
// Possibly upload the database bundles for remote queries.
|
||||||
// Note: Take care with the ordering of this call since databases may be cleaned up
|
// Note: Take care with the ordering of this call since databases may be cleaned up
|
||||||
// at the `overlay` or `clear` level.
|
// at the `overlay` or `clear` level.
|
||||||
await cleanupAndUploadDatabases(
|
databaseUploadResults = await cleanupAndUploadDatabases(
|
||||||
repositoryNwo,
|
repositoryNwo,
|
||||||
codeql,
|
codeql,
|
||||||
config,
|
config,
|
||||||
@@ -497,6 +465,7 @@ async function run() {
|
|||||||
didUploadTrapCaches,
|
didUploadTrapCaches,
|
||||||
trapCacheCleanupTelemetry,
|
trapCacheCleanupTelemetry,
|
||||||
dependencyCacheResults,
|
dependencyCacheResults,
|
||||||
|
databaseUploadResults,
|
||||||
logger,
|
logger,
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
@@ -519,6 +488,7 @@ async function run() {
|
|||||||
didUploadTrapCaches,
|
didUploadTrapCaches,
|
||||||
trapCacheCleanupTelemetry,
|
trapCacheCleanupTelemetry,
|
||||||
dependencyCacheResults,
|
dependencyCacheResults,
|
||||||
|
databaseUploadResults,
|
||||||
logger,
|
logger,
|
||||||
);
|
);
|
||||||
} else if (runStats !== undefined) {
|
} else if (runStats !== undefined) {
|
||||||
@@ -532,6 +502,7 @@ async function run() {
|
|||||||
didUploadTrapCaches,
|
didUploadTrapCaches,
|
||||||
trapCacheCleanupTelemetry,
|
trapCacheCleanupTelemetry,
|
||||||
dependencyCacheResults,
|
dependencyCacheResults,
|
||||||
|
databaseUploadResults,
|
||||||
logger,
|
logger,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@@ -545,6 +516,7 @@ async function run() {
|
|||||||
didUploadTrapCaches,
|
didUploadTrapCaches,
|
||||||
trapCacheCleanupTelemetry,
|
trapCacheCleanupTelemetry,
|
||||||
dependencyCacheResults,
|
dependencyCacheResults,
|
||||||
|
databaseUploadResults,
|
||||||
logger,
|
logger,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,14 +95,14 @@ test("getGitHubVersion for different domain", async (t) => {
|
|||||||
t.deepEqual({ type: util.GitHubVariant.DOTCOM }, v3);
|
t.deepEqual({ type: util.GitHubVariant.DOTCOM }, v3);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("getGitHubVersion for GHE_DOTCOM", async (t) => {
|
test("getGitHubVersion for GHEC-DR", async (t) => {
|
||||||
mockGetMetaVersionHeader("ghe.com");
|
mockGetMetaVersionHeader("ghe.com");
|
||||||
const gheDotcom = await api.getGitHubVersionFromApi(api.getApiClient(), {
|
const gheDotcom = await api.getGitHubVersionFromApi(api.getApiClient(), {
|
||||||
auth: "",
|
auth: "",
|
||||||
url: "https://foo.ghe.com",
|
url: "https://foo.ghe.com",
|
||||||
apiURL: undefined,
|
apiURL: undefined,
|
||||||
});
|
});
|
||||||
t.deepEqual({ type: util.GitHubVariant.GHE_DOTCOM }, gheDotcom);
|
t.deepEqual({ type: util.GitHubVariant.GHEC_DR }, gheDotcom);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("wrapApiConfigurationError correctly wraps specific configuration errors", (t) => {
|
test("wrapApiConfigurationError correctly wraps specific configuration errors", (t) => {
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ export async function getGitHubVersionFromApi(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === "ghe.com") {
|
if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === "ghe.com") {
|
||||||
return { type: GitHubVariant.GHE_DOTCOM };
|
return { type: GitHubVariant.GHEC_DR };
|
||||||
}
|
}
|
||||||
|
|
||||||
const version = response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] as string;
|
const version = response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] as string;
|
||||||
|
|||||||
@@ -206,6 +206,7 @@ export interface CodeQL {
|
|||||||
* Run 'codeql resolve queries --format=startingpacks'.
|
* Run 'codeql resolve queries --format=startingpacks'.
|
||||||
*/
|
*/
|
||||||
resolveQueriesStartingPacks(queries: string[]): Promise<string[]>;
|
resolveQueriesStartingPacks(queries: string[]): Promise<string[]>;
|
||||||
|
resolveDatabase(databasePath: string): Promise<ResolveDatabaseOutput>;
|
||||||
/**
|
/**
|
||||||
* Run 'codeql github merge-results'.
|
* Run 'codeql github merge-results'.
|
||||||
*/
|
*/
|
||||||
@@ -230,6 +231,10 @@ export interface VersionInfo {
|
|||||||
overlayVersion?: number;
|
overlayVersion?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ResolveDatabaseOutput {
|
||||||
|
overlayBaseSpecifier?: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface ResolveLanguagesOutput {
|
export interface ResolveLanguagesOutput {
|
||||||
[language: string]: [string];
|
[language: string]: [string];
|
||||||
}
|
}
|
||||||
@@ -493,6 +498,7 @@ export function createStubCodeQL(partialCodeql: Partial<CodeQL>): CodeQL {
|
|||||||
partialCodeql,
|
partialCodeql,
|
||||||
"resolveQueriesStartingPacks",
|
"resolveQueriesStartingPacks",
|
||||||
),
|
),
|
||||||
|
resolveDatabase: resolveFunction(partialCodeql, "resolveDatabase"),
|
||||||
mergeResults: resolveFunction(partialCodeql, "mergeResults"),
|
mergeResults: resolveFunction(partialCodeql, "mergeResults"),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -1003,6 +1009,26 @@ async function getCodeQLForCmd(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
async resolveDatabase(
|
||||||
|
databasePath: string,
|
||||||
|
): Promise<ResolveDatabaseOutput> {
|
||||||
|
const codeqlArgs = [
|
||||||
|
"resolve",
|
||||||
|
"database",
|
||||||
|
databasePath,
|
||||||
|
"--format=json",
|
||||||
|
...getExtraOptionsFromEnv(["resolve", "database"]),
|
||||||
|
];
|
||||||
|
const output = await runCli(cmd, codeqlArgs, { noStreamStdout: true });
|
||||||
|
|
||||||
|
try {
|
||||||
|
return JSON.parse(output) as ResolveDatabaseOutput;
|
||||||
|
} catch (e) {
|
||||||
|
throw new Error(
|
||||||
|
`Unexpected output from codeql resolve database --format=json: ${e}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
async mergeResults(
|
async mergeResults(
|
||||||
sarifFiles: string[],
|
sarifFiles: string[],
|
||||||
outputFile: string,
|
outputFile: string,
|
||||||
|
|||||||
@@ -978,6 +978,7 @@ interface OverlayDatabaseModeTestSetup {
|
|||||||
languages: Language[];
|
languages: Language[];
|
||||||
codeqlVersion: string;
|
codeqlVersion: string;
|
||||||
gitRoot: string | undefined;
|
gitRoot: string | undefined;
|
||||||
|
gitVersion: string | undefined;
|
||||||
codeScanningConfig: configUtils.UserConfig;
|
codeScanningConfig: configUtils.UserConfig;
|
||||||
diskUsage: DiskUsage | undefined;
|
diskUsage: DiskUsage | undefined;
|
||||||
memoryFlagValue: number;
|
memoryFlagValue: number;
|
||||||
@@ -992,6 +993,7 @@ const defaultOverlayDatabaseModeTestSetup: OverlayDatabaseModeTestSetup = {
|
|||||||
languages: [KnownLanguage.javascript],
|
languages: [KnownLanguage.javascript],
|
||||||
codeqlVersion: CODEQL_OVERLAY_MINIMUM_VERSION,
|
codeqlVersion: CODEQL_OVERLAY_MINIMUM_VERSION,
|
||||||
gitRoot: "/some/git/root",
|
gitRoot: "/some/git/root",
|
||||||
|
gitVersion: gitUtils.GIT_MINIMUM_VERSION_FOR_OVERLAY,
|
||||||
codeScanningConfig: {},
|
codeScanningConfig: {},
|
||||||
diskUsage: {
|
diskUsage: {
|
||||||
numAvailableBytes: 50_000_000_000,
|
numAvailableBytes: 50_000_000_000,
|
||||||
@@ -1070,6 +1072,7 @@ const getOverlayDatabaseModeMacro = test.macro({
|
|||||||
setup.buildMode,
|
setup.buildMode,
|
||||||
undefined,
|
undefined,
|
||||||
setup.codeScanningConfig,
|
setup.codeScanningConfig,
|
||||||
|
setup.gitVersion,
|
||||||
logger,
|
logger,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -1773,6 +1776,32 @@ test(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
test(
|
||||||
|
getOverlayDatabaseModeMacro,
|
||||||
|
"Fallback due to old git version",
|
||||||
|
{
|
||||||
|
overlayDatabaseEnvVar: "overlay",
|
||||||
|
gitVersion: "2.30.0", // Version below required 2.38.0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
overlayDatabaseMode: OverlayDatabaseMode.None,
|
||||||
|
useOverlayDatabaseCaching: false,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
test(
|
||||||
|
getOverlayDatabaseModeMacro,
|
||||||
|
"Fallback when git version cannot be determined",
|
||||||
|
{
|
||||||
|
overlayDatabaseEnvVar: "overlay",
|
||||||
|
gitVersion: undefined,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
overlayDatabaseMode: OverlayDatabaseMode.None,
|
||||||
|
useOverlayDatabaseCaching: false,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
// Exercise language-specific overlay analysis features code paths
|
// Exercise language-specific overlay analysis features code paths
|
||||||
for (const language in KnownLanguage) {
|
for (const language in KnownLanguage) {
|
||||||
test(
|
test(
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import * as path from "path";
|
|||||||
import { performance } from "perf_hooks";
|
import { performance } from "perf_hooks";
|
||||||
|
|
||||||
import * as yaml from "js-yaml";
|
import * as yaml from "js-yaml";
|
||||||
|
import * as semver from "semver";
|
||||||
|
|
||||||
import { getActionVersion, isAnalyzingPullRequest } from "./actions-util";
|
import { getActionVersion, isAnalyzingPullRequest } from "./actions-util";
|
||||||
import {
|
import {
|
||||||
@@ -22,11 +23,17 @@ import {
|
|||||||
parseUserConfig,
|
parseUserConfig,
|
||||||
UserConfig,
|
UserConfig,
|
||||||
} from "./config/db-config";
|
} from "./config/db-config";
|
||||||
|
import { addDiagnostic, makeTelemetryDiagnostic } from "./diagnostics";
|
||||||
import { shouldPerformDiffInformedAnalysis } from "./diff-informed-analysis-utils";
|
import { shouldPerformDiffInformedAnalysis } from "./diff-informed-analysis-utils";
|
||||||
import * as errorMessages from "./error-messages";
|
import * as errorMessages from "./error-messages";
|
||||||
import { Feature, FeatureEnablement } from "./feature-flags";
|
import { Feature, FeatureEnablement } from "./feature-flags";
|
||||||
import { RepositoryProperties } from "./feature-flags/properties";
|
import { RepositoryProperties } from "./feature-flags/properties";
|
||||||
import { getGitRoot, isAnalyzingDefaultBranch } from "./git-utils";
|
import {
|
||||||
|
getGitRoot,
|
||||||
|
getGitVersionOrThrow,
|
||||||
|
GIT_MINIMUM_VERSION_FOR_OVERLAY,
|
||||||
|
isAnalyzingDefaultBranch,
|
||||||
|
} from "./git-utils";
|
||||||
import { KnownLanguage, Language } from "./languages";
|
import { KnownLanguage, Language } from "./languages";
|
||||||
import { Logger } from "./logging";
|
import { Logger } from "./logging";
|
||||||
import {
|
import {
|
||||||
@@ -45,6 +52,7 @@ import {
|
|||||||
isDefined,
|
isDefined,
|
||||||
checkDiskUsage,
|
checkDiskUsage,
|
||||||
getCodeQLMemoryLimit,
|
getCodeQLMemoryLimit,
|
||||||
|
getErrorMessage,
|
||||||
} from "./util";
|
} from "./util";
|
||||||
|
|
||||||
export * from "./config/db-config";
|
export * from "./config/db-config";
|
||||||
@@ -709,6 +717,7 @@ export async function getOverlayDatabaseMode(
|
|||||||
buildMode: BuildMode | undefined,
|
buildMode: BuildMode | undefined,
|
||||||
ramInput: string | undefined,
|
ramInput: string | undefined,
|
||||||
codeScanningConfig: UserConfig,
|
codeScanningConfig: UserConfig,
|
||||||
|
gitVersion: string | undefined,
|
||||||
logger: Logger,
|
logger: Logger,
|
||||||
): Promise<{
|
): Promise<{
|
||||||
overlayDatabaseMode: OverlayDatabaseMode;
|
overlayDatabaseMode: OverlayDatabaseMode;
|
||||||
@@ -811,6 +820,22 @@ export async function getOverlayDatabaseMode(
|
|||||||
);
|
);
|
||||||
return nonOverlayAnalysis;
|
return nonOverlayAnalysis;
|
||||||
}
|
}
|
||||||
|
if (gitVersion === undefined) {
|
||||||
|
logger.warning(
|
||||||
|
`Cannot build an ${overlayDatabaseMode} database because ` +
|
||||||
|
"the Git version could not be determined. " +
|
||||||
|
"Falling back to creating a normal full database instead.",
|
||||||
|
);
|
||||||
|
return nonOverlayAnalysis;
|
||||||
|
}
|
||||||
|
if (!semver.gte(gitVersion, GIT_MINIMUM_VERSION_FOR_OVERLAY)) {
|
||||||
|
logger.warning(
|
||||||
|
`Cannot build an ${overlayDatabaseMode} database because ` +
|
||||||
|
`the installed Git version is older than ${GIT_MINIMUM_VERSION_FOR_OVERLAY}. ` +
|
||||||
|
"Falling back to creating a normal full database instead.",
|
||||||
|
);
|
||||||
|
return nonOverlayAnalysis;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
overlayDatabaseMode,
|
overlayDatabaseMode,
|
||||||
@@ -903,6 +928,15 @@ export async function initConfig(
|
|||||||
config.computedConfig["query-filters"] = [];
|
config.computedConfig["query-filters"] = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let gitVersion: string | undefined = undefined;
|
||||||
|
try {
|
||||||
|
gitVersion = await getGitVersionOrThrow();
|
||||||
|
logger.info(`Using Git version ${gitVersion}`);
|
||||||
|
await logGitVersionTelemetry(config, gitVersion);
|
||||||
|
} catch (e) {
|
||||||
|
logger.debug(`Could not determine Git version: ${getErrorMessage(e)}`);
|
||||||
|
}
|
||||||
|
|
||||||
// The choice of overlay database mode depends on the selection of languages
|
// The choice of overlay database mode depends on the selection of languages
|
||||||
// and queries, which in turn depends on the user config and the augmentation
|
// and queries, which in turn depends on the user config and the augmentation
|
||||||
// properties. So we need to calculate the overlay database mode after the
|
// properties. So we need to calculate the overlay database mode after the
|
||||||
@@ -916,6 +950,7 @@ export async function initConfig(
|
|||||||
config.buildMode,
|
config.buildMode,
|
||||||
inputs.ramInput,
|
inputs.ramInput,
|
||||||
config.computedConfig,
|
config.computedConfig,
|
||||||
|
gitVersion,
|
||||||
logger,
|
logger,
|
||||||
);
|
);
|
||||||
logger.info(
|
logger.info(
|
||||||
@@ -1316,3 +1351,23 @@ export function getPrimaryAnalysisConfig(config: Config): AnalysisConfig {
|
|||||||
? CodeScanning
|
? CodeScanning
|
||||||
: CodeQuality;
|
: CodeQuality;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Logs the Git version as a telemetry diagnostic. */
|
||||||
|
async function logGitVersionTelemetry(
|
||||||
|
config: Config,
|
||||||
|
gitVersion: string,
|
||||||
|
): Promise<void> {
|
||||||
|
if (config.languages.length > 0) {
|
||||||
|
addDiagnostic(
|
||||||
|
config,
|
||||||
|
// Arbitrarily choose the first language. We could also choose all languages, but that
|
||||||
|
// increases the risk of misinterpreting the data.
|
||||||
|
config.languages[0],
|
||||||
|
makeTelemetryDiagnostic(
|
||||||
|
"codeql-action/git-version-telemetry",
|
||||||
|
"Git version telemetry",
|
||||||
|
{ gitVersion },
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -231,7 +231,7 @@ test("Don't crash if uploading a database fails", async (t) => {
|
|||||||
(v) =>
|
(v) =>
|
||||||
v.type === "warning" &&
|
v.type === "warning" &&
|
||||||
v.message ===
|
v.message ===
|
||||||
"Failed to upload database for javascript: Error: some error message",
|
"Failed to upload database for javascript: some error message",
|
||||||
) !== undefined,
|
) !== undefined,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -13,6 +13,20 @@ import { RepositoryNwo } from "./repository";
|
|||||||
import * as util from "./util";
|
import * as util from "./util";
|
||||||
import { bundleDb, CleanupLevel, parseGitHubUrl } from "./util";
|
import { bundleDb, CleanupLevel, parseGitHubUrl } from "./util";
|
||||||
|
|
||||||
|
/** Information about a database upload. */
|
||||||
|
export interface DatabaseUploadResult {
|
||||||
|
/** Language of the database. */
|
||||||
|
language: string;
|
||||||
|
/** Size of the zipped database in bytes. */
|
||||||
|
zipped_upload_size_bytes?: number;
|
||||||
|
/** Whether the uploaded database is an overlay base. */
|
||||||
|
is_overlay_base?: boolean;
|
||||||
|
/** Time taken to upload database in milliseconds. */
|
||||||
|
upload_duration_ms?: number;
|
||||||
|
/** If there was an error during database upload, this is its message. */
|
||||||
|
error?: string;
|
||||||
|
}
|
||||||
|
|
||||||
export async function cleanupAndUploadDatabases(
|
export async function cleanupAndUploadDatabases(
|
||||||
repositoryNwo: RepositoryNwo,
|
repositoryNwo: RepositoryNwo,
|
||||||
codeql: CodeQL,
|
codeql: CodeQL,
|
||||||
@@ -20,42 +34,44 @@ export async function cleanupAndUploadDatabases(
|
|||||||
apiDetails: GitHubApiDetails,
|
apiDetails: GitHubApiDetails,
|
||||||
features: FeatureEnablement,
|
features: FeatureEnablement,
|
||||||
logger: Logger,
|
logger: Logger,
|
||||||
): Promise<void> {
|
): Promise<DatabaseUploadResult[]> {
|
||||||
if (actionsUtil.getRequiredInput("upload-database") !== "true") {
|
if (actionsUtil.getRequiredInput("upload-database") !== "true") {
|
||||||
logger.debug("Database upload disabled in workflow. Skipping upload.");
|
logger.debug("Database upload disabled in workflow. Skipping upload.");
|
||||||
return;
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!config.analysisKinds.includes(AnalysisKind.CodeScanning)) {
|
if (!config.analysisKinds.includes(AnalysisKind.CodeScanning)) {
|
||||||
logger.debug(
|
logger.debug(
|
||||||
`Not uploading database because 'analysis-kinds: ${AnalysisKind.CodeScanning}' is not enabled.`,
|
`Not uploading database because 'analysis-kinds: ${AnalysisKind.CodeScanning}' is not enabled.`,
|
||||||
);
|
);
|
||||||
return;
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (util.isInTestMode()) {
|
if (util.isInTestMode()) {
|
||||||
logger.debug("In test mode. Skipping database upload.");
|
logger.debug("In test mode. Skipping database upload.");
|
||||||
return;
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do nothing when not running against github.com
|
// Do nothing when not running against github.com
|
||||||
if (
|
if (
|
||||||
config.gitHubVersion.type !== util.GitHubVariant.DOTCOM &&
|
config.gitHubVersion.type !== util.GitHubVariant.DOTCOM &&
|
||||||
config.gitHubVersion.type !== util.GitHubVariant.GHE_DOTCOM
|
config.gitHubVersion.type !== util.GitHubVariant.GHEC_DR
|
||||||
) {
|
) {
|
||||||
logger.debug("Not running against github.com or GHEC-DR. Skipping upload.");
|
logger.debug("Not running against github.com or GHEC-DR. Skipping upload.");
|
||||||
return;
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(await gitUtils.isAnalyzingDefaultBranch())) {
|
if (!(await gitUtils.isAnalyzingDefaultBranch())) {
|
||||||
// We only want to upload a database if we are analyzing the default branch.
|
// We only want to upload a database if we are analyzing the default branch.
|
||||||
logger.debug("Not analyzing default branch. Skipping upload.");
|
logger.debug("Not analyzing default branch. Skipping upload.");
|
||||||
return;
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const cleanupLevel =
|
// If config.overlayDatabaseMode is OverlayBase, then we have overlay base databases for all languages.
|
||||||
|
const shouldUploadOverlayBase =
|
||||||
config.overlayDatabaseMode === OverlayDatabaseMode.OverlayBase &&
|
config.overlayDatabaseMode === OverlayDatabaseMode.OverlayBase &&
|
||||||
(await features.getValue(Feature.UploadOverlayDbToApi))
|
(await features.getValue(Feature.UploadOverlayDbToApi));
|
||||||
|
const cleanupLevel = shouldUploadOverlayBase
|
||||||
? CleanupLevel.Overlay
|
? CleanupLevel.Overlay
|
||||||
: CleanupLevel.Clear;
|
: CleanupLevel.Clear;
|
||||||
|
|
||||||
@@ -77,6 +93,7 @@ export async function cleanupAndUploadDatabases(
|
|||||||
uploadsBaseUrl = uploadsBaseUrl.slice(0, -1);
|
uploadsBaseUrl = uploadsBaseUrl.slice(0, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const reports: DatabaseUploadResult[] = [];
|
||||||
for (const language of config.languages) {
|
for (const language of config.languages) {
|
||||||
try {
|
try {
|
||||||
// Upload the database bundle.
|
// Upload the database bundle.
|
||||||
@@ -90,6 +107,7 @@ export async function cleanupAndUploadDatabases(
|
|||||||
actionsUtil.getRequiredInput("checkout_path"),
|
actionsUtil.getRequiredInput("checkout_path"),
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
|
const startTime = performance.now();
|
||||||
await client.request(
|
await client.request(
|
||||||
`POST /repos/:owner/:repo/code-scanning/codeql/databases/:language?name=:name&commit_oid=:commit_oid`,
|
`POST /repos/:owner/:repo/code-scanning/codeql/databases/:language?name=:name&commit_oid=:commit_oid`,
|
||||||
{
|
{
|
||||||
@@ -107,13 +125,27 @@ export async function cleanupAndUploadDatabases(
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
const endTime = performance.now();
|
||||||
|
reports.push({
|
||||||
|
language,
|
||||||
|
zipped_upload_size_bytes: bundledDbSize,
|
||||||
|
is_overlay_base: shouldUploadOverlayBase,
|
||||||
|
upload_duration_ms: endTime - startTime,
|
||||||
|
});
|
||||||
logger.debug(`Successfully uploaded database for ${language}`);
|
logger.debug(`Successfully uploaded database for ${language}`);
|
||||||
} finally {
|
} finally {
|
||||||
bundledDbReadStream.close();
|
bundledDbReadStream.close();
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Log a warning but don't fail the workflow
|
// Log a warning but don't fail the workflow
|
||||||
logger.warning(`Failed to upload database for ${language}: ${e}`);
|
logger.warning(
|
||||||
|
`Failed to upload database for ${language}: ${util.getErrorMessage(e)}`,
|
||||||
|
);
|
||||||
|
reports.push({
|
||||||
|
language,
|
||||||
|
error: util.getErrorMessage(e),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return reports;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"bundleVersion": "codeql-bundle-v2.23.7",
|
"bundleVersion": "codeql-bundle-v2.23.8",
|
||||||
"cliVersion": "2.23.7",
|
"cliVersion": "2.23.8",
|
||||||
"priorBundleVersion": "codeql-bundle-v2.23.6",
|
"priorBundleVersion": "codeql-bundle-v2.23.7",
|
||||||
"priorCliVersion": "2.23.6"
|
"priorCliVersion": "2.23.7"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -603,28 +603,6 @@ test("getFeaturePrefix - returns empty string if no features are enabled", async
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test("getFeaturePrefix - Java - returns 'minify-' if JavaMinimizeDependencyJars is enabled", async (t) => {
|
|
||||||
const codeql = createStubCodeQL({});
|
|
||||||
const features = createFeatures([Feature.JavaMinimizeDependencyJars]);
|
|
||||||
|
|
||||||
const result = await getFeaturePrefix(codeql, features, KnownLanguage.java);
|
|
||||||
t.deepEqual(result, "minify-");
|
|
||||||
});
|
|
||||||
|
|
||||||
test("getFeaturePrefix - non-Java - returns '' if JavaMinimizeDependencyJars is enabled", async (t) => {
|
|
||||||
const codeql = createStubCodeQL({});
|
|
||||||
const features = createFeatures([Feature.JavaMinimizeDependencyJars]);
|
|
||||||
|
|
||||||
for (const knownLanguage of Object.values(KnownLanguage)) {
|
|
||||||
// Skip Java since we expect a result for it, which is tested in the previous test.
|
|
||||||
if (knownLanguage === KnownLanguage.java) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const result = await getFeaturePrefix(codeql, features, knownLanguage);
|
|
||||||
t.deepEqual(result, "", `Expected no feature prefix for ${knownLanguage}`);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
test("getFeaturePrefix - C# - returns prefix if CsharpNewCacheKey is enabled", async (t) => {
|
test("getFeaturePrefix - C# - returns prefix if CsharpNewCacheKey is enabled", async (t) => {
|
||||||
const codeql = createStubCodeQL({});
|
const codeql = createStubCodeQL({});
|
||||||
const features = createFeatures([Feature.CsharpNewCacheKey]);
|
const features = createFeatures([Feature.CsharpNewCacheKey]);
|
||||||
|
|||||||
@@ -541,18 +541,7 @@ export async function getFeaturePrefix(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (language === KnownLanguage.java) {
|
if (language === KnownLanguage.csharp) {
|
||||||
// To ensure a safe rollout of JAR minimization, we change the key when the feature is enabled.
|
|
||||||
const minimizeJavaJars = await features.getValue(
|
|
||||||
Feature.JavaMinimizeDependencyJars,
|
|
||||||
codeql,
|
|
||||||
);
|
|
||||||
|
|
||||||
// To maintain backwards compatibility with this, we return "minify-" instead of a hash.
|
|
||||||
if (minimizeJavaJars) {
|
|
||||||
return "minify-";
|
|
||||||
}
|
|
||||||
} else if (language === KnownLanguage.csharp) {
|
|
||||||
await addFeatureIfEnabled(Feature.CsharpNewCacheKey);
|
await addFeatureIfEnabled(Feature.CsharpNewCacheKey);
|
||||||
await addFeatureIfEnabled(Feature.CsharpCacheBuildModeNone);
|
await addFeatureIfEnabled(Feature.CsharpCacheBuildModeNone);
|
||||||
}
|
}
|
||||||
@@ -593,15 +582,9 @@ async function cachePrefix(
|
|||||||
// experimental features that affect the cache contents.
|
// experimental features that affect the cache contents.
|
||||||
const featurePrefix = await getFeaturePrefix(codeql, features, language);
|
const featurePrefix = await getFeaturePrefix(codeql, features, language);
|
||||||
|
|
||||||
// Assemble the cache key. For backwards compatibility with the JAR minification experiment's existing
|
// Assemble the cache key.
|
||||||
// feature prefix usage, we add that feature prefix at the start. Other feature prefixes are inserted
|
|
||||||
// after the general CodeQL dependency cache prefix.
|
|
||||||
if (featurePrefix === "minify-") {
|
|
||||||
return `${featurePrefix}${prefix}-${CODEQL_DEPENDENCY_CACHE_VERSION}-${runnerOs}-${language}-`;
|
|
||||||
} else {
|
|
||||||
return `${prefix}-${featurePrefix}${CODEQL_DEPENDENCY_CACHE_VERSION}-${runnerOs}-${language}-`;
|
return `${prefix}-${featurePrefix}${CODEQL_DEPENDENCY_CACHE_VERSION}-${runnerOs}-${language}-`;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/** Represents information about our overall cache usage for CodeQL dependency caches. */
|
/** Represents information about our overall cache usage for CodeQL dependency caches. */
|
||||||
export interface DependencyCachingUsageReport {
|
export interface DependencyCachingUsageReport {
|
||||||
|
|||||||
@@ -185,3 +185,27 @@ export function flushDiagnostics(config: Config) {
|
|||||||
// Reset the unwritten diagnostics array.
|
// Reset the unwritten diagnostics array.
|
||||||
unwrittenDiagnostics = [];
|
unwrittenDiagnostics = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a telemetry-only diagnostic message. This is a convenience function
|
||||||
|
* for creating diagnostics that should only be sent to telemetry and not
|
||||||
|
* displayed on the status page or CLI summary table.
|
||||||
|
*
|
||||||
|
* @param id An identifier under which it makes sense to group this diagnostic message
|
||||||
|
* @param name Display name
|
||||||
|
* @param attributes Structured metadata
|
||||||
|
*/
|
||||||
|
export function makeTelemetryDiagnostic(
|
||||||
|
id: string,
|
||||||
|
name: string,
|
||||||
|
attributes: { [key: string]: any },
|
||||||
|
): DiagnosticMessage {
|
||||||
|
return makeDiagnostic(id, name, {
|
||||||
|
attributes,
|
||||||
|
visibility: {
|
||||||
|
cliSummaryTable: false,
|
||||||
|
statusPage: false,
|
||||||
|
telemetry: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@@ -62,13 +62,13 @@ test(`All features are disabled if running against GHES`, async (t) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test(`Feature flags are requested in Proxima`, async (t) => {
|
test(`Feature flags are requested in GHEC-DR`, async (t) => {
|
||||||
await withTmpDir(async (tmpDir) => {
|
await withTmpDir(async (tmpDir) => {
|
||||||
const loggedMessages = [];
|
const loggedMessages = [];
|
||||||
const features = setUpFeatureFlagTests(
|
const features = setUpFeatureFlagTests(
|
||||||
tmpDir,
|
tmpDir,
|
||||||
getRecordingLogger(loggedMessages),
|
getRecordingLogger(loggedMessages),
|
||||||
{ type: GitHubVariant.GHE_DOTCOM },
|
{ type: GitHubVariant.GHEC_DR },
|
||||||
);
|
);
|
||||||
|
|
||||||
mockFeatureFlagApiEndpoint(200, initializeFeatures(true));
|
mockFeatureFlagApiEndpoint(200, initializeFeatures(true));
|
||||||
@@ -436,21 +436,24 @@ test(`selects CLI from defaults.json on GHES`, async (t) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test("selects CLI v2.20.1 on Dotcom when feature flags enable v2.20.0 and v2.20.1", async (t) => {
|
for (const variant of [GitHubVariant.DOTCOM, GitHubVariant.GHEC_DR]) {
|
||||||
|
test(`selects CLI v2.20.1 on ${variant} when feature flags enable v2.20.0 and v2.20.1`, async (t) => {
|
||||||
await withTmpDir(async (tmpDir) => {
|
await withTmpDir(async (tmpDir) => {
|
||||||
const features = setUpFeatureFlagTests(tmpDir);
|
const features = setUpFeatureFlagTests(tmpDir);
|
||||||
const expectedFeatureEnablement = initializeFeatures(true);
|
const expectedFeatureEnablement = initializeFeatures(true);
|
||||||
expectedFeatureEnablement["default_codeql_version_2_20_0_enabled"] = true;
|
expectedFeatureEnablement["default_codeql_version_2_20_0_enabled"] = true;
|
||||||
expectedFeatureEnablement["default_codeql_version_2_20_1_enabled"] = true;
|
expectedFeatureEnablement["default_codeql_version_2_20_1_enabled"] = true;
|
||||||
expectedFeatureEnablement["default_codeql_version_2_20_2_enabled"] = false;
|
expectedFeatureEnablement["default_codeql_version_2_20_2_enabled"] =
|
||||||
expectedFeatureEnablement["default_codeql_version_2_20_3_enabled"] = false;
|
false;
|
||||||
expectedFeatureEnablement["default_codeql_version_2_20_4_enabled"] = false;
|
expectedFeatureEnablement["default_codeql_version_2_20_3_enabled"] =
|
||||||
expectedFeatureEnablement["default_codeql_version_2_20_5_enabled"] = false;
|
false;
|
||||||
|
expectedFeatureEnablement["default_codeql_version_2_20_4_enabled"] =
|
||||||
|
false;
|
||||||
|
expectedFeatureEnablement["default_codeql_version_2_20_5_enabled"] =
|
||||||
|
false;
|
||||||
mockFeatureFlagApiEndpoint(200, expectedFeatureEnablement);
|
mockFeatureFlagApiEndpoint(200, expectedFeatureEnablement);
|
||||||
|
|
||||||
const defaultCliVersion = await features.getDefaultCliVersion(
|
const defaultCliVersion = await features.getDefaultCliVersion(variant);
|
||||||
GitHubVariant.DOTCOM,
|
|
||||||
);
|
|
||||||
t.deepEqual(defaultCliVersion, {
|
t.deepEqual(defaultCliVersion, {
|
||||||
cliVersion: "2.20.1",
|
cliVersion: "2.20.1",
|
||||||
tagName: "codeql-bundle-v2.20.1",
|
tagName: "codeql-bundle-v2.20.1",
|
||||||
@@ -459,33 +462,13 @@ test("selects CLI v2.20.1 on Dotcom when feature flags enable v2.20.0 and v2.20.
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test("includes tag name", async (t) => {
|
test(`selects CLI from defaults.json on ${variant} when no default version feature flags are enabled`, async (t) => {
|
||||||
await withTmpDir(async (tmpDir) => {
|
|
||||||
const features = setUpFeatureFlagTests(tmpDir);
|
|
||||||
const expectedFeatureEnablement = initializeFeatures(true);
|
|
||||||
expectedFeatureEnablement["default_codeql_version_2_20_0_enabled"] = true;
|
|
||||||
mockFeatureFlagApiEndpoint(200, expectedFeatureEnablement);
|
|
||||||
|
|
||||||
const defaultCliVersion = await features.getDefaultCliVersion(
|
|
||||||
GitHubVariant.DOTCOM,
|
|
||||||
);
|
|
||||||
t.deepEqual(defaultCliVersion, {
|
|
||||||
cliVersion: "2.20.0",
|
|
||||||
tagName: "codeql-bundle-v2.20.0",
|
|
||||||
toolsFeatureFlagsValid: true,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test(`selects CLI from defaults.json on Dotcom when no default version feature flags are enabled`, async (t) => {
|
|
||||||
await withTmpDir(async (tmpDir) => {
|
await withTmpDir(async (tmpDir) => {
|
||||||
const features = setUpFeatureFlagTests(tmpDir);
|
const features = setUpFeatureFlagTests(tmpDir);
|
||||||
const expectedFeatureEnablement = initializeFeatures(true);
|
const expectedFeatureEnablement = initializeFeatures(true);
|
||||||
mockFeatureFlagApiEndpoint(200, expectedFeatureEnablement);
|
mockFeatureFlagApiEndpoint(200, expectedFeatureEnablement);
|
||||||
|
|
||||||
const defaultCliVersion = await features.getDefaultCliVersion(
|
const defaultCliVersion = await features.getDefaultCliVersion(variant);
|
||||||
GitHubVariant.DOTCOM,
|
|
||||||
);
|
|
||||||
t.deepEqual(defaultCliVersion, {
|
t.deepEqual(defaultCliVersion, {
|
||||||
cliVersion: defaults.cliVersion,
|
cliVersion: defaults.cliVersion,
|
||||||
tagName: defaults.bundleVersion,
|
tagName: defaults.bundleVersion,
|
||||||
@@ -494,7 +477,7 @@ test(`selects CLI from defaults.json on Dotcom when no default version feature f
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test("ignores invalid version numbers in default version feature flags", async (t) => {
|
test(`ignores invalid version numbers in default version feature flags on ${variant}`, async (t) => {
|
||||||
await withTmpDir(async (tmpDir) => {
|
await withTmpDir(async (tmpDir) => {
|
||||||
const loggedMessages = [];
|
const loggedMessages = [];
|
||||||
const features = setUpFeatureFlagTests(
|
const features = setUpFeatureFlagTests(
|
||||||
@@ -508,9 +491,7 @@ test("ignores invalid version numbers in default version feature flags", async (
|
|||||||
true;
|
true;
|
||||||
mockFeatureFlagApiEndpoint(200, expectedFeatureEnablement);
|
mockFeatureFlagApiEndpoint(200, expectedFeatureEnablement);
|
||||||
|
|
||||||
const defaultCliVersion = await features.getDefaultCliVersion(
|
const defaultCliVersion = await features.getDefaultCliVersion(variant);
|
||||||
GitHubVariant.DOTCOM,
|
|
||||||
);
|
|
||||||
t.deepEqual(defaultCliVersion, {
|
t.deepEqual(defaultCliVersion, {
|
||||||
cliVersion: "2.20.1",
|
cliVersion: "2.20.1",
|
||||||
tagName: "codeql-bundle-v2.20.1",
|
tagName: "codeql-bundle-v2.20.1",
|
||||||
@@ -527,6 +508,7 @@ test("ignores invalid version numbers in default version feature flags", async (
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
test("legacy feature flags should end with _enabled", async (t) => {
|
test("legacy feature flags should end with _enabled", async (t) => {
|
||||||
for (const [feature, config] of Object.entries(featureConfig)) {
|
for (const [feature, config] of Object.entries(featureConfig)) {
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ export interface FeatureEnablement {
|
|||||||
*/
|
*/
|
||||||
export enum Feature {
|
export enum Feature {
|
||||||
AllowToolcacheInput = "allow_toolcache_input",
|
AllowToolcacheInput = "allow_toolcache_input",
|
||||||
AnalyzeUseNewUpload = "analyze_use_new_upload",
|
|
||||||
CleanupTrapCaches = "cleanup_trap_caches",
|
CleanupTrapCaches = "cleanup_trap_caches",
|
||||||
CppDependencyInstallation = "cpp_dependency_installation_enabled",
|
CppDependencyInstallation = "cpp_dependency_installation_enabled",
|
||||||
CsharpCacheBuildModeNone = "csharp_cache_bmn",
|
CsharpCacheBuildModeNone = "csharp_cache_bmn",
|
||||||
@@ -54,7 +53,6 @@ export enum Feature {
|
|||||||
DisableJavaBuildlessEnabled = "disable_java_buildless_enabled",
|
DisableJavaBuildlessEnabled = "disable_java_buildless_enabled",
|
||||||
DisableKotlinAnalysisEnabled = "disable_kotlin_analysis_enabled",
|
DisableKotlinAnalysisEnabled = "disable_kotlin_analysis_enabled",
|
||||||
ExportDiagnosticsEnabled = "export_diagnostics_enabled",
|
ExportDiagnosticsEnabled = "export_diagnostics_enabled",
|
||||||
JavaMinimizeDependencyJars = "java_minimize_dependency_jars",
|
|
||||||
OverlayAnalysis = "overlay_analysis",
|
OverlayAnalysis = "overlay_analysis",
|
||||||
OverlayAnalysisActions = "overlay_analysis_actions",
|
OverlayAnalysisActions = "overlay_analysis_actions",
|
||||||
OverlayAnalysisCodeScanningActions = "overlay_analysis_code_scanning_actions",
|
OverlayAnalysisCodeScanningActions = "overlay_analysis_code_scanning_actions",
|
||||||
@@ -120,11 +118,6 @@ export const featureConfig: Record<
|
|||||||
envVar: "CODEQL_ACTION_ALLOW_TOOLCACHE_INPUT",
|
envVar: "CODEQL_ACTION_ALLOW_TOOLCACHE_INPUT",
|
||||||
minimumVersion: undefined,
|
minimumVersion: undefined,
|
||||||
},
|
},
|
||||||
[Feature.AnalyzeUseNewUpload]: {
|
|
||||||
defaultValue: false,
|
|
||||||
envVar: "CODEQL_ACTION_ANALYZE_USE_NEW_UPLOAD",
|
|
||||||
minimumVersion: undefined,
|
|
||||||
},
|
|
||||||
[Feature.CleanupTrapCaches]: {
|
[Feature.CleanupTrapCaches]: {
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
envVar: "CODEQL_ACTION_CLEANUP_TRAP_CACHES",
|
envVar: "CODEQL_ACTION_CLEANUP_TRAP_CACHES",
|
||||||
@@ -174,11 +167,6 @@ export const featureConfig: Record<
|
|||||||
legacyApi: true,
|
legacyApi: true,
|
||||||
minimumVersion: undefined,
|
minimumVersion: undefined,
|
||||||
},
|
},
|
||||||
[Feature.JavaMinimizeDependencyJars]: {
|
|
||||||
defaultValue: false,
|
|
||||||
envVar: "CODEQL_ACTION_JAVA_MINIMIZE_DEPENDENCY_JARS",
|
|
||||||
minimumVersion: "2.23.0",
|
|
||||||
},
|
|
||||||
[Feature.OverlayAnalysis]: {
|
[Feature.OverlayAnalysis]: {
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS",
|
envVar: "CODEQL_ACTION_OVERLAY_ANALYSIS",
|
||||||
@@ -498,8 +486,8 @@ class GitHubFeatureFlags {
|
|||||||
async getDefaultCliVersion(
|
async getDefaultCliVersion(
|
||||||
variant: util.GitHubVariant,
|
variant: util.GitHubVariant,
|
||||||
): Promise<CodeQLDefaultVersionInfo> {
|
): Promise<CodeQLDefaultVersionInfo> {
|
||||||
if (variant === util.GitHubVariant.DOTCOM) {
|
if (supportsFeatureFlags(variant)) {
|
||||||
return await this.getDefaultDotcomCliVersion();
|
return await this.getDefaultCliVersionFromFlags();
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
cliVersion: defaults.cliVersion,
|
cliVersion: defaults.cliVersion,
|
||||||
@@ -507,7 +495,7 @@ class GitHubFeatureFlags {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async getDefaultDotcomCliVersion(): Promise<CodeQLDefaultVersionInfo> {
|
async getDefaultCliVersionFromFlags(): Promise<CodeQLDefaultVersionInfo> {
|
||||||
const response = await this.getAllFeatures();
|
const response = await this.getAllFeatures();
|
||||||
|
|
||||||
const enabledFeatureFlagCliVersions = Object.entries(response)
|
const enabledFeatureFlagCliVersions = Object.entries(response)
|
||||||
@@ -633,10 +621,7 @@ class GitHubFeatureFlags {
|
|||||||
|
|
||||||
private async loadApiResponse(): Promise<GitHubFeatureFlagsApiResponse> {
|
private async loadApiResponse(): Promise<GitHubFeatureFlagsApiResponse> {
|
||||||
// Do nothing when not running against github.com
|
// Do nothing when not running against github.com
|
||||||
if (
|
if (!supportsFeatureFlags(this.gitHubVersion.type)) {
|
||||||
this.gitHubVersion.type !== util.GitHubVariant.DOTCOM &&
|
|
||||||
this.gitHubVersion.type !== util.GitHubVariant.GHE_DOTCOM
|
|
||||||
) {
|
|
||||||
this.logger.debug(
|
this.logger.debug(
|
||||||
"Not running against github.com. Disabling all toggleable features.",
|
"Not running against github.com. Disabling all toggleable features.",
|
||||||
);
|
);
|
||||||
@@ -702,3 +687,10 @@ class GitHubFeatureFlags {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function supportsFeatureFlags(githubVariant: util.GitHubVariant): boolean {
|
||||||
|
return (
|
||||||
|
githubVariant === util.GitHubVariant.DOTCOM ||
|
||||||
|
githubVariant === util.GitHubVariant.GHEC_DR
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@@ -315,7 +315,6 @@ test("getFileOidsUnderPath returns correct file mapping", async (t) => {
|
|||||||
"a47c11f5bfdca7661942d2c8f1b7209fb0dfdf96_src/git-utils.ts",
|
"a47c11f5bfdca7661942d2c8f1b7209fb0dfdf96_src/git-utils.ts",
|
||||||
);
|
);
|
||||||
|
|
||||||
try {
|
|
||||||
const result = await gitUtils.getFileOidsUnderPath("/fake/path");
|
const result = await gitUtils.getFileOidsUnderPath("/fake/path");
|
||||||
|
|
||||||
t.deepEqual(result, {
|
t.deepEqual(result, {
|
||||||
@@ -329,13 +328,10 @@ test("getFileOidsUnderPath returns correct file mapping", async (t) => {
|
|||||||
["ls-files", "--recurse-submodules", "--format=%(objectname)_%(path)"],
|
["ls-files", "--recurse-submodules", "--format=%(objectname)_%(path)"],
|
||||||
"Cannot list Git OIDs of tracked files.",
|
"Cannot list Git OIDs of tracked files.",
|
||||||
]);
|
]);
|
||||||
} finally {
|
|
||||||
runGitCommandStub.restore();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("getFileOidsUnderPath handles quoted paths", async (t) => {
|
test("getFileOidsUnderPath handles quoted paths", async (t) => {
|
||||||
const runGitCommandStub = sinon
|
sinon
|
||||||
.stub(gitUtils as any, "runGitCommand")
|
.stub(gitUtils as any, "runGitCommand")
|
||||||
.resolves(
|
.resolves(
|
||||||
"30d998ded095371488be3a729eb61d86ed721a18_lib/normal-file.js\n" +
|
"30d998ded095371488be3a729eb61d86ed721a18_lib/normal-file.js\n" +
|
||||||
@@ -343,7 +339,6 @@ test("getFileOidsUnderPath handles quoted paths", async (t) => {
|
|||||||
'a47c11f5bfdca7661942d2c8f1b7209fb0dfdf96_"lib/file\\twith\\ttabs.js"',
|
'a47c11f5bfdca7661942d2c8f1b7209fb0dfdf96_"lib/file\\twith\\ttabs.js"',
|
||||||
);
|
);
|
||||||
|
|
||||||
try {
|
|
||||||
const result = await gitUtils.getFileOidsUnderPath("/fake/path");
|
const result = await gitUtils.getFileOidsUnderPath("/fake/path");
|
||||||
|
|
||||||
t.deepEqual(result, {
|
t.deepEqual(result, {
|
||||||
@@ -351,26 +346,17 @@ test("getFileOidsUnderPath handles quoted paths", async (t) => {
|
|||||||
"lib/file with spaces.js": "d89514599a9a99f22b4085766d40af7b99974827",
|
"lib/file with spaces.js": "d89514599a9a99f22b4085766d40af7b99974827",
|
||||||
"lib/file\twith\ttabs.js": "a47c11f5bfdca7661942d2c8f1b7209fb0dfdf96",
|
"lib/file\twith\ttabs.js": "a47c11f5bfdca7661942d2c8f1b7209fb0dfdf96",
|
||||||
});
|
});
|
||||||
} finally {
|
|
||||||
runGitCommandStub.restore();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("getFileOidsUnderPath handles empty output", async (t) => {
|
test("getFileOidsUnderPath handles empty output", async (t) => {
|
||||||
const runGitCommandStub = sinon
|
sinon.stub(gitUtils as any, "runGitCommand").resolves("");
|
||||||
.stub(gitUtils as any, "runGitCommand")
|
|
||||||
.resolves("");
|
|
||||||
|
|
||||||
try {
|
|
||||||
const result = await gitUtils.getFileOidsUnderPath("/fake/path");
|
const result = await gitUtils.getFileOidsUnderPath("/fake/path");
|
||||||
t.deepEqual(result, {});
|
t.deepEqual(result, {});
|
||||||
} finally {
|
|
||||||
runGitCommandStub.restore();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("getFileOidsUnderPath throws on unexpected output format", async (t) => {
|
test("getFileOidsUnderPath throws on unexpected output format", async (t) => {
|
||||||
const runGitCommandStub = sinon
|
sinon
|
||||||
.stub(gitUtils as any, "runGitCommand")
|
.stub(gitUtils as any, "runGitCommand")
|
||||||
.resolves(
|
.resolves(
|
||||||
"30d998ded095371488be3a729eb61d86ed721a18_lib/git-utils.js\n" +
|
"30d998ded095371488be3a729eb61d86ed721a18_lib/git-utils.js\n" +
|
||||||
@@ -378,7 +364,6 @@ test("getFileOidsUnderPath throws on unexpected output format", async (t) => {
|
|||||||
"a47c11f5bfdca7661942d2c8f1b7209fb0dfdf96_src/git-utils.ts",
|
"a47c11f5bfdca7661942d2c8f1b7209fb0dfdf96_src/git-utils.ts",
|
||||||
);
|
);
|
||||||
|
|
||||||
try {
|
|
||||||
await t.throwsAsync(
|
await t.throwsAsync(
|
||||||
async () => {
|
async () => {
|
||||||
await gitUtils.getFileOidsUnderPath("/fake/path");
|
await gitUtils.getFileOidsUnderPath("/fake/path");
|
||||||
@@ -388,7 +373,51 @@ test("getFileOidsUnderPath throws on unexpected output format", async (t) => {
|
|||||||
message: 'Unexpected "git ls-files" output: invalid-line-format',
|
message: 'Unexpected "git ls-files" output: invalid-line-format',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
} finally {
|
});
|
||||||
runGitCommandStub.restore();
|
|
||||||
}
|
test("getGitVersionOrThrow returns version for valid git output", async (t) => {
|
||||||
|
sinon.stub(gitUtils as any, "runGitCommand").resolves("git version 2.40.0\n");
|
||||||
|
|
||||||
|
const version = await gitUtils.getGitVersionOrThrow();
|
||||||
|
t.is(version, "2.40.0");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("getGitVersionOrThrow throws for invalid git output", async (t) => {
|
||||||
|
sinon.stub(gitUtils as any, "runGitCommand").resolves("invalid output");
|
||||||
|
|
||||||
|
await t.throwsAsync(
|
||||||
|
async () => {
|
||||||
|
await gitUtils.getGitVersionOrThrow();
|
||||||
|
},
|
||||||
|
{
|
||||||
|
instanceOf: Error,
|
||||||
|
message: "Could not parse Git version from output: invalid output",
|
||||||
|
},
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("getGitVersionOrThrow handles Windows-style git output", async (t) => {
|
||||||
|
sinon
|
||||||
|
.stub(gitUtils as any, "runGitCommand")
|
||||||
|
.resolves("git version 2.40.0.windows.1\n");
|
||||||
|
|
||||||
|
const version = await gitUtils.getGitVersionOrThrow();
|
||||||
|
// Should extract just the major.minor.patch portion
|
||||||
|
t.is(version, "2.40.0");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("getGitVersionOrThrow throws when git command fails", async (t) => {
|
||||||
|
sinon
|
||||||
|
.stub(gitUtils as any, "runGitCommand")
|
||||||
|
.rejects(new Error("git not found"));
|
||||||
|
|
||||||
|
await t.throwsAsync(
|
||||||
|
async () => {
|
||||||
|
await gitUtils.getGitVersionOrThrow();
|
||||||
|
},
|
||||||
|
{
|
||||||
|
instanceOf: Error,
|
||||||
|
message: "git not found",
|
||||||
|
},
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -9,6 +9,34 @@ import {
|
|||||||
} from "./actions-util";
|
} from "./actions-util";
|
||||||
import { ConfigurationError, getRequiredEnvParam } from "./util";
|
import { ConfigurationError, getRequiredEnvParam } from "./util";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Minimum Git version required for overlay analysis. The `git ls-files --format`
|
||||||
|
* option, which is used by `getFileOidsUnderPath`, was introduced in Git 2.38.0.
|
||||||
|
*/
|
||||||
|
export const GIT_MINIMUM_VERSION_FOR_OVERLAY = "2.38.0";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the version of Git installed on the system and throws an error if
|
||||||
|
* the version cannot be determined.
|
||||||
|
*
|
||||||
|
* @returns The Git version string (e.g., "2.40.0").
|
||||||
|
* @throws {Error} if the version could not be determined.
|
||||||
|
*/
|
||||||
|
export async function getGitVersionOrThrow(): Promise<string> {
|
||||||
|
const stdout = await runGitCommand(
|
||||||
|
undefined,
|
||||||
|
["--version"],
|
||||||
|
"Failed to get git version.",
|
||||||
|
);
|
||||||
|
// Git version output can vary: "git version 2.40.0" or "git version 2.40.0.windows.1"
|
||||||
|
// We capture just the major.minor.patch portion to ensure semver compatibility.
|
||||||
|
const match = stdout.match(/git version (\d+\.\d+\.\d+)/);
|
||||||
|
if (match?.[1]) {
|
||||||
|
return match[1];
|
||||||
|
}
|
||||||
|
throw new Error(`Could not parse Git version from output: ${stdout.trim()}`);
|
||||||
|
}
|
||||||
|
|
||||||
export const runGitCommand = async function (
|
export const runGitCommand = async function (
|
||||||
workingDirectory: string | undefined,
|
workingDirectory: string | undefined,
|
||||||
args: string[],
|
args: string[],
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import {
|
|||||||
flushDiagnostics,
|
flushDiagnostics,
|
||||||
logUnwrittenDiagnostics,
|
logUnwrittenDiagnostics,
|
||||||
makeDiagnostic,
|
makeDiagnostic,
|
||||||
|
makeTelemetryDiagnostic,
|
||||||
} from "./diagnostics";
|
} from "./diagnostics";
|
||||||
import { EnvVar } from "./environment";
|
import { EnvVar } from "./environment";
|
||||||
import { Feature, Features } from "./feature-flags";
|
import { Feature, Features } from "./feature-flags";
|
||||||
@@ -88,6 +89,13 @@ import {
|
|||||||
} from "./util";
|
} from "./util";
|
||||||
import { checkWorkflow } from "./workflow";
|
import { checkWorkflow } from "./workflow";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* First version of CodeQL where the Java extractor safely supports the option to minimize
|
||||||
|
* dependency jars. Note: some earlier versions of the extractor will respond to the corresponding
|
||||||
|
* option, but may rewrite jars in ways that lead to extraction errors.
|
||||||
|
*/
|
||||||
|
export const CODEQL_VERSION_JAR_MINIMIZATION = "2.23.0";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a status report indicating that the `init` Action is starting.
|
* Sends a status report indicating that the `init` Action is starting.
|
||||||
*
|
*
|
||||||
@@ -418,17 +426,10 @@ async function run() {
|
|||||||
// Arbitrarily choose the first language. We could also choose all languages, but that
|
// Arbitrarily choose the first language. We could also choose all languages, but that
|
||||||
// increases the risk of misinterpreting the data.
|
// increases the risk of misinterpreting the data.
|
||||||
config.languages[0],
|
config.languages[0],
|
||||||
makeDiagnostic(
|
makeTelemetryDiagnostic(
|
||||||
"codeql-action/bundle-download-telemetry",
|
"codeql-action/bundle-download-telemetry",
|
||||||
"CodeQL bundle download telemetry",
|
"CodeQL bundle download telemetry",
|
||||||
{
|
toolsDownloadStatusReport,
|
||||||
attributes: toolsDownloadStatusReport,
|
|
||||||
visibility: {
|
|
||||||
cliSummaryTable: false,
|
|
||||||
statusPage: false,
|
|
||||||
telemetry: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -638,18 +639,20 @@ async function run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the feature flag to minimize Java dependency jars is enabled, and we are doing a Java
|
// If we are doing a Java `build-mode: none` analysis, then set the environment variable that
|
||||||
// `build-mode: none` analysis (i.e. the flag is relevant), then set the environment variable
|
// enables the option in the Java extractor to minimize dependency jars. We also only do this if
|
||||||
// that enables the corresponding option in the Java extractor. We also only do this if
|
// dependency caching is enabled, since the option is intended to reduce the size of dependency
|
||||||
// dependency caching is enabled, since the option is intended to reduce the size of
|
// caches, but the jar-rewriting does have a performance cost that we'd like to avoid when
|
||||||
// dependency caches, but the jar-rewriting does have a performance cost that we'd like to avoid
|
// caching is not being used.
|
||||||
// when caching is not being used.
|
// TODO: Remove this language-specific mechanism and replace it with a more general one that
|
||||||
|
// tells extractors when dependency caching is enabled, and then the Java extractor can make its
|
||||||
|
// own decision about whether to rewrite jars.
|
||||||
if (process.env[EnvVar.JAVA_EXTRACTOR_MINIMIZE_DEPENDENCY_JARS]) {
|
if (process.env[EnvVar.JAVA_EXTRACTOR_MINIMIZE_DEPENDENCY_JARS]) {
|
||||||
logger.debug(
|
logger.debug(
|
||||||
`${EnvVar.JAVA_EXTRACTOR_MINIMIZE_DEPENDENCY_JARS} is already set to '${process.env[EnvVar.JAVA_EXTRACTOR_MINIMIZE_DEPENDENCY_JARS]}', so the Action will not override it.`,
|
`${EnvVar.JAVA_EXTRACTOR_MINIMIZE_DEPENDENCY_JARS} is already set to '${process.env[EnvVar.JAVA_EXTRACTOR_MINIMIZE_DEPENDENCY_JARS]}', so the Action will not override it.`,
|
||||||
);
|
);
|
||||||
} else if (
|
} else if (
|
||||||
(await features.getValue(Feature.JavaMinimizeDependencyJars, codeql)) &&
|
(await codeQlVersionAtLeast(codeql, CODEQL_VERSION_JAR_MINIMIZATION)) &&
|
||||||
config.dependencyCachingEnabled &&
|
config.dependencyCachingEnabled &&
|
||||||
config.buildMode === BuildMode.None &&
|
config.buildMode === BuildMode.None &&
|
||||||
config.languages.includes(KnownLanguage.java)
|
config.languages.includes(KnownLanguage.java)
|
||||||
@@ -785,17 +788,10 @@ async function recordZstdAvailability(
|
|||||||
// Arbitrarily choose the first language. We could also choose all languages, but that
|
// Arbitrarily choose the first language. We could also choose all languages, but that
|
||||||
// increases the risk of misinterpreting the data.
|
// increases the risk of misinterpreting the data.
|
||||||
config.languages[0],
|
config.languages[0],
|
||||||
makeDiagnostic(
|
makeTelemetryDiagnostic(
|
||||||
"codeql-action/zstd-availability",
|
"codeql-action/zstd-availability",
|
||||||
"Zstandard availability",
|
"Zstandard availability",
|
||||||
{
|
zstdAvailability,
|
||||||
attributes: zstdAvailability,
|
|
||||||
visibility: {
|
|
||||||
cliSummaryTable: false,
|
|
||||||
statusPage: false,
|
|
||||||
telemetry: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,9 @@ import * as sinon from "sinon";
|
|||||||
|
|
||||||
import * as actionsUtil from "./actions-util";
|
import * as actionsUtil from "./actions-util";
|
||||||
import * as apiClient from "./api-client";
|
import * as apiClient from "./api-client";
|
||||||
|
import { ResolveDatabaseOutput } from "./codeql";
|
||||||
import * as gitUtils from "./git-utils";
|
import * as gitUtils from "./git-utils";
|
||||||
|
import { KnownLanguage } from "./languages";
|
||||||
import { getRunnerLogger } from "./logging";
|
import { getRunnerLogger } from "./logging";
|
||||||
import {
|
import {
|
||||||
downloadOverlayBaseDatabaseFromCache,
|
downloadOverlayBaseDatabaseFromCache,
|
||||||
@@ -95,6 +97,7 @@ interface DownloadOverlayBaseDatabaseTestCase {
|
|||||||
hasBaseDatabaseOidsFile: boolean;
|
hasBaseDatabaseOidsFile: boolean;
|
||||||
tryGetFolderBytesSucceeds: boolean;
|
tryGetFolderBytesSucceeds: boolean;
|
||||||
codeQLVersion: string;
|
codeQLVersion: string;
|
||||||
|
resolveDatabaseOutput: ResolveDatabaseOutput | Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultDownloadTestCase: DownloadOverlayBaseDatabaseTestCase = {
|
const defaultDownloadTestCase: DownloadOverlayBaseDatabaseTestCase = {
|
||||||
@@ -105,6 +108,7 @@ const defaultDownloadTestCase: DownloadOverlayBaseDatabaseTestCase = {
|
|||||||
hasBaseDatabaseOidsFile: true,
|
hasBaseDatabaseOidsFile: true,
|
||||||
tryGetFolderBytesSucceeds: true,
|
tryGetFolderBytesSucceeds: true,
|
||||||
codeQLVersion: "2.20.5",
|
codeQLVersion: "2.20.5",
|
||||||
|
resolveDatabaseOutput: { overlayBaseSpecifier: "20250626:XXX" },
|
||||||
};
|
};
|
||||||
|
|
||||||
const testDownloadOverlayBaseDatabaseFromCache = test.macro({
|
const testDownloadOverlayBaseDatabaseFromCache = test.macro({
|
||||||
@@ -119,9 +123,11 @@ const testDownloadOverlayBaseDatabaseFromCache = test.macro({
|
|||||||
await fs.promises.mkdir(dbLocation, { recursive: true });
|
await fs.promises.mkdir(dbLocation, { recursive: true });
|
||||||
|
|
||||||
const logger = getRunnerLogger(true);
|
const logger = getRunnerLogger(true);
|
||||||
const config = createTestConfig({ dbLocation });
|
|
||||||
|
|
||||||
const testCase = { ...defaultDownloadTestCase, ...partialTestCase };
|
const testCase = { ...defaultDownloadTestCase, ...partialTestCase };
|
||||||
|
const config = createTestConfig({
|
||||||
|
dbLocation,
|
||||||
|
languages: [KnownLanguage.java],
|
||||||
|
});
|
||||||
|
|
||||||
config.overlayDatabaseMode = testCase.overlayDatabaseMode;
|
config.overlayDatabaseMode = testCase.overlayDatabaseMode;
|
||||||
config.useOverlayDatabaseCaching = testCase.useOverlayDatabaseCaching;
|
config.useOverlayDatabaseCaching = testCase.useOverlayDatabaseCaching;
|
||||||
@@ -163,9 +169,23 @@ const testDownloadOverlayBaseDatabaseFromCache = test.macro({
|
|||||||
.resolves(testCase.tryGetFolderBytesSucceeds ? 1024 * 1024 : undefined);
|
.resolves(testCase.tryGetFolderBytesSucceeds ? 1024 * 1024 : undefined);
|
||||||
stubs.push(tryGetFolderBytesStub);
|
stubs.push(tryGetFolderBytesStub);
|
||||||
|
|
||||||
|
const codeql = mockCodeQLVersion(testCase.codeQLVersion);
|
||||||
|
|
||||||
|
if (testCase.resolveDatabaseOutput instanceof Error) {
|
||||||
|
const resolveDatabaseStub = sinon
|
||||||
|
.stub(codeql, "resolveDatabase")
|
||||||
|
.rejects(testCase.resolveDatabaseOutput);
|
||||||
|
stubs.push(resolveDatabaseStub);
|
||||||
|
} else {
|
||||||
|
const resolveDatabaseStub = sinon
|
||||||
|
.stub(codeql, "resolveDatabase")
|
||||||
|
.resolves(testCase.resolveDatabaseOutput);
|
||||||
|
stubs.push(resolveDatabaseStub);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await downloadOverlayBaseDatabaseFromCache(
|
const result = await downloadOverlayBaseDatabaseFromCache(
|
||||||
mockCodeQLVersion(testCase.codeQLVersion),
|
codeql,
|
||||||
config,
|
config,
|
||||||
logger,
|
logger,
|
||||||
);
|
);
|
||||||
@@ -255,6 +275,24 @@ test(
|
|||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
test(
|
||||||
|
testDownloadOverlayBaseDatabaseFromCache,
|
||||||
|
"returns undefined when downloaded database doesn't have an overlayBaseSpecifier",
|
||||||
|
{
|
||||||
|
resolveDatabaseOutput: {},
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
|
||||||
|
test(
|
||||||
|
testDownloadOverlayBaseDatabaseFromCache,
|
||||||
|
"returns undefined when resolving database metadata fails",
|
||||||
|
{
|
||||||
|
resolveDatabaseOutput: new Error("Failed to resolve database metadata"),
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
|
||||||
test(
|
test(
|
||||||
testDownloadOverlayBaseDatabaseFromCache,
|
testDownloadOverlayBaseDatabaseFromCache,
|
||||||
"returns undefined when filesystem error occurs",
|
"returns undefined when filesystem error occurs",
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import { getCommitOid, getFileOidsUnderPath } from "./git-utils";
|
|||||||
import { Logger, withGroupAsync } from "./logging";
|
import { Logger, withGroupAsync } from "./logging";
|
||||||
import {
|
import {
|
||||||
CleanupLevel,
|
CleanupLevel,
|
||||||
|
getCodeQLDatabasePath,
|
||||||
getErrorMessage,
|
getErrorMessage,
|
||||||
isInTestMode,
|
isInTestMode,
|
||||||
tryGetFolderBytes,
|
tryGetFolderBytes,
|
||||||
@@ -176,11 +177,12 @@ const MAX_CACHE_OPERATION_MS = 600_000;
|
|||||||
* @param warningPrefix Prefix for the check failure warning message
|
* @param warningPrefix Prefix for the check failure warning message
|
||||||
* @returns True if the verification succeeded, false otherwise
|
* @returns True if the verification succeeded, false otherwise
|
||||||
*/
|
*/
|
||||||
function checkOverlayBaseDatabase(
|
async function checkOverlayBaseDatabase(
|
||||||
|
codeql: CodeQL,
|
||||||
config: Config,
|
config: Config,
|
||||||
logger: Logger,
|
logger: Logger,
|
||||||
warningPrefix: string,
|
warningPrefix: string,
|
||||||
): boolean {
|
): Promise<boolean> {
|
||||||
// An overlay-base database should contain the base database OIDs file.
|
// An overlay-base database should contain the base database OIDs file.
|
||||||
const baseDatabaseOidsFilePath = getBaseDatabaseOidsFilePath(config);
|
const baseDatabaseOidsFilePath = getBaseDatabaseOidsFilePath(config);
|
||||||
if (!fs.existsSync(baseDatabaseOidsFilePath)) {
|
if (!fs.existsSync(baseDatabaseOidsFilePath)) {
|
||||||
@@ -189,6 +191,29 @@ function checkOverlayBaseDatabase(
|
|||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const language of config.languages) {
|
||||||
|
const dbPath = getCodeQLDatabasePath(config, language);
|
||||||
|
try {
|
||||||
|
const resolveDatabaseOutput = await codeql.resolveDatabase(dbPath);
|
||||||
|
if (
|
||||||
|
resolveDatabaseOutput === undefined ||
|
||||||
|
!("overlayBaseSpecifier" in resolveDatabaseOutput)
|
||||||
|
) {
|
||||||
|
logger.info(`${warningPrefix}: no overlayBaseSpecifier defined`);
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
logger.debug(
|
||||||
|
`Overlay base specifier for ${language} overlay-base database found: ` +
|
||||||
|
`${resolveDatabaseOutput.overlayBaseSpecifier}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
logger.warning(`${warningPrefix}: failed to resolve database: ${e}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,7 +257,8 @@ export async function cleanupAndUploadOverlayBaseDatabaseToCache(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const databaseIsValid = checkOverlayBaseDatabase(
|
const databaseIsValid = await checkOverlayBaseDatabase(
|
||||||
|
codeql,
|
||||||
config,
|
config,
|
||||||
logger,
|
logger,
|
||||||
"Abort uploading overlay-base database to cache",
|
"Abort uploading overlay-base database to cache",
|
||||||
@@ -415,7 +441,8 @@ export async function downloadOverlayBaseDatabaseFromCache(
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
const databaseIsValid = checkOverlayBaseDatabase(
|
const databaseIsValid = await checkOverlayBaseDatabase(
|
||||||
|
codeql,
|
||||||
config,
|
config,
|
||||||
logger,
|
logger,
|
||||||
"Downloaded overlay-base database is invalid",
|
"Downloaded overlay-base database is invalid",
|
||||||
|
|||||||
@@ -511,7 +511,7 @@ export async function getCodeQLSource(
|
|||||||
// different version to save download time if the version hasn't been
|
// different version to save download time if the version hasn't been
|
||||||
// specified explicitly (in which case we always honor it).
|
// specified explicitly (in which case we always honor it).
|
||||||
if (
|
if (
|
||||||
variant !== util.GitHubVariant.DOTCOM &&
|
variant === util.GitHubVariant.GHES &&
|
||||||
!forceShippedTools &&
|
!forceShippedTools &&
|
||||||
!toolsInput
|
!toolsInput
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -433,8 +433,8 @@ function formatGitHubVersion(version: util.GitHubVersion): string {
|
|||||||
switch (version.type) {
|
switch (version.type) {
|
||||||
case util.GitHubVariant.DOTCOM:
|
case util.GitHubVariant.DOTCOM:
|
||||||
return "dotcom";
|
return "dotcom";
|
||||||
case util.GitHubVariant.GHE_DOTCOM:
|
case util.GitHubVariant.GHEC_DR:
|
||||||
return "GHE dotcom";
|
return "GHEC-DR";
|
||||||
case util.GitHubVariant.GHES:
|
case util.GitHubVariant.GHES:
|
||||||
return `GHES ${version.version}`;
|
return `GHES ${version.version}`;
|
||||||
default:
|
default:
|
||||||
@@ -445,12 +445,12 @@ function formatGitHubVersion(version: util.GitHubVersion): string {
|
|||||||
const CHECK_ACTION_VERSION_TESTS: Array<[string, util.GitHubVersion, boolean]> =
|
const CHECK_ACTION_VERSION_TESTS: Array<[string, util.GitHubVersion, boolean]> =
|
||||||
[
|
[
|
||||||
["2.2.1", { type: util.GitHubVariant.DOTCOM }, true],
|
["2.2.1", { type: util.GitHubVariant.DOTCOM }, true],
|
||||||
["2.2.1", { type: util.GitHubVariant.GHE_DOTCOM }, true],
|
["2.2.1", { type: util.GitHubVariant.GHEC_DR }, true],
|
||||||
["2.2.1", { type: util.GitHubVariant.GHES, version: "3.10" }, false],
|
["2.2.1", { type: util.GitHubVariant.GHES, version: "3.10" }, false],
|
||||||
["2.2.1", { type: util.GitHubVariant.GHES, version: "3.11" }, false],
|
["2.2.1", { type: util.GitHubVariant.GHES, version: "3.11" }, false],
|
||||||
["2.2.1", { type: util.GitHubVariant.GHES, version: "3.12" }, false],
|
["2.2.1", { type: util.GitHubVariant.GHES, version: "3.12" }, false],
|
||||||
["3.2.1", { type: util.GitHubVariant.DOTCOM }, true],
|
["3.2.1", { type: util.GitHubVariant.DOTCOM }, true],
|
||||||
["3.2.1", { type: util.GitHubVariant.GHE_DOTCOM }, true],
|
["3.2.1", { type: util.GitHubVariant.GHEC_DR }, true],
|
||||||
["3.2.1", { type: util.GitHubVariant.GHES, version: "3.10" }, false],
|
["3.2.1", { type: util.GitHubVariant.GHES, version: "3.10" }, false],
|
||||||
["3.2.1", { type: util.GitHubVariant.GHES, version: "3.11" }, false],
|
["3.2.1", { type: util.GitHubVariant.GHES, version: "3.11" }, false],
|
||||||
["3.2.1", { type: util.GitHubVariant.GHES, version: "3.12" }, false],
|
["3.2.1", { type: util.GitHubVariant.GHES, version: "3.12" }, false],
|
||||||
@@ -458,7 +458,7 @@ const CHECK_ACTION_VERSION_TESTS: Array<[string, util.GitHubVersion, boolean]> =
|
|||||||
["3.2.1", { type: util.GitHubVariant.GHES, version: "3.20" }, true],
|
["3.2.1", { type: util.GitHubVariant.GHES, version: "3.20" }, true],
|
||||||
["3.2.1", { type: util.GitHubVariant.GHES, version: "3.21" }, true],
|
["3.2.1", { type: util.GitHubVariant.GHES, version: "3.21" }, true],
|
||||||
["4.2.1", { type: util.GitHubVariant.DOTCOM }, false],
|
["4.2.1", { type: util.GitHubVariant.DOTCOM }, false],
|
||||||
["4.2.1", { type: util.GitHubVariant.GHE_DOTCOM }, false],
|
["4.2.1", { type: util.GitHubVariant.GHEC_DR }, false],
|
||||||
["4.2.1", { type: util.GitHubVariant.GHES, version: "3.19" }, false],
|
["4.2.1", { type: util.GitHubVariant.GHES, version: "3.19" }, false],
|
||||||
["4.2.1", { type: util.GitHubVariant.GHES, version: "3.20" }, false],
|
["4.2.1", { type: util.GitHubVariant.GHES, version: "3.20" }, false],
|
||||||
["4.2.1", { type: util.GitHubVariant.GHES, version: "3.21" }, false],
|
["4.2.1", { type: util.GitHubVariant.GHES, version: "3.21" }, false],
|
||||||
|
|||||||
14
src/util.ts
14
src/util.ts
@@ -556,13 +556,17 @@ const CODEQL_ACTION_WARNED_ABOUT_VERSION_ENV_VAR =
|
|||||||
let hasBeenWarnedAboutVersion = false;
|
let hasBeenWarnedAboutVersion = false;
|
||||||
|
|
||||||
export enum GitHubVariant {
|
export enum GitHubVariant {
|
||||||
DOTCOM,
|
/** [GitHub.com](https://github.com) */
|
||||||
GHES,
|
DOTCOM = "GitHub.com",
|
||||||
GHE_DOTCOM,
|
/** [GitHub Enterprise Server](https://docs.github.com/en/enterprise-server@latest/admin/overview/about-github-enterprise-server) */
|
||||||
|
GHES = "GitHub Enterprise Server",
|
||||||
|
/** [GitHub Enterprise Cloud with data residency](https://docs.github.com/en/enterprise-cloud@latest/admin/data-residency/about-github-enterprise-cloud-with-data-residency) */
|
||||||
|
GHEC_DR = "GitHub Enterprise Cloud with data residency",
|
||||||
}
|
}
|
||||||
|
|
||||||
export type GitHubVersion =
|
export type GitHubVersion =
|
||||||
| { type: GitHubVariant.DOTCOM }
|
| { type: GitHubVariant.DOTCOM }
|
||||||
| { type: GitHubVariant.GHE_DOTCOM }
|
| { type: GitHubVariant.GHEC_DR }
|
||||||
| { type: GitHubVariant.GHES; version: string };
|
| { type: GitHubVariant.GHES; version: string };
|
||||||
|
|
||||||
export function checkGitHubVersionInRange(
|
export function checkGitHubVersionInRange(
|
||||||
@@ -1105,7 +1109,7 @@ export function checkActionVersion(
|
|||||||
// and should update to CodeQL Action v4.
|
// and should update to CodeQL Action v4.
|
||||||
if (
|
if (
|
||||||
githubVersion.type === GitHubVariant.DOTCOM ||
|
githubVersion.type === GitHubVariant.DOTCOM ||
|
||||||
githubVersion.type === GitHubVariant.GHE_DOTCOM ||
|
githubVersion.type === GitHubVariant.GHEC_DR ||
|
||||||
(githubVersion.type === GitHubVariant.GHES &&
|
(githubVersion.type === GitHubVariant.GHES &&
|
||||||
semver.satisfies(
|
semver.satisfies(
|
||||||
semver.coerce(githubVersion.version) ?? "0.0.0",
|
semver.coerce(githubVersion.version) ?? "0.0.0",
|
||||||
|
|||||||
Reference in New Issue
Block a user