mirror of
https://github.com/github/codeql-action.git
synced 2025-12-08 16:58:06 +08:00
Compare commits
41 Commits
v1.1.4
...
codeql-bun
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
81bfc289f5 | ||
|
|
6de8537e54 | ||
|
|
1d81ec489b | ||
|
|
c592f89989 | ||
|
|
f71aeef4dc | ||
|
|
0a713019c3 | ||
|
|
243ebf6e35 | ||
|
|
3886398541 | ||
|
|
f60bb5cc38 | ||
|
|
d0ee2b4276 | ||
|
|
34905f691e | ||
|
|
ac7bd44c3b | ||
|
|
1457c164a9 | ||
|
|
8834766498 | ||
|
|
69a58ad266 | ||
|
|
5b59d8784d | ||
|
|
ea5898d606 | ||
|
|
39aa619399 | ||
|
|
2190825ac9 | ||
|
|
e61a4b9c7c | ||
|
|
b74506c7c2 | ||
|
|
e27fa67f0f | ||
|
|
eb507cfac6 | ||
|
|
c33cdd74b3 | ||
|
|
aeefdce612 | ||
|
|
761da7eb50 | ||
|
|
560edbc33e | ||
|
|
e64a215b41 | ||
|
|
e437ea1d38 | ||
|
|
8ecc1fcbc4 | ||
|
|
0b3acf68ab | ||
|
|
480ef7689f | ||
|
|
4e2634f2fd | ||
|
|
04d521d705 | ||
|
|
cdf3c9d01e | ||
|
|
628afae9d3 | ||
|
|
111428ce06 | ||
|
|
d2fd19b7d7 | ||
|
|
c825c24663 | ||
|
|
0e0e934038 | ||
|
|
d430deb927 |
1
.github/workflows/__analyze-ref-input.yml
generated
vendored
1
.github/workflows/__analyze-ref-input.yml
generated
vendored
@@ -65,6 +65,7 @@ jobs:
|
||||
- os: windows-2022
|
||||
version: nightly-latest
|
||||
name: "Analyze: 'ref' and 'sha' from inputs"
|
||||
timeout-minutes: 30
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Check out repository
|
||||
|
||||
1
.github/workflows/__debug-artifacts.yml
generated
vendored
1
.github/workflows/__debug-artifacts.yml
generated
vendored
@@ -49,6 +49,7 @@ jobs:
|
||||
- os: macos-latest
|
||||
version: nightly-latest
|
||||
name: Debug artifact upload
|
||||
timeout-minutes: 30
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Check out repository
|
||||
|
||||
1
.github/workflows/__extractor-ram-threads.yml
generated
vendored
1
.github/workflows/__extractor-ram-threads.yml
generated
vendored
@@ -27,6 +27,7 @@ jobs:
|
||||
- os: ubuntu-latest
|
||||
version: latest
|
||||
name: Extractor ram and threads options test
|
||||
timeout-minutes: 30
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Check out repository
|
||||
|
||||
1
.github/workflows/__go-custom-queries.yml
generated
vendored
1
.github/workflows/__go-custom-queries.yml
generated
vendored
@@ -65,6 +65,7 @@ jobs:
|
||||
- os: windows-2022
|
||||
version: nightly-latest
|
||||
name: 'Go: Custom queries'
|
||||
timeout-minutes: 30
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Check out repository
|
||||
|
||||
1
.github/workflows/__go-custom-tracing-autobuild.yml
generated
vendored
1
.github/workflows/__go-custom-tracing-autobuild.yml
generated
vendored
@@ -49,6 +49,7 @@ jobs:
|
||||
- os: macos-latest
|
||||
version: nightly-latest
|
||||
name: 'Go: Autobuild custom tracing'
|
||||
timeout-minutes: 30
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Check out repository
|
||||
|
||||
1
.github/workflows/__go-custom-tracing.yml
generated
vendored
1
.github/workflows/__go-custom-tracing.yml
generated
vendored
@@ -65,6 +65,7 @@ jobs:
|
||||
- os: windows-2022
|
||||
version: nightly-latest
|
||||
name: 'Go: Custom tracing'
|
||||
timeout-minutes: 30
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Check out repository
|
||||
|
||||
1
.github/workflows/__javascript-source-root.yml
generated
vendored
1
.github/workflows/__javascript-source-root.yml
generated
vendored
@@ -31,6 +31,7 @@ jobs:
|
||||
- os: ubuntu-latest
|
||||
version: nightly-latest
|
||||
name: Custom source root
|
||||
timeout-minutes: 30
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Check out repository
|
||||
|
||||
1
.github/workflows/__multi-language-autodetect.yml
generated
vendored
1
.github/workflows/__multi-language-autodetect.yml
generated
vendored
@@ -49,6 +49,7 @@ jobs:
|
||||
- os: macos-latest
|
||||
version: nightly-latest
|
||||
name: Multi-language repository
|
||||
timeout-minutes: 30
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Check out repository
|
||||
|
||||
1
.github/workflows/__packaging-config-inputs-js.yml
generated
vendored
1
.github/workflows/__packaging-config-inputs-js.yml
generated
vendored
@@ -29,6 +29,7 @@ jobs:
|
||||
- os: macos-latest
|
||||
version: nightly-20210831
|
||||
name: 'Packaging: Config and input'
|
||||
timeout-minutes: 30
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Check out repository
|
||||
|
||||
1
.github/workflows/__packaging-config-js.yml
generated
vendored
1
.github/workflows/__packaging-config-js.yml
generated
vendored
@@ -29,6 +29,7 @@ jobs:
|
||||
- os: macos-latest
|
||||
version: nightly-20210831
|
||||
name: 'Packaging: Config file'
|
||||
timeout-minutes: 30
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Check out repository
|
||||
|
||||
1
.github/workflows/__packaging-inputs-js.yml
generated
vendored
1
.github/workflows/__packaging-inputs-js.yml
generated
vendored
@@ -29,6 +29,7 @@ jobs:
|
||||
- os: macos-latest
|
||||
version: nightly-20210831
|
||||
name: 'Packaging: Action input'
|
||||
timeout-minutes: 30
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Check out repository
|
||||
|
||||
1
.github/workflows/__remote-config.yml
generated
vendored
1
.github/workflows/__remote-config.yml
generated
vendored
@@ -65,6 +65,7 @@ jobs:
|
||||
- os: windows-2022
|
||||
version: nightly-latest
|
||||
name: Remote config file
|
||||
timeout-minutes: 30
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Check out repository
|
||||
|
||||
1
.github/workflows/__rubocop-multi-language.yml
generated
vendored
1
.github/workflows/__rubocop-multi-language.yml
generated
vendored
@@ -37,6 +37,7 @@ jobs:
|
||||
- os: ubuntu-latest
|
||||
version: nightly-latest
|
||||
name: RuboCop multi-language
|
||||
timeout-minutes: 30
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Check out repository
|
||||
|
||||
1
.github/workflows/__split-workflow.yml
generated
vendored
1
.github/workflows/__split-workflow.yml
generated
vendored
@@ -29,6 +29,7 @@ jobs:
|
||||
- os: macos-latest
|
||||
version: nightly-20210831
|
||||
name: Split workflow
|
||||
timeout-minutes: 30
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Check out repository
|
||||
|
||||
1
.github/workflows/__test-local-codeql.yml
generated
vendored
1
.github/workflows/__test-local-codeql.yml
generated
vendored
@@ -27,6 +27,7 @@ jobs:
|
||||
- os: ubuntu-latest
|
||||
version: nightly-latest
|
||||
name: Local CodeQL bundle
|
||||
timeout-minutes: 30
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Check out repository
|
||||
|
||||
1
.github/workflows/__test-proxy.yml
generated
vendored
1
.github/workflows/__test-proxy.yml
generated
vendored
@@ -27,6 +27,7 @@ jobs:
|
||||
- os: ubuntu-latest
|
||||
version: latest
|
||||
name: Proxy test
|
||||
timeout-minutes: 30
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Check out repository
|
||||
|
||||
1
.github/workflows/__test-ruby.yml
generated
vendored
1
.github/workflows/__test-ruby.yml
generated
vendored
@@ -37,6 +37,7 @@ jobs:
|
||||
- os: macos-latest
|
||||
version: nightly-latest
|
||||
name: Ruby analysis
|
||||
timeout-minutes: 30
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Check out repository
|
||||
|
||||
1
.github/workflows/__unset-environment.yml
generated
vendored
1
.github/workflows/__unset-environment.yml
generated
vendored
@@ -37,6 +37,7 @@ jobs:
|
||||
- os: ubuntu-latest
|
||||
version: nightly-latest
|
||||
name: Test unsetting environment variables
|
||||
timeout-minutes: 30
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Check out repository
|
||||
|
||||
1
.github/workflows/__upload-ref-sha-input.yml
generated
vendored
1
.github/workflows/__upload-ref-sha-input.yml
generated
vendored
@@ -65,6 +65,7 @@ jobs:
|
||||
- os: windows-2022
|
||||
version: nightly-latest
|
||||
name: "Upload-sarif: 'ref' and 'sha' from inputs"
|
||||
timeout-minutes: 30
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Check out repository
|
||||
|
||||
@@ -20,6 +20,6 @@ jobs:
|
||||
run: |
|
||||
bundle_version="$(cat "./src/defaults.json" | jq -r ".bundleVersion")"
|
||||
set -x
|
||||
for expected_file in "codeql-bundle.tar.gz" "codeql-bundle-linux64.tar.gz" "codeql-bundle-osx64.tar.gz" "codeql-bundle-win64.tar.gz" "codeql-runner-linux" "codeql-runner-macos" "codeql-runner-win.exe"; do
|
||||
for expected_file in "codeql-bundle.tar.gz" "codeql-bundle-linux64.tar.gz" "codeql-bundle-osx64.tar.gz" "codeql-bundle-win64.tar.gz"; do
|
||||
curl --location --fail --head --request GET "https://github.com/github/codeql-action/releases/download/$bundle_version/$expected_file" > /dev/null
|
||||
done
|
||||
|
||||
16
.github/workflows/pr-checks.yml
vendored
16
.github/workflows/pr-checks.yml
vendored
@@ -13,6 +13,7 @@ jobs:
|
||||
lint-js:
|
||||
name: Lint
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
@@ -21,6 +22,7 @@ jobs:
|
||||
|
||||
check-js:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
@@ -30,6 +32,7 @@ jobs:
|
||||
check-node-modules:
|
||||
name: Check modules up to date
|
||||
runs-on: macos-latest
|
||||
timeout-minutes: 30
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
@@ -39,6 +42,7 @@ jobs:
|
||||
verify-pr-checks:
|
||||
name: Verify PR checks up to date
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
@@ -60,6 +64,7 @@ jobs:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
timeout-minutes: 30
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
@@ -69,6 +74,7 @@ jobs:
|
||||
runner-analyze-javascript-ubuntu:
|
||||
name: Runner ubuntu JS analyze
|
||||
needs: [check-js, check-node-modules]
|
||||
timeout-minutes: 30
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
@@ -97,6 +103,7 @@ jobs:
|
||||
runner-analyze-javascript-windows:
|
||||
name: Runner windows JS analyze
|
||||
needs: [check-js, check-node-modules]
|
||||
timeout-minutes: 30
|
||||
runs-on: windows-latest
|
||||
|
||||
steps:
|
||||
@@ -121,6 +128,7 @@ jobs:
|
||||
runner-analyze-javascript-macos:
|
||||
name: Runner macos JS analyze
|
||||
needs: [check-js, check-node-modules]
|
||||
timeout-minutes: 30
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
@@ -145,6 +153,7 @@ jobs:
|
||||
runner-analyze-csharp-ubuntu:
|
||||
name: Runner ubuntu C# analyze
|
||||
needs: [check-js, check-node-modules]
|
||||
timeout-minutes: 30
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
@@ -184,6 +193,7 @@ jobs:
|
||||
needs: [check-js, check-node-modules]
|
||||
# Build tracing currently does not support Windows 2022, so use `windows-2019` instead of
|
||||
# `windows-latest`.
|
||||
timeout-minutes: 30
|
||||
runs-on: windows-2019
|
||||
|
||||
steps:
|
||||
@@ -228,6 +238,7 @@ jobs:
|
||||
|
||||
runner-analyze-csharp-macos:
|
||||
name: Runner macos C# analyze
|
||||
timeout-minutes: 30
|
||||
needs: [check-js, check-node-modules]
|
||||
runs-on: macos-latest
|
||||
|
||||
@@ -266,6 +277,7 @@ jobs:
|
||||
|
||||
runner-analyze-csharp-autobuild-ubuntu:
|
||||
name: Runner ubuntu autobuild C# analyze
|
||||
timeout-minutes: 30
|
||||
needs: [check-js, check-node-modules]
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
@@ -301,6 +313,7 @@ jobs:
|
||||
TEST_MODE: true
|
||||
|
||||
runner-analyze-csharp-autobuild-windows:
|
||||
timeout-minutes: 30
|
||||
name: Runner windows autobuild C# analyze
|
||||
needs: [check-js, check-node-modules]
|
||||
# Build tracing currently does not support Windows 2022, so use `windows-2019` instead of
|
||||
@@ -343,6 +356,7 @@ jobs:
|
||||
name: Runner macos autobuild C# analyze
|
||||
needs: [check-js, check-node-modules]
|
||||
runs-on: macos-latest
|
||||
timeout-minutes: 30
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
@@ -380,6 +394,7 @@ jobs:
|
||||
name: Runner upload sarif
|
||||
needs: [check-js, check-node-modules]
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
|
||||
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id }}
|
||||
|
||||
@@ -402,6 +417,7 @@ jobs:
|
||||
name: Runner ubuntu extractor RAM and threads options
|
||||
needs: [check-js, check-node-modules]
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
1
.github/workflows/python-deps.yml
vendored
1
.github/workflows/python-deps.yml
vendored
@@ -10,6 +10,7 @@ on:
|
||||
|
||||
jobs:
|
||||
test-setup-python-scripts:
|
||||
timeout-minutes: 30
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
|
||||
1
.github/workflows/release-runner.yml
vendored
1
.github/workflows/release-runner.yml
vendored
@@ -9,6 +9,7 @@ on:
|
||||
|
||||
jobs:
|
||||
release-runner:
|
||||
timeout-minutes: 30
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
RELEASE_TAG: "${{ github.event.inputs.bundle-tag }}"
|
||||
|
||||
1
.github/workflows/split.yml
vendored
1
.github/workflows/split.yml
vendored
@@ -26,6 +26,7 @@ on:
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
env:
|
||||
CLI_RELEASE: "${{ github.event.inputs.cli-release }}"
|
||||
RELEASE_TAG: "${{ github.event.inputs.bundle-tag }}"
|
||||
|
||||
1
.github/workflows/update-dependencies.yml
vendored
1
.github/workflows/update-dependencies.yml
vendored
@@ -6,6 +6,7 @@ on:
|
||||
jobs:
|
||||
update:
|
||||
name: Update dependencies
|
||||
timeout-minutes: 30
|
||||
runs-on: macos-latest
|
||||
if: contains(github.event.pull_request.labels.*.name, 'Update dependencies') && (github.event.pull_request.head.repo.full_name == 'github/codeql-action')
|
||||
steps:
|
||||
|
||||
1
.github/workflows/update-release-branch.yml
vendored
1
.github/workflows/update-release-branch.yml
vendored
@@ -9,6 +9,7 @@ on:
|
||||
|
||||
jobs:
|
||||
update:
|
||||
timeout-minutes: 30
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ github.repository == 'github/codeql-action' }}
|
||||
steps:
|
||||
|
||||
@@ -6,6 +6,8 @@ on:
|
||||
|
||||
jobs:
|
||||
update-supported-enterprise-server-versions:
|
||||
name: Update Supported Enterprise Server Versions
|
||||
timeout-minutes: 30
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ github.repository == 'github/codeql-action' }}
|
||||
|
||||
|
||||
14
CHANGELOG.md
14
CHANGELOG.md
@@ -1,4 +1,16 @@
|
||||
# CodeQL Action and CodeQL Runner Changelog
|
||||
# CodeQL Action Changelog
|
||||
|
||||
## [UNRELEASED]
|
||||
|
||||
No user facing changes.
|
||||
|
||||
## 1.1.5 - 15 Mar 2022
|
||||
|
||||
- Update default CodeQL bundle version to 2.8.3.
|
||||
- The CodeQL runner is now deprecated and no longer being released. For more information, see [CodeQL runner deprecation](https://github.blog/changelog/2021-09-21-codeql-runner-deprecation/).
|
||||
- Fix two bugs that cause action failures with GHES 3.3 or earlier. [#978](https://github.com/github/codeql-action/pull/978)
|
||||
- Fix `not a permitted key` invalid requests with GHES 3.1 or earlier
|
||||
- Fix `RUNNER_ARCH environment variable must be set` errors with GHES 3.3 or earlier
|
||||
|
||||
## 1.1.4 - 07 Mar 2022
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ Here are a few things you can do that will increase the likelihood of your pull
|
||||
1. The first step of releasing a new version of the `codeql-action` is running the "Update release branch" workflow.
|
||||
This workflow goes through the pull requests that have been merged to `main` since the last release, creates a changelog, then opens a pull request to merge the changes since the last release into the `v1` release branch.
|
||||
|
||||
A release is automatically started every Monday via a scheduled run of this workflow, however you can start a release manually by triggering a run via [workflow dispatch](https://github.com/github/codeql-action/actions/workflows/update-release-branch.yml).
|
||||
A release is automatically started every Monday via a scheduled run of this workflow, however you can start a release manually by triggering a run via [workflow dispatch](https://github.com/github/codeql-action/actions/workflows/update-release-branch.yml).
|
||||
1. The workflow run will open a pull request titled "Merge main into v1". Mark the pull request as [ready for review](https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-stage-of-a-pull-request#marking-a-pull-request-as-ready-for-review) to trigger the PR checks.
|
||||
1. Review the checklist items in the pull request description.
|
||||
Once you've checked off all but the last of these, approve the PR and automerge it.
|
||||
@@ -72,6 +72,25 @@ Here are a few things you can do that will increase the likelihood of your pull
|
||||
|
||||
Approve the mergeback PR and automerge it. Once the mergeback has been merged into main, the release is complete.
|
||||
|
||||
## Keeping the PR checks up to date (admin access required)
|
||||
|
||||
Since the `codeql-action` runs most of its testing through individual Actions workflows, there are over two hundred jobs that need to pass in order for a PR to turn green. Managing these PR checks manually is time consuming and complex. Here is a semi-automated approach.
|
||||
|
||||
To regenerate the PR jobs for the action:
|
||||
|
||||
1. From a terminal, run the following commands (replace `SHA` with the sha of the commit whose checks you want to use, typically this should be the latest from `main`):
|
||||
|
||||
```sh
|
||||
SHA= ####
|
||||
CHECKS="$(gh api repos/github/codeql-action/commits/${SHA}/check-runs --paginate | jq --slurp --compact-output --raw-output '[.[].check_runs | .[].name | select(contains("https://") or . == "CodeQL" or . == "LGTM.com" or . == "Update dependencies" or . == "Update Supported Enterprise Server Versions" | not)]')"
|
||||
echo "{\"contexts\": ${CHECKS}}" > checks.json
|
||||
gh api -X "PATCH" repos/github/codeql-action/branches/main/protection/required_status_checks --input checks.json
|
||||
gh api -X "PATCH" repos/github/codeql-action/branches/v1/protection/required_status_checks --input checks.json
|
||||
````
|
||||
|
||||
2. Go to the [branch protection rules settings page](https://github.com/github/codeql-action/settings/branches) and validate that the rules have been updated.
|
||||
|
||||
|
||||
## Resources
|
||||
|
||||
- [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
|
||||
|
||||
@@ -39,8 +39,7 @@ on:
|
||||
|
||||
jobs:
|
||||
CodeQL-Build:
|
||||
# If you're only analyzing JavaScript or Python, CodeQL runs on ubuntu-latest, windows-latest, and macos-latest.
|
||||
# If you're analyzing C/C++, C#, Go, or Java, CodeQL runs on ubuntu-latest, windows-2019, and macos-latest.
|
||||
# CodeQL runs on ubuntu-latest, windows-latest, and macos-latest
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
permissions:
|
||||
|
||||
23
lib/actions-util.js
generated
23
lib/actions-util.js
generated
@@ -30,6 +30,8 @@ const yaml = __importStar(require("js-yaml"));
|
||||
const api = __importStar(require("./api-client"));
|
||||
const sharedEnv = __importStar(require("./shared-environment"));
|
||||
const util_1 = require("./util");
|
||||
// eslint-disable-next-line import/no-commonjs
|
||||
const pkg = require("../package.json");
|
||||
/**
|
||||
* The utils in this module are meant to be run inside of the action only.
|
||||
* Code paths from the runner should not enter this module.
|
||||
@@ -500,7 +502,7 @@ async function createStatusReportBase(actionName, status, actionStartedAt, cause
|
||||
core.exportVariable(sharedEnv.CODEQL_WORKFLOW_STARTED_AT, workflowStartedAt);
|
||||
}
|
||||
const runnerOs = (0, util_1.getRequiredEnvParam)("RUNNER_OS");
|
||||
const runnerArch = (0, util_1.getRequiredEnvParam)("RUNNER_ARCH");
|
||||
const codeQlCliVersion = (0, util_1.getCachedCodeQlVersion)();
|
||||
// If running locally then the GITHUB_ACTION_REF cannot be trusted as it may be for the previous action
|
||||
// See https://github.com/actions/runner/issues/803
|
||||
const actionRef = isRunningLocalAction()
|
||||
@@ -520,7 +522,7 @@ async function createStatusReportBase(actionName, status, actionStartedAt, cause
|
||||
action_started_at: actionStartedAt.toISOString(),
|
||||
status,
|
||||
runner_os: runnerOs,
|
||||
runner_arch: runnerArch,
|
||||
action_version: pkg.version,
|
||||
};
|
||||
// Add optional parameters
|
||||
if (cause) {
|
||||
@@ -539,9 +541,17 @@ async function createStatusReportBase(actionName, status, actionStartedAt, cause
|
||||
if (matrix) {
|
||||
statusReport.matrix_vars = matrix;
|
||||
}
|
||||
if ("RUNNER_ARCH" in process.env) {
|
||||
// RUNNER_ARCH is available only in GHES 3.4 and later
|
||||
// Values other than X86, X64, ARM, or ARM64 are discarded server side
|
||||
statusReport.runner_arch = process.env["RUNNER_ARCH"];
|
||||
}
|
||||
if (runnerOs === "Windows" || runnerOs === "macOS") {
|
||||
statusReport.runner_os_release = os.release();
|
||||
}
|
||||
if (codeQlCliVersion !== undefined) {
|
||||
statusReport.codeql_cli_version = codeQlCliVersion;
|
||||
}
|
||||
return statusReport;
|
||||
}
|
||||
exports.createStatusReportBase = createStatusReportBase;
|
||||
@@ -559,6 +569,13 @@ const INCOMPATIBLE_MSG = "CodeQL Action version is incompatible with the code sc
|
||||
* Returns whether sending the status report was successful of not.
|
||||
*/
|
||||
async function sendStatusReport(statusReport) {
|
||||
const gitHubVersion = await api.getGitHubVersionActionsOnly();
|
||||
if ((0, util_1.isGitHubGhesVersionBelow)(gitHubVersion, "3.2.0")) {
|
||||
// GHES 3.1 and earlier versions reject unexpected properties, which means
|
||||
// that they will reject status reports with newly added properties.
|
||||
// Inhibiting status reporting for GHES < 3.2 avoids such failures.
|
||||
return true;
|
||||
}
|
||||
const statusReportJSON = JSON.stringify(statusReport);
|
||||
core.debug(`Sending status report: ${statusReportJSON}`);
|
||||
// If in test mode we don't want to upload the results
|
||||
@@ -656,7 +673,7 @@ async function isAnalyzingDefaultBranch() {
|
||||
// Get the current ref and trim and refs/heads/ prefix
|
||||
let currentRef = await getRef();
|
||||
currentRef = currentRef.startsWith("refs/heads/")
|
||||
? currentRef.substr("refs/heads/".length)
|
||||
? currentRef.slice("refs/heads/".length)
|
||||
: currentRef;
|
||||
const event = getWorkflowEvent();
|
||||
const defaultBranch = (_a = event === null || event === void 0 ? void 0 : event.repository) === null || _a === void 0 ? void 0 : _a.default_branch;
|
||||
|
||||
File diff suppressed because one or more lines are too long
34
lib/api-client.js
generated
34
lib/api-client.js
generated
@@ -22,12 +22,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getActionsApiClient = exports.getApiClient = exports.DisallowedAPIVersionReason = void 0;
|
||||
exports.getGitHubVersionActionsOnly = exports.getActionsApiClient = exports.getApiClient = exports.DisallowedAPIVersionReason = void 0;
|
||||
const path = __importStar(require("path"));
|
||||
const githubUtils = __importStar(require("@actions/github/lib/utils"));
|
||||
const retry = __importStar(require("@octokit/plugin-retry"));
|
||||
const console_log_level_1 = __importDefault(require("console-log-level"));
|
||||
const actions_util_1 = require("./actions-util");
|
||||
const util = __importStar(require("./util"));
|
||||
const util_1 = require("./util");
|
||||
// eslint-disable-next-line import/no-commonjs
|
||||
const pkg = require("../package.json");
|
||||
@@ -57,15 +58,36 @@ function getApiUrl(githubUrl) {
|
||||
url.pathname = path.join(url.pathname, "api", "v3");
|
||||
return url.toString();
|
||||
}
|
||||
function getApiDetails() {
|
||||
return {
|
||||
auth: (0, actions_util_1.getRequiredInput)("token"),
|
||||
url: (0, util_1.getRequiredEnvParam)("GITHUB_SERVER_URL"),
|
||||
};
|
||||
}
|
||||
// Temporary function to aid in the transition to running on and off of github actions.
|
||||
// Once all code has been converted this function should be removed or made canonical
|
||||
// and called only from the action entrypoints.
|
||||
function getActionsApiClient() {
|
||||
const apiDetails = {
|
||||
auth: (0, actions_util_1.getRequiredInput)("token"),
|
||||
url: (0, util_1.getRequiredEnvParam)("GITHUB_SERVER_URL"),
|
||||
};
|
||||
return (0, exports.getApiClient)(apiDetails);
|
||||
return (0, exports.getApiClient)(getApiDetails());
|
||||
}
|
||||
exports.getActionsApiClient = getActionsApiClient;
|
||||
let cachedGitHubVersion = undefined;
|
||||
/**
|
||||
* Report the GitHub server version. This is a wrapper around
|
||||
* util.getGitHubVersion() that automatically supplies GitHub API details using
|
||||
* GitHub Action inputs. If you need to get the GitHub server version from the
|
||||
* Runner, please call util.getGitHubVersion() instead.
|
||||
*
|
||||
* @returns GitHub version
|
||||
*/
|
||||
async function getGitHubVersionActionsOnly() {
|
||||
if (!util.isActions()) {
|
||||
throw new Error("getGitHubVersionActionsOnly() works only in an action");
|
||||
}
|
||||
if (cachedGitHubVersion === undefined) {
|
||||
cachedGitHubVersion = await util.getGitHubVersion(getApiDetails());
|
||||
}
|
||||
return cachedGitHubVersion;
|
||||
}
|
||||
exports.getGitHubVersionActionsOnly = getGitHubVersionActionsOnly;
|
||||
//# sourceMappingURL=api-client.js.map
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"api-client.js","sourceRoot":"","sources":["../src/api-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAE7B,uEAAyD;AACzD,6DAA+C;AAC/C,0EAAgD;AA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@@ -1 +1 @@
|
||||
{ "maximumVersion": "3.4", "minimumVersion": "3.1" }
|
||||
{ "maximumVersion": "3.5", "minimumVersion": "3.1" }
|
||||
|
||||
39
lib/codeql.js
generated
39
lib/codeql.js
generated
@@ -196,6 +196,19 @@ async function getCodeQLBundleDownloadURL(apiDetails, variant, logger) {
|
||||
}
|
||||
return `https://github.com/${CODEQL_DEFAULT_ACTION_REPOSITORY}/releases/download/${CODEQL_BUNDLE_VERSION}/${codeQLBundleName}`;
|
||||
}
|
||||
/**
|
||||
* Set up CodeQL CLI access.
|
||||
*
|
||||
* @param codeqlURL
|
||||
* @param apiDetails
|
||||
* @param tempDir
|
||||
* @param toolCacheDir
|
||||
* @param variant
|
||||
* @param logger
|
||||
* @param checkVersion Whether to check that CodeQL CLI meets the minimum
|
||||
* version requirement. Must be set to true outside tests.
|
||||
* @returns
|
||||
*/
|
||||
async function setupCodeQL(codeqlURL, apiDetails, tempDir, toolCacheDir, variant, logger, checkVersion) {
|
||||
try {
|
||||
// We use the special value of 'latest' to prioritize the version in the
|
||||
@@ -367,16 +380,26 @@ async function getCodeQLForTesting() {
|
||||
return getCodeQLForCmd("codeql-for-testing", false);
|
||||
}
|
||||
exports.getCodeQLForTesting = getCodeQLForTesting;
|
||||
/**
|
||||
* Return a CodeQL object for CodeQL CLI access.
|
||||
*
|
||||
* @param cmd Path to CodeQL CLI
|
||||
* @param checkVersion Whether to check that CodeQL CLI meets the minimum
|
||||
* version requirement. Must be set to true outside tests.
|
||||
* @returns A new CodeQL object
|
||||
*/
|
||||
async function getCodeQLForCmd(cmd, checkVersion) {
|
||||
let cachedVersion = undefined;
|
||||
const codeql = {
|
||||
getPath() {
|
||||
return cmd;
|
||||
},
|
||||
async getVersion() {
|
||||
if (cachedVersion === undefined)
|
||||
cachedVersion = runTool(cmd, ["version", "--format=terse"]);
|
||||
return await cachedVersion;
|
||||
let result = util.getCachedCodeQlVersion();
|
||||
if (result === undefined) {
|
||||
result = await runTool(cmd, ["version", "--format=terse"]);
|
||||
util.cacheCodeQlVersion(result);
|
||||
}
|
||||
return result;
|
||||
},
|
||||
async printVersion() {
|
||||
await runTool(cmd, ["version", "--format=json"]);
|
||||
@@ -672,6 +695,14 @@ async function getCodeQLForCmd(cmd, checkVersion) {
|
||||
await new toolrunner.ToolRunner(cmd, args).exec();
|
||||
},
|
||||
};
|
||||
// To ensure that status reports include the CodeQL CLI version whereever
|
||||
// possbile, we want to call getVersion(), which populates the version value
|
||||
// used by status reporting, at the earliest opportunity. But invoking
|
||||
// getVersion() directly here breaks tests that only pretend to create a
|
||||
// CodeQL object. So instead we rely on the assumption that all non-test
|
||||
// callers would set checkVersion to true, and util.codeQlVersionAbove()
|
||||
// would call getVersion(), so the CLI version would be cached as soon as the
|
||||
// CodeQL object is created.
|
||||
if (checkVersion &&
|
||||
!(await util.codeQlVersionAbove(codeql, CODEQL_MINIMUM_VERSION))) {
|
||||
throw new Error(`Expected a CodeQL CLI with version at least ${CODEQL_MINIMUM_VERSION} but got version ${await codeql.getVersion()}`);
|
||||
|
||||
File diff suppressed because one or more lines are too long
2
lib/config-utils.js
generated
2
lib/config-utils.js
generated
@@ -435,7 +435,7 @@ async function addQueriesAndPacksFromWorkflow(codeQL, queriesInput, languages, r
|
||||
// should instead be added in addition
|
||||
function shouldAddConfigFileQueries(queriesInput) {
|
||||
if (queriesInput) {
|
||||
return queriesInput.trimStart().substr(0, 1) === "+";
|
||||
return queriesInput.trimStart().slice(0, 1) === "+";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
4
lib/config-utils.test.js
generated
4
lib/config-utils.test.js
generated
@@ -914,7 +914,7 @@ const mlPoweredQueriesMacro = ava_1.default.macro({
|
||||
(0, ava_1.default)(mlPoweredQueriesMacro, "2.7.4", true, undefined, "security-extended", undefined);
|
||||
(0, ava_1.default)(mlPoweredQueriesMacro, "2.7.5", false, undefined, "security-extended", undefined);
|
||||
(0, ava_1.default)(mlPoweredQueriesMacro, "2.7.5", true, undefined, undefined, undefined);
|
||||
(0, ava_1.default)(mlPoweredQueriesMacro, "2.7.5", true, undefined, "security-extended", "~0.0.2");
|
||||
(0, ava_1.default)(mlPoweredQueriesMacro, "2.7.5", true, undefined, "security-and-quality", "~0.0.2");
|
||||
(0, ava_1.default)(mlPoweredQueriesMacro, "2.7.5", true, undefined, "security-extended", "~0.1.0");
|
||||
(0, ava_1.default)(mlPoweredQueriesMacro, "2.7.5", true, undefined, "security-and-quality", "~0.1.0");
|
||||
(0, ava_1.default)(mlPoweredQueriesMacro, "2.7.5", true, "codeql/javascript-experimental-atm-queries@0.0.1", "security-and-quality", "0.0.1");
|
||||
//# sourceMappingURL=config-utils.test.js.map
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"bundleVersion": "codeql-bundle-20220224"
|
||||
"bundleVersion": "codeql-bundle-20220311"
|
||||
}
|
||||
|
||||
5
lib/init-action.js
generated
5
lib/init-action.js
generated
@@ -22,6 +22,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const path = __importStar(require("path"));
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const actions_util_1 = require("./actions-util");
|
||||
const api_client_1 = require("./api-client");
|
||||
const codeql_1 = require("./codeql");
|
||||
const feature_flags_1 = require("./feature-flags");
|
||||
const init_1 = require("./init");
|
||||
@@ -48,7 +49,7 @@ async function sendSuccessStatusReport(startedAt, config, toolsVersion) {
|
||||
}
|
||||
if (queriesInput !== undefined) {
|
||||
queriesInput = queriesInput.startsWith("+")
|
||||
? queriesInput.substr(1)
|
||||
? queriesInput.slice(1)
|
||||
: queriesInput;
|
||||
queries.push(...queriesInput.split(","));
|
||||
}
|
||||
@@ -78,7 +79,7 @@ async function run() {
|
||||
externalRepoAuth: (0, actions_util_1.getOptionalInput)("external-repository-token"),
|
||||
url: (0, util_1.getRequiredEnvParam)("GITHUB_SERVER_URL"),
|
||||
};
|
||||
const gitHubVersion = await (0, util_1.getGitHubVersion)(apiDetails);
|
||||
const gitHubVersion = await (0, api_client_1.getGitHubVersionActionsOnly)();
|
||||
(0, util_1.checkGitHubVersionInRange)(gitHubVersion, logger, util_1.Mode.actions);
|
||||
const repositoryNwo = (0, repository_1.parseRepositoryNwo)((0, util_1.getRequiredEnvParam)("GITHUB_REPOSITORY"));
|
||||
const featureFlags = new feature_flags_1.GitHubFeatureFlags(gitHubVersion, apiDetails, repositoryNwo, logger);
|
||||
|
||||
File diff suppressed because one or more lines are too long
3
lib/upload-sarif-action.js
generated
3
lib/upload-sarif-action.js
generated
@@ -21,6 +21,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const actionsUtil = __importStar(require("./actions-util"));
|
||||
const api_client_1 = require("./api-client");
|
||||
const logging_1 = require("./logging");
|
||||
const repository_1 = require("./repository");
|
||||
const upload_lib = __importStar(require("./upload-lib"));
|
||||
@@ -46,7 +47,7 @@ async function run() {
|
||||
auth: actionsUtil.getRequiredInput("token"),
|
||||
url: (0, util_1.getRequiredEnvParam)("GITHUB_SERVER_URL"),
|
||||
};
|
||||
const gitHubVersion = await (0, util_1.getGitHubVersion)(apiDetails);
|
||||
const gitHubVersion = await (0, api_client_1.getGitHubVersionActionsOnly)();
|
||||
const uploadResult = await upload_lib.uploadFromActions(actionsUtil.getRequiredInput("sarif_file"), gitHubVersion, apiDetails, (0, logging_1.getActionsLogger)());
|
||||
core.setOutput("sarif-id", uploadResult.sarifID);
|
||||
if (actionsUtil.getRequiredInput("wait-for-processing") === "true") {
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"upload-sarif-action.js","sourceRoot":"","sources":["../src/upload-sarif-action.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsC;AAEtC,4DAA8C;AAC9C,uCAA6C;AAC7C,6CAAkD;AAClD,yDAA2C;AAC3C,iCAKgB;AAEhB,8CAA8C;AAC9C,MAAM,GAAG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0BAAmB,EAAC,mBAAmB,CAAC,CAAC,EAC5D,YAAY,CAAC,OAAO,EACpB,UAAU,EACV,IAAA,0BAAgB,GAAE,CACnB,CAAC;SACH;QACD,MAAM,uBAAuB,CAAC,SAAS,EAAE,YAAY,CAAC,YAAY,CAAC,CAAC;KACrE;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,MAAM,KAAK,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACnE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACxB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACnB,MAAM,WAAW,CAAC,gBAAgB,CAChC,MAAM,WAAW,CAAC,sBAAsB,CACtC,cAAc,EACd,WAAW,CAAC,gBAAgB,CAAC,KAAK,CAAC,EACnC,SAAS,EACT,OAAO,EACP,KAAK,CACN,CACF,CAAC;QACF,OAAO;KACR;AACH,CAAC;AAED,KAAK,UAAU,UAAU;IACvB,IAAI;QACF,MAAM,GAAG,EAAE,CAAC;KACb;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,SAAS,CAAC,sCAAsC,KAAK,EAAE,CAAC,CAAC;QAC9D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;KACpB;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"}
|
||||
21
lib/util.js
generated
21
lib/util.js
generated
@@ -22,7 +22,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getMlPoweredJsQueriesStatus = exports.ML_POWERED_JS_QUERIES_PACK = exports.isGoodVersion = exports.delay = exports.bundleDb = exports.codeQlVersionAbove = exports.isHTTPError = exports.UserError = exports.HTTPError = exports.getRequiredEnvParam = exports.isActions = exports.getMode = exports.enrichEnvironment = exports.initializeEnvironment = exports.Mode = exports.assertNever = exports.getGitHubAuth = exports.apiVersionInRange = exports.DisallowedAPIVersionReason = exports.checkGitHubVersionInRange = exports.getGitHubVersion = exports.GitHubVariant = exports.parseGitHubUrl = exports.getCodeQLDatabasePath = exports.getThreadsFlag = exports.getThreadsFlagValue = exports.getAddSnippetsFlag = exports.getMemoryFlag = exports.getMemoryFlagValue = exports.withTmpDir = exports.getToolNames = exports.getExtraOptionsEnvParam = exports.DEFAULT_DEBUG_DATABASE_NAME = exports.DEFAULT_DEBUG_ARTIFACT_NAME = exports.GITHUB_DOTCOM_URL = void 0;
|
||||
exports.getMlPoweredJsQueriesStatus = exports.ML_POWERED_JS_QUERIES_PACK = exports.isGoodVersion = exports.delay = exports.bundleDb = exports.codeQlVersionAbove = exports.getCachedCodeQlVersion = exports.cacheCodeQlVersion = exports.isGitHubGhesVersionBelow = exports.isHTTPError = exports.UserError = exports.HTTPError = exports.getRequiredEnvParam = exports.isActions = exports.getMode = exports.enrichEnvironment = exports.initializeEnvironment = exports.Mode = exports.assertNever = exports.getGitHubAuth = exports.apiVersionInRange = exports.DisallowedAPIVersionReason = exports.checkGitHubVersionInRange = exports.getGitHubVersion = exports.GitHubVariant = exports.parseGitHubUrl = exports.getCodeQLDatabasePath = exports.getThreadsFlag = exports.getThreadsFlagValue = exports.getAddSnippetsFlag = exports.getMemoryFlag = exports.getMemoryFlagValue = exports.withTmpDir = exports.getToolNames = exports.getExtraOptionsEnvParam = exports.DEFAULT_DEBUG_DATABASE_NAME = exports.DEFAULT_DEBUG_ARTIFACT_NAME = exports.GITHUB_DOTCOM_URL = void 0;
|
||||
const fs = __importStar(require("fs"));
|
||||
const os = __importStar(require("os"));
|
||||
const path = __importStar(require("path"));
|
||||
@@ -500,6 +500,23 @@ function isHTTPError(arg) {
|
||||
return (arg === null || arg === void 0 ? void 0 : arg.status) !== undefined && Number.isInteger(arg.status);
|
||||
}
|
||||
exports.isHTTPError = isHTTPError;
|
||||
function isGitHubGhesVersionBelow(gitHubVersion, expectedVersion) {
|
||||
return (gitHubVersion.type === GitHubVariant.GHES &&
|
||||
semver.lt(gitHubVersion.version, expectedVersion));
|
||||
}
|
||||
exports.isGitHubGhesVersionBelow = isGitHubGhesVersionBelow;
|
||||
let cachedCodeQlVersion = undefined;
|
||||
function cacheCodeQlVersion(version) {
|
||||
if (cachedCodeQlVersion !== undefined) {
|
||||
throw new Error("cacheCodeQlVersion() should be called only once");
|
||||
}
|
||||
cachedCodeQlVersion = version;
|
||||
}
|
||||
exports.cacheCodeQlVersion = cacheCodeQlVersion;
|
||||
function getCachedCodeQlVersion() {
|
||||
return cachedCodeQlVersion;
|
||||
}
|
||||
exports.getCachedCodeQlVersion = getCachedCodeQlVersion;
|
||||
async function codeQlVersionAbove(codeql, requiredVersion) {
|
||||
return semver.gte(await codeql.getVersion(), requiredVersion);
|
||||
}
|
||||
@@ -534,7 +551,7 @@ exports.isGoodVersion = isGoodVersion;
|
||||
*/
|
||||
exports.ML_POWERED_JS_QUERIES_PACK = {
|
||||
packName: "codeql/javascript-experimental-atm-queries",
|
||||
version: "~0.0.2",
|
||||
version: "~0.1.0",
|
||||
};
|
||||
/**
|
||||
* Get information about ML-powered JS queries to populate status reports with.
|
||||
|
||||
File diff suppressed because one or more lines are too long
7
lib/util.test.js
generated
7
lib/util.test.js
generated
@@ -262,4 +262,11 @@ for (const [packs, expectedStatus] of ML_POWERED_JS_STATUS_TESTS) {
|
||||
});
|
||||
});
|
||||
}
|
||||
(0, ava_1.default)("isGitHubGhesVersionBelow", async (t) => {
|
||||
t.falsy(util.isGitHubGhesVersionBelow({ type: util.GitHubVariant.DOTCOM }, "3.2.0"));
|
||||
t.falsy(util.isGitHubGhesVersionBelow({ type: util.GitHubVariant.GHAE }, "3.2.0"));
|
||||
t.falsy(util.isGitHubGhesVersionBelow({ type: util.GitHubVariant.GHES, version: "3.3.0" }, "3.2.0"));
|
||||
t.falsy(util.isGitHubGhesVersionBelow({ type: util.GitHubVariant.GHES, version: "3.2.0" }, "3.2.0"));
|
||||
t.true(util.isGitHubGhesVersionBelow({ type: util.GitHubVariant.GHES, version: "3.1.2" }, "3.2.0"));
|
||||
});
|
||||
//# sourceMappingURL=util.test.js.map
|
||||
File diff suppressed because one or more lines are too long
2
node_modules/.package-lock.json
generated
vendored
2
node_modules/.package-lock.json
generated
vendored
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "codeql",
|
||||
"version": "1.1.4",
|
||||
"version": "1.1.6",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "codeql",
|
||||
"version": "1.1.4",
|
||||
"version": "1.1.6",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "codeql",
|
||||
"version": "1.1.4",
|
||||
"version": "1.1.6",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/artifact": "^1.0.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "codeql",
|
||||
"version": "1.1.4",
|
||||
"version": "1.1.6",
|
||||
"private": true,
|
||||
"description": "CodeQL action",
|
||||
"scripts": {
|
||||
@@ -75,4 +75,4 @@
|
||||
"resolutions": {
|
||||
"glob-parent": ">=5.1.2"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,6 +85,7 @@ for file in os.listdir('checks'):
|
||||
}
|
||||
},
|
||||
'name': checkSpecification['name'],
|
||||
'timeout-minutes': 30,
|
||||
'runs-on': '${{ matrix.os }}',
|
||||
'steps': steps
|
||||
}
|
||||
|
||||
2
runner/package-lock.json
generated
2
runner/package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "codeql-runner",
|
||||
"version": "1.1.4",
|
||||
"version": "1.1.6",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "codeql-runner",
|
||||
"version": "1.1.4",
|
||||
"version": "1.1.6",
|
||||
"private": true,
|
||||
"description": "CodeQL runner",
|
||||
"scripts": {
|
||||
@@ -14,4 +14,4 @@
|
||||
"webpack": "^5.50.0",
|
||||
"webpack-cli": "^4.7.2"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,12 +10,17 @@ import * as yaml from "js-yaml";
|
||||
import * as api from "./api-client";
|
||||
import * as sharedEnv from "./shared-environment";
|
||||
import {
|
||||
getCachedCodeQlVersion,
|
||||
getRequiredEnvParam,
|
||||
GITHUB_DOTCOM_URL,
|
||||
isGitHubGhesVersionBelow,
|
||||
isHTTPError,
|
||||
UserError,
|
||||
} from "./util";
|
||||
|
||||
// eslint-disable-next-line import/no-commonjs
|
||||
const pkg = require("../package.json");
|
||||
|
||||
/**
|
||||
* The utils in this module are meant to be run inside of the action only.
|
||||
* Code paths from the runner should not enter this module.
|
||||
@@ -600,9 +605,13 @@ export interface StatusReportBase {
|
||||
/** Action runner operating system (context runner.os). */
|
||||
runner_os: string;
|
||||
/** Action runner hardware architecture (context runner.arch). */
|
||||
runner_arch: string;
|
||||
runner_arch?: string;
|
||||
/** Action runner operating system release (x.y.z from os.release()). */
|
||||
runner_os_release?: string;
|
||||
/** Action version (x.y.z from package.json). */
|
||||
action_version: string;
|
||||
/** CodeQL CLI version (x.y.z from the CLI). */
|
||||
codeql_cli_version?: string;
|
||||
}
|
||||
|
||||
export function getActionsStatus(
|
||||
@@ -651,7 +660,7 @@ export async function createStatusReportBase(
|
||||
);
|
||||
}
|
||||
const runnerOs = getRequiredEnvParam("RUNNER_OS");
|
||||
const runnerArch = getRequiredEnvParam("RUNNER_ARCH");
|
||||
const codeQlCliVersion = getCachedCodeQlVersion();
|
||||
|
||||
// If running locally then the GITHUB_ACTION_REF cannot be trusted as it may be for the previous action
|
||||
// See https://github.com/actions/runner/issues/803
|
||||
@@ -673,7 +682,7 @@ export async function createStatusReportBase(
|
||||
action_started_at: actionStartedAt.toISOString(),
|
||||
status,
|
||||
runner_os: runnerOs,
|
||||
runner_arch: runnerArch,
|
||||
action_version: pkg.version,
|
||||
};
|
||||
|
||||
// Add optional parameters
|
||||
@@ -695,9 +704,17 @@ export async function createStatusReportBase(
|
||||
if (matrix) {
|
||||
statusReport.matrix_vars = matrix;
|
||||
}
|
||||
if ("RUNNER_ARCH" in process.env) {
|
||||
// RUNNER_ARCH is available only in GHES 3.4 and later
|
||||
// Values other than X86, X64, ARM, or ARM64 are discarded server side
|
||||
statusReport.runner_arch = process.env["RUNNER_ARCH"];
|
||||
}
|
||||
if (runnerOs === "Windows" || runnerOs === "macOS") {
|
||||
statusReport.runner_os_release = os.release();
|
||||
}
|
||||
if (codeQlCliVersion !== undefined) {
|
||||
statusReport.codeql_cli_version = codeQlCliVersion;
|
||||
}
|
||||
|
||||
return statusReport;
|
||||
}
|
||||
@@ -723,6 +740,14 @@ const INCOMPATIBLE_MSG =
|
||||
export async function sendStatusReport<S extends StatusReportBase>(
|
||||
statusReport: S
|
||||
): Promise<boolean> {
|
||||
const gitHubVersion = await api.getGitHubVersionActionsOnly();
|
||||
if (isGitHubGhesVersionBelow(gitHubVersion, "3.2.0")) {
|
||||
// GHES 3.1 and earlier versions reject unexpected properties, which means
|
||||
// that they will reject status reports with newly added properties.
|
||||
// Inhibiting status reporting for GHES < 3.2 avoids such failures.
|
||||
return true;
|
||||
}
|
||||
|
||||
const statusReportJSON = JSON.stringify(statusReport);
|
||||
core.debug(`Sending status report: ${statusReportJSON}`);
|
||||
// If in test mode we don't want to upload the results
|
||||
@@ -833,7 +858,7 @@ export async function isAnalyzingDefaultBranch(): Promise<boolean> {
|
||||
// Get the current ref and trim and refs/heads/ prefix
|
||||
let currentRef = await getRef();
|
||||
currentRef = currentRef.startsWith("refs/heads/")
|
||||
? currentRef.substr("refs/heads/".length)
|
||||
? currentRef.slice("refs/heads/".length)
|
||||
: currentRef;
|
||||
|
||||
const event = getWorkflowEvent();
|
||||
|
||||
@@ -5,7 +5,8 @@ import * as retry from "@octokit/plugin-retry";
|
||||
import consoleLogLevel from "console-log-level";
|
||||
|
||||
import { getRequiredInput } from "./actions-util";
|
||||
import { getMode, getRequiredEnvParam } from "./util";
|
||||
import * as util from "./util";
|
||||
import { getMode, getRequiredEnvParam, GitHubVersion } from "./util";
|
||||
|
||||
// eslint-disable-next-line import/no-commonjs
|
||||
const pkg = require("../package.json");
|
||||
@@ -58,14 +59,36 @@ function getApiUrl(githubUrl: string): string {
|
||||
return url.toString();
|
||||
}
|
||||
|
||||
function getApiDetails() {
|
||||
return {
|
||||
auth: getRequiredInput("token"),
|
||||
url: getRequiredEnvParam("GITHUB_SERVER_URL"),
|
||||
};
|
||||
}
|
||||
|
||||
// Temporary function to aid in the transition to running on and off of github actions.
|
||||
// Once all code has been converted this function should be removed or made canonical
|
||||
// and called only from the action entrypoints.
|
||||
export function getActionsApiClient() {
|
||||
const apiDetails = {
|
||||
auth: getRequiredInput("token"),
|
||||
url: getRequiredEnvParam("GITHUB_SERVER_URL"),
|
||||
};
|
||||
|
||||
return getApiClient(apiDetails);
|
||||
return getApiClient(getApiDetails());
|
||||
}
|
||||
|
||||
let cachedGitHubVersion: GitHubVersion | undefined = undefined;
|
||||
|
||||
/**
|
||||
* Report the GitHub server version. This is a wrapper around
|
||||
* util.getGitHubVersion() that automatically supplies GitHub API details using
|
||||
* GitHub Action inputs. If you need to get the GitHub server version from the
|
||||
* Runner, please call util.getGitHubVersion() instead.
|
||||
*
|
||||
* @returns GitHub version
|
||||
*/
|
||||
export async function getGitHubVersionActionsOnly(): Promise<GitHubVersion> {
|
||||
if (!util.isActions()) {
|
||||
throw new Error("getGitHubVersionActionsOnly() works only in an action");
|
||||
}
|
||||
if (cachedGitHubVersion === undefined) {
|
||||
cachedGitHubVersion = await util.getGitHubVersion(getApiDetails());
|
||||
}
|
||||
return cachedGitHubVersion;
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"maximumVersion": "3.4", "minimumVersion": "3.1"}
|
||||
{"maximumVersion": "3.5", "minimumVersion": "3.1"}
|
||||
|
||||
@@ -367,6 +367,19 @@ async function getCodeQLBundleDownloadURL(
|
||||
return `https://github.com/${CODEQL_DEFAULT_ACTION_REPOSITORY}/releases/download/${CODEQL_BUNDLE_VERSION}/${codeQLBundleName}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up CodeQL CLI access.
|
||||
*
|
||||
* @param codeqlURL
|
||||
* @param apiDetails
|
||||
* @param tempDir
|
||||
* @param toolCacheDir
|
||||
* @param variant
|
||||
* @param logger
|
||||
* @param checkVersion Whether to check that CodeQL CLI meets the minimum
|
||||
* version requirement. Must be set to true outside tests.
|
||||
* @returns
|
||||
*/
|
||||
export async function setupCodeQL(
|
||||
codeqlURL: string | undefined,
|
||||
apiDetails: api.GitHubApiDetails,
|
||||
@@ -611,19 +624,29 @@ export async function getCodeQLForTesting(): Promise<CodeQL> {
|
||||
return getCodeQLForCmd("codeql-for-testing", false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a CodeQL object for CodeQL CLI access.
|
||||
*
|
||||
* @param cmd Path to CodeQL CLI
|
||||
* @param checkVersion Whether to check that CodeQL CLI meets the minimum
|
||||
* version requirement. Must be set to true outside tests.
|
||||
* @returns A new CodeQL object
|
||||
*/
|
||||
async function getCodeQLForCmd(
|
||||
cmd: string,
|
||||
checkVersion: boolean
|
||||
): Promise<CodeQL> {
|
||||
let cachedVersion: undefined | Promise<string> = undefined;
|
||||
const codeql = {
|
||||
getPath() {
|
||||
return cmd;
|
||||
},
|
||||
async getVersion() {
|
||||
if (cachedVersion === undefined)
|
||||
cachedVersion = runTool(cmd, ["version", "--format=terse"]);
|
||||
return await cachedVersion;
|
||||
let result = util.getCachedCodeQlVersion();
|
||||
if (result === undefined) {
|
||||
result = await runTool(cmd, ["version", "--format=terse"]);
|
||||
util.cacheCodeQlVersion(result);
|
||||
}
|
||||
return result;
|
||||
},
|
||||
async printVersion() {
|
||||
await runTool(cmd, ["version", "--format=json"]);
|
||||
@@ -997,6 +1020,14 @@ async function getCodeQLForCmd(
|
||||
await new toolrunner.ToolRunner(cmd, args).exec();
|
||||
},
|
||||
};
|
||||
// To ensure that status reports include the CodeQL CLI version whereever
|
||||
// possbile, we want to call getVersion(), which populates the version value
|
||||
// used by status reporting, at the earliest opportunity. But invoking
|
||||
// getVersion() directly here breaks tests that only pretend to create a
|
||||
// CodeQL object. So instead we rely on the assumption that all non-test
|
||||
// callers would set checkVersion to true, and util.codeQlVersionAbove()
|
||||
// would call getVersion(), so the CLI version would be cached as soon as the
|
||||
// CodeQL object is created.
|
||||
if (
|
||||
checkVersion &&
|
||||
!(await util.codeQlVersionAbove(codeql, CODEQL_MINIMUM_VERSION))
|
||||
|
||||
@@ -1811,7 +1811,7 @@ test(
|
||||
true,
|
||||
undefined,
|
||||
"security-extended",
|
||||
"~0.0.2"
|
||||
"~0.1.0"
|
||||
);
|
||||
test(
|
||||
mlPoweredQueriesMacro,
|
||||
@@ -1819,7 +1819,7 @@ test(
|
||||
true,
|
||||
undefined,
|
||||
"security-and-quality",
|
||||
"~0.0.2"
|
||||
"~0.1.0"
|
||||
);
|
||||
test(
|
||||
mlPoweredQueriesMacro,
|
||||
|
||||
@@ -849,7 +849,7 @@ async function addQueriesAndPacksFromWorkflow(
|
||||
// should instead be added in addition
|
||||
function shouldAddConfigFileQueries(queriesInput: string | undefined): boolean {
|
||||
if (queriesInput) {
|
||||
return queriesInput.trimStart().substr(0, 1) === "+";
|
||||
return queriesInput.trimStart().slice(0, 1) === "+";
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"bundleVersion": "codeql-bundle-20220224"
|
||||
"bundleVersion": "codeql-bundle-20220311"
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
StatusReportBase,
|
||||
validateWorkflow,
|
||||
} from "./actions-util";
|
||||
import { getGitHubVersionActionsOnly } from "./api-client";
|
||||
import { CodeQL, CODEQL_VERSION_NEW_TRACING } from "./codeql";
|
||||
import * as configUtils from "./config-utils";
|
||||
import { GitHubFeatureFlags } from "./feature-flags";
|
||||
@@ -31,7 +32,6 @@ import {
|
||||
initializeEnvironment,
|
||||
Mode,
|
||||
checkGitHubVersionInRange,
|
||||
getGitHubVersion,
|
||||
codeQlVersionAbove,
|
||||
enrichEnvironment,
|
||||
getMemoryFlagValue,
|
||||
@@ -99,7 +99,7 @@ async function sendSuccessStatusReport(
|
||||
}
|
||||
if (queriesInput !== undefined) {
|
||||
queriesInput = queriesInput.startsWith("+")
|
||||
? queriesInput.substr(1)
|
||||
? queriesInput.slice(1)
|
||||
: queriesInput;
|
||||
queries.push(...queriesInput.split(","));
|
||||
}
|
||||
@@ -135,7 +135,7 @@ async function run() {
|
||||
url: getRequiredEnvParam("GITHUB_SERVER_URL"),
|
||||
};
|
||||
|
||||
const gitHubVersion = await getGitHubVersion(apiDetails);
|
||||
const gitHubVersion = await getGitHubVersionActionsOnly();
|
||||
checkGitHubVersionInRange(gitHubVersion, logger, Mode.actions);
|
||||
|
||||
const repositoryNwo = parseRepositoryNwo(
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
import * as core from "@actions/core";
|
||||
|
||||
import * as actionsUtil from "./actions-util";
|
||||
import { getGitHubVersionActionsOnly } from "./api-client";
|
||||
import { getActionsLogger } from "./logging";
|
||||
import { parseRepositoryNwo } from "./repository";
|
||||
import * as upload_lib from "./upload-lib";
|
||||
import {
|
||||
getGitHubVersion,
|
||||
getRequiredEnvParam,
|
||||
initializeEnvironment,
|
||||
Mode,
|
||||
} from "./util";
|
||||
import { getRequiredEnvParam, initializeEnvironment, Mode } from "./util";
|
||||
|
||||
// eslint-disable-next-line import/no-commonjs
|
||||
const pkg = require("../package.json");
|
||||
@@ -55,7 +51,7 @@ async function run() {
|
||||
url: getRequiredEnvParam("GITHUB_SERVER_URL"),
|
||||
};
|
||||
|
||||
const gitHubVersion = await getGitHubVersion(apiDetails);
|
||||
const gitHubVersion = await getGitHubVersionActionsOnly();
|
||||
|
||||
const uploadResult = await upload_lib.uploadFromActions(
|
||||
actionsUtil.getRequiredInput("sarif_file"),
|
||||
|
||||
@@ -353,3 +353,30 @@ for (const [packs, expectedStatus] of ML_POWERED_JS_STATUS_TESTS) {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
test("isGitHubGhesVersionBelow", async (t) => {
|
||||
t.falsy(
|
||||
util.isGitHubGhesVersionBelow({ type: util.GitHubVariant.DOTCOM }, "3.2.0")
|
||||
);
|
||||
t.falsy(
|
||||
util.isGitHubGhesVersionBelow({ type: util.GitHubVariant.GHAE }, "3.2.0")
|
||||
);
|
||||
t.falsy(
|
||||
util.isGitHubGhesVersionBelow(
|
||||
{ type: util.GitHubVariant.GHES, version: "3.3.0" },
|
||||
"3.2.0"
|
||||
)
|
||||
);
|
||||
t.falsy(
|
||||
util.isGitHubGhesVersionBelow(
|
||||
{ type: util.GitHubVariant.GHES, version: "3.2.0" },
|
||||
"3.2.0"
|
||||
)
|
||||
);
|
||||
t.true(
|
||||
util.isGitHubGhesVersionBelow(
|
||||
{ type: util.GitHubVariant.GHES, version: "3.1.2" },
|
||||
"3.2.0"
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
25
src/util.ts
25
src/util.ts
@@ -594,6 +594,29 @@ export function isHTTPError(arg: any): arg is HTTPError {
|
||||
return arg?.status !== undefined && Number.isInteger(arg.status);
|
||||
}
|
||||
|
||||
export function isGitHubGhesVersionBelow(
|
||||
gitHubVersion: GitHubVersion,
|
||||
expectedVersion: string
|
||||
): boolean {
|
||||
return (
|
||||
gitHubVersion.type === GitHubVariant.GHES &&
|
||||
semver.lt(gitHubVersion.version, expectedVersion)
|
||||
);
|
||||
}
|
||||
|
||||
let cachedCodeQlVersion: undefined | string = undefined;
|
||||
|
||||
export function cacheCodeQlVersion(version: string): void {
|
||||
if (cachedCodeQlVersion !== undefined) {
|
||||
throw new Error("cacheCodeQlVersion() should be called only once");
|
||||
}
|
||||
cachedCodeQlVersion = version;
|
||||
}
|
||||
|
||||
export function getCachedCodeQlVersion(): undefined | string {
|
||||
return cachedCodeQlVersion;
|
||||
}
|
||||
|
||||
export async function codeQlVersionAbove(
|
||||
codeql: CodeQL,
|
||||
requiredVersion: string
|
||||
@@ -636,7 +659,7 @@ export function isGoodVersion(versionSpec: string) {
|
||||
*/
|
||||
export const ML_POWERED_JS_QUERIES_PACK: PackWithVersion = {
|
||||
packName: "codeql/javascript-experimental-atm-queries",
|
||||
version: "~0.0.2",
|
||||
version: "~0.1.0",
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user