mirror of
https://github.com/github/codeql-action.git
synced 2026-08-05 04:57:19 -05:00
Compare commits
39 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3d39294047 | |||
| e4cc4a2fef | |||
| 84dffe700c | |||
| 9e044c5432 | |||
| 24c8de16fa | |||
| f359ba7af1 | |||
| 5960ce1190 | |||
| 59fbe34861 | |||
| 6ace05baa3 | |||
| 4cf80047d0 | |||
| c0641ea1d3 | |||
| 61b87c69a6 | |||
| 57719e015c | |||
| 0831a67a20 | |||
| ffa74c5cb3 | |||
| 885b397f2e | |||
| e0e5ded33c | |||
| c60b8543e6 | |||
| 97054749c9 | |||
| fb0f74784f | |||
| 3400e51bc8 | |||
| 74740eef3d | |||
| 1ec8ea99ee | |||
| 2466f0ce2c | |||
| a711c7623d | |||
| 39064e0f9b | |||
| 28c63d131f | |||
| a4e4529299 | |||
| cc4ee05a07 | |||
| 1f0700d1c0 | |||
| cab46c529f | |||
| e37b0d6470 | |||
| 314ede696b | |||
| b96c7546c1 | |||
| 4c8f13758e | |||
| b98b2def63 | |||
| a643eb3621 | |||
| 6188cbdeb9 | |||
| 4706007119 |
+1
@@ -93,4 +93,5 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
TEST_MODE: true
|
TEST_MODE: true
|
||||||
env:
|
env:
|
||||||
|
DOTNET_GENERATE_ASPNET_CERTIFICATE: 'false'
|
||||||
INTERNAL_CODEQL_ACTION_DEBUG_LOC: true
|
INTERNAL_CODEQL_ACTION_DEBUG_LOC: true
|
||||||
|
|||||||
-97
@@ -1,97 +0,0 @@
|
|||||||
# 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 - Test unsetting environment variables
|
|
||||||
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:
|
|
||||||
unset-environment:
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
include:
|
|
||||||
- os: ubuntu-latest
|
|
||||||
version: stable-20210308
|
|
||||||
- os: ubuntu-latest
|
|
||||||
version: stable-20210319
|
|
||||||
- os: ubuntu-latest
|
|
||||||
version: stable-20210809
|
|
||||||
- os: ubuntu-latest
|
|
||||||
version: cached
|
|
||||||
- os: ubuntu-latest
|
|
||||||
version: latest
|
|
||||||
- os: ubuntu-latest
|
|
||||||
version: nightly-latest
|
|
||||||
name: Test unsetting environment variables
|
|
||||||
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: ./../action/init
|
|
||||||
with:
|
|
||||||
db-location: ${{ runner.temp }}/customDbLocation
|
|
||||||
tools: ${{ steps.prepare-test.outputs.tools-url }}
|
|
||||||
env:
|
|
||||||
TEST_MODE: true
|
|
||||||
- name: Build code
|
|
||||||
shell: bash
|
|
||||||
run: env -i PATH="$PATH" HOME="$HOME" ./build.sh
|
|
||||||
- uses: ./../action/analyze
|
|
||||||
id: analysis
|
|
||||||
env:
|
|
||||||
TEST_MODE: true
|
|
||||||
- shell: bash
|
|
||||||
run: |
|
|
||||||
CPP_DB=${{ fromJson(steps.analysis.outputs.db-locations).cpp }}
|
|
||||||
if [[ ! -d $CPP_DB ]] || [[ ! $CPP_DB == ${{ runner.temp }}/customDbLocation/* ]]; then
|
|
||||||
echo "Did not create a database for CPP, or created it in the wrong location."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
CSHARP_DB=${{ fromJson(steps.analysis.outputs.db-locations).csharp }}
|
|
||||||
if [[ ! -d $CSHARP_DB ]] || [[ ! $CSHARP_DB == ${{ runner.temp }}/customDbLocation/* ]]; then
|
|
||||||
echo "Did not create a database for C Sharp, or created it in the wrong location."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
GO_DB=${{ fromJson(steps.analysis.outputs.db-locations).go }}
|
|
||||||
if [[ ! -d $GO_DB ]] || [[ ! $GO_DB == ${{ runner.temp }}/customDbLocation/* ]]; then
|
|
||||||
echo "Did not create a database for Go, or created it in the wrong location."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
JAVA_DB=${{ fromJson(steps.analysis.outputs.db-locations).java }}
|
|
||||||
if [[ ! -d $JAVA_DB ]] || [[ ! $JAVA_DB == ${{ runner.temp }}/customDbLocation/* ]]; then
|
|
||||||
echo "Did not create a database for Java, or created it in the wrong location."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
JAVASCRIPT_DB=${{ fromJson(steps.analysis.outputs.db-locations).javascript }}
|
|
||||||
if [[ ! -d $JAVASCRIPT_DB ]] || [[ ! $JAVASCRIPT_DB == ${{ runner.temp }}/customDbLocation/* ]]; then
|
|
||||||
echo "Did not create a database for Javascript, or created it in the wrong location."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
PYTHON_DB=${{ fromJson(steps.analysis.outputs.db-locations).python }}
|
|
||||||
if [[ ! -d $PYTHON_DB ]] || [[ ! $PYTHON_DB == ${{ runner.temp }}/customDbLocation/* ]]; then
|
|
||||||
echo "Did not create a database for Python, or created it in the wrong location."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
env:
|
|
||||||
INTERNAL_CODEQL_ACTION_DEBUG_LOC: true
|
|
||||||
@@ -79,7 +79,7 @@ jobs:
|
|||||||
echo "Missing database initialization logs"
|
echo "Missing database initialization logs"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [[ ! -d "$language/log" ]] ; then
|
if [[ ! "$language" == "go" ]] && [[ ! -d "$language/log" ]] ; then
|
||||||
echo "Missing logs for $language"
|
echo "Missing logs for $language"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -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") | 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 contains("Update") or contains("update") or contains("test-setup-python-scripts") | not)] | unique | sort')"
|
||||||
|
|
||||||
echo "$CHECKS" | jq
|
echo "$CHECKS" | jq
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,95 @@
|
|||||||
|
# See `unset-environment-old-cli.yml` for reasoning behind the separate tests.
|
||||||
|
name: PR Check - Test unsetting environment variables for CLI version >= 2.5.1
|
||||||
|
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:
|
||||||
|
unset-environment:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: ubuntu-latest
|
||||||
|
version: stable-20210809
|
||||||
|
- os: ubuntu-latest
|
||||||
|
version: cached
|
||||||
|
- os: ubuntu-latest
|
||||||
|
version: latest
|
||||||
|
- os: ubuntu-latest
|
||||||
|
version: nightly-latest
|
||||||
|
name: Test unsetting environment variables
|
||||||
|
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: ./../action/init
|
||||||
|
with:
|
||||||
|
db-location: ${{ runner.temp }}/customDbLocation
|
||||||
|
tools: ${{ steps.prepare-test.outputs.tools-url }}
|
||||||
|
env:
|
||||||
|
TEST_MODE: true
|
||||||
|
- name: Build code
|
||||||
|
shell: bash
|
||||||
|
run: env -i PATH="$PATH" HOME="$HOME" ./build.sh
|
||||||
|
- uses: ./../action/analyze
|
||||||
|
id: analysis
|
||||||
|
env:
|
||||||
|
TEST_MODE: true
|
||||||
|
- shell: bash
|
||||||
|
run: |
|
||||||
|
CPP_DB="${{ fromJson(steps.analysis.outputs.db-locations).cpp }}"
|
||||||
|
if [[ ! -d "$CPP_DB" ]] || [[ ! "$CPP_DB" == "${RUNNER_TEMP}/customDbLocation/cpp" ]]; then
|
||||||
|
echo "::error::Did not create a database for CPP, or created it in the wrong location." \
|
||||||
|
"Expected location was '${RUNNER_TEMP}/customDbLocation/cpp' but actual was '${CPP_DB}'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
CSHARP_DB="${{ fromJson(steps.analysis.outputs.db-locations).csharp }}"
|
||||||
|
if [[ ! -d "$CSHARP_DB" ]] || [[ ! "$CSHARP_DB" == "${RUNNER_TEMP}/customDbLocation/csharp" ]]; then
|
||||||
|
echo "::error::Did not create a database for C Sharp, or created it in the wrong location." \
|
||||||
|
"Expected location was '${RUNNER_TEMP}/customDbLocation/csharp' but actual was '${CSHARP_DB}'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
GO_DB="${{ fromJson(steps.analysis.outputs.db-locations).go }}"
|
||||||
|
if [[ ! -d "$GO_DB" ]] || [[ ! "$GO_DB" == "${RUNNER_TEMP}/customDbLocation/go" ]]; then
|
||||||
|
echo "::error::Did not create a database for Go, or created it in the wrong location." \
|
||||||
|
"Expected location was '${RUNNER_TEMP}/customDbLocation/go' but actual was '${GO_DB}'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
JAVA_DB="${{ fromJson(steps.analysis.outputs.db-locations).java }}"
|
||||||
|
if [[ ! -d "$JAVA_DB" ]] || [[ ! "$JAVA_DB" == "${RUNNER_TEMP}/customDbLocation/java" ]]; then
|
||||||
|
echo "::error::Did not create a database for Java, or created it in the wrong location." \
|
||||||
|
"Expected location was '${RUNNER_TEMP}/customDbLocation/java' but actual was '${JAVA_DB}'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
JAVASCRIPT_DB="${{ fromJson(steps.analysis.outputs.db-locations).javascript }}"
|
||||||
|
if [[ ! -d "$JAVASCRIPT_DB" ]] || [[ ! "$JAVASCRIPT_DB" == "${RUNNER_TEMP}/customDbLocation/javascript" ]]; then
|
||||||
|
echo "::error::Did not create a database for Javascript, or created it in the wrong location." \
|
||||||
|
"Expected location was '${RUNNER_TEMP}/customDbLocation/javascript' but actual was '${JAVASCRIPT_DB}'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
PYTHON_DB="${{ fromJson(steps.analysis.outputs.db-locations).python }}"
|
||||||
|
if [[ ! -d "$PYTHON_DB" ]] || [[ ! "$PYTHON_DB" == "${RUNNER_TEMP}/customDbLocation/python" ]]; then
|
||||||
|
echo "::error::Did not create a database for Python, or created it in the wrong location." \
|
||||||
|
"Expected location was '${RUNNER_TEMP}/customDbLocation/python' but actual was '${PYTHON_DB}'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
env:
|
||||||
|
INTERNAL_CODEQL_ACTION_DEBUG_LOC: true
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
# There was a bug, fixed in CLI v2.5.1, that didn't propagate environment
|
||||||
|
# variables that the Java tracer needed. Here we test all languages
|
||||||
|
# except Java for these CLI versions. In `unset-environment-new-cli.yml`
|
||||||
|
# we test all languages for recent CLI versions.
|
||||||
|
name: PR Check - Test unsetting environment variables for CLI version < 2.5.1
|
||||||
|
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:
|
||||||
|
unset-environment:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: ubuntu-latest
|
||||||
|
version: stable-20210308
|
||||||
|
- os: ubuntu-latest
|
||||||
|
version: stable-20210319
|
||||||
|
name: Test unsetting environment variables
|
||||||
|
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: ./../action/init
|
||||||
|
with:
|
||||||
|
languages: csharp,cpp,go,javascript,python
|
||||||
|
db-location: ${{ runner.temp }}/customDbLocation
|
||||||
|
tools: ${{ steps.prepare-test.outputs.tools-url }}
|
||||||
|
env:
|
||||||
|
TEST_MODE: true
|
||||||
|
- name: Build code
|
||||||
|
shell: bash
|
||||||
|
run: env -i PATH="$PATH" HOME="$HOME" ./build.sh
|
||||||
|
- uses: ./../action/analyze
|
||||||
|
id: analysis
|
||||||
|
env:
|
||||||
|
TEST_MODE: true
|
||||||
|
- shell: bash
|
||||||
|
run: |
|
||||||
|
CPP_DB="${{ fromJson(steps.analysis.outputs.db-locations).cpp }}"
|
||||||
|
if [[ ! -d "$CPP_DB" ]] || [[ ! "$CPP_DB" == "${RUNNER_TEMP}/customDbLocation/cpp" ]]; then
|
||||||
|
echo "::error::Did not create a database for CPP, or created it in the wrong location." \
|
||||||
|
"Expected location was '${RUNNER_TEMP}/customDbLocation/cpp' but actual was '${CPP_DB}'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
CSHARP_DB="${{ fromJson(steps.analysis.outputs.db-locations).csharp }}"
|
||||||
|
if [[ ! -d "$CSHARP_DB" ]] || [[ ! "$CSHARP_DB" == "${RUNNER_TEMP}/customDbLocation/csharp" ]]; then
|
||||||
|
echo "::error::Did not create a database for C Sharp, or created it in the wrong location." \
|
||||||
|
"Expected location was '${RUNNER_TEMP}/customDbLocation/csharp' but actual was '${CSHARP_DB}'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
GO_DB="${{ fromJson(steps.analysis.outputs.db-locations).go }}"
|
||||||
|
if [[ ! -d "$GO_DB" ]] || [[ ! "$GO_DB" == "${RUNNER_TEMP}/customDbLocation/go" ]]; then
|
||||||
|
echo "::error::Did not create a database for Go, or created it in the wrong location." \
|
||||||
|
"Expected location was '${RUNNER_TEMP}/customDbLocation/go' but actual was '${GO_DB}'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
JAVASCRIPT_DB="${{ fromJson(steps.analysis.outputs.db-locations).javascript }}"
|
||||||
|
if [[ ! -d "$JAVASCRIPT_DB" ]] || [[ ! "$JAVASCRIPT_DB" == "${RUNNER_TEMP}/customDbLocation/javascript" ]]; then
|
||||||
|
echo "::error::Did not create a database for Javascript, or created it in the wrong location." \
|
||||||
|
"Expected location was '${RUNNER_TEMP}/customDbLocation/javascript' but actual was '${JAVASCRIPT_DB}'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
PYTHON_DB="${{ fromJson(steps.analysis.outputs.db-locations).python }}"
|
||||||
|
if [[ ! -d "$PYTHON_DB" ]] || [[ ! "$PYTHON_DB" == "${RUNNER_TEMP}/customDbLocation/python" ]]; then
|
||||||
|
echo "::error::Did not create a database for Python, or created it in the wrong location." \
|
||||||
|
"Expected location was '${RUNNER_TEMP}/customDbLocation/python' but actual was '${PYTHON_DB}'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
env:
|
||||||
|
INTERNAL_CODEQL_ACTION_DEBUG_LOC: true
|
||||||
@@ -1,5 +1,17 @@
|
|||||||
# CodeQL Action Changelog
|
# CodeQL Action Changelog
|
||||||
|
|
||||||
|
## [UNRELEASED]
|
||||||
|
|
||||||
|
No user facing changes.
|
||||||
|
|
||||||
|
## 2.1.27 - 06 Oct 2022
|
||||||
|
|
||||||
|
- We are rolling out a feature of the CodeQL Action in October 2022 that changes the way that Go code is analyzed to be more consistent with other compiled languages like C/C++, C#, and Java. You do not need to alter your code scanning workflows. If you encounter any problems, please [file an issue](https://github.com/github/codeql-action/issues) or open a private ticket with GitHub Support and request an escalation to engineering.
|
||||||
|
|
||||||
|
## 2.1.26 - 29 Sep 2022
|
||||||
|
|
||||||
|
- Update default CodeQL bundle version to 2.11.0. [#1267](https://github.com/github/codeql-action/pull/1267)
|
||||||
|
|
||||||
## 2.1.25 - 21 Sep 2022
|
## 2.1.25 - 21 Sep 2022
|
||||||
|
|
||||||
- We will soon be rolling out a feature of the CodeQL Action that stores some information used to make future runs faster in the GitHub Actions cache. Initially, this will only be enabled on JavaScript repositories, but we plan to add more languages to this soon. The new feature can be disabled by passing the `trap-caching: false` option to your workflow's `init` step, for example if you are already using the GitHub Actions cache for a different purpose and are near the storage limit for it.
|
- We will soon be rolling out a feature of the CodeQL Action that stores some information used to make future runs faster in the GitHub Actions cache. Initially, this will only be enabled on JavaScript repositories, but we plan to add more languages to this soon. The new feature can be disabled by passing the `trap-caching: false` option to your workflow's `init` step, for example if you are already using the GitHub Actions cache for a different purpose and are near the storage limit for it.
|
||||||
|
|||||||
Generated
+1
-1
@@ -452,7 +452,7 @@ async function getRef() {
|
|||||||
// in actions/checkout@v1 this may not be true as it checks out the repository
|
// in actions/checkout@v1 this may not be true as it checks out the repository
|
||||||
// using GITHUB_REF. There is a subtle race condition where
|
// using GITHUB_REF. There is a subtle race condition where
|
||||||
// git rev-parse GITHUB_REF != GITHUB_SHA, so we must check
|
// git rev-parse GITHUB_REF != GITHUB_SHA, so we must check
|
||||||
// git git-parse GITHUB_REF == git rev-parse HEAD instead.
|
// git rev-parse GITHUB_REF == git rev-parse HEAD instead.
|
||||||
const hasChangedRef = sha !== head &&
|
const hasChangedRef = sha !== head &&
|
||||||
(await (0, exports.getCommitOid)(checkoutPath, ref.replace(/^refs\/pull\//, "refs/remotes/pull/"))) !== head;
|
(await (0, exports.getCommitOid)(checkoutPath, ref.replace(/^refs\/pull\//, "refs/remotes/pull/"))) !== head;
|
||||||
if (hasChangedRef) {
|
if (hasChangedRef) {
|
||||||
|
|||||||
Generated
+1
@@ -52,6 +52,7 @@ const util = __importStar(require("./util"));
|
|||||||
gitHubVersion,
|
gitHubVersion,
|
||||||
languages: [],
|
languages: [],
|
||||||
packs: [],
|
packs: [],
|
||||||
|
trapCaches: {},
|
||||||
});
|
});
|
||||||
const requiredInputStub = sinon.stub(actionsUtil, "getRequiredInput");
|
const requiredInputStub = sinon.stub(actionsUtil, "getRequiredInput");
|
||||||
requiredInputStub.withArgs("token").returns("fake-token");
|
requiredInputStub.withArgs("token").returns("fake-token");
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file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C,CAAC;QACzD,MAAM,aAAa,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;QAElD,uEAAuE;QACvE,oEAAoE;QACpE,4EAA4E;QAC5E,wEAAwE;QACxE,MAAM,aAAa,CAAC,UAAU,CAAC;QAE/B,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;QAC/D,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;QAC7D,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;QAC9D,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
||||||
Generated
+1
@@ -52,6 +52,7 @@ const util = __importStar(require("./util"));
|
|||||||
gitHubVersion,
|
gitHubVersion,
|
||||||
languages: [],
|
languages: [],
|
||||||
packs: [],
|
packs: [],
|
||||||
|
trapCaches: {},
|
||||||
});
|
});
|
||||||
const requiredInputStub = sinon.stub(actionsUtil, "getRequiredInput");
|
const requiredInputStub = sinon.stub(actionsUtil, "getRequiredInput");
|
||||||
requiredInputStub.withArgs("token").returns("fake-token");
|
requiredInputStub.withArgs("token").returns("fake-token");
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"analyze-action-input.test.js","sourceRoot":"","sources":["../src/analyze-action-input.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAuB;AACvB,6CAA+B;AAE/B,4DAA8C;AAC9C,mDAAqC;AACrC,4DAA8C;AAC9C,mDAIyB;AACzB,6CAA+B;AAE/B,IAAA,0BAAU,EAAC,aAAI,CAA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AAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;QACzD,MAAM,aAAa,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;QAElD,uEAAuE;QACvE,oEAAoE;QACpE,4EAA4E;QAC5E,wEAAwE;QACxE,MAAM,aAAa,CAAC,UAAU,CAAC;QAE/B,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;QAC/D,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;QAC7D,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;QAC9D,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
||||||
Generated
+1
-1
@@ -163,7 +163,7 @@ async function run() {
|
|||||||
await runAutobuildIfLegacyGoWorkflow(config, featureFlags, logger);
|
await runAutobuildIfLegacyGoWorkflow(config, featureFlags, logger);
|
||||||
dbCreationTimings = await (0, analyze_1.runFinalize)(outputDir, threads, memory, config, logger, featureFlags);
|
dbCreationTimings = await (0, analyze_1.runFinalize)(outputDir, threads, memory, config, logger, featureFlags);
|
||||||
if (actionsUtil.getRequiredInput("skip-queries") !== "true") {
|
if (actionsUtil.getRequiredInput("skip-queries") !== "true") {
|
||||||
runStats = await (0, analyze_1.runQueries)(outputDir, memory, util.getAddSnippetsFlag(actionsUtil.getRequiredInput("add-snippets")), threads, actionsUtil.getOptionalInput("category"), config, logger);
|
runStats = await (0, analyze_1.runQueries)(outputDir, memory, util.getAddSnippetsFlag(actionsUtil.getRequiredInput("add-snippets")), threads, actionsUtil.getOptionalInput("category"), config, logger, featureFlags);
|
||||||
}
|
}
|
||||||
if (actionsUtil.getOptionalInput("cleanup-level") !== "none") {
|
if (actionsUtil.getOptionalInput("cleanup-level") !== "none") {
|
||||||
await (0, analyze_1.runCleanup)(config, actionsUtil.getOptionalInput("cleanup-level") || "brutal", logger);
|
await (0, analyze_1.runCleanup)(config, actionsUtil.getOptionalInput("cleanup-level") || "brutal", logger);
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Generated
+3
-2
@@ -122,7 +122,7 @@ async function finalizeDatabaseCreation(config, threadsFlag, memoryFlag, logger,
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
// Runs queries and creates sarif files in the given folder
|
// Runs queries and creates sarif files in the given folder
|
||||||
async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag, automationDetailsId, config, logger) {
|
async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag, automationDetailsId, config, logger, featureFlags) {
|
||||||
const statusReport = {};
|
const statusReport = {};
|
||||||
let locPromise = Promise.resolve({});
|
let locPromise = Promise.resolve({});
|
||||||
const cliCanCountBaseline = await cliCanCountLoC();
|
const cliCanCountBaseline = await cliCanCountLoC();
|
||||||
@@ -136,6 +136,7 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
|
|||||||
config.paths, config.pathsIgnore, config.languages, logger);
|
config.paths, config.pathsIgnore, config.languages, logger);
|
||||||
}
|
}
|
||||||
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
||||||
|
await util.logCodeScanningConfigInCli(codeql, featureFlags, logger);
|
||||||
for (const language of config.languages) {
|
for (const language of config.languages) {
|
||||||
const queries = config.queries[language];
|
const queries = config.queries[language];
|
||||||
const queryFilters = validateQueryFilters(config.originalUserInput["query-filters"]);
|
const queryFilters = validateQueryFilters(config.originalUserInput["query-filters"]);
|
||||||
@@ -147,7 +148,7 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
|
|||||||
throw new Error(`Unable to analyse ${language} as no queries were selected for this language`);
|
throw new Error(`Unable to analyse ${language} as no queries were selected for this language`);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (await util.useCodeScanningConfigInCli(codeql)) {
|
if (await util.useCodeScanningConfigInCli(codeql, featureFlags)) {
|
||||||
// If we are using the codescanning config in the CLI,
|
// If we are using the codescanning config in the CLI,
|
||||||
// much of the work needed to generate the query suites
|
// much of the work needed to generate the query suites
|
||||||
// is done in the CLI. We just need to make a single
|
// is done in the CLI. We just need to make a single
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
Generated
+3
-2
@@ -30,6 +30,7 @@ const sinon = __importStar(require("sinon"));
|
|||||||
const analyze_1 = require("./analyze");
|
const analyze_1 = require("./analyze");
|
||||||
const codeql_1 = require("./codeql");
|
const codeql_1 = require("./codeql");
|
||||||
const count = __importStar(require("./count-loc"));
|
const count = __importStar(require("./count-loc"));
|
||||||
|
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 testing_utils_1 = require("./testing-utils");
|
const testing_utils_1 = require("./testing-utils");
|
||||||
@@ -131,7 +132,7 @@ const util = __importStar(require("./util"));
|
|||||||
builtin: ["foo.ql"],
|
builtin: ["foo.ql"],
|
||||||
custom: [],
|
custom: [],
|
||||||
};
|
};
|
||||||
const builtinStatusReport = await (0, analyze_1.runQueries)(tmpDir, memoryFlag, addSnippetsFlag, threadsFlag, undefined, config, (0, logging_1.getRunnerLogger)(true));
|
const builtinStatusReport = await (0, analyze_1.runQueries)(tmpDir, memoryFlag, addSnippetsFlag, threadsFlag, undefined, config, (0, logging_1.getRunnerLogger)(true), (0, feature_flags_1.createFeatureFlags)([]));
|
||||||
const hasPacks = language in packs;
|
const hasPacks = language in packs;
|
||||||
const statusReportKeys = Object.keys(builtinStatusReport).sort();
|
const statusReportKeys = Object.keys(builtinStatusReport).sort();
|
||||||
if (hasPacks) {
|
if (hasPacks) {
|
||||||
@@ -157,7 +158,7 @@ const util = __importStar(require("./util"));
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
const customStatusReport = await (0, analyze_1.runQueries)(tmpDir, memoryFlag, addSnippetsFlag, threadsFlag, undefined, config, (0, logging_1.getRunnerLogger)(true));
|
const customStatusReport = await (0, analyze_1.runQueries)(tmpDir, memoryFlag, addSnippetsFlag, threadsFlag, undefined, config, (0, logging_1.getRunnerLogger)(true), (0, feature_flags_1.createFeatureFlags)([]));
|
||||||
t.deepEqual(Object.keys(customStatusReport).length, 2);
|
t.deepEqual(Object.keys(customStatusReport).length, 2);
|
||||||
t.true(`analyze_custom_queries_${language}_duration_ms` in customStatusReport);
|
t.true(`analyze_custom_queries_${language}_duration_ms` in customStatusReport);
|
||||||
const expectedSearchPathsUsed = hasPacks
|
const expectedSearchPathsUsed = hasPacks
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Generated
+5
-4
@@ -224,7 +224,7 @@ async function getCodeQLBundleDownloadURL(apiDetails, variant, logger) {
|
|||||||
* @param logger
|
* @param logger
|
||||||
* @param checkVersion Whether to check that CodeQL CLI meets the minimum
|
* @param checkVersion Whether to check that CodeQL CLI meets the minimum
|
||||||
* version requirement. Must be set to true outside tests.
|
* version requirement. Must be set to true outside tests.
|
||||||
* @returns
|
* @returns a { CodeQL, toolsVersion } object.
|
||||||
*/
|
*/
|
||||||
async function setupCodeQL(codeqlURL, apiDetails, tempDir, variant, featureFlags, logger, checkVersion) {
|
async function setupCodeQL(codeqlURL, apiDetails, tempDir, variant, featureFlags, logger, checkVersion) {
|
||||||
try {
|
try {
|
||||||
@@ -267,6 +267,7 @@ async function setupCodeQL(codeqlURL, apiDetails, tempDir, variant, featureFlags
|
|||||||
if (fs.existsSync(path.join(tmpCodeqlFolder, "pinned-version"))) {
|
if (fs.existsSync(path.join(tmpCodeqlFolder, "pinned-version"))) {
|
||||||
logger.debug(`CodeQL in cache overriding the default ${CODEQL_BUNDLE_VERSION}`);
|
logger.debug(`CodeQL in cache overriding the default ${CODEQL_BUNDLE_VERSION}`);
|
||||||
codeqlFolder = tmpCodeqlFolder;
|
codeqlFolder = tmpCodeqlFolder;
|
||||||
|
codeqlURLVersion = codeqlVersions[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -515,7 +516,7 @@ async function getCodeQLForCmd(cmd, checkVersion) {
|
|||||||
extraArgs.push("--no-internal-use-lua-tracing");
|
extraArgs.push("--no-internal-use-lua-tracing");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const configLocation = await generateCodescanningConfig(codeql, config);
|
const configLocation = await generateCodescanningConfig(codeql, config, featureFlags);
|
||||||
if (configLocation) {
|
if (configLocation) {
|
||||||
extraArgs.push(`--codescanning-config=${configLocation}`);
|
extraArgs.push(`--codescanning-config=${configLocation}`);
|
||||||
}
|
}
|
||||||
@@ -875,9 +876,9 @@ async function runTool(cmd, args = []) {
|
|||||||
* @param config The configuration to use.
|
* @param config The configuration to use.
|
||||||
* @returns the path to the generated user configuration file.
|
* @returns the path to the generated user configuration file.
|
||||||
*/
|
*/
|
||||||
async function generateCodescanningConfig(codeql, config) {
|
async function generateCodescanningConfig(codeql, config, featureFlags) {
|
||||||
var _a;
|
var _a;
|
||||||
if (!(await util.useCodeScanningConfigInCli(codeql))) {
|
if (!(await util.useCodeScanningConfigInCli(codeql, featureFlags))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const configLocation = path.resolve(config.tempDir, "user-config.yaml");
|
const configLocation = path.resolve(config.tempDir, "user-config.yaml");
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
Generated
+25
-10
@@ -95,7 +95,7 @@ async function mockApiAndSetupCodeQL({ apiDetails, featureFlags, isPinned, tmpDi
|
|||||||
(0, nock_1.default)(baseUrl)
|
(0, nock_1.default)(baseUrl)
|
||||||
.get(relativeUrl)
|
.get(relativeUrl)
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle${isPinned ? "-pinned" : ""}.tar.gz`));
|
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle${isPinned ? "-pinned" : ""}.tar.gz`));
|
||||||
await codeql.setupCodeQL(toolsInput ? toolsInput.input : `${baseUrl}${relativeUrl}`, apiDetails !== null && apiDetails !== void 0 ? apiDetails : sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, featureFlags !== null && featureFlags !== void 0 ? featureFlags : (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true), false);
|
return await codeql.setupCodeQL(toolsInput ? toolsInput.input : `${baseUrl}${relativeUrl}`, apiDetails !== null && apiDetails !== void 0 ? apiDetails : sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, featureFlags !== null && featureFlags !== void 0 ? featureFlags : (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true), false);
|
||||||
}
|
}
|
||||||
(0, ava_1.default)("download codeql bundle cache", async (t) => {
|
(0, ava_1.default)("download codeql bundle cache", async (t) => {
|
||||||
await util.withTmpDir(async (tmpDir) => {
|
await util.withTmpDir(async (tmpDir) => {
|
||||||
@@ -103,8 +103,9 @@ async function mockApiAndSetupCodeQL({ apiDetails, featureFlags, isPinned, tmpDi
|
|||||||
const versions = ["20200601", "20200610"];
|
const versions = ["20200601", "20200610"];
|
||||||
for (let i = 0; i < versions.length; i++) {
|
for (let i = 0; i < versions.length; i++) {
|
||||||
const version = versions[i];
|
const version = versions[i];
|
||||||
await mockApiAndSetupCodeQL({ version, tmpDir });
|
const codeQLConfig = await mockApiAndSetupCodeQL({ version, tmpDir });
|
||||||
t.assert(toolcache.find("CodeQL", `0.0.0-${version}`));
|
t.assert(toolcache.find("CodeQL", `0.0.0-${version}`));
|
||||||
|
t.deepEqual(codeQLConfig.toolsVersion, version);
|
||||||
}
|
}
|
||||||
t.is(toolcache.findAllVersions("CodeQL").length, 2);
|
t.is(toolcache.findAllVersions("CodeQL").length, 2);
|
||||||
});
|
});
|
||||||
@@ -112,26 +113,33 @@ async function mockApiAndSetupCodeQL({ apiDetails, featureFlags, isPinned, tmpDi
|
|||||||
(0, ava_1.default)("download codeql bundle cache explicitly requested with pinned different version cached", async (t) => {
|
(0, ava_1.default)("download codeql bundle cache explicitly requested with pinned different version cached", async (t) => {
|
||||||
await util.withTmpDir(async (tmpDir) => {
|
await util.withTmpDir(async (tmpDir) => {
|
||||||
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
await mockApiAndSetupCodeQL({
|
const pinnedCodeQLConfig = await mockApiAndSetupCodeQL({
|
||||||
version: "20200601",
|
version: "20200601",
|
||||||
isPinned: true,
|
isPinned: true,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
});
|
});
|
||||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
||||||
await mockApiAndSetupCodeQL({ version: "20200610", tmpDir });
|
t.deepEqual(pinnedCodeQLConfig.toolsVersion, "20200601");
|
||||||
|
const unpinnedCodeQLConfig = await mockApiAndSetupCodeQL({
|
||||||
|
version: "20200610",
|
||||||
|
tmpDir,
|
||||||
|
});
|
||||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200610"));
|
t.assert(toolcache.find("CodeQL", "0.0.0-20200610"));
|
||||||
|
t.deepEqual(unpinnedCodeQLConfig.toolsVersion, "20200610");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("don't download codeql bundle cache with pinned different version cached", async (t) => {
|
(0, ava_1.default)("don't download codeql bundle cache with pinned different version cached", async (t) => {
|
||||||
await util.withTmpDir(async (tmpDir) => {
|
await util.withTmpDir(async (tmpDir) => {
|
||||||
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
await mockApiAndSetupCodeQL({
|
const pinnedCodeQLConfig = await mockApiAndSetupCodeQL({
|
||||||
version: "20200601",
|
version: "20200601",
|
||||||
isPinned: true,
|
isPinned: true,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
});
|
});
|
||||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
||||||
await codeql.setupCodeQL(undefined, sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true), false);
|
t.deepEqual(pinnedCodeQLConfig.toolsVersion, "20200601");
|
||||||
|
const codeQLConfig = await codeql.setupCodeQL(undefined, sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true), false);
|
||||||
|
t.deepEqual(codeQLConfig.toolsVersion, "0.0.0-20200601");
|
||||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||||
t.is(cachedVersions.length, 1);
|
t.is(cachedVersions.length, 1);
|
||||||
});
|
});
|
||||||
@@ -139,14 +147,19 @@ async function mockApiAndSetupCodeQL({ apiDetails, featureFlags, isPinned, tmpDi
|
|||||||
(0, ava_1.default)("download codeql bundle cache with different version cached (not pinned)", async (t) => {
|
(0, ava_1.default)("download codeql bundle cache with different version cached (not pinned)", async (t) => {
|
||||||
await util.withTmpDir(async (tmpDir) => {
|
await util.withTmpDir(async (tmpDir) => {
|
||||||
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
await mockApiAndSetupCodeQL({ version: "20200601", tmpDir });
|
const cachedCodeQLConfig = await mockApiAndSetupCodeQL({
|
||||||
|
version: "20200601",
|
||||||
|
tmpDir,
|
||||||
|
});
|
||||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
||||||
await mockApiAndSetupCodeQL({
|
t.deepEqual(cachedCodeQLConfig.toolsVersion, "20200601");
|
||||||
|
const codeQLConfig = await mockApiAndSetupCodeQL({
|
||||||
version: defaults.bundleVersion,
|
version: defaults.bundleVersion,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
apiDetails: sampleApiDetails,
|
apiDetails: sampleApiDetails,
|
||||||
toolsInput: { input: undefined },
|
toolsInput: { input: undefined },
|
||||||
});
|
});
|
||||||
|
t.deepEqual(codeQLConfig.toolsVersion, defaults.bundleVersion.replace("codeql-bundle-", ""));
|
||||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||||
t.is(cachedVersions.length, 2);
|
t.is(cachedVersions.length, 2);
|
||||||
});
|
});
|
||||||
@@ -154,18 +167,20 @@ async function mockApiAndSetupCodeQL({ apiDetails, featureFlags, isPinned, tmpDi
|
|||||||
(0, ava_1.default)('download codeql bundle cache with pinned different version cached if "latest" tools specified', async (t) => {
|
(0, ava_1.default)('download codeql bundle cache with pinned different version cached if "latest" tools specified', async (t) => {
|
||||||
await util.withTmpDir(async (tmpDir) => {
|
await util.withTmpDir(async (tmpDir) => {
|
||||||
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
await mockApiAndSetupCodeQL({
|
const pinnedCodeQLConfig = await mockApiAndSetupCodeQL({
|
||||||
version: "20200601",
|
version: "20200601",
|
||||||
isPinned: true,
|
isPinned: true,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
});
|
});
|
||||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
||||||
await mockApiAndSetupCodeQL({
|
t.deepEqual(pinnedCodeQLConfig.toolsVersion, "20200601");
|
||||||
|
const latestCodeQLConfig = await mockApiAndSetupCodeQL({
|
||||||
version: defaults.bundleVersion,
|
version: defaults.bundleVersion,
|
||||||
apiDetails: sampleApiDetails,
|
apiDetails: sampleApiDetails,
|
||||||
toolsInput: { input: "latest" },
|
toolsInput: { input: "latest" },
|
||||||
tmpDir,
|
tmpDir,
|
||||||
});
|
});
|
||||||
|
t.deepEqual(latestCodeQLConfig.toolsVersion, defaults.bundleVersion.replace("codeql-bundle-", ""));
|
||||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||||
t.is(cachedVersions.length, 2);
|
t.is(cachedVersions.length, 2);
|
||||||
});
|
});
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Generated
+2
-1
@@ -908,7 +908,8 @@ async function initConfig(languagesInput, queriesInput, packsInput, registriesIn
|
|||||||
// When using the codescanning config in the CLI, pack downloads
|
// When using the codescanning config in the CLI, pack downloads
|
||||||
// happen in the CLI during the `database init` command, so no need
|
// happen in the CLI during the `database init` command, so no need
|
||||||
// to download them here.
|
// to download them here.
|
||||||
if (!(await (0, util_1.useCodeScanningConfigInCli)(codeQL))) {
|
await (0, util_1.logCodeScanningConfigInCli)(codeQL, featureFlags, logger);
|
||||||
|
if (!(await (0, util_1.useCodeScanningConfigInCli)(codeQL, featureFlags))) {
|
||||||
const registries = parseRegistries(registriesInput);
|
const registries = parseRegistries(registriesInput);
|
||||||
await downloadPacks(codeQL, config.languages, config.packs, registries, apiDetails, config.tempDir, logger);
|
await downloadPacks(codeQL, config.languages, config.packs, registries, apiDetails, config.tempDir, logger);
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"bundleVersion": "codeql-bundle-20220908"
|
"bundleVersion": "codeql-bundle-20220923"
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+1
@@ -28,6 +28,7 @@ var FeatureFlag;
|
|||||||
FeatureFlag["MlPoweredQueriesEnabled"] = "ml_powered_queries_enabled";
|
FeatureFlag["MlPoweredQueriesEnabled"] = "ml_powered_queries_enabled";
|
||||||
FeatureFlag["TrapCachingEnabled"] = "trap_caching_enabled";
|
FeatureFlag["TrapCachingEnabled"] = "trap_caching_enabled";
|
||||||
FeatureFlag["GolangExtractionReconciliationEnabled"] = "golang_extraction_reconciliation_enabled";
|
FeatureFlag["GolangExtractionReconciliationEnabled"] = "golang_extraction_reconciliation_enabled";
|
||||||
|
FeatureFlag["CliConfigFileEnabled"] = "cli_config_file_enabled";
|
||||||
})(FeatureFlag = exports.FeatureFlag || (exports.FeatureFlag = {}));
|
})(FeatureFlag = exports.FeatureFlag || (exports.FeatureFlag = {}));
|
||||||
class GitHubFeatureFlags {
|
class GitHubFeatureFlags {
|
||||||
constructor(gitHubVersion, apiDetails, repositoryNwo, logger) {
|
constructor(gitHubVersion, apiDetails, repositoryNwo, logger) {
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"feature-flags.js","sourceRoot":"","sources":["../src/feature-flags.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA8D;AAG9D,6CAA+B;AAM/B,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,kEAAmD,CAAA;IACnD,qEAAsD,CAAA;IACtD,0DAA2C,CAAA;IAC3C,iGAAkF,CAAA;AACpF,CAAC,EALW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAKtB;AAUD,MAAa,kBAAkB;IAG7B,YACU,aAAiC,EACjC,UAA4B,EAC5B,aAA4B,EAC5B,MAAc;QAHd,kBAAa,GAAb,aAAa,CAAoB;QACjC,eAAU,GAAV,UAAU,CAAkB;QAC5B,kBAAa,GAAb,aAAa,CAAe;QAC5B,WAAM,GAAN,MAAM,CAAQ;IACrB,CAAC;IAEJ,KAAK,CAAC,QAAQ,CAAC,IAAiB;QAC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I,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,GAAG,EAAE;oBAC3C,IAAI,CAAC,MAAM,CAAC,OAAO,CACjB,gGAAgG;wBAC9F,oEAAoE;wBACpE,qFAAqF;wBACrF,kFAAkF,CAAC,EAAE,CACxF,CAAC;iBACH;qBAAM;oBACL,uFAAuF;oBACvF,mFAAmF;oBACnF,2FAA2F;oBAC3F,qBAAqB;oBACrB,MAAM,IAAI,KAAK,CACb,4DAA4D,CAAC,EAAE,CAChE,CAAC;iBACH;aACF;QACH,CAAC,CAAC;QAEF,MAAM,WAAW,GAAG,IAAI,CAAC,iBAAiB,IAAI,CAAC,MAAM,eAAe,EAAE,CAAC,CAAC;QACxE,IAAI,CAAC,iBAAiB,GAAG,WAAW,CAAC;QACrC,OAAO,WAAW,CAAC;IACrB,CAAC;CACF;AA5ED,gDA4EC;AAED;;;;GAIG;AACH,SAAgB,kBAAkB,CAAC,YAA2B;IAC5D,OAAO;QACL,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;YACvB,OAAO,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACrC,CAAC;KACF,CAAC;AACJ,CAAC;AAND,gDAMC"}
|
||||||
Generated
+31
-15
@@ -47,7 +47,6 @@ async function initConfig(languagesInput, queriesInput, packsInput, registriesIn
|
|||||||
}
|
}
|
||||||
exports.initConfig = initConfig;
|
exports.initConfig = initConfig;
|
||||||
async function runInit(codeql, config, sourceRoot, processName, processLevel, featureFlags, logger) {
|
async function runInit(codeql, config, sourceRoot, processName, processLevel, featureFlags, logger) {
|
||||||
var _a, _b;
|
|
||||||
fs.mkdirSync(config.dbLocation, { recursive: true });
|
fs.mkdirSync(config.dbLocation, { recursive: true });
|
||||||
try {
|
try {
|
||||||
if (await (0, util_1.codeQlVersionAbove)(codeql, codeql_1.CODEQL_VERSION_NEW_TRACING)) {
|
if (await (0, util_1.codeQlVersionAbove)(codeql, codeql_1.CODEQL_VERSION_NEW_TRACING)) {
|
||||||
@@ -62,24 +61,41 @@ async function runInit(codeql, config, sourceRoot, processName, processLevel, fe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
// Handle the situation where init is called twice
|
throw processError(e);
|
||||||
// for the same database in the same job.
|
|
||||||
if (e instanceof Error &&
|
|
||||||
((_a = e.message) === null || _a === void 0 ? void 0 : _a.includes("Refusing to create databases")) &&
|
|
||||||
e.message.includes("exists and is not an empty directory.")) {
|
|
||||||
throw new util.UserError(`Is the "init" action called twice in the same job? ${e.message}`);
|
|
||||||
}
|
|
||||||
else if (e instanceof Error &&
|
|
||||||
((_b = e.message) === null || _b === void 0 ? void 0 : _b.includes("is not compatible with this CodeQL CLI"))) {
|
|
||||||
throw new util.UserError(e.message);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return await (0, tracer_config_1.getCombinedTracerConfig)(config, codeql, await util.isGoExtractionReconciliationEnabled(featureFlags), logger);
|
return await (0, tracer_config_1.getCombinedTracerConfig)(config, codeql, await util.isGoExtractionReconciliationEnabled(featureFlags), logger);
|
||||||
}
|
}
|
||||||
exports.runInit = runInit;
|
exports.runInit = runInit;
|
||||||
|
/**
|
||||||
|
* Possibly convert this error into a UserError in order to avoid
|
||||||
|
* counting this error towards our internal error budget.
|
||||||
|
*
|
||||||
|
* @param e The error to possibly convert to a UserError.
|
||||||
|
*
|
||||||
|
* @returns A UserError if the error is a known error that can be
|
||||||
|
* attributed to the user, otherwise the original error.
|
||||||
|
*/
|
||||||
|
function processError(e) {
|
||||||
|
var _a, _b, _c, _d;
|
||||||
|
if (!(e instanceof Error)) {
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
// Init action called twice
|
||||||
|
((_a = e.message) === null || _a === void 0 ? void 0 : _a.includes("Refusing to create databases")) &&
|
||||||
|
((_b = e.message) === null || _b === void 0 ? void 0 : _b.includes("exists and is not an empty directory."))) {
|
||||||
|
return new util.UserError(`Is the "init" action called twice in the same job? ${e.message}`);
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
// Version of CodeQL CLI is incompatible with this version of the CodeQL Action
|
||||||
|
((_c = e.message) === null || _c === void 0 ? void 0 : _c.includes("is not compatible with this CodeQL CLI")) ||
|
||||||
|
(
|
||||||
|
// Expected source location for database creation does not exist
|
||||||
|
(_d = e.message) === null || _d === void 0 ? void 0 : _d.includes("Invalid source root"))) {
|
||||||
|
return new util.UserError(e.message);
|
||||||
|
}
|
||||||
|
return e;
|
||||||
|
}
|
||||||
// Runs a powershell script to inject the tracer into a parent process
|
// Runs a powershell script to inject the tracer into a parent process
|
||||||
// so it can tracer future processes, hopefully including the build process.
|
// so it can tracer future processes, hopefully including the build process.
|
||||||
// If processName is given then injects into the nearest parent process with
|
// If processName is given then injects into the nearest parent process with
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,yEAA2D;AAC3D,kEAAoD;AAEpD,gEAAkD;AAElD,qCAA2E;AAC3E,4DAA8C;AAI9C,mDAAwE;AACxE,6CAA+B;AAC/B,iCAA4C;AAErC,KAAK,UAAU,UAAU,CAC9B,SAA6B,EAC7B,UAA4B,EAC5B,OAAe,EACf,OAA2B,EAC3B,YAA0B,EAC1B,MAAc;IAEd,MAAM,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC;IACxC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,IAAA,oBAAW,EAChD,SAAS,EACT,UAAU,EACV,OAAO,EACP,OAAO,EACP,YAAY,EACZ,MAAM,EACN,IAAI,CACL,CAAC;IACF,MAAM,MAAM,CAAC,YAAY,EAAE,CAAC;IAC5B,MAAM,CAAC,QAAQ,EAAE,CAAC;IAClB,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IAAI;gBACJ,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC;gBAChC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;aAC/B,CAAC,CAAC,IAAI,EAAE,CAAC;SACX;KACF;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,CAAC,QAAQ,EAAE,CAAC;QAClB,MAAM,CAAC,OAAO,CACZ,gFAAgF,CAAC,IAAI;YACnF,qGAAqG;YACrG,oGAAoG;YACpG,iDAAiD,CACpD,CAAC;QACF,OAAO;KACR;IACD,MAAM,CAAC,QAAQ,EAAE,CAAC;AACpB,CAAC;AAzCD,8CAyCC"}
|
||||||
Generated
+1
-1
@@ -295,7 +295,7 @@ program
|
|||||||
const threads = (0, util_1.getThreadsFlag)(cmd.threads || initEnv["CODEQL_THREADS"], logger);
|
const threads = (0, util_1.getThreadsFlag)(cmd.threads || initEnv["CODEQL_THREADS"], logger);
|
||||||
const memory = (0, util_1.getMemoryFlag)(cmd.ram || initEnv["CODEQL_RAM"]);
|
const memory = (0, util_1.getMemoryFlag)(cmd.ram || initEnv["CODEQL_RAM"]);
|
||||||
await (0, analyze_1.runFinalize)(outputDir, threads, memory, config, logger, (0, feature_flags_1.createFeatureFlags)([]));
|
await (0, analyze_1.runFinalize)(outputDir, threads, memory, config, logger, (0, feature_flags_1.createFeatureFlags)([]));
|
||||||
await (0, analyze_1.runQueries)(outputDir, memory, (0, util_1.getAddSnippetsFlag)(cmd.addSnippets), threads, cmd.category, config, logger);
|
await (0, analyze_1.runQueries)(outputDir, memory, (0, util_1.getAddSnippetsFlag)(cmd.addSnippets), threads, cmd.category, config, logger, (0, feature_flags_1.createFeatureFlags)([]));
|
||||||
if (!cmd.upload) {
|
if (!cmd.upload) {
|
||||||
logger.info("Not uploading results");
|
logger.info("Not uploading results");
|
||||||
return;
|
return;
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
Generated
+28
-22
@@ -18,19 +18,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
__setModuleDefault(result, mod);
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.getTotalCacheSize = exports.getLanguagesSupportingCaching = exports.uploadTrapCaches = exports.downloadTrapCaches = exports.getTrapCachingExtractorConfigArgsForLang = exports.getTrapCachingExtractorConfigArgs = void 0;
|
exports.getTotalCacheSize = exports.getLanguagesSupportingCaching = exports.uploadTrapCaches = exports.downloadTrapCaches = exports.getTrapCachingExtractorConfigArgsForLang = exports.getTrapCachingExtractorConfigArgs = void 0;
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const util_1 = require("util");
|
|
||||||
const cache = __importStar(require("@actions/cache"));
|
const cache = __importStar(require("@actions/cache"));
|
||||||
const get_folder_size_1 = __importDefault(require("get-folder-size"));
|
|
||||||
const actionsUtil = __importStar(require("./actions-util"));
|
const actionsUtil = __importStar(require("./actions-util"));
|
||||||
const codeql_1 = require("./codeql");
|
const codeql_1 = require("./codeql");
|
||||||
const util_2 = require("./util");
|
const util_1 = require("./util");
|
||||||
// This constant should be bumped if we make a breaking change
|
// This constant should be bumped if we make a breaking change
|
||||||
// to how the CodeQL Action stores or retrieves the TRAP cache,
|
// to how the CodeQL Action stores or retrieves the TRAP cache,
|
||||||
// and will invalidate previous caches. We don't need to bump
|
// and will invalidate previous caches. We don't need to bump
|
||||||
@@ -39,6 +34,14 @@ const util_2 = require("./util");
|
|||||||
const CACHE_VERSION = 1;
|
const CACHE_VERSION = 1;
|
||||||
// This constant sets the size of each TRAP cache in megabytes.
|
// This constant sets the size of each TRAP cache in megabytes.
|
||||||
const CACHE_SIZE_MB = 1024;
|
const CACHE_SIZE_MB = 1024;
|
||||||
|
// This constant sets the minimum size in megabytes of a TRAP
|
||||||
|
// cache for us to consider it worth uploading.
|
||||||
|
const MINIMUM_CACHE_MB_TO_UPLOAD = 10;
|
||||||
|
// The maximum number of milliseconds to wait for TRAP cache
|
||||||
|
// uploads or downloads to complete before continuing. Note
|
||||||
|
// this timeout is per operation, so will be run as many
|
||||||
|
// times as there are languages with TRAP caching enabled.
|
||||||
|
const MAX_CACHE_OPERATION_MS = 120000; // Two minutes
|
||||||
async function getTrapCachingExtractorConfigArgs(config) {
|
async function getTrapCachingExtractorConfigArgs(config) {
|
||||||
const result = [];
|
const result = [];
|
||||||
for (const language of config.languages)
|
for (const language of config.languages)
|
||||||
@@ -97,9 +100,11 @@ async function downloadTrapCaches(codeql, languages, logger) {
|
|||||||
// The SHA from the base of the PR is the most similar commit we might have a cache for
|
// The SHA from the base of the PR is the most similar commit we might have a cache for
|
||||||
const preferredKey = await cacheKey(codeql, language, baseSha);
|
const preferredKey = await cacheKey(codeql, language, baseSha);
|
||||||
logger.info(`Looking in Actions cache for TRAP cache with key ${preferredKey}`);
|
logger.info(`Looking in Actions cache for TRAP cache with key ${preferredKey}`);
|
||||||
const found = await cache.restoreCache([cacheDir], preferredKey, [
|
const found = await (0, util_1.withTimeout)(MAX_CACHE_OPERATION_MS, cache.restoreCache([cacheDir], preferredKey, [
|
||||||
await cachePrefix(codeql, language), // Fall back to any cache with the right key prefix
|
await cachePrefix(codeql, language), // Fall back to any cache with the right key prefix
|
||||||
]);
|
]), () => {
|
||||||
|
logger.info(`Timed out waiting for TRAP cache download for ${language}, will continue without it`);
|
||||||
|
});
|
||||||
if (found === undefined) {
|
if (found === undefined) {
|
||||||
// We didn't find a TRAP cache in the Actions cache, so the directory on disk is
|
// We didn't find a TRAP cache in the Actions cache, so the directory on disk is
|
||||||
// still just an empty directory. There's no reason to tell the extractor to use it,
|
// still just an empty directory. There's no reason to tell the extractor to use it,
|
||||||
@@ -121,23 +126,32 @@ exports.downloadTrapCaches = downloadTrapCaches;
|
|||||||
async function uploadTrapCaches(codeql, config, logger) {
|
async function uploadTrapCaches(codeql, config, logger) {
|
||||||
if (!(await actionsUtil.isAnalyzingDefaultBranch()))
|
if (!(await actionsUtil.isAnalyzingDefaultBranch()))
|
||||||
return false; // Only upload caches from the default branch
|
return false; // Only upload caches from the default branch
|
||||||
const toAwait = [];
|
|
||||||
for (const language of config.languages) {
|
for (const language of config.languages) {
|
||||||
const cacheDir = config.trapCaches[language];
|
const cacheDir = config.trapCaches[language];
|
||||||
if (cacheDir === undefined)
|
if (cacheDir === undefined)
|
||||||
continue;
|
continue;
|
||||||
|
const trapFolderSize = await (0, util_1.tryGetFolderBytes)(cacheDir, logger);
|
||||||
|
if (trapFolderSize === undefined) {
|
||||||
|
logger.info(`Skipping upload of TRAP cache for ${language} as we couldn't determine its size`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (trapFolderSize < MINIMUM_CACHE_MB_TO_UPLOAD * 1048576) {
|
||||||
|
logger.info(`Skipping upload of TRAP cache for ${language} as it is too small`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
const key = await cacheKey(codeql, language, process.env.GITHUB_SHA || "unknown");
|
const key = await cacheKey(codeql, language, process.env.GITHUB_SHA || "unknown");
|
||||||
logger.info(`Uploading TRAP cache to Actions cache with key ${key}`);
|
logger.info(`Uploading TRAP cache to Actions cache with key ${key}`);
|
||||||
toAwait.push(cache.saveCache([cacheDir], key));
|
await (0, util_1.withTimeout)(MAX_CACHE_OPERATION_MS, cache.saveCache([cacheDir], key), () => {
|
||||||
|
logger.info(`Timed out waiting for TRAP cache for ${language} to upload, will continue without uploading`);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
await Promise.all(toAwait);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
exports.uploadTrapCaches = uploadTrapCaches;
|
exports.uploadTrapCaches = uploadTrapCaches;
|
||||||
async function getLanguagesSupportingCaching(codeql, languages, logger) {
|
async function getLanguagesSupportingCaching(codeql, languages, logger) {
|
||||||
var _a, _b, _c, _d;
|
var _a, _b, _c, _d;
|
||||||
const result = [];
|
const result = [];
|
||||||
if (!(await (0, util_2.codeQlVersionAbove)(codeql, codeql_1.CODEQL_VERSION_BETTER_RESOLVE_LANGUAGES)))
|
if (!(await (0, util_1.codeQlVersionAbove)(codeql, codeql_1.CODEQL_VERSION_BETTER_RESOLVE_LANGUAGES)))
|
||||||
return result;
|
return result;
|
||||||
const resolveResult = await codeql.betterResolveLanguages();
|
const resolveResult = await codeql.betterResolveLanguages();
|
||||||
outer: for (const lang of languages) {
|
outer: for (const lang of languages) {
|
||||||
@@ -168,16 +182,8 @@ async function getLanguagesSupportingCaching(codeql, languages, logger) {
|
|||||||
}
|
}
|
||||||
exports.getLanguagesSupportingCaching = getLanguagesSupportingCaching;
|
exports.getLanguagesSupportingCaching = getLanguagesSupportingCaching;
|
||||||
async function getTotalCacheSize(trapCaches, logger) {
|
async function getTotalCacheSize(trapCaches, logger) {
|
||||||
try {
|
const sizes = await Promise.all(Object.values(trapCaches).map((cacheDir) => (0, util_1.tryGetFolderBytes)(cacheDir, logger)));
|
||||||
const sizes = await Promise.all(Object.values(trapCaches).map(async (cacheDir) => {
|
return sizes.map((a) => a || 0).reduce((a, b) => a + b, 0);
|
||||||
return (0, util_1.promisify)(get_folder_size_1.default)(cacheDir);
|
|
||||||
}));
|
|
||||||
return sizes.reduce((a, b) => a + b, 0);
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
logger.warning(`Encountered an error while getting TRAP cache size: ${e}`);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
exports.getTotalCacheSize = getTotalCacheSize;
|
exports.getTotalCacheSize = getTotalCacheSize;
|
||||||
async function cacheKey(codeql, language, baseSha) {
|
async function cacheKey(codeql, language, baseSha) {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Generated
+1
@@ -164,6 +164,7 @@ function getTestConfigWithTempDir(tmpDir) {
|
|||||||
const loggedMessages = [];
|
const loggedMessages = [];
|
||||||
const logger = (0, testing_utils_1.getRecordingLogger)(loggedMessages);
|
const logger = (0, testing_utils_1.getRecordingLogger)(loggedMessages);
|
||||||
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
||||||
|
sinon.stub(util, "tryGetFolderBytes").resolves(999999999);
|
||||||
const stubSave = sinon.stub(cache, "saveCache");
|
const stubSave = sinon.stub(cache, "saveCache");
|
||||||
process.env.GITHUB_SHA = "somesha";
|
process.env.GITHUB_SHA = "somesha";
|
||||||
await (0, trap_caching_1.uploadTrapCaches)(stubCodeql, testConfigWithoutTmpDir, logger);
|
await (0, trap_caching_1.uploadTrapCaches)(stubCodeql, testConfigWithoutTmpDir, logger);
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Generated
+68
-5
@@ -22,12 +22,14 @@ 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.isGoExtractionReconciliationEnabled = exports.listFolder = exports.doesDirectoryExist = 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.isGitHubGhesVersionBelow = exports.isHTTPError = exports.UserError = exports.HTTPError = exports.getRequiredEnvParam = exports.isActions = exports.getMode = exports.enrichEnvironment = exports.initializeEnvironment = exports.Mode = exports.assertNever = exports.getGitHubAuth = exports.apiVersionInRange = exports.DisallowedAPIVersionReason = exports.checkGitHubVersionInRange = exports.getGitHubVersion = exports.GitHubVariant = exports.parseGitHubUrl = exports.getCodeQLDatabasePath = exports.getThreadsFlag = exports.getThreadsFlagValue = exports.getAddSnippetsFlag = exports.getMemoryFlag = exports.getMemoryFlagValue = exports.withTmpDir = exports.getToolNames = exports.getExtraOptionsEnvParam = exports.DID_AUTOBUILD_GO_ENV_VAR_NAME = exports.DEFAULT_DEBUG_DATABASE_NAME = exports.DEFAULT_DEBUG_ARTIFACT_NAME = exports.GITHUB_DOTCOM_URL = void 0;
|
exports.withTimeout = exports.tryGetFolderBytes = exports.isGoExtractionReconciliationEnabled = 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.isGitHubGhesVersionBelow = exports.isHTTPError = exports.UserError = exports.HTTPError = exports.getRequiredEnvParam = exports.isActions = exports.getMode = exports.enrichEnvironment = exports.initializeEnvironment = exports.EnvVar = exports.Mode = exports.assertNever = exports.getGitHubAuth = exports.apiVersionInRange = exports.DisallowedAPIVersionReason = exports.checkGitHubVersionInRange = exports.getGitHubVersion = exports.GitHubVariant = exports.parseGitHubUrl = exports.getCodeQLDatabasePath = exports.getThreadsFlag = exports.getThreadsFlagValue = exports.getAddSnippetsFlag = exports.getMemoryFlag = exports.getMemoryFlagValue = exports.withTmpDir = exports.getToolNames = exports.getExtraOptionsEnvParam = exports.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"));
|
||||||
|
const util_1 = require("util");
|
||||||
const core = __importStar(require("@actions/core"));
|
const core = __importStar(require("@actions/core"));
|
||||||
const del_1 = __importDefault(require("del"));
|
const del_1 = __importDefault(require("del"));
|
||||||
|
const get_folder_size_1 = __importDefault(require("get-folder-size"));
|
||||||
const semver = __importStar(require("semver"));
|
const semver = __importStar(require("semver"));
|
||||||
const api = __importStar(require("./api-client"));
|
const api = __importStar(require("./api-client"));
|
||||||
const api_client_1 = require("./api-client");
|
const api_client_1 = require("./api-client");
|
||||||
@@ -428,7 +430,7 @@ var EnvVar;
|
|||||||
* the codeql-config file to the codeql CLI to be processed there.
|
* the codeql-config file to the codeql CLI to be processed there.
|
||||||
*/
|
*/
|
||||||
EnvVar["CODEQL_PASS_CONFIG_TO_CLI"] = "CODEQL_PASS_CONFIG_TO_CLI";
|
EnvVar["CODEQL_PASS_CONFIG_TO_CLI"] = "CODEQL_PASS_CONFIG_TO_CLI";
|
||||||
})(EnvVar || (EnvVar = {}));
|
})(EnvVar = exports.EnvVar || (exports.EnvVar = {}));
|
||||||
const exportVar = (mode, name, value) => {
|
const exportVar = (mode, name, value) => {
|
||||||
if (mode === Mode.actions) {
|
if (mode === Mode.actions) {
|
||||||
core.exportVariable(name, value);
|
core.exportVariable(name, value);
|
||||||
@@ -489,6 +491,9 @@ function getRequiredEnvParam(paramName) {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
exports.getRequiredEnvParam = getRequiredEnvParam;
|
exports.getRequiredEnvParam = getRequiredEnvParam;
|
||||||
|
function getOptionalEnvParam(paramName) {
|
||||||
|
return process.env[paramName] || "";
|
||||||
|
}
|
||||||
class HTTPError extends Error {
|
class HTTPError extends Error {
|
||||||
constructor(message, status) {
|
constructor(message, status) {
|
||||||
super(message);
|
super(message);
|
||||||
@@ -657,11 +662,32 @@ exports.isInTestMode = isInTestMode;
|
|||||||
* @returns true if the action should generate a conde-scanning config file
|
* @returns true if the action should generate a conde-scanning config file
|
||||||
* that gets passed to the CLI.
|
* that gets passed to the CLI.
|
||||||
*/
|
*/
|
||||||
async function useCodeScanningConfigInCli(codeql) {
|
async function useCodeScanningConfigInCli(codeql, featureFlags) {
|
||||||
return (process.env[EnvVar.CODEQL_PASS_CONFIG_TO_CLI] === "true" &&
|
const envVarIsEnabled = getOptionalEnvParam(EnvVar.CODEQL_PASS_CONFIG_TO_CLI);
|
||||||
(await codeQlVersionAbove(codeql, codeql_1.CODEQL_VERSION_CONFIG_FILES)));
|
// If the user has explicitly turned off the feature, then don't use it.
|
||||||
|
if (envVarIsEnabled.toLocaleLowerCase() === "false") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// If the user has explicitly turned on the feature, then use it.
|
||||||
|
// Or if the feature flag is enabled, then use it.
|
||||||
|
const isEnabled = envVarIsEnabled.toLocaleLowerCase() === "true" ||
|
||||||
|
(await featureFlags.getValue(feature_flags_1.FeatureFlag.CliConfigFileEnabled));
|
||||||
|
if (!isEnabled) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// If the CLI version is too old, then don't use it.
|
||||||
|
return await codeQlVersionAbove(codeql, codeql_1.CODEQL_VERSION_CONFIG_FILES);
|
||||||
}
|
}
|
||||||
exports.useCodeScanningConfigInCli = useCodeScanningConfigInCli;
|
exports.useCodeScanningConfigInCli = useCodeScanningConfigInCli;
|
||||||
|
async function logCodeScanningConfigInCli(codeql, featureFlags, logger) {
|
||||||
|
if (await useCodeScanningConfigInCli(codeql, featureFlags)) {
|
||||||
|
logger.info("Code Scanning configuration file being processed in the codeql CLI.");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
logger.info("Code Scanning configuration file being processed in the codeql-action.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.logCodeScanningConfigInCli = logCodeScanningConfigInCli;
|
||||||
/*
|
/*
|
||||||
* Returns whether the path in the argument represents an existing directory.
|
* Returns whether the path in the argument represents an existing directory.
|
||||||
*/
|
*/
|
||||||
@@ -700,4 +726,41 @@ async function isGoExtractionReconciliationEnabled(featureFlags) {
|
|||||||
(await featureFlags.getValue(feature_flags_1.FeatureFlag.GolangExtractionReconciliationEnabled)));
|
(await featureFlags.getValue(feature_flags_1.FeatureFlag.GolangExtractionReconciliationEnabled)));
|
||||||
}
|
}
|
||||||
exports.isGoExtractionReconciliationEnabled = isGoExtractionReconciliationEnabled;
|
exports.isGoExtractionReconciliationEnabled = isGoExtractionReconciliationEnabled;
|
||||||
|
/**
|
||||||
|
* Get the size a folder in bytes. This will log any filesystem errors
|
||||||
|
* as a warning and then return undefined.
|
||||||
|
*
|
||||||
|
* @param cacheDir A directory to get the size of.
|
||||||
|
* @param logger A logger to log any errors to.
|
||||||
|
* @returns The size in bytes of the folder, or undefined if errors occurred.
|
||||||
|
*/
|
||||||
|
async function tryGetFolderBytes(cacheDir, logger) {
|
||||||
|
try {
|
||||||
|
return await (0, util_1.promisify)(get_folder_size_1.default)(cacheDir);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
logger.warning(`Encountered an error while getting size of folder: ${e}`);
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.tryGetFolderBytes = tryGetFolderBytes;
|
||||||
|
/**
|
||||||
|
* Run a promise for a given amount of time, and if it doesn't resolve within
|
||||||
|
* that time, call the provided callback and then return undefined.
|
||||||
|
*
|
||||||
|
* @param timeoutMs The timeout in milliseconds.
|
||||||
|
* @param promise The promise to run.
|
||||||
|
* @param onTimeout A callback to call if the promise times out.
|
||||||
|
* @returns The result of the promise, or undefined if the promise times out.
|
||||||
|
*/
|
||||||
|
async function withTimeout(timeoutMs, promise, onTimeout) {
|
||||||
|
const timeout = new Promise((resolve) => {
|
||||||
|
setTimeout(() => {
|
||||||
|
onTimeout();
|
||||||
|
resolve(undefined);
|
||||||
|
}, timeoutMs);
|
||||||
|
});
|
||||||
|
return await Promise.race([promise, timeout]);
|
||||||
|
}
|
||||||
|
exports.withTimeout = withTimeout;
|
||||||
//# sourceMappingURL=util.js.map
|
//# sourceMappingURL=util.js.map
|
||||||
+1
-1
File diff suppressed because one or more lines are too long
Generated
+63
@@ -31,6 +31,7 @@ const github = __importStar(require("@actions/github"));
|
|||||||
const ava_1 = __importDefault(require("ava"));
|
const ava_1 = __importDefault(require("ava"));
|
||||||
const sinon = __importStar(require("sinon"));
|
const sinon = __importStar(require("sinon"));
|
||||||
const api = __importStar(require("./api-client"));
|
const api = __importStar(require("./api-client"));
|
||||||
|
const feature_flags_1 = require("./feature-flags");
|
||||||
const logging_1 = require("./logging");
|
const logging_1 = require("./logging");
|
||||||
const testing_utils_1 = require("./testing-utils");
|
const testing_utils_1 = require("./testing-utils");
|
||||||
const util = __importStar(require("./util"));
|
const util = __importStar(require("./util"));
|
||||||
@@ -361,4 +362,66 @@ for (const [version, githubVersion, shouldReportWarning,] of CHECK_ACTION_VERSIO
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
(0, ava_1.default)("useCodeScanningConfigInCli with no env var", async (t) => {
|
||||||
|
t.assert(!(await util.useCodeScanningConfigInCli(mockVersion("2.10.0"), (0, feature_flags_1.createFeatureFlags)([]))));
|
||||||
|
t.assert(!(await util.useCodeScanningConfigInCli(mockVersion("2.10.1"), (0, feature_flags_1.createFeatureFlags)([]))));
|
||||||
|
t.assert(!(await util.useCodeScanningConfigInCli(mockVersion("2.10.0"), (0, feature_flags_1.createFeatureFlags)([feature_flags_1.FeatureFlag.CliConfigFileEnabled]))));
|
||||||
|
// Yay! It works!
|
||||||
|
t.assert(await util.useCodeScanningConfigInCli(mockVersion("2.10.1"), (0, feature_flags_1.createFeatureFlags)([feature_flags_1.FeatureFlag.CliConfigFileEnabled])));
|
||||||
|
});
|
||||||
|
for (const val of ["TRUE", "true", "True"]) {
|
||||||
|
(0, ava_1.default)(`useCodeScanningConfigInCli with env var ${val}`, async (t) => {
|
||||||
|
process.env[util.EnvVar.CODEQL_PASS_CONFIG_TO_CLI] = val;
|
||||||
|
t.assert(!(await util.useCodeScanningConfigInCli(mockVersion("2.10.0"), (0, feature_flags_1.createFeatureFlags)([]))));
|
||||||
|
t.assert(!(await util.useCodeScanningConfigInCli(mockVersion("2.10.0"), (0, feature_flags_1.createFeatureFlags)([feature_flags_1.FeatureFlag.CliConfigFileEnabled]))));
|
||||||
|
// Yay! It works!
|
||||||
|
t.assert(await util.useCodeScanningConfigInCli(mockVersion("2.10.1"), (0, feature_flags_1.createFeatureFlags)([feature_flags_1.FeatureFlag.CliConfigFileEnabled])));
|
||||||
|
t.assert(await util.useCodeScanningConfigInCli(mockVersion("2.10.1"), (0, feature_flags_1.createFeatureFlags)([])));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
for (const val of ["FALSE", "false", "False"]) {
|
||||||
|
(0, ava_1.default)(`useCodeScanningConfigInCli with env var ${val}`, async (t) => {
|
||||||
|
// Never turned on when env var is false
|
||||||
|
process.env[util.EnvVar.CODEQL_PASS_CONFIG_TO_CLI] = val;
|
||||||
|
t.assert(!(await util.useCodeScanningConfigInCli(mockVersion("2.10.0"), (0, feature_flags_1.createFeatureFlags)([]))));
|
||||||
|
t.assert(!(await util.useCodeScanningConfigInCli(mockVersion("2.10.0"), (0, feature_flags_1.createFeatureFlags)([feature_flags_1.FeatureFlag.CliConfigFileEnabled]))));
|
||||||
|
t.assert(!(await util.useCodeScanningConfigInCli(mockVersion("2.10.1"), (0, feature_flags_1.createFeatureFlags)([feature_flags_1.FeatureFlag.CliConfigFileEnabled]))));
|
||||||
|
t.assert(!(await util.useCodeScanningConfigInCli(mockVersion("2.10.1"), (0, feature_flags_1.createFeatureFlags)([]))));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function mockVersion(version) {
|
||||||
|
return {
|
||||||
|
async getVersion() {
|
||||||
|
return version;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const longTime = 999999;
|
||||||
|
const shortTime = 10;
|
||||||
|
(0, ava_1.default)("withTimeout on long task", async (t) => {
|
||||||
|
let longTaskTimedOut = false;
|
||||||
|
const longTask = new Promise((resolve) => {
|
||||||
|
setTimeout(() => {
|
||||||
|
resolve(42);
|
||||||
|
}, longTime);
|
||||||
|
});
|
||||||
|
const result = await util.withTimeout(shortTime, longTask, () => {
|
||||||
|
longTaskTimedOut = true;
|
||||||
|
});
|
||||||
|
t.deepEqual(longTaskTimedOut, true);
|
||||||
|
t.deepEqual(result, undefined);
|
||||||
|
});
|
||||||
|
(0, ava_1.default)("withTimeout on short task", async (t) => {
|
||||||
|
let shortTaskTimedOut = false;
|
||||||
|
const shortTask = new Promise((resolve) => {
|
||||||
|
setTimeout(() => {
|
||||||
|
resolve(99);
|
||||||
|
}, shortTime);
|
||||||
|
});
|
||||||
|
const result = await util.withTimeout(longTime, shortTask, () => {
|
||||||
|
shortTaskTimedOut = true;
|
||||||
|
});
|
||||||
|
t.deepEqual(shortTaskTimedOut, false);
|
||||||
|
t.deepEqual(result, 99);
|
||||||
|
});
|
||||||
//# sourceMappingURL=util.test.js.map
|
//# sourceMappingURL=util.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.25",
|
"version": "2.1.28",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
|
|||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "codeql",
|
"name": "codeql",
|
||||||
"version": "2.1.25",
|
"version": "2.1.28",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "codeql",
|
"name": "codeql",
|
||||||
"version": "2.1.25",
|
"version": "2.1.28",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/artifact": "^1.0.0",
|
"@actions/artifact": "^1.0.0",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "codeql",
|
"name": "codeql",
|
||||||
"version": "2.1.25",
|
"version": "2.1.28",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "CodeQL action",
|
"description": "CodeQL action",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
name: "Go: Custom queries"
|
name: "Go: Custom queries"
|
||||||
description: "Checks that Go works in conjunction with a config file specifying custom queries"
|
description: "Checks that Go works in conjunction with a config file specifying custom queries"
|
||||||
|
env:
|
||||||
|
DOTNET_GENERATE_ASPNET_CERTIFICATE: "false"
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/setup-go@v3
|
- uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -1,49 +0,0 @@
|
|||||||
name: "Test unsetting environment variables"
|
|
||||||
description: "An end-to-end integration test that unsets some environment variables"
|
|
||||||
os: ["ubuntu-latest"]
|
|
||||||
steps:
|
|
||||||
- uses: ./../action/init
|
|
||||||
with:
|
|
||||||
db-location: "${{ runner.temp }}/customDbLocation"
|
|
||||||
tools: ${{ steps.prepare-test.outputs.tools-url }}
|
|
||||||
env:
|
|
||||||
TEST_MODE: true
|
|
||||||
- name: Build code
|
|
||||||
shell: bash
|
|
||||||
run: env -i PATH="$PATH" HOME="$HOME" ./build.sh
|
|
||||||
- uses: ./../action/analyze
|
|
||||||
id: analysis
|
|
||||||
env:
|
|
||||||
TEST_MODE: true
|
|
||||||
- shell: bash
|
|
||||||
run: |
|
|
||||||
CPP_DB=${{ fromJson(steps.analysis.outputs.db-locations).cpp }}
|
|
||||||
if [[ ! -d $CPP_DB ]] || [[ ! $CPP_DB == ${{ runner.temp }}/customDbLocation/* ]]; then
|
|
||||||
echo "Did not create a database for CPP, or created it in the wrong location."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
CSHARP_DB=${{ fromJson(steps.analysis.outputs.db-locations).csharp }}
|
|
||||||
if [[ ! -d $CSHARP_DB ]] || [[ ! $CSHARP_DB == ${{ runner.temp }}/customDbLocation/* ]]; then
|
|
||||||
echo "Did not create a database for C Sharp, or created it in the wrong location."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
GO_DB=${{ fromJson(steps.analysis.outputs.db-locations).go }}
|
|
||||||
if [[ ! -d $GO_DB ]] || [[ ! $GO_DB == ${{ runner.temp }}/customDbLocation/* ]]; then
|
|
||||||
echo "Did not create a database for Go, or created it in the wrong location."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
JAVA_DB=${{ fromJson(steps.analysis.outputs.db-locations).java }}
|
|
||||||
if [[ ! -d $JAVA_DB ]] || [[ ! $JAVA_DB == ${{ runner.temp }}/customDbLocation/* ]]; then
|
|
||||||
echo "Did not create a database for Java, or created it in the wrong location."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
JAVASCRIPT_DB=${{ fromJson(steps.analysis.outputs.db-locations).javascript }}
|
|
||||||
if [[ ! -d $JAVASCRIPT_DB ]] || [[ ! $JAVASCRIPT_DB == ${{ runner.temp }}/customDbLocation/* ]]; then
|
|
||||||
echo "Did not create a database for Javascript, or created it in the wrong location."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
PYTHON_DB=${{ fromJson(steps.analysis.outputs.db-locations).python }}
|
|
||||||
if [[ ! -d $PYTHON_DB ]] || [[ ! $PYTHON_DB == ${{ runner.temp }}/customDbLocation/* ]]; then
|
|
||||||
echo "Did not create a database for Python, or created it in the wrong location."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
+1
-1
@@ -545,7 +545,7 @@ export async function getRef(): Promise<string> {
|
|||||||
// in actions/checkout@v1 this may not be true as it checks out the repository
|
// in actions/checkout@v1 this may not be true as it checks out the repository
|
||||||
// using GITHUB_REF. There is a subtle race condition where
|
// using GITHUB_REF. There is a subtle race condition where
|
||||||
// git rev-parse GITHUB_REF != GITHUB_SHA, so we must check
|
// git rev-parse GITHUB_REF != GITHUB_SHA, so we must check
|
||||||
// git git-parse GITHUB_REF == git rev-parse HEAD instead.
|
// git rev-parse GITHUB_REF == git rev-parse HEAD instead.
|
||||||
const hasChangedRef =
|
const hasChangedRef =
|
||||||
sha !== head &&
|
sha !== head &&
|
||||||
(await getCommitOid(
|
(await getCommitOid(
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ test("analyze action with RAM & threads from environment variables", async (t) =
|
|||||||
gitHubVersion,
|
gitHubVersion,
|
||||||
languages: [],
|
languages: [],
|
||||||
packs: [],
|
packs: [],
|
||||||
|
trapCaches: {},
|
||||||
} as unknown as configUtils.Config);
|
} as unknown as configUtils.Config);
|
||||||
const requiredInputStub = sinon.stub(actionsUtil, "getRequiredInput");
|
const requiredInputStub = sinon.stub(actionsUtil, "getRequiredInput");
|
||||||
requiredInputStub.withArgs("token").returns("fake-token");
|
requiredInputStub.withArgs("token").returns("fake-token");
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ test("analyze action with RAM & threads from action inputs", async (t) => {
|
|||||||
gitHubVersion,
|
gitHubVersion,
|
||||||
languages: [],
|
languages: [],
|
||||||
packs: [],
|
packs: [],
|
||||||
|
trapCaches: {},
|
||||||
} as unknown as configUtils.Config);
|
} as unknown as configUtils.Config);
|
||||||
const requiredInputStub = sinon.stub(actionsUtil, "getRequiredInput");
|
const requiredInputStub = sinon.stub(actionsUtil, "getRequiredInput");
|
||||||
requiredInputStub.withArgs("token").returns("fake-token");
|
requiredInputStub.withArgs("token").returns("fake-token");
|
||||||
|
|||||||
@@ -245,6 +245,7 @@ async function run() {
|
|||||||
logger,
|
logger,
|
||||||
featureFlags
|
featureFlags
|
||||||
);
|
);
|
||||||
|
|
||||||
if (actionsUtil.getRequiredInput("skip-queries") !== "true") {
|
if (actionsUtil.getRequiredInput("skip-queries") !== "true") {
|
||||||
runStats = await runQueries(
|
runStats = await runQueries(
|
||||||
outputDir,
|
outputDir,
|
||||||
@@ -253,7 +254,8 @@ async function run() {
|
|||||||
threads,
|
threads,
|
||||||
actionsUtil.getOptionalInput("category"),
|
actionsUtil.getOptionalInput("category"),
|
||||||
config,
|
config,
|
||||||
logger
|
logger,
|
||||||
|
featureFlags
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-2
@@ -14,6 +14,7 @@ import {
|
|||||||
import { setCodeQL } from "./codeql";
|
import { setCodeQL } from "./codeql";
|
||||||
import { Config } from "./config-utils";
|
import { Config } from "./config-utils";
|
||||||
import * as count from "./count-loc";
|
import * as count from "./count-loc";
|
||||||
|
import { createFeatureFlags } from "./feature-flags";
|
||||||
import { Language } from "./languages";
|
import { Language } from "./languages";
|
||||||
import { getRunnerLogger } from "./logging";
|
import { getRunnerLogger } from "./logging";
|
||||||
import { setupTests, setupActionsVars } from "./testing-utils";
|
import { setupTests, setupActionsVars } from "./testing-utils";
|
||||||
@@ -138,7 +139,8 @@ test("status report fields and search path setting", async (t) => {
|
|||||||
threadsFlag,
|
threadsFlag,
|
||||||
undefined,
|
undefined,
|
||||||
config,
|
config,
|
||||||
getRunnerLogger(true)
|
getRunnerLogger(true),
|
||||||
|
createFeatureFlags([])
|
||||||
);
|
);
|
||||||
const hasPacks = language in packs;
|
const hasPacks = language in packs;
|
||||||
const statusReportKeys = Object.keys(builtinStatusReport).sort();
|
const statusReportKeys = Object.keys(builtinStatusReport).sort();
|
||||||
@@ -187,7 +189,8 @@ test("status report fields and search path setting", async (t) => {
|
|||||||
threadsFlag,
|
threadsFlag,
|
||||||
undefined,
|
undefined,
|
||||||
config,
|
config,
|
||||||
getRunnerLogger(true)
|
getRunnerLogger(true),
|
||||||
|
createFeatureFlags([])
|
||||||
);
|
);
|
||||||
t.deepEqual(Object.keys(customStatusReport).length, 2);
|
t.deepEqual(Object.keys(customStatusReport).length, 2);
|
||||||
t.true(
|
t.true(
|
||||||
|
|||||||
+6
-2
@@ -213,7 +213,8 @@ export async function runQueries(
|
|||||||
threadsFlag: string,
|
threadsFlag: string,
|
||||||
automationDetailsId: string | undefined,
|
automationDetailsId: string | undefined,
|
||||||
config: configUtils.Config,
|
config: configUtils.Config,
|
||||||
logger: Logger
|
logger: Logger,
|
||||||
|
featureFlags: FeatureFlags
|
||||||
): Promise<QueriesStatusReport> {
|
): Promise<QueriesStatusReport> {
|
||||||
const statusReport: QueriesStatusReport = {};
|
const statusReport: QueriesStatusReport = {};
|
||||||
|
|
||||||
@@ -238,6 +239,9 @@ export async function runQueries(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const codeql = await getCodeQL(config.codeQLCmd);
|
const codeql = await getCodeQL(config.codeQLCmd);
|
||||||
|
|
||||||
|
await util.logCodeScanningConfigInCli(codeql, featureFlags, logger);
|
||||||
|
|
||||||
for (const language of config.languages) {
|
for (const language of config.languages) {
|
||||||
const queries = config.queries[language];
|
const queries = config.queries[language];
|
||||||
const queryFilters = validateQueryFilters(
|
const queryFilters = validateQueryFilters(
|
||||||
@@ -256,7 +260,7 @@ export async function runQueries(
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (await util.useCodeScanningConfigInCli(codeql)) {
|
if (await util.useCodeScanningConfigInCli(codeql, featureFlags)) {
|
||||||
// If we are using the codescanning config in the CLI,
|
// If we are using the codescanning config in the CLI,
|
||||||
// much of the work needed to generate the query suites
|
// much of the work needed to generate the query suites
|
||||||
// is done in the CLI. We just need to make a single
|
// is done in the CLI. We just need to make a single
|
||||||
|
|||||||
+32
-11
@@ -81,7 +81,7 @@ async function mockApiAndSetupCodeQL({
|
|||||||
tmpDir: string;
|
tmpDir: string;
|
||||||
toolsInput?: { input?: string };
|
toolsInput?: { input?: string };
|
||||||
version: string;
|
version: string;
|
||||||
}) {
|
}): Promise<{ codeql: codeql.CodeQL; toolsVersion: string }> {
|
||||||
const platform =
|
const platform =
|
||||||
process.platform === "win32"
|
process.platform === "win32"
|
||||||
? "win64"
|
? "win64"
|
||||||
@@ -104,7 +104,7 @@ async function mockApiAndSetupCodeQL({
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
await codeql.setupCodeQL(
|
return await codeql.setupCodeQL(
|
||||||
toolsInput ? toolsInput.input : `${baseUrl}${relativeUrl}`,
|
toolsInput ? toolsInput.input : `${baseUrl}${relativeUrl}`,
|
||||||
apiDetails ?? sampleApiDetails,
|
apiDetails ?? sampleApiDetails,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
@@ -124,8 +124,9 @@ test("download codeql bundle cache", async (t) => {
|
|||||||
for (let i = 0; i < versions.length; i++) {
|
for (let i = 0; i < versions.length; i++) {
|
||||||
const version = versions[i];
|
const version = versions[i];
|
||||||
|
|
||||||
await mockApiAndSetupCodeQL({ version, tmpDir });
|
const codeQLConfig = await mockApiAndSetupCodeQL({ version, tmpDir });
|
||||||
t.assert(toolcache.find("CodeQL", `0.0.0-${version}`));
|
t.assert(toolcache.find("CodeQL", `0.0.0-${version}`));
|
||||||
|
t.deepEqual(codeQLConfig.toolsVersion, version);
|
||||||
}
|
}
|
||||||
|
|
||||||
t.is(toolcache.findAllVersions("CodeQL").length, 2);
|
t.is(toolcache.findAllVersions("CodeQL").length, 2);
|
||||||
@@ -136,15 +137,20 @@ test("download codeql bundle cache explicitly requested with pinned different ve
|
|||||||
await util.withTmpDir(async (tmpDir) => {
|
await util.withTmpDir(async (tmpDir) => {
|
||||||
setupActionsVars(tmpDir, tmpDir);
|
setupActionsVars(tmpDir, tmpDir);
|
||||||
|
|
||||||
await mockApiAndSetupCodeQL({
|
const pinnedCodeQLConfig = await mockApiAndSetupCodeQL({
|
||||||
version: "20200601",
|
version: "20200601",
|
||||||
isPinned: true,
|
isPinned: true,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
});
|
});
|
||||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
||||||
|
t.deepEqual(pinnedCodeQLConfig.toolsVersion, "20200601");
|
||||||
|
|
||||||
await mockApiAndSetupCodeQL({ version: "20200610", tmpDir });
|
const unpinnedCodeQLConfig = await mockApiAndSetupCodeQL({
|
||||||
|
version: "20200610",
|
||||||
|
tmpDir,
|
||||||
|
});
|
||||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200610"));
|
t.assert(toolcache.find("CodeQL", "0.0.0-20200610"));
|
||||||
|
t.deepEqual(unpinnedCodeQLConfig.toolsVersion, "20200610");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -152,15 +158,16 @@ test("don't download codeql bundle cache with pinned different version cached",
|
|||||||
await util.withTmpDir(async (tmpDir) => {
|
await util.withTmpDir(async (tmpDir) => {
|
||||||
setupActionsVars(tmpDir, tmpDir);
|
setupActionsVars(tmpDir, tmpDir);
|
||||||
|
|
||||||
await mockApiAndSetupCodeQL({
|
const pinnedCodeQLConfig = await mockApiAndSetupCodeQL({
|
||||||
version: "20200601",
|
version: "20200601",
|
||||||
isPinned: true,
|
isPinned: true,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
});
|
});
|
||||||
|
|
||||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
||||||
|
t.deepEqual(pinnedCodeQLConfig.toolsVersion, "20200601");
|
||||||
|
|
||||||
await codeql.setupCodeQL(
|
const codeQLConfig = await codeql.setupCodeQL(
|
||||||
undefined,
|
undefined,
|
||||||
sampleApiDetails,
|
sampleApiDetails,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
@@ -169,6 +176,7 @@ test("don't download codeql bundle cache with pinned different version cached",
|
|||||||
getRunnerLogger(true),
|
getRunnerLogger(true),
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
t.deepEqual(codeQLConfig.toolsVersion, "0.0.0-20200601");
|
||||||
|
|
||||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||||
|
|
||||||
@@ -180,16 +188,24 @@ test("download codeql bundle cache with different version cached (not pinned)",
|
|||||||
await util.withTmpDir(async (tmpDir) => {
|
await util.withTmpDir(async (tmpDir) => {
|
||||||
setupActionsVars(tmpDir, tmpDir);
|
setupActionsVars(tmpDir, tmpDir);
|
||||||
|
|
||||||
await mockApiAndSetupCodeQL({ version: "20200601", tmpDir });
|
const cachedCodeQLConfig = await mockApiAndSetupCodeQL({
|
||||||
|
version: "20200601",
|
||||||
|
tmpDir,
|
||||||
|
});
|
||||||
|
|
||||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
||||||
|
t.deepEqual(cachedCodeQLConfig.toolsVersion, "20200601");
|
||||||
|
|
||||||
await mockApiAndSetupCodeQL({
|
const codeQLConfig = await mockApiAndSetupCodeQL({
|
||||||
version: defaults.bundleVersion,
|
version: defaults.bundleVersion,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
apiDetails: sampleApiDetails,
|
apiDetails: sampleApiDetails,
|
||||||
toolsInput: { input: undefined },
|
toolsInput: { input: undefined },
|
||||||
});
|
});
|
||||||
|
t.deepEqual(
|
||||||
|
codeQLConfig.toolsVersion,
|
||||||
|
defaults.bundleVersion.replace("codeql-bundle-", "")
|
||||||
|
);
|
||||||
|
|
||||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||||
|
|
||||||
@@ -201,20 +217,25 @@ test('download codeql bundle cache with pinned different version cached if "late
|
|||||||
await util.withTmpDir(async (tmpDir) => {
|
await util.withTmpDir(async (tmpDir) => {
|
||||||
setupActionsVars(tmpDir, tmpDir);
|
setupActionsVars(tmpDir, tmpDir);
|
||||||
|
|
||||||
await mockApiAndSetupCodeQL({
|
const pinnedCodeQLConfig = await mockApiAndSetupCodeQL({
|
||||||
version: "20200601",
|
version: "20200601",
|
||||||
isPinned: true,
|
isPinned: true,
|
||||||
tmpDir,
|
tmpDir,
|
||||||
});
|
});
|
||||||
|
|
||||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
||||||
|
t.deepEqual(pinnedCodeQLConfig.toolsVersion, "20200601");
|
||||||
|
|
||||||
await mockApiAndSetupCodeQL({
|
const latestCodeQLConfig = await mockApiAndSetupCodeQL({
|
||||||
version: defaults.bundleVersion,
|
version: defaults.bundleVersion,
|
||||||
apiDetails: sampleApiDetails,
|
apiDetails: sampleApiDetails,
|
||||||
toolsInput: { input: "latest" },
|
toolsInput: { input: "latest" },
|
||||||
tmpDir,
|
tmpDir,
|
||||||
});
|
});
|
||||||
|
t.deepEqual(
|
||||||
|
latestCodeQLConfig.toolsVersion,
|
||||||
|
defaults.bundleVersion.replace("codeql-bundle-", "")
|
||||||
|
);
|
||||||
|
|
||||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||||
|
|
||||||
|
|||||||
+10
-4
@@ -421,7 +421,7 @@ async function getCodeQLBundleDownloadURL(
|
|||||||
* @param logger
|
* @param logger
|
||||||
* @param checkVersion Whether to check that CodeQL CLI meets the minimum
|
* @param checkVersion Whether to check that CodeQL CLI meets the minimum
|
||||||
* version requirement. Must be set to true outside tests.
|
* version requirement. Must be set to true outside tests.
|
||||||
* @returns
|
* @returns a { CodeQL, toolsVersion } object.
|
||||||
*/
|
*/
|
||||||
export async function setupCodeQL(
|
export async function setupCodeQL(
|
||||||
codeqlURL: string | undefined,
|
codeqlURL: string | undefined,
|
||||||
@@ -479,6 +479,7 @@ export async function setupCodeQL(
|
|||||||
`CodeQL in cache overriding the default ${CODEQL_BUNDLE_VERSION}`
|
`CodeQL in cache overriding the default ${CODEQL_BUNDLE_VERSION}`
|
||||||
);
|
);
|
||||||
codeqlFolder = tmpCodeqlFolder;
|
codeqlFolder = tmpCodeqlFolder;
|
||||||
|
codeqlURLVersion = codeqlVersions[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -819,7 +820,11 @@ async function getCodeQLForCmd(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const configLocation = await generateCodescanningConfig(codeql, config);
|
const configLocation = await generateCodescanningConfig(
|
||||||
|
codeql,
|
||||||
|
config,
|
||||||
|
featureFlags
|
||||||
|
);
|
||||||
if (configLocation) {
|
if (configLocation) {
|
||||||
extraArgs.push(`--codescanning-config=${configLocation}`);
|
extraArgs.push(`--codescanning-config=${configLocation}`);
|
||||||
}
|
}
|
||||||
@@ -1269,9 +1274,10 @@ async function runTool(cmd: string, args: string[] = []) {
|
|||||||
*/
|
*/
|
||||||
async function generateCodescanningConfig(
|
async function generateCodescanningConfig(
|
||||||
codeql: CodeQL,
|
codeql: CodeQL,
|
||||||
config: Config
|
config: Config,
|
||||||
|
featureFlags: FeatureFlags
|
||||||
): Promise<string | undefined> {
|
): Promise<string | undefined> {
|
||||||
if (!(await util.useCodeScanningConfigInCli(codeql))) {
|
if (!(await util.useCodeScanningConfigInCli(codeql, featureFlags))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const configLocation = path.resolve(config.tempDir, "user-config.yaml");
|
const configLocation = path.resolve(config.tempDir, "user-config.yaml");
|
||||||
|
|||||||
+4
-1
@@ -24,6 +24,7 @@ import {
|
|||||||
codeQlVersionAbove,
|
codeQlVersionAbove,
|
||||||
getMlPoweredJsQueriesPack,
|
getMlPoweredJsQueriesPack,
|
||||||
GitHubVersion,
|
GitHubVersion,
|
||||||
|
logCodeScanningConfigInCli,
|
||||||
ML_POWERED_JS_QUERIES_PACK_NAME,
|
ML_POWERED_JS_QUERIES_PACK_NAME,
|
||||||
useCodeScanningConfigInCli,
|
useCodeScanningConfigInCli,
|
||||||
} from "./util";
|
} from "./util";
|
||||||
@@ -1704,7 +1705,9 @@ export async function initConfig(
|
|||||||
// When using the codescanning config in the CLI, pack downloads
|
// When using the codescanning config in the CLI, pack downloads
|
||||||
// happen in the CLI during the `database init` command, so no need
|
// happen in the CLI during the `database init` command, so no need
|
||||||
// to download them here.
|
// to download them here.
|
||||||
if (!(await useCodeScanningConfigInCli(codeQL))) {
|
await logCodeScanningConfigInCli(codeQL, featureFlags, logger);
|
||||||
|
|
||||||
|
if (!(await useCodeScanningConfigInCli(codeQL, featureFlags))) {
|
||||||
const registries = parseRegistries(registriesInput);
|
const registries = parseRegistries(registriesInput);
|
||||||
await downloadPacks(
|
await downloadPacks(
|
||||||
codeQL,
|
codeQL,
|
||||||
|
|||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"bundleVersion": "codeql-bundle-20220908"
|
"bundleVersion": "codeql-bundle-20220923"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ export enum FeatureFlag {
|
|||||||
MlPoweredQueriesEnabled = "ml_powered_queries_enabled",
|
MlPoweredQueriesEnabled = "ml_powered_queries_enabled",
|
||||||
TrapCachingEnabled = "trap_caching_enabled",
|
TrapCachingEnabled = "trap_caching_enabled",
|
||||||
GolangExtractionReconciliationEnabled = "golang_extraction_reconciliation_enabled",
|
GolangExtractionReconciliationEnabled = "golang_extraction_reconciliation_enabled",
|
||||||
|
CliConfigFileEnabled = "cli_config_file_enabled",
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+37
-18
@@ -117,24 +117,7 @@ export async function runInit(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle the situation where init is called twice
|
throw processError(e);
|
||||||
// for the same database in the same job.
|
|
||||||
if (
|
|
||||||
e instanceof Error &&
|
|
||||||
e.message?.includes("Refusing to create databases") &&
|
|
||||||
e.message.includes("exists and is not an empty directory.")
|
|
||||||
) {
|
|
||||||
throw new util.UserError(
|
|
||||||
`Is the "init" action called twice in the same job? ${e.message}`
|
|
||||||
);
|
|
||||||
} else if (
|
|
||||||
e instanceof Error &&
|
|
||||||
e.message?.includes("is not compatible with this CodeQL CLI")
|
|
||||||
) {
|
|
||||||
throw new util.UserError(e.message);
|
|
||||||
} else {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return await getCombinedTracerConfig(
|
return await getCombinedTracerConfig(
|
||||||
config,
|
config,
|
||||||
@@ -144,6 +127,42 @@ export async function runInit(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Possibly convert this error into a UserError in order to avoid
|
||||||
|
* counting this error towards our internal error budget.
|
||||||
|
*
|
||||||
|
* @param e The error to possibly convert to a UserError.
|
||||||
|
*
|
||||||
|
* @returns A UserError if the error is a known error that can be
|
||||||
|
* attributed to the user, otherwise the original error.
|
||||||
|
*/
|
||||||
|
function processError(e: any): Error {
|
||||||
|
if (!(e instanceof Error)) {
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
// Init action called twice
|
||||||
|
e.message?.includes("Refusing to create databases") &&
|
||||||
|
e.message?.includes("exists and is not an empty directory.")
|
||||||
|
) {
|
||||||
|
return new util.UserError(
|
||||||
|
`Is the "init" action called twice in the same job? ${e.message}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
// Version of CodeQL CLI is incompatible with this version of the CodeQL Action
|
||||||
|
e.message?.includes("is not compatible with this CodeQL CLI") ||
|
||||||
|
// Expected source location for database creation does not exist
|
||||||
|
e.message?.includes("Invalid source root")
|
||||||
|
) {
|
||||||
|
return new util.UserError(e.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
// Runs a powershell script to inject the tracer into a parent process
|
// Runs a powershell script to inject the tracer into a parent process
|
||||||
// so it can tracer future processes, hopefully including the build process.
|
// so it can tracer future processes, hopefully including the build process.
|
||||||
// If processName is given then injects into the nearest parent process with
|
// If processName is given then injects into the nearest parent process with
|
||||||
|
|||||||
+2
-1
@@ -517,7 +517,8 @@ program
|
|||||||
threads,
|
threads,
|
||||||
cmd.category,
|
cmd.category,
|
||||||
config,
|
config,
|
||||||
logger
|
logger,
|
||||||
|
createFeatureFlags([])
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!cmd.upload) {
|
if (!cmd.upload) {
|
||||||
|
|||||||
@@ -165,6 +165,7 @@ test("upload cache key contains right fields", async (t) => {
|
|||||||
const loggedMessages = [];
|
const loggedMessages = [];
|
||||||
const logger = getRecordingLogger(loggedMessages);
|
const logger = getRecordingLogger(loggedMessages);
|
||||||
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
||||||
|
sinon.stub(util, "tryGetFolderBytes").resolves(999_999_999);
|
||||||
const stubSave = sinon.stub(cache, "saveCache");
|
const stubSave = sinon.stub(cache, "saveCache");
|
||||||
process.env.GITHUB_SHA = "somesha";
|
process.env.GITHUB_SHA = "somesha";
|
||||||
await uploadTrapCaches(stubCodeql, testConfigWithoutTmpDir, logger);
|
await uploadTrapCaches(stubCodeql, testConfigWithoutTmpDir, logger);
|
||||||
|
|||||||
+50
-20
@@ -1,16 +1,14 @@
|
|||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import { promisify } from "util";
|
|
||||||
|
|
||||||
import * as cache from "@actions/cache";
|
import * as cache from "@actions/cache";
|
||||||
import getFolderSize from "get-folder-size";
|
|
||||||
|
|
||||||
import * as actionsUtil from "./actions-util";
|
import * as actionsUtil from "./actions-util";
|
||||||
import { CodeQL, CODEQL_VERSION_BETTER_RESOLVE_LANGUAGES } from "./codeql";
|
import { CodeQL, CODEQL_VERSION_BETTER_RESOLVE_LANGUAGES } from "./codeql";
|
||||||
import { Config } from "./config-utils";
|
import { Config } from "./config-utils";
|
||||||
import { Language } from "./languages";
|
import { Language } from "./languages";
|
||||||
import { Logger } from "./logging";
|
import { Logger } from "./logging";
|
||||||
import { codeQlVersionAbove } from "./util";
|
import { codeQlVersionAbove, tryGetFolderBytes, withTimeout } from "./util";
|
||||||
|
|
||||||
// This constant should be bumped if we make a breaking change
|
// This constant should be bumped if we make a breaking change
|
||||||
// to how the CodeQL Action stores or retrieves the TRAP cache,
|
// to how the CodeQL Action stores or retrieves the TRAP cache,
|
||||||
@@ -22,6 +20,16 @@ const CACHE_VERSION = 1;
|
|||||||
// This constant sets the size of each TRAP cache in megabytes.
|
// This constant sets the size of each TRAP cache in megabytes.
|
||||||
const CACHE_SIZE_MB = 1024;
|
const CACHE_SIZE_MB = 1024;
|
||||||
|
|
||||||
|
// This constant sets the minimum size in megabytes of a TRAP
|
||||||
|
// cache for us to consider it worth uploading.
|
||||||
|
const MINIMUM_CACHE_MB_TO_UPLOAD = 10;
|
||||||
|
|
||||||
|
// The maximum number of milliseconds to wait for TRAP cache
|
||||||
|
// uploads or downloads to complete before continuing. Note
|
||||||
|
// this timeout is per operation, so will be run as many
|
||||||
|
// times as there are languages with TRAP caching enabled.
|
||||||
|
const MAX_CACHE_OPERATION_MS = 120_000; // Two minutes
|
||||||
|
|
||||||
export async function getTrapCachingExtractorConfigArgs(
|
export async function getTrapCachingExtractorConfigArgs(
|
||||||
config: Config
|
config: Config
|
||||||
): Promise<string[]> {
|
): Promise<string[]> {
|
||||||
@@ -105,9 +113,17 @@ export async function downloadTrapCaches(
|
|||||||
logger.info(
|
logger.info(
|
||||||
`Looking in Actions cache for TRAP cache with key ${preferredKey}`
|
`Looking in Actions cache for TRAP cache with key ${preferredKey}`
|
||||||
);
|
);
|
||||||
const found = await cache.restoreCache([cacheDir], preferredKey, [
|
const found = await withTimeout(
|
||||||
await cachePrefix(codeql, language), // Fall back to any cache with the right key prefix
|
MAX_CACHE_OPERATION_MS,
|
||||||
]);
|
cache.restoreCache([cacheDir], preferredKey, [
|
||||||
|
await cachePrefix(codeql, language), // Fall back to any cache with the right key prefix
|
||||||
|
]),
|
||||||
|
() => {
|
||||||
|
logger.info(
|
||||||
|
`Timed out waiting for TRAP cache download for ${language}, will continue without it`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
if (found === undefined) {
|
if (found === undefined) {
|
||||||
// We didn't find a TRAP cache in the Actions cache, so the directory on disk is
|
// We didn't find a TRAP cache in the Actions cache, so the directory on disk is
|
||||||
// still just an empty directory. There's no reason to tell the extractor to use it,
|
// still just an empty directory. There's no reason to tell the extractor to use it,
|
||||||
@@ -134,19 +150,38 @@ export async function uploadTrapCaches(
|
|||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
if (!(await actionsUtil.isAnalyzingDefaultBranch())) return false; // Only upload caches from the default branch
|
if (!(await actionsUtil.isAnalyzingDefaultBranch())) return false; // Only upload caches from the default branch
|
||||||
|
|
||||||
const toAwait: Array<Promise<number>> = [];
|
|
||||||
for (const language of config.languages) {
|
for (const language of config.languages) {
|
||||||
const cacheDir = config.trapCaches[language];
|
const cacheDir = config.trapCaches[language];
|
||||||
if (cacheDir === undefined) continue;
|
if (cacheDir === undefined) continue;
|
||||||
|
const trapFolderSize = await tryGetFolderBytes(cacheDir, logger);
|
||||||
|
if (trapFolderSize === undefined) {
|
||||||
|
logger.info(
|
||||||
|
`Skipping upload of TRAP cache for ${language} as we couldn't determine its size`
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (trapFolderSize < MINIMUM_CACHE_MB_TO_UPLOAD * 1_048_576) {
|
||||||
|
logger.info(
|
||||||
|
`Skipping upload of TRAP cache for ${language} as it is too small`
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
const key = await cacheKey(
|
const key = await cacheKey(
|
||||||
codeql,
|
codeql,
|
||||||
language,
|
language,
|
||||||
process.env.GITHUB_SHA || "unknown"
|
process.env.GITHUB_SHA || "unknown"
|
||||||
);
|
);
|
||||||
logger.info(`Uploading TRAP cache to Actions cache with key ${key}`);
|
logger.info(`Uploading TRAP cache to Actions cache with key ${key}`);
|
||||||
toAwait.push(cache.saveCache([cacheDir], key));
|
await withTimeout(
|
||||||
|
MAX_CACHE_OPERATION_MS,
|
||||||
|
cache.saveCache([cacheDir], key),
|
||||||
|
() => {
|
||||||
|
logger.info(
|
||||||
|
`Timed out waiting for TRAP cache for ${language} to upload, will continue without uploading`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
await Promise.all(toAwait);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,17 +236,12 @@ export async function getTotalCacheSize(
|
|||||||
trapCaches: Partial<Record<Language, string>>,
|
trapCaches: Partial<Record<Language, string>>,
|
||||||
logger: Logger
|
logger: Logger
|
||||||
): Promise<number> {
|
): Promise<number> {
|
||||||
try {
|
const sizes = await Promise.all(
|
||||||
const sizes = await Promise.all(
|
Object.values(trapCaches).map((cacheDir) =>
|
||||||
Object.values(trapCaches).map(async (cacheDir) => {
|
tryGetFolderBytes(cacheDir, logger)
|
||||||
return promisify<string, number>(getFolderSize)(cacheDir);
|
)
|
||||||
})
|
);
|
||||||
);
|
return sizes.map((a) => a || 0).reduce((a, b) => a + b, 0);
|
||||||
return sizes.reduce((a, b) => a + b, 0);
|
|
||||||
} catch (e) {
|
|
||||||
logger.warning(`Encountered an error while getting TRAP cache size: ${e}`);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function cacheKey(
|
async function cacheKey(
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ import test, { ExecutionContext } from "ava";
|
|||||||
import * as sinon from "sinon";
|
import * as sinon from "sinon";
|
||||||
|
|
||||||
import * as api from "./api-client";
|
import * as api from "./api-client";
|
||||||
|
import { CodeQL } from "./codeql";
|
||||||
import { Config } from "./config-utils";
|
import { Config } from "./config-utils";
|
||||||
|
import { createFeatureFlags, FeatureFlag } from "./feature-flags";
|
||||||
import { getRunnerLogger, Logger } from "./logging";
|
import { getRunnerLogger, Logger } from "./logging";
|
||||||
import { setupTests } from "./testing-utils";
|
import { setupTests } from "./testing-utils";
|
||||||
import * as util from "./util";
|
import * as util from "./util";
|
||||||
@@ -492,3 +494,141 @@ test("listFolder", async (t) => {
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("useCodeScanningConfigInCli with no env var", async (t) => {
|
||||||
|
t.assert(
|
||||||
|
!(await util.useCodeScanningConfigInCli(
|
||||||
|
mockVersion("2.10.0"),
|
||||||
|
createFeatureFlags([])
|
||||||
|
))
|
||||||
|
);
|
||||||
|
|
||||||
|
t.assert(
|
||||||
|
!(await util.useCodeScanningConfigInCli(
|
||||||
|
mockVersion("2.10.1"),
|
||||||
|
createFeatureFlags([])
|
||||||
|
))
|
||||||
|
);
|
||||||
|
|
||||||
|
t.assert(
|
||||||
|
!(await util.useCodeScanningConfigInCli(
|
||||||
|
mockVersion("2.10.0"),
|
||||||
|
createFeatureFlags([FeatureFlag.CliConfigFileEnabled])
|
||||||
|
))
|
||||||
|
);
|
||||||
|
|
||||||
|
// Yay! It works!
|
||||||
|
t.assert(
|
||||||
|
await util.useCodeScanningConfigInCli(
|
||||||
|
mockVersion("2.10.1"),
|
||||||
|
createFeatureFlags([FeatureFlag.CliConfigFileEnabled])
|
||||||
|
)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const val of ["TRUE", "true", "True"]) {
|
||||||
|
test(`useCodeScanningConfigInCli with env var ${val}`, async (t) => {
|
||||||
|
process.env[util.EnvVar.CODEQL_PASS_CONFIG_TO_CLI] = val;
|
||||||
|
t.assert(
|
||||||
|
!(await util.useCodeScanningConfigInCli(
|
||||||
|
mockVersion("2.10.0"),
|
||||||
|
createFeatureFlags([])
|
||||||
|
))
|
||||||
|
);
|
||||||
|
|
||||||
|
t.assert(
|
||||||
|
!(await util.useCodeScanningConfigInCli(
|
||||||
|
mockVersion("2.10.0"),
|
||||||
|
createFeatureFlags([FeatureFlag.CliConfigFileEnabled])
|
||||||
|
))
|
||||||
|
);
|
||||||
|
|
||||||
|
// Yay! It works!
|
||||||
|
t.assert(
|
||||||
|
await util.useCodeScanningConfigInCli(
|
||||||
|
mockVersion("2.10.1"),
|
||||||
|
createFeatureFlags([FeatureFlag.CliConfigFileEnabled])
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
t.assert(
|
||||||
|
await util.useCodeScanningConfigInCli(
|
||||||
|
mockVersion("2.10.1"),
|
||||||
|
createFeatureFlags([])
|
||||||
|
)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const val of ["FALSE", "false", "False"]) {
|
||||||
|
test(`useCodeScanningConfigInCli with env var ${val}`, async (t) => {
|
||||||
|
// Never turned on when env var is false
|
||||||
|
process.env[util.EnvVar.CODEQL_PASS_CONFIG_TO_CLI] = val;
|
||||||
|
t.assert(
|
||||||
|
!(await util.useCodeScanningConfigInCli(
|
||||||
|
mockVersion("2.10.0"),
|
||||||
|
createFeatureFlags([])
|
||||||
|
))
|
||||||
|
);
|
||||||
|
|
||||||
|
t.assert(
|
||||||
|
!(await util.useCodeScanningConfigInCli(
|
||||||
|
mockVersion("2.10.0"),
|
||||||
|
createFeatureFlags([FeatureFlag.CliConfigFileEnabled])
|
||||||
|
))
|
||||||
|
);
|
||||||
|
|
||||||
|
t.assert(
|
||||||
|
!(await util.useCodeScanningConfigInCli(
|
||||||
|
mockVersion("2.10.1"),
|
||||||
|
createFeatureFlags([FeatureFlag.CliConfigFileEnabled])
|
||||||
|
))
|
||||||
|
);
|
||||||
|
|
||||||
|
t.assert(
|
||||||
|
!(await util.useCodeScanningConfigInCli(
|
||||||
|
mockVersion("2.10.1"),
|
||||||
|
createFeatureFlags([])
|
||||||
|
))
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function mockVersion(version) {
|
||||||
|
return {
|
||||||
|
async getVersion() {
|
||||||
|
return version;
|
||||||
|
},
|
||||||
|
} as CodeQL;
|
||||||
|
}
|
||||||
|
|
||||||
|
const longTime = 999_999;
|
||||||
|
const shortTime = 10;
|
||||||
|
|
||||||
|
test("withTimeout on long task", async (t) => {
|
||||||
|
let longTaskTimedOut = false;
|
||||||
|
const longTask = new Promise((resolve) => {
|
||||||
|
setTimeout(() => {
|
||||||
|
resolve(42);
|
||||||
|
}, longTime);
|
||||||
|
});
|
||||||
|
const result = await util.withTimeout(shortTime, longTask, () => {
|
||||||
|
longTaskTimedOut = true;
|
||||||
|
});
|
||||||
|
t.deepEqual(longTaskTimedOut, true);
|
||||||
|
t.deepEqual(result, undefined);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("withTimeout on short task", async (t) => {
|
||||||
|
let shortTaskTimedOut = false;
|
||||||
|
const shortTask = new Promise((resolve) => {
|
||||||
|
setTimeout(() => {
|
||||||
|
resolve(99);
|
||||||
|
}, shortTime);
|
||||||
|
});
|
||||||
|
const result = await util.withTimeout(longTime, shortTask, () => {
|
||||||
|
shortTaskTimedOut = true;
|
||||||
|
});
|
||||||
|
t.deepEqual(shortTaskTimedOut, false);
|
||||||
|
t.deepEqual(result, 99);
|
||||||
|
});
|
||||||
|
|||||||
+88
-6
@@ -2,9 +2,11 @@ import * as fs from "fs";
|
|||||||
import * as os from "os";
|
import * as os from "os";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import { Readable } from "stream";
|
import { Readable } from "stream";
|
||||||
|
import { promisify } from "util";
|
||||||
|
|
||||||
import * as core from "@actions/core";
|
import * as core from "@actions/core";
|
||||||
import del from "del";
|
import del from "del";
|
||||||
|
import getFolderSize from "get-folder-size";
|
||||||
import * as semver from "semver";
|
import * as semver from "semver";
|
||||||
|
|
||||||
import * as api from "./api-client";
|
import * as api from "./api-client";
|
||||||
@@ -487,7 +489,7 @@ export enum Mode {
|
|||||||
* CLI. These environment variables are relevant for both the runner
|
* CLI. These environment variables are relevant for both the runner
|
||||||
* and the action.
|
* and the action.
|
||||||
*/
|
*/
|
||||||
enum EnvVar {
|
export enum EnvVar {
|
||||||
/**
|
/**
|
||||||
* The mode of the codeql-action, either 'actions' or 'runner'.
|
* The mode of the codeql-action, either 'actions' or 'runner'.
|
||||||
*/
|
*/
|
||||||
@@ -591,6 +593,10 @@ export function getRequiredEnvParam(paramName: string): string {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getOptionalEnvParam(paramName: string): string {
|
||||||
|
return process.env[paramName] || "";
|
||||||
|
}
|
||||||
|
|
||||||
export class HTTPError extends Error {
|
export class HTTPError extends Error {
|
||||||
public status: number;
|
public status: number;
|
||||||
|
|
||||||
@@ -787,12 +793,44 @@ export function isInTestMode(): boolean {
|
|||||||
* that gets passed to the CLI.
|
* that gets passed to the CLI.
|
||||||
*/
|
*/
|
||||||
export async function useCodeScanningConfigInCli(
|
export async function useCodeScanningConfigInCli(
|
||||||
codeql: CodeQL
|
codeql: CodeQL,
|
||||||
|
featureFlags: FeatureFlags
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
return (
|
const envVarIsEnabled = getOptionalEnvParam(EnvVar.CODEQL_PASS_CONFIG_TO_CLI);
|
||||||
process.env[EnvVar.CODEQL_PASS_CONFIG_TO_CLI] === "true" &&
|
|
||||||
(await codeQlVersionAbove(codeql, CODEQL_VERSION_CONFIG_FILES))
|
// If the user has explicitly turned off the feature, then don't use it.
|
||||||
);
|
if (envVarIsEnabled.toLocaleLowerCase() === "false") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the user has explicitly turned on the feature, then use it.
|
||||||
|
// Or if the feature flag is enabled, then use it.
|
||||||
|
const isEnabled =
|
||||||
|
envVarIsEnabled.toLocaleLowerCase() === "true" ||
|
||||||
|
(await featureFlags.getValue(FeatureFlag.CliConfigFileEnabled));
|
||||||
|
|
||||||
|
if (!isEnabled) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the CLI version is too old, then don't use it.
|
||||||
|
return await codeQlVersionAbove(codeql, CODEQL_VERSION_CONFIG_FILES);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function logCodeScanningConfigInCli(
|
||||||
|
codeql: CodeQL,
|
||||||
|
featureFlags: FeatureFlags,
|
||||||
|
logger: Logger
|
||||||
|
) {
|
||||||
|
if (await useCodeScanningConfigInCli(codeql, featureFlags)) {
|
||||||
|
logger.info(
|
||||||
|
"Code Scanning configuration file being processed in the codeql CLI."
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
logger.info(
|
||||||
|
"Code Scanning configuration file being processed in the codeql-action."
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -836,3 +874,47 @@ export async function isGoExtractionReconciliationEnabled(
|
|||||||
))
|
))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the size a folder in bytes. This will log any filesystem errors
|
||||||
|
* as a warning and then return undefined.
|
||||||
|
*
|
||||||
|
* @param cacheDir A directory to get the size of.
|
||||||
|
* @param logger A logger to log any errors to.
|
||||||
|
* @returns The size in bytes of the folder, or undefined if errors occurred.
|
||||||
|
*/
|
||||||
|
export async function tryGetFolderBytes(
|
||||||
|
cacheDir: string,
|
||||||
|
logger: Logger
|
||||||
|
): Promise<number | undefined> {
|
||||||
|
try {
|
||||||
|
return await promisify<string, number>(getFolderSize)(cacheDir);
|
||||||
|
} catch (e) {
|
||||||
|
logger.warning(`Encountered an error while getting size of folder: ${e}`);
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run a promise for a given amount of time, and if it doesn't resolve within
|
||||||
|
* that time, call the provided callback and then return undefined.
|
||||||
|
*
|
||||||
|
* @param timeoutMs The timeout in milliseconds.
|
||||||
|
* @param promise The promise to run.
|
||||||
|
* @param onTimeout A callback to call if the promise times out.
|
||||||
|
* @returns The result of the promise, or undefined if the promise times out.
|
||||||
|
*/
|
||||||
|
export async function withTimeout<T>(
|
||||||
|
timeoutMs: number,
|
||||||
|
promise: Promise<T>,
|
||||||
|
onTimeout: () => void
|
||||||
|
): Promise<T | undefined> {
|
||||||
|
const timeout: Promise<undefined> = new Promise((resolve) => {
|
||||||
|
setTimeout(() => {
|
||||||
|
onTimeout();
|
||||||
|
resolve(undefined);
|
||||||
|
}, timeoutMs);
|
||||||
|
});
|
||||||
|
|
||||||
|
return await Promise.race([promise, timeout]);
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,8 +3,10 @@ name: "Check SARIF for default queries with Single include, Single exclude"
|
|||||||
query-filters:
|
query-filters:
|
||||||
# This should run js/path-injection and js/zipslip
|
# This should run js/path-injection and js/zipslip
|
||||||
- include:
|
- include:
|
||||||
tags contain: external/cwe/cwe-022
|
tags contain:
|
||||||
|
- external/cwe/cwe-022
|
||||||
|
|
||||||
# Removes js/path-injection
|
# Removes js/path-injection
|
||||||
- exclude:
|
- exclude:
|
||||||
id: js/path-injection
|
id:
|
||||||
|
- js/path-injection
|
||||||
|
|||||||
@@ -10,12 +10,15 @@ packs:
|
|||||||
query-filters:
|
query-filters:
|
||||||
# This should run js/path-injection and js/zipslip
|
# This should run js/path-injection and js/zipslip
|
||||||
- include:
|
- include:
|
||||||
tags contain: external/cwe/cwe-022
|
tags contain:
|
||||||
|
- external/cwe/cwe-022
|
||||||
|
|
||||||
# Removes js/path-injection
|
# Removes js/path-injection
|
||||||
- exclude:
|
- exclude:
|
||||||
id: js/path-injection
|
id:
|
||||||
|
- js/path-injection
|
||||||
|
|
||||||
# Query from extra pack
|
# Query from extra pack
|
||||||
- include:
|
- include:
|
||||||
id: javascript/example/empty-or-one-block
|
id:
|
||||||
|
- javascript/example/empty-or-one-block
|
||||||
|
|||||||
@@ -20,16 +20,20 @@ packs:
|
|||||||
query-filters:
|
query-filters:
|
||||||
# This should run js/path-injection and js/zipslip
|
# This should run js/path-injection and js/zipslip
|
||||||
- include:
|
- include:
|
||||||
tags contain: external/cwe/cwe-022
|
tags contain:
|
||||||
|
- external/cwe/cwe-022
|
||||||
|
|
||||||
# Removes js/path-injection
|
# Removes js/path-injection
|
||||||
- exclude:
|
- exclude:
|
||||||
id: js/path-injection
|
id:
|
||||||
|
- js/path-injection
|
||||||
|
|
||||||
# Query from extra pack
|
# Query from extra pack
|
||||||
- include:
|
- include:
|
||||||
id: javascript/example/empty-or-one-block
|
id:
|
||||||
|
- javascript/example/empty-or-one-block
|
||||||
|
|
||||||
# Local query
|
# Local query
|
||||||
- include:
|
- include:
|
||||||
id: inrepo-javascript-querypack/show-ifs
|
id:
|
||||||
|
- inrepo-javascript-querypack/show-ifs
|
||||||
|
|||||||
Reference in New Issue
Block a user