mirror of
https://github.com/github/codeql-action.git
synced 2026-08-06 05:07:52 -05:00
Compare commits
67 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 896079047b | |||
| e58b8d6a61 | |||
| 01330498de | |||
| a669cc5936 | |||
| 6fec2ab57a | |||
| aab7a26877 | |||
| 2b971a70bb | |||
| 4e81e2933a | |||
| bf944d782b | |||
| 566a5e6727 | |||
| 10c89976dc | |||
| 8121f62c54 | |||
| 104319fe98 | |||
| aba18b82f7 | |||
| 4a5ad5af18 | |||
| 19f867a052 | |||
| 5e452f0d9d | |||
| 8bebf77dbd | |||
| fb74504ab5 | |||
| c51babb6c6 | |||
| 79166d0788 | |||
| 44ef9d902a | |||
| 384a214d60 | |||
| 697ed97fa5 | |||
| 2207a72006 | |||
| 4623c8edb6 | |||
| 9085295c40 | |||
| 3b0a2f607d | |||
| 5566638d56 | |||
| 27c1438455 | |||
| 1e8d3b8fca | |||
| 7fc528c3c6 | |||
| 2cbc140ac5 | |||
| 1653364141 | |||
| 61cc378b7f | |||
| 7aa5026a55 | |||
| c80f00a5c9 | |||
| 62b14cbbad | |||
| 794a4b543a | |||
| ee6ba9c213 | |||
| 81f99a8582 | |||
| 4b18b7bc24 | |||
| 4acf201e5b | |||
| 1e5919b22d | |||
| 375dacad24 | |||
| e0ff272230 | |||
| 98b2ddc7f9 | |||
| 77cda4d75d | |||
| 3d90c4f911 | |||
| 6c5cad784c | |||
| 58b2ab08a8 | |||
| e0dec83cfc | |||
| 00a3c456fb | |||
| e628ee0ae1 | |||
| 7fc3c603aa | |||
| 24fd4c0f4e | |||
| d0517be03a | |||
| 37b4358e44 | |||
| 122b180b66 | |||
| 8337c2be0f | |||
| 5296a763b1 | |||
| 3afc2b194c | |||
| 3cf2a1ba2e | |||
| 4d4e25083a | |||
| 9de6c31571 | |||
| 44ae944a29 | |||
| e2338066a1 |
+9
-12
@@ -1,20 +1,17 @@
|
|||||||
version: 2
|
version: 2
|
||||||
updates:
|
updates:
|
||||||
- package-ecosystem: "npm"
|
- package-ecosystem: npm
|
||||||
directory: "/"
|
directory: "/"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "weekly"
|
interval: weekly
|
||||||
day: "thursday" # Gives us a working day to merge this before our typical release
|
|
||||||
labels:
|
labels:
|
||||||
- "Update dependencies"
|
- Update dependencies
|
||||||
ignore:
|
ignore:
|
||||||
- dependency-name: "*"
|
- dependency-name: "*"
|
||||||
update-types: ["version-update:semver-minor", "version-update:semver-patch"]
|
update-types:
|
||||||
- package-ecosystem: "npm"
|
- version-update:semver-minor
|
||||||
directory: "/runner"
|
- version-update:semver-patch
|
||||||
|
- package-ecosystem: github-actions
|
||||||
|
directory: "/"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "weekly"
|
interval: weekly
|
||||||
day: "thursday" # Gives us a working day to merge this before our typical release
|
|
||||||
ignore:
|
|
||||||
- dependency-name: "*"
|
|
||||||
update-types: ["version-update:semver-minor", "version-update:semver-patch"]
|
|
||||||
|
|||||||
+2
-2
@@ -42,11 +42,11 @@ jobs:
|
|||||||
uses: ./.github/prepare-test
|
uses: ./.github/prepare-test
|
||||||
with:
|
with:
|
||||||
version: ${{ matrix.version }}
|
version: ${{ matrix.version }}
|
||||||
- uses: swift-actions/setup-swift@5cdaa9161ad1f55ae39a5ea1784ef96de72f95d9
|
- uses: swift-actions/setup-swift@194625b58a582570f61cc707c3b558086c26b723
|
||||||
# Windows doesn't support Swift, and only macOS latest and nightly-latest support Swift 5.7.1.
|
# Windows doesn't support Swift, and only macOS latest and nightly-latest support Swift 5.7.1.
|
||||||
if: runner.os == 'Linux' || (runner.os == 'macOS' && matrix.version == 'cached')
|
if: runner.os == 'Linux' || (runner.os == 'macOS' && matrix.version == 'cached')
|
||||||
with:
|
with:
|
||||||
swift-version: '5.7'
|
swift-version: 5.7.0
|
||||||
- uses: ./../action/init
|
- uses: ./../action/init
|
||||||
with:
|
with:
|
||||||
languages: javascript
|
languages: javascript
|
||||||
|
|||||||
+2
-6
@@ -45,10 +45,6 @@ jobs:
|
|||||||
version: latest
|
version: latest
|
||||||
- os: macos-latest
|
- os: macos-latest
|
||||||
version: latest
|
version: latest
|
||||||
- os: ubuntu-latest
|
|
||||||
version: nightly-latest
|
|
||||||
- os: macos-latest
|
|
||||||
version: nightly-latest
|
|
||||||
name: Multi-language repository
|
name: Multi-language repository
|
||||||
timeout-minutes: 45
|
timeout-minutes: 45
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
@@ -65,11 +61,11 @@ jobs:
|
|||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: ^1.13.1
|
go-version: ^1.13.1
|
||||||
- uses: swift-actions/setup-swift@5cdaa9161ad1f55ae39a5ea1784ef96de72f95d9
|
- uses: swift-actions/setup-swift@194625b58a582570f61cc707c3b558086c26b723
|
||||||
# Only macOS latest and nightly-latest support Swift 5.7.1
|
# Only macOS latest and nightly-latest support Swift 5.7.1
|
||||||
if: runner.os == 'Linux' || matrix.version == 'cached'
|
if: runner.os == 'Linux' || matrix.version == 'cached'
|
||||||
with:
|
with:
|
||||||
swift-version: '5.7'
|
swift-version: 5.7.0
|
||||||
|
|
||||||
- uses: ./../action/init
|
- uses: ./../action/init
|
||||||
with:
|
with:
|
||||||
|
|||||||
+72
@@ -0,0 +1,72 @@
|
|||||||
|
# Warning: This file is generated automatically, and should not be modified.
|
||||||
|
# Instead, please modify the template in the pr-checks directory and run:
|
||||||
|
# pip install ruamel.yaml && python3 sync.py
|
||||||
|
# to regenerate this file.
|
||||||
|
|
||||||
|
name: PR Check - Submit SARIF after failure
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
GO111MODULE: auto
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- releases/v1
|
||||||
|
- releases/v2
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
- synchronize
|
||||||
|
- reopened
|
||||||
|
- ready_for_review
|
||||||
|
workflow_dispatch: {}
|
||||||
|
jobs:
|
||||||
|
submit-sarif-failure:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: ubuntu-latest
|
||||||
|
version: latest
|
||||||
|
- os: ubuntu-latest
|
||||||
|
version: cached
|
||||||
|
- os: ubuntu-latest
|
||||||
|
version: nightly-latest
|
||||||
|
name: Submit SARIF after failure
|
||||||
|
timeout-minutes: 45
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Check out repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Prepare test
|
||||||
|
id: prepare-test
|
||||||
|
uses: ./.github/prepare-test
|
||||||
|
with:
|
||||||
|
version: ${{ matrix.version }}
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: ./init
|
||||||
|
with:
|
||||||
|
languages: javascript
|
||||||
|
- name: Fail
|
||||||
|
# We want this job to pass if the Action correctly uploads the SARIF file for
|
||||||
|
# the failed run.
|
||||||
|
# Setting this step to continue on error means that it is marked as completing
|
||||||
|
# successfully, so will not fail the job.
|
||||||
|
continue-on-error: true
|
||||||
|
run: exit 1
|
||||||
|
- uses: ./analyze
|
||||||
|
# In a real workflow, this step wouldn't run. Since we used `continue-on-error`
|
||||||
|
# above, we manually disable it with an `if` condition.
|
||||||
|
if: false
|
||||||
|
with:
|
||||||
|
category: /test-codeql-version:${{ matrix.version }}
|
||||||
|
env:
|
||||||
|
# Internal-only environment variable used to indicate that the post-init Action
|
||||||
|
# should expect to upload a SARIF file for the failed run.
|
||||||
|
CODEQL_ACTION_EXPECT_UPLOAD_FAILED_SARIF: true
|
||||||
|
# Make sure the uploading SARIF files feature is enabled.
|
||||||
|
CODEQL_ACTION_UPLOAD_FAILED_SARIF: true
|
||||||
|
# Upload the failed SARIF file as an integration test of the API endpoint.
|
||||||
|
CODEQL_ACTION_TEST_MODE: false
|
||||||
|
# Mark telemetry for this workflow so it can be treated separately.
|
||||||
|
CODEQL_ACTION_TESTING_ENVIRONMENT: codeql-action-pr-checks
|
||||||
|
|
||||||
Generated
+2
-2
@@ -42,11 +42,11 @@ jobs:
|
|||||||
uses: ./.github/prepare-test
|
uses: ./.github/prepare-test
|
||||||
with:
|
with:
|
||||||
version: ${{ matrix.version }}
|
version: ${{ matrix.version }}
|
||||||
- uses: swift-actions/setup-swift@5cdaa9161ad1f55ae39a5ea1784ef96de72f95d9
|
- uses: swift-actions/setup-swift@194625b58a582570f61cc707c3b558086c26b723
|
||||||
# Only macOS latest and nightly-latest support Swift 5.7.1
|
# Only macOS latest and nightly-latest support Swift 5.7.1
|
||||||
if: runner.os == 'Linux' || matrix.version == 'cached'
|
if: runner.os == 'Linux' || matrix.version == 'cached'
|
||||||
with:
|
with:
|
||||||
swift-version: '5.7'
|
swift-version: 5.7.0
|
||||||
- uses: ./../action/init
|
- uses: ./../action/init
|
||||||
with:
|
with:
|
||||||
languages: swift
|
languages: swift
|
||||||
|
|||||||
+2
-6
@@ -33,10 +33,6 @@ jobs:
|
|||||||
version: cached
|
version: cached
|
||||||
- os: macos-latest
|
- os: macos-latest
|
||||||
version: cached
|
version: cached
|
||||||
- os: ubuntu-latest
|
|
||||||
version: nightly-latest
|
|
||||||
- os: macos-latest
|
|
||||||
version: nightly-latest
|
|
||||||
name: Swift analysis using a custom build command
|
name: Swift analysis using a custom build command
|
||||||
timeout-minutes: 45
|
timeout-minutes: 45
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
@@ -48,11 +44,11 @@ jobs:
|
|||||||
uses: ./.github/prepare-test
|
uses: ./.github/prepare-test
|
||||||
with:
|
with:
|
||||||
version: ${{ matrix.version }}
|
version: ${{ matrix.version }}
|
||||||
- uses: swift-actions/setup-swift@5cdaa9161ad1f55ae39a5ea1784ef96de72f95d9
|
- uses: swift-actions/setup-swift@194625b58a582570f61cc707c3b558086c26b723
|
||||||
# Only macOS latest and nightly-latest support Swift 5.7.1
|
# Only macOS latest and nightly-latest support Swift 5.7.1
|
||||||
if: runner.os == 'Linux' || matrix.version == 'cached'
|
if: runner.os == 'Linux' || matrix.version == 'cached'
|
||||||
with:
|
with:
|
||||||
swift-version: '5.7'
|
swift-version: 5.7.0
|
||||||
- uses: ./../action/init
|
- uses: ./../action/init
|
||||||
with:
|
with:
|
||||||
languages: swift
|
languages: swift
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v3
|
uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: 3.8
|
python-version: 3.8
|
||||||
|
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ jobs:
|
|||||||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- uses: actions/setup-python@v3
|
- uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python_version }}
|
python-version: ${{ matrix.python_version }}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ fi
|
|||||||
|
|
||||||
if [ "$#" -eq 1 ]; then
|
if [ "$#" -eq 1 ]; then
|
||||||
# If we were passed an argument, use that as the SHA
|
# If we were passed an argument, use that as the SHA
|
||||||
GITHUB_SHA="$0"
|
GITHUB_SHA="$1"
|
||||||
elif [ "$#" -gt 1 ]; then
|
elif [ "$#" -gt 1 ]; then
|
||||||
echo "Usage: $0 [SHA]"
|
echo "Usage: $0 [SHA]"
|
||||||
echo "Update the required checks based on the SHA, or main."
|
echo "Update the required checks based on the SHA, or main."
|
||||||
@@ -23,7 +23,7 @@ fi
|
|||||||
echo "Getting checks for $GITHUB_SHA"
|
echo "Getting checks for $GITHUB_SHA"
|
||||||
|
|
||||||
# Ignore any checks with "https://", CodeQL, LGTM, and Update checks.
|
# Ignore any checks with "https://", CodeQL, LGTM, and Update checks.
|
||||||
CHECKS="$(gh api repos/github/codeql-action/commits/"${GITHUB_SHA}"/check-runs --paginate | jq --slurp --compact-output --raw-output '[.[].check_runs | .[].name | select(contains("https://") or . == "CodeQL" or . == "LGTM.com" or contains("Update") or contains("update") or contains("test-setup-python-scripts") | not)] | unique | sort')"
|
CHECKS="$(gh api repos/github/codeql-action/commits/"${GITHUB_SHA}"/check-runs --paginate | jq --slurp --compact-output --raw-output '[.[].check_runs | .[].name | select(contains("https://") or . == "CodeQL" or . == "LGTM.com" or . == "check-expected-release-files" or contains("Update") or contains("update") or contains("test-setup-python-scripts") | not)] | unique | sort')"
|
||||||
|
|
||||||
echo "$CHECKS" | jq
|
echo "$CHECKS" | jq
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ jobs:
|
|||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v3
|
uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: 3.8
|
python-version: 3.8
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Setup Python
|
- name: Setup Python
|
||||||
uses: actions/setup-python@v3
|
uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: "3.7"
|
python-version: "3.7"
|
||||||
- name: Checkout CodeQL Action
|
- name: Checkout CodeQL Action
|
||||||
@@ -35,7 +35,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
ENTERPRISE_RELEASES_PATH: ${{ github.workspace }}/enterprise-releases/
|
ENTERPRISE_RELEASES_PATH: ${{ github.workspace }}/enterprise-releases/
|
||||||
- name: Commit Changes
|
- name: Commit Changes
|
||||||
uses: peter-evans/create-pull-request@c7f493a8000b8aeb17a1332e326ba76b57cb83eb # v3.4.1
|
uses: peter-evans/create-pull-request@2b011faafdcbc9ceb11414d64d0573f37c774b04 # v4.2.3
|
||||||
with:
|
with:
|
||||||
commit-message: Update supported GitHub Enterprise Server versions.
|
commit-message: Update supported GitHub Enterprise Server versions.
|
||||||
title: Update supported GitHub Enterprise Server versions.
|
title: Update supported GitHub Enterprise Server versions.
|
||||||
|
|||||||
@@ -4,6 +4,12 @@
|
|||||||
|
|
||||||
No user facing changes.
|
No user facing changes.
|
||||||
|
|
||||||
|
## 2.1.36 - 08 Dec 2022
|
||||||
|
|
||||||
|
- Update default CodeQL bundle version to 2.11.5. [#1412](https://github.com/github/codeql-action/pull/1412)
|
||||||
|
- Add a step that tries to upload a SARIF file for the workflow run when that workflow run fails. This will help better surface failed code scanning workflow runs. [#1393](https://github.com/github/codeql-action/pull/1393)
|
||||||
|
- Python automatic dependency installation will no longer consider dependecy code installed in venv as user-written, for projects using Poetry that specify `virtualenvs.in-project = true` in their `poetry.toml`. [#1419](https://github.com/github/codeql-action/pull/1419).
|
||||||
|
|
||||||
## 2.1.35 - 01 Dec 2022
|
## 2.1.35 - 01 Dec 2022
|
||||||
|
|
||||||
No user facing changes.
|
No user facing changes.
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ inputs:
|
|||||||
upload:
|
upload:
|
||||||
description: Upload the SARIF file to Code Scanning
|
description: Upload the SARIF file to Code Scanning
|
||||||
required: false
|
required: false
|
||||||
|
# If changing this, make sure to update workflow.ts accordingly.
|
||||||
default: "true"
|
default: "true"
|
||||||
cleanup-level:
|
cleanup-level:
|
||||||
description: "Level of cleanup to perform on CodeQL databases at the end of the analyze step. This should either be 'none' to skip cleanup, or be a valid argument for the --mode flag of the CodeQL CLI command 'codeql database cleanup' as documented at https://codeql.github.com/docs/codeql-cli/manual/database-cleanup"
|
description: "Level of cleanup to perform on CodeQL databases at the end of the analyze step. This should either be 'none' to skip cleanup, or be a valid argument for the --mode flag of the CodeQL CLI command 'codeql database cleanup' as documented at https://codeql.github.com/docs/codeql-cli/manual/database-cleanup"
|
||||||
@@ -44,6 +45,7 @@ inputs:
|
|||||||
checkout_path:
|
checkout_path:
|
||||||
description: "The path at which the analyzed repository was checked out. Used to relativize any absolute paths in the uploaded SARIF file."
|
description: "The path at which the analyzed repository was checked out. Used to relativize any absolute paths in the uploaded SARIF file."
|
||||||
required: false
|
required: false
|
||||||
|
# If changing this, make sure to update workflow.ts accordingly.
|
||||||
default: ${{ github.workspace }}
|
default: ${{ github.workspace }}
|
||||||
ref:
|
ref:
|
||||||
description: "The ref where results will be uploaded. If not provided, the Action will use the GITHUB_REF environment variable. If provided, the sha input must be provided as well. This input is not available in pull requests from forks."
|
description: "The ref where results will be uploaded. If not provided, the Action will use the GITHUB_REF environment variable. If provided, the sha input must be provided as well. This input is not available in pull requests from forks."
|
||||||
|
|||||||
Generated
+4
-4
@@ -173,10 +173,10 @@ async function getAutomationID() {
|
|||||||
exports.getAutomationID = getAutomationID;
|
exports.getAutomationID = getAutomationID;
|
||||||
function computeAutomationID(analysis_key, environment) {
|
function computeAutomationID(analysis_key, environment) {
|
||||||
let automationID = `${analysis_key}/`;
|
let automationID = `${analysis_key}/`;
|
||||||
// the id has to be deterministic so we sort the fields
|
const matrix = (0, util_1.parseMatrixInput)(environment);
|
||||||
if (environment !== undefined && environment !== "null") {
|
if (matrix !== undefined) {
|
||||||
const environmentObject = JSON.parse(environment);
|
// the id has to be deterministic so we sort the fields
|
||||||
for (const entry of Object.entries(environmentObject).sort()) {
|
for (const entry of Object.entries(matrix).sort()) {
|
||||||
if (typeof entry[1] === "string") {
|
if (typeof entry[1] === "string") {
|
||||||
automationID += `${entry[0]}:${entry[1]}/`;
|
automationID += `${entry[0]}:${entry[1]}/`;
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Generated
+3
-1
@@ -39,6 +39,7 @@ const feature_flags_1 = require("./feature-flags");
|
|||||||
const languages_1 = require("./languages");
|
const languages_1 = require("./languages");
|
||||||
const logging_1 = require("./logging");
|
const logging_1 = require("./logging");
|
||||||
const repository_1 = require("./repository");
|
const repository_1 = require("./repository");
|
||||||
|
const shared_environment_1 = require("./shared-environment");
|
||||||
const trap_caching_1 = require("./trap-caching");
|
const trap_caching_1 = require("./trap-caching");
|
||||||
const upload_lib = __importStar(require("./upload-lib"));
|
const upload_lib = __importStar(require("./upload-lib"));
|
||||||
const util = __importStar(require("./util"));
|
const util = __importStar(require("./util"));
|
||||||
@@ -176,8 +177,9 @@ async function run() {
|
|||||||
}
|
}
|
||||||
core.setOutput("db-locations", dbLocations);
|
core.setOutput("db-locations", dbLocations);
|
||||||
if (runStats && actionsUtil.getRequiredInput("upload") === "true") {
|
if (runStats && actionsUtil.getRequiredInput("upload") === "true") {
|
||||||
uploadResult = await upload_lib.uploadFromActions(outputDir, logger);
|
uploadResult = await upload_lib.uploadFromActions(outputDir, actionsUtil.getRequiredInput("checkout_path"), actionsUtil.getOptionalInput("category"), logger);
|
||||||
core.setOutput("sarif-id", uploadResult.sarifID);
|
core.setOutput("sarif-id", uploadResult.sarifID);
|
||||||
|
core.exportVariable(shared_environment_1.CODEQL_ACTION_ANALYZE_DID_UPLOAD_SARIF, "true");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
logger.info("Not uploading results");
|
logger.info("Not uploading results");
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Generated
+1
-1
@@ -207,7 +207,7 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
|
|||||||
return statusReport;
|
return statusReport;
|
||||||
async function runInterpretResults(language, queries, sarifFile, enableDebugLogging) {
|
async function runInterpretResults(language, queries, sarifFile, enableDebugLogging) {
|
||||||
const databasePath = util.getCodeQLDatabasePath(config, language);
|
const databasePath = util.getCodeQLDatabasePath(config, language);
|
||||||
return await codeql.databaseInterpretResults(databasePath, queries, sarifFile, addSnippetsFlag, threadsFlag, enableDebugLogging ? "-vv" : "-v", automationDetailsId, featureEnablement);
|
return await codeql.databaseInterpretResults(databasePath, queries, sarifFile, addSnippetsFlag, threadsFlag, enableDebugLogging ? "-vv" : "-v", automationDetailsId);
|
||||||
}
|
}
|
||||||
async function runPrintLinesOfCode(language) {
|
async function runPrintLinesOfCode(language) {
|
||||||
const databasePath = util.getCodeQLDatabasePath(config, language);
|
const databasePath = util.getCodeQLDatabasePath(config, language);
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
Generated
+17
-3
@@ -36,7 +36,6 @@ const actions_util_1 = require("./actions-util");
|
|||||||
const api = __importStar(require("./api-client"));
|
const api = __importStar(require("./api-client"));
|
||||||
const defaults = __importStar(require("./defaults.json")); // Referenced from codeql-action-sync-tool!
|
const defaults = __importStar(require("./defaults.json")); // Referenced from codeql-action-sync-tool!
|
||||||
const error_matcher_1 = require("./error-matcher");
|
const error_matcher_1 = require("./error-matcher");
|
||||||
const feature_flags_1 = require("./feature-flags");
|
|
||||||
const languages_1 = require("./languages");
|
const languages_1 = require("./languages");
|
||||||
const toolrunner_error_catcher_1 = require("./toolrunner-error-catcher");
|
const toolrunner_error_catcher_1 = require("./toolrunner-error-catcher");
|
||||||
const trap_caching_1 = require("./trap-caching");
|
const trap_caching_1 = require("./trap-caching");
|
||||||
@@ -77,6 +76,7 @@ const CODEQL_VERSION_LUA_TRACER_CONFIG = "2.10.0";
|
|||||||
exports.CODEQL_VERSION_CONFIG_FILES = "2.10.1";
|
exports.CODEQL_VERSION_CONFIG_FILES = "2.10.1";
|
||||||
const CODEQL_VERSION_LUA_TRACING_GO_WINDOWS_FIXED = "2.10.4";
|
const CODEQL_VERSION_LUA_TRACING_GO_WINDOWS_FIXED = "2.10.4";
|
||||||
exports.CODEQL_VERSION_GHES_PACK_DOWNLOAD = "2.10.4";
|
exports.CODEQL_VERSION_GHES_PACK_DOWNLOAD = "2.10.4";
|
||||||
|
const CODEQL_VERSION_FILE_BASELINE_INFORMATION = "2.11.3";
|
||||||
/**
|
/**
|
||||||
* This variable controls using the new style of tracing from the CodeQL
|
* This variable controls using the new style of tracing from the CodeQL
|
||||||
* CLI. In particular, with versions above this we will use both indirect
|
* CLI. In particular, with versions above this we will use both indirect
|
||||||
@@ -371,6 +371,7 @@ function setCodeQL(partialCodeql) {
|
|||||||
databaseRunQueries: resolveFunction(partialCodeql, "databaseRunQueries"),
|
databaseRunQueries: resolveFunction(partialCodeql, "databaseRunQueries"),
|
||||||
databaseInterpretResults: resolveFunction(partialCodeql, "databaseInterpretResults"),
|
databaseInterpretResults: resolveFunction(partialCodeql, "databaseInterpretResults"),
|
||||||
databasePrintBaseline: resolveFunction(partialCodeql, "databasePrintBaseline"),
|
databasePrintBaseline: resolveFunction(partialCodeql, "databasePrintBaseline"),
|
||||||
|
diagnosticsExport: resolveFunction(partialCodeql, "diagnosticsExport"),
|
||||||
};
|
};
|
||||||
return cachedCodeQL;
|
return cachedCodeQL;
|
||||||
}
|
}
|
||||||
@@ -668,7 +669,7 @@ async function getCodeQLForCmd(cmd, checkVersion) {
|
|||||||
}
|
}
|
||||||
await (0, toolrunner_error_catcher_1.toolrunnerErrorCatcher)(cmd, codeqlArgs, error_matcher_1.errorMatchers);
|
await (0, toolrunner_error_catcher_1.toolrunnerErrorCatcher)(cmd, codeqlArgs, error_matcher_1.errorMatchers);
|
||||||
},
|
},
|
||||||
async databaseInterpretResults(databasePath, querySuitePaths, sarifFile, addSnippetsFlag, threadsFlag, verbosityFlag, automationDetailsId, featureEnablement) {
|
async databaseInterpretResults(databasePath, querySuitePaths, sarifFile, addSnippetsFlag, threadsFlag, verbosityFlag, automationDetailsId) {
|
||||||
const codeqlArgs = [
|
const codeqlArgs = [
|
||||||
"database",
|
"database",
|
||||||
"interpret-results",
|
"interpret-results",
|
||||||
@@ -687,7 +688,7 @@ async function getCodeQLForCmd(cmd, checkVersion) {
|
|||||||
if (automationDetailsId !== undefined) {
|
if (automationDetailsId !== undefined) {
|
||||||
codeqlArgs.push("--sarif-category", automationDetailsId);
|
codeqlArgs.push("--sarif-category", automationDetailsId);
|
||||||
}
|
}
|
||||||
if (await featureEnablement.getValue(feature_flags_1.Feature.FileBaselineInformationEnabled, this)) {
|
if (await util.codeQlVersionAbove(this, CODEQL_VERSION_FILE_BASELINE_INFORMATION)) {
|
||||||
codeqlArgs.push("--sarif-add-baseline-file-info");
|
codeqlArgs.push("--sarif-add-baseline-file-info");
|
||||||
}
|
}
|
||||||
codeqlArgs.push(databasePath);
|
codeqlArgs.push(databasePath);
|
||||||
@@ -772,6 +773,19 @@ async function getCodeQLForCmd(cmd, checkVersion) {
|
|||||||
];
|
];
|
||||||
await new toolrunner.ToolRunner(cmd, args).exec();
|
await new toolrunner.ToolRunner(cmd, args).exec();
|
||||||
},
|
},
|
||||||
|
async diagnosticsExport(sarifFile, automationDetailsId) {
|
||||||
|
const args = [
|
||||||
|
"diagnostics",
|
||||||
|
"export",
|
||||||
|
"--format=sarif-latest",
|
||||||
|
`--output=${sarifFile}`,
|
||||||
|
...getExtraOptionsFromEnv(["diagnostics", "export"]),
|
||||||
|
];
|
||||||
|
if (automationDetailsId !== undefined) {
|
||||||
|
args.push("--sarif-category", automationDetailsId);
|
||||||
|
}
|
||||||
|
await new toolrunner.ToolRunner(cmd, args).exec();
|
||||||
|
},
|
||||||
};
|
};
|
||||||
// To ensure that status reports include the CodeQL CLI version wherever
|
// To ensure that status reports include the CodeQL CLI version wherever
|
||||||
// possible, we want to call getVersion(), which populates the version value
|
// possible, we want to call getVersion(), which populates the version value
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
Generated
+8
-14
@@ -311,7 +311,7 @@ for (const [isFeatureEnabled, toolsInput, shouldToolcacheBeBypassed,] of TOOLCAC
|
|||||||
sinon.stub(codeqlObject, "getVersion").resolves("2.7.0");
|
sinon.stub(codeqlObject, "getVersion").resolves("2.7.0");
|
||||||
// safeWhich throws because of the test CodeQL object.
|
// safeWhich throws because of the test CodeQL object.
|
||||||
sinon.stub(safeWhich, "safeWhich").resolves("");
|
sinon.stub(safeWhich, "safeWhich").resolves("");
|
||||||
await codeqlObject.databaseInterpretResults("", [], "", "", "", "-v", "", (0, testing_utils_1.createFeatures)([]));
|
await codeqlObject.databaseInterpretResults("", [], "", "", "", "-v", "");
|
||||||
t.false(runnerConstructorStub.firstCall.args[1].includes("--sarif-add-query-help"), "--sarif-add-query-help should be absent, but it is present");
|
t.false(runnerConstructorStub.firstCall.args[1].includes("--sarif-add-query-help"), "--sarif-add-query-help should be absent, but it is present");
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("databaseInterpretResults() sets --sarif-add-query-help for 2.7.1", async (t) => {
|
(0, ava_1.default)("databaseInterpretResults() sets --sarif-add-query-help for 2.7.1", async (t) => {
|
||||||
@@ -320,7 +320,7 @@ for (const [isFeatureEnabled, toolsInput, shouldToolcacheBeBypassed,] of TOOLCAC
|
|||||||
sinon.stub(codeqlObject, "getVersion").resolves("2.7.1");
|
sinon.stub(codeqlObject, "getVersion").resolves("2.7.1");
|
||||||
// safeWhich throws because of the test CodeQL object.
|
// safeWhich throws because of the test CodeQL object.
|
||||||
sinon.stub(safeWhich, "safeWhich").resolves("");
|
sinon.stub(safeWhich, "safeWhich").resolves("");
|
||||||
await codeqlObject.databaseInterpretResults("", [], "", "", "", "-v", "", (0, testing_utils_1.createFeatures)([]));
|
await codeqlObject.databaseInterpretResults("", [], "", "", "", "-v", "");
|
||||||
t.true(runnerConstructorStub.firstCall.args[1].includes("--sarif-add-query-help"), "--sarif-add-query-help should be present, but it is absent");
|
t.true(runnerConstructorStub.firstCall.args[1].includes("--sarif-add-query-help"), "--sarif-add-query-help should be present, but it is absent");
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("databaseInitCluster() without injected codescanning config", async (t) => {
|
(0, ava_1.default)("databaseInitCluster() without injected codescanning config", async (t) => {
|
||||||
@@ -571,28 +571,22 @@ const injectedConfigMacro = ava_1.default.macro({
|
|||||||
process.env["CODEQL_PASS_CONFIG_TO_CLI"] = origCODEQL_PASS_CONFIG_TO_CLI;
|
process.env["CODEQL_PASS_CONFIG_TO_CLI"] = origCODEQL_PASS_CONFIG_TO_CLI;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("databaseInterpretResults() sets --sarif-add-baseline-file-info when feature enabled", async (t) => {
|
(0, ava_1.default)("databaseInterpretResults() sets --sarif-add-baseline-file-info for 2.11.3", async (t) => {
|
||||||
const runnerConstructorStub = stubToolRunnerConstructor();
|
const runnerConstructorStub = stubToolRunnerConstructor();
|
||||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||||
// We need to set a CodeQL version such that running `databaseInterpretResults` does not crash.
|
sinon.stub(codeqlObject, "getVersion").resolves("2.11.3");
|
||||||
// The version of CodeQL is checked separately to determine feature enablement, and does not
|
|
||||||
// otherwise impact this test, so set it to 0.0.0.
|
|
||||||
sinon.stub(codeqlObject, "getVersion").resolves("0.0.0");
|
|
||||||
// safeWhich throws because of the test CodeQL object.
|
// safeWhich throws because of the test CodeQL object.
|
||||||
sinon.stub(safeWhich, "safeWhich").resolves("");
|
sinon.stub(safeWhich, "safeWhich").resolves("");
|
||||||
await codeqlObject.databaseInterpretResults("", [], "", "", "", "-v", "", (0, testing_utils_1.createFeatures)([feature_flags_1.Feature.FileBaselineInformationEnabled]));
|
await codeqlObject.databaseInterpretResults("", [], "", "", "", "-v", "");
|
||||||
t.true(runnerConstructorStub.firstCall.args[1].includes("--sarif-add-baseline-file-info"), "--sarif-add-baseline-file-info should be present, but it is absent");
|
t.true(runnerConstructorStub.firstCall.args[1].includes("--sarif-add-baseline-file-info"), "--sarif-add-baseline-file-info should be present, but it is absent");
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("databaseInterpretResults() does not set --sarif-add-baseline-file-info if feature disabled", async (t) => {
|
(0, ava_1.default)("databaseInterpretResults() does not set --sarif-add-baseline-file-info for 2.11.2", async (t) => {
|
||||||
const runnerConstructorStub = stubToolRunnerConstructor();
|
const runnerConstructorStub = stubToolRunnerConstructor();
|
||||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||||
// We need to set a CodeQL version such that running `databaseInterpretResults` does not crash.
|
sinon.stub(codeqlObject, "getVersion").resolves("2.11.2");
|
||||||
// The version of CodeQL is checked upstream to determine feature enablement, so it does not
|
|
||||||
// affect this test.
|
|
||||||
sinon.stub(codeqlObject, "getVersion").resolves("0.0.0");
|
|
||||||
// safeWhich throws because of the test CodeQL object.
|
// safeWhich throws because of the test CodeQL object.
|
||||||
sinon.stub(safeWhich, "safeWhich").resolves("");
|
sinon.stub(safeWhich, "safeWhich").resolves("");
|
||||||
await codeqlObject.databaseInterpretResults("", [], "", "", "", "-v", "", (0, testing_utils_1.createFeatures)([]));
|
await codeqlObject.databaseInterpretResults("", [], "", "", "", "-v", "");
|
||||||
t.false(runnerConstructorStub.firstCall.args[1].includes("--sarif-add-baseline-file-info"), "--sarif-add-baseline-file-info must be absent, but it is present");
|
t.false(runnerConstructorStub.firstCall.args[1].includes("--sarif-add-baseline-file-info"), "--sarif-add-baseline-file-info must be absent, but it is present");
|
||||||
});
|
});
|
||||||
function stubToolRunnerConstructor() {
|
function stubToolRunnerConstructor() {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"bundleVersion": "codeql-bundle-20221123"
|
"bundleVersion": "codeql-bundle-20221202"
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+5
-5
@@ -30,9 +30,9 @@ var Feature;
|
|||||||
Feature["BypassToolcacheKotlinSwiftEnabled"] = "bypass_toolcache_kotlin_swift_enabled";
|
Feature["BypassToolcacheKotlinSwiftEnabled"] = "bypass_toolcache_kotlin_swift_enabled";
|
||||||
Feature["CliConfigFileEnabled"] = "cli_config_file_enabled";
|
Feature["CliConfigFileEnabled"] = "cli_config_file_enabled";
|
||||||
Feature["DisableKotlinAnalysisEnabled"] = "disable_kotlin_analysis_enabled";
|
Feature["DisableKotlinAnalysisEnabled"] = "disable_kotlin_analysis_enabled";
|
||||||
Feature["FileBaselineInformationEnabled"] = "file_baseline_information_enabled";
|
|
||||||
Feature["MlPoweredQueriesEnabled"] = "ml_powered_queries_enabled";
|
Feature["MlPoweredQueriesEnabled"] = "ml_powered_queries_enabled";
|
||||||
Feature["TrapCachingEnabled"] = "trap_caching_enabled";
|
Feature["TrapCachingEnabled"] = "trap_caching_enabled";
|
||||||
|
Feature["UploadFailedSarifEnabled"] = "upload_failed_sarif_enabled";
|
||||||
})(Feature = exports.Feature || (exports.Feature = {}));
|
})(Feature = exports.Feature || (exports.Feature = {}));
|
||||||
exports.featureConfig = {
|
exports.featureConfig = {
|
||||||
[Feature.BypassToolcacheEnabled]: {
|
[Feature.BypassToolcacheEnabled]: {
|
||||||
@@ -55,10 +55,6 @@ exports.featureConfig = {
|
|||||||
envVar: "CODEQL_PASS_CONFIG_TO_CLI",
|
envVar: "CODEQL_PASS_CONFIG_TO_CLI",
|
||||||
minimumVersion: "2.11.1",
|
minimumVersion: "2.11.1",
|
||||||
},
|
},
|
||||||
[Feature.FileBaselineInformationEnabled]: {
|
|
||||||
envVar: "CODEQL_FILE_BASELINE_INFORMATION",
|
|
||||||
minimumVersion: "2.11.3",
|
|
||||||
},
|
|
||||||
[Feature.MlPoweredQueriesEnabled]: {
|
[Feature.MlPoweredQueriesEnabled]: {
|
||||||
envVar: "CODEQL_ML_POWERED_QUERIES",
|
envVar: "CODEQL_ML_POWERED_QUERIES",
|
||||||
minimumVersion: "2.7.5",
|
minimumVersion: "2.7.5",
|
||||||
@@ -67,6 +63,10 @@ exports.featureConfig = {
|
|||||||
envVar: "CODEQL_TRAP_CACHING",
|
envVar: "CODEQL_TRAP_CACHING",
|
||||||
minimumVersion: undefined,
|
minimumVersion: undefined,
|
||||||
},
|
},
|
||||||
|
[Feature.UploadFailedSarifEnabled]: {
|
||||||
|
envVar: "CODEQL_ACTION_UPLOAD_FAILED_SARIF",
|
||||||
|
minimumVersion: "2.11.3",
|
||||||
|
},
|
||||||
};
|
};
|
||||||
exports.FEATURE_FLAGS_FILE_NAME = "cached-feature-flags.json";
|
exports.FEATURE_FLAGS_FILE_NAME = "cached-feature-flags.json";
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"feature-flags.js","sourceRoot":"","sources":["../src/feature-flags.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,6CAA4C;AAI5C,6CAA+B;AAM/B,IAAY,OAQX;AARD,WAAY,OAAO;IACjB,8DAAmD,CAAA;IACnD,sFAA2E,CAAA;IAC3E,2DAAgD,CAAA;IAChD,2EAAgE,CAAA;IAChE,+EAAoE,CAAA;IACpE,iEAAsD,CAAA;IACtD,sDAA2C,CAAA;AAC7C,CAAC,EARW,OAAO,GAAP,eAAO,KAAP,eAAO,QAQlB;AAEY,QAAA,aAAa,GAGtB;IACF,CAAC,OAAO,CAAC,sBAAsB,CAAC,EAAE;QAChC,MAAM,EAAE,yBAAyB;QACjC,+EAA+E;QAC/E,iCAAiC;QACjC,cAAc,EAAE,SAAS;KAC1B;IACD,CAAC,OAAO,CAAC,iCAAiC,CAAC,EAAE;QAC3C,MAAM,EAAE,sCAAsC;QAC9C,+EAA+E;QAC/E,iCAAiC;QACjC,cAAc,EAAE,SAAS;KAC1B;IACD,CAAC,OAAO,CAAC,4BAA4B,CAAC,EAAE;QACtC,MAAM,EAAE,gCAAgC;QACxC,cAAc,EAAE,SAAS;KAC1B;IACD,CAAC,OAAO,CAAC,oBAAoB,CAAC,EAAE;QAC9B,MAAM,EAAE,2BAA2B;QACnC,cAAc,EAAE,QAAQ;KACzB;IACD,CAAC,OAAO,CAAC,8BAA8B,CAAC,EAAE;QACxC,MAAM,EAAE,kCAAkC;QAC1C,cAAc,EAAE,QAAQ;KACzB;IACD,CAAC,OAAO,CAAC,uBAAuB,CAAC,EAAE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AAC,IAAI,CAAC,CAAC,MAAM,KAAK,GAAG,EAAE;gBAC3C,IAAI,CAAC,MAAM,CAAC,OAAO,CACjB,gGAAgG;oBAC9F,oEAAoE;oBACpE,qFAAqF;oBACrF,kFAAkF,CAAC,EAAE,CACxF,CAAC;aACH;iBAAM;gBACL,kFAAkF;gBAClF,8EAA8E;gBAC9E,2FAA2F;gBAC3F,eAAe;gBACf,MAAM,IAAI,KAAK,CACb,sEAAsE,CAAC,EAAE,CAC1E,CAAC;aACH;SACF;IACH,CAAC;CACF"}
|
||||||
Generated
+54
-5
@@ -19,19 +19,68 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.run = void 0;
|
exports.run = exports.uploadFailedSarif = void 0;
|
||||||
const core = __importStar(require("@actions/core"));
|
const core = __importStar(require("@actions/core"));
|
||||||
const actionsUtil = __importStar(require("./actions-util"));
|
const actionsUtil = __importStar(require("./actions-util"));
|
||||||
|
const codeql_1 = require("./codeql");
|
||||||
const config_utils_1 = require("./config-utils");
|
const config_utils_1 = require("./config-utils");
|
||||||
const logging_1 = require("./logging");
|
const feature_flags_1 = require("./feature-flags");
|
||||||
async function run(uploadDatabaseBundleDebugArtifact, uploadLogsDebugArtifact, printDebugLogs) {
|
const shared_environment_1 = require("./shared-environment");
|
||||||
const logger = (0, logging_1.getActionsLogger)();
|
const uploadLib = __importStar(require("./upload-lib"));
|
||||||
|
const util_1 = require("./util");
|
||||||
|
const workflow_1 = require("./workflow");
|
||||||
|
async function uploadFailedSarif(config, repositoryNwo, featureEnablement, logger) {
|
||||||
|
if (!config.codeQLCmd) {
|
||||||
|
logger.warning("CodeQL command not found. Unable to upload failed SARIF file.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
||||||
|
if (!(await featureEnablement.getValue(feature_flags_1.Feature.UploadFailedSarifEnabled, codeql))) {
|
||||||
|
logger.debug("Uploading failed SARIF is disabled.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const workflow = await (0, workflow_1.getWorkflow)();
|
||||||
|
const jobName = (0, util_1.getRequiredEnvParam)("GITHUB_JOB");
|
||||||
|
const matrix = (0, util_1.parseMatrixInput)(actionsUtil.getRequiredInput("matrix"));
|
||||||
|
if ((0, workflow_1.getUploadInputOrThrow)(workflow, jobName, matrix) !== "true" ||
|
||||||
|
(0, util_1.isInTestMode)()) {
|
||||||
|
logger.debug("Won't upload a failed SARIF file since SARIF upload is disabled.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const category = (0, workflow_1.getCategoryInputOrThrow)(workflow, jobName, matrix);
|
||||||
|
const checkoutPath = (0, workflow_1.getCheckoutPathInputOrThrow)(workflow, jobName, matrix);
|
||||||
|
const sarifFile = "../codeql-failed-run.sarif";
|
||||||
|
await codeql.diagnosticsExport(sarifFile, category);
|
||||||
|
core.info(`Uploading failed SARIF file ${sarifFile}`);
|
||||||
|
const uploadResult = await uploadLib.uploadFromActions(sarifFile, checkoutPath, category, logger);
|
||||||
|
await uploadLib.waitForProcessing(repositoryNwo, uploadResult.sarifID, logger, { isUnsuccessfulExecution: true });
|
||||||
|
}
|
||||||
|
exports.uploadFailedSarif = uploadFailedSarif;
|
||||||
|
async function run(uploadDatabaseBundleDebugArtifact, uploadLogsDebugArtifact, printDebugLogs, repositoryNwo, featureEnablement, logger) {
|
||||||
const config = await (0, config_utils_1.getConfig)(actionsUtil.getTemporaryDirectory(), logger);
|
const config = await (0, config_utils_1.getConfig)(actionsUtil.getTemporaryDirectory(), logger);
|
||||||
if (config === undefined) {
|
if (config === undefined) {
|
||||||
logger.warning("Debugging artifacts are unavailable since the 'init' Action failed before it could produce any.");
|
logger.warning("Debugging artifacts are unavailable since the 'init' Action failed before it could produce any.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Environment variable used to integration test uploading a SARIF file for failed runs
|
||||||
|
const expectFailedSarifUpload = process.env["CODEQL_ACTION_EXPECT_UPLOAD_FAILED_SARIF"] === "true";
|
||||||
|
if (process.env[shared_environment_1.CODEQL_ACTION_ANALYZE_DID_UPLOAD_SARIF] !== "true") {
|
||||||
|
try {
|
||||||
|
await uploadFailedSarif(config, repositoryNwo, featureEnablement, logger);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
if (expectFailedSarifUpload) {
|
||||||
|
throw new Error("Expected to upload a SARIF file for the failed run, but encountered " +
|
||||||
|
`the following error: ${e}`);
|
||||||
|
}
|
||||||
|
logger.info(`Failed to upload a SARIF file for the failed run. Error: ${e}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (expectFailedSarifUpload) {
|
||||||
|
throw new Error("Expected to upload a SARIF file for the failed run, but didn't.");
|
||||||
}
|
}
|
||||||
// Upload appropriate Actions artifacts for debugging
|
// Upload appropriate Actions artifacts for debugging
|
||||||
if (config === null || config === void 0 ? void 0 : config.debugMode) {
|
if (config.debugMode) {
|
||||||
core.info("Debug mode is on. Uploading available database bundles and logs as Actions debugging artifacts...");
|
core.info("Debug mode is on. Uploading available database bundles and logs as Actions debugging artifacts...");
|
||||||
await uploadDatabaseBundleDebugArtifact(config, logger);
|
await uploadDatabaseBundleDebugArtifact(config, logger);
|
||||||
await uploadLogsDebugArtifact(config);
|
await uploadLogsDebugArtifact(config);
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"init-action-post-helper.js","sourceRoot":"","sources":["../src/init-action-post-helper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsC;AAEtC,4DAA8C;AAC9C,iDAA2C;AAC3C,uCAA6C;AAEtC,KAAK,UAAU,GAAG,CACvB,iCAA2C,EAC3C,uBAAiC,EACjC,cAAwB;IAExB,MAAM,MAAM,GAAG,IAAA,0BAAgB,GAAE,CAAC;IAElC,MAAM,MAAM,GAAG,MAAM,IAAA,wBAAS,EAAC,WAAW,CAAC,qBAAqB,EAAE,EAAE,MAAM,CAAC,CAAC;IAC5E,IAAI,MAAM,KAAK,SAAS,EAAE;QACxB,MAAM,CAAC,OAAO,CACZ,iGAAiG,CAClG,CAAC;KACH;IAED,qDAAqD;IACrD,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,SAAS,EAAE;QACrB,IAAI,CAAC,IAAI,CACP,mGAAmG,CACpG,CAAC;QACF,MAAM,iCAAiC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACxD,MAAM,uBAAuB,CAAC,MAAM,CAAC,CAAC;QAEtC,MAAM,cAAc,CAAC,MAAM,CAAC,CAAC;KAC9B;AACH,CAAC;AAxBD,kBAwBC"}
|
{"version":3,"file":"init-action-post-helper.js","sourceRoot":"","sources":["../src/init-action-post-helper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsC;AAEtC,4DAA8C;AAC9C,qCAAqC;AACrC,iDAAmD;AACnD,mDAA6D;AAG7D,6DAA8E;AAC9E,wDAA0C;AAC1C,iCAA6E;AAC7E,yCAKoB;AAEb,KAAK,UAAU,iBAAiB,CACrC,MAAc,EACd,aAA4B,EAC5B,iBAAoC,EACpC,MAAc;IAEd,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE;QACrB,MAAM,CAAC,OAAO,CACZ,+DAA+D,CAChE,CAAC;QACF,OAAO;KACR;IACD,MAAM,MAAM,GAAG,MAAM,IAAA,kBAAS,EAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACjD,IACE,CAAC,CAAC,MAAM,iBAAiB,CAAC,QAAQ,CAChC,uBAAO,CAAC,wBAAwB,EAChC,MAAM,CACP,CAAC,EACF;QACA,MAAM,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACpD,OAAO;KACR;IACD,MAAM,QAAQ,GAAG,MAAM,IAAA,sBAAW,GAAE,CAAC;IACrC,MAAM,OAAO,GAAG,IAAA,0B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uFAAuF;IACvF,MAAM,uBAAuB,GAC3B,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,KAAK,MAAM,CAAC;IAErE,IAAI,OAAO,CAAC,GAAG,CAAC,2DAAsC,CAAC,KAAK,MAAM,EAAE;QAClE,IAAI;YACF,MAAM,iBAAiB,CAAC,MAAM,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,CAAC,CAAC;SAC3E;QAAC,OAAO,CAAC,EAAE;YACV,IAAI,uBAAuB,EAAE;gBAC3B,MAAM,IAAI,KAAK,CACb,sEAAsE;oBACpE,wBAAwB,CAAC,EAAE,CAC9B,CAAC;aACH;YACD,MAAM,CAAC,IAAI,CACT,4DAA4D,CAAC,EAAE,CAChE,CAAC;SACH;KACF;SAAM,IAAI,uBAAuB,EAAE;QAClC,MAAM,IAAI,KAAK,CACb,iEAAiE,CAClE,CAAC;KACH;IAED,qDAAqD;IACrD,IAAI,MAAM,CAAC,SAAS,EAAE;QACpB,IAAI,CAAC,IAAI,CACP,mGAAmG,CACpG,CAAC;QACF,MAAM,iCAAiC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACxD,MAAM,uBAAuB,CAAC,MAAM,CAAC,CAAC;QAEtC,MAAM,cAAc,CAAC,MAAM,CAAC,CAAC;KAC9B;AACH,CAAC;AAlDD,kBAkDC"}
|
||||||
Generated
+91
-2
@@ -24,13 +24,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const ava_1 = __importDefault(require("ava"));
|
const ava_1 = __importDefault(require("ava"));
|
||||||
const sinon = __importStar(require("sinon"));
|
const sinon = __importStar(require("sinon"));
|
||||||
|
const actionsUtil = __importStar(require("./actions-util"));
|
||||||
|
const codeql = __importStar(require("./codeql"));
|
||||||
const configUtils = __importStar(require("./config-utils"));
|
const configUtils = __importStar(require("./config-utils"));
|
||||||
|
const feature_flags_1 = require("./feature-flags");
|
||||||
const initActionPostHelper = __importStar(require("./init-action-post-helper"));
|
const initActionPostHelper = __importStar(require("./init-action-post-helper"));
|
||||||
|
const logging_1 = require("./logging");
|
||||||
|
const repository_1 = require("./repository");
|
||||||
const testing_utils_1 = require("./testing-utils");
|
const testing_utils_1 = require("./testing-utils");
|
||||||
|
const uploadLib = __importStar(require("./upload-lib"));
|
||||||
const util = __importStar(require("./util"));
|
const util = __importStar(require("./util"));
|
||||||
|
const workflow = __importStar(require("./workflow"));
|
||||||
(0, testing_utils_1.setupTests)(ava_1.default);
|
(0, testing_utils_1.setupTests)(ava_1.default);
|
||||||
(0, ava_1.default)("post: init action with debug mode off", async (t) => {
|
(0, ava_1.default)("post: init action with debug mode off", async (t) => {
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
|
process.env["GITHUB_REPOSITORY"] = "github/codeql-action-fake-repository";
|
||||||
process.env["RUNNER_TEMP"] = tmpDir;
|
process.env["RUNNER_TEMP"] = tmpDir;
|
||||||
const gitHubVersion = {
|
const gitHubVersion = {
|
||||||
type: util.GitHubVariant.DOTCOM,
|
type: util.GitHubVariant.DOTCOM,
|
||||||
@@ -44,7 +52,7 @@ const util = __importStar(require("./util"));
|
|||||||
const uploadDatabaseBundleSpy = sinon.spy();
|
const uploadDatabaseBundleSpy = sinon.spy();
|
||||||
const uploadLogsSpy = sinon.spy();
|
const uploadLogsSpy = sinon.spy();
|
||||||
const printDebugLogsSpy = sinon.spy();
|
const printDebugLogsSpy = sinon.spy();
|
||||||
await initActionPostHelper.run(uploadDatabaseBundleSpy, uploadLogsSpy, printDebugLogsSpy);
|
await initActionPostHelper.run(uploadDatabaseBundleSpy, uploadLogsSpy, printDebugLogsSpy, (0, repository_1.parseRepositoryNwo)("github/codeql-action"), (0, testing_utils_1.createFeatures)([]), (0, logging_1.getRunnerLogger)(true));
|
||||||
t.assert(uploadDatabaseBundleSpy.notCalled);
|
t.assert(uploadDatabaseBundleSpy.notCalled);
|
||||||
t.assert(uploadLogsSpy.notCalled);
|
t.assert(uploadLogsSpy.notCalled);
|
||||||
t.assert(printDebugLogsSpy.notCalled);
|
t.assert(printDebugLogsSpy.notCalled);
|
||||||
@@ -52,6 +60,7 @@ const util = __importStar(require("./util"));
|
|||||||
});
|
});
|
||||||
(0, ava_1.default)("post: init action with debug mode on", async (t) => {
|
(0, ava_1.default)("post: init action with debug mode on", async (t) => {
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
|
process.env["GITHUB_REPOSITORY"] = "github/codeql-action-fake-repository";
|
||||||
process.env["RUNNER_TEMP"] = tmpDir;
|
process.env["RUNNER_TEMP"] = tmpDir;
|
||||||
const gitHubVersion = {
|
const gitHubVersion = {
|
||||||
type: util.GitHubVariant.DOTCOM,
|
type: util.GitHubVariant.DOTCOM,
|
||||||
@@ -65,10 +74,90 @@ const util = __importStar(require("./util"));
|
|||||||
const uploadDatabaseBundleSpy = sinon.spy();
|
const uploadDatabaseBundleSpy = sinon.spy();
|
||||||
const uploadLogsSpy = sinon.spy();
|
const uploadLogsSpy = sinon.spy();
|
||||||
const printDebugLogsSpy = sinon.spy();
|
const printDebugLogsSpy = sinon.spy();
|
||||||
await initActionPostHelper.run(uploadDatabaseBundleSpy, uploadLogsSpy, printDebugLogsSpy);
|
await initActionPostHelper.run(uploadDatabaseBundleSpy, uploadLogsSpy, printDebugLogsSpy, (0, repository_1.parseRepositoryNwo)("github/codeql-action"), (0, testing_utils_1.createFeatures)([]), (0, logging_1.getRunnerLogger)(true));
|
||||||
t.assert(uploadDatabaseBundleSpy.called);
|
t.assert(uploadDatabaseBundleSpy.called);
|
||||||
t.assert(uploadLogsSpy.called);
|
t.assert(uploadLogsSpy.called);
|
||||||
t.assert(printDebugLogsSpy.called);
|
t.assert(printDebugLogsSpy.called);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
(0, ava_1.default)("uploads failed SARIF run for typical workflow", async (t) => {
|
||||||
|
const actionsWorkflow = createTestWorkflow([
|
||||||
|
{
|
||||||
|
name: "Checkout repository",
|
||||||
|
uses: "actions/checkout@v3",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Initialize CodeQL",
|
||||||
|
uses: "github/codeql-action/init@v2",
|
||||||
|
with: {
|
||||||
|
languages: "javascript",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Perform CodeQL Analysis",
|
||||||
|
uses: "github/codeql-action/analyze@v2",
|
||||||
|
with: {
|
||||||
|
category: "my-category",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
await testFailedSarifUpload(t, actionsWorkflow, { category: "my-category" });
|
||||||
|
});
|
||||||
|
(0, ava_1.default)("uploading failed SARIF run fails when workflow does not reference github/codeql-action", async (t) => {
|
||||||
|
const actionsWorkflow = createTestWorkflow([
|
||||||
|
{
|
||||||
|
name: "Checkout repository",
|
||||||
|
uses: "actions/checkout@v3",
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
await t.throwsAsync(async () => await testFailedSarifUpload(t, actionsWorkflow));
|
||||||
|
});
|
||||||
|
function createTestWorkflow(steps) {
|
||||||
|
return {
|
||||||
|
name: "CodeQL",
|
||||||
|
on: {
|
||||||
|
push: {
|
||||||
|
branches: ["main"],
|
||||||
|
},
|
||||||
|
pull_request: {
|
||||||
|
branches: ["main"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
jobs: {
|
||||||
|
analyze: {
|
||||||
|
name: "CodeQL Analysis",
|
||||||
|
"runs-on": "ubuntu-latest",
|
||||||
|
steps,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
async function testFailedSarifUpload(t, actionsWorkflow, { category } = {}) {
|
||||||
|
const config = {
|
||||||
|
codeQLCmd: "codeql",
|
||||||
|
debugMode: true,
|
||||||
|
languages: [],
|
||||||
|
packs: [],
|
||||||
|
};
|
||||||
|
const messages = [];
|
||||||
|
process.env["GITHUB_JOB"] = "analyze";
|
||||||
|
process.env["GITHUB_REPOSITORY"] = "github/codeql-action-fake-repository";
|
||||||
|
process.env["GITHUB_WORKSPACE"] =
|
||||||
|
"/home/runner/work/codeql-action/codeql-action";
|
||||||
|
sinon.stub(actionsUtil, "getRequiredInput").withArgs("matrix").returns("{}");
|
||||||
|
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||||
|
sinon.stub(codeql, "getCodeQL").resolves(codeqlObject);
|
||||||
|
const diagnosticsExportStub = sinon.stub(codeqlObject, "diagnosticsExport");
|
||||||
|
sinon.stub(workflow, "getWorkflow").resolves(actionsWorkflow);
|
||||||
|
const uploadFromActions = sinon.stub(uploadLib, "uploadFromActions");
|
||||||
|
uploadFromActions.resolves({ sarifID: "42" });
|
||||||
|
const waitForProcessing = sinon.stub(uploadLib, "waitForProcessing");
|
||||||
|
await initActionPostHelper.uploadFailedSarif(config, (0, repository_1.parseRepositoryNwo)("github/codeql-action"), (0, testing_utils_1.createFeatures)([feature_flags_1.Feature.UploadFailedSarifEnabled]), (0, testing_utils_1.getRecordingLogger)(messages));
|
||||||
|
t.deepEqual(messages, []);
|
||||||
|
t.true(diagnosticsExportStub.calledOnceWith(sinon.match.string, category), `Actual args were: ${diagnosticsExportStub.args}`);
|
||||||
|
t.true(uploadFromActions.calledOnceWith(sinon.match.string, sinon.match.string, category, sinon.match.any), `Actual args were: ${uploadFromActions.args}`);
|
||||||
|
t.true(waitForProcessing.calledOnceWith(sinon.match.any, "42", sinon.match.any, {
|
||||||
|
isUnsuccessfulExecution: true,
|
||||||
|
}));
|
||||||
|
}
|
||||||
//# sourceMappingURL=init-action-post-helper.test.js.map
|
//# sourceMappingURL=init-action-post-helper.test.js.map
|
||||||
File diff suppressed because one or more lines are too long
Generated
+11
-1
@@ -26,11 +26,21 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const core = __importStar(require("@actions/core"));
|
const core = __importStar(require("@actions/core"));
|
||||||
const actionsUtil = __importStar(require("./actions-util"));
|
const actionsUtil = __importStar(require("./actions-util"));
|
||||||
|
const api_client_1 = require("./api-client");
|
||||||
const debugArtifacts = __importStar(require("./debug-artifacts"));
|
const debugArtifacts = __importStar(require("./debug-artifacts"));
|
||||||
|
const feature_flags_1 = require("./feature-flags");
|
||||||
const initActionPostHelper = __importStar(require("./init-action-post-helper"));
|
const initActionPostHelper = __importStar(require("./init-action-post-helper"));
|
||||||
|
const logging_1 = require("./logging");
|
||||||
|
const repository_1 = require("./repository");
|
||||||
|
const util_1 = require("./util");
|
||||||
async function runWrapper() {
|
async function runWrapper() {
|
||||||
try {
|
try {
|
||||||
await initActionPostHelper.run(debugArtifacts.uploadDatabaseBundleDebugArtifact, debugArtifacts.uploadLogsDebugArtifact, actionsUtil.printDebugLogs);
|
const logger = (0, logging_1.getActionsLogger)();
|
||||||
|
const gitHubVersion = await (0, api_client_1.getGitHubVersion)();
|
||||||
|
(0, util_1.checkGitHubVersionInRange)(gitHubVersion, logger);
|
||||||
|
const repositoryNwo = (0, repository_1.parseRepositoryNwo)((0, util_1.getRequiredEnvParam)("GITHUB_REPOSITORY"));
|
||||||
|
const features = new feature_flags_1.Features(gitHubVersion, repositoryNwo, actionsUtil.getTemporaryDirectory(), logger);
|
||||||
|
await initActionPostHelper.run(debugArtifacts.uploadDatabaseBundleDebugArtifact, debugArtifacts.uploadLogsDebugArtifact, actionsUtil.printDebugLogs, repositoryNwo, features, logger);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
core.setFailed(`init post-action step failed: ${error}`);
|
core.setFailed(`init post-action step failed: ${error}`);
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"init-action-post.js","sourceRoot":"","sources":["../src/init-action-post.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;AAEH,oDAAsC;AAEtC,4D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AAC,SAAS,CAAC,iCAAiC,KAAK,EAAE,CAAC,CAAC;QACzD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;KACpB;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"}
|
||||||
Generated
+16
-8
@@ -1,14 +1,22 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.CODEQL_ACTION_TEST_MODE = exports.CODEQL_ACTION_TESTING_ENVIRONMENT = exports.CODEQL_WORKFLOW_STARTED_AT = exports.ODASA_TRACER_CONFIGURATION = void 0;
|
exports.ODASA_TRACER_CONFIGURATION = exports.CODEQL_WORKFLOW_STARTED_AT = exports.CODEQL_ACTION_TEST_MODE = exports.CODEQL_ACTION_TESTING_ENVIRONMENT = exports.CODEQL_ACTION_ANALYZE_DID_UPLOAD_SARIF = void 0;
|
||||||
exports.ODASA_TRACER_CONFIGURATION = "ODASA_TRACER_CONFIGURATION";
|
/**
|
||||||
// The time at which the first action (normally init) started executing.
|
* This environment variable is set to true when the `analyze` Action
|
||||||
// If a workflow invokes a different action without first invoking the init
|
* successfully uploads a SARIF file. It does NOT indicate whether the
|
||||||
// action (i.e. the upload action is being used by a third-party integrator)
|
* SARIF file was processed successfully.
|
||||||
// then this variable will be assigned the start time of the action invoked
|
*/
|
||||||
// rather that the init action.
|
exports.CODEQL_ACTION_ANALYZE_DID_UPLOAD_SARIF = "CODEQL_ACTION_ANALYZE_DID_UPLOAD_SARIF";
|
||||||
exports.CODEQL_WORKFLOW_STARTED_AT = "CODEQL_WORKFLOW_STARTED_AT";
|
|
||||||
exports.CODEQL_ACTION_TESTING_ENVIRONMENT = "CODEQL_ACTION_TESTING_ENVIRONMENT";
|
exports.CODEQL_ACTION_TESTING_ENVIRONMENT = "CODEQL_ACTION_TESTING_ENVIRONMENT";
|
||||||
/** Used to disable uploading SARIF results or status reports to the GitHub API */
|
/** Used to disable uploading SARIF results or status reports to the GitHub API */
|
||||||
exports.CODEQL_ACTION_TEST_MODE = "CODEQL_ACTION_TEST_MODE";
|
exports.CODEQL_ACTION_TEST_MODE = "CODEQL_ACTION_TEST_MODE";
|
||||||
|
/**
|
||||||
|
* The time at which the first action (normally init) started executing.
|
||||||
|
* If a workflow invokes a different action without first invoking the init
|
||||||
|
* action (i.e. the upload action is being used by a third-party integrator)
|
||||||
|
* then this variable will be assigned the start time of the action invoked
|
||||||
|
* rather that the init action.
|
||||||
|
*/
|
||||||
|
exports.CODEQL_WORKFLOW_STARTED_AT = "CODEQL_WORKFLOW_STARTED_AT";
|
||||||
|
exports.ODASA_TRACER_CONFIGURATION = "ODASA_TRACER_CONFIGURATION";
|
||||||
//# sourceMappingURL=shared-environment.js.map
|
//# sourceMappingURL=shared-environment.js.map
|
||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"shared-environment.js","sourceRoot":"","sources":["../src/shared-environment.ts"],"names":[],"mappings":";;;AAAa,QAAA,0BAA0B,GAAG,4BAA4B,CAAC;AACvE,wEAAwE;AACxE,2EAA2E;AAC3E,4EAA4E;AAC5E,2EAA2E;AAC3E,+BAA+B;AAClB,QAAA,0BAA0B,GAAG,4BAA4B,CAAC;AAE1D,QAAA,iCAAiC,GAC5C,mCAAmC,CAAC;AAEtC,kFAAkF;AACrE,QAAA,uBAAuB,GAAG,yBAAyB,CAAC"}
|
{"version":3,"file":"shared-environment.js","sourceRoot":"","sources":["../src/shared-environment.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACU,QAAA,sCAAsC,GACjD,wCAAwC,CAAC;AAE9B,QAAA,iCAAiC,GAC5C,mCAAmC,CAAC;AAEtC,kFAAkF;AACrE,QAAA,uBAAuB,GAAG,yBAAyB,CAAC;AAEjE;;;;;;GAMG;AACU,QAAA,0BAA0B,GAAG,4BAA4B,CAAC;AAE1D,QAAA,0BAA0B,GAAG,4BAA4B,CAAC"}
|
||||||
Generated
+83
-40
@@ -128,9 +128,8 @@ function findSarifFilesInDir(sarifPath) {
|
|||||||
exports.findSarifFilesInDir = findSarifFilesInDir;
|
exports.findSarifFilesInDir = findSarifFilesInDir;
|
||||||
// Uploads a single sarif file or a directory of sarif files
|
// Uploads a single sarif file or a directory of sarif files
|
||||||
// depending on what the path happens to refer to.
|
// depending on what the path happens to refer to.
|
||||||
// Returns true iff the upload occurred and succeeded
|
async function uploadFromActions(sarifPath, checkoutPath, category, logger) {
|
||||||
async function uploadFromActions(sarifPath, logger) {
|
return await uploadFiles(getSarifFilePaths(sarifPath), (0, repository_1.parseRepositoryNwo)(util.getRequiredEnvParam("GITHUB_REPOSITORY")), await actionsUtil.getCommitOid(checkoutPath), await actionsUtil.getRef(), await actionsUtil.getAnalysisKey(), category, util.getRequiredEnvParam("GITHUB_WORKFLOW"), workflow.getWorkflowRunID(), checkoutPath, actionsUtil.getRequiredInput("matrix"), logger);
|
||||||
return await uploadFiles(getSarifFilePaths(sarifPath), (0, repository_1.parseRepositoryNwo)(util.getRequiredEnvParam("GITHUB_REPOSITORY")), await actionsUtil.getCommitOid(actionsUtil.getRequiredInput("checkout_path")), await actionsUtil.getRef(), await actionsUtil.getAnalysisKey(), actionsUtil.getOptionalInput("category"), util.getRequiredEnvParam("GITHUB_WORKFLOW"), workflow.getWorkflowRunID(), actionsUtil.getRequiredInput("checkout_path"), actionsUtil.getRequiredInput("matrix"), logger);
|
|
||||||
}
|
}
|
||||||
exports.uploadFromActions = uploadFromActions;
|
exports.uploadFromActions = uploadFromActions;
|
||||||
function getSarifFilePaths(sarifPath) {
|
function getSarifFilePaths(sarifPath) {
|
||||||
@@ -270,48 +269,92 @@ async function uploadFiles(sarifFiles, repositoryNwo, commitOid, ref, analysisKe
|
|||||||
}
|
}
|
||||||
const STATUS_CHECK_FREQUENCY_MILLISECONDS = 5 * 1000;
|
const STATUS_CHECK_FREQUENCY_MILLISECONDS = 5 * 1000;
|
||||||
const STATUS_CHECK_TIMEOUT_MILLISECONDS = 2 * 60 * 1000;
|
const STATUS_CHECK_TIMEOUT_MILLISECONDS = 2 * 60 * 1000;
|
||||||
// Waits until either the analysis is successfully processed, a processing error is reported, or STATUS_CHECK_TIMEOUT_MILLISECONDS elapses.
|
/**
|
||||||
async function waitForProcessing(repositoryNwo, sarifID, logger) {
|
* Waits until either the analysis is successfully processed, a processing error
|
||||||
|
* is reported, or `STATUS_CHECK_TIMEOUT_MILLISECONDS` elapses.
|
||||||
|
*
|
||||||
|
* If `isUnsuccessfulExecution` is passed, will throw an error if the analysis
|
||||||
|
* processing does not produce a single error mentioning the unsuccessful
|
||||||
|
* execution.
|
||||||
|
*/
|
||||||
|
async function waitForProcessing(repositoryNwo, sarifID, logger, options = {
|
||||||
|
isUnsuccessfulExecution: false,
|
||||||
|
}) {
|
||||||
logger.startGroup("Waiting for processing to finish");
|
logger.startGroup("Waiting for processing to finish");
|
||||||
const client = api.getApiClient();
|
try {
|
||||||
const statusCheckingStarted = Date.now();
|
const client = api.getApiClient();
|
||||||
// eslint-disable-next-line no-constant-condition
|
const statusCheckingStarted = Date.now();
|
||||||
while (true) {
|
// eslint-disable-next-line no-constant-condition
|
||||||
if (Date.now() >
|
while (true) {
|
||||||
statusCheckingStarted + STATUS_CHECK_TIMEOUT_MILLISECONDS) {
|
if (Date.now() >
|
||||||
// If the analysis hasn't finished processing in the allotted time, we continue anyway rather than failing.
|
statusCheckingStarted + STATUS_CHECK_TIMEOUT_MILLISECONDS) {
|
||||||
// It's possible the analysis will eventually finish processing, but it's not worth spending more Actions time waiting.
|
// If the analysis hasn't finished processing in the allotted time, we continue anyway rather than failing.
|
||||||
logger.warning("Timed out waiting for analysis to finish processing. Continuing.");
|
// It's possible the analysis will eventually finish processing, but it's not worth spending more Actions time waiting.
|
||||||
break;
|
logger.warning("Timed out waiting for analysis to finish processing. Continuing.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
let response = undefined;
|
||||||
|
try {
|
||||||
|
response = await client.request("GET /repos/:owner/:repo/code-scanning/sarifs/:sarif_id", {
|
||||||
|
owner: repositoryNwo.owner,
|
||||||
|
repo: repositoryNwo.repo,
|
||||||
|
sarif_id: sarifID,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
logger.warning(`An error occurred checking the status of the delivery. ${e} It should still be processed in the background, but errors that occur during processing may not be reported.`);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
const status = response.data.processing_status;
|
||||||
|
logger.info(`Analysis upload status is ${status}.`);
|
||||||
|
if (status === "pending") {
|
||||||
|
logger.debug("Analysis processing is still pending...");
|
||||||
|
}
|
||||||
|
else if (options.isUnsuccessfulExecution) {
|
||||||
|
// We expect a specific processing error for unsuccessful executions, so
|
||||||
|
// handle these separately.
|
||||||
|
handleProcessingResultForUnsuccessfulExecution(response, status, logger);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (status === "complete") {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (status === "failed") {
|
||||||
|
throw new Error(`Code Scanning could not process the submitted SARIF file:\n${response.data.errors}`);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
util.assertNever(status);
|
||||||
|
}
|
||||||
|
await util.delay(STATUS_CHECK_FREQUENCY_MILLISECONDS);
|
||||||
}
|
}
|
||||||
let response = undefined;
|
|
||||||
try {
|
|
||||||
response = await client.request("GET /repos/:owner/:repo/code-scanning/sarifs/:sarif_id", {
|
|
||||||
owner: repositoryNwo.owner,
|
|
||||||
repo: repositoryNwo.repo,
|
|
||||||
sarif_id: sarifID,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
logger.warning(`An error occurred checking the status of the delivery. ${e} It should still be processed in the background, but errors that occur during processing may not be reported.`);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
const status = response.data.processing_status;
|
|
||||||
logger.info(`Analysis upload status is ${status}.`);
|
|
||||||
if (status === "complete") {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (status === "pending") {
|
|
||||||
logger.debug("Analysis processing is still pending...");
|
|
||||||
}
|
|
||||||
else if (status === "failed") {
|
|
||||||
throw new Error(`Code Scanning could not process the submitted SARIF file:\n${response.data.errors}`);
|
|
||||||
}
|
|
||||||
await util.delay(STATUS_CHECK_FREQUENCY_MILLISECONDS);
|
|
||||||
}
|
}
|
||||||
logger.endGroup();
|
finally {
|
||||||
|
logger.endGroup();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
exports.waitForProcessing = waitForProcessing;
|
exports.waitForProcessing = waitForProcessing;
|
||||||
|
/**
|
||||||
|
* Checks the processing result for an unsuccessful execution. Throws if the
|
||||||
|
* result is not a failure with a single "unsuccessful execution" error.
|
||||||
|
*/
|
||||||
|
function handleProcessingResultForUnsuccessfulExecution(response, status, logger) {
|
||||||
|
if (status === "failed" &&
|
||||||
|
Array.isArray(response.data.errors) &&
|
||||||
|
response.data.errors.length === 1 &&
|
||||||
|
response.data.errors[0].toString().startsWith("unsuccessful execution")) {
|
||||||
|
logger.debug("Successfully uploaded a SARIF file for the unsuccessful execution. Received expected " +
|
||||||
|
'"unsuccessful execution" error, and no other errors.');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const shortMessage = "Failed to upload a SARIF file for the unsuccessful execution. Code scanning status " +
|
||||||
|
"information for the repository may be out of date as a result.";
|
||||||
|
const longMessage = shortMessage + status === "failed"
|
||||||
|
? ` Processing errors: ${response.data.errors}`
|
||||||
|
: ' Encountered no processing errors, but expected to receive an "unsuccessful execution" error.';
|
||||||
|
logger.debug(longMessage);
|
||||||
|
throw new Error(shortMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
function validateUniqueCategory(sarif) {
|
function validateUniqueCategory(sarif) {
|
||||||
var _a, _b, _c;
|
var _a, _b, _c;
|
||||||
// duplicate categories are allowed in the same sarif file
|
// duplicate categories are allowed in the same sarif file
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Generated
+1
-1
@@ -43,7 +43,7 @@ async function run() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const uploadResult = await upload_lib.uploadFromActions(actionsUtil.getRequiredInput("sarif_file"), (0, logging_1.getActionsLogger)());
|
const uploadResult = await upload_lib.uploadFromActions(actionsUtil.getRequiredInput("sarif_file"), actionsUtil.getRequiredInput("checkout_path"), actionsUtil.getOptionalInput("category"), (0, logging_1.getActionsLogger)());
|
||||||
core.setOutput("sarif-id", uploadResult.sarifID);
|
core.setOutput("sarif-id", uploadResult.sarifID);
|
||||||
// We don't upload results in test mode, so don't wait for processing
|
// We don't upload results in test mode, so don't wait for processing
|
||||||
if ((0, util_1.isInTestMode)()) {
|
if ((0, util_1.isInTestMode)()) {
|
||||||
|
|||||||
@@ -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,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAMvC,KAAK,UAAU,uBAAuB,CACpC,SAAe,EACf,WAA0C;IAE1C,MAAM,gBAAgB,GAAG,MAAM,WAAW,CAAC,sBAAsB,CAC/D,cAAc,EACd,SAAS,EACT,SAAS,CACV,CAAC;IACF,MAAM,YAAY,GAA4B;QAC5C,GAAG,gBAAgB;QACnB,GAAG,WAAW;KACf,CAAC;IACF,MAAM,WAAW,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;AACnD,CAAC;AAED,KAAK,UAAU,GAAG;IAChB,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;IAC7B,IAAA,4BAAqB,EAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACnC,MAAM,IAAA,yBAAkB,EAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACtC,IACE,CAAC,CAAC,MAAM,WAAW,CAAC,g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,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"}
|
{"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,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAMvC,KAAK,UAAU,uBAAuB,CACpC,SAAe,EACf,WAA0C;IAE1C,MAAM,gBAAgB,GAAG,MAAM,WAAW,CAAC,sBAAsB,CAC/D,cAAc,EACd,SAAS,EACT,SAAS,CACV,CAAC;IACF,MAAM,YAAY,GAA4B;QAC5C,GAAG,gBAAgB;QACnB,GAAG,WAAW;KACf,CAAC;IACF,MAAM,WAAW,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;AACnD,CAAC;AAED,KAAK,UAAU,GAAG;IAChB,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;IAC7B,IAAA,4BAAqB,EAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACnC,MAAM,IAAA,yBAAkB,EAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACtC,IACE,CAAC,CAAC,MAAM,WAAW,CAAC,gBAAgB,CAClC,MAAM,WAAW,CAAC,sBAAsB,CACtC,cAAc,EACd,UAAU,EACV,SAAS,CACV,CACF,CAAC,EACF;QACA,OAAO;K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AS,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"}
|
||||||
Generated
+8
-1
@@ -22,7 +22,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.shouldBypassToolcache = exports.isHostedRunner = exports.checkForTimeout = exports.withTimeout = exports.tryGetFolderBytes = exports.listFolder = exports.doesDirectoryExist = exports.logCodeScanningConfigInCli = exports.useCodeScanningConfigInCli = exports.isInTestMode = exports.checkActionVersion = exports.getMlPoweredJsQueriesStatus = exports.getMlPoweredJsQueriesPack = exports.ML_POWERED_JS_QUERIES_PACK_NAME = exports.isGoodVersion = exports.delay = exports.bundleDb = exports.codeQlVersionAbove = exports.getCachedCodeQlVersion = exports.cacheCodeQlVersion = exports.isHTTPError = exports.UserError = exports.HTTPError = exports.getRequiredEnvParam = exports.enrichEnvironment = exports.initializeEnvironment = exports.EnvVar = exports.assertNever = 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.DID_AUTOBUILD_GO_ENV_VAR_NAME = exports.DEFAULT_DEBUG_DATABASE_NAME = exports.DEFAULT_DEBUG_ARTIFACT_NAME = exports.GITHUB_DOTCOM_URL = void 0;
|
exports.parseMatrixInput = exports.shouldBypassToolcache = exports.isHostedRunner = exports.checkForTimeout = exports.withTimeout = exports.tryGetFolderBytes = exports.listFolder = exports.doesDirectoryExist = exports.logCodeScanningConfigInCli = exports.useCodeScanningConfigInCli = exports.isInTestMode = exports.checkActionVersion = exports.getMlPoweredJsQueriesStatus = exports.getMlPoweredJsQueriesPack = exports.ML_POWERED_JS_QUERIES_PACK_NAME = exports.isGoodVersion = exports.delay = exports.bundleDb = exports.codeQlVersionAbove = exports.getCachedCodeQlVersion = exports.cacheCodeQlVersion = exports.isHTTPError = exports.UserError = exports.HTTPError = exports.getRequiredEnvParam = exports.enrichEnvironment = exports.initializeEnvironment = exports.EnvVar = exports.assertNever = 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.DID_AUTOBUILD_GO_ENV_VAR_NAME = exports.DEFAULT_DEBUG_DATABASE_NAME = exports.DEFAULT_DEBUG_ARTIFACT_NAME = exports.GITHUB_DOTCOM_URL = void 0;
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const os = __importStar(require("os"));
|
const os = __importStar(require("os"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
@@ -750,4 +750,11 @@ async function shouldBypassToolcache(featuresEnablement, codeqlUrl, languagesInp
|
|||||||
return bypass;
|
return bypass;
|
||||||
}
|
}
|
||||||
exports.shouldBypassToolcache = shouldBypassToolcache;
|
exports.shouldBypassToolcache = shouldBypassToolcache;
|
||||||
|
function parseMatrixInput(matrixInput) {
|
||||||
|
if (matrixInput === undefined || matrixInput === "null") {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return JSON.parse(matrixInput);
|
||||||
|
}
|
||||||
|
exports.parseMatrixInput = parseMatrixInput;
|
||||||
//# sourceMappingURL=util.js.map
|
//# sourceMappingURL=util.js.map
|
||||||
+1
-1
File diff suppressed because one or more lines are too long
Generated
+61
-19
@@ -19,7 +19,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.getCategoryInputOrThrow = exports.getWorkflowRunID = exports.getWorkflowPath = exports.getWorkflow = exports.formatWorkflowCause = exports.formatWorkflowErrors = exports.validateWorkflow = exports.getWorkflowErrors = exports.WorkflowErrors = exports.patternIsSuperset = void 0;
|
exports.getCheckoutPathInputOrThrow = exports.getUploadInputOrThrow = exports.getCategoryInputOrThrow = exports.getWorkflowRunID = exports.getWorkflowPath = exports.getWorkflow = exports.formatWorkflowCause = exports.formatWorkflowErrors = exports.validateWorkflow = exports.getWorkflowErrors = exports.WorkflowErrors = exports.patternIsSuperset = void 0;
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const core = __importStar(require("@actions/core"));
|
const core = __importStar(require("@actions/core"));
|
||||||
@@ -264,34 +264,48 @@ function getStepsCallingAction(job, actionName) {
|
|||||||
* determine that no such input is passed to the Action.
|
* determine that no such input is passed to the Action.
|
||||||
*/
|
*/
|
||||||
function getInputOrThrow(workflow, jobName, actionName, inputName, matrixVars) {
|
function getInputOrThrow(workflow, jobName, actionName, inputName, matrixVars) {
|
||||||
|
var _a;
|
||||||
|
const preamble = `Could not get ${inputName} input to ${actionName} since`;
|
||||||
if (!workflow.jobs) {
|
if (!workflow.jobs) {
|
||||||
throw new Error(`Could not get ${inputName} input to ${actionName} since the workflow has no jobs.`);
|
throw new Error(`${preamble} the workflow has no jobs.`);
|
||||||
}
|
}
|
||||||
if (!workflow.jobs[jobName]) {
|
if (!workflow.jobs[jobName]) {
|
||||||
throw new Error(`Could not get ${inputName} input to ${actionName} since the workflow has no job named ${jobName}.`);
|
throw new Error(`${preamble} the workflow has no job named ${jobName}.`);
|
||||||
}
|
}
|
||||||
const inputs = getStepsCallingAction(workflow.jobs[jobName], actionName)
|
const stepsCallingAction = getStepsCallingAction(workflow.jobs[jobName], actionName);
|
||||||
.map((step) => { var _a; return (_a = step.with) === null || _a === void 0 ? void 0 : _a[inputName]; })
|
if (stepsCallingAction.length === 0) {
|
||||||
.filter((input) => input !== undefined)
|
throw new Error(`${preamble} the ${jobName} job does not call ${actionName}.`);
|
||||||
.map((input) => input);
|
|
||||||
if (inputs.length === 0) {
|
|
||||||
return undefined;
|
|
||||||
}
|
}
|
||||||
if (!inputs.every((input) => input === inputs[0])) {
|
else if (stepsCallingAction.length > 1) {
|
||||||
throw new Error(`Could not get ${inputName} input to ${actionName} since there were multiple steps calling ` +
|
throw new Error(`${preamble} the ${jobName} job calls ${actionName} multiple times.`);
|
||||||
`${actionName} with different values for ${inputName}.`);
|
|
||||||
}
|
}
|
||||||
// Make a basic attempt to substitute matrix variables
|
let input = (_a = stepsCallingAction[0].with) === null || _a === void 0 ? void 0 : _a[inputName];
|
||||||
// First normalize by removing whitespace
|
if (input !== undefined && matrixVars !== undefined) {
|
||||||
let input = inputs[0].replace(/\${{\s+/, "${{").replace(/\s+}}/, "}}");
|
// Make a basic attempt to substitute matrix variables
|
||||||
for (const [key, value] of Object.entries(matrixVars)) {
|
// First normalize by removing whitespace
|
||||||
input = input.replace(`\${{matrix.${key}}}`, value);
|
input = input.replace(/\${{\s+/, "${{").replace(/\s+}}/, "}}");
|
||||||
|
for (const [key, value] of Object.entries(matrixVars)) {
|
||||||
|
input = input.replace(`\${{matrix.${key}}}`, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (input.includes("${{")) {
|
if (input !== undefined && input.includes("${{")) {
|
||||||
throw new Error(`Could not get ${inputName} input to ${actionName} since it contained an unrecognized dynamic value.`);
|
throw new Error(`Could not get ${inputName} input to ${actionName} since it contained an unrecognized dynamic value.`);
|
||||||
}
|
}
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Get the expected name of the analyze Action.
|
||||||
|
*
|
||||||
|
* This allows us to test workflow parsing functionality as a CodeQL Action PR check.
|
||||||
|
*/
|
||||||
|
function getAnalyzeActionName() {
|
||||||
|
if ((0, util_1.getRequiredEnvParam)("GITHUB_REPOSITORY") === "github/codeql-action") {
|
||||||
|
return "./analyze";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return "github/codeql-action/analyze";
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Makes a best effort attempt to retrieve the category input for the particular job,
|
* Makes a best effort attempt to retrieve the category input for the particular job,
|
||||||
* given a set of matrix variables.
|
* given a set of matrix variables.
|
||||||
@@ -302,7 +316,35 @@ function getInputOrThrow(workflow, jobName, actionName, inputName, matrixVars) {
|
|||||||
* @throws an error if the category input could not be determined
|
* @throws an error if the category input could not be determined
|
||||||
*/
|
*/
|
||||||
function getCategoryInputOrThrow(workflow, jobName, matrixVars) {
|
function getCategoryInputOrThrow(workflow, jobName, matrixVars) {
|
||||||
return getInputOrThrow(workflow, jobName, "github/codeql-action/analyze", "category", matrixVars);
|
return getInputOrThrow(workflow, jobName, getAnalyzeActionName(), "category", matrixVars);
|
||||||
}
|
}
|
||||||
exports.getCategoryInputOrThrow = getCategoryInputOrThrow;
|
exports.getCategoryInputOrThrow = getCategoryInputOrThrow;
|
||||||
|
/**
|
||||||
|
* Makes a best effort attempt to retrieve the upload input for the particular job,
|
||||||
|
* given a set of matrix variables.
|
||||||
|
*
|
||||||
|
* Typically you'll want to wrap this function in a try/catch block and handle the error.
|
||||||
|
*
|
||||||
|
* @returns the upload input
|
||||||
|
* @throws an error if the upload input could not be determined
|
||||||
|
*/
|
||||||
|
function getUploadInputOrThrow(workflow, jobName, matrixVars) {
|
||||||
|
return (getInputOrThrow(workflow, jobName, getAnalyzeActionName(), "upload", matrixVars) || "true" // if unspecified, upload defaults to true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
exports.getUploadInputOrThrow = getUploadInputOrThrow;
|
||||||
|
/**
|
||||||
|
* Makes a best effort attempt to retrieve the checkout_path input for the
|
||||||
|
* particular job, given a set of matrix variables.
|
||||||
|
*
|
||||||
|
* Typically you'll want to wrap this function in a try/catch block and handle the error.
|
||||||
|
*
|
||||||
|
* @returns the checkout_path input
|
||||||
|
* @throws an error if the checkout_path input could not be determined
|
||||||
|
*/
|
||||||
|
function getCheckoutPathInputOrThrow(workflow, jobName, matrixVars) {
|
||||||
|
return (getInputOrThrow(workflow, jobName, getAnalyzeActionName(), "checkout_path", matrixVars) || (0, util_1.getRequiredEnvParam)("GITHUB_WORKSPACE") // if unspecified, checkout_path defaults to ${{ github.workspace }}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
exports.getCheckoutPathInputOrThrow = getCheckoutPathInputOrThrow;
|
||||||
//# sourceMappingURL=workflow.js.map
|
//# sourceMappingURL=workflow.js.map
|
||||||
+1
-1
File diff suppressed because one or more lines are too long
Generated
+9
-3
@@ -356,6 +356,7 @@ function errorCodes(actual, expected) {
|
|||||||
`)), []));
|
`)), []));
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("getCategoryInputOrThrow returns category for simple workflow with category", (t) => {
|
(0, ava_1.default)("getCategoryInputOrThrow returns category for simple workflow with category", (t) => {
|
||||||
|
process.env["GITHUB_REPOSITORY"] = "github/codeql-action-fake-repository";
|
||||||
t.is((0, workflow_1.getCategoryInputOrThrow)(yaml.load(`
|
t.is((0, workflow_1.getCategoryInputOrThrow)(yaml.load(`
|
||||||
jobs:
|
jobs:
|
||||||
analysis:
|
analysis:
|
||||||
@@ -369,6 +370,7 @@ function errorCodes(actual, expected) {
|
|||||||
`), "analysis", {}), "some-category");
|
`), "analysis", {}), "some-category");
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("getCategoryInputOrThrow returns undefined for simple workflow without category", (t) => {
|
(0, ava_1.default)("getCategoryInputOrThrow returns undefined for simple workflow without category", (t) => {
|
||||||
|
process.env["GITHUB_REPOSITORY"] = "github/codeql-action-fake-repository";
|
||||||
t.is((0, workflow_1.getCategoryInputOrThrow)(yaml.load(`
|
t.is((0, workflow_1.getCategoryInputOrThrow)(yaml.load(`
|
||||||
jobs:
|
jobs:
|
||||||
analysis:
|
analysis:
|
||||||
@@ -380,6 +382,7 @@ function errorCodes(actual, expected) {
|
|||||||
`), "analysis", {}), undefined);
|
`), "analysis", {}), undefined);
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("getCategoryInputOrThrow returns category for workflow with multiple jobs", (t) => {
|
(0, ava_1.default)("getCategoryInputOrThrow returns category for workflow with multiple jobs", (t) => {
|
||||||
|
process.env["GITHUB_REPOSITORY"] = "github/codeql-action-fake-repository";
|
||||||
t.is((0, workflow_1.getCategoryInputOrThrow)(yaml.load(`
|
t.is((0, workflow_1.getCategoryInputOrThrow)(yaml.load(`
|
||||||
jobs:
|
jobs:
|
||||||
foo:
|
foo:
|
||||||
@@ -403,6 +406,7 @@ function errorCodes(actual, expected) {
|
|||||||
`), "bar", {}), "bar-category");
|
`), "bar", {}), "bar-category");
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("getCategoryInputOrThrow finds category for workflow with language matrix", (t) => {
|
(0, ava_1.default)("getCategoryInputOrThrow finds category for workflow with language matrix", (t) => {
|
||||||
|
process.env["GITHUB_REPOSITORY"] = "github/codeql-action-fake-repository";
|
||||||
t.is((0, workflow_1.getCategoryInputOrThrow)(yaml.load(`
|
t.is((0, workflow_1.getCategoryInputOrThrow)(yaml.load(`
|
||||||
jobs:
|
jobs:
|
||||||
analysis:
|
analysis:
|
||||||
@@ -421,6 +425,7 @@ function errorCodes(actual, expected) {
|
|||||||
`), "analysis", { language: "javascript" }), "/language:javascript");
|
`), "analysis", { language: "javascript" }), "/language:javascript");
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("getCategoryInputOrThrow throws error for workflow with dynamic category", (t) => {
|
(0, ava_1.default)("getCategoryInputOrThrow throws error for workflow with dynamic category", (t) => {
|
||||||
|
process.env["GITHUB_REPOSITORY"] = "github/codeql-action-fake-repository";
|
||||||
t.throws(() => (0, workflow_1.getCategoryInputOrThrow)(yaml.load(`
|
t.throws(() => (0, workflow_1.getCategoryInputOrThrow)(yaml.load(`
|
||||||
jobs:
|
jobs:
|
||||||
analysis:
|
analysis:
|
||||||
@@ -435,7 +440,8 @@ function errorCodes(actual, expected) {
|
|||||||
"an unrecognized dynamic value.",
|
"an unrecognized dynamic value.",
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("getCategoryInputOrThrow throws error for workflow with multiple categories", (t) => {
|
(0, ava_1.default)("getCategoryInputOrThrow throws error for workflow with multiple calls to analyze", (t) => {
|
||||||
|
process.env["GITHUB_REPOSITORY"] = "github/codeql-action-fake-repository";
|
||||||
t.throws(() => (0, workflow_1.getCategoryInputOrThrow)(yaml.load(`
|
t.throws(() => (0, workflow_1.getCategoryInputOrThrow)(yaml.load(`
|
||||||
jobs:
|
jobs:
|
||||||
analysis:
|
analysis:
|
||||||
@@ -450,8 +456,8 @@ function errorCodes(actual, expected) {
|
|||||||
with:
|
with:
|
||||||
category: another-category
|
category: another-category
|
||||||
`), "analysis", {}), {
|
`), "analysis", {}), {
|
||||||
message: "Could not get category input to github/codeql-action/analyze since there were multiple steps " +
|
message: "Could not get category input to github/codeql-action/analyze since the analysis job " +
|
||||||
"calling github/codeql-action/analyze with different values for category.",
|
"calls github/codeql-action/analyze multiple times.",
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
//# sourceMappingURL=workflow.test.js.map
|
//# sourceMappingURL=workflow.test.js.map
|
||||||
File diff suppressed because one or more lines are too long
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "codeql",
|
"name": "codeql",
|
||||||
"version": "2.1.36",
|
"version": "2.1.37",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "codeql",
|
"name": "codeql",
|
||||||
"version": "2.1.36",
|
"version": "2.1.37",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "codeql",
|
"name": "codeql",
|
||||||
"version": "2.1.36",
|
"version": "2.1.37",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/artifact": "^1.1.0",
|
"@actions/artifact": "^1.1.0",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "codeql",
|
"name": "codeql",
|
||||||
"version": "2.1.36",
|
"version": "2.1.37",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "CodeQL action",
|
"description": "CodeQL action",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -2,11 +2,11 @@ name: "Export file baseline information"
|
|||||||
description: "Tests that file baseline information is exported when the feature is enabled"
|
description: "Tests that file baseline information is exported when the feature is enabled"
|
||||||
versions: ["nightly-latest"]
|
versions: ["nightly-latest"]
|
||||||
steps:
|
steps:
|
||||||
- uses: swift-actions/setup-swift@5cdaa9161ad1f55ae39a5ea1784ef96de72f95d9
|
- uses: swift-actions/setup-swift@194625b58a582570f61cc707c3b558086c26b723
|
||||||
# Windows doesn't support Swift, and only macOS latest and nightly-latest support Swift 5.7.1.
|
# Windows doesn't support Swift, and only macOS latest and nightly-latest support Swift 5.7.1.
|
||||||
if: runner.os == 'Linux' || (runner.os == 'macOS' && matrix.version == 'cached')
|
if: runner.os == 'Linux' || (runner.os == 'macOS' && matrix.version == 'cached')
|
||||||
with:
|
with:
|
||||||
swift-version: "5.7"
|
swift-version: "5.7.0"
|
||||||
- uses: ./../action/init
|
- uses: ./../action/init
|
||||||
with:
|
with:
|
||||||
languages: javascript
|
languages: javascript
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
name: "Multi-language repository"
|
name: "Multi-language repository"
|
||||||
description: "An end-to-end integration test of a multi-language repository using automatic language detection"
|
description: "An end-to-end integration test of a multi-language repository using automatic language detection"
|
||||||
|
# Temporarily exclude nightly-latest to unblock release
|
||||||
|
versions: ["stable-20211005", "stable-20220120", "stable-20220401", "cached", "latest"]
|
||||||
operatingSystems: ["ubuntu", "macos"]
|
operatingSystems: ["ubuntu", "macos"]
|
||||||
env:
|
env:
|
||||||
CODEQL_ENABLE_EXPERIMENTAL_FEATURES_SWIFT: "true" # Remove when Swift is GA.
|
CODEQL_ENABLE_EXPERIMENTAL_FEATURES_SWIFT: "true" # Remove when Swift is GA.
|
||||||
steps:
|
steps:
|
||||||
- uses: swift-actions/setup-swift@5cdaa9161ad1f55ae39a5ea1784ef96de72f95d9
|
- uses: swift-actions/setup-swift@194625b58a582570f61cc707c3b558086c26b723
|
||||||
# Only macOS latest and nightly-latest support Swift 5.7.1
|
# Only macOS latest and nightly-latest support Swift 5.7.1
|
||||||
if: runner.os == 'Linux' || matrix.version == 'cached'
|
if: runner.os == 'Linux' || matrix.version == 'cached'
|
||||||
with:
|
with:
|
||||||
swift-version: "5.7"
|
swift-version: "5.7.0"
|
||||||
|
|
||||||
- uses: ./../action/init
|
- uses: ./../action/init
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
name: Submit SARIF after failure
|
||||||
|
description: Check that a SARIF file is submitted for the workflow run if it fails
|
||||||
|
versions: ["latest", "cached", "nightly-latest"]
|
||||||
|
operatingSystems: ["ubuntu"]
|
||||||
|
|
||||||
|
env:
|
||||||
|
# Internal-only environment variable used to indicate that the post-init Action
|
||||||
|
# should expect to upload a SARIF file for the failed run.
|
||||||
|
CODEQL_ACTION_EXPECT_UPLOAD_FAILED_SARIF: true
|
||||||
|
# Make sure the uploading SARIF files feature is enabled.
|
||||||
|
CODEQL_ACTION_UPLOAD_FAILED_SARIF: true
|
||||||
|
# Upload the failed SARIF file as an integration test of the API endpoint.
|
||||||
|
CODEQL_ACTION_TEST_MODE: false
|
||||||
|
# Mark telemetry for this workflow so it can be treated separately.
|
||||||
|
CODEQL_ACTION_TESTING_ENVIRONMENT: codeql-action-pr-checks
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: ./init
|
||||||
|
with:
|
||||||
|
languages: javascript
|
||||||
|
- name: Fail
|
||||||
|
# We want this job to pass if the Action correctly uploads the SARIF file for
|
||||||
|
# the failed run.
|
||||||
|
# Setting this step to continue on error means that it is marked as completing
|
||||||
|
# successfully, so will not fail the job.
|
||||||
|
continue-on-error: true
|
||||||
|
run: exit 1
|
||||||
|
- uses: ./analyze
|
||||||
|
# In a real workflow, this step wouldn't run. Since we used `continue-on-error`
|
||||||
|
# above, we manually disable it with an `if` condition.
|
||||||
|
if: false
|
||||||
|
with:
|
||||||
|
category: "/test-codeql-version:${{ matrix.version }}"
|
||||||
@@ -6,11 +6,11 @@ operatingSystems: ["macos"]
|
|||||||
env:
|
env:
|
||||||
CODEQL_ENABLE_EXPERIMENTAL_FEATURES_SWIFT: "true"
|
CODEQL_ENABLE_EXPERIMENTAL_FEATURES_SWIFT: "true"
|
||||||
steps:
|
steps:
|
||||||
- uses: swift-actions/setup-swift@5cdaa9161ad1f55ae39a5ea1784ef96de72f95d9
|
- uses: swift-actions/setup-swift@194625b58a582570f61cc707c3b558086c26b723
|
||||||
# Only macOS latest and nightly-latest support Swift 5.7.1
|
# Only macOS latest and nightly-latest support Swift 5.7.1
|
||||||
if: runner.os == 'Linux' || matrix.version == 'cached'
|
if: runner.os == 'Linux' || matrix.version == 'cached'
|
||||||
with:
|
with:
|
||||||
swift-version: "5.7"
|
swift-version: "5.7.0"
|
||||||
- uses: ./../action/init
|
- uses: ./../action/init
|
||||||
with:
|
with:
|
||||||
languages: swift
|
languages: swift
|
||||||
|
|||||||
@@ -1,16 +1,17 @@
|
|||||||
name: "Swift analysis using a custom build command"
|
name: "Swift analysis using a custom build command"
|
||||||
description: "Tests creation of a Swift database using custom build"
|
description: "Tests creation of a Swift database using custom build"
|
||||||
versions: ["latest", "cached", "nightly-latest"]
|
# Temporarily exclude nightly-latest to unblock release
|
||||||
|
versions: ["latest", "cached"]
|
||||||
operatingSystems: ["ubuntu", "macos"]
|
operatingSystems: ["ubuntu", "macos"]
|
||||||
env:
|
env:
|
||||||
CODEQL_ENABLE_EXPERIMENTAL_FEATURES_SWIFT: "true"
|
CODEQL_ENABLE_EXPERIMENTAL_FEATURES_SWIFT: "true"
|
||||||
DOTNET_GENERATE_ASPNET_CERTIFICATE: "false"
|
DOTNET_GENERATE_ASPNET_CERTIFICATE: "false"
|
||||||
steps:
|
steps:
|
||||||
- uses: swift-actions/setup-swift@5cdaa9161ad1f55ae39a5ea1784ef96de72f95d9
|
- uses: swift-actions/setup-swift@194625b58a582570f61cc707c3b558086c26b723
|
||||||
# Only macOS latest and nightly-latest support Swift 5.7.1
|
# Only macOS latest and nightly-latest support Swift 5.7.1
|
||||||
if: runner.os == 'Linux' || matrix.version == 'cached'
|
if: runner.os == 'Linux' || matrix.version == 'cached'
|
||||||
with:
|
with:
|
||||||
swift-version: "5.7"
|
swift-version: "5.7.0"
|
||||||
- uses: ./../action/init
|
- uses: ./../action/init
|
||||||
with:
|
with:
|
||||||
languages: swift
|
languages: swift
|
||||||
|
|||||||
+2
-1
@@ -115,7 +115,8 @@ for file in os.listdir('checks'):
|
|||||||
checkJob[key] = checkSpecification[key]
|
checkJob[key] = checkSpecification[key]
|
||||||
|
|
||||||
checkJob['env'] = checkJob.get('env', {})
|
checkJob['env'] = checkJob.get('env', {})
|
||||||
checkJob['env']['CODEQL_ACTION_TEST_MODE'] = True
|
if 'CODEQL_ACTION_TEST_MODE' not in checkJob['env']:
|
||||||
|
checkJob['env']['CODEQL_ACTION_TEST_MODE'] = True
|
||||||
checkName = file[:len(file) - 4]
|
checkName = file[:len(file) - 4]
|
||||||
|
|
||||||
with open(f"../.github/workflows/__{checkName}.yml", 'w') as output_stream:
|
with open(f"../.github/workflows/__{checkName}.yml", 'w') as output_stream:
|
||||||
|
|||||||
@@ -33,10 +33,17 @@ def _check_output(command, extra_env={}):
|
|||||||
|
|
||||||
def install_packages_with_poetry():
|
def install_packages_with_poetry():
|
||||||
|
|
||||||
# To handle poetry 1.2, which started to use keyring interaction MUCH more, we need
|
extra_poetry_env = {
|
||||||
# add a workaround. See
|
# To handle poetry 1.2, which started to use keyring interaction MUCH more, we need
|
||||||
# https://github.com/python-poetry/poetry/issues/2692#issuecomment-1235683370
|
# add a workaround. See
|
||||||
extra_poetry_env = {"PYTHON_KEYRING_BACKEND": "keyring.backends.null.Keyring"}
|
# https://github.com/python-poetry/poetry/issues/2692#issuecomment-1235683370
|
||||||
|
"PYTHON_KEYRING_BACKEND": "keyring.backends.null.Keyring",
|
||||||
|
# Projects that specify `virtualenvs.in-project = true` in their poetry.toml
|
||||||
|
# would get the venv created inside the repo directory, which would cause CodeQL
|
||||||
|
# to consider it as user-written code. We don't want this to happen. see
|
||||||
|
# https://python-poetry.org/docs/configuration/#virtualenvsin-project
|
||||||
|
"POETRY_VIRTUALENVS_IN_PROJECT": "False",
|
||||||
|
}
|
||||||
|
|
||||||
command = [sys.executable, '-m', 'poetry']
|
command = [sys.executable, '-m', 'poetry']
|
||||||
if sys.platform.startswith('win32'):
|
if sys.platform.startswith('win32'):
|
||||||
|
|||||||
+15
-14
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"_meta": {
|
"_meta": {
|
||||||
"hash": {
|
"hash": {
|
||||||
"sha256": "cbd95e61b2b1e90be5379b643dfef7e88a1a4359e9a76803c2ca09b0caa83525"
|
"sha256": "acbc8c4e7f2f98f1059b2a93d581ef43f4aa0c9741e64e6253adff8e35fbd99e"
|
||||||
},
|
},
|
||||||
"pipfile-spec": 6,
|
"pipfile-spec": 6,
|
||||||
"requires": {
|
"requires": {
|
||||||
@@ -18,26 +18,27 @@
|
|||||||
"default": {
|
"default": {
|
||||||
"certifi": {
|
"certifi": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:78884e7c1d4b00ce3cea67b44566851c4343c120abd683433ce934a68ea58872",
|
"sha256:35824b4c3a97115964b408844d64aa14db1cc518f6562e8d7261699d1350a9e3",
|
||||||
"sha256:d62a0163eb4c2344ac042ab2bdf75399a71a2d8c7d47eac2e2ee91b9d6339569"
|
"sha256:4ad3232f5e926d6718ec31cfc1fcadfde020920e278684144551c91769c7bc18"
|
||||||
],
|
],
|
||||||
"version": "==2021.10.8"
|
"index": "pypi",
|
||||||
|
"version": "==2022.12.7"
|
||||||
},
|
},
|
||||||
"charset-normalizer": {
|
"charset-normalizer": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:e019de665e2bcf9c2b64e2e5aa025fa991da8720daa3c1138cadd2fd1856aed0",
|
"sha256:2857e29ff0d34db842cd7ca3230549d1a697f96ee6d3fb071cfa6c7393832597",
|
||||||
"sha256:f7af805c321bfa1ce6714c51f254e0d5bb5e5834039bc17db7ebe3a4cec9492b"
|
"sha256:6881edbebdb17b39b4eaaa821b438bf6eddffb4468cf344f09f89def34a8b1df"
|
||||||
],
|
],
|
||||||
"markers": "python_version >= '3'",
|
"markers": "python_version >= '3'",
|
||||||
"version": "==2.0.7"
|
"version": "==2.0.12"
|
||||||
},
|
},
|
||||||
"idna": {
|
"idna": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff",
|
"sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4",
|
||||||
"sha256:9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d"
|
"sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2"
|
||||||
],
|
],
|
||||||
"markers": "python_version >= '3'",
|
"markers": "python_version >= '3'",
|
||||||
"version": "==3.3"
|
"version": "==3.4"
|
||||||
},
|
},
|
||||||
"requests": {
|
"requests": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
@@ -49,11 +50,11 @@
|
|||||||
},
|
},
|
||||||
"urllib3": {
|
"urllib3": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:4987c65554f7a2dbf30c18fd48778ef124af6fab771a377103da0585e2336ece",
|
"sha256:47cc05d99aaa09c9e72ed5809b60e7ba354e64b59c9c173ac3018642d8bb41fc",
|
||||||
"sha256:c4fdf4019605b6e5423637e01bc9fe4daef873709a7973e195ceba0a62bbc844"
|
"sha256:c083dd0dce68dbfbe1129d5271cb90f9447dea7d52097c6e0126120c521ddea8"
|
||||||
],
|
],
|
||||||
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4'",
|
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'",
|
||||||
"version": "==1.26.7"
|
"version": "==1.26.13"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"develop": {}
|
"develop": {}
|
||||||
|
|||||||
+15
-14
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"_meta": {
|
"_meta": {
|
||||||
"hash": {
|
"hash": {
|
||||||
"sha256": "9e4895d52c597b97d49cf69d314224f6738668271d51f71534063f42b565e85c"
|
"sha256": "70e8bf6bc774f5ca177467cab4e67d4264d0536857993326abc13ff43063bec0"
|
||||||
},
|
},
|
||||||
"pipfile-spec": 6,
|
"pipfile-spec": 6,
|
||||||
"requires": {},
|
"requires": {},
|
||||||
@@ -16,26 +16,27 @@
|
|||||||
"default": {
|
"default": {
|
||||||
"certifi": {
|
"certifi": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:78884e7c1d4b00ce3cea67b44566851c4343c120abd683433ce934a68ea58872",
|
"sha256:35824b4c3a97115964b408844d64aa14db1cc518f6562e8d7261699d1350a9e3",
|
||||||
"sha256:d62a0163eb4c2344ac042ab2bdf75399a71a2d8c7d47eac2e2ee91b9d6339569"
|
"sha256:4ad3232f5e926d6718ec31cfc1fcadfde020920e278684144551c91769c7bc18"
|
||||||
],
|
],
|
||||||
"version": "==2021.10.8"
|
"index": "pypi",
|
||||||
|
"version": "==2022.12.7"
|
||||||
},
|
},
|
||||||
"charset-normalizer": {
|
"charset-normalizer": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:e019de665e2bcf9c2b64e2e5aa025fa991da8720daa3c1138cadd2fd1856aed0",
|
"sha256:2857e29ff0d34db842cd7ca3230549d1a697f96ee6d3fb071cfa6c7393832597",
|
||||||
"sha256:f7af805c321bfa1ce6714c51f254e0d5bb5e5834039bc17db7ebe3a4cec9492b"
|
"sha256:6881edbebdb17b39b4eaaa821b438bf6eddffb4468cf344f09f89def34a8b1df"
|
||||||
],
|
],
|
||||||
"markers": "python_version >= '3'",
|
"markers": "python_version >= '3'",
|
||||||
"version": "==2.0.7"
|
"version": "==2.0.12"
|
||||||
},
|
},
|
||||||
"idna": {
|
"idna": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff",
|
"sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4",
|
||||||
"sha256:9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d"
|
"sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2"
|
||||||
],
|
],
|
||||||
"markers": "python_version >= '3'",
|
"markers": "python_version >= '3'",
|
||||||
"version": "==3.3"
|
"version": "==3.4"
|
||||||
},
|
},
|
||||||
"requests": {
|
"requests": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
@@ -47,11 +48,11 @@
|
|||||||
},
|
},
|
||||||
"urllib3": {
|
"urllib3": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:4987c65554f7a2dbf30c18fd48778ef124af6fab771a377103da0585e2336ece",
|
"sha256:47cc05d99aaa09c9e72ed5809b60e7ba354e64b59c9c173ac3018642d8bb41fc",
|
||||||
"sha256:c4fdf4019605b6e5423637e01bc9fe4daef873709a7973e195ceba0a62bbc844"
|
"sha256:c083dd0dce68dbfbe1129d5271cb90f9447dea7d52097c6e0126120c521ddea8"
|
||||||
],
|
],
|
||||||
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4'",
|
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'",
|
||||||
"version": "==1.26.7"
|
"version": "==1.26.13"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"develop": {}
|
"develop": {}
|
||||||
|
|||||||
+8
-8
@@ -1,10 +1,10 @@
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "certifi"
|
name = "certifi"
|
||||||
version = "2021.10.8"
|
version = "2022.12.7"
|
||||||
description = "Python package for providing Mozilla's CA Bundle."
|
description = "Python package for providing Mozilla's CA Bundle."
|
||||||
category = "main"
|
category = "main"
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = "*"
|
python-versions = ">=3.6"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "charset-normalizer"
|
name = "charset-normalizer"
|
||||||
@@ -15,7 +15,7 @@ optional = false
|
|||||||
python-versions = ">=3.5.0"
|
python-versions = ">=3.5.0"
|
||||||
|
|
||||||
[package.extras]
|
[package.extras]
|
||||||
unicode_backport = ["unicodedata2"]
|
unicode-backport = ["unicodedata2"]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "idna"
|
name = "idna"
|
||||||
@@ -41,7 +41,7 @@ urllib3 = ">=1.21.1,<1.27"
|
|||||||
|
|
||||||
[package.extras]
|
[package.extras]
|
||||||
socks = ["PySocks (>=1.5.6,!=1.5.7)", "win-inet-pton"]
|
socks = ["PySocks (>=1.5.6,!=1.5.7)", "win-inet-pton"]
|
||||||
use_chardet_on_py3 = ["chardet (>=3.0.2,<5)"]
|
use-chardet-on-py3 = ["chardet (>=3.0.2,<5)"]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "urllib3"
|
name = "urllib3"
|
||||||
@@ -53,18 +53,18 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4"
|
|||||||
|
|
||||||
[package.extras]
|
[package.extras]
|
||||||
brotli = ["brotlipy (>=0.6.0)"]
|
brotli = ["brotlipy (>=0.6.0)"]
|
||||||
secure = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "certifi", "ipaddress"]
|
secure = ["certifi", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "ipaddress", "pyOpenSSL (>=0.14)"]
|
||||||
socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"]
|
socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"]
|
||||||
|
|
||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "1.1"
|
lock-version = "1.1"
|
||||||
python-versions = "^3.8"
|
python-versions = "^3.8"
|
||||||
content-hash = "1c921c3aff11a5d59460cdcbe97f0a9c2379e746771452a2bdfe7c530bb5dad0"
|
content-hash = "fabc9cabf9f18437e7b9ea3dbd1895a5a118239c17b3d097c465a290707e6bfd"
|
||||||
|
|
||||||
[metadata.files]
|
[metadata.files]
|
||||||
certifi = [
|
certifi = [
|
||||||
{file = "certifi-2021.10.8-py2.py3-none-any.whl", hash = "sha256:d62a0163eb4c2344ac042ab2bdf75399a71a2d8c7d47eac2e2ee91b9d6339569"},
|
{file = "certifi-2022.12.7-py3-none-any.whl", hash = "sha256:4ad3232f5e926d6718ec31cfc1fcadfde020920e278684144551c91769c7bc18"},
|
||||||
{file = "certifi-2021.10.8.tar.gz", hash = "sha256:78884e7c1d4b00ce3cea67b44566851c4343c120abd683433ce934a68ea58872"},
|
{file = "certifi-2022.12.7.tar.gz", hash = "sha256:35824b4c3a97115964b408844d64aa14db1cc518f6562e8d7261699d1350a9e3"},
|
||||||
]
|
]
|
||||||
charset-normalizer = [
|
charset-normalizer = [
|
||||||
{file = "charset-normalizer-2.0.7.tar.gz", hash = "sha256:e019de665e2bcf9c2b64e2e5aa025fa991da8720daa3c1138cadd2fd1856aed0"},
|
{file = "charset-normalizer-2.0.7.tar.gz", hash = "sha256:e019de665e2bcf9c2b64e2e5aa025fa991da8720daa3c1138cadd2fd1856aed0"},
|
||||||
|
|||||||
+8
-8
@@ -1,10 +1,10 @@
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "certifi"
|
name = "certifi"
|
||||||
version = "2021.10.8"
|
version = "2022.12.7"
|
||||||
description = "Python package for providing Mozilla's CA Bundle."
|
description = "Python package for providing Mozilla's CA Bundle."
|
||||||
category = "main"
|
category = "main"
|
||||||
optional = false
|
optional = false
|
||||||
python-versions = "*"
|
python-versions = ">=3.6"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "charset-normalizer"
|
name = "charset-normalizer"
|
||||||
@@ -15,7 +15,7 @@ optional = false
|
|||||||
python-versions = ">=3.5.0"
|
python-versions = ">=3.5.0"
|
||||||
|
|
||||||
[package.extras]
|
[package.extras]
|
||||||
unicode_backport = ["unicodedata2"]
|
unicode-backport = ["unicodedata2"]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "idna"
|
name = "idna"
|
||||||
@@ -41,7 +41,7 @@ urllib3 = ">=1.21.1,<1.27"
|
|||||||
|
|
||||||
[package.extras]
|
[package.extras]
|
||||||
socks = ["PySocks (>=1.5.6,!=1.5.7)", "win-inet-pton"]
|
socks = ["PySocks (>=1.5.6,!=1.5.7)", "win-inet-pton"]
|
||||||
use_chardet_on_py3 = ["chardet (>=3.0.2,<5)"]
|
use-chardet-on-py3 = ["chardet (>=3.0.2,<5)"]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "urllib3"
|
name = "urllib3"
|
||||||
@@ -53,18 +53,18 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4"
|
|||||||
|
|
||||||
[package.extras]
|
[package.extras]
|
||||||
brotli = ["brotlipy (>=0.6.0)"]
|
brotli = ["brotlipy (>=0.6.0)"]
|
||||||
secure = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "certifi", "ipaddress"]
|
secure = ["certifi", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "ipaddress", "pyOpenSSL (>=0.14)"]
|
||||||
socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"]
|
socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"]
|
||||||
|
|
||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "1.1"
|
lock-version = "1.1"
|
||||||
python-versions = "^3.6"
|
python-versions = "^3.6"
|
||||||
content-hash = "0688bcc269cb32eab2edeadcb342631e24cf30fd9ef54f8710010cc06cd523c5"
|
content-hash = "3186fede9fea5b617c0bcebda3034f2d889a3c4579d60dd45945772895a28b7d"
|
||||||
|
|
||||||
[metadata.files]
|
[metadata.files]
|
||||||
certifi = [
|
certifi = [
|
||||||
{file = "certifi-2021.10.8-py2.py3-none-any.whl", hash = "sha256:d62a0163eb4c2344ac042ab2bdf75399a71a2d8c7d47eac2e2ee91b9d6339569"},
|
{file = "certifi-2022.12.7-py3-none-any.whl", hash = "sha256:4ad3232f5e926d6718ec31cfc1fcadfde020920e278684144551c91769c7bc18"},
|
||||||
{file = "certifi-2021.10.8.tar.gz", hash = "sha256:78884e7c1d4b00ce3cea67b44566851c4343c120abd683433ce934a68ea58872"},
|
{file = "certifi-2022.12.7.tar.gz", hash = "sha256:35824b4c3a97115964b408844d64aa14db1cc518f6562e8d7261699d1350a9e3"},
|
||||||
]
|
]
|
||||||
charset-normalizer = [
|
charset-normalizer = [
|
||||||
{file = "charset-normalizer-2.0.7.tar.gz", hash = "sha256:e019de665e2bcf9c2b64e2e5aa025fa991da8720daa3c1138cadd2fd1856aed0"},
|
{file = "charset-normalizer-2.0.7.tar.gz", hash = "sha256:e019de665e2bcf9c2b64e2e5aa025fa991da8720daa3c1138cadd2fd1856aed0"},
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
[virtualenvs]
|
||||||
|
in-project = true
|
||||||
+5
-4
@@ -17,6 +17,7 @@ import {
|
|||||||
GITHUB_DOTCOM_URL,
|
GITHUB_DOTCOM_URL,
|
||||||
isHTTPError,
|
isHTTPError,
|
||||||
isInTestMode,
|
isInTestMode,
|
||||||
|
parseMatrixInput,
|
||||||
UserError,
|
UserError,
|
||||||
} from "./util";
|
} from "./util";
|
||||||
import { getWorkflowPath } from "./workflow";
|
import { getWorkflowPath } from "./workflow";
|
||||||
@@ -192,10 +193,10 @@ export function computeAutomationID(
|
|||||||
): string {
|
): string {
|
||||||
let automationID = `${analysis_key}/`;
|
let automationID = `${analysis_key}/`;
|
||||||
|
|
||||||
// the id has to be deterministic so we sort the fields
|
const matrix = parseMatrixInput(environment);
|
||||||
if (environment !== undefined && environment !== "null") {
|
if (matrix !== undefined) {
|
||||||
const environmentObject = JSON.parse(environment);
|
// the id has to be deterministic so we sort the fields
|
||||||
for (const entry of Object.entries(environmentObject).sort()) {
|
for (const entry of Object.entries(matrix).sort()) {
|
||||||
if (typeof entry[1] === "string") {
|
if (typeof entry[1] === "string") {
|
||||||
automationID += `${entry[0]}:${entry[1]}/`;
|
automationID += `${entry[0]}:${entry[1]}/`;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import { Features } from "./feature-flags";
|
|||||||
import { Language } from "./languages";
|
import { Language } from "./languages";
|
||||||
import { getActionsLogger, Logger } from "./logging";
|
import { getActionsLogger, Logger } from "./logging";
|
||||||
import { parseRepositoryNwo } from "./repository";
|
import { parseRepositoryNwo } from "./repository";
|
||||||
|
import { CODEQL_ACTION_ANALYZE_DID_UPLOAD_SARIF } from "./shared-environment";
|
||||||
import { getTotalCacheSize, uploadTrapCaches } from "./trap-caching";
|
import { getTotalCacheSize, uploadTrapCaches } from "./trap-caching";
|
||||||
import * as upload_lib from "./upload-lib";
|
import * as upload_lib from "./upload-lib";
|
||||||
import { UploadResult } from "./upload-lib";
|
import { UploadResult } from "./upload-lib";
|
||||||
@@ -271,8 +272,14 @@ async function run() {
|
|||||||
core.setOutput("db-locations", dbLocations);
|
core.setOutput("db-locations", dbLocations);
|
||||||
|
|
||||||
if (runStats && actionsUtil.getRequiredInput("upload") === "true") {
|
if (runStats && actionsUtil.getRequiredInput("upload") === "true") {
|
||||||
uploadResult = await upload_lib.uploadFromActions(outputDir, logger);
|
uploadResult = await upload_lib.uploadFromActions(
|
||||||
|
outputDir,
|
||||||
|
actionsUtil.getRequiredInput("checkout_path"),
|
||||||
|
actionsUtil.getOptionalInput("category"),
|
||||||
|
logger
|
||||||
|
);
|
||||||
core.setOutput("sarif-id", uploadResult.sarifID);
|
core.setOutput("sarif-id", uploadResult.sarifID);
|
||||||
|
core.exportVariable(CODEQL_ACTION_ANALYZE_DID_UPLOAD_SARIF, "true");
|
||||||
} else {
|
} else {
|
||||||
logger.info("Not uploading results");
|
logger.info("Not uploading results");
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -355,8 +355,7 @@ export async function runQueries(
|
|||||||
addSnippetsFlag,
|
addSnippetsFlag,
|
||||||
threadsFlag,
|
threadsFlag,
|
||||||
enableDebugLogging ? "-vv" : "-v",
|
enableDebugLogging ? "-vv" : "-v",
|
||||||
automationDetailsId,
|
automationDetailsId
|
||||||
featureEnablement
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+8
-50
@@ -445,16 +445,7 @@ test("databaseInterpretResults() does not set --sarif-add-query-help for 2.7.0",
|
|||||||
sinon.stub(codeqlObject, "getVersion").resolves("2.7.0");
|
sinon.stub(codeqlObject, "getVersion").resolves("2.7.0");
|
||||||
// safeWhich throws because of the test CodeQL object.
|
// safeWhich throws because of the test CodeQL object.
|
||||||
sinon.stub(safeWhich, "safeWhich").resolves("");
|
sinon.stub(safeWhich, "safeWhich").resolves("");
|
||||||
await codeqlObject.databaseInterpretResults(
|
await codeqlObject.databaseInterpretResults("", [], "", "", "", "-v", "");
|
||||||
"",
|
|
||||||
[],
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"-v",
|
|
||||||
"",
|
|
||||||
createFeatures([])
|
|
||||||
);
|
|
||||||
t.false(
|
t.false(
|
||||||
runnerConstructorStub.firstCall.args[1].includes("--sarif-add-query-help"),
|
runnerConstructorStub.firstCall.args[1].includes("--sarif-add-query-help"),
|
||||||
"--sarif-add-query-help should be absent, but it is present"
|
"--sarif-add-query-help should be absent, but it is present"
|
||||||
@@ -467,16 +458,7 @@ test("databaseInterpretResults() sets --sarif-add-query-help for 2.7.1", async (
|
|||||||
sinon.stub(codeqlObject, "getVersion").resolves("2.7.1");
|
sinon.stub(codeqlObject, "getVersion").resolves("2.7.1");
|
||||||
// safeWhich throws because of the test CodeQL object.
|
// safeWhich throws because of the test CodeQL object.
|
||||||
sinon.stub(safeWhich, "safeWhich").resolves("");
|
sinon.stub(safeWhich, "safeWhich").resolves("");
|
||||||
await codeqlObject.databaseInterpretResults(
|
await codeqlObject.databaseInterpretResults("", [], "", "", "", "-v", "");
|
||||||
"",
|
|
||||||
[],
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"-v",
|
|
||||||
"",
|
|
||||||
createFeatures([])
|
|
||||||
);
|
|
||||||
t.true(
|
t.true(
|
||||||
runnerConstructorStub.firstCall.args[1].includes("--sarif-add-query-help"),
|
runnerConstructorStub.firstCall.args[1].includes("--sarif-add-query-help"),
|
||||||
"--sarif-add-query-help should be present, but it is absent"
|
"--sarif-add-query-help should be present, but it is absent"
|
||||||
@@ -865,25 +847,13 @@ test("does not use injected config", async (t: ExecutionContext<unknown>) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test("databaseInterpretResults() sets --sarif-add-baseline-file-info when feature enabled", async (t) => {
|
test("databaseInterpretResults() sets --sarif-add-baseline-file-info for 2.11.3", async (t) => {
|
||||||
const runnerConstructorStub = stubToolRunnerConstructor();
|
const runnerConstructorStub = stubToolRunnerConstructor();
|
||||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||||
// We need to set a CodeQL version such that running `databaseInterpretResults` does not crash.
|
sinon.stub(codeqlObject, "getVersion").resolves("2.11.3");
|
||||||
// The version of CodeQL is checked separately to determine feature enablement, and does not
|
|
||||||
// otherwise impact this test, so set it to 0.0.0.
|
|
||||||
sinon.stub(codeqlObject, "getVersion").resolves("0.0.0");
|
|
||||||
// safeWhich throws because of the test CodeQL object.
|
// safeWhich throws because of the test CodeQL object.
|
||||||
sinon.stub(safeWhich, "safeWhich").resolves("");
|
sinon.stub(safeWhich, "safeWhich").resolves("");
|
||||||
await codeqlObject.databaseInterpretResults(
|
await codeqlObject.databaseInterpretResults("", [], "", "", "", "-v", "");
|
||||||
"",
|
|
||||||
[],
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"-v",
|
|
||||||
"",
|
|
||||||
createFeatures([Feature.FileBaselineInformationEnabled])
|
|
||||||
);
|
|
||||||
t.true(
|
t.true(
|
||||||
runnerConstructorStub.firstCall.args[1].includes(
|
runnerConstructorStub.firstCall.args[1].includes(
|
||||||
"--sarif-add-baseline-file-info"
|
"--sarif-add-baseline-file-info"
|
||||||
@@ -892,25 +862,13 @@ test("databaseInterpretResults() sets --sarif-add-baseline-file-info when featur
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("databaseInterpretResults() does not set --sarif-add-baseline-file-info if feature disabled", async (t) => {
|
test("databaseInterpretResults() does not set --sarif-add-baseline-file-info for 2.11.2", async (t) => {
|
||||||
const runnerConstructorStub = stubToolRunnerConstructor();
|
const runnerConstructorStub = stubToolRunnerConstructor();
|
||||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||||
// We need to set a CodeQL version such that running `databaseInterpretResults` does not crash.
|
sinon.stub(codeqlObject, "getVersion").resolves("2.11.2");
|
||||||
// The version of CodeQL is checked upstream to determine feature enablement, so it does not
|
|
||||||
// affect this test.
|
|
||||||
sinon.stub(codeqlObject, "getVersion").resolves("0.0.0");
|
|
||||||
// safeWhich throws because of the test CodeQL object.
|
// safeWhich throws because of the test CodeQL object.
|
||||||
sinon.stub(safeWhich, "safeWhich").resolves("");
|
sinon.stub(safeWhich, "safeWhich").resolves("");
|
||||||
await codeqlObject.databaseInterpretResults(
|
await codeqlObject.databaseInterpretResults("", [], "", "", "", "-v", "");
|
||||||
"",
|
|
||||||
[],
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
"-v",
|
|
||||||
"",
|
|
||||||
createFeatures([])
|
|
||||||
);
|
|
||||||
t.false(
|
t.false(
|
||||||
runnerConstructorStub.firstCall.args[1].includes(
|
runnerConstructorStub.firstCall.args[1].includes(
|
||||||
"--sarif-add-baseline-file-info"
|
"--sarif-add-baseline-file-info"
|
||||||
|
|||||||
+32
-9
@@ -15,7 +15,7 @@ import * as api from "./api-client";
|
|||||||
import { Config } from "./config-utils";
|
import { Config } from "./config-utils";
|
||||||
import * as defaults from "./defaults.json"; // Referenced from codeql-action-sync-tool!
|
import * as defaults from "./defaults.json"; // Referenced from codeql-action-sync-tool!
|
||||||
import { errorMatchers } from "./error-matcher";
|
import { errorMatchers } from "./error-matcher";
|
||||||
import { Feature, FeatureEnablement } from "./feature-flags";
|
import { FeatureEnablement } from "./feature-flags";
|
||||||
import { isTracedLanguage, Language } from "./languages";
|
import { isTracedLanguage, Language } from "./languages";
|
||||||
import { Logger } from "./logging";
|
import { Logger } from "./logging";
|
||||||
import { toolrunnerErrorCatcher } from "./toolrunner-error-catcher";
|
import { toolrunnerErrorCatcher } from "./toolrunner-error-catcher";
|
||||||
@@ -172,13 +172,19 @@ export interface CodeQL {
|
|||||||
addSnippetsFlag: string,
|
addSnippetsFlag: string,
|
||||||
threadsFlag: string,
|
threadsFlag: string,
|
||||||
verbosityFlag: string | undefined,
|
verbosityFlag: string | undefined,
|
||||||
automationDetailsId: string | undefined,
|
automationDetailsId: string | undefined
|
||||||
featureEnablement: FeatureEnablement
|
|
||||||
): Promise<string>;
|
): Promise<string>;
|
||||||
/**
|
/**
|
||||||
* Run 'codeql database print-baseline'.
|
* Run 'codeql database print-baseline'.
|
||||||
*/
|
*/
|
||||||
databasePrintBaseline(databasePath: string): Promise<string>;
|
databasePrintBaseline(databasePath: string): Promise<string>;
|
||||||
|
/**
|
||||||
|
* Run 'codeql diagnostics export'.
|
||||||
|
*/
|
||||||
|
diagnosticsExport(
|
||||||
|
sarifFile: string,
|
||||||
|
automationDetailsId: string | undefined
|
||||||
|
): Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ResolveLanguagesOutput {
|
export interface ResolveLanguagesOutput {
|
||||||
@@ -250,6 +256,7 @@ const CODEQL_VERSION_LUA_TRACER_CONFIG = "2.10.0";
|
|||||||
export const CODEQL_VERSION_CONFIG_FILES = "2.10.1";
|
export const CODEQL_VERSION_CONFIG_FILES = "2.10.1";
|
||||||
const CODEQL_VERSION_LUA_TRACING_GO_WINDOWS_FIXED = "2.10.4";
|
const CODEQL_VERSION_LUA_TRACING_GO_WINDOWS_FIXED = "2.10.4";
|
||||||
export const CODEQL_VERSION_GHES_PACK_DOWNLOAD = "2.10.4";
|
export const CODEQL_VERSION_GHES_PACK_DOWNLOAD = "2.10.4";
|
||||||
|
const CODEQL_VERSION_FILE_BASELINE_INFORMATION = "2.11.3";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This variable controls using the new style of tracing from the CodeQL
|
* This variable controls using the new style of tracing from the CodeQL
|
||||||
@@ -634,6 +641,7 @@ export function setCodeQL(partialCodeql: Partial<CodeQL>): CodeQL {
|
|||||||
partialCodeql,
|
partialCodeql,
|
||||||
"databasePrintBaseline"
|
"databasePrintBaseline"
|
||||||
),
|
),
|
||||||
|
diagnosticsExport: resolveFunction(partialCodeql, "diagnosticsExport"),
|
||||||
};
|
};
|
||||||
return cachedCodeQL;
|
return cachedCodeQL;
|
||||||
}
|
}
|
||||||
@@ -675,7 +683,7 @@ async function getCodeQLForCmd(
|
|||||||
cmd: string,
|
cmd: string,
|
||||||
checkVersion: boolean
|
checkVersion: boolean
|
||||||
): Promise<CodeQL> {
|
): Promise<CodeQL> {
|
||||||
const codeql = {
|
const codeql: CodeQL = {
|
||||||
getPath() {
|
getPath() {
|
||||||
return cmd;
|
return cmd;
|
||||||
},
|
},
|
||||||
@@ -1025,8 +1033,7 @@ async function getCodeQLForCmd(
|
|||||||
addSnippetsFlag: string,
|
addSnippetsFlag: string,
|
||||||
threadsFlag: string,
|
threadsFlag: string,
|
||||||
verbosityFlag: string,
|
verbosityFlag: string,
|
||||||
automationDetailsId: string | undefined,
|
automationDetailsId: string | undefined
|
||||||
featureEnablement: FeatureEnablement
|
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
const codeqlArgs = [
|
const codeqlArgs = [
|
||||||
"database",
|
"database",
|
||||||
@@ -1047,9 +1054,9 @@ async function getCodeQLForCmd(
|
|||||||
codeqlArgs.push("--sarif-category", automationDetailsId);
|
codeqlArgs.push("--sarif-category", automationDetailsId);
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
await featureEnablement.getValue(
|
await util.codeQlVersionAbove(
|
||||||
Feature.FileBaselineInformationEnabled,
|
this,
|
||||||
this
|
CODEQL_VERSION_FILE_BASELINE_INFORMATION
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
codeqlArgs.push("--sarif-add-baseline-file-info");
|
codeqlArgs.push("--sarif-add-baseline-file-info");
|
||||||
@@ -1156,6 +1163,22 @@ async function getCodeQLForCmd(
|
|||||||
];
|
];
|
||||||
await new toolrunner.ToolRunner(cmd, args).exec();
|
await new toolrunner.ToolRunner(cmd, args).exec();
|
||||||
},
|
},
|
||||||
|
async diagnosticsExport(
|
||||||
|
sarifFile: string,
|
||||||
|
automationDetailsId: string | undefined
|
||||||
|
): Promise<void> {
|
||||||
|
const args = [
|
||||||
|
"diagnostics",
|
||||||
|
"export",
|
||||||
|
"--format=sarif-latest",
|
||||||
|
`--output=${sarifFile}`,
|
||||||
|
...getExtraOptionsFromEnv(["diagnostics", "export"]),
|
||||||
|
];
|
||||||
|
if (automationDetailsId !== undefined) {
|
||||||
|
args.push("--sarif-category", automationDetailsId);
|
||||||
|
}
|
||||||
|
await new toolrunner.ToolRunner(cmd, args).exec();
|
||||||
|
},
|
||||||
};
|
};
|
||||||
// To ensure that status reports include the CodeQL CLI version wherever
|
// To ensure that status reports include the CodeQL CLI version wherever
|
||||||
// possible, we want to call getVersion(), which populates the version value
|
// possible, we want to call getVersion(), which populates the version value
|
||||||
|
|||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"bundleVersion": "codeql-bundle-20221123"
|
"bundleVersion": "codeql-bundle-20221202"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ export enum Feature {
|
|||||||
BypassToolcacheKotlinSwiftEnabled = "bypass_toolcache_kotlin_swift_enabled",
|
BypassToolcacheKotlinSwiftEnabled = "bypass_toolcache_kotlin_swift_enabled",
|
||||||
CliConfigFileEnabled = "cli_config_file_enabled",
|
CliConfigFileEnabled = "cli_config_file_enabled",
|
||||||
DisableKotlinAnalysisEnabled = "disable_kotlin_analysis_enabled",
|
DisableKotlinAnalysisEnabled = "disable_kotlin_analysis_enabled",
|
||||||
FileBaselineInformationEnabled = "file_baseline_information_enabled",
|
|
||||||
MlPoweredQueriesEnabled = "ml_powered_queries_enabled",
|
MlPoweredQueriesEnabled = "ml_powered_queries_enabled",
|
||||||
TrapCachingEnabled = "trap_caching_enabled",
|
TrapCachingEnabled = "trap_caching_enabled",
|
||||||
|
UploadFailedSarifEnabled = "upload_failed_sarif_enabled",
|
||||||
}
|
}
|
||||||
|
|
||||||
export const featureConfig: Record<
|
export const featureConfig: Record<
|
||||||
@@ -45,10 +45,6 @@ export const featureConfig: Record<
|
|||||||
envVar: "CODEQL_PASS_CONFIG_TO_CLI",
|
envVar: "CODEQL_PASS_CONFIG_TO_CLI",
|
||||||
minimumVersion: "2.11.1",
|
minimumVersion: "2.11.1",
|
||||||
},
|
},
|
||||||
[Feature.FileBaselineInformationEnabled]: {
|
|
||||||
envVar: "CODEQL_FILE_BASELINE_INFORMATION",
|
|
||||||
minimumVersion: "2.11.3",
|
|
||||||
},
|
|
||||||
[Feature.MlPoweredQueriesEnabled]: {
|
[Feature.MlPoweredQueriesEnabled]: {
|
||||||
envVar: "CODEQL_ML_POWERED_QUERIES",
|
envVar: "CODEQL_ML_POWERED_QUERIES",
|
||||||
minimumVersion: "2.7.5",
|
minimumVersion: "2.7.5",
|
||||||
@@ -57,6 +53,10 @@ export const featureConfig: Record<
|
|||||||
envVar: "CODEQL_TRAP_CACHING",
|
envVar: "CODEQL_TRAP_CACHING",
|
||||||
minimumVersion: undefined,
|
minimumVersion: undefined,
|
||||||
},
|
},
|
||||||
|
[Feature.UploadFailedSarifEnabled]: {
|
||||||
|
envVar: "CODEQL_ACTION_UPLOAD_FAILED_SARIF",
|
||||||
|
minimumVersion: "2.11.3",
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,15 +1,27 @@
|
|||||||
import test from "ava";
|
import test, { ExecutionContext } from "ava";
|
||||||
import * as sinon from "sinon";
|
import * as sinon from "sinon";
|
||||||
|
|
||||||
|
import * as actionsUtil from "./actions-util";
|
||||||
|
import * as codeql from "./codeql";
|
||||||
import * as configUtils from "./config-utils";
|
import * as configUtils from "./config-utils";
|
||||||
|
import { Feature } from "./feature-flags";
|
||||||
import * as initActionPostHelper from "./init-action-post-helper";
|
import * as initActionPostHelper from "./init-action-post-helper";
|
||||||
import { setupTests } from "./testing-utils";
|
import { getRunnerLogger } from "./logging";
|
||||||
|
import { parseRepositoryNwo } from "./repository";
|
||||||
|
import {
|
||||||
|
createFeatures,
|
||||||
|
getRecordingLogger,
|
||||||
|
setupTests,
|
||||||
|
} from "./testing-utils";
|
||||||
|
import * as uploadLib from "./upload-lib";
|
||||||
import * as util from "./util";
|
import * as util from "./util";
|
||||||
|
import * as workflow from "./workflow";
|
||||||
|
|
||||||
setupTests(test);
|
setupTests(test);
|
||||||
|
|
||||||
test("post: init action with debug mode off", async (t) => {
|
test("post: init action with debug mode off", async (t) => {
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
|
process.env["GITHUB_REPOSITORY"] = "github/codeql-action-fake-repository";
|
||||||
process.env["RUNNER_TEMP"] = tmpDir;
|
process.env["RUNNER_TEMP"] = tmpDir;
|
||||||
|
|
||||||
const gitHubVersion: util.GitHubVersion = {
|
const gitHubVersion: util.GitHubVersion = {
|
||||||
@@ -29,7 +41,10 @@ test("post: init action with debug mode off", async (t) => {
|
|||||||
await initActionPostHelper.run(
|
await initActionPostHelper.run(
|
||||||
uploadDatabaseBundleSpy,
|
uploadDatabaseBundleSpy,
|
||||||
uploadLogsSpy,
|
uploadLogsSpy,
|
||||||
printDebugLogsSpy
|
printDebugLogsSpy,
|
||||||
|
parseRepositoryNwo("github/codeql-action"),
|
||||||
|
createFeatures([]),
|
||||||
|
getRunnerLogger(true)
|
||||||
);
|
);
|
||||||
|
|
||||||
t.assert(uploadDatabaseBundleSpy.notCalled);
|
t.assert(uploadDatabaseBundleSpy.notCalled);
|
||||||
@@ -40,6 +55,7 @@ test("post: init action with debug mode off", async (t) => {
|
|||||||
|
|
||||||
test("post: init action with debug mode on", async (t) => {
|
test("post: init action with debug mode on", async (t) => {
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
|
process.env["GITHUB_REPOSITORY"] = "github/codeql-action-fake-repository";
|
||||||
process.env["RUNNER_TEMP"] = tmpDir;
|
process.env["RUNNER_TEMP"] = tmpDir;
|
||||||
|
|
||||||
const gitHubVersion: util.GitHubVersion = {
|
const gitHubVersion: util.GitHubVersion = {
|
||||||
@@ -59,7 +75,10 @@ test("post: init action with debug mode on", async (t) => {
|
|||||||
await initActionPostHelper.run(
|
await initActionPostHelper.run(
|
||||||
uploadDatabaseBundleSpy,
|
uploadDatabaseBundleSpy,
|
||||||
uploadLogsSpy,
|
uploadLogsSpy,
|
||||||
printDebugLogsSpy
|
printDebugLogsSpy,
|
||||||
|
parseRepositoryNwo("github/codeql-action"),
|
||||||
|
createFeatures([]),
|
||||||
|
getRunnerLogger(true)
|
||||||
);
|
);
|
||||||
|
|
||||||
t.assert(uploadDatabaseBundleSpy.called);
|
t.assert(uploadDatabaseBundleSpy.called);
|
||||||
@@ -67,3 +86,117 @@ test("post: init action with debug mode on", async (t) => {
|
|||||||
t.assert(printDebugLogsSpy.called);
|
t.assert(printDebugLogsSpy.called);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("uploads failed SARIF run for typical workflow", async (t) => {
|
||||||
|
const actionsWorkflow = createTestWorkflow([
|
||||||
|
{
|
||||||
|
name: "Checkout repository",
|
||||||
|
uses: "actions/checkout@v3",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Initialize CodeQL",
|
||||||
|
uses: "github/codeql-action/init@v2",
|
||||||
|
with: {
|
||||||
|
languages: "javascript",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Perform CodeQL Analysis",
|
||||||
|
uses: "github/codeql-action/analyze@v2",
|
||||||
|
with: {
|
||||||
|
category: "my-category",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
await testFailedSarifUpload(t, actionsWorkflow, { category: "my-category" });
|
||||||
|
});
|
||||||
|
|
||||||
|
test("uploading failed SARIF run fails when workflow does not reference github/codeql-action", async (t) => {
|
||||||
|
const actionsWorkflow = createTestWorkflow([
|
||||||
|
{
|
||||||
|
name: "Checkout repository",
|
||||||
|
uses: "actions/checkout@v3",
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
await t.throwsAsync(
|
||||||
|
async () => await testFailedSarifUpload(t, actionsWorkflow)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
function createTestWorkflow(
|
||||||
|
steps: workflow.WorkflowJobStep[]
|
||||||
|
): workflow.Workflow {
|
||||||
|
return {
|
||||||
|
name: "CodeQL",
|
||||||
|
on: {
|
||||||
|
push: {
|
||||||
|
branches: ["main"],
|
||||||
|
},
|
||||||
|
pull_request: {
|
||||||
|
branches: ["main"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
jobs: {
|
||||||
|
analyze: {
|
||||||
|
name: "CodeQL Analysis",
|
||||||
|
"runs-on": "ubuntu-latest",
|
||||||
|
steps,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
async function testFailedSarifUpload(
|
||||||
|
t: ExecutionContext<unknown>,
|
||||||
|
actionsWorkflow: workflow.Workflow,
|
||||||
|
{ category }: { category?: string } = {}
|
||||||
|
): Promise<void> {
|
||||||
|
const config = {
|
||||||
|
codeQLCmd: "codeql",
|
||||||
|
debugMode: true,
|
||||||
|
languages: [],
|
||||||
|
packs: [],
|
||||||
|
} as unknown as configUtils.Config;
|
||||||
|
const messages = [];
|
||||||
|
process.env["GITHUB_JOB"] = "analyze";
|
||||||
|
process.env["GITHUB_REPOSITORY"] = "github/codeql-action-fake-repository";
|
||||||
|
process.env["GITHUB_WORKSPACE"] =
|
||||||
|
"/home/runner/work/codeql-action/codeql-action";
|
||||||
|
sinon.stub(actionsUtil, "getRequiredInput").withArgs("matrix").returns("{}");
|
||||||
|
|
||||||
|
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||||
|
sinon.stub(codeql, "getCodeQL").resolves(codeqlObject);
|
||||||
|
const diagnosticsExportStub = sinon.stub(codeqlObject, "diagnosticsExport");
|
||||||
|
|
||||||
|
sinon.stub(workflow, "getWorkflow").resolves(actionsWorkflow);
|
||||||
|
|
||||||
|
const uploadFromActions = sinon.stub(uploadLib, "uploadFromActions");
|
||||||
|
uploadFromActions.resolves({ sarifID: "42" } as uploadLib.UploadResult);
|
||||||
|
const waitForProcessing = sinon.stub(uploadLib, "waitForProcessing");
|
||||||
|
|
||||||
|
await initActionPostHelper.uploadFailedSarif(
|
||||||
|
config,
|
||||||
|
parseRepositoryNwo("github/codeql-action"),
|
||||||
|
createFeatures([Feature.UploadFailedSarifEnabled]),
|
||||||
|
getRecordingLogger(messages)
|
||||||
|
);
|
||||||
|
t.deepEqual(messages, []);
|
||||||
|
t.true(
|
||||||
|
diagnosticsExportStub.calledOnceWith(sinon.match.string, category),
|
||||||
|
`Actual args were: ${diagnosticsExportStub.args}`
|
||||||
|
);
|
||||||
|
t.true(
|
||||||
|
uploadFromActions.calledOnceWith(
|
||||||
|
sinon.match.string,
|
||||||
|
sinon.match.string,
|
||||||
|
category,
|
||||||
|
sinon.match.any
|
||||||
|
),
|
||||||
|
`Actual args were: ${uploadFromActions.args}`
|
||||||
|
);
|
||||||
|
t.true(
|
||||||
|
waitForProcessing.calledOnceWith(sinon.match.any, "42", sinon.match.any, {
|
||||||
|
isUnsuccessfulExecution: true,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,25 +1,118 @@
|
|||||||
import * as core from "@actions/core";
|
import * as core from "@actions/core";
|
||||||
|
|
||||||
import * as actionsUtil from "./actions-util";
|
import * as actionsUtil from "./actions-util";
|
||||||
import { getConfig } from "./config-utils";
|
import { getCodeQL } from "./codeql";
|
||||||
import { getActionsLogger } from "./logging";
|
import { Config, getConfig } from "./config-utils";
|
||||||
|
import { Feature, FeatureEnablement } from "./feature-flags";
|
||||||
|
import { Logger } from "./logging";
|
||||||
|
import { RepositoryNwo } from "./repository";
|
||||||
|
import { CODEQL_ACTION_ANALYZE_DID_UPLOAD_SARIF } from "./shared-environment";
|
||||||
|
import * as uploadLib from "./upload-lib";
|
||||||
|
import { getRequiredEnvParam, isInTestMode, parseMatrixInput } from "./util";
|
||||||
|
import {
|
||||||
|
getCategoryInputOrThrow,
|
||||||
|
getCheckoutPathInputOrThrow,
|
||||||
|
getUploadInputOrThrow,
|
||||||
|
getWorkflow,
|
||||||
|
} from "./workflow";
|
||||||
|
|
||||||
|
export async function uploadFailedSarif(
|
||||||
|
config: Config,
|
||||||
|
repositoryNwo: RepositoryNwo,
|
||||||
|
featureEnablement: FeatureEnablement,
|
||||||
|
logger: Logger
|
||||||
|
) {
|
||||||
|
if (!config.codeQLCmd) {
|
||||||
|
logger.warning(
|
||||||
|
"CodeQL command not found. Unable to upload failed SARIF file."
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const codeql = await getCodeQL(config.codeQLCmd);
|
||||||
|
if (
|
||||||
|
!(await featureEnablement.getValue(
|
||||||
|
Feature.UploadFailedSarifEnabled,
|
||||||
|
codeql
|
||||||
|
))
|
||||||
|
) {
|
||||||
|
logger.debug("Uploading failed SARIF is disabled.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const workflow = await getWorkflow();
|
||||||
|
const jobName = getRequiredEnvParam("GITHUB_JOB");
|
||||||
|
const matrix = parseMatrixInput(actionsUtil.getRequiredInput("matrix"));
|
||||||
|
if (
|
||||||
|
getUploadInputOrThrow(workflow, jobName, matrix) !== "true" ||
|
||||||
|
isInTestMode()
|
||||||
|
) {
|
||||||
|
logger.debug(
|
||||||
|
"Won't upload a failed SARIF file since SARIF upload is disabled."
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const category = getCategoryInputOrThrow(workflow, jobName, matrix);
|
||||||
|
const checkoutPath = getCheckoutPathInputOrThrow(workflow, jobName, matrix);
|
||||||
|
|
||||||
|
const sarifFile = "../codeql-failed-run.sarif";
|
||||||
|
await codeql.diagnosticsExport(sarifFile, category);
|
||||||
|
|
||||||
|
core.info(`Uploading failed SARIF file ${sarifFile}`);
|
||||||
|
const uploadResult = await uploadLib.uploadFromActions(
|
||||||
|
sarifFile,
|
||||||
|
checkoutPath,
|
||||||
|
category,
|
||||||
|
logger
|
||||||
|
);
|
||||||
|
await uploadLib.waitForProcessing(
|
||||||
|
repositoryNwo,
|
||||||
|
uploadResult.sarifID,
|
||||||
|
logger,
|
||||||
|
{ isUnsuccessfulExecution: true }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export async function run(
|
export async function run(
|
||||||
uploadDatabaseBundleDebugArtifact: Function,
|
uploadDatabaseBundleDebugArtifact: Function,
|
||||||
uploadLogsDebugArtifact: Function,
|
uploadLogsDebugArtifact: Function,
|
||||||
printDebugLogs: Function
|
printDebugLogs: Function,
|
||||||
|
repositoryNwo: RepositoryNwo,
|
||||||
|
featureEnablement: FeatureEnablement,
|
||||||
|
logger: Logger
|
||||||
) {
|
) {
|
||||||
const logger = getActionsLogger();
|
|
||||||
|
|
||||||
const config = await getConfig(actionsUtil.getTemporaryDirectory(), logger);
|
const config = await getConfig(actionsUtil.getTemporaryDirectory(), logger);
|
||||||
if (config === undefined) {
|
if (config === undefined) {
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"Debugging artifacts are unavailable since the 'init' Action failed before it could produce any."
|
"Debugging artifacts are unavailable since the 'init' Action failed before it could produce any."
|
||||||
);
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Environment variable used to integration test uploading a SARIF file for failed runs
|
||||||
|
const expectFailedSarifUpload =
|
||||||
|
process.env["CODEQL_ACTION_EXPECT_UPLOAD_FAILED_SARIF"] === "true";
|
||||||
|
|
||||||
|
if (process.env[CODEQL_ACTION_ANALYZE_DID_UPLOAD_SARIF] !== "true") {
|
||||||
|
try {
|
||||||
|
await uploadFailedSarif(config, repositoryNwo, featureEnablement, logger);
|
||||||
|
} catch (e) {
|
||||||
|
if (expectFailedSarifUpload) {
|
||||||
|
throw new Error(
|
||||||
|
"Expected to upload a SARIF file for the failed run, but encountered " +
|
||||||
|
`the following error: ${e}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
logger.info(
|
||||||
|
`Failed to upload a SARIF file for the failed run. Error: ${e}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else if (expectFailedSarifUpload) {
|
||||||
|
throw new Error(
|
||||||
|
"Expected to upload a SARIF file for the failed run, but didn't."
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Upload appropriate Actions artifacts for debugging
|
// Upload appropriate Actions artifacts for debugging
|
||||||
if (config?.debugMode) {
|
if (config.debugMode) {
|
||||||
core.info(
|
core.info(
|
||||||
"Debug mode is on. Uploading available database bundles and logs as Actions debugging artifacts..."
|
"Debug mode is on. Uploading available database bundles and logs as Actions debugging artifacts..."
|
||||||
);
|
);
|
||||||
|
|||||||
+23
-1
@@ -7,15 +7,37 @@
|
|||||||
import * as core from "@actions/core";
|
import * as core from "@actions/core";
|
||||||
|
|
||||||
import * as actionsUtil from "./actions-util";
|
import * as actionsUtil from "./actions-util";
|
||||||
|
import { getGitHubVersion } from "./api-client";
|
||||||
import * as debugArtifacts from "./debug-artifacts";
|
import * as debugArtifacts from "./debug-artifacts";
|
||||||
|
import { Features } from "./feature-flags";
|
||||||
import * as initActionPostHelper from "./init-action-post-helper";
|
import * as initActionPostHelper from "./init-action-post-helper";
|
||||||
|
import { getActionsLogger } from "./logging";
|
||||||
|
import { parseRepositoryNwo } from "./repository";
|
||||||
|
import { checkGitHubVersionInRange, getRequiredEnvParam } from "./util";
|
||||||
|
|
||||||
async function runWrapper() {
|
async function runWrapper() {
|
||||||
try {
|
try {
|
||||||
|
const logger = getActionsLogger();
|
||||||
|
const gitHubVersion = await getGitHubVersion();
|
||||||
|
checkGitHubVersionInRange(gitHubVersion, logger);
|
||||||
|
|
||||||
|
const repositoryNwo = parseRepositoryNwo(
|
||||||
|
getRequiredEnvParam("GITHUB_REPOSITORY")
|
||||||
|
);
|
||||||
|
const features = new Features(
|
||||||
|
gitHubVersion,
|
||||||
|
repositoryNwo,
|
||||||
|
actionsUtil.getTemporaryDirectory(),
|
||||||
|
logger
|
||||||
|
);
|
||||||
|
|
||||||
await initActionPostHelper.run(
|
await initActionPostHelper.run(
|
||||||
debugArtifacts.uploadDatabaseBundleDebugArtifact,
|
debugArtifacts.uploadDatabaseBundleDebugArtifact,
|
||||||
debugArtifacts.uploadLogsDebugArtifact,
|
debugArtifacts.uploadLogsDebugArtifact,
|
||||||
actionsUtil.printDebugLogs
|
actionsUtil.printDebugLogs,
|
||||||
|
repositoryNwo,
|
||||||
|
features,
|
||||||
|
logger
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(`init post-action step failed: ${error}`);
|
core.setFailed(`init post-action step failed: ${error}`);
|
||||||
|
|||||||
@@ -1,13 +1,24 @@
|
|||||||
export const ODASA_TRACER_CONFIGURATION = "ODASA_TRACER_CONFIGURATION";
|
/**
|
||||||
// The time at which the first action (normally init) started executing.
|
* This environment variable is set to true when the `analyze` Action
|
||||||
// If a workflow invokes a different action without first invoking the init
|
* successfully uploads a SARIF file. It does NOT indicate whether the
|
||||||
// action (i.e. the upload action is being used by a third-party integrator)
|
* SARIF file was processed successfully.
|
||||||
// then this variable will be assigned the start time of the action invoked
|
*/
|
||||||
// rather that the init action.
|
export const CODEQL_ACTION_ANALYZE_DID_UPLOAD_SARIF =
|
||||||
export const CODEQL_WORKFLOW_STARTED_AT = "CODEQL_WORKFLOW_STARTED_AT";
|
"CODEQL_ACTION_ANALYZE_DID_UPLOAD_SARIF";
|
||||||
|
|
||||||
export const CODEQL_ACTION_TESTING_ENVIRONMENT =
|
export const CODEQL_ACTION_TESTING_ENVIRONMENT =
|
||||||
"CODEQL_ACTION_TESTING_ENVIRONMENT";
|
"CODEQL_ACTION_TESTING_ENVIRONMENT";
|
||||||
|
|
||||||
/** Used to disable uploading SARIF results or status reports to the GitHub API */
|
/** Used to disable uploading SARIF results or status reports to the GitHub API */
|
||||||
export const CODEQL_ACTION_TEST_MODE = "CODEQL_ACTION_TEST_MODE";
|
export const CODEQL_ACTION_TEST_MODE = "CODEQL_ACTION_TEST_MODE";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The time at which the first action (normally init) started executing.
|
||||||
|
* If a workflow invokes a different action without first invoking the init
|
||||||
|
* action (i.e. the upload action is being used by a third-party integrator)
|
||||||
|
* then this variable will be assigned the start time of the action invoked
|
||||||
|
* rather that the init action.
|
||||||
|
*/
|
||||||
|
export const CODEQL_WORKFLOW_STARTED_AT = "CODEQL_WORKFLOW_STARTED_AT";
|
||||||
|
|
||||||
|
export const ODASA_TRACER_CONFIGURATION = "ODASA_TRACER_CONFIGURATION";
|
||||||
|
|||||||
+110
-52
@@ -158,23 +158,22 @@ export function findSarifFilesInDir(sarifPath: string): string[] {
|
|||||||
|
|
||||||
// Uploads a single sarif file or a directory of sarif files
|
// Uploads a single sarif file or a directory of sarif files
|
||||||
// depending on what the path happens to refer to.
|
// depending on what the path happens to refer to.
|
||||||
// Returns true iff the upload occurred and succeeded
|
|
||||||
export async function uploadFromActions(
|
export async function uploadFromActions(
|
||||||
sarifPath: string,
|
sarifPath: string,
|
||||||
|
checkoutPath: string,
|
||||||
|
category: string | undefined,
|
||||||
logger: Logger
|
logger: Logger
|
||||||
): Promise<UploadResult> {
|
): Promise<UploadResult> {
|
||||||
return await uploadFiles(
|
return await uploadFiles(
|
||||||
getSarifFilePaths(sarifPath),
|
getSarifFilePaths(sarifPath),
|
||||||
parseRepositoryNwo(util.getRequiredEnvParam("GITHUB_REPOSITORY")),
|
parseRepositoryNwo(util.getRequiredEnvParam("GITHUB_REPOSITORY")),
|
||||||
await actionsUtil.getCommitOid(
|
await actionsUtil.getCommitOid(checkoutPath),
|
||||||
actionsUtil.getRequiredInput("checkout_path")
|
|
||||||
),
|
|
||||||
await actionsUtil.getRef(),
|
await actionsUtil.getRef(),
|
||||||
await actionsUtil.getAnalysisKey(),
|
await actionsUtil.getAnalysisKey(),
|
||||||
actionsUtil.getOptionalInput("category"),
|
category,
|
||||||
util.getRequiredEnvParam("GITHUB_WORKFLOW"),
|
util.getRequiredEnvParam("GITHUB_WORKFLOW"),
|
||||||
workflow.getWorkflowRunID(),
|
workflow.getWorkflowRunID(),
|
||||||
actionsUtil.getRequiredInput("checkout_path"),
|
checkoutPath,
|
||||||
actionsUtil.getRequiredInput("matrix"),
|
actionsUtil.getRequiredInput("matrix"),
|
||||||
logger
|
logger
|
||||||
);
|
);
|
||||||
@@ -386,60 +385,119 @@ async function uploadFiles(
|
|||||||
const STATUS_CHECK_FREQUENCY_MILLISECONDS = 5 * 1000;
|
const STATUS_CHECK_FREQUENCY_MILLISECONDS = 5 * 1000;
|
||||||
const STATUS_CHECK_TIMEOUT_MILLISECONDS = 2 * 60 * 1000;
|
const STATUS_CHECK_TIMEOUT_MILLISECONDS = 2 * 60 * 1000;
|
||||||
|
|
||||||
// Waits until either the analysis is successfully processed, a processing error is reported, or STATUS_CHECK_TIMEOUT_MILLISECONDS elapses.
|
type ProcessingStatus = "pending" | "complete" | "failed";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Waits until either the analysis is successfully processed, a processing error
|
||||||
|
* is reported, or `STATUS_CHECK_TIMEOUT_MILLISECONDS` elapses.
|
||||||
|
*
|
||||||
|
* If `isUnsuccessfulExecution` is passed, will throw an error if the analysis
|
||||||
|
* processing does not produce a single error mentioning the unsuccessful
|
||||||
|
* execution.
|
||||||
|
*/
|
||||||
export async function waitForProcessing(
|
export async function waitForProcessing(
|
||||||
repositoryNwo: RepositoryNwo,
|
repositoryNwo: RepositoryNwo,
|
||||||
sarifID: string,
|
sarifID: string,
|
||||||
logger: Logger
|
logger: Logger,
|
||||||
|
options: { isUnsuccessfulExecution: boolean } = {
|
||||||
|
isUnsuccessfulExecution: false,
|
||||||
|
}
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
logger.startGroup("Waiting for processing to finish");
|
logger.startGroup("Waiting for processing to finish");
|
||||||
const client = api.getApiClient();
|
try {
|
||||||
|
const client = api.getApiClient();
|
||||||
|
|
||||||
const statusCheckingStarted = Date.now();
|
const statusCheckingStarted = Date.now();
|
||||||
// eslint-disable-next-line no-constant-condition
|
// eslint-disable-next-line no-constant-condition
|
||||||
while (true) {
|
while (true) {
|
||||||
if (
|
if (
|
||||||
Date.now() >
|
Date.now() >
|
||||||
statusCheckingStarted + STATUS_CHECK_TIMEOUT_MILLISECONDS
|
statusCheckingStarted + STATUS_CHECK_TIMEOUT_MILLISECONDS
|
||||||
) {
|
) {
|
||||||
// If the analysis hasn't finished processing in the allotted time, we continue anyway rather than failing.
|
// If the analysis hasn't finished processing in the allotted time, we continue anyway rather than failing.
|
||||||
// It's possible the analysis will eventually finish processing, but it's not worth spending more Actions time waiting.
|
// It's possible the analysis will eventually finish processing, but it's not worth spending more Actions time waiting.
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"Timed out waiting for analysis to finish processing. Continuing."
|
"Timed out waiting for analysis to finish processing. Continuing."
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
let response: OctokitResponse<any> | undefined = undefined;
|
let response: OctokitResponse<any> | undefined = undefined;
|
||||||
try {
|
try {
|
||||||
response = await client.request(
|
response = await client.request(
|
||||||
"GET /repos/:owner/:repo/code-scanning/sarifs/:sarif_id",
|
"GET /repos/:owner/:repo/code-scanning/sarifs/:sarif_id",
|
||||||
{
|
{
|
||||||
owner: repositoryNwo.owner,
|
owner: repositoryNwo.owner,
|
||||||
repo: repositoryNwo.repo,
|
repo: repositoryNwo.repo,
|
||||||
sarif_id: sarifID,
|
sarif_id: sarifID,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.warning(
|
logger.warning(
|
||||||
`An error occurred checking the status of the delivery. ${e} It should still be processed in the background, but errors that occur during processing may not be reported.`
|
`An error occurred checking the status of the delivery. ${e} It should still be processed in the background, but errors that occur during processing may not be reported.`
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
const status = response.data.processing_status;
|
const status = response.data.processing_status as ProcessingStatus;
|
||||||
logger.info(`Analysis upload status is ${status}.`);
|
logger.info(`Analysis upload status is ${status}.`);
|
||||||
if (status === "complete") {
|
|
||||||
break;
|
|
||||||
} else if (status === "pending") {
|
|
||||||
logger.debug("Analysis processing is still pending...");
|
|
||||||
} else if (status === "failed") {
|
|
||||||
throw new Error(
|
|
||||||
`Code Scanning could not process the submitted SARIF file:\n${response.data.errors}`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
await util.delay(STATUS_CHECK_FREQUENCY_MILLISECONDS);
|
if (status === "pending") {
|
||||||
|
logger.debug("Analysis processing is still pending...");
|
||||||
|
} else if (options.isUnsuccessfulExecution) {
|
||||||
|
// We expect a specific processing error for unsuccessful executions, so
|
||||||
|
// handle these separately.
|
||||||
|
handleProcessingResultForUnsuccessfulExecution(
|
||||||
|
response,
|
||||||
|
status,
|
||||||
|
logger
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
} else if (status === "complete") {
|
||||||
|
break;
|
||||||
|
} else if (status === "failed") {
|
||||||
|
throw new Error(
|
||||||
|
`Code Scanning could not process the submitted SARIF file:\n${response.data.errors}`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
util.assertNever(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
await util.delay(STATUS_CHECK_FREQUENCY_MILLISECONDS);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
logger.endGroup();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks the processing result for an unsuccessful execution. Throws if the
|
||||||
|
* result is not a failure with a single "unsuccessful execution" error.
|
||||||
|
*/
|
||||||
|
function handleProcessingResultForUnsuccessfulExecution(
|
||||||
|
response: OctokitResponse<any, number>,
|
||||||
|
status: Exclude<ProcessingStatus, "pending">,
|
||||||
|
logger: Logger
|
||||||
|
): void {
|
||||||
|
if (
|
||||||
|
status === "failed" &&
|
||||||
|
Array.isArray(response.data.errors) &&
|
||||||
|
response.data.errors.length === 1 &&
|
||||||
|
response.data.errors[0].toString().startsWith("unsuccessful execution")
|
||||||
|
) {
|
||||||
|
logger.debug(
|
||||||
|
"Successfully uploaded a SARIF file for the unsuccessful execution. Received expected " +
|
||||||
|
'"unsuccessful execution" error, and no other errors.'
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
const shortMessage =
|
||||||
|
"Failed to upload a SARIF file for the unsuccessful execution. Code scanning status " +
|
||||||
|
"information for the repository may be out of date as a result.";
|
||||||
|
const longMessage =
|
||||||
|
shortMessage + status === "failed"
|
||||||
|
? ` Processing errors: ${response.data.errors}`
|
||||||
|
: ' Encountered no processing errors, but expected to receive an "unsuccessful execution" error.';
|
||||||
|
logger.debug(longMessage);
|
||||||
|
throw new Error(shortMessage);
|
||||||
}
|
}
|
||||||
logger.endGroup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function validateUniqueCategory(sarif: SarifFile): void {
|
export function validateUniqueCategory(sarif: SarifFile): void {
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ async function run() {
|
|||||||
try {
|
try {
|
||||||
const uploadResult = await upload_lib.uploadFromActions(
|
const uploadResult = await upload_lib.uploadFromActions(
|
||||||
actionsUtil.getRequiredInput("sarif_file"),
|
actionsUtil.getRequiredInput("sarif_file"),
|
||||||
|
actionsUtil.getRequiredInput("checkout_path"),
|
||||||
|
actionsUtil.getOptionalInput("category"),
|
||||||
getActionsLogger()
|
getActionsLogger()
|
||||||
);
|
);
|
||||||
core.setOutput("sarif-id", uploadResult.sarifID);
|
core.setOutput("sarif-id", uploadResult.sarifID);
|
||||||
|
|||||||
@@ -892,3 +892,12 @@ export async function shouldBypassToolcache(
|
|||||||
}
|
}
|
||||||
return bypass;
|
return bypass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function parseMatrixInput(
|
||||||
|
matrixInput: string | undefined
|
||||||
|
): { [key: string]: string } | undefined {
|
||||||
|
if (matrixInput === undefined || matrixInput === "null") {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return JSON.parse(matrixInput);
|
||||||
|
}
|
||||||
|
|||||||
@@ -525,6 +525,7 @@ test("getWorkflowErrors() should not report an error if PRs are totally unconfig
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("getCategoryInputOrThrow returns category for simple workflow with category", (t) => {
|
test("getCategoryInputOrThrow returns category for simple workflow with category", (t) => {
|
||||||
|
process.env["GITHUB_REPOSITORY"] = "github/codeql-action-fake-repository";
|
||||||
t.is(
|
t.is(
|
||||||
getCategoryInputOrThrow(
|
getCategoryInputOrThrow(
|
||||||
yaml.load(`
|
yaml.load(`
|
||||||
@@ -546,6 +547,7 @@ test("getCategoryInputOrThrow returns category for simple workflow with category
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("getCategoryInputOrThrow returns undefined for simple workflow without category", (t) => {
|
test("getCategoryInputOrThrow returns undefined for simple workflow without category", (t) => {
|
||||||
|
process.env["GITHUB_REPOSITORY"] = "github/codeql-action-fake-repository";
|
||||||
t.is(
|
t.is(
|
||||||
getCategoryInputOrThrow(
|
getCategoryInputOrThrow(
|
||||||
yaml.load(`
|
yaml.load(`
|
||||||
@@ -565,6 +567,7 @@ test("getCategoryInputOrThrow returns undefined for simple workflow without cate
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("getCategoryInputOrThrow returns category for workflow with multiple jobs", (t) => {
|
test("getCategoryInputOrThrow returns category for workflow with multiple jobs", (t) => {
|
||||||
|
process.env["GITHUB_REPOSITORY"] = "github/codeql-action-fake-repository";
|
||||||
t.is(
|
t.is(
|
||||||
getCategoryInputOrThrow(
|
getCategoryInputOrThrow(
|
||||||
yaml.load(`
|
yaml.load(`
|
||||||
@@ -596,6 +599,7 @@ test("getCategoryInputOrThrow returns category for workflow with multiple jobs",
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("getCategoryInputOrThrow finds category for workflow with language matrix", (t) => {
|
test("getCategoryInputOrThrow finds category for workflow with language matrix", (t) => {
|
||||||
|
process.env["GITHUB_REPOSITORY"] = "github/codeql-action-fake-repository";
|
||||||
t.is(
|
t.is(
|
||||||
getCategoryInputOrThrow(
|
getCategoryInputOrThrow(
|
||||||
yaml.load(`
|
yaml.load(`
|
||||||
@@ -622,6 +626,7 @@ test("getCategoryInputOrThrow finds category for workflow with language matrix",
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("getCategoryInputOrThrow throws error for workflow with dynamic category", (t) => {
|
test("getCategoryInputOrThrow throws error for workflow with dynamic category", (t) => {
|
||||||
|
process.env["GITHUB_REPOSITORY"] = "github/codeql-action-fake-repository";
|
||||||
t.throws(
|
t.throws(
|
||||||
() =>
|
() =>
|
||||||
getCategoryInputOrThrow(
|
getCategoryInputOrThrow(
|
||||||
@@ -646,7 +651,8 @@ test("getCategoryInputOrThrow throws error for workflow with dynamic category",
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("getCategoryInputOrThrow throws error for workflow with multiple categories", (t) => {
|
test("getCategoryInputOrThrow throws error for workflow with multiple calls to analyze", (t) => {
|
||||||
|
process.env["GITHUB_REPOSITORY"] = "github/codeql-action-fake-repository";
|
||||||
t.throws(
|
t.throws(
|
||||||
() =>
|
() =>
|
||||||
getCategoryInputOrThrow(
|
getCategoryInputOrThrow(
|
||||||
@@ -669,8 +675,8 @@ test("getCategoryInputOrThrow throws error for workflow with multiple categories
|
|||||||
),
|
),
|
||||||
{
|
{
|
||||||
message:
|
message:
|
||||||
"Could not get category input to github/codeql-action/analyze since there were multiple steps " +
|
"Could not get category input to github/codeql-action/analyze since the analysis job " +
|
||||||
"calling github/codeql-action/analyze with different values for category.",
|
"calls github/codeql-action/analyze multiple times.",
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
+97
-30
@@ -7,13 +7,16 @@ import * as yaml from "js-yaml";
|
|||||||
import * as api from "./api-client";
|
import * as api from "./api-client";
|
||||||
import { getRequiredEnvParam } from "./util";
|
import { getRequiredEnvParam } from "./util";
|
||||||
|
|
||||||
interface WorkflowJobStep {
|
export interface WorkflowJobStep {
|
||||||
run: any;
|
name?: string;
|
||||||
|
run?: any;
|
||||||
uses?: string;
|
uses?: string;
|
||||||
with?: { [key: string]: string };
|
with?: { [key: string]: string };
|
||||||
}
|
}
|
||||||
|
|
||||||
interface WorkflowJob {
|
interface WorkflowJob {
|
||||||
|
name?: string;
|
||||||
|
"runs-on"?: string;
|
||||||
steps?: WorkflowJobStep[];
|
steps?: WorkflowJobStep[];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,6 +36,7 @@ interface WorkflowTriggers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface Workflow {
|
export interface Workflow {
|
||||||
|
name?: string;
|
||||||
jobs?: { [key: string]: WorkflowJob };
|
jobs?: { [key: string]: WorkflowJob };
|
||||||
on?: string | string[] | WorkflowTriggers;
|
on?: string | string[] | WorkflowTriggers;
|
||||||
}
|
}
|
||||||
@@ -321,42 +325,42 @@ function getInputOrThrow(
|
|||||||
jobName: string,
|
jobName: string,
|
||||||
actionName: string,
|
actionName: string,
|
||||||
inputName: string,
|
inputName: string,
|
||||||
matrixVars: { [key: string]: string }
|
matrixVars: { [key: string]: string } | undefined
|
||||||
) {
|
) {
|
||||||
|
const preamble = `Could not get ${inputName} input to ${actionName} since`;
|
||||||
if (!workflow.jobs) {
|
if (!workflow.jobs) {
|
||||||
throw new Error(
|
throw new Error(`${preamble} the workflow has no jobs.`);
|
||||||
`Could not get ${inputName} input to ${actionName} since the workflow has no jobs.`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
if (!workflow.jobs[jobName]) {
|
if (!workflow.jobs[jobName]) {
|
||||||
|
throw new Error(`${preamble} the workflow has no job named ${jobName}.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const stepsCallingAction = getStepsCallingAction(
|
||||||
|
workflow.jobs[jobName],
|
||||||
|
actionName
|
||||||
|
);
|
||||||
|
|
||||||
|
if (stepsCallingAction.length === 0) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Could not get ${inputName} input to ${actionName} since the workflow has no job named ${jobName}.`
|
`${preamble} the ${jobName} job does not call ${actionName}.`
|
||||||
|
);
|
||||||
|
} else if (stepsCallingAction.length > 1) {
|
||||||
|
throw new Error(
|
||||||
|
`${preamble} the ${jobName} job calls ${actionName} multiple times.`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const inputs = getStepsCallingAction(workflow.jobs[jobName], actionName)
|
let input = stepsCallingAction[0].with?.[inputName];
|
||||||
.map((step) => step.with?.[inputName])
|
|
||||||
.filter((input) => input !== undefined)
|
|
||||||
.map((input) => input!);
|
|
||||||
|
|
||||||
if (inputs.length === 0) {
|
if (input !== undefined && matrixVars !== undefined) {
|
||||||
return undefined;
|
// Make a basic attempt to substitute matrix variables
|
||||||
|
// First normalize by removing whitespace
|
||||||
|
input = input.replace(/\${{\s+/, "${{").replace(/\s+}}/, "}}");
|
||||||
|
for (const [key, value] of Object.entries(matrixVars)) {
|
||||||
|
input = input.replace(`\${{matrix.${key}}}`, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!inputs.every((input) => input === inputs[0])) {
|
if (input !== undefined && input.includes("${{")) {
|
||||||
throw new Error(
|
|
||||||
`Could not get ${inputName} input to ${actionName} since there were multiple steps calling ` +
|
|
||||||
`${actionName} with different values for ${inputName}.`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make a basic attempt to substitute matrix variables
|
|
||||||
// First normalize by removing whitespace
|
|
||||||
let input = inputs[0].replace(/\${{\s+/, "${{").replace(/\s+}}/, "}}");
|
|
||||||
for (const [key, value] of Object.entries(matrixVars)) {
|
|
||||||
input = input.replace(`\${{matrix.${key}}}`, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (input.includes("${{")) {
|
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Could not get ${inputName} input to ${actionName} since it contained an unrecognized dynamic value.`
|
`Could not get ${inputName} input to ${actionName} since it contained an unrecognized dynamic value.`
|
||||||
);
|
);
|
||||||
@@ -364,6 +368,19 @@ function getInputOrThrow(
|
|||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the expected name of the analyze Action.
|
||||||
|
*
|
||||||
|
* This allows us to test workflow parsing functionality as a CodeQL Action PR check.
|
||||||
|
*/
|
||||||
|
function getAnalyzeActionName() {
|
||||||
|
if (getRequiredEnvParam("GITHUB_REPOSITORY") === "github/codeql-action") {
|
||||||
|
return "./analyze";
|
||||||
|
} else {
|
||||||
|
return "github/codeql-action/analyze";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes a best effort attempt to retrieve the category input for the particular job,
|
* Makes a best effort attempt to retrieve the category input for the particular job,
|
||||||
* given a set of matrix variables.
|
* given a set of matrix variables.
|
||||||
@@ -376,13 +393,63 @@ function getInputOrThrow(
|
|||||||
export function getCategoryInputOrThrow(
|
export function getCategoryInputOrThrow(
|
||||||
workflow: Workflow,
|
workflow: Workflow,
|
||||||
jobName: string,
|
jobName: string,
|
||||||
matrixVars: { [key: string]: string }
|
matrixVars: { [key: string]: string } | undefined
|
||||||
): string | undefined {
|
): string | undefined {
|
||||||
return getInputOrThrow(
|
return getInputOrThrow(
|
||||||
workflow,
|
workflow,
|
||||||
jobName,
|
jobName,
|
||||||
"github/codeql-action/analyze",
|
getAnalyzeActionName(),
|
||||||
"category",
|
"category",
|
||||||
matrixVars
|
matrixVars
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Makes a best effort attempt to retrieve the upload input for the particular job,
|
||||||
|
* given a set of matrix variables.
|
||||||
|
*
|
||||||
|
* Typically you'll want to wrap this function in a try/catch block and handle the error.
|
||||||
|
*
|
||||||
|
* @returns the upload input
|
||||||
|
* @throws an error if the upload input could not be determined
|
||||||
|
*/
|
||||||
|
export function getUploadInputOrThrow(
|
||||||
|
workflow: Workflow,
|
||||||
|
jobName: string,
|
||||||
|
matrixVars: { [key: string]: string } | undefined
|
||||||
|
): string {
|
||||||
|
return (
|
||||||
|
getInputOrThrow(
|
||||||
|
workflow,
|
||||||
|
jobName,
|
||||||
|
getAnalyzeActionName(),
|
||||||
|
"upload",
|
||||||
|
matrixVars
|
||||||
|
) || "true" // if unspecified, upload defaults to true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Makes a best effort attempt to retrieve the checkout_path input for the
|
||||||
|
* particular job, given a set of matrix variables.
|
||||||
|
*
|
||||||
|
* Typically you'll want to wrap this function in a try/catch block and handle the error.
|
||||||
|
*
|
||||||
|
* @returns the checkout_path input
|
||||||
|
* @throws an error if the checkout_path input could not be determined
|
||||||
|
*/
|
||||||
|
export function getCheckoutPathInputOrThrow(
|
||||||
|
workflow: Workflow,
|
||||||
|
jobName: string,
|
||||||
|
matrixVars: { [key: string]: string } | undefined
|
||||||
|
): string {
|
||||||
|
return (
|
||||||
|
getInputOrThrow(
|
||||||
|
workflow,
|
||||||
|
jobName,
|
||||||
|
getAnalyzeActionName(),
|
||||||
|
"checkout_path",
|
||||||
|
matrixVars
|
||||||
|
) || getRequiredEnvParam("GITHUB_WORKSPACE") // if unspecified, checkout_path defaults to ${{ github.workspace }}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user