mirror of
https://github.com/github/codeql-action.git
synced 2025-12-11 10:14:33 +08:00
Compare commits
231 Commits
v1.1.9
...
codeql-bun
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bbc2e7010f | ||
|
|
caa2a0df0a | ||
|
|
a2f4d66a8b | ||
|
|
b4ff463500 | ||
|
|
58faf9d60c | ||
|
|
dc1c51db28 | ||
|
|
2d2dfa3424 | ||
|
|
ceec52c4bc | ||
|
|
a32664975f | ||
|
|
8171514c02 | ||
|
|
6fa0b7cb22 | ||
|
|
b8bd06e075 | ||
|
|
aa231930c1 | ||
|
|
ba95eeb60e | ||
|
|
c059f95c05 | ||
|
|
75afbf4a30 | ||
|
|
01fa64cb90 | ||
|
|
28ccb035bb | ||
|
|
11111290fc | ||
|
|
d8c9c723a5 | ||
|
|
8d24c9e4c1 | ||
|
|
c8971b8e0a | ||
|
|
3e7e3b32d0 | ||
|
|
330d552535 | ||
|
|
548f07e307 | ||
|
|
a844fefc86 | ||
|
|
7ce9ef9137 | ||
|
|
d750c6d79d | ||
|
|
4cb248b0ec | ||
|
|
1e7f770864 | ||
|
|
816b3e91bc | ||
|
|
fbbd1dcd52 | ||
|
|
0a5dad3c83 | ||
|
|
d61e3fdf02 | ||
|
|
dca60ba711 | ||
|
|
e1ec69721f | ||
|
|
b45ac1f8f8 | ||
|
|
b316baae94 | ||
|
|
e655fb331c | ||
|
|
b3801753d4 | ||
|
|
3dcdbc9add | ||
|
|
688508d8cb | ||
|
|
fc926423a5 | ||
|
|
ea8fb214de | ||
|
|
3a5fa35535 | ||
|
|
7e94a6cbca | ||
|
|
b7da732b32 | ||
|
|
0c729c81f2 | ||
|
|
53850d88bb | ||
|
|
b1742f8919 | ||
|
|
c736697abf | ||
|
|
ca8a203b51 | ||
|
|
53bc5e6c78 | ||
|
|
130a51dbc6 | ||
|
|
c2fd5d10f6 | ||
|
|
30681e79db | ||
|
|
c15604920a | ||
|
|
4792297702 | ||
|
|
79ec03f3e5 | ||
|
|
7ebbfcbbdd | ||
|
|
3ea10cc7b5 | ||
|
|
4a887ca920 | ||
|
|
7c1b9e6b1a | ||
|
|
3f62b754e2 | ||
|
|
26a69806cf | ||
|
|
9953936347 | ||
|
|
41d6ac4d2a | ||
|
|
e8c48cc8cf | ||
|
|
1616e0ef98 | ||
|
|
b40cd0390c | ||
|
|
821fe9b476 | ||
|
|
37d8b5142f | ||
|
|
ab7316e0c5 | ||
|
|
f422a50448 | ||
|
|
ed40e306f5 | ||
|
|
cae9a1f462 | ||
|
|
11a46b8856 | ||
|
|
95673cf9a2 | ||
|
|
3ff1fd9192 | ||
|
|
47bcabd3e8 | ||
|
|
b9deefbe0a | ||
|
|
7c4d0e0f6e | ||
|
|
b38dc80666 | ||
|
|
e0411511a5 | ||
|
|
c08ab55e3d | ||
|
|
934c0340a7 | ||
|
|
c18b1d6732 | ||
|
|
8bfe3c6be5 | ||
|
|
4efa7d6115 | ||
|
|
c699821722 | ||
|
|
7fa4dc3512 | ||
|
|
a965b69658 | ||
|
|
3b151b1bde | ||
|
|
f9fd90ed60 | ||
|
|
41a4ada31b | ||
|
|
e524cd64db | ||
|
|
1653a84fbc | ||
|
|
08f9ac4674 | ||
|
|
2e0c6caf16 | ||
|
|
99d4397d88 | ||
|
|
47dc295f08 | ||
|
|
5a6f006e4d | ||
|
|
ceacebd3ff | ||
|
|
d069ed5c71 | ||
|
|
0e17d37ac3 | ||
|
|
2318cf79e9 | ||
|
|
b2786f5323 | ||
|
|
d00e8c09a3 | ||
|
|
8bd4419d1e | ||
|
|
99acb8dda6 | ||
|
|
31367d4e57 | ||
|
|
ccf5d70ab3 | ||
|
|
30fe0a56d2 | ||
|
|
7adb33da1d | ||
|
|
2e111b27f7 | ||
|
|
c7785f6b91 | ||
|
|
2e80c74b1b | ||
|
|
80ecdcdf69 | ||
|
|
7c412c67ba | ||
|
|
ee4575b213 | ||
|
|
d2ab7a2abb | ||
|
|
d7459f0368 | ||
|
|
6db77eec0d | ||
|
|
777b778409 | ||
|
|
97f9db4fb9 | ||
|
|
59ca9b59cb | ||
|
|
6834383903 | ||
|
|
4918636a75 | ||
|
|
428caf0cf5 | ||
|
|
df05122fc6 | ||
|
|
a27dc4fee4 | ||
|
|
a568674c69 | ||
|
|
f8f4c0b33e | ||
|
|
79d8e4a43d | ||
|
|
0ece1d1000 | ||
|
|
81b419c908 | ||
|
|
eec34d5f05 | ||
|
|
06e27d3e3d | ||
|
|
40b280032c | ||
|
|
bcb7fad5b3 | ||
|
|
0efcf74ce0 | ||
|
|
29a2159db1 | ||
|
|
f7c46e5cbc | ||
|
|
ccf479d336 | ||
|
|
1b5ea4afdc | ||
|
|
69e09909dc | ||
|
|
632cc8efb3 | ||
|
|
57096f1d43 | ||
|
|
27ea8f8fe5 | ||
|
|
3f00a1265f | ||
|
|
dbe6f211e6 | ||
|
|
16c620dea4 | ||
|
|
b36688d5b7 | ||
|
|
bfe9d7da56 | ||
|
|
822fe5ef9a | ||
|
|
255ffd480f | ||
|
|
4b775686a0 | ||
|
|
f0705a6d6f | ||
|
|
2faa3e16f3 | ||
|
|
aaff818427 | ||
|
|
6f285ad15b | ||
|
|
c88cf91b1f | ||
|
|
a3a6c128d7 | ||
|
|
657581e7a8 | ||
|
|
657c2f3ff0 | ||
|
|
970e0879d9 | ||
|
|
db50adab01 | ||
|
|
9e9a8428c3 | ||
|
|
1725087693 | ||
|
|
e655565390 | ||
|
|
c38e41c45a | ||
|
|
0658e4b2d6 | ||
|
|
54b4854fda | ||
|
|
1fae5bf71b | ||
|
|
533ce91971 | ||
|
|
ace076b980 | ||
|
|
97847a4dde | ||
|
|
f8c88ab2dc | ||
|
|
2f58583a1b | ||
|
|
4e0668d05e | ||
|
|
c4fdf5fe69 | ||
|
|
4f87830a1f | ||
|
|
daf6560612 | ||
|
|
03e2e3c45f | ||
|
|
3bb6c41212 | ||
|
|
38fc5ebb37 | ||
|
|
a82d691646 | ||
|
|
ca6773e404 | ||
|
|
8dbd96566a | ||
|
|
ef73e3bee8 | ||
|
|
75b4f1c466 | ||
|
|
d468c94a69 | ||
|
|
7c55012151 | ||
|
|
f8eea91a7b | ||
|
|
878b64e0ef | ||
|
|
7cf0ed5e3f | ||
|
|
b651a677d2 | ||
|
|
827fd55c21 | ||
|
|
dd56e95b46 | ||
|
|
3c6dd303a8 | ||
|
|
96bc9c36c6 | ||
|
|
366e88c2c1 | ||
|
|
7b66e72cb7 | ||
|
|
06d4e82bd2 | ||
|
|
0fb78380f8 | ||
|
|
b71f20d70f | ||
|
|
8f845425a2 | ||
|
|
c9882bef2d | ||
|
|
9a6bf18ec4 | ||
|
|
0235de0279 | ||
|
|
a73e506617 | ||
|
|
b11fe85402 | ||
|
|
922dc2b976 | ||
|
|
395afb1dd9 | ||
|
|
ceeddf2638 | ||
|
|
06b15c22b1 | ||
|
|
ed0abc6cac | ||
|
|
193cfa588d | ||
|
|
d9e30cb001 | ||
|
|
ea676e3184 | ||
|
|
7c2be06006 | ||
|
|
0c3c093eba | ||
|
|
2bf00f719d | ||
|
|
02083c307e | ||
|
|
35ef6a2db3 | ||
|
|
5227afabbe | ||
|
|
6ed7f70798 | ||
|
|
04f504ca7f | ||
|
|
016ec75b7c | ||
|
|
0256599547 | ||
|
|
8a646279fc |
20
.github/check-sarif/action.yml
vendored
Normal file
20
.github/check-sarif/action.yml
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
name: Check SARIF
|
||||||
|
description: Checks a SARIF file to see if certain queries were run and others were not run.
|
||||||
|
inputs:
|
||||||
|
sarif-file:
|
||||||
|
required: true
|
||||||
|
description: The SARIF file to check
|
||||||
|
|
||||||
|
queries-run:
|
||||||
|
required: true
|
||||||
|
description: |
|
||||||
|
Comma separated list of query ids that should be included in this SARIF file.
|
||||||
|
|
||||||
|
queries-not-run:
|
||||||
|
required: true
|
||||||
|
description: |
|
||||||
|
Comma separated list of query ids that should NOT be included in this SARIF file.
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: node12
|
||||||
|
main: index.js
|
||||||
43
.github/check-sarif/index.js
vendored
Normal file
43
.github/check-sarif/index.js
vendored
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
'use strict'
|
||||||
|
|
||||||
|
const core = require('@actions/core')
|
||||||
|
const fs = require('fs')
|
||||||
|
|
||||||
|
const sarif = JSON.parse(fs.readFileSync(core.getInput('sarif-file'), 'utf8'))
|
||||||
|
const rules = sarif.runs[0].tool.extensions.flatMap(ext => ext.rules || [])
|
||||||
|
const ruleIds = rules.map(rule => rule.id)
|
||||||
|
|
||||||
|
// Check that all the expected queries ran
|
||||||
|
const expectedQueriesRun = getQueryIdsInput('queries-run')
|
||||||
|
const queriesThatShouldHaveRunButDidNot = expectedQueriesRun.filter(queryId => !ruleIds.includes(queryId))
|
||||||
|
|
||||||
|
if (queriesThatShouldHaveRunButDidNot.length > 0) {
|
||||||
|
core.setFailed(`The following queries were expected to run but did not: ${queriesThatShouldHaveRunButDidNot.join(', ')}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check that all the unexpected queries did not run
|
||||||
|
const expectedQueriesNotRun = getQueryIdsInput('queries-not-run')
|
||||||
|
|
||||||
|
const queriesThatShouldNotHaveRunButDid = expectedQueriesNotRun.filter(queryId => ruleIds.includes(queryId))
|
||||||
|
|
||||||
|
if (queriesThatShouldNotHaveRunButDid.length > 0) {
|
||||||
|
core.setFailed(`The following queries were NOT expected to have run but did: ${queriesThatShouldNotHaveRunButDid.join(', ')}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
core.startGroup('All queries run')
|
||||||
|
rules.forEach(rule => {
|
||||||
|
core.info(`${rule.id}: ${(rule.properties && rule.properties.name) || rule.name}`)
|
||||||
|
})
|
||||||
|
core.endGroup()
|
||||||
|
|
||||||
|
core.startGroup('Full SARIF')
|
||||||
|
core.info(JSON.stringify(sarif, null, 2))
|
||||||
|
core.endGroup()
|
||||||
|
|
||||||
|
function getQueryIdsInput(name) {
|
||||||
|
return core.getInput(name)
|
||||||
|
.split(',')
|
||||||
|
.map(q => q.trim())
|
||||||
|
.filter(q => q.length > 0)
|
||||||
|
}
|
||||||
52
.github/query-filter-test/action.yml
vendored
Normal file
52
.github/query-filter-test/action.yml
vendored
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
name: Query Filter Test
|
||||||
|
description: Runs a test of query filters using the check sarif action
|
||||||
|
inputs:
|
||||||
|
sarif-file:
|
||||||
|
required: true
|
||||||
|
description: The SARIF file to check
|
||||||
|
|
||||||
|
queries-run:
|
||||||
|
required: true
|
||||||
|
description: |
|
||||||
|
Comma separated list of query ids that should be included in this SARIF file.
|
||||||
|
|
||||||
|
queries-not-run:
|
||||||
|
required: true
|
||||||
|
description: |
|
||||||
|
Comma separated list of query ids that should NOT be included in this SARIF file.
|
||||||
|
|
||||||
|
config-file:
|
||||||
|
required: true
|
||||||
|
description: |
|
||||||
|
The location of the codeql configuration file to use.
|
||||||
|
|
||||||
|
tools:
|
||||||
|
required: true
|
||||||
|
description: |
|
||||||
|
The url of codeql to use.
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: composite
|
||||||
|
steps:
|
||||||
|
- uses: ./../action/init
|
||||||
|
with:
|
||||||
|
languages: javascript
|
||||||
|
config-file: ${{ inputs.config-file }}
|
||||||
|
tools: ${{ inputs.tools }}
|
||||||
|
db-location: ${{ runner.temp }}/query-filter-test
|
||||||
|
- uses: ./../action/analyze
|
||||||
|
with:
|
||||||
|
output: ${{ runner.temp }}/results
|
||||||
|
upload-database: false
|
||||||
|
upload: false
|
||||||
|
env:
|
||||||
|
TEST_MODE: "true"
|
||||||
|
- name: Check SARIF
|
||||||
|
uses: ./../action/.github/check-sarif
|
||||||
|
with:
|
||||||
|
sarif-file: ${{ inputs.sarif-file }}
|
||||||
|
queries-run: ${{ inputs.queries-run}}
|
||||||
|
queries-not-run: ${{ inputs.queries-not-run}}
|
||||||
|
- name: Cleanup after test
|
||||||
|
shell: bash
|
||||||
|
run: rm -rf "$RUNNER_TEMP/results" "$RUNNER_TEMP//query-filter-test"
|
||||||
2
.github/update-release-branch.py
vendored
2
.github/update-release-branch.py
vendored
@@ -292,7 +292,7 @@ def main():
|
|||||||
conflicted_files = run_git('diff', '--name-only', '--diff-filter', 'U').splitlines()
|
conflicted_files = run_git('diff', '--name-only', '--diff-filter', 'U').splitlines()
|
||||||
if len(conflicted_files) > 0:
|
if len(conflicted_files) > 0:
|
||||||
run_git('add', '.')
|
run_git('add', '.')
|
||||||
run_git('commit', '--no-edit')
|
run_git('commit', '--no-edit')
|
||||||
|
|
||||||
# Migrate the package version number from a v2 version number to a v1 version number
|
# Migrate the package version number from a v2 version number to a v1 version number
|
||||||
print(f'Setting version number to {version}')
|
print(f'Setting version number to {version}')
|
||||||
|
|||||||
72
.github/workflows/__autobuild-action.yml
generated
vendored
Normal file
72
.github/workflows/__autobuild-action.yml
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
# Warning: This file is generated automatically, and should not be modified.
|
||||||
|
# Instead, please modify the template in the pr-checks directory and run:
|
||||||
|
# pip install ruamel.yaml && python3 sync.py
|
||||||
|
# to regenerate this file.
|
||||||
|
|
||||||
|
name: PR Check - autobuild-action
|
||||||
|
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:
|
||||||
|
autobuild-action:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- os: ubuntu-latest
|
||||||
|
version: latest
|
||||||
|
- os: macos-latest
|
||||||
|
version: latest
|
||||||
|
- os: windows-2019
|
||||||
|
version: latest
|
||||||
|
- os: windows-2022
|
||||||
|
version: latest
|
||||||
|
name: autobuild-action
|
||||||
|
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
|
||||||
|
tools: ${{ steps.prepare-test.outputs.tools-url }}
|
||||||
|
- uses: ./../action/autobuild
|
||||||
|
env:
|
||||||
|
# Explicitly disable the CLR tracer.
|
||||||
|
COR_ENABLE_PROFILING: ''
|
||||||
|
COR_PROFILER: ''
|
||||||
|
COR_PROFILER_PATH_64: ''
|
||||||
|
CORECLR_ENABLE_PROFILING: ''
|
||||||
|
CORECLR_PROFILER: ''
|
||||||
|
CORECLR_PROFILER_PATH_64: ''
|
||||||
|
- uses: ./../action/analyze
|
||||||
|
env:
|
||||||
|
TEST_MODE: true
|
||||||
|
- name: Check database
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
cd "$RUNNER_TEMP/codeql_databases"
|
||||||
|
if [[ ! -d csharp ]]; then
|
||||||
|
echo "Did not find a C# database"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
env:
|
||||||
|
INTERNAL_CODEQL_ACTION_DEBUG_LOC: true
|
||||||
20
.github/workflows/__ml-powered-queries.yml
generated
vendored
20
.github/workflows/__ml-powered-queries.yml
generated
vendored
@@ -82,10 +82,20 @@ jobs:
|
|||||||
retention-days: 7
|
retention-days: 7
|
||||||
|
|
||||||
- name: Check results
|
- name: Check results
|
||||||
|
# Running ML-powered queries on Windows requires CodeQL CLI 2.9.0+. We don't run these checks
|
||||||
|
# against Windows and `cached` while CodeQL CLI 2.9.0 makes its way into `cached` to avoid the
|
||||||
|
# test starting to fail when the cached CodeQL Bundle gets updated. Once the CodeQL Bundle
|
||||||
|
# containing CodeQL CLI 2.9.0 has been fully released, we can drop this line and start running
|
||||||
|
# these checks on Windows and `cached`.
|
||||||
|
if: matrix.os != 'windows-latest' || matrix.version != 'cached'
|
||||||
env:
|
env:
|
||||||
IS_WINDOWS: ${{ matrix.os == 'windows-latest' }}
|
# Running on Windows requires CodeQL CLI 2.9.0+, which has so far only made it to 'latest'.
|
||||||
|
SHOULD_RUN_ML_POWERED_QUERIES: ${{ matrix.os != 'windows-latest' || matrix.version
|
||||||
|
== 'latest' || matrix.version == 'nightly-latest' }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
|
echo "Expecting ML-powered queries to be run: ${SHOULD_RUN_ML_POWERED_QUERIES}"
|
||||||
|
|
||||||
cd "$RUNNER_TEMP/results"
|
cd "$RUNNER_TEMP/results"
|
||||||
# We should run at least the ML-powered queries in `expected_rules`.
|
# We should run at least the ML-powered queries in `expected_rules`.
|
||||||
expected_rules="js/ml-powered/nosql-injection js/ml-powered/path-injection js/ml-powered/sql-injection js/ml-powered/xss"
|
expected_rules="js/ml-powered/nosql-injection js/ml-powered/path-injection js/ml-powered/sql-injection js/ml-powered/xss"
|
||||||
@@ -94,10 +104,10 @@ jobs:
|
|||||||
found_rule=$(jq --arg rule "${rule}" '[.runs[0].tool.extensions[].rules | select(. != null) |
|
found_rule=$(jq --arg rule "${rule}" '[.runs[0].tool.extensions[].rules | select(. != null) |
|
||||||
flatten | .[].id] | any(. == $rule)' javascript.sarif)
|
flatten | .[].id] | any(. == $rule)' javascript.sarif)
|
||||||
echo "Did find rule '${rule}': ${found_rule}"
|
echo "Did find rule '${rule}': ${found_rule}"
|
||||||
if [[ "${found_rule}" != "true" && "${IS_WINDOWS}" != "true" ]]; then
|
if [[ "${found_rule}" != "true" && "${SHOULD_RUN_ML_POWERED_QUERIES}" == "true" ]]; then
|
||||||
echo "Expected SARIF output to contain rule '${rule}', but found no such rule."
|
echo "Expected SARIF output to contain rule '${rule}', but found no such rule."
|
||||||
exit 1
|
exit 1
|
||||||
elif [[ "${found_rule}" == "true" && "${IS_WINDOWS}" == "true" ]]; then
|
elif [[ "${found_rule}" == "true" && "${SHOULD_RUN_ML_POWERED_QUERIES}" != "true" ]]; then
|
||||||
echo "Found rule '${rule}' in the SARIF output which shouldn't have been part of the analysis."
|
echo "Found rule '${rule}' in the SARIF output which shouldn't have been part of the analysis."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -108,10 +118,10 @@ jobs:
|
|||||||
select(.properties.score != null and (.rule.id | startswith("js/ml-powered/")))] | length' \
|
select(.properties.score != null and (.rule.id | startswith("js/ml-powered/")))] | length' \
|
||||||
javascript.sarif)
|
javascript.sarif)
|
||||||
echo "Found ${num_alerts} alerts from ML-powered queries.";
|
echo "Found ${num_alerts} alerts from ML-powered queries.";
|
||||||
if [[ "${num_alerts}" -eq 0 && "${IS_WINDOWS}" != "true" ]]; then
|
if [[ "${num_alerts}" -eq 0 && "${SHOULD_RUN_ML_POWERED_QUERIES}" == "true" ]]; then
|
||||||
echo "Expected to find at least one alert from an ML-powered query but found ${num_alerts}."
|
echo "Expected to find at least one alert from an ML-powered query but found ${num_alerts}."
|
||||||
exit 1
|
exit 1
|
||||||
elif [[ "${num_alerts}" -ne 0 && "${IS_WINDOWS}" == "true" ]]; then
|
elif [[ "${num_alerts}" -ne 0 && "${SHOULD_RUN_ML_POWERED_QUERIES}" != "true" ]]; then
|
||||||
echo "Expected not to find any alerts from an ML-powered query but found ${num_alerts}."
|
echo "Expected not to find any alerts from an ML-powered query but found ${num_alerts}."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
30
.github/workflows/__packaging-config-inputs-js.yml
generated
vendored
30
.github/workflows/__packaging-config-inputs-js.yml
generated
vendored
@@ -26,9 +26,27 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
version: nightly-20210831
|
version: latest
|
||||||
- os: macos-latest
|
- os: macos-latest
|
||||||
version: nightly-20210831
|
version: latest
|
||||||
|
- os: windows-2019
|
||||||
|
version: latest
|
||||||
|
- os: windows-2022
|
||||||
|
version: latest
|
||||||
|
- os: ubuntu-latest
|
||||||
|
version: cached
|
||||||
|
- os: macos-latest
|
||||||
|
version: cached
|
||||||
|
- os: windows-2019
|
||||||
|
version: cached
|
||||||
|
- os: ubuntu-latest
|
||||||
|
version: nightly-latest
|
||||||
|
- os: macos-latest
|
||||||
|
version: nightly-latest
|
||||||
|
- os: windows-2019
|
||||||
|
version: nightly-latest
|
||||||
|
- os: windows-2022
|
||||||
|
version: nightly-latest
|
||||||
name: 'Packaging: Config and input'
|
name: 'Packaging: Config and input'
|
||||||
timeout-minutes: 45
|
timeout-minutes: 45
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
@@ -43,7 +61,7 @@ jobs:
|
|||||||
- uses: ./../action/init
|
- uses: ./../action/init
|
||||||
with:
|
with:
|
||||||
config-file: .github/codeql/codeql-config-packaging3.yml
|
config-file: .github/codeql/codeql-config-packaging3.yml
|
||||||
packs: +dsp-testing/codeql-pack1@0.1.0
|
packs: +dsp-testing/codeql-pack1@1.0.0
|
||||||
languages: javascript
|
languages: javascript
|
||||||
tools: ${{ steps.prepare-test.outputs.tools-url }}
|
tools: ${{ steps.prepare-test.outputs.tools-url }}
|
||||||
- name: Build code
|
- name: Build code
|
||||||
@@ -58,11 +76,11 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
cd "$RUNNER_TEMP/results"
|
cd "$RUNNER_TEMP/results"
|
||||||
# We should have 3 hits from these rules
|
# We should have 4 hits from these rules
|
||||||
EXPECTED_RULES="javascript/example/empty-or-one-block javascript/example/empty-or-one-block javascript/example/two-block"
|
EXPECTED_RULES="javascript/example/empty-or-one-block javascript/example/empty-or-one-block javascript/example/other-query-block javascript/example/two-block"
|
||||||
|
|
||||||
# use tr to replace newlines with spaces and xargs to trim leading and trailing whitespace
|
# use tr to replace newlines with spaces and xargs to trim leading and trailing whitespace
|
||||||
RULES="$(cat javascript.sarif | jq -r '.runs[0].results[].ruleId' | sort | tr "\n" " " | xargs)"
|
RULES="$(cat javascript.sarif | jq -r '.runs[0].results[].ruleId' | sort | tr "\n\r" " " | xargs)"
|
||||||
echo "Found matching rules '$RULES'"
|
echo "Found matching rules '$RULES'"
|
||||||
if [ "$RULES" != "$EXPECTED_RULES" ]; then
|
if [ "$RULES" != "$EXPECTED_RULES" ]; then
|
||||||
echo "Did not match expected rules '$EXPECTED_RULES'."
|
echo "Did not match expected rules '$EXPECTED_RULES'."
|
||||||
|
|||||||
28
.github/workflows/__packaging-config-js.yml
generated
vendored
28
.github/workflows/__packaging-config-js.yml
generated
vendored
@@ -26,9 +26,27 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
version: nightly-20210831
|
version: latest
|
||||||
- os: macos-latest
|
- os: macos-latest
|
||||||
version: nightly-20210831
|
version: latest
|
||||||
|
- os: windows-2019
|
||||||
|
version: latest
|
||||||
|
- os: windows-2022
|
||||||
|
version: latest
|
||||||
|
- os: ubuntu-latest
|
||||||
|
version: cached
|
||||||
|
- os: macos-latest
|
||||||
|
version: cached
|
||||||
|
- os: windows-2019
|
||||||
|
version: cached
|
||||||
|
- os: ubuntu-latest
|
||||||
|
version: nightly-latest
|
||||||
|
- os: macos-latest
|
||||||
|
version: nightly-latest
|
||||||
|
- os: windows-2019
|
||||||
|
version: nightly-latest
|
||||||
|
- os: windows-2022
|
||||||
|
version: nightly-latest
|
||||||
name: 'Packaging: Config file'
|
name: 'Packaging: Config file'
|
||||||
timeout-minutes: 45
|
timeout-minutes: 45
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
@@ -57,11 +75,11 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
cd "$RUNNER_TEMP/results"
|
cd "$RUNNER_TEMP/results"
|
||||||
# We should have 3 hits from these rules
|
# We should have 4 hits from these rules
|
||||||
EXPECTED_RULES="javascript/example/empty-or-one-block javascript/example/empty-or-one-block javascript/example/two-block"
|
EXPECTED_RULES="javascript/example/empty-or-one-block javascript/example/empty-or-one-block javascript/example/other-query-block javascript/example/two-block"
|
||||||
|
|
||||||
# use tr to replace newlines with spaces and xargs to trim leading and trailing whitespace
|
# use tr to replace newlines with spaces and xargs to trim leading and trailing whitespace
|
||||||
RULES="$(cat javascript.sarif | jq -r '.runs[0].results[].ruleId' | sort | tr "\n" " " | xargs)"
|
RULES="$(cat javascript.sarif | jq -r '.runs[0].results[].ruleId' | sort | tr "\n\r" " " | xargs)"
|
||||||
echo "Found matching rules '$RULES'"
|
echo "Found matching rules '$RULES'"
|
||||||
if [ "$RULES" != "$EXPECTED_RULES" ]; then
|
if [ "$RULES" != "$EXPECTED_RULES" ]; then
|
||||||
echo "Did not match expected rules '$EXPECTED_RULES'."
|
echo "Did not match expected rules '$EXPECTED_RULES'."
|
||||||
|
|||||||
30
.github/workflows/__packaging-inputs-js.yml
generated
vendored
30
.github/workflows/__packaging-inputs-js.yml
generated
vendored
@@ -26,9 +26,27 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
version: nightly-20210831
|
version: latest
|
||||||
- os: macos-latest
|
- os: macos-latest
|
||||||
version: nightly-20210831
|
version: latest
|
||||||
|
- os: windows-2019
|
||||||
|
version: latest
|
||||||
|
- os: windows-2022
|
||||||
|
version: latest
|
||||||
|
- os: ubuntu-latest
|
||||||
|
version: cached
|
||||||
|
- os: macos-latest
|
||||||
|
version: cached
|
||||||
|
- os: windows-2019
|
||||||
|
version: cached
|
||||||
|
- os: ubuntu-latest
|
||||||
|
version: nightly-latest
|
||||||
|
- os: macos-latest
|
||||||
|
version: nightly-latest
|
||||||
|
- os: windows-2019
|
||||||
|
version: nightly-latest
|
||||||
|
- os: windows-2022
|
||||||
|
version: nightly-latest
|
||||||
name: 'Packaging: Action input'
|
name: 'Packaging: Action input'
|
||||||
timeout-minutes: 45
|
timeout-minutes: 45
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
@@ -44,7 +62,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
config-file: .github/codeql/codeql-config-packaging2.yml
|
config-file: .github/codeql/codeql-config-packaging2.yml
|
||||||
languages: javascript
|
languages: javascript
|
||||||
packs: dsp-testing/codeql-pack1@0.1.0, dsp-testing/codeql-pack2
|
packs: dsp-testing/codeql-pack1@1.0.0, dsp-testing/codeql-pack2, dsp-testing/codeql-pack3:other-query.ql
|
||||||
tools: ${{ steps.prepare-test.outputs.tools-url }}
|
tools: ${{ steps.prepare-test.outputs.tools-url }}
|
||||||
- name: Build code
|
- name: Build code
|
||||||
shell: bash
|
shell: bash
|
||||||
@@ -58,11 +76,11 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
cd "$RUNNER_TEMP/results"
|
cd "$RUNNER_TEMP/results"
|
||||||
# We should have 3 hits from these rules
|
# We should have 4 hits from these rules
|
||||||
EXPECTED_RULES="javascript/example/empty-or-one-block javascript/example/empty-or-one-block javascript/example/two-block"
|
EXPECTED_RULES="javascript/example/empty-or-one-block javascript/example/empty-or-one-block javascript/example/other-query-block javascript/example/two-block"
|
||||||
|
|
||||||
# use tr to replace newlines with spaces and xargs to trim leading and trailing whitespace
|
# use tr to replace newlines with spaces and xargs to trim leading and trailing whitespace
|
||||||
RULES="$(cat javascript.sarif | jq -r '.runs[0].results[].ruleId' | sort | tr "\n" " " | xargs)"
|
RULES="$(cat javascript.sarif | jq -r '.runs[0].results[].ruleId' | sort | tr "\n\r" " " | xargs)"
|
||||||
echo "Found matching rules '$RULES'"
|
echo "Found matching rules '$RULES'"
|
||||||
if [ "$RULES" != "$EXPECTED_RULES" ]; then
|
if [ "$RULES" != "$EXPECTED_RULES" ]; then
|
||||||
echo "Did not match expected rules '$EXPECTED_RULES'."
|
echo "Did not match expected rules '$EXPECTED_RULES'."
|
||||||
|
|||||||
20
.github/workflows/__split-workflow.yml
generated
vendored
20
.github/workflows/__split-workflow.yml
generated
vendored
@@ -26,9 +26,17 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
version: nightly-20210831
|
version: latest
|
||||||
- os: macos-latest
|
- os: macos-latest
|
||||||
version: nightly-20210831
|
version: latest
|
||||||
|
- os: ubuntu-latest
|
||||||
|
version: cached
|
||||||
|
- os: macos-latest
|
||||||
|
version: cached
|
||||||
|
- os: ubuntu-latest
|
||||||
|
version: nightly-latest
|
||||||
|
- os: macos-latest
|
||||||
|
version: nightly-latest
|
||||||
name: Split workflow
|
name: Split workflow
|
||||||
timeout-minutes: 45
|
timeout-minutes: 45
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
@@ -43,7 +51,7 @@ jobs:
|
|||||||
- uses: ./../action/init
|
- uses: ./../action/init
|
||||||
with:
|
with:
|
||||||
config-file: .github/codeql/codeql-config-packaging3.yml
|
config-file: .github/codeql/codeql-config-packaging3.yml
|
||||||
packs: +dsp-testing/codeql-pack1@0.1.0
|
packs: +dsp-testing/codeql-pack1@1.0.0
|
||||||
languages: javascript
|
languages: javascript
|
||||||
tools: ${{ steps.prepare-test.outputs.tools-url }}
|
tools: ${{ steps.prepare-test.outputs.tools-url }}
|
||||||
- name: Build code
|
- name: Build code
|
||||||
@@ -72,11 +80,11 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
cd "$RUNNER_TEMP/results"
|
cd "$RUNNER_TEMP/results"
|
||||||
# We should have 3 hits from these rules
|
# We should have 4 hits from these rules
|
||||||
EXPECTED_RULES="javascript/example/empty-or-one-block javascript/example/empty-or-one-block javascript/example/two-block"
|
EXPECTED_RULES="javascript/example/empty-or-one-block javascript/example/empty-or-one-block javascript/example/other-query-block javascript/example/two-block"
|
||||||
|
|
||||||
# use tr to replace newlines with spaces and xargs to trim leading and trailing whitespace
|
# use tr to replace newlines with spaces and xargs to trim leading and trailing whitespace
|
||||||
RULES="$(cat javascript.sarif | jq -r '.runs[0].results[].ruleId' | sort | tr "\n" " " | xargs)"
|
RULES="$(cat javascript.sarif | jq -r '.runs[0].results[].ruleId' | sort | tr "\n\r" " " | xargs)"
|
||||||
echo "Found matching rules '$RULES'"
|
echo "Found matching rules '$RULES'"
|
||||||
if [ "$RULES" != "$EXPECTED_RULES" ]; then
|
if [ "$RULES" != "$EXPECTED_RULES" ]; then
|
||||||
echo "Did not match expected rules '$EXPECTED_RULES'."
|
echo "Did not match expected rules '$EXPECTED_RULES'."
|
||||||
|
|||||||
2
.github/workflows/check-for-conflicts.yml
vendored
2
.github/workflows/check-for-conflicts.yml
vendored
@@ -4,7 +4,7 @@ name: Check for conflicts
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [main, v1, v2]
|
branches: [main, releases/v1, releases/v2]
|
||||||
# Run checks on reopened draft PRs to support triggering PR checks on draft PRs that were opened
|
# Run checks on reopened draft PRs to support triggering PR checks on draft PRs that were opened
|
||||||
# by other workflows.
|
# by other workflows.
|
||||||
types: [opened, synchronize, reopened, ready_for_review]
|
types: [opened, synchronize, reopened, ready_for_review]
|
||||||
|
|||||||
49
.github/workflows/expected-queries-runs.yml
vendored
Normal file
49
.github/workflows/expected-queries-runs.yml
vendored
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
name: Expected queries runs
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- releases/v1
|
||||||
|
- releases/v2
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- opened
|
||||||
|
- synchronize
|
||||||
|
- reopened
|
||||||
|
- ready_for_review
|
||||||
|
workflow_dispatch: {}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
expected-queries:
|
||||||
|
name: Expected Queries Tests
|
||||||
|
timeout-minutes: 45
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Prepare test
|
||||||
|
id: prepare-test
|
||||||
|
uses: ./.github/prepare-test
|
||||||
|
with:
|
||||||
|
version: latest
|
||||||
|
- uses: ./../action/init
|
||||||
|
with:
|
||||||
|
languages: javascript
|
||||||
|
tools: ${{ steps.prepare-test.outputs.tools-url }}
|
||||||
|
- uses: ./../action/analyze
|
||||||
|
with:
|
||||||
|
output: ${{ runner.temp }}/results
|
||||||
|
upload-database: false
|
||||||
|
upload: false
|
||||||
|
env:
|
||||||
|
TEST_MODE: true
|
||||||
|
|
||||||
|
- name: Check Sarif
|
||||||
|
uses: ./../action/.github/check-sarif
|
||||||
|
with:
|
||||||
|
sarif-file: ${{ runner.temp }}/results/javascript.sarif
|
||||||
|
queries-run: js/incomplete-hostname-regexp,js/path-injection
|
||||||
|
queries-not-run: foo,bar
|
||||||
15
.github/workflows/pr-checks.yml
vendored
15
.github/workflows/pr-checks.yml
vendored
@@ -90,14 +90,18 @@ jobs:
|
|||||||
needs: [check-js, check-node-modules]
|
needs: [check-js, check-node-modules]
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, macos-latest]
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
timeout-minutes: 45
|
timeout-minutes: 45
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: npm run-script test
|
- name: npm test
|
||||||
run: npm run-script test
|
run: |
|
||||||
|
# Run any commands referenced in package.json using Bash, otherwise
|
||||||
|
# we won't be able to find them on Windows.
|
||||||
|
npm config set script-shell bash
|
||||||
|
npm test
|
||||||
|
|
||||||
runner-analyze-javascript-ubuntu:
|
runner-analyze-javascript-ubuntu:
|
||||||
name: Runner ubuntu JS analyze
|
name: Runner ubuntu JS analyze
|
||||||
@@ -410,7 +414,10 @@ jobs:
|
|||||||
- name: Build code
|
- name: Build code
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
../action/runner/dist/codeql-runner-macos autobuild
|
. codeql-runner/codeql-env.sh
|
||||||
|
CODEQL_RUNNER="$(cat codeql-runner/codeql-env.json | jq -r '.CODEQL_RUNNER')"
|
||||||
|
echo "$CODEQL_RUNNER"
|
||||||
|
$CODEQL_RUNNER ../action/runner/dist/codeql-runner-macos autobuild
|
||||||
|
|
||||||
- name: Run analyze
|
- name: Run analyze
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
9
.github/workflows/python-deps.yml
vendored
9
.github/workflows/python-deps.yml
vendored
@@ -18,6 +18,11 @@ jobs:
|
|||||||
os: [ubuntu-latest, macos-latest]
|
os: [ubuntu-latest, macos-latest]
|
||||||
python_deps_type: [pipenv, poetry, requirements, setup_py]
|
python_deps_type: [pipenv, poetry, requirements, setup_py]
|
||||||
python_version: [2, 3]
|
python_version: [2, 3]
|
||||||
|
exclude:
|
||||||
|
# Python2 and poetry are not supported. See https://github.com/actions/setup-python/issues/374
|
||||||
|
- python_version: 2
|
||||||
|
python_deps_type: poetry
|
||||||
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
PYTHON_DEPS_TYPE: ${{ matrix.python_deps_type }}
|
PYTHON_DEPS_TYPE: ${{ matrix.python_deps_type }}
|
||||||
@@ -115,6 +120,10 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
python_deps_type: [pipenv, poetry, requirements, setup_py]
|
python_deps_type: [pipenv, poetry, requirements, setup_py]
|
||||||
python_version: [2, 3]
|
python_version: [2, 3]
|
||||||
|
exclude:
|
||||||
|
# Python2 and poetry are not supported. See https://github.com/actions/setup-python/issues/374
|
||||||
|
- python_version: 2
|
||||||
|
python_deps_type: poetry
|
||||||
|
|
||||||
env:
|
env:
|
||||||
PYTHON_DEPS_TYPE: ${{ matrix.python_deps_type }}
|
PYTHON_DEPS_TYPE: ${{ matrix.python_deps_type }}
|
||||||
|
|||||||
4
.github/workflows/script/check-js.sh
vendored
4
.github/workflows/script/check-js.sh
vendored
@@ -14,8 +14,8 @@ npm run-script build
|
|||||||
# Check that repo is still clean
|
# Check that repo is still clean
|
||||||
if [ ! -z "$(git status --porcelain)" ]; then
|
if [ ! -z "$(git status --porcelain)" ]; then
|
||||||
# If we get a fail here then the PR needs attention
|
# If we get a fail here then the PR needs attention
|
||||||
>&2 echo "Failed: JavaScript files are not up to date. Run 'npm run-script build' to update"
|
>&2 echo "Failed: JavaScript files are not up to date. Run 'rm -rf lib && npm run-script build' to update"
|
||||||
git status
|
git status
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "Success: JavaScript files are up to date"
|
echo "Success: JavaScript files are up to date"
|
||||||
|
|||||||
37
.github/workflows/script/update-required-checks.sh
vendored
Executable file
37
.github/workflows/script/update-required-checks.sh
vendored
Executable file
@@ -0,0 +1,37 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Update the required checks based on the current branch.
|
||||||
|
# Typically, this will be main.
|
||||||
|
|
||||||
|
if ! gh auth status 2>/dev/null; then
|
||||||
|
gh auth status
|
||||||
|
echo "Failed: Not authorized. This script requires admin access to github/codeql-action through the gh CLI."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$#" -eq 1 ]; then
|
||||||
|
# If we were passed an argument, use that as the SHA
|
||||||
|
GITHUB_SHA="$0"
|
||||||
|
elif [ "$#" -gt 1 ]; then
|
||||||
|
echo "Usage: $0 [SHA]"
|
||||||
|
echo "Update the required checks based on the SHA, or main."
|
||||||
|
exit 1
|
||||||
|
elif [ -z "$GITHUB_SHA" ]; then
|
||||||
|
# If we don't have a SHA, use main
|
||||||
|
GITHUB_SHA="$(git rev-parse main)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Getting checks for $GITHUB_SHA"
|
||||||
|
|
||||||
|
# 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')"
|
||||||
|
|
||||||
|
echo "$CHECKS" | jq
|
||||||
|
|
||||||
|
echo "{\"contexts\": ${CHECKS}}" > checks.json
|
||||||
|
|
||||||
|
for BRANCH in main releases/v2 releases/v1; do
|
||||||
|
echo "Updating $BRANCH"
|
||||||
|
gh api --silent -X "PATCH" "repos/github/codeql-action/branches/$BRANCH/protection/required_status_checks" --input checks.json
|
||||||
|
done
|
||||||
|
|
||||||
|
rm checks.json
|
||||||
36
CHANGELOG.md
36
CHANGELOG.md
@@ -1,5 +1,41 @@
|
|||||||
# CodeQL Action Changelog
|
# CodeQL Action Changelog
|
||||||
|
|
||||||
|
## [UNRELEASED]
|
||||||
|
|
||||||
|
- Update default CodeQL bundle version to 2.10.1. [#1143](https://github.com/github/codeql-action/pull/1143)
|
||||||
|
|
||||||
|
## 2.1.16 - 13 Jul 2022
|
||||||
|
|
||||||
|
- You can now quickly debug a job that uses the CodeQL Action by re-running the job from the GitHub UI and selecting the "Enable debug logging" option. [#1132](https://github.com/github/codeql-action/pull/1132)
|
||||||
|
- You can now see diagnostic messages produced by the analysis in the logs of the `analyze` Action by enabling debug mode. To enable debug mode, pass `debug: true` to the `init` Action, or [enable step debug logging](https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/enabling-debug-logging#enabling-step-debug-logging). This feature is available for CodeQL CLI version 2.10.0 and later. [#1133](https://github.com/github/codeql-action/pull/1133)
|
||||||
|
|
||||||
|
## 2.1.15 - 28 Jun 2022
|
||||||
|
|
||||||
|
- CodeQL query packs listed in the `packs` configuration field will be skipped if their target language is not being analyzed in the current Actions job. Previously, this would throw an error. [#1116](https://github.com/github/codeql-action/pull/1116)
|
||||||
|
- The combination of python2 and poetry is no longer supported. See https://github.com/actions/setup-python/issues/374 for more details. [#1124](https://github.com/github/codeql-action/pull/1124)
|
||||||
|
- Update default CodeQL bundle version to 2.10.0. [#1123](https://github.com/github/codeql-action/pull/1123)
|
||||||
|
|
||||||
|
## 2.1.14 - 22 Jun 2022
|
||||||
|
|
||||||
|
No user facing changes.
|
||||||
|
|
||||||
|
## 2.1.13 - 21 Jun 2022
|
||||||
|
|
||||||
|
- Update default CodeQL bundle version to 2.9.4. [#1100](https://github.com/github/codeql-action/pull/1100)
|
||||||
|
|
||||||
|
## 2.1.12 - 01 Jun 2022
|
||||||
|
|
||||||
|
- Update default CodeQL bundle version to 2.9.3. [#1084](https://github.com/github/codeql-action/pull/1084)
|
||||||
|
|
||||||
|
## 2.1.11 - 17 May 2022
|
||||||
|
|
||||||
|
- Update default CodeQL bundle version to 2.9.2. [#1074](https://github.com/github/codeql-action/pull/1074)
|
||||||
|
|
||||||
|
## 2.1.10 - 10 May 2022
|
||||||
|
|
||||||
|
- Update default CodeQL bundle version to 2.9.1. [#1056](https://github.com/github/codeql-action/pull/1056)
|
||||||
|
- When `wait-for-processing` is enabled, the workflow will now fail if there were any errors that occurred during processing of the analysis results.
|
||||||
|
|
||||||
## 2.1.9 - 27 Apr 2022
|
## 2.1.9 - 27 Apr 2022
|
||||||
|
|
||||||
- Add `working-directory` input to the `autobuild` action. [#1024](https://github.com/github/codeql-action/pull/1024)
|
- Add `working-directory` input to the `autobuild` action. [#1024](https://github.com/github/codeql-action/pull/1024)
|
||||||
|
|||||||
@@ -80,22 +80,11 @@ Here are a few things you can do that will increase the likelihood of your pull
|
|||||||
|
|
||||||
## Keeping the PR checks up to date (admin access required)
|
## Keeping the PR checks up to date (admin access required)
|
||||||
|
|
||||||
Since the `codeql-action` runs most of its testing through individual Actions workflows, there are over two hundred jobs that need to pass in order for a PR to turn green. Managing these PR checks manually is time consuming and complex. Here is a semi-automated approach.
|
Since the `codeql-action` runs most of its testing through individual Actions workflows, there are over two hundred jobs that need to pass in order for a PR to turn green. You can regenerate the checks automatically by running the [update-required-checks.sh](.github/workflows/script/update-required-checks.sh) script:
|
||||||
|
|
||||||
To regenerate the PR jobs for the action:
|
1. By default, this script retrieves the checks from the latest SHA on `main`, so make sure that your `main` branch is up to date.
|
||||||
|
2. Run the script. If there's a reason to, you can pass in a different SHA as a CLI argument.
|
||||||
1. From a terminal, run the following commands (replace `SHA` with the sha of the commit whose checks you want to use, typically this should be the latest from `main`):
|
3. After running, go to the [branch protection rules settings page](https://github.com/github/codeql-action/settings/branches) and validate that the rules for `main`, `v1`, and `v2` have been updated.
|
||||||
|
|
||||||
```sh
|
|
||||||
SHA= ####
|
|
||||||
CHECKS="$(gh api repos/github/codeql-action/commits/${SHA}/check-runs --paginate | jq --slurp --compact-output --raw-output '[.[].check_runs | .[].name | select(contains("https://") or . == "CodeQL" or . == "LGTM.com" or . == "Update dependencies" or . == "Update Supported Enterprise Server Versions" | not)]')"
|
|
||||||
echo "{\"contexts\": ${CHECKS}}" > checks.json
|
|
||||||
gh api -X "PATCH" repos/github/codeql-action/branches/main/protection/required_status_checks --input checks.json
|
|
||||||
gh api -X "PATCH" repos/github/codeql-action/branches/releases/v2/protection/required_status_checks --input checks.json
|
|
||||||
gh api -X "PATCH" repos/github/codeql-action/branches/releases/v1/protection/required_status_checks --input checks.json
|
|
||||||
````
|
|
||||||
|
|
||||||
2. Go to the [branch protection rules settings page](https://github.com/github/codeql-action/settings/branches) and validate that the rules have been updated.
|
|
||||||
|
|
||||||
## Resources
|
## Resources
|
||||||
|
|
||||||
|
|||||||
@@ -139,10 +139,3 @@ By default, this will override any queries specified in a config file. If you wi
|
|||||||
|
|
||||||
Read about [troubleshooting code scanning](https://help.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/troubleshooting-code-scanning).
|
Read about [troubleshooting code scanning](https://help.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/troubleshooting-code-scanning).
|
||||||
|
|
||||||
### Note on "missing analysis" message
|
|
||||||
|
|
||||||
The very first time code scanning is run and if it is on a pull request, you will probably get a message mentioning a "missing analysis". This is expected.
|
|
||||||
|
|
||||||
After code scanning has analyzed the code in a pull request, it needs to compare the analysis of the topic branch (the merge commit of the branch you used to create the pull request) with the analysis of the base branch (the branch into which you want to merge the pull request). This allows code scanning to compute which alerts are newly introduced by the pull request, which alerts were already present in the base branch, and whether any existing alerts are fixed by the changes in the pull request. Initially, if you use a pull request to add code scanning to a repository, the base branch has not yet been analyzed, so it's not possible to compute these details. In this case, when you click through from the results check on the pull request you will see the "Missing analysis for base commit SHA-HASH" message.
|
|
||||||
|
|
||||||
For more information and other causes of this message, see [Reasons for the "Analysis not found" message](https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/setting-up-code-scanning-for-a-repository#reasons-for-the-analysis-not-found-message)
|
|
||||||
|
|||||||
@@ -56,7 +56,10 @@ inputs:
|
|||||||
This input also sets the number of threads that can later be used by the "analyze" action.
|
This input also sets the number of threads that can later be used by the "analyze" action.
|
||||||
required: false
|
required: false
|
||||||
debug:
|
debug:
|
||||||
description: Enable debugging mode. This will result in more output being produced which may be useful when debugging certain issues.
|
description: >-
|
||||||
|
Enable debugging mode.
|
||||||
|
This will result in more output being produced which may be useful when debugging certain issues.
|
||||||
|
Debugging mode is enabled automatically when step debug logging is turned on.
|
||||||
required: false
|
required: false
|
||||||
default: 'false'
|
default: 'false'
|
||||||
debug-artifact-name:
|
debug-artifact-name:
|
||||||
|
|||||||
12
lib/actions-util.js
generated
12
lib/actions-util.js
generated
@@ -19,7 +19,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.sanitizeArifactName = exports.isAnalyzingDefaultBranch = exports.getRelativeScriptPath = exports.isRunningLocalAction = exports.sendStatusReport = exports.createStatusReportBase = exports.getActionsStatus = exports.getRef = exports.computeAutomationID = exports.getAutomationID = exports.getAnalysisKey = exports.getWorkflowRunID = exports.getWorkflow = exports.formatWorkflowCause = exports.formatWorkflowErrors = exports.validateWorkflow = exports.getWorkflowErrors = exports.WorkflowErrors = exports.patternIsSuperset = exports.determineMergeBaseCommitOid = exports.getCommitOid = exports.getToolCacheDirectory = exports.getTemporaryDirectory = exports.getOptionalInput = exports.getRequiredInput = void 0;
|
exports.sanitizeArifactName = exports.isAnalyzingDefaultBranch = exports.getRelativeScriptPath = exports.isRunningLocalAction = exports.sendStatusReport = exports.createStatusReportBase = exports.getActionsStatus = exports.getRef = exports.computeAutomationID = exports.getAutomationID = exports.getAnalysisKey = exports.getWorkflowRunID = exports.getWorkflow = exports.formatWorkflowCause = exports.formatWorkflowErrors = exports.validateWorkflow = exports.getWorkflowErrors = exports.WorkflowErrors = exports.patternIsSuperset = exports.determineMergeBaseCommitOid = exports.getCommitOid = exports.getTemporaryDirectory = exports.getOptionalInput = exports.getRequiredInput = 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"));
|
||||||
@@ -66,13 +66,6 @@ function getTemporaryDirectory() {
|
|||||||
: (0, util_1.getRequiredEnvParam)("RUNNER_TEMP");
|
: (0, util_1.getRequiredEnvParam)("RUNNER_TEMP");
|
||||||
}
|
}
|
||||||
exports.getTemporaryDirectory = getTemporaryDirectory;
|
exports.getTemporaryDirectory = getTemporaryDirectory;
|
||||||
function getToolCacheDirectory() {
|
|
||||||
const value = process.env["CODEQL_ACTION_TOOL_CACHE"];
|
|
||||||
return value !== undefined && value !== ""
|
|
||||||
? value
|
|
||||||
: (0, util_1.getRequiredEnvParam)("RUNNER_TOOL_CACHE");
|
|
||||||
}
|
|
||||||
exports.getToolCacheDirectory = getToolCacheDirectory;
|
|
||||||
/**
|
/**
|
||||||
* Gets the SHA of the commit that is currently checked out.
|
* Gets the SHA of the commit that is currently checked out.
|
||||||
*/
|
*/
|
||||||
@@ -584,8 +577,7 @@ async function sendStatusReport(statusReport) {
|
|||||||
const statusReportJSON = JSON.stringify(statusReport);
|
const statusReportJSON = JSON.stringify(statusReport);
|
||||||
core.debug(`Sending status report: ${statusReportJSON}`);
|
core.debug(`Sending status report: ${statusReportJSON}`);
|
||||||
// If in test mode we don't want to upload the results
|
// If in test mode we don't want to upload the results
|
||||||
const testMode = process.env["TEST_MODE"] === "true" || false;
|
if ((0, util_1.isInTestMode)()) {
|
||||||
if (testMode) {
|
|
||||||
core.debug("In test mode. Status reports are not uploaded.");
|
core.debug("In test mode. Status reports are not uploaded.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
7
lib/analysis-paths.js
generated
7
lib/analysis-paths.js
generated
@@ -58,14 +58,11 @@ function includeAndExcludeAnalysisPaths(config) {
|
|||||||
}
|
}
|
||||||
// If the temporary or tools directory is in the working directory ignore that too.
|
// If the temporary or tools directory is in the working directory ignore that too.
|
||||||
const tempRelativeToWorking = path.relative(process.cwd(), config.tempDir);
|
const tempRelativeToWorking = path.relative(process.cwd(), config.tempDir);
|
||||||
const toolsRelativeToWorking = path.relative(process.cwd(), config.toolCacheDir);
|
|
||||||
let pathsIgnore = config.pathsIgnore;
|
let pathsIgnore = config.pathsIgnore;
|
||||||
if (!tempRelativeToWorking.startsWith("..")) {
|
if (!tempRelativeToWorking.startsWith("..") &&
|
||||||
|
!path.isAbsolute(tempRelativeToWorking)) {
|
||||||
pathsIgnore = pathsIgnore.concat(tempRelativeToWorking);
|
pathsIgnore = pathsIgnore.concat(tempRelativeToWorking);
|
||||||
}
|
}
|
||||||
if (!toolsRelativeToWorking.startsWith("..")) {
|
|
||||||
pathsIgnore = pathsIgnore.concat(toolsRelativeToWorking);
|
|
||||||
}
|
|
||||||
if (pathsIgnore.length !== 0) {
|
if (pathsIgnore.length !== 0) {
|
||||||
process.env["LGTM_INDEX_EXCLUDE"] = buildIncludeExcludeEnvVar(pathsIgnore);
|
process.env["LGTM_INDEX_EXCLUDE"] = buildIncludeExcludeEnvVar(pathsIgnore);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"analysis-paths.js","sourceRoot":"","sources":["../src/analysis-paths.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAK7B,SAAS,qBAAqB,CAAC,QAAQ;IACrC,OAAO,CACL,QAAQ,KAAK,YAAY,IAAI,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,MAAM,CAC1E,CAAC;AACJ,CAAC;AAED,6FAA6F;AAChF,QAAA,+BAA+B,GAAG,cAAc,CAAC;AAE9D,uFAAuF;AACvF,SAAS,yBAAyB,CAAC,KAAe;IAChD,iCAAiC;IACjC,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAEnD,uDAAuD;IACvD,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE;QAChC,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,uCAA+B,CAAC,CAAC,CAAC;KACvE;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,SAAgB,uBAA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AC,GAAG,yBAAyB,CAAC,WAAW,CAAC,CAAC;KAC5E;IAED,yEAAyE;IACzE,6EAA6E;IAC7E,wDAAwD;IACxD,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC;IACzD,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC;IAC/D,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;QACxB,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KACxD;AACH,CAAC;AAjCD,wEAiCC"}
|
||||||
47
lib/analysis-paths.test.js
generated
47
lib/analysis-paths.test.js
generated
@@ -37,7 +37,6 @@ const util = __importStar(require("./util"));
|
|||||||
paths: [],
|
paths: [],
|
||||||
originalUserInput: {},
|
originalUserInput: {},
|
||||||
tempDir: tmpDir,
|
tempDir: tmpDir,
|
||||||
toolCacheDir: tmpDir,
|
|
||||||
codeQLCmd: "",
|
codeQLCmd: "",
|
||||||
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
||||||
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
||||||
@@ -62,7 +61,6 @@ const util = __importStar(require("./util"));
|
|||||||
pathsIgnore: ["path4", "path5", "path6/**"],
|
pathsIgnore: ["path4", "path5", "path6/**"],
|
||||||
originalUserInput: {},
|
originalUserInput: {},
|
||||||
tempDir: tmpDir,
|
tempDir: tmpDir,
|
||||||
toolCacheDir: tmpDir,
|
|
||||||
codeQLCmd: "",
|
codeQLCmd: "",
|
||||||
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
||||||
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
||||||
@@ -79,29 +77,26 @@ const util = __importStar(require("./util"));
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("exclude temp dir", async (t) => {
|
(0, ava_1.default)("exclude temp dir", async (t) => {
|
||||||
return await util.withTmpDir(async (toolCacheDir) => {
|
const tempDir = path.join(process.cwd(), "codeql-runner-temp");
|
||||||
const tempDir = path.join(process.cwd(), "codeql-runner-temp");
|
const config = {
|
||||||
const config = {
|
languages: [],
|
||||||
languages: [],
|
queries: {},
|
||||||
queries: {},
|
pathsIgnore: [],
|
||||||
pathsIgnore: [],
|
paths: [],
|
||||||
paths: [],
|
originalUserInput: {},
|
||||||
originalUserInput: {},
|
tempDir,
|
||||||
tempDir,
|
codeQLCmd: "",
|
||||||
toolCacheDir,
|
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
||||||
codeQLCmd: "",
|
dbLocation: path.resolve(tempDir, "codeql_databases"),
|
||||||
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
packs: {},
|
||||||
dbLocation: path.resolve(tempDir, "codeql_databases"),
|
debugMode: false,
|
||||||
packs: {},
|
debugArtifactName: util.DEFAULT_DEBUG_ARTIFACT_NAME,
|
||||||
debugMode: false,
|
debugDatabaseName: util.DEFAULT_DEBUG_DATABASE_NAME,
|
||||||
debugArtifactName: util.DEFAULT_DEBUG_ARTIFACT_NAME,
|
injectedMlQueries: false,
|
||||||
debugDatabaseName: util.DEFAULT_DEBUG_DATABASE_NAME,
|
};
|
||||||
injectedMlQueries: false,
|
analysisPaths.includeAndExcludeAnalysisPaths(config);
|
||||||
};
|
t.is(process.env["LGTM_INDEX_INCLUDE"], undefined);
|
||||||
analysisPaths.includeAndExcludeAnalysisPaths(config);
|
t.is(process.env["LGTM_INDEX_EXCLUDE"], "codeql-runner-temp");
|
||||||
t.is(process.env["LGTM_INDEX_INCLUDE"], undefined);
|
t.is(process.env["LGTM_INDEX_FILTERS"], undefined);
|
||||||
t.is(process.env["LGTM_INDEX_EXCLUDE"], "codeql-runner-temp");
|
|
||||||
t.is(process.env["LGTM_INDEX_FILTERS"], undefined);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
//# sourceMappingURL=analysis-paths.test.js.map
|
//# sourceMappingURL=analysis-paths.test.js.map
|
||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"analysis-paths.test.js","sourceRoot":"","sources":["../src/analysis-paths.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAE7B,8CAAuB;AAEvB,gEAAkD;AAClD,mDAA6C;AAC7C,6CAA+B;AAE/B,IAAA,0BAAU,EAAC,aAAI,CAAC,CAAC;AAEjB,IAAA,aAAI,EAAC,YAAY,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAC7B,OAAO,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QAC5C,MAAM,MAAM,GAAG;YACb,SAAS,EAAE,EAAE;YACb,OAAO,EAAE,EAAE;YACX,WAAW,EAAE,EAAE;YACf,KAAK,EAAE,EAAE;YACT,iBAAiB,EAAE,EAAE;YACrB,OAAO,EAAE,MAAM;YACf,YAAY,EAAE,MAAM;YACpB,SAAS,EAAE,EAAE;YACb,aAAa,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,MAAM,EAAwB;YACxE,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,kBAAkB,CAAC;YACpD,KAAK,EAAE,EAAE;YACT,SAAS,EAAE,KAAK;YAChB,iBAAiB,EAAE,IAAI,CAAC,2BAA2B;YACnD,iBAAiB,EAAE,IAAI,CAAC,2BAA2B;YACnD,iBAAiB,EAAE,KAAK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C,CAAC;AAEH,IAAA,aAAI,EAAC,kBAAkB,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IACnC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,oBAAoB,CAAC,CAAC;IAC/D,MAAM,MAAM,GAAG;QACb,SAAS,EAAE,EAAE;QACb,OAAO,EAAE,EAAE;QACX,WAAW,EAAE,EAAE;QACf,KAAK,EAAE,EAAE;QACT,iBAAiB,EAAE,EAAE;QACrB,OAAO;QACP,SAAS,EAAE,EAAE;QACb,aAAa,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,MAAM,EAAwB;QACxE,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,kBAAkB,CAAC;QACrD,KAAK,EAAE,EAAE;QACT,SAAS,EAAE,KAAK;QAChB,iBAAiB,EAAE,IAAI,CAAC,2BAA2B;QACnD,iBAAiB,EAAE,IAAI,CAAC,2BAA2B;QACnD,iBAAiB,EAAE,KAAK;KACzB,CAAC;IACF,aAAa,CAAC,8BAA8B,CAAC,MAAM,CAAC,CAAC;IACrD,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,SAAS,CAAC,CAAC;IACnD,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,oBAAoB,CAAC,CAAC;IAC9D,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,SAAS,CAAC,CAAC;AACrD,CAAC,CAAC,CAAC"}
|
||||||
10
lib/analyze-action-env.test.js
generated
10
lib/analyze-action-env.test.js
generated
@@ -38,14 +38,17 @@ const util = __importStar(require("./util"));
|
|||||||
// but the first test would fail.
|
// but the first test would fail.
|
||||||
(0, ava_1.default)("analyze action with RAM & threads from environment variables", async (t) => {
|
(0, ava_1.default)("analyze action with RAM & threads from environment variables", async (t) => {
|
||||||
await util.withTmpDir(async (tmpDir) => {
|
await util.withTmpDir(async (tmpDir) => {
|
||||||
process.env["GITHUB_SERVER_URL"] = "fake-server-url";
|
process.env["GITHUB_SERVER_URL"] = util.GITHUB_DOTCOM_URL;
|
||||||
process.env["GITHUB_REPOSITORY"] = "fake/repository";
|
process.env["GITHUB_REPOSITORY"] = "github/codeql-action-fake-repository";
|
||||||
sinon
|
sinon
|
||||||
.stub(actionsUtil, "createStatusReportBase")
|
.stub(actionsUtil, "createStatusReportBase")
|
||||||
.resolves({});
|
.resolves({});
|
||||||
sinon.stub(actionsUtil, "sendStatusReport").resolves(true);
|
sinon.stub(actionsUtil, "sendStatusReport").resolves(true);
|
||||||
|
const gitHubVersion = {
|
||||||
|
type: util.GitHubVariant.DOTCOM,
|
||||||
|
};
|
||||||
sinon.stub(configUtils, "getConfig").resolves({
|
sinon.stub(configUtils, "getConfig").resolves({
|
||||||
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
gitHubVersion,
|
||||||
languages: [],
|
languages: [],
|
||||||
packs: [],
|
packs: [],
|
||||||
});
|
});
|
||||||
@@ -54,6 +57,7 @@ const util = __importStar(require("./util"));
|
|||||||
requiredInputStub.withArgs("upload-database").returns("false");
|
requiredInputStub.withArgs("upload-database").returns("false");
|
||||||
const optionalInputStub = sinon.stub(actionsUtil, "getOptionalInput");
|
const optionalInputStub = sinon.stub(actionsUtil, "getOptionalInput");
|
||||||
optionalInputStub.withArgs("cleanup-level").returns("none");
|
optionalInputStub.withArgs("cleanup-level").returns("none");
|
||||||
|
sinon.stub(util, "getGitHubVersion").resolves(gitHubVersion);
|
||||||
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
(0, testing_utils_1.mockFeatureFlagApiEndpoint)(200, {});
|
(0, testing_utils_1.mockFeatureFlagApiEndpoint)(200, {});
|
||||||
// When there are no action inputs for RAM and threads, the action uses
|
// When there are no action inputs for RAM and threads, the action uses
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"analyze-action-env.test.js","sourceRoot":"","sources":["../src/analyze-action-env.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,CAAC,CAAC;AAEjB,4EAA4E;AAC5E,4EAA4E;AAC5E,+EAA+E;AAC/E,+EAA+E;AAC/E,gFAAgF;AAChF,iCAAiC;AAEjC,IAAA,aAAI,EAAC,8DAA8D,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAC/E,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QACrC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,GAAG,iBAAiB,CAAC;QACrD,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,GAAG,iBAAiB,CAAC;QACrD,KAAK;aACF,IAAI,CAAC,WAAW,EAAE,wBAAwB,CAAC;aAC3C,QAAQ,CAAC,EAAkC,CAAC,CAAC;QAChD,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC3D,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC;YAC5C,aAAa,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE;YAClD,SAAS,EAAE,EAAE;YACb,KAAK,EAAE,EAAE;SACuB,CAAC,CAAC;QACpC,MAAM,iBAAiB,GAAG,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;QACtE,iBAAiB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,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AC,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"}
|
||||||
10
lib/analyze-action-input.test.js
generated
10
lib/analyze-action-input.test.js
generated
@@ -38,14 +38,17 @@ const util = __importStar(require("./util"));
|
|||||||
// but the first test would fail.
|
// but the first test would fail.
|
||||||
(0, ava_1.default)("analyze action with RAM & threads from action inputs", async (t) => {
|
(0, ava_1.default)("analyze action with RAM & threads from action inputs", async (t) => {
|
||||||
await util.withTmpDir(async (tmpDir) => {
|
await util.withTmpDir(async (tmpDir) => {
|
||||||
process.env["GITHUB_SERVER_URL"] = "fake-server-url";
|
process.env["GITHUB_SERVER_URL"] = util.GITHUB_DOTCOM_URL;
|
||||||
process.env["GITHUB_REPOSITORY"] = "fake/repository";
|
process.env["GITHUB_REPOSITORY"] = "github/codeql-action-fake-repository";
|
||||||
sinon
|
sinon
|
||||||
.stub(actionsUtil, "createStatusReportBase")
|
.stub(actionsUtil, "createStatusReportBase")
|
||||||
.resolves({});
|
.resolves({});
|
||||||
sinon.stub(actionsUtil, "sendStatusReport").resolves(true);
|
sinon.stub(actionsUtil, "sendStatusReport").resolves(true);
|
||||||
|
const gitHubVersion = {
|
||||||
|
type: util.GitHubVariant.DOTCOM,
|
||||||
|
};
|
||||||
sinon.stub(configUtils, "getConfig").resolves({
|
sinon.stub(configUtils, "getConfig").resolves({
|
||||||
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
gitHubVersion,
|
||||||
languages: [],
|
languages: [],
|
||||||
packs: [],
|
packs: [],
|
||||||
});
|
});
|
||||||
@@ -54,6 +57,7 @@ const util = __importStar(require("./util"));
|
|||||||
requiredInputStub.withArgs("upload-database").returns("false");
|
requiredInputStub.withArgs("upload-database").returns("false");
|
||||||
const optionalInputStub = sinon.stub(actionsUtil, "getOptionalInput");
|
const optionalInputStub = sinon.stub(actionsUtil, "getOptionalInput");
|
||||||
optionalInputStub.withArgs("cleanup-level").returns("none");
|
optionalInputStub.withArgs("cleanup-level").returns("none");
|
||||||
|
sinon.stub(util, "getGitHubVersion").resolves(gitHubVersion);
|
||||||
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
(0, testing_utils_1.mockFeatureFlagApiEndpoint)(200, {});
|
(0, testing_utils_1.mockFeatureFlagApiEndpoint)(200, {});
|
||||||
process.env["CODEQL_THREADS"] = "1";
|
process.env["CODEQL_THREADS"] = "1";
|
||||||
|
|||||||
@@ -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,CAAC,CAAC;AAEjB,4EAA4E;AAC5E,4EAA4E;AAC5E,+EAA+E;AAC/E,+EAA+E;AAC/E,gFAAgF;AAChF,iCAAiC;AAEjC,IAAA,aAAI,EAAC,sDAAsD,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IACvE,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QACrC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,GAAG,iBAAiB,CAAC;QACrD,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,GAAG,iBAAiB,CAAC;QACrD,KAAK;aACF,IAAI,CAAC,WAAW,EAAE,wBAAwB,CAAC;aAC3C,QAAQ,CAAC,EAAkC,CAAC,CAAC;QAChD,KAAK,C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M,CAAC;QAEnC,4DAA4D;QAC5D,iBAAiB,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACpD,iBAAiB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAElD,MAAM,eAAe,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QAC3D,MAAM,cAAc,GAAG,KAAK,CAAC,IAAI,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"}
|
||||||
27
lib/analyze-action.js
generated
27
lib/analyze-action.js
generated
@@ -26,9 +26,11 @@ const artifact = __importStar(require("@actions/artifact"));
|
|||||||
const core = __importStar(require("@actions/core"));
|
const core = __importStar(require("@actions/core"));
|
||||||
const actionsUtil = __importStar(require("./actions-util"));
|
const actionsUtil = __importStar(require("./actions-util"));
|
||||||
const analyze_1 = require("./analyze");
|
const analyze_1 = require("./analyze");
|
||||||
|
const api_client_1 = require("./api-client");
|
||||||
const codeql_1 = require("./codeql");
|
const codeql_1 = require("./codeql");
|
||||||
const config_utils_1 = require("./config-utils");
|
const config_utils_1 = require("./config-utils");
|
||||||
const database_upload_1 = require("./database-upload");
|
const database_upload_1 = require("./database-upload");
|
||||||
|
const feature_flags_1 = require("./feature-flags");
|
||||||
const logging_1 = require("./logging");
|
const logging_1 = require("./logging");
|
||||||
const repository_1 = require("./repository");
|
const repository_1 = require("./repository");
|
||||||
const upload_lib = __importStar(require("./upload-lib"));
|
const upload_lib = __importStar(require("./upload-lib"));
|
||||||
@@ -57,6 +59,7 @@ async function run() {
|
|||||||
let runStats = undefined;
|
let runStats = undefined;
|
||||||
let config = undefined;
|
let config = undefined;
|
||||||
util.initializeEnvironment(util.Mode.actions, pkg.version);
|
util.initializeEnvironment(util.Mode.actions, pkg.version);
|
||||||
|
await util.checkActionVersion(pkg.version);
|
||||||
try {
|
try {
|
||||||
if (!(await actionsUtil.sendStatusReport(await actionsUtil.createStatusReportBase("finish", "starting", startedAt)))) {
|
if (!(await actionsUtil.sendStatusReport(await actionsUtil.createStatusReportBase("finish", "starting", startedAt)))) {
|
||||||
return;
|
return;
|
||||||
@@ -75,7 +78,9 @@ async function run() {
|
|||||||
const threads = util.getThreadsFlag(actionsUtil.getOptionalInput("threads") || process.env["CODEQL_THREADS"], logger);
|
const threads = util.getThreadsFlag(actionsUtil.getOptionalInput("threads") || process.env["CODEQL_THREADS"], logger);
|
||||||
const memory = util.getMemoryFlag(actionsUtil.getOptionalInput("ram") || process.env["CODEQL_RAM"]);
|
const memory = util.getMemoryFlag(actionsUtil.getOptionalInput("ram") || process.env["CODEQL_RAM"]);
|
||||||
const repositoryNwo = (0, repository_1.parseRepositoryNwo)(util.getRequiredEnvParam("GITHUB_REPOSITORY"));
|
const repositoryNwo = (0, repository_1.parseRepositoryNwo)(util.getRequiredEnvParam("GITHUB_REPOSITORY"));
|
||||||
await (0, analyze_1.runFinalize)(outputDir, threads, memory, config, logger);
|
const gitHubVersion = await (0, api_client_1.getGitHubVersionActionsOnly)();
|
||||||
|
const featureFlags = new feature_flags_1.GitHubFeatureFlags(gitHubVersion, apiDetails, repositoryNwo, logger);
|
||||||
|
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);
|
||||||
if (config.debugMode) {
|
if (config.debugMode) {
|
||||||
@@ -86,13 +91,13 @@ async function run() {
|
|||||||
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
||||||
if (config.debugMode) {
|
if (config.debugMode) {
|
||||||
// Upload the logs as an Actions artifact for debugging
|
// Upload the logs as an Actions artifact for debugging
|
||||||
const toUpload = [];
|
let toUpload = [];
|
||||||
for (const language of config.languages) {
|
for (const language of config.languages) {
|
||||||
toUpload.push(...listFolder(path.resolve(util.getCodeQLDatabasePath(config, language), "log")));
|
toUpload = toUpload.concat(listFolder(path.resolve(util.getCodeQLDatabasePath(config, language), "log")));
|
||||||
}
|
}
|
||||||
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)) {
|
||||||
// Multilanguage tracing: there are additional logs in the root of the cluster
|
// Multilanguage tracing: there are additional logs in the root of the cluster
|
||||||
toUpload.push(...listFolder(path.resolve(config.dbLocation, "log")));
|
toUpload = toUpload.concat(listFolder(path.resolve(config.dbLocation, "log")));
|
||||||
}
|
}
|
||||||
await uploadDebugArtifacts(toUpload, config.dbLocation, config.debugArtifactName);
|
await uploadDebugArtifacts(toUpload, config.dbLocation, config.debugArtifactName);
|
||||||
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))) {
|
||||||
@@ -117,7 +122,11 @@ async function run() {
|
|||||||
}
|
}
|
||||||
// Possibly upload the database bundles for remote queries
|
// Possibly upload the database bundles for remote queries
|
||||||
await (0, database_upload_1.uploadDatabases)(repositoryNwo, config, apiDetails, logger);
|
await (0, database_upload_1.uploadDatabases)(repositoryNwo, config, apiDetails, logger);
|
||||||
if (uploadResult !== undefined &&
|
// We don't upload results in test mode, so don't wait for processing
|
||||||
|
if (util.isInTestMode()) {
|
||||||
|
core.debug("In test mode. Waiting for processing is disabled.");
|
||||||
|
}
|
||||||
|
else if (uploadResult !== undefined &&
|
||||||
actionsUtil.getRequiredInput("wait-for-processing") === "true") {
|
actionsUtil.getRequiredInput("wait-for-processing") === "true") {
|
||||||
await upload_lib.waitForProcessing((0, repository_1.parseRepositoryNwo)(util.getRequiredEnvParam("GITHUB_REPOSITORY")), uploadResult.sarifID, apiDetails, (0, logging_1.getActionsLogger)());
|
await upload_lib.waitForProcessing((0, repository_1.parseRepositoryNwo)(util.getRequiredEnvParam("GITHUB_REPOSITORY")), uploadResult.sarifID, apiDetails, (0, logging_1.getActionsLogger)());
|
||||||
}
|
}
|
||||||
@@ -136,7 +145,7 @@ async function run() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if (config !== undefined && config.debugMode) {
|
if (config === null || config === void 0 ? void 0 : config.debugMode) {
|
||||||
try {
|
try {
|
||||||
// Upload the database bundles as an Actions artifact for debugging
|
// Upload the database bundles as an Actions artifact for debugging
|
||||||
const toUpload = [];
|
const toUpload = [];
|
||||||
@@ -149,7 +158,7 @@ async function run() {
|
|||||||
console.log(`Failed to upload database debug bundles: ${error}`);
|
console.log(`Failed to upload database debug bundles: ${error}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (core.isDebug() && config !== undefined) {
|
if (config === null || config === void 0 ? void 0 : config.debugMode) {
|
||||||
core.info("Debug mode is on. Printing CodeQL debug logs...");
|
core.info("Debug mode is on. Printing CodeQL debug logs...");
|
||||||
for (const language of config.languages) {
|
for (const language of config.languages) {
|
||||||
const databaseDirectory = util.getCodeQLDatabasePath(config, language);
|
const databaseDirectory = util.getCodeQLDatabasePath(config, language);
|
||||||
@@ -195,13 +204,13 @@ async function uploadDebugArtifacts(toUpload, rootDir, artifactName) {
|
|||||||
}
|
}
|
||||||
function listFolder(dir) {
|
function listFolder(dir) {
|
||||||
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
||||||
const files = [];
|
let files = [];
|
||||||
for (const entry of entries) {
|
for (const entry of entries) {
|
||||||
if (entry.isFile()) {
|
if (entry.isFile()) {
|
||||||
files.push(path.resolve(dir, entry.name));
|
files.push(path.resolve(dir, entry.name));
|
||||||
}
|
}
|
||||||
else if (entry.isDirectory()) {
|
else if (entry.isDirectory()) {
|
||||||
files.push(...listFolder(path.resolve(dir, entry.name)));
|
files = files.concat(listFolder(path.resolve(dir, entry.name)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return files;
|
return files;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
84
lib/analyze.js
generated
84
lib/analyze.js
generated
@@ -18,11 +18,15 @@ 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.runCleanup = exports.runFinalize = exports.runQueries = exports.CodeQLAnalysisError = void 0;
|
exports.runCleanup = exports.runFinalize = exports.runQueries = exports.createdDBForScannedLanguages = exports.CodeQLAnalysisError = void 0;
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
|
const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
|
||||||
|
const del_1 = __importDefault(require("del"));
|
||||||
const yaml = __importStar(require("js-yaml"));
|
const yaml = __importStar(require("js-yaml"));
|
||||||
const analysisPaths = __importStar(require("./analysis-paths"));
|
const analysisPaths = __importStar(require("./analysis-paths"));
|
||||||
const codeql_1 = require("./codeql");
|
const codeql_1 = require("./codeql");
|
||||||
@@ -64,11 +68,10 @@ async function setupPythonExtractor(logger) {
|
|||||||
logger.info(`Setting LGTM_PYTHON_SETUP_VERSION=${output}`);
|
logger.info(`Setting LGTM_PYTHON_SETUP_VERSION=${output}`);
|
||||||
process.env["LGTM_PYTHON_SETUP_VERSION"] = output;
|
process.env["LGTM_PYTHON_SETUP_VERSION"] = output;
|
||||||
}
|
}
|
||||||
async function createdDBForScannedLanguages(config, logger) {
|
async function createdDBForScannedLanguages(codeql, config, logger, featureFlags) {
|
||||||
// Insert the LGTM_INDEX_X env vars at this point so they are set when
|
// Insert the LGTM_INDEX_X env vars at this point so they are set when
|
||||||
// we extract any scanned languages.
|
// we extract any scanned languages.
|
||||||
analysisPaths.includeAndExcludeAnalysisPaths(config);
|
analysisPaths.includeAndExcludeAnalysisPaths(config);
|
||||||
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
|
||||||
for (const language of config.languages) {
|
for (const language of config.languages) {
|
||||||
if ((0, languages_1.isScannedLanguage)(language) &&
|
if ((0, languages_1.isScannedLanguage)(language) &&
|
||||||
!dbIsFinalized(config, language, logger)) {
|
!dbIsFinalized(config, language, logger)) {
|
||||||
@@ -76,11 +79,12 @@ async function createdDBForScannedLanguages(config, logger) {
|
|||||||
if (language === languages_1.Language.python) {
|
if (language === languages_1.Language.python) {
|
||||||
await setupPythonExtractor(logger);
|
await setupPythonExtractor(logger);
|
||||||
}
|
}
|
||||||
await codeql.extractScannedLanguage(util.getCodeQLDatabasePath(config, language), language);
|
await codeql.extractScannedLanguage(util.getCodeQLDatabasePath(config, language), language, featureFlags);
|
||||||
logger.endGroup();
|
logger.endGroup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
exports.createdDBForScannedLanguages = createdDBForScannedLanguages;
|
||||||
function dbIsFinalized(config, language, logger) {
|
function dbIsFinalized(config, language, logger) {
|
||||||
const dbPath = util.getCodeQLDatabasePath(config, language);
|
const dbPath = util.getCodeQLDatabasePath(config, language);
|
||||||
try {
|
try {
|
||||||
@@ -92,9 +96,9 @@ function dbIsFinalized(config, language, logger) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async function finalizeDatabaseCreation(config, threadsFlag, memoryFlag, logger) {
|
async function finalizeDatabaseCreation(config, threadsFlag, memoryFlag, logger, featureFlags) {
|
||||||
await createdDBForScannedLanguages(config, logger);
|
|
||||||
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
||||||
|
await createdDBForScannedLanguages(codeql, config, logger, featureFlags);
|
||||||
for (const language of config.languages) {
|
for (const language of config.languages) {
|
||||||
if (dbIsFinalized(config, language, logger)) {
|
if (dbIsFinalized(config, language, logger)) {
|
||||||
logger.info(`There is already a finalized database for ${language} at the location where the CodeQL Action places databases, so we did not create one.`);
|
logger.info(`There is already a finalized database for ${language} at the location where the CodeQL Action places databases, so we did not create one.`);
|
||||||
@@ -111,10 +115,8 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
|
|||||||
const statusReport = {};
|
const statusReport = {};
|
||||||
let locPromise = Promise.resolve({});
|
let locPromise = Promise.resolve({});
|
||||||
const cliCanCountBaseline = await cliCanCountLoC();
|
const cliCanCountBaseline = await cliCanCountLoC();
|
||||||
const debugMode = process.env["INTERNAL_CODEQL_ACTION_DEBUG_LOC"] ||
|
const countLocDebugMode = process.env["INTERNAL_CODEQL_ACTION_DEBUG_LOC"] || config.debugMode;
|
||||||
process.env["ACTIONS_RUNNER_DEBUG"] ||
|
if (!cliCanCountBaseline || countLocDebugMode) {
|
||||||
process.env["ACTIONS_STEP_DEBUG"];
|
|
||||||
if (!cliCanCountBaseline || debugMode) {
|
|
||||||
// count the number of lines in the background
|
// count the number of lines in the background
|
||||||
locPromise = (0, count_loc_1.countLoc)(path.resolve(),
|
locPromise = (0, count_loc_1.countLoc)(path.resolve(),
|
||||||
// config.paths specifies external directories. the current
|
// config.paths specifies external directories. the current
|
||||||
@@ -159,7 +161,7 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (packsWithVersion.length > 0) {
|
if (packsWithVersion.length > 0) {
|
||||||
querySuitePaths.push(await runQueryGroup(language, "packs", createPackSuiteContents(packsWithVersion), undefined));
|
querySuitePaths.push(...(await runQueryPacks(language, "packs", packsWithVersion, undefined)));
|
||||||
ranCustom = true;
|
ranCustom = true;
|
||||||
}
|
}
|
||||||
if (ranCustom) {
|
if (ranCustom) {
|
||||||
@@ -170,14 +172,14 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
|
|||||||
logger.startGroup(`Interpreting results for ${language}`);
|
logger.startGroup(`Interpreting results for ${language}`);
|
||||||
const startTimeInterpretResults = new Date().getTime();
|
const startTimeInterpretResults = new Date().getTime();
|
||||||
const sarifFile = path.join(sarifFolder, `${language}.sarif`);
|
const sarifFile = path.join(sarifFolder, `${language}.sarif`);
|
||||||
const analysisSummary = await runInterpretResults(language, querySuitePaths, sarifFile);
|
const analysisSummary = await runInterpretResults(language, querySuitePaths, sarifFile, config.debugMode);
|
||||||
if (!cliCanCountBaseline)
|
if (!cliCanCountBaseline)
|
||||||
await injectLinesOfCode(sarifFile, language, locPromise);
|
await injectLinesOfCode(sarifFile, language, locPromise);
|
||||||
statusReport[`interpret_results_${language}_duration_ms`] =
|
statusReport[`interpret_results_${language}_duration_ms`] =
|
||||||
new Date().getTime() - startTimeInterpretResults;
|
new Date().getTime() - startTimeInterpretResults;
|
||||||
logger.endGroup();
|
logger.endGroup();
|
||||||
logger.info(analysisSummary);
|
logger.info(analysisSummary);
|
||||||
if (!cliCanCountBaseline || debugMode)
|
if (!cliCanCountBaseline || countLocDebugMode)
|
||||||
printLinesOfCodeSummary(logger, language, await locPromise);
|
printLinesOfCodeSummary(logger, language, await locPromise);
|
||||||
if (cliCanCountBaseline)
|
if (cliCanCountBaseline)
|
||||||
logger.info(await runPrintLinesOfCode(language));
|
logger.info(await runPrintLinesOfCode(language));
|
||||||
@@ -192,10 +194,10 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return statusReport;
|
return statusReport;
|
||||||
async function runInterpretResults(language, queries, sarifFile) {
|
async function runInterpretResults(language, queries, sarifFile, enableDebugLogging) {
|
||||||
const databasePath = util.getCodeQLDatabasePath(config, language);
|
const databasePath = util.getCodeQLDatabasePath(config, language);
|
||||||
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
||||||
return await codeql.databaseInterpretResults(databasePath, queries, sarifFile, addSnippetsFlag, threadsFlag, automationDetailsId);
|
return await codeql.databaseInterpretResults(databasePath, queries, sarifFile, addSnippetsFlag, threadsFlag, enableDebugLogging ? "-vv" : "-v", automationDetailsId);
|
||||||
}
|
}
|
||||||
async function cliCanCountLoC() {
|
async function cliCanCountLoC() {
|
||||||
return await util.codeQlVersionAbove(await (0, codeql_1.getCodeQL)(config.codeQLCmd), codeql_1.CODEQL_VERSION_COUNTS_LINES);
|
return await util.codeQlVersionAbove(await (0, codeql_1.getCodeQL)(config.codeQLCmd), codeql_1.CODEQL_VERSION_COUNTS_LINES);
|
||||||
@@ -217,23 +219,40 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
|
|||||||
logger.debug(`BQRS results produced for ${language} (queries: ${type})"`);
|
logger.debug(`BQRS results produced for ${language} (queries: ${type})"`);
|
||||||
return querySuitePath;
|
return querySuitePath;
|
||||||
}
|
}
|
||||||
|
async function runQueryPacks(language, type, packs, searchPath) {
|
||||||
|
const databasePath = util.getCodeQLDatabasePath(config, language);
|
||||||
|
// Run the queries individually instead of all at once to avoid command
|
||||||
|
// line length restrictions, particularly on windows.
|
||||||
|
for (const pack of packs) {
|
||||||
|
logger.debug(`Running query pack for ${language}-${type}: ${pack}`);
|
||||||
|
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
||||||
|
await codeql.databaseRunQueries(databasePath, searchPath, pack, memoryFlag, threadsFlag);
|
||||||
|
logger.debug(`BQRS results produced for ${language} (queries: ${type})"`);
|
||||||
|
}
|
||||||
|
return packs;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
exports.runQueries = runQueries;
|
exports.runQueries = runQueries;
|
||||||
function createQuerySuiteContents(queries) {
|
function createQuerySuiteContents(queries) {
|
||||||
return queries.map((q) => `- query: ${q}`).join("\n");
|
return queries.map((q) => `- query: ${q}`).join("\n");
|
||||||
}
|
}
|
||||||
function createPackSuiteContents(packsWithVersion) {
|
async function runFinalize(outputDir, threadsFlag, memoryFlag, config, logger, featureFlags) {
|
||||||
return packsWithVersion.map(packWithVersionToQuerySuiteEntry).join("\n");
|
try {
|
||||||
}
|
await (0, del_1.default)(outputDir, { force: true });
|
||||||
function packWithVersionToQuerySuiteEntry(pack) {
|
|
||||||
let text = `- qlpack: ${pack.packName}`;
|
|
||||||
if (pack.version) {
|
|
||||||
text += `\n version: ${pack.version}`;
|
|
||||||
}
|
}
|
||||||
return text;
|
catch (error) {
|
||||||
}
|
if ((error === null || error === void 0 ? void 0 : error.code) !== "ENOENT") {
|
||||||
async function runFinalize(outputDir, threadsFlag, memoryFlag, config, logger) {
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await fs.promises.mkdir(outputDir, { recursive: true });
|
||||||
|
await finalizeDatabaseCreation(config, threadsFlag, memoryFlag, logger, featureFlags);
|
||||||
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
||||||
|
// WARNING: This does not _really_ end tracing, as the tracer will restore its
|
||||||
|
// critical environment variables and it'll still be active for all processes
|
||||||
|
// launched from this build step.
|
||||||
|
// However, it will stop tracing for all steps past the codeql-action/analyze
|
||||||
|
// step.
|
||||||
if (await util.codeQlVersionAbove(codeql, codeql_1.CODEQL_VERSION_NEW_TRACING)) {
|
if (await util.codeQlVersionAbove(codeql, codeql_1.CODEQL_VERSION_NEW_TRACING)) {
|
||||||
// Delete variables as specified by the end-tracing script
|
// Delete variables as specified by the end-tracing script
|
||||||
await (0, tracer_config_1.endTracingForCluster)(config);
|
await (0, tracer_config_1.endTracingForCluster)(config);
|
||||||
@@ -242,21 +261,6 @@ async function runFinalize(outputDir, threadsFlag, memoryFlag, config, logger) {
|
|||||||
// Delete the tracer config env var to avoid tracing ourselves
|
// Delete the tracer config env var to avoid tracing ourselves
|
||||||
delete process.env[sharedEnv.ODASA_TRACER_CONFIGURATION];
|
delete process.env[sharedEnv.ODASA_TRACER_CONFIGURATION];
|
||||||
}
|
}
|
||||||
// After switching to Node16, this entire block can be replaced with `await fs.promises.rm(outputDir, { recursive: true, force: true });`.
|
|
||||||
try {
|
|
||||||
await fs.promises.rmdir(outputDir, {
|
|
||||||
recursive: true,
|
|
||||||
maxRetries: 5,
|
|
||||||
retryDelay: 2000,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
if ((error === null || error === void 0 ? void 0 : error.code) !== "ENOENT") {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
await fs.promises.mkdir(outputDir, { recursive: true });
|
|
||||||
await finalizeDatabaseCreation(config, threadsFlag, memoryFlag, logger);
|
|
||||||
}
|
}
|
||||||
exports.runFinalize = runFinalize;
|
exports.runFinalize = runFinalize;
|
||||||
async function runCleanup(config, cleanupLevel, logger) {
|
async function runCleanup(config, cleanupLevel, logger) {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
107
lib/analyze.test.js
generated
107
lib/analyze.test.js
generated
@@ -26,11 +26,12 @@ const fs = __importStar(require("fs"));
|
|||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const ava_1 = __importDefault(require("ava"));
|
const ava_1 = __importDefault(require("ava"));
|
||||||
const yaml = __importStar(require("js-yaml"));
|
const yaml = __importStar(require("js-yaml"));
|
||||||
const semver_1 = require("semver");
|
|
||||||
const sinon = __importStar(require("sinon"));
|
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 codeql_test_1 = require("./codeql.test");
|
||||||
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");
|
||||||
@@ -53,18 +54,8 @@ const util = __importStar(require("./util"));
|
|||||||
const addSnippetsFlag = "";
|
const addSnippetsFlag = "";
|
||||||
const threadsFlag = "";
|
const threadsFlag = "";
|
||||||
const packs = {
|
const packs = {
|
||||||
[languages_1.Language.cpp]: [
|
[languages_1.Language.cpp]: ["a/b@1.0.0"],
|
||||||
{
|
[languages_1.Language.java]: ["c/d@2.0.0"],
|
||||||
packName: "a/b",
|
|
||||||
version: (0, semver_1.clean)("1.0.0"),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
[languages_1.Language.java]: [
|
|
||||||
{
|
|
||||||
packName: "c/d",
|
|
||||||
version: (0, semver_1.clean)("2.0.0"),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
};
|
||||||
for (const language of Object.values(languages_1.Language)) {
|
for (const language of Object.values(languages_1.Language)) {
|
||||||
(0, codeql_1.setCodeQL)({
|
(0, codeql_1.setCodeQL)({
|
||||||
@@ -118,7 +109,6 @@ const util = __importStar(require("./util"));
|
|||||||
paths: [],
|
paths: [],
|
||||||
originalUserInput: {},
|
originalUserInput: {},
|
||||||
tempDir: tmpDir,
|
tempDir: tmpDir,
|
||||||
toolCacheDir: tmpDir,
|
|
||||||
codeQLCmd: "",
|
codeQLCmd: "",
|
||||||
gitHubVersion: {
|
gitHubVersion: {
|
||||||
type: util.GitHubVariant.DOTCOM,
|
type: util.GitHubVariant.DOTCOM,
|
||||||
@@ -209,32 +199,10 @@ const util = __importStar(require("./util"));
|
|||||||
query: "bar.ql",
|
query: "bar.ql",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
const qlsPackContentCpp = [
|
|
||||||
{
|
|
||||||
qlpack: "a/b",
|
|
||||||
version: "1.0.0",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
const qlsPackContentJava = [
|
|
||||||
{
|
|
||||||
qlpack: "c/d",
|
|
||||||
version: "2.0.0",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
for (const lang of Object.values(languages_1.Language)) {
|
for (const lang of Object.values(languages_1.Language)) {
|
||||||
t.deepEqual(readContents(`${lang}-queries-builtin.qls`), qlsContent);
|
t.deepEqual(readContents(`${lang}-queries-builtin.qls`), qlsContent);
|
||||||
t.deepEqual(readContents(`${lang}-queries-custom-0.qls`), qlsContent);
|
t.deepEqual(readContents(`${lang}-queries-custom-0.qls`), qlsContent);
|
||||||
t.deepEqual(readContents(`${lang}-queries-custom-1.qls`), qlsContent2);
|
t.deepEqual(readContents(`${lang}-queries-custom-1.qls`), qlsContent2);
|
||||||
const packSuiteName = `${lang}-queries-packs.qls`;
|
|
||||||
if (lang === languages_1.Language.cpp) {
|
|
||||||
t.deepEqual(readContents(packSuiteName), qlsPackContentCpp);
|
|
||||||
}
|
|
||||||
else if (lang === languages_1.Language.java) {
|
|
||||||
t.deepEqual(readContents(packSuiteName), qlsPackContentJava);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
t.false(fs.existsSync(path.join(tmpDir, "codeql_databases", packSuiteName)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
function readContents(name) {
|
function readContents(name) {
|
||||||
const x = fs.readFileSync(path.join(tmpDir, "codeql_databases", name), "utf8");
|
const x = fs.readFileSync(path.join(tmpDir, "codeql_databases", name), "utf8");
|
||||||
@@ -243,4 +211,71 @@ const util = __importStar(require("./util"));
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
const stubConfig = {
|
||||||
|
languages: [languages_1.Language.cpp, languages_1.Language.go],
|
||||||
|
queries: {},
|
||||||
|
pathsIgnore: [],
|
||||||
|
paths: [],
|
||||||
|
originalUserInput: {},
|
||||||
|
tempDir: "",
|
||||||
|
codeQLCmd: "",
|
||||||
|
gitHubVersion: {
|
||||||
|
type: util.GitHubVariant.DOTCOM,
|
||||||
|
},
|
||||||
|
dbLocation: "",
|
||||||
|
packs: {},
|
||||||
|
debugMode: false,
|
||||||
|
debugArtifactName: util.DEFAULT_DEBUG_ARTIFACT_NAME,
|
||||||
|
debugDatabaseName: util.DEFAULT_DEBUG_DATABASE_NAME,
|
||||||
|
injectedMlQueries: false,
|
||||||
|
};
|
||||||
|
for (const options of [
|
||||||
|
{
|
||||||
|
name: "Lua feature flag enabled, but old CLI",
|
||||||
|
version: "2.9.0",
|
||||||
|
featureFlags: [feature_flags_1.FeatureFlag.LuaTracerConfigEnabled],
|
||||||
|
yesFlagSet: false,
|
||||||
|
noFlagSet: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Lua feature flag disabled, with old CLI",
|
||||||
|
version: "2.9.0",
|
||||||
|
featureFlags: [],
|
||||||
|
yesFlagSet: false,
|
||||||
|
noFlagSet: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Lua feature flag enabled, with new CLI",
|
||||||
|
version: "2.10.0",
|
||||||
|
featureFlags: [feature_flags_1.FeatureFlag.LuaTracerConfigEnabled],
|
||||||
|
yesFlagSet: true,
|
||||||
|
noFlagSet: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Lua feature flag disabled, with new CLI",
|
||||||
|
version: "2.10.0",
|
||||||
|
featureFlags: [],
|
||||||
|
yesFlagSet: false,
|
||||||
|
noFlagSet: true,
|
||||||
|
},
|
||||||
|
]) {
|
||||||
|
(0, ava_1.default)(`createdDBForScannedLanguages() ${options.name}`, async (t) => {
|
||||||
|
const runnerConstructorStub = (0, codeql_test_1.stubToolRunnerConstructor)();
|
||||||
|
const codeqlObject = await (0, codeql_1.getCodeQLForTesting)("codeql/for-testing");
|
||||||
|
sinon.stub(codeqlObject, "getVersion").resolves(options.version);
|
||||||
|
const promise = (0, analyze_1.createdDBForScannedLanguages)(codeqlObject, stubConfig, (0, logging_1.getRunnerLogger)(true), (0, feature_flags_1.createFeatureFlags)(options.featureFlags));
|
||||||
|
// call listener on `codeql resolve extractor`
|
||||||
|
const mockToolRunner = runnerConstructorStub.getCall(0);
|
||||||
|
mockToolRunner.args[2].listeners.stdout('"/path/to/extractor"');
|
||||||
|
await promise;
|
||||||
|
if (options.yesFlagSet)
|
||||||
|
t.true(runnerConstructorStub.secondCall.args[1].includes("--internal-use-lua-tracing"), "--internal-use-lua-tracing should be present, but it is absent");
|
||||||
|
else
|
||||||
|
t.false(runnerConstructorStub.secondCall.args[1].includes("--internal-use-lua-tracing"), "--internal-use-lua-tracing should be absent, but it is present");
|
||||||
|
if (options.noFlagSet)
|
||||||
|
t.true(runnerConstructorStub.secondCall.args[1].includes("--no-internal-use-lua-tracing"), "--no-internal-use-lua-tracing should be present, but it is absent");
|
||||||
|
else
|
||||||
|
t.false(runnerConstructorStub.secondCall.args[1].includes("--no-internal-use-lua-tracing"), "--no-internal-use-lua-tracing should be absent, but it is present");
|
||||||
|
});
|
||||||
|
}
|
||||||
//# sourceMappingURL=analyze.test.js.map
|
//# sourceMappingURL=analyze.test.js.map
|
||||||
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
|
|||||||
{ "maximumVersion": "3.5", "minimumVersion": "3.1" }
|
{ "maximumVersion": "3.6", "minimumVersion": "3.2" }
|
||||||
|
|||||||
3
lib/autobuild-action.js
generated
3
lib/autobuild-action.js
generated
@@ -39,8 +39,9 @@ async function sendCompletedStatusReport(startedAt, allLanguages, failingLanguag
|
|||||||
await (0, actions_util_1.sendStatusReport)(statusReport);
|
await (0, actions_util_1.sendStatusReport)(statusReport);
|
||||||
}
|
}
|
||||||
async function run() {
|
async function run() {
|
||||||
const logger = (0, logging_1.getActionsLogger)();
|
|
||||||
const startedAt = new Date();
|
const startedAt = new Date();
|
||||||
|
const logger = (0, logging_1.getActionsLogger)();
|
||||||
|
await (0, util_1.checkActionVersion)(pkg.version);
|
||||||
let language = undefined;
|
let language = undefined;
|
||||||
try {
|
try {
|
||||||
if (!(await (0, actions_util_1.sendStatusReport)(await (0, actions_util_1.createStatusReportBase)("autobuild", "starting", startedAt)))) {
|
if (!(await (0, actions_util_1.sendStatusReport)(await (0, actions_util_1.createStatusReportBase)("autobuild", "starting", startedAt)))) {
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"autobuild-action.js","sourceRoot":"","sources":["../src/autobuild-action.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsC;AA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,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AACzE,CAAC;AAED,KAAK,UAAU,UAAU;IACvB,IAAI;QACF,MAAM,GAAG,EAAE,CAAC;KACb;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,SAAS,CAAC,4BAA4B,KAAK,EAAE,CAAC,CAAC;QACpD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;KACpB;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"}
|
||||||
85
lib/codeql.js
generated
85
lib/codeql.js
generated
@@ -22,19 +22,21 @@ 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.getExtraOptions = exports.getCodeQLForTesting = exports.getCachedCodeQL = exports.setCodeQL = exports.getCodeQL = exports.convertToSemVer = exports.getCodeQLURLVersion = exports.setupCodeQL = exports.getCodeQLActionRepository = exports.CODEQL_VERSION_NEW_TRACING = exports.CODEQL_VERSION_ML_POWERED_QUERIES = exports.CODEQL_VERSION_COUNTS_LINES = exports.CommandInvocationError = void 0;
|
exports.getExtraOptions = exports.getCodeQLForTesting = exports.getCachedCodeQL = exports.setCodeQL = exports.getCodeQL = exports.convertToSemVer = exports.getCodeQLURLVersion = exports.setupCodeQL = exports.getCodeQLActionRepository = exports.CODEQL_VERSION_ML_POWERED_QUERIES_WINDOWS = exports.CODEQL_VERSION_NEW_TRACING = exports.CODEQL_VERSION_ML_POWERED_QUERIES = exports.CODEQL_VERSION_COUNTS_LINES = exports.CommandInvocationError = void 0;
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
|
const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
|
||||||
|
const toolcache = __importStar(require("@actions/tool-cache"));
|
||||||
const fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
|
const fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
|
||||||
const query_string_1 = __importDefault(require("query-string"));
|
const query_string_1 = __importDefault(require("query-string"));
|
||||||
const semver = __importStar(require("semver"));
|
const semver = __importStar(require("semver"));
|
||||||
|
const uuid_1 = require("uuid");
|
||||||
const actions_util_1 = require("./actions-util");
|
const actions_util_1 = require("./actions-util");
|
||||||
const api = __importStar(require("./api-client"));
|
const api = __importStar(require("./api-client"));
|
||||||
const defaults = __importStar(require("./defaults.json")); // Referenced from codeql-action-sync-tool!
|
const defaults = __importStar(require("./defaults.json")); // Referenced from codeql-action-sync-tool!
|
||||||
const error_matcher_1 = require("./error-matcher");
|
const error_matcher_1 = require("./error-matcher");
|
||||||
|
const feature_flags_1 = require("./feature-flags");
|
||||||
const languages_1 = require("./languages");
|
const languages_1 = require("./languages");
|
||||||
const toolcache = __importStar(require("./toolcache"));
|
|
||||||
const toolrunner_error_catcher_1 = require("./toolrunner-error-catcher");
|
const toolrunner_error_catcher_1 = require("./toolrunner-error-catcher");
|
||||||
const util = __importStar(require("./util"));
|
const util = __importStar(require("./util"));
|
||||||
const util_1 = require("./util");
|
const util_1 = require("./util");
|
||||||
@@ -76,6 +78,7 @@ const CODEQL_VERSION_SARIF_GROUP = "2.5.3";
|
|||||||
exports.CODEQL_VERSION_COUNTS_LINES = "2.6.2";
|
exports.CODEQL_VERSION_COUNTS_LINES = "2.6.2";
|
||||||
const CODEQL_VERSION_CUSTOM_QUERY_HELP = "2.7.1";
|
const CODEQL_VERSION_CUSTOM_QUERY_HELP = "2.7.1";
|
||||||
exports.CODEQL_VERSION_ML_POWERED_QUERIES = "2.7.5";
|
exports.CODEQL_VERSION_ML_POWERED_QUERIES = "2.7.5";
|
||||||
|
const CODEQL_VERSION_LUA_TRACER_CONFIG = "2.10.0";
|
||||||
/**
|
/**
|
||||||
* This variable controls using the new style of tracing from the CodeQL
|
* This variable controls using the new style of tracing from the CodeQL
|
||||||
* CLI. In particular, with versions above this we will use both indirect
|
* CLI. In particular, with versions above this we will use both indirect
|
||||||
@@ -86,6 +89,12 @@ exports.CODEQL_VERSION_ML_POWERED_QUERIES = "2.7.5";
|
|||||||
* versions above that.
|
* versions above that.
|
||||||
*/
|
*/
|
||||||
exports.CODEQL_VERSION_NEW_TRACING = "2.7.0";
|
exports.CODEQL_VERSION_NEW_TRACING = "2.7.0";
|
||||||
|
/**
|
||||||
|
* Versions 2.9.0+ of the CodeQL CLI run machine learning models from a temporary directory, which
|
||||||
|
* resolves an issue on Windows where TensorFlow models are not correctly loaded due to the path of
|
||||||
|
* some of their files being greater than MAX_PATH (260 characters).
|
||||||
|
*/
|
||||||
|
exports.CODEQL_VERSION_ML_POWERED_QUERIES_WINDOWS = "2.9.0";
|
||||||
function getCodeQLBundleName() {
|
function getCodeQLBundleName() {
|
||||||
let platform;
|
let platform;
|
||||||
if (process.platform === "win32") {
|
if (process.platform === "win32") {
|
||||||
@@ -200,14 +209,13 @@ async function getCodeQLBundleDownloadURL(apiDetails, variant, logger) {
|
|||||||
* @param codeqlURL
|
* @param codeqlURL
|
||||||
* @param apiDetails
|
* @param apiDetails
|
||||||
* @param tempDir
|
* @param tempDir
|
||||||
* @param toolCacheDir
|
|
||||||
* @param variant
|
* @param variant
|
||||||
* @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
|
||||||
*/
|
*/
|
||||||
async function setupCodeQL(codeqlURL, apiDetails, tempDir, toolCacheDir, variant, logger, checkVersion) {
|
async function setupCodeQL(codeqlURL, apiDetails, tempDir, variant, logger, checkVersion) {
|
||||||
try {
|
try {
|
||||||
// We use the special value of 'latest' to prioritize the version in the
|
// We use the special value of 'latest' to prioritize the version in the
|
||||||
// defaults over any pinned cached version.
|
// defaults over any pinned cached version.
|
||||||
@@ -218,21 +226,21 @@ async function setupCodeQL(codeqlURL, apiDetails, tempDir, toolCacheDir, variant
|
|||||||
let codeqlFolder;
|
let codeqlFolder;
|
||||||
let codeqlURLVersion;
|
let codeqlURLVersion;
|
||||||
if (codeqlURL && !codeqlURL.startsWith("http")) {
|
if (codeqlURL && !codeqlURL.startsWith("http")) {
|
||||||
codeqlFolder = await toolcache.extractTar(codeqlURL, tempDir, logger);
|
codeqlFolder = await toolcache.extractTar(codeqlURL);
|
||||||
codeqlURLVersion = "local";
|
codeqlURLVersion = "local";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
codeqlURLVersion = getCodeQLURLVersion(codeqlURL || `/${CODEQL_BUNDLE_VERSION}/`);
|
codeqlURLVersion = getCodeQLURLVersion(codeqlURL || `/${CODEQL_BUNDLE_VERSION}/`);
|
||||||
const codeqlURLSemVer = convertToSemVer(codeqlURLVersion, logger);
|
const codeqlURLSemVer = convertToSemVer(codeqlURLVersion, logger);
|
||||||
// If we find the specified version, we always use that.
|
// If we find the specified version, we always use that.
|
||||||
codeqlFolder = toolcache.find("CodeQL", codeqlURLSemVer, toolCacheDir, logger);
|
codeqlFolder = toolcache.find("CodeQL", codeqlURLSemVer);
|
||||||
// If we don't find the requested version, in some cases we may allow a
|
// If we don't find the requested version, in some cases we may allow a
|
||||||
// different version to save download time if the version hasn't been
|
// different version to save download time if the version hasn't been
|
||||||
// specified explicitly (in which case we always honor it).
|
// specified explicitly (in which case we always honor it).
|
||||||
if (!codeqlFolder && !codeqlURL && !forceLatest) {
|
if (!codeqlFolder && !codeqlURL && !forceLatest) {
|
||||||
const codeqlVersions = toolcache.findAllVersions("CodeQL", toolCacheDir, logger);
|
const codeqlVersions = toolcache.findAllVersions("CodeQL");
|
||||||
if (codeqlVersions.length === 1 && (0, util_1.isGoodVersion)(codeqlVersions[0])) {
|
if (codeqlVersions.length === 1 && (0, util_1.isGoodVersion)(codeqlVersions[0])) {
|
||||||
const tmpCodeqlFolder = toolcache.find("CodeQL", codeqlVersions[0], toolCacheDir, logger);
|
const tmpCodeqlFolder = toolcache.find("CodeQL", codeqlVersions[0]);
|
||||||
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;
|
||||||
@@ -248,7 +256,9 @@ async function setupCodeQL(codeqlURL, apiDetails, tempDir, toolCacheDir, variant
|
|||||||
}
|
}
|
||||||
const parsedCodeQLURL = new URL(codeqlURL);
|
const parsedCodeQLURL = new URL(codeqlURL);
|
||||||
const parsedQueryString = query_string_1.default.parse(parsedCodeQLURL.search);
|
const parsedQueryString = query_string_1.default.parse(parsedCodeQLURL.search);
|
||||||
const headers = { accept: "application/octet-stream" };
|
const headers = {
|
||||||
|
accept: "application/octet-stream",
|
||||||
|
};
|
||||||
// We only want to provide an authorization header if we are downloading
|
// We only want to provide an authorization header if we are downloading
|
||||||
// from the same GitHub instance the Action is running on.
|
// from the same GitHub instance the Action is running on.
|
||||||
// This avoids leaking Enterprise tokens to dotcom.
|
// This avoids leaking Enterprise tokens to dotcom.
|
||||||
@@ -262,10 +272,12 @@ async function setupCodeQL(codeqlURL, apiDetails, tempDir, toolCacheDir, variant
|
|||||||
logger.debug("Downloading CodeQL bundle without token.");
|
logger.debug("Downloading CodeQL bundle without token.");
|
||||||
}
|
}
|
||||||
logger.info(`Downloading CodeQL tools from ${codeqlURL}. This may take a while.`);
|
logger.info(`Downloading CodeQL tools from ${codeqlURL}. This may take a while.`);
|
||||||
const codeqlPath = await toolcache.downloadTool(codeqlURL, tempDir, headers);
|
const dest = path.join(tempDir, (0, uuid_1.v4)());
|
||||||
|
const finalHeaders = Object.assign({ "User-Agent": "CodeQL Action" }, headers);
|
||||||
|
const codeqlPath = await toolcache.downloadTool(codeqlURL, dest, undefined, finalHeaders);
|
||||||
logger.debug(`CodeQL bundle download to ${codeqlPath} complete.`);
|
logger.debug(`CodeQL bundle download to ${codeqlPath} complete.`);
|
||||||
const codeqlExtracted = await toolcache.extractTar(codeqlPath, tempDir, logger);
|
const codeqlExtracted = await toolcache.extractTar(codeqlPath);
|
||||||
codeqlFolder = await toolcache.cacheDir(codeqlExtracted, "CodeQL", codeqlURLSemVer, toolCacheDir, logger);
|
codeqlFolder = await toolcache.cacheDir(codeqlExtracted, "CodeQL", codeqlURLSemVer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let codeqlCmd = path.join(codeqlFolder, "codeql", "codeql");
|
let codeqlCmd = path.join(codeqlFolder, "codeql", "codeql");
|
||||||
@@ -374,8 +386,8 @@ exports.getCachedCodeQL = getCachedCodeQL;
|
|||||||
* a non-existent placeholder codeql command, so tests that use this function
|
* a non-existent placeholder codeql command, so tests that use this function
|
||||||
* should also stub the toolrunner.ToolRunner constructor.
|
* should also stub the toolrunner.ToolRunner constructor.
|
||||||
*/
|
*/
|
||||||
async function getCodeQLForTesting() {
|
async function getCodeQLForTesting(cmd = "codeql-for-testing") {
|
||||||
return getCodeQLForCmd("codeql-for-testing", false);
|
return getCodeQLForCmd(cmd, false);
|
||||||
}
|
}
|
||||||
exports.getCodeQLForTesting = getCodeQLForTesting;
|
exports.getCodeQLForTesting = getCodeQLForTesting;
|
||||||
/**
|
/**
|
||||||
@@ -452,7 +464,7 @@ async function getCodeQLForCmd(cmd, checkVersion) {
|
|||||||
...getExtraOptionsFromEnv(["database", "init"]),
|
...getExtraOptionsFromEnv(["database", "init"]),
|
||||||
]);
|
]);
|
||||||
},
|
},
|
||||||
async databaseInitCluster(config, sourceRoot, processName, processLevel) {
|
async databaseInitCluster(config, sourceRoot, processName, processLevel, featureFlags) {
|
||||||
const extraArgs = config.languages.map((language) => `--language=${language}`);
|
const extraArgs = config.languages.map((language) => `--language=${language}`);
|
||||||
if (config.languages.filter(languages_1.isTracedLanguage).length > 0) {
|
if (config.languages.filter(languages_1.isTracedLanguage).length > 0) {
|
||||||
extraArgs.push("--begin-tracing");
|
extraArgs.push("--begin-tracing");
|
||||||
@@ -465,6 +477,14 @@ async function getCodeQLForCmd(cmd, checkVersion) {
|
|||||||
// because that always passes in a process name.
|
// because that always passes in a process name.
|
||||||
extraArgs.push(`--trace-process-level=${processLevel || 3}`);
|
extraArgs.push(`--trace-process-level=${processLevel || 3}`);
|
||||||
}
|
}
|
||||||
|
if (await util.codeQlVersionAbove(this, CODEQL_VERSION_LUA_TRACER_CONFIG)) {
|
||||||
|
if (await featureFlags.getValue(feature_flags_1.FeatureFlag.LuaTracerConfigEnabled)) {
|
||||||
|
extraArgs.push("--internal-use-lua-tracing");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
extraArgs.push("--no-internal-use-lua-tracing");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
await runTool(cmd, [
|
await runTool(cmd, [
|
||||||
"database",
|
"database",
|
||||||
@@ -490,9 +510,22 @@ async function getCodeQLForCmd(cmd, checkVersion) {
|
|||||||
"-Dhttp.keepAlive=false",
|
"-Dhttp.keepAlive=false",
|
||||||
"-Dmaven.wagon.http.pool=false",
|
"-Dmaven.wagon.http.pool=false",
|
||||||
].join(" ");
|
].join(" ");
|
||||||
|
// On macOS, System Integrity Protection (SIP) typically interferes with
|
||||||
|
// CodeQL build tracing of protected binaries.
|
||||||
|
// The usual workaround is to prefix `$CODEQL_RUNNER` to build commands:
|
||||||
|
// `$CODEQL_RUNNER` (not to be confused with the deprecated CodeQL Runner tool)
|
||||||
|
// points to a simple wrapper binary included with the CLI, and the extra layer of
|
||||||
|
// process indirection helps the tracer bypass SIP.
|
||||||
|
// The above SIP workaround is *not* needed here.
|
||||||
|
// At the `autobuild` step in the Actions workflow, we assume the `init` step
|
||||||
|
// has successfully run, and will have exported `DYLD_INSERT_LIBRARIES`
|
||||||
|
// into the environment of subsequent steps, to activate the tracer.
|
||||||
|
// When `DYLD_INSERT_LIBRARIES` is set in the environment for a step,
|
||||||
|
// the Actions runtime introduces its own workaround for SIP
|
||||||
|
// (https://github.com/actions/runner/pull/416).
|
||||||
await runTool(autobuildCmd);
|
await runTool(autobuildCmd);
|
||||||
},
|
},
|
||||||
async extractScannedLanguage(databasePath, language) {
|
async extractScannedLanguage(databasePath, language, featureFlags) {
|
||||||
// Get extractor location
|
// Get extractor location
|
||||||
let extractorPath = "";
|
let extractorPath = "";
|
||||||
await new toolrunner.ToolRunner(cmd, [
|
await new toolrunner.ToolRunner(cmd, [
|
||||||
@@ -515,10 +548,20 @@ async function getCodeQLForCmd(cmd, checkVersion) {
|
|||||||
// Set trace command
|
// Set trace command
|
||||||
const ext = process.platform === "win32" ? ".cmd" : ".sh";
|
const ext = process.platform === "win32" ? ".cmd" : ".sh";
|
||||||
const traceCommand = path.resolve(JSON.parse(extractorPath), "tools", `autobuild${ext}`);
|
const traceCommand = path.resolve(JSON.parse(extractorPath), "tools", `autobuild${ext}`);
|
||||||
|
const extraArgs = [];
|
||||||
|
if (await util.codeQlVersionAbove(this, CODEQL_VERSION_LUA_TRACER_CONFIG)) {
|
||||||
|
if (await featureFlags.getValue(feature_flags_1.FeatureFlag.LuaTracerConfigEnabled)) {
|
||||||
|
extraArgs.push("--internal-use-lua-tracing");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
extraArgs.push("--no-internal-use-lua-tracing");
|
||||||
|
}
|
||||||
|
}
|
||||||
// Run trace command
|
// Run trace command
|
||||||
await (0, toolrunner_error_catcher_1.toolrunnerErrorCatcher)(cmd, [
|
await (0, toolrunner_error_catcher_1.toolrunnerErrorCatcher)(cmd, [
|
||||||
"database",
|
"database",
|
||||||
"trace-command",
|
"trace-command",
|
||||||
|
...extraArgs,
|
||||||
...getExtraOptionsFromEnv(["database", "trace-command"]),
|
...getExtraOptionsFromEnv(["database", "trace-command"]),
|
||||||
databasePath,
|
databasePath,
|
||||||
"--",
|
"--",
|
||||||
@@ -589,13 +632,13 @@ async function getCodeQLForCmd(cmd, checkVersion) {
|
|||||||
codeqlArgs.push(querySuitePath);
|
codeqlArgs.push(querySuitePath);
|
||||||
await runTool(cmd, codeqlArgs);
|
await runTool(cmd, codeqlArgs);
|
||||||
},
|
},
|
||||||
async databaseInterpretResults(databasePath, querySuitePaths, sarifFile, addSnippetsFlag, threadsFlag, automationDetailsId) {
|
async databaseInterpretResults(databasePath, querySuitePaths, sarifFile, addSnippetsFlag, threadsFlag, verbosityFlag, automationDetailsId) {
|
||||||
const codeqlArgs = [
|
const codeqlArgs = [
|
||||||
"database",
|
"database",
|
||||||
"interpret-results",
|
"interpret-results",
|
||||||
threadsFlag,
|
threadsFlag,
|
||||||
"--format=sarif-latest",
|
"--format=sarif-latest",
|
||||||
"-v",
|
verbosityFlag,
|
||||||
`--output=${sarifFile}`,
|
`--output=${sarifFile}`,
|
||||||
addSnippetsFlag,
|
addSnippetsFlag,
|
||||||
...getExtraOptionsFromEnv(["database", "interpret-results"]),
|
...getExtraOptionsFromEnv(["database", "interpret-results"]),
|
||||||
@@ -641,8 +684,9 @@ async function getCodeQLForCmd(cmd, checkVersion) {
|
|||||||
"pack",
|
"pack",
|
||||||
"download",
|
"download",
|
||||||
"--format=json",
|
"--format=json",
|
||||||
|
"--resolve-query-specs",
|
||||||
...getExtraOptionsFromEnv(["pack", "download"]),
|
...getExtraOptionsFromEnv(["pack", "download"]),
|
||||||
...packs.map(packWithVersionToString),
|
...packs,
|
||||||
];
|
];
|
||||||
const output = await runTool(cmd, codeqlArgs);
|
const output = await runTool(cmd, codeqlArgs);
|
||||||
try {
|
try {
|
||||||
@@ -698,9 +742,6 @@ async function getCodeQLForCmd(cmd, checkVersion) {
|
|||||||
}
|
}
|
||||||
return codeql;
|
return codeql;
|
||||||
}
|
}
|
||||||
function packWithVersionToString(pack) {
|
|
||||||
return pack.version ? `${pack.packName}@${pack.version}` : pack.packName;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Gets the options for `path` of `options` as an array of extra option strings.
|
* Gets the options for `path` of `options` as an array of extra option strings.
|
||||||
*/
|
*/
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
76
lib/codeql.test.js
generated
76
lib/codeql.test.js
generated
@@ -22,6 +22,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.stubToolRunnerConstructor = void 0;
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
|
const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
|
||||||
const toolcache = __importStar(require("@actions/tool-cache"));
|
const toolcache = __importStar(require("@actions/tool-cache"));
|
||||||
@@ -30,6 +31,8 @@ const nock_1 = __importDefault(require("nock"));
|
|||||||
const sinon = __importStar(require("sinon"));
|
const sinon = __importStar(require("sinon"));
|
||||||
const codeql = __importStar(require("./codeql"));
|
const codeql = __importStar(require("./codeql"));
|
||||||
const defaults = __importStar(require("./defaults.json"));
|
const defaults = __importStar(require("./defaults.json"));
|
||||||
|
const feature_flags_1 = require("./feature-flags");
|
||||||
|
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");
|
||||||
const util = __importStar(require("./util"));
|
const util = __importStar(require("./util"));
|
||||||
@@ -55,7 +58,7 @@ ava_1.default.beforeEach(() => {
|
|||||||
(0, nock_1.default)("https://example.com")
|
(0, nock_1.default)("https://example.com")
|
||||||
.get(`/download/codeql-bundle-${version}/codeql-bundle.tar.gz`)
|
.get(`/download/codeql-bundle-${version}/codeql-bundle.tar.gz`)
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
||||||
await codeql.setupCodeQL(`https://example.com/download/codeql-bundle-${version}/codeql-bundle.tar.gz`, sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false);
|
await codeql.setupCodeQL(`https://example.com/download/codeql-bundle-${version}/codeql-bundle.tar.gz`, sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false);
|
||||||
t.assert(toolcache.find("CodeQL", `0.0.0-${version}`));
|
t.assert(toolcache.find("CodeQL", `0.0.0-${version}`));
|
||||||
}
|
}
|
||||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||||
@@ -68,12 +71,12 @@ ava_1.default.beforeEach(() => {
|
|||||||
(0, nock_1.default)("https://example.com")
|
(0, nock_1.default)("https://example.com")
|
||||||
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
|
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
|
||||||
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false);
|
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false);
|
||||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
||||||
(0, nock_1.default)("https://example.com")
|
(0, nock_1.default)("https://example.com")
|
||||||
.get(`/download/codeql-bundle-20200610/codeql-bundle.tar.gz`)
|
.get(`/download/codeql-bundle-20200610/codeql-bundle.tar.gz`)
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
||||||
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200610/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false);
|
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200610/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false);
|
||||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200610"));
|
t.assert(toolcache.find("CodeQL", "0.0.0-20200610"));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -83,9 +86,9 @@ ava_1.default.beforeEach(() => {
|
|||||||
(0, nock_1.default)("https://example.com")
|
(0, nock_1.default)("https://example.com")
|
||||||
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
|
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
|
||||||
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false);
|
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false);
|
||||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
||||||
await codeql.setupCodeQL(undefined, sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false);
|
await codeql.setupCodeQL(undefined, sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false);
|
||||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||||
t.is(cachedVersions.length, 1);
|
t.is(cachedVersions.length, 1);
|
||||||
});
|
});
|
||||||
@@ -96,7 +99,7 @@ ava_1.default.beforeEach(() => {
|
|||||||
(0, nock_1.default)("https://example.com")
|
(0, nock_1.default)("https://example.com")
|
||||||
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
||||||
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false);
|
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false);
|
||||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
||||||
const platform = process.platform === "win32"
|
const platform = process.platform === "win32"
|
||||||
? "win64"
|
? "win64"
|
||||||
@@ -106,7 +109,7 @@ ava_1.default.beforeEach(() => {
|
|||||||
(0, nock_1.default)("https://github.com")
|
(0, nock_1.default)("https://github.com")
|
||||||
.get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/codeql-bundle-${platform}.tar.gz`)
|
.get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/codeql-bundle-${platform}.tar.gz`)
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
||||||
await codeql.setupCodeQL(undefined, sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false);
|
await codeql.setupCodeQL(undefined, sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false);
|
||||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||||
t.is(cachedVersions.length, 2);
|
t.is(cachedVersions.length, 2);
|
||||||
});
|
});
|
||||||
@@ -117,7 +120,7 @@ ava_1.default.beforeEach(() => {
|
|||||||
(0, nock_1.default)("https://example.com")
|
(0, nock_1.default)("https://example.com")
|
||||||
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
|
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
|
||||||
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false);
|
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false);
|
||||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
||||||
const platform = process.platform === "win32"
|
const platform = process.platform === "win32"
|
||||||
? "win64"
|
? "win64"
|
||||||
@@ -127,7 +130,7 @@ ava_1.default.beforeEach(() => {
|
|||||||
(0, nock_1.default)("https://github.com")
|
(0, nock_1.default)("https://github.com")
|
||||||
.get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/codeql-bundle-${platform}.tar.gz`)
|
.get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/codeql-bundle-${platform}.tar.gz`)
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
||||||
await codeql.setupCodeQL("latest", sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false);
|
await codeql.setupCodeQL("latest", sampleApiDetails, tmpDir, util.GitHubVariant.DOTCOM, (0, logging_1.getRunnerLogger)(true), false);
|
||||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||||
t.is(cachedVersions.length, 2);
|
t.is(cachedVersions.length, 2);
|
||||||
});
|
});
|
||||||
@@ -155,7 +158,7 @@ ava_1.default.beforeEach(() => {
|
|||||||
(0, nock_1.default)("https://example.githubenterprise.com")
|
(0, nock_1.default)("https://example.githubenterprise.com")
|
||||||
.get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/${codeQLBundleName}`)
|
.get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/${codeQLBundleName}`)
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
|
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
|
||||||
await codeql.setupCodeQL(undefined, sampleGHAEApiDetails, tmpDir, tmpDir, util.GitHubVariant.GHAE, (0, logging_1.getRunnerLogger)(true), false);
|
await codeql.setupCodeQL(undefined, sampleGHAEApiDetails, tmpDir, util.GitHubVariant.GHAE, (0, logging_1.getRunnerLogger)(true), false);
|
||||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||||
t.is(cachedVersions.length, 1);
|
t.is(cachedVersions.length, 1);
|
||||||
});
|
});
|
||||||
@@ -223,16 +226,64 @@ ava_1.default.beforeEach(() => {
|
|||||||
const runnerConstructorStub = stubToolRunnerConstructor();
|
const runnerConstructorStub = stubToolRunnerConstructor();
|
||||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||||
sinon.stub(codeqlObject, "getVersion").resolves("2.7.0");
|
sinon.stub(codeqlObject, "getVersion").resolves("2.7.0");
|
||||||
await codeqlObject.databaseInterpretResults("", [], "", "", "", "");
|
await codeqlObject.databaseInterpretResults("", [], "", "", "", "-v", "");
|
||||||
t.false(runnerConstructorStub.firstCall.args[1].includes("--sarif-add-query-help"), "--sarif-add-query-help should be absent, but it is present");
|
t.false(runnerConstructorStub.firstCall.args[1].includes("--sarif-add-query-help"), "--sarif-add-query-help should be absent, but it is present");
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("databaseInterpretResults() sets --sarif-add-query-help for 2.7.1", async (t) => {
|
(0, ava_1.default)("databaseInterpretResults() sets --sarif-add-query-help for 2.7.1", async (t) => {
|
||||||
const runnerConstructorStub = stubToolRunnerConstructor();
|
const runnerConstructorStub = stubToolRunnerConstructor();
|
||||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||||
sinon.stub(codeqlObject, "getVersion").resolves("2.7.1");
|
sinon.stub(codeqlObject, "getVersion").resolves("2.7.1");
|
||||||
await codeqlObject.databaseInterpretResults("", [], "", "", "", "");
|
await codeqlObject.databaseInterpretResults("", [], "", "", "", "-v", "");
|
||||||
t.true(runnerConstructorStub.firstCall.args[1].includes("--sarif-add-query-help"), "--sarif-add-query-help should be present, but it is absent");
|
t.true(runnerConstructorStub.firstCall.args[1].includes("--sarif-add-query-help"), "--sarif-add-query-help should be present, but it is absent");
|
||||||
});
|
});
|
||||||
|
const stubConfig = {
|
||||||
|
languages: [languages_1.Language.cpp],
|
||||||
|
queries: {},
|
||||||
|
pathsIgnore: [],
|
||||||
|
paths: [],
|
||||||
|
originalUserInput: {},
|
||||||
|
tempDir: "",
|
||||||
|
codeQLCmd: "",
|
||||||
|
gitHubVersion: {
|
||||||
|
type: util.GitHubVariant.DOTCOM,
|
||||||
|
},
|
||||||
|
dbLocation: "",
|
||||||
|
packs: {},
|
||||||
|
debugMode: false,
|
||||||
|
debugArtifactName: util.DEFAULT_DEBUG_ARTIFACT_NAME,
|
||||||
|
debugDatabaseName: util.DEFAULT_DEBUG_DATABASE_NAME,
|
||||||
|
injectedMlQueries: false,
|
||||||
|
};
|
||||||
|
(0, ava_1.default)("databaseInitCluster() Lua feature flag enabled, but old CLI", async (t) => {
|
||||||
|
const runnerConstructorStub = stubToolRunnerConstructor();
|
||||||
|
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||||
|
sinon.stub(codeqlObject, "getVersion").resolves("2.9.0");
|
||||||
|
await codeqlObject.databaseInitCluster(stubConfig, "", undefined, undefined, (0, feature_flags_1.createFeatureFlags)([feature_flags_1.FeatureFlag.LuaTracerConfigEnabled]));
|
||||||
|
t.false(runnerConstructorStub.firstCall.args[1].includes("--internal-use-lua-tracing"), "--internal-use-lua-tracing should be absent, but it is present");
|
||||||
|
t.false(runnerConstructorStub.firstCall.args[1].includes("--no-internal-use-lua-tracing"), "--no-internal-use-lua-tracing should be absent, but it is present");
|
||||||
|
});
|
||||||
|
(0, ava_1.default)("databaseInitCluster() Lua feature flag disabled, with old CLI", async (t) => {
|
||||||
|
const runnerConstructorStub = stubToolRunnerConstructor();
|
||||||
|
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||||
|
sinon.stub(codeqlObject, "getVersion").resolves("2.9.0");
|
||||||
|
await codeqlObject.databaseInitCluster(stubConfig, "", undefined, undefined, (0, feature_flags_1.createFeatureFlags)([]));
|
||||||
|
t.false(runnerConstructorStub.firstCall.args[1].includes("--internal-use-lua-tracing"), "--internal-use-lua-tracing should be absent, but it is present");
|
||||||
|
t.false(runnerConstructorStub.firstCall.args[1].includes("--no-internal-use-lua-tracing"), "--no-internal-use-lua-tracing should be absent, but it is present");
|
||||||
|
});
|
||||||
|
(0, ava_1.default)("databaseInitCluster() Lua feature flag enabled, compatible CLI", async (t) => {
|
||||||
|
const runnerConstructorStub = stubToolRunnerConstructor();
|
||||||
|
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||||
|
sinon.stub(codeqlObject, "getVersion").resolves("2.10.0");
|
||||||
|
await codeqlObject.databaseInitCluster(stubConfig, "", undefined, undefined, (0, feature_flags_1.createFeatureFlags)([feature_flags_1.FeatureFlag.LuaTracerConfigEnabled]));
|
||||||
|
t.true(runnerConstructorStub.firstCall.args[1].includes("--internal-use-lua-tracing"), "--internal-use-lua-tracing should be present, but it is absent");
|
||||||
|
});
|
||||||
|
(0, ava_1.default)("databaseInitCluster() Lua feature flag disabled, compatible CLI", async (t) => {
|
||||||
|
const runnerConstructorStub = stubToolRunnerConstructor();
|
||||||
|
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||||
|
sinon.stub(codeqlObject, "getVersion").resolves("2.10.0");
|
||||||
|
await codeqlObject.databaseInitCluster(stubConfig, "", undefined, undefined, (0, feature_flags_1.createFeatureFlags)([]));
|
||||||
|
t.true(runnerConstructorStub.firstCall.args[1].includes("--no-internal-use-lua-tracing"), "--no-internal-use-lua-tracing should be present, but it is absent");
|
||||||
|
});
|
||||||
function stubToolRunnerConstructor() {
|
function stubToolRunnerConstructor() {
|
||||||
const runnerObjectStub = sinon.createStubInstance(toolrunner.ToolRunner);
|
const runnerObjectStub = sinon.createStubInstance(toolrunner.ToolRunner);
|
||||||
runnerObjectStub.exec.resolves(0);
|
runnerObjectStub.exec.resolves(0);
|
||||||
@@ -240,4 +291,5 @@ function stubToolRunnerConstructor() {
|
|||||||
runnerConstructorStub.returns(runnerObjectStub);
|
runnerConstructorStub.returns(runnerObjectStub);
|
||||||
return runnerConstructorStub;
|
return runnerConstructorStub;
|
||||||
}
|
}
|
||||||
|
exports.stubToolRunnerConstructor = stubToolRunnerConstructor;
|
||||||
//# sourceMappingURL=codeql.test.js.map
|
//# sourceMappingURL=codeql.test.js.map
|
||||||
File diff suppressed because one or more lines are too long
123
lib/config-utils.js
generated
123
lib/config-utils.js
generated
@@ -19,7 +19,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.getConfig = exports.getPathToParsedConfigFile = exports.initConfig = exports.parsePacks = exports.parsePacksFromConfig = exports.getDefaultConfig = exports.getUnknownLanguagesError = exports.getNoLanguagesError = exports.getConfigFileDirectoryGivenMessage = exports.getConfigFileFormatInvalidMessage = exports.getConfigFileRepoFormatInvalidMessage = exports.getConfigFileDoesNotExistErrorMessage = exports.getConfigFileOutsideWorkspaceErrorMessage = exports.getLocalPathDoesNotExist = exports.getLocalPathOutsideOfRepository = exports.getPacksStrInvalid = exports.getPacksInvalid = exports.getPacksInvalidSplit = exports.getPacksRequireLanguage = exports.getPathsInvalid = exports.getPathsIgnoreInvalid = exports.getQueryUsesInvalid = exports.getQueriesInvalid = exports.getDisableDefaultQueriesInvalid = exports.getNameInvalid = exports.validateAndSanitisePath = void 0;
|
exports.getConfig = exports.getPathToParsedConfigFile = exports.initConfig = exports.parsePacks = exports.validatePacksSpecification = exports.parsePacksFromConfig = exports.getDefaultConfig = exports.getUnknownLanguagesError = exports.getNoLanguagesError = exports.getConfigFileDirectoryGivenMessage = exports.getConfigFileFormatInvalidMessage = exports.getConfigFileRepoFormatInvalidMessage = exports.getConfigFileDoesNotExistErrorMessage = exports.getConfigFileOutsideWorkspaceErrorMessage = exports.getLocalPathDoesNotExist = exports.getLocalPathOutsideOfRepository = exports.getPacksStrInvalid = exports.getPacksInvalid = exports.getPacksInvalidSplit = exports.getPathsInvalid = exports.getPathsIgnoreInvalid = exports.getQueryUsesInvalid = exports.getQueriesInvalid = exports.getDisableDefaultQueriesInvalid = exports.getNameInvalid = exports.validateAndSanitisePath = void 0;
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const yaml = __importStar(require("js-yaml"));
|
const yaml = __importStar(require("js-yaml"));
|
||||||
@@ -131,11 +131,12 @@ async function addBuiltinSuiteQueries(languages, codeQL, resultMap, packs, suite
|
|||||||
// opted into the ML-powered queries beta, and a user hasn't already added the ML-powered query
|
// opted into the ML-powered queries beta, and a user hasn't already added the ML-powered query
|
||||||
// pack, then add the ML-powered query pack so that we run ML-powered queries.
|
// pack, then add the ML-powered query pack so that we run ML-powered queries.
|
||||||
if (
|
if (
|
||||||
// Disable ML-powered queries on Windows
|
// Only run ML-powered queries on Windows if we have a CLI that supports it.
|
||||||
process.platform !== "win32" &&
|
(process.platform !== "win32" ||
|
||||||
|
(await (0, util_1.codeQlVersionAbove)(codeQL, codeql_1.CODEQL_VERSION_ML_POWERED_QUERIES_WINDOWS))) &&
|
||||||
languages.includes("javascript") &&
|
languages.includes("javascript") &&
|
||||||
(found === "security-extended" || found === "security-and-quality") &&
|
(found === "security-extended" || found === "security-and-quality") &&
|
||||||
!((_a = packs.javascript) === null || _a === void 0 ? void 0 : _a.some((pack) => pack.packName === util_1.ML_POWERED_JS_QUERIES_PACK_NAME)) &&
|
!((_a = packs.javascript) === null || _a === void 0 ? void 0 : _a.some(isMlPoweredJsQueriesPack)) &&
|
||||||
(await featureFlags.getValue(feature_flags_1.FeatureFlag.MlPoweredQueriesEnabled)) &&
|
(await featureFlags.getValue(feature_flags_1.FeatureFlag.MlPoweredQueriesEnabled)) &&
|
||||||
(await (0, util_1.codeQlVersionAbove)(codeQL, codeql_1.CODEQL_VERSION_ML_POWERED_QUERIES))) {
|
(await (0, util_1.codeQlVersionAbove)(codeQL, codeql_1.CODEQL_VERSION_ML_POWERED_QUERIES))) {
|
||||||
if (!packs.javascript) {
|
if (!packs.javascript) {
|
||||||
@@ -148,6 +149,11 @@ async function addBuiltinSuiteQueries(languages, codeQL, resultMap, packs, suite
|
|||||||
await runResolveQueries(codeQL, resultMap, suites, undefined);
|
await runResolveQueries(codeQL, resultMap, suites, undefined);
|
||||||
return injectedMlQueries;
|
return injectedMlQueries;
|
||||||
}
|
}
|
||||||
|
function isMlPoweredJsQueriesPack(pack) {
|
||||||
|
return (pack === util_1.ML_POWERED_JS_QUERIES_PACK_NAME ||
|
||||||
|
pack.startsWith(`${util_1.ML_POWERED_JS_QUERIES_PACK_NAME}@`) ||
|
||||||
|
pack.startsWith(`${util_1.ML_POWERED_JS_QUERIES_PACK_NAME}:`));
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Retrieve the set of queries at localQueryPath and add them to resultMap.
|
* Retrieve the set of queries at localQueryPath and add them to resultMap.
|
||||||
*/
|
*/
|
||||||
@@ -300,9 +306,8 @@ function getPathsInvalid(configFile) {
|
|||||||
}
|
}
|
||||||
exports.getPathsInvalid = getPathsInvalid;
|
exports.getPathsInvalid = getPathsInvalid;
|
||||||
function getPacksRequireLanguage(lang, configFile) {
|
function getPacksRequireLanguage(lang, configFile) {
|
||||||
return getConfigFilePropertyError(configFile, PACKS_PROPERTY, `has "${lang}", but it is not one of the languages to analyze`);
|
return getConfigFilePropertyError(configFile, PACKS_PROPERTY, `has "${lang}", but it is not a valid language.`);
|
||||||
}
|
}
|
||||||
exports.getPacksRequireLanguage = getPacksRequireLanguage;
|
|
||||||
function getPacksInvalidSplit(configFile) {
|
function getPacksInvalidSplit(configFile) {
|
||||||
return getConfigFilePropertyError(configFile, PACKS_PROPERTY, "must split packages by language");
|
return getConfigFilePropertyError(configFile, PACKS_PROPERTY, "must split packages by language");
|
||||||
}
|
}
|
||||||
@@ -457,7 +462,7 @@ function shouldAddConfigFileQueries(queriesInput) {
|
|||||||
/**
|
/**
|
||||||
* Get the default config for when the user has not supplied one.
|
* Get the default config for when the user has not supplied one.
|
||||||
*/
|
*/
|
||||||
async function getDefaultConfig(languagesInput, queriesInput, packsInput, dbLocation, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger) {
|
async function getDefaultConfig(languagesInput, queriesInput, packsInput, dbLocation, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger) {
|
||||||
var _a;
|
var _a;
|
||||||
const languages = await getLanguages(codeQL, languagesInput, repository, apiDetails, logger);
|
const languages = await getLanguages(codeQL, languagesInput, repository, apiDetails, logger);
|
||||||
const queries = {};
|
const queries = {};
|
||||||
@@ -481,7 +486,6 @@ async function getDefaultConfig(languagesInput, queriesInput, packsInput, dbLoca
|
|||||||
packs,
|
packs,
|
||||||
originalUserInput: {},
|
originalUserInput: {},
|
||||||
tempDir,
|
tempDir,
|
||||||
toolCacheDir,
|
|
||||||
codeQLCmd: codeQL.getPath(),
|
codeQLCmd: codeQL.getPath(),
|
||||||
gitHubVersion,
|
gitHubVersion,
|
||||||
dbLocation: dbLocationOrDefault(dbLocation, tempDir),
|
dbLocation: dbLocationOrDefault(dbLocation, tempDir),
|
||||||
@@ -495,7 +499,7 @@ exports.getDefaultConfig = getDefaultConfig;
|
|||||||
/**
|
/**
|
||||||
* Load the config from the given file.
|
* Load the config from the given file.
|
||||||
*/
|
*/
|
||||||
async function loadConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger) {
|
async function loadConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger) {
|
||||||
var _a;
|
var _a;
|
||||||
let parsedYAML;
|
let parsedYAML;
|
||||||
if (isLocal(configFile)) {
|
if (isLocal(configFile)) {
|
||||||
@@ -536,7 +540,7 @@ async function loadConfig(languagesInput, queriesInput, packsInput, configFile,
|
|||||||
if (!disableDefaultQueries) {
|
if (!disableDefaultQueries) {
|
||||||
await addDefaultQueries(codeQL, languages, queries);
|
await addDefaultQueries(codeQL, languages, queries);
|
||||||
}
|
}
|
||||||
const packs = parsePacks((_a = parsedYAML[PACKS_PROPERTY]) !== null && _a !== void 0 ? _a : {}, packsInput, languages, configFile);
|
const packs = parsePacks((_a = parsedYAML[PACKS_PROPERTY]) !== null && _a !== void 0 ? _a : {}, packsInput, languages, configFile, logger);
|
||||||
// If queries were provided using `with` in the action configuration,
|
// If queries were provided using `with` in the action configuration,
|
||||||
// they should take precedence over the queries in the config file
|
// they should take precedence over the queries in the config file
|
||||||
// unless they're prefixed with "+", in which case they supplement those
|
// unless they're prefixed with "+", in which case they supplement those
|
||||||
@@ -589,7 +593,6 @@ async function loadConfig(languagesInput, queriesInput, packsInput, configFile,
|
|||||||
packs,
|
packs,
|
||||||
originalUserInput: parsedYAML,
|
originalUserInput: parsedYAML,
|
||||||
tempDir,
|
tempDir,
|
||||||
toolCacheDir,
|
|
||||||
codeQLCmd: codeQL.getPath(),
|
codeQLCmd: codeQL.getPath(),
|
||||||
gitHubVersion,
|
gitHubVersion,
|
||||||
dbLocation: dbLocationOrDefault(dbLocation, tempDir),
|
dbLocation: dbLocationOrDefault(dbLocation, tempDir),
|
||||||
@@ -610,7 +613,7 @@ const PACK_IDENTIFIER_PATTERN = (function () {
|
|||||||
return new RegExp(`^${component}/${component}$`);
|
return new RegExp(`^${component}/${component}$`);
|
||||||
})();
|
})();
|
||||||
// Exported for testing
|
// Exported for testing
|
||||||
function parsePacksFromConfig(packsByLanguage, languages, configFile) {
|
function parsePacksFromConfig(packsByLanguage, languages, configFile, logger) {
|
||||||
const packs = {};
|
const packs = {};
|
||||||
if (Array.isArray(packsByLanguage)) {
|
if (Array.isArray(packsByLanguage)) {
|
||||||
if (languages.length === 1) {
|
if (languages.length === 1) {
|
||||||
@@ -630,11 +633,19 @@ function parsePacksFromConfig(packsByLanguage, languages, configFile) {
|
|||||||
throw new Error(getPacksInvalid(configFile));
|
throw new Error(getPacksInvalid(configFile));
|
||||||
}
|
}
|
||||||
if (!languages.includes(lang)) {
|
if (!languages.includes(lang)) {
|
||||||
throw new Error(getPacksRequireLanguage(lang, configFile));
|
// This particular language is not being analyzed in this run.
|
||||||
|
if (languages_1.Language[lang]) {
|
||||||
|
logger.info(`Ignoring packs for ${lang} since this language is not being analyzed in this run.`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// This language is invalid, probably a misspelling
|
||||||
|
throw new Error(getPacksRequireLanguage(configFile, lang));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
packs[lang] = [];
|
packs[lang] = [];
|
||||||
for (const packStr of packsArr) {
|
for (const packStr of packsArr) {
|
||||||
packs[lang].push(toPackWithVersion(packStr, configFile));
|
packs[lang].push(validatePacksSpecification(packStr, configFile));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return packs;
|
return packs;
|
||||||
@@ -659,36 +670,84 @@ function parsePacksFromInput(packsInput, languages) {
|
|||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
[languages[0]]: packsInput.split(",").reduce((packs, pack) => {
|
[languages[0]]: packsInput.split(",").reduce((packs, pack) => {
|
||||||
packs.push(toPackWithVersion(pack, ""));
|
packs.push(validatePacksSpecification(pack, ""));
|
||||||
return packs;
|
return packs;
|
||||||
}, []),
|
}, []),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
function toPackWithVersion(packStr, configFile) {
|
/**
|
||||||
|
* Validates that this package specification is syntactically correct.
|
||||||
|
* It may not point to any real package, but after this function returns
|
||||||
|
* without throwing, we are guaranteed that the package specification
|
||||||
|
* is roughly correct.
|
||||||
|
*
|
||||||
|
* The CLI itself will do a more thorough validation of the package
|
||||||
|
* specification.
|
||||||
|
*
|
||||||
|
* A package specification looks like this:
|
||||||
|
*
|
||||||
|
* `scope/name@version:path`
|
||||||
|
*
|
||||||
|
* Version and path are optional.
|
||||||
|
*
|
||||||
|
* @param packStr the package specification to verify.
|
||||||
|
* @param configFile Config file to use for error reporting
|
||||||
|
*/
|
||||||
|
function validatePacksSpecification(packStr, configFile) {
|
||||||
if (typeof packStr !== "string") {
|
if (typeof packStr !== "string") {
|
||||||
throw new Error(getPacksStrInvalid(packStr, configFile));
|
throw new Error(getPacksStrInvalid(packStr, configFile));
|
||||||
}
|
}
|
||||||
const nameWithVersion = packStr.trim().split("@");
|
packStr = packStr.trim();
|
||||||
let version;
|
const atIndex = packStr.indexOf("@");
|
||||||
if (nameWithVersion.length > 2 ||
|
const colonIndex = packStr.indexOf(":", atIndex);
|
||||||
!PACK_IDENTIFIER_PATTERN.test(nameWithVersion[0])) {
|
const packStart = 0;
|
||||||
|
const versionStart = atIndex + 1 || undefined;
|
||||||
|
const pathStart = colonIndex + 1 || undefined;
|
||||||
|
const packEnd = Math.min(atIndex > 0 ? atIndex : Infinity, colonIndex > 0 ? colonIndex : Infinity, packStr.length);
|
||||||
|
const versionEnd = versionStart
|
||||||
|
? Math.min(colonIndex > 0 ? colonIndex : Infinity, packStr.length)
|
||||||
|
: undefined;
|
||||||
|
const pathEnd = pathStart ? packStr.length : undefined;
|
||||||
|
const packName = packStr.slice(packStart, packEnd).trim();
|
||||||
|
const version = versionStart
|
||||||
|
? packStr.slice(versionStart, versionEnd).trim()
|
||||||
|
: undefined;
|
||||||
|
const packPath = pathStart
|
||||||
|
? packStr.slice(pathStart, pathEnd).trim()
|
||||||
|
: undefined;
|
||||||
|
if (!PACK_IDENTIFIER_PATTERN.test(packName)) {
|
||||||
throw new Error(getPacksStrInvalid(packStr, configFile));
|
throw new Error(getPacksStrInvalid(packStr, configFile));
|
||||||
}
|
}
|
||||||
else if (nameWithVersion.length === 2) {
|
if (version) {
|
||||||
version = semver.clean(nameWithVersion[1]) || undefined;
|
try {
|
||||||
if (!version) {
|
new semver.Range(version);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
// The range string is invalid. OK to ignore the caught error
|
||||||
throw new Error(getPacksStrInvalid(packStr, configFile));
|
throw new Error(getPacksStrInvalid(packStr, configFile));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {
|
if (packPath &&
|
||||||
packName: nameWithVersion[0].trim(),
|
(path.isAbsolute(packPath) ||
|
||||||
version,
|
// Permit using "/" instead of "\" on Windows
|
||||||
};
|
// Use `x.split(y).join(z)` as a polyfill for `x.replaceAll(y, z)` since
|
||||||
|
// if we used a regex we'd need to escape the path separator on Windows
|
||||||
|
// which seems more awkward.
|
||||||
|
path.normalize(packPath).split(path.sep).join("/") !==
|
||||||
|
packPath.split(path.sep).join("/"))) {
|
||||||
|
throw new Error(getPacksStrInvalid(packStr, configFile));
|
||||||
|
}
|
||||||
|
if (!packPath && pathStart) {
|
||||||
|
// 0 length path
|
||||||
|
throw new Error(getPacksStrInvalid(packStr, configFile));
|
||||||
|
}
|
||||||
|
return (packName + (version ? `@${version}` : "") + (packPath ? `:${packPath}` : ""));
|
||||||
}
|
}
|
||||||
|
exports.validatePacksSpecification = validatePacksSpecification;
|
||||||
// exported for testing
|
// exported for testing
|
||||||
function parsePacks(rawPacksFromConfig, rawPacksInput, languages, configFile) {
|
function parsePacks(rawPacksFromConfig, rawPacksInput, languages, configFile, logger) {
|
||||||
const packsFromInput = parsePacksFromInput(rawPacksInput, languages);
|
const packsFromInput = parsePacksFromInput(rawPacksInput, languages);
|
||||||
const packsFomConfig = parsePacksFromConfig(rawPacksFromConfig, languages, configFile);
|
const packsFomConfig = parsePacksFromConfig(rawPacksFromConfig, languages, configFile, logger);
|
||||||
if (!packsFromInput) {
|
if (!packsFromInput) {
|
||||||
return packsFomConfig;
|
return packsFomConfig;
|
||||||
}
|
}
|
||||||
@@ -722,16 +781,16 @@ function dbLocationOrDefault(dbLocation, tempDir) {
|
|||||||
* This will parse the config from the user input if present, or generate
|
* This will parse the config from the user input if present, or generate
|
||||||
* a default config. The parsed config is then stored to a known location.
|
* a default config. The parsed config is then stored to a known location.
|
||||||
*/
|
*/
|
||||||
async function initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger) {
|
async function initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger) {
|
||||||
var _a, _b, _c;
|
var _a, _b, _c;
|
||||||
let config;
|
let config;
|
||||||
// If no config file was provided create an empty one
|
// If no config file was provided create an empty one
|
||||||
if (!configFile) {
|
if (!configFile) {
|
||||||
logger.debug("No configuration file was provided");
|
logger.debug("No configuration file was provided");
|
||||||
config = await getDefaultConfig(languagesInput, queriesInput, packsInput, dbLocation, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger);
|
config = await getDefaultConfig(languagesInput, queriesInput, packsInput, dbLocation, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
config = await loadConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger);
|
config = await loadConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger);
|
||||||
}
|
}
|
||||||
// The list of queries should not be empty for any language. If it is then
|
// The list of queries should not be empty for any language. If it is then
|
||||||
// it is a user configuration error.
|
// it is a user configuration error.
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
247
lib/config-utils.test.js
generated
247
lib/config-utils.test.js
generated
@@ -26,7 +26,6 @@ const fs = __importStar(require("fs"));
|
|||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const github = __importStar(require("@actions/github"));
|
const github = __importStar(require("@actions/github"));
|
||||||
const ava_1 = __importDefault(require("ava"));
|
const ava_1 = __importDefault(require("ava"));
|
||||||
const semver_1 = require("semver");
|
|
||||||
const sinon = __importStar(require("sinon"));
|
const sinon = __importStar(require("sinon"));
|
||||||
const api = __importStar(require("./api-client"));
|
const api = __importStar(require("./api-client"));
|
||||||
const codeql_1 = require("./codeql");
|
const codeql_1 = require("./codeql");
|
||||||
@@ -89,8 +88,8 @@ function mockListLanguages(languages) {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const config = await configUtils.initConfig(languages, undefined, undefined, undefined, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), logger);
|
const config = await configUtils.initConfig(languages, undefined, undefined, undefined, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), logger);
|
||||||
t.deepEqual(config, await configUtils.getDefaultConfig(languages, undefined, undefined, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), logger));
|
t.deepEqual(config, await configUtils.getDefaultConfig(languages, undefined, undefined, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), logger));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("loading config saves config", async (t) => {
|
(0, ava_1.default)("loading config saves config", async (t) => {
|
||||||
@@ -112,7 +111,7 @@ function mockListLanguages(languages) {
|
|||||||
t.false(fs.existsSync(configUtils.getPathToParsedConfigFile(tmpDir)));
|
t.false(fs.existsSync(configUtils.getPathToParsedConfigFile(tmpDir)));
|
||||||
// Sanity check that getConfig returns undefined before we have called initConfig
|
// Sanity check that getConfig returns undefined before we have called initConfig
|
||||||
t.deepEqual(await configUtils.getConfig(tmpDir, logger), undefined);
|
t.deepEqual(await configUtils.getConfig(tmpDir, logger), undefined);
|
||||||
const config1 = await configUtils.initConfig("javascript,python", undefined, undefined, undefined, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), logger);
|
const config1 = await configUtils.initConfig("javascript,python", undefined, undefined, undefined, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), logger);
|
||||||
// The saved config file should now exist
|
// The saved config file should now exist
|
||||||
t.true(fs.existsSync(configUtils.getPathToParsedConfigFile(tmpDir)));
|
t.true(fs.existsSync(configUtils.getPathToParsedConfigFile(tmpDir)));
|
||||||
// And that same newly-initialised config should now be returned by getConfig
|
// And that same newly-initialised config should now be returned by getConfig
|
||||||
@@ -126,7 +125,7 @@ function mockListLanguages(languages) {
|
|||||||
(0, ava_1.default)("load input outside of workspace", async (t) => {
|
(0, ava_1.default)("load input outside of workspace", async (t) => {
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(undefined, undefined, undefined, "../input", undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
|
await configUtils.initConfig(undefined, undefined, undefined, "../input", undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -139,7 +138,7 @@ function mockListLanguages(languages) {
|
|||||||
// no filename given, just a repo
|
// no filename given, just a repo
|
||||||
const configFile = "octo-org/codeql-config@main";
|
const configFile = "octo-org/codeql-config@main";
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(undefined, undefined, undefined, configFile, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
|
await configUtils.initConfig(undefined, undefined, undefined, configFile, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -153,7 +152,7 @@ function mockListLanguages(languages) {
|
|||||||
const configFile = "input";
|
const configFile = "input";
|
||||||
t.false(fs.existsSync(path.join(tmpDir, configFile)));
|
t.false(fs.existsSync(path.join(tmpDir, configFile)));
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
|
await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -213,7 +212,6 @@ function mockListLanguages(languages) {
|
|||||||
paths: ["c/d"],
|
paths: ["c/d"],
|
||||||
},
|
},
|
||||||
tempDir: tmpDir,
|
tempDir: tmpDir,
|
||||||
toolCacheDir: tmpDir,
|
|
||||||
codeQLCmd: codeQL.getPath(),
|
codeQLCmd: codeQL.getPath(),
|
||||||
gitHubVersion,
|
gitHubVersion,
|
||||||
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
||||||
@@ -225,7 +223,7 @@ function mockListLanguages(languages) {
|
|||||||
};
|
};
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const configFilePath = createConfigFile(inputFileContents, tmpDir);
|
const configFilePath = createConfigFile(inputFileContents, tmpDir);
|
||||||
const actualConfig = await configUtils.initConfig(languages, undefined, undefined, configFilePath, undefined, false, "my-artifact", "my-db", { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
|
const actualConfig = await configUtils.initConfig(languages, undefined, undefined, configFilePath, undefined, false, "my-artifact", "my-db", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
|
||||||
// Should exactly equal the object we constructed earlier
|
// Should exactly equal the object we constructed earlier
|
||||||
t.deepEqual(actualConfig, expectedConfig);
|
t.deepEqual(actualConfig, expectedConfig);
|
||||||
});
|
});
|
||||||
@@ -261,7 +259,7 @@ function mockListLanguages(languages) {
|
|||||||
fs.mkdirSync(path.join(tmpDir, "foo"));
|
fs.mkdirSync(path.join(tmpDir, "foo"));
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const configFilePath = createConfigFile(inputFileContents, tmpDir);
|
const configFilePath = createConfigFile(inputFileContents, tmpDir);
|
||||||
await configUtils.initConfig(languages, undefined, undefined, configFilePath, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
|
await configUtils.initConfig(languages, undefined, undefined, configFilePath, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
|
||||||
// Check resolve queries was called correctly
|
// Check resolve queries was called correctly
|
||||||
t.deepEqual(resolveQueriesArgs.length, 1);
|
t.deepEqual(resolveQueriesArgs.length, 1);
|
||||||
t.deepEqual(resolveQueriesArgs[0].queries, [
|
t.deepEqual(resolveQueriesArgs[0].queries, [
|
||||||
@@ -304,18 +302,18 @@ function queriesToResolvedQueryForm(queries) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const config = await configUtils.initConfig(languages, undefined, undefined, configFilePath, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
|
const config = await configUtils.initConfig(languages, undefined, undefined, configFilePath, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
|
||||||
// Check resolveQueries was called correctly
|
// Check resolveQueries was called correctly
|
||||||
// It'll be called once for the default queries
|
// It'll be called once for the default queries
|
||||||
// and once for `./foo` from the config file.
|
// and once for `./foo` from the config file.
|
||||||
t.deepEqual(resolveQueriesArgs.length, 2);
|
t.deepEqual(resolveQueriesArgs.length, 2);
|
||||||
t.deepEqual(resolveQueriesArgs[1].queries.length, 1);
|
t.deepEqual(resolveQueriesArgs[1].queries.length, 1);
|
||||||
t.regex(resolveQueriesArgs[1].queries[0], /.*\/foo$/);
|
t.true(resolveQueriesArgs[1].queries[0].endsWith(`${path.sep}foo`));
|
||||||
// Now check that the end result contains the default queries and the query from config
|
// Now check that the end result contains the default queries and the query from config
|
||||||
t.deepEqual(config.queries["javascript"].builtin.length, 1);
|
t.deepEqual(config.queries["javascript"].builtin.length, 1);
|
||||||
t.deepEqual(config.queries["javascript"].custom.length, 1);
|
t.deepEqual(config.queries["javascript"].custom.length, 1);
|
||||||
t.regex(config.queries["javascript"].builtin[0], /javascript-code-scanning.qls$/);
|
t.true(config.queries["javascript"].builtin[0].endsWith("javascript-code-scanning.qls"));
|
||||||
t.regex(config.queries["javascript"].custom[0].queries[0], /.*\/foo$/);
|
t.true(config.queries["javascript"].custom[0].queries[0].endsWith(`${path.sep}foo`));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("Queries from config file can be overridden in workflow file", async (t) => {
|
(0, ava_1.default)("Queries from config file can be overridden in workflow file", async (t) => {
|
||||||
@@ -337,18 +335,18 @@ function queriesToResolvedQueryForm(queries) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const config = await configUtils.initConfig(languages, testQueries, undefined, configFilePath, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
|
const config = await configUtils.initConfig(languages, testQueries, undefined, configFilePath, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
|
||||||
// Check resolveQueries was called correctly
|
// Check resolveQueries was called correctly
|
||||||
// It'll be called once for the default queries and once for `./override`,
|
// It'll be called once for the default queries and once for `./override`,
|
||||||
// but won't be called for './foo' from the config file.
|
// but won't be called for './foo' from the config file.
|
||||||
t.deepEqual(resolveQueriesArgs.length, 2);
|
t.deepEqual(resolveQueriesArgs.length, 2);
|
||||||
t.deepEqual(resolveQueriesArgs[1].queries.length, 1);
|
t.deepEqual(resolveQueriesArgs[1].queries.length, 1);
|
||||||
t.regex(resolveQueriesArgs[1].queries[0], /.*\/override$/);
|
t.true(resolveQueriesArgs[1].queries[0].endsWith(`${path.sep}override`));
|
||||||
// Now check that the end result contains only the default queries and the override query
|
// Now check that the end result contains only the default queries and the override query
|
||||||
t.deepEqual(config.queries["javascript"].builtin.length, 1);
|
t.deepEqual(config.queries["javascript"].builtin.length, 1);
|
||||||
t.deepEqual(config.queries["javascript"].custom.length, 1);
|
t.deepEqual(config.queries["javascript"].custom.length, 1);
|
||||||
t.regex(config.queries["javascript"].builtin[0], /javascript-code-scanning.qls$/);
|
t.true(config.queries["javascript"].builtin[0].endsWith("javascript-code-scanning.qls"));
|
||||||
t.regex(config.queries["javascript"].custom[0].queries[0], /.*\/override$/);
|
t.true(config.queries["javascript"].custom[0].queries[0].endsWith(`${path.sep}override`));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("Queries in workflow file can be used in tandem with the 'disable default queries' option", async (t) => {
|
(0, ava_1.default)("Queries in workflow file can be used in tandem with the 'disable default queries' option", async (t) => {
|
||||||
@@ -369,17 +367,17 @@ function queriesToResolvedQueryForm(queries) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const config = await configUtils.initConfig(languages, testQueries, undefined, configFilePath, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
|
const config = await configUtils.initConfig(languages, testQueries, undefined, configFilePath, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
|
||||||
// Check resolveQueries was called correctly
|
// Check resolveQueries was called correctly
|
||||||
// It'll be called once for `./workflow-query`,
|
// It'll be called once for `./workflow-query`,
|
||||||
// but won't be called for the default one since that was disabled
|
// but won't be called for the default one since that was disabled
|
||||||
t.deepEqual(resolveQueriesArgs.length, 1);
|
t.deepEqual(resolveQueriesArgs.length, 1);
|
||||||
t.deepEqual(resolveQueriesArgs[0].queries.length, 1);
|
t.deepEqual(resolveQueriesArgs[0].queries.length, 1);
|
||||||
t.regex(resolveQueriesArgs[0].queries[0], /.*\/workflow-query$/);
|
t.true(resolveQueriesArgs[0].queries[0].endsWith(`${path.sep}workflow-query`));
|
||||||
// Now check that the end result contains only the workflow query, and not the default one
|
// Now check that the end result contains only the workflow query, and not the default one
|
||||||
t.deepEqual(config.queries["javascript"].builtin.length, 0);
|
t.deepEqual(config.queries["javascript"].builtin.length, 0);
|
||||||
t.deepEqual(config.queries["javascript"].custom.length, 1);
|
t.deepEqual(config.queries["javascript"].custom.length, 1);
|
||||||
t.regex(config.queries["javascript"].custom[0].queries[0], /.*\/workflow-query$/);
|
t.true(config.queries["javascript"].custom[0].queries[0].endsWith(`${path.sep}workflow-query`));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("Multiple queries can be specified in workflow file, no config file required", async (t) => {
|
(0, ava_1.default)("Multiple queries can be specified in workflow file, no config file required", async (t) => {
|
||||||
@@ -395,21 +393,21 @@ function queriesToResolvedQueryForm(queries) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const config = await configUtils.initConfig(languages, testQueries, undefined, undefined, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
|
const config = await configUtils.initConfig(languages, testQueries, undefined, undefined, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
|
||||||
// Check resolveQueries was called correctly:
|
// Check resolveQueries was called correctly:
|
||||||
// It'll be called once for the default queries,
|
// It'll be called once for the default queries,
|
||||||
// and then once for each of the two queries from the workflow
|
// and then once for each of the two queries from the workflow
|
||||||
t.deepEqual(resolveQueriesArgs.length, 3);
|
t.deepEqual(resolveQueriesArgs.length, 3);
|
||||||
t.deepEqual(resolveQueriesArgs[1].queries.length, 1);
|
t.deepEqual(resolveQueriesArgs[1].queries.length, 1);
|
||||||
t.deepEqual(resolveQueriesArgs[2].queries.length, 1);
|
t.deepEqual(resolveQueriesArgs[2].queries.length, 1);
|
||||||
t.regex(resolveQueriesArgs[1].queries[0], /.*\/override1$/);
|
t.true(resolveQueriesArgs[1].queries[0].endsWith(`${path.sep}override1`));
|
||||||
t.regex(resolveQueriesArgs[2].queries[0], /.*\/override2$/);
|
t.true(resolveQueriesArgs[2].queries[0].endsWith(`${path.sep}override2`));
|
||||||
// Now check that the end result contains both the queries from the workflow, as well as the defaults
|
// Now check that the end result contains both the queries from the workflow, as well as the defaults
|
||||||
t.deepEqual(config.queries["javascript"].builtin.length, 1);
|
t.deepEqual(config.queries["javascript"].builtin.length, 1);
|
||||||
t.deepEqual(config.queries["javascript"].custom.length, 2);
|
t.deepEqual(config.queries["javascript"].custom.length, 2);
|
||||||
t.regex(config.queries["javascript"].builtin[0], /javascript-code-scanning.qls$/);
|
t.true(config.queries["javascript"].builtin[0].endsWith("javascript-code-scanning.qls"));
|
||||||
t.regex(config.queries["javascript"].custom[0].queries[0], /.*\/override1$/);
|
t.true(config.queries["javascript"].custom[0].queries[0].endsWith(`${path.sep}override1`));
|
||||||
t.regex(config.queries["javascript"].custom[1].queries[0], /.*\/override2$/);
|
t.true(config.queries["javascript"].custom[1].queries[0].endsWith(`${path.sep}override2`));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("Queries in workflow file can be added to the set of queries without overriding config file", async (t) => {
|
(0, ava_1.default)("Queries in workflow file can be added to the set of queries without overriding config file", async (t) => {
|
||||||
@@ -434,25 +432,25 @@ function queriesToResolvedQueryForm(queries) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const config = await configUtils.initConfig(languages, testQueries, undefined, configFilePath, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
|
const config = await configUtils.initConfig(languages, testQueries, undefined, configFilePath, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
|
||||||
// Check resolveQueries was called correctly
|
// Check resolveQueries was called correctly
|
||||||
// It'll be called once for the default queries,
|
// It'll be called once for the default queries,
|
||||||
// once for each of additional1 and additional2,
|
// once for each of additional1 and additional2,
|
||||||
// and once for './foo' from the config file
|
// and once for './foo' from the config file
|
||||||
t.deepEqual(resolveQueriesArgs.length, 4);
|
t.deepEqual(resolveQueriesArgs.length, 4);
|
||||||
t.deepEqual(resolveQueriesArgs[1].queries.length, 1);
|
t.deepEqual(resolveQueriesArgs[1].queries.length, 1);
|
||||||
t.regex(resolveQueriesArgs[1].queries[0], /.*\/additional1$/);
|
t.true(resolveQueriesArgs[1].queries[0].endsWith(`${path.sep}additional1`));
|
||||||
t.deepEqual(resolveQueriesArgs[2].queries.length, 1);
|
t.deepEqual(resolveQueriesArgs[2].queries.length, 1);
|
||||||
t.regex(resolveQueriesArgs[2].queries[0], /.*\/additional2$/);
|
t.true(resolveQueriesArgs[2].queries[0].endsWith(`${path.sep}additional2`));
|
||||||
t.deepEqual(resolveQueriesArgs[3].queries.length, 1);
|
t.deepEqual(resolveQueriesArgs[3].queries.length, 1);
|
||||||
t.regex(resolveQueriesArgs[3].queries[0], /.*\/foo$/);
|
t.true(resolveQueriesArgs[3].queries[0].endsWith(`${path.sep}foo`));
|
||||||
// Now check that the end result contains all the queries
|
// Now check that the end result contains all the queries
|
||||||
t.deepEqual(config.queries["javascript"].builtin.length, 1);
|
t.deepEqual(config.queries["javascript"].builtin.length, 1);
|
||||||
t.deepEqual(config.queries["javascript"].custom.length, 3);
|
t.deepEqual(config.queries["javascript"].custom.length, 3);
|
||||||
t.regex(config.queries["javascript"].builtin[0], /javascript-code-scanning.qls$/);
|
t.true(config.queries["javascript"].builtin[0].endsWith("javascript-code-scanning.qls"));
|
||||||
t.regex(config.queries["javascript"].custom[0].queries[0], /.*\/additional1$/);
|
t.true(config.queries["javascript"].custom[0].queries[0].endsWith(`${path.sep}additional1`));
|
||||||
t.regex(config.queries["javascript"].custom[1].queries[0], /.*\/additional2$/);
|
t.true(config.queries["javascript"].custom[1].queries[0].endsWith(`${path.sep}additional2`));
|
||||||
t.regex(config.queries["javascript"].custom[2].queries[0], /.*\/foo$/);
|
t.true(config.queries["javascript"].custom[2].queries[0].endsWith(`${path.sep}foo`));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("Invalid queries in workflow file handled correctly", async (t) => {
|
(0, ava_1.default)("Invalid queries in workflow file handled correctly", async (t) => {
|
||||||
@@ -473,7 +471,7 @@ function queriesToResolvedQueryForm(queries) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(languages, queries, undefined, undefined, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
|
await configUtils.initConfig(languages, queries, undefined, undefined, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
|
||||||
t.fail("initConfig did not throw error");
|
t.fail("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -516,7 +514,7 @@ function queriesToResolvedQueryForm(queries) {
|
|||||||
fs.mkdirSync(path.join(tmpDir, "foo/bar/dev"), { recursive: true });
|
fs.mkdirSync(path.join(tmpDir, "foo/bar/dev"), { recursive: true });
|
||||||
const configFile = "octo-org/codeql-config/config.yaml@main";
|
const configFile = "octo-org/codeql-config/config.yaml@main";
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
|
await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
|
||||||
t.assert(spyGetContents.called);
|
t.assert(spyGetContents.called);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -526,7 +524,7 @@ function queriesToResolvedQueryForm(queries) {
|
|||||||
mockGetContents(dummyResponse);
|
mockGetContents(dummyResponse);
|
||||||
const repoReference = "octo-org/codeql-config/config.yaml@main";
|
const repoReference = "octo-org/codeql-config/config.yaml@main";
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(undefined, undefined, undefined, repoReference, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
|
await configUtils.initConfig(undefined, undefined, undefined, repoReference, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -542,7 +540,7 @@ function queriesToResolvedQueryForm(queries) {
|
|||||||
mockGetContents(dummyResponse);
|
mockGetContents(dummyResponse);
|
||||||
const repoReference = "octo-org/codeql-config/config.yaml@main";
|
const repoReference = "octo-org/codeql-config/config.yaml@main";
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(undefined, undefined, undefined, repoReference, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
|
await configUtils.initConfig(undefined, undefined, undefined, repoReference, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -559,7 +557,7 @@ function queriesToResolvedQueryForm(queries) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(undefined, undefined, undefined, undefined, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
|
await configUtils.initConfig(undefined, undefined, undefined, undefined, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -571,7 +569,7 @@ function queriesToResolvedQueryForm(queries) {
|
|||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
const languages = "rubbish,english";
|
const languages = "rubbish,english";
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(languages, undefined, undefined, undefined, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
|
await configUtils.initConfig(languages, undefined, undefined, undefined, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -599,14 +597,9 @@ function queriesToResolvedQueryForm(queries) {
|
|||||||
const configFile = path.join(tmpDir, "codeql-config.yaml");
|
const configFile = path.join(tmpDir, "codeql-config.yaml");
|
||||||
fs.writeFileSync(configFile, inputFileContents);
|
fs.writeFileSync(configFile, inputFileContents);
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const { packs } = await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
|
const { packs } = await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
|
||||||
t.deepEqual(packs, {
|
t.deepEqual(packs, {
|
||||||
[languages_1.Language.javascript]: [
|
[languages_1.Language.javascript]: ["a/b@1.2.3"],
|
||||||
{
|
|
||||||
packName: "a/b",
|
|
||||||
version: (0, semver_1.clean)("1.2.3"),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -638,20 +631,10 @@ function queriesToResolvedQueryForm(queries) {
|
|||||||
fs.writeFileSync(configFile, inputFileContents);
|
fs.writeFileSync(configFile, inputFileContents);
|
||||||
fs.mkdirSync(path.join(tmpDir, "foo"));
|
fs.mkdirSync(path.join(tmpDir, "foo"));
|
||||||
const languages = "javascript,python,cpp";
|
const languages = "javascript,python,cpp";
|
||||||
const { packs, queries } = await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, false, "", "", { owner: "github", repo: "example" }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
|
const { packs, queries } = await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, false, "", "", { owner: "github", repo: "example" }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
|
||||||
t.deepEqual(packs, {
|
t.deepEqual(packs, {
|
||||||
[languages_1.Language.javascript]: [
|
[languages_1.Language.javascript]: ["a/b@1.2.3"],
|
||||||
{
|
[languages_1.Language.python]: ["c/d@1.2.3"],
|
||||||
packName: "a/b",
|
|
||||||
version: (0, semver_1.clean)("1.2.3"),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
[languages_1.Language.python]: [
|
|
||||||
{
|
|
||||||
packName: "c/d",
|
|
||||||
version: (0, semver_1.clean)("1.2.3"),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
t.deepEqual(queries, {
|
t.deepEqual(queries, {
|
||||||
cpp: {
|
cpp: {
|
||||||
@@ -691,7 +674,7 @@ function doInvalidInputTest(testName, inputFileContents, expectedErrorMessageGen
|
|||||||
const inputFile = path.join(tmpDir, configFile);
|
const inputFile = path.join(tmpDir, configFile);
|
||||||
fs.writeFileSync(inputFile, inputFileContents, "utf8");
|
fs.writeFileSync(inputFile, inputFileContents, "utf8");
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
|
await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), (0, logging_1.getRunnerLogger)(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -765,14 +748,14 @@ const invalidPaths = ["a/***/b", "a/**b", "a/b**", "**"];
|
|||||||
* Test macro for ensuring the packs block is valid
|
* Test macro for ensuring the packs block is valid
|
||||||
*/
|
*/
|
||||||
const parsePacksMacro = ava_1.default.macro({
|
const parsePacksMacro = ava_1.default.macro({
|
||||||
exec: (t, packsByLanguage, languages, expected) => t.deepEqual(configUtils.parsePacksFromConfig(packsByLanguage, languages, "/a/b"), expected),
|
exec: (t, packsByLanguage, languages, expected) => t.deepEqual(configUtils.parsePacksFromConfig(packsByLanguage, languages, "/a/b", mockLogger), expected),
|
||||||
title: (providedTitle = "") => `Parse Packs: ${providedTitle}`,
|
title: (providedTitle = "") => `Parse Packs: ${providedTitle}`,
|
||||||
});
|
});
|
||||||
/**
|
/**
|
||||||
* Test macro for testing when the packs block is invalid
|
* Test macro for testing when the packs block is invalid
|
||||||
*/
|
*/
|
||||||
const parsePacksErrorMacro = ava_1.default.macro({
|
const parsePacksErrorMacro = ava_1.default.macro({
|
||||||
exec: (t, packsByLanguage, languages, expected) => t.throws(() => configUtils.parsePacksFromConfig(packsByLanguage, languages, "/a/b"), {
|
exec: (t, packsByLanguage, languages, expected) => t.throws(() => configUtils.parsePacksFromConfig(packsByLanguage, languages, "/a/b", {}), {
|
||||||
message: expected,
|
message: expected,
|
||||||
}),
|
}),
|
||||||
title: (providedTitle = "") => `Parse Packs Error: ${providedTitle}`,
|
title: (providedTitle = "") => `Parse Packs Error: ${providedTitle}`,
|
||||||
@@ -786,87 +769,106 @@ const invalidPackNameMacro = ava_1.default.macro({
|
|||||||
});
|
});
|
||||||
(0, ava_1.default)("no packs", parsePacksMacro, {}, [], {});
|
(0, ava_1.default)("no packs", parsePacksMacro, {}, [], {});
|
||||||
(0, ava_1.default)("two packs", parsePacksMacro, ["a/b", "c/d@1.2.3"], [languages_1.Language.cpp], {
|
(0, ava_1.default)("two packs", parsePacksMacro, ["a/b", "c/d@1.2.3"], [languages_1.Language.cpp], {
|
||||||
[languages_1.Language.cpp]: [
|
[languages_1.Language.cpp]: ["a/b", "c/d@1.2.3"],
|
||||||
{ packName: "a/b", version: undefined },
|
|
||||||
{ packName: "c/d", version: (0, semver_1.clean)("1.2.3") },
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("two packs with spaces", parsePacksMacro, [" a/b ", " c/d@1.2.3 "], [languages_1.Language.cpp], {
|
(0, ava_1.default)("two packs with spaces", parsePacksMacro, [" a/b ", " c/d@1.2.3 "], [languages_1.Language.cpp], {
|
||||||
[languages_1.Language.cpp]: [
|
[languages_1.Language.cpp]: ["a/b", "c/d@1.2.3"],
|
||||||
{ packName: "a/b", version: undefined },
|
|
||||||
{ packName: "c/d", version: (0, semver_1.clean)("1.2.3") },
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("two packs with language", parsePacksMacro, {
|
(0, ava_1.default)("two packs with language", parsePacksMacro, {
|
||||||
[languages_1.Language.cpp]: ["a/b", "c/d@1.2.3"],
|
[languages_1.Language.cpp]: ["a/b", "c/d@1.2.3"],
|
||||||
[languages_1.Language.java]: ["d/e", "f/g@1.2.3"],
|
[languages_1.Language.java]: ["d/e", "f/g@1.2.3"],
|
||||||
}, [languages_1.Language.cpp, languages_1.Language.java, languages_1.Language.csharp], {
|
}, [languages_1.Language.cpp, languages_1.Language.java, languages_1.Language.csharp], {
|
||||||
|
[languages_1.Language.cpp]: ["a/b", "c/d@1.2.3"],
|
||||||
|
[languages_1.Language.java]: ["d/e", "f/g@1.2.3"],
|
||||||
|
});
|
||||||
|
(0, ava_1.default)("two packs with unused language in config", parsePacksMacro, {
|
||||||
|
[languages_1.Language.cpp]: ["a/b", "c/d@1.2.3"],
|
||||||
|
[languages_1.Language.java]: ["d/e", "f/g@1.2.3"],
|
||||||
|
}, [languages_1.Language.cpp, languages_1.Language.csharp], {
|
||||||
|
[languages_1.Language.cpp]: ["a/b", "c/d@1.2.3"],
|
||||||
|
});
|
||||||
|
(0, ava_1.default)("packs with other valid names", parsePacksMacro, [
|
||||||
|
// ranges are ok
|
||||||
|
"c/d@1.0",
|
||||||
|
"c/d@~1.0.0",
|
||||||
|
"c/d@~1.0.0:a/b",
|
||||||
|
"c/d@~1.0.0+abc:a/b",
|
||||||
|
"c/d@~1.0.0-abc:a/b",
|
||||||
|
"c/d:a/b",
|
||||||
|
// whitespace is removed
|
||||||
|
" c/d @ ~1.0.0 : b.qls ",
|
||||||
|
// and it is retained within a path
|
||||||
|
" c/d @ ~1.0.0 : b/a path with/spaces.qls ",
|
||||||
|
// this is valid. the path is '@'. It will probably fail when passed to the CLI
|
||||||
|
"c/d@1.2.3:@",
|
||||||
|
// this is valid, too. It will fail if it doesn't match a path
|
||||||
|
// (globbing is not done)
|
||||||
|
"c/d@1.2.3:+*)_(",
|
||||||
|
], [languages_1.Language.cpp], {
|
||||||
[languages_1.Language.cpp]: [
|
[languages_1.Language.cpp]: [
|
||||||
{ packName: "a/b", version: undefined },
|
"c/d@1.0",
|
||||||
{ packName: "c/d", version: (0, semver_1.clean)("1.2.3") },
|
"c/d@~1.0.0",
|
||||||
],
|
"c/d@~1.0.0:a/b",
|
||||||
[languages_1.Language.java]: [
|
"c/d@~1.0.0+abc:a/b",
|
||||||
{ packName: "d/e", version: undefined },
|
"c/d@~1.0.0-abc:a/b",
|
||||||
{ packName: "f/g", version: (0, semver_1.clean)("1.2.3") },
|
"c/d:a/b",
|
||||||
|
"c/d@~1.0.0:b.qls",
|
||||||
|
"c/d@~1.0.0:b/a path with/spaces.qls",
|
||||||
|
"c/d@1.2.3:@",
|
||||||
|
"c/d@1.2.3:+*)_(",
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("no language", parsePacksErrorMacro, ["a/b@1.2.3"], [languages_1.Language.java, languages_1.Language.python], /The configuration file "\/a\/b" is invalid: property "packs" must split packages by language/);
|
(0, ava_1.default)("no language", parsePacksErrorMacro, ["a/b@1.2.3"], [languages_1.Language.java, languages_1.Language.python], /The configuration file "\/a\/b" is invalid: property "packs" must split packages by language/);
|
||||||
(0, ava_1.default)("invalid language", parsePacksErrorMacro, { [languages_1.Language.java]: ["c/d"] }, [languages_1.Language.cpp], /The configuration file "\/a\/b" is invalid: property "packs" has "java", but it is not one of the languages to analyze/);
|
|
||||||
(0, ava_1.default)("not an array", parsePacksErrorMacro, { [languages_1.Language.cpp]: "c/d" }, [languages_1.Language.cpp], /The configuration file "\/a\/b" is invalid: property "packs" must be an array of non-empty strings/);
|
(0, ava_1.default)("not an array", parsePacksErrorMacro, { [languages_1.Language.cpp]: "c/d" }, [languages_1.Language.cpp], /The configuration file "\/a\/b" is invalid: property "packs" must be an array of non-empty strings/);
|
||||||
(0, ava_1.default)(invalidPackNameMacro, "c"); // all packs require at least a scope and a name
|
(0, ava_1.default)(invalidPackNameMacro, "c"); // all packs require at least a scope and a name
|
||||||
(0, ava_1.default)(invalidPackNameMacro, "c-/d");
|
(0, ava_1.default)(invalidPackNameMacro, "c-/d");
|
||||||
(0, ava_1.default)(invalidPackNameMacro, "-c/d");
|
(0, ava_1.default)(invalidPackNameMacro, "-c/d");
|
||||||
(0, ava_1.default)(invalidPackNameMacro, "c/d_d");
|
(0, ava_1.default)(invalidPackNameMacro, "c/d_d");
|
||||||
(0, ava_1.default)(invalidPackNameMacro, "c/d@x");
|
(0, ava_1.default)(invalidPackNameMacro, "c/d@@");
|
||||||
|
(0, ava_1.default)(invalidPackNameMacro, "c/d@1.0.0:");
|
||||||
|
(0, ava_1.default)(invalidPackNameMacro, "c/d:");
|
||||||
|
(0, ava_1.default)(invalidPackNameMacro, "c/d:/a");
|
||||||
|
(0, ava_1.default)(invalidPackNameMacro, "@1.0.0:a");
|
||||||
|
(0, ava_1.default)(invalidPackNameMacro, "c/d@../a");
|
||||||
|
(0, ava_1.default)(invalidPackNameMacro, "c/d@b/../a");
|
||||||
|
(0, ava_1.default)(invalidPackNameMacro, "c/d:z@1");
|
||||||
/**
|
/**
|
||||||
* Test macro for testing the packs block and the packs input
|
* Test macro for testing the packs block and the packs input
|
||||||
*/
|
*/
|
||||||
function parseInputAndConfigMacro(t, packsFromConfig, packsFromInput, languages, expected) {
|
function parseInputAndConfigMacro(t, packsFromConfig, packsFromInput, languages, expected) {
|
||||||
t.deepEqual(configUtils.parsePacks(packsFromConfig, packsFromInput, languages, "/a/b"), expected);
|
t.deepEqual(configUtils.parsePacks(packsFromConfig, packsFromInput, languages, "/a/b", mockLogger), expected);
|
||||||
}
|
}
|
||||||
parseInputAndConfigMacro.title = (providedTitle) => `Parse Packs input and config: ${providedTitle}`;
|
parseInputAndConfigMacro.title = (providedTitle) => `Parse Packs input and config: ${providedTitle}`;
|
||||||
|
const mockLogger = {
|
||||||
|
info: (message) => {
|
||||||
|
console.log(message);
|
||||||
|
},
|
||||||
|
};
|
||||||
function parseInputAndConfigErrorMacro(t, packsFromConfig, packsFromInput, languages, expected) {
|
function parseInputAndConfigErrorMacro(t, packsFromConfig, packsFromInput, languages, expected) {
|
||||||
t.throws(() => {
|
t.throws(() => {
|
||||||
configUtils.parsePacks(packsFromConfig, packsFromInput, languages, "/a/b");
|
configUtils.parsePacks(packsFromConfig, packsFromInput, languages, "/a/b", mockLogger);
|
||||||
}, {
|
}, {
|
||||||
message: expected,
|
message: expected,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
parseInputAndConfigErrorMacro.title = (providedTitle) => `Parse Packs input and config Error: ${providedTitle}`;
|
parseInputAndConfigErrorMacro.title = (providedTitle) => `Parse Packs input and config Error: ${providedTitle}`;
|
||||||
(0, ava_1.default)("input only", parseInputAndConfigMacro, {}, " c/d ", [languages_1.Language.cpp], {
|
(0, ava_1.default)("input only", parseInputAndConfigMacro, {}, " c/d ", [languages_1.Language.cpp], {
|
||||||
[languages_1.Language.cpp]: [{ packName: "c/d", version: undefined }],
|
[languages_1.Language.cpp]: ["c/d"],
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("input only with multiple", parseInputAndConfigMacro, {}, "a/b , c/d@1.2.3", [languages_1.Language.cpp], {
|
(0, ava_1.default)("input only with multiple", parseInputAndConfigMacro, {}, "a/b , c/d@1.2.3", [languages_1.Language.cpp], {
|
||||||
[languages_1.Language.cpp]: [
|
[languages_1.Language.cpp]: ["a/b", "c/d@1.2.3"],
|
||||||
{ packName: "a/b", version: undefined },
|
|
||||||
{ packName: "c/d", version: "1.2.3" },
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("input only with +", parseInputAndConfigMacro, {}, " + a/b , c/d@1.2.3 ", [languages_1.Language.cpp], {
|
(0, ava_1.default)("input only with +", parseInputAndConfigMacro, {}, " + a/b , c/d@1.2.3 ", [languages_1.Language.cpp], {
|
||||||
[languages_1.Language.cpp]: [
|
[languages_1.Language.cpp]: ["a/b", "c/d@1.2.3"],
|
||||||
{ packName: "a/b", version: undefined },
|
|
||||||
{ packName: "c/d", version: "1.2.3" },
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("config only", parseInputAndConfigMacro, ["a/b", "c/d"], " ", [languages_1.Language.cpp], {
|
(0, ava_1.default)("config only", parseInputAndConfigMacro, ["a/b", "c/d"], " ", [languages_1.Language.cpp], {
|
||||||
[languages_1.Language.cpp]: [
|
[languages_1.Language.cpp]: ["a/b", "c/d"],
|
||||||
{ packName: "a/b", version: undefined },
|
|
||||||
{ packName: "c/d", version: undefined },
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("input overrides", parseInputAndConfigMacro, ["a/b", "c/d"], " e/f, g/h@1.2.3 ", [languages_1.Language.cpp], {
|
(0, ava_1.default)("input overrides", parseInputAndConfigMacro, ["a/b", "c/d"], " e/f, g/h@1.2.3 ", [languages_1.Language.cpp], {
|
||||||
[languages_1.Language.cpp]: [
|
[languages_1.Language.cpp]: ["e/f", "g/h@1.2.3"],
|
||||||
{ packName: "e/f", version: undefined },
|
|
||||||
{ packName: "g/h", version: "1.2.3" },
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("input and config", parseInputAndConfigMacro, ["a/b", "c/d"], " +e/f, g/h@1.2.3 ", [languages_1.Language.cpp], {
|
(0, ava_1.default)("input and config", parseInputAndConfigMacro, ["a/b", "c/d"], " +e/f, g/h@1.2.3 ", [languages_1.Language.cpp], {
|
||||||
[languages_1.Language.cpp]: [
|
[languages_1.Language.cpp]: ["e/f", "g/h@1.2.3", "a/b", "c/d"],
|
||||||
{ packName: "e/f", version: undefined },
|
|
||||||
{ packName: "g/h", version: "1.2.3" },
|
|
||||||
{ packName: "a/b", version: undefined },
|
|
||||||
{ packName: "c/d", version: undefined },
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("input with no language", parseInputAndConfigErrorMacro, {}, "c/d", [], /No languages specified/);
|
(0, ava_1.default)("input with no language", parseInputAndConfigErrorMacro, {}, "c/d", [], /No languages specified/);
|
||||||
(0, ava_1.default)("input with two languages", parseInputAndConfigErrorMacro, {}, "c/d", [languages_1.Language.cpp, languages_1.Language.csharp], /multi-language analysis/);
|
(0, ava_1.default)("input with two languages", parseInputAndConfigErrorMacro, {}, "c/d", [languages_1.Language.cpp, languages_1.Language.csharp], /multi-language analysis/);
|
||||||
@@ -889,16 +891,13 @@ const mlPoweredQueriesMacro = ava_1.default.macro({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const { packs } = await configUtils.initConfig("javascript", queriesInput, packsInput, undefined, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)(isMlPoweredQueriesFlagEnabled
|
const { packs } = await configUtils.initConfig("javascript", queriesInput, packsInput, undefined, undefined, false, "", "", { owner: "github", repo: "example " }, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)(isMlPoweredQueriesFlagEnabled
|
||||||
? [feature_flags_1.FeatureFlag.MlPoweredQueriesEnabled]
|
? [feature_flags_1.FeatureFlag.MlPoweredQueriesEnabled]
|
||||||
: []), (0, logging_1.getRunnerLogger)(true));
|
: []), (0, logging_1.getRunnerLogger)(true));
|
||||||
if (expectedVersionString !== undefined) {
|
if (expectedVersionString !== undefined) {
|
||||||
t.deepEqual(packs, {
|
t.deepEqual(packs, {
|
||||||
[languages_1.Language.javascript]: [
|
[languages_1.Language.javascript]: [
|
||||||
{
|
`codeql/javascript-experimental-atm-queries@${expectedVersionString}`,
|
||||||
packName: "codeql/javascript-experimental-atm-queries",
|
|
||||||
version: expectedVersionString,
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -916,15 +915,29 @@ const mlPoweredQueriesMacro = ava_1.default.macro({
|
|||||||
(0, ava_1.default)(mlPoweredQueriesMacro, "2.7.4", true, undefined, "security-extended", undefined);
|
(0, ava_1.default)(mlPoweredQueriesMacro, "2.7.4", true, undefined, "security-extended", undefined);
|
||||||
// Test that ML-powered queries aren't run when the feature flag is off.
|
// Test that ML-powered queries aren't run when the feature flag is off.
|
||||||
(0, ava_1.default)(mlPoweredQueriesMacro, "2.7.5", false, undefined, "security-extended", undefined);
|
(0, ava_1.default)(mlPoweredQueriesMacro, "2.7.5", false, undefined, "security-extended", undefined);
|
||||||
|
// Test that the ~0.1.0 version of ML-powered queries is run on v2.8.3 of the CLI.
|
||||||
|
(0, ava_1.default)(mlPoweredQueriesMacro, "2.8.3", true, undefined, "security-extended", process.platform === "win32" ? undefined : "~0.1.0");
|
||||||
// Test that ML-powered queries aren't run when the user hasn't specified that we should run the
|
// Test that ML-powered queries aren't run when the user hasn't specified that we should run the
|
||||||
// `security-extended` or `security-and-quality` query suite.
|
// `security-extended` or `security-and-quality` query suite.
|
||||||
(0, ava_1.default)(mlPoweredQueriesMacro, "2.7.5", true, undefined, undefined, undefined);
|
(0, ava_1.default)(mlPoweredQueriesMacro, "2.7.5", true, undefined, undefined, undefined);
|
||||||
// Test that ML-powered queries are run on non-Windows platforms running `security-extended`.
|
// Test that ML-powered queries are run on non-Windows platforms running `security-extended` on
|
||||||
(0, ava_1.default)(mlPoweredQueriesMacro, "2.7.5", true, undefined, "security-extended", process.platform === "win32" ? undefined : "~0.1.0");
|
// versions of the CodeQL CLI prior to 2.9.0.
|
||||||
// Test that ML-powered queries are run on non-Windows platforms running `security-and-quality`.
|
(0, ava_1.default)(mlPoweredQueriesMacro, "2.8.5", true, undefined, "security-extended", process.platform === "win32" ? undefined : "~0.2.0");
|
||||||
(0, ava_1.default)(mlPoweredQueriesMacro, "2.7.5", true, undefined, "security-and-quality", process.platform === "win32" ? undefined : "~0.1.0");
|
// Test that ML-powered queries are run on non-Windows platforms running `security-and-quality` on
|
||||||
|
// versions of the CodeQL CLI prior to 2.9.0.
|
||||||
|
(0, ava_1.default)(mlPoweredQueriesMacro, "2.8.5", true, undefined, "security-and-quality", process.platform === "win32" ? undefined : "~0.2.0");
|
||||||
|
// Test that ML-powered queries are run on all platforms running `security-extended` on CodeQL CLI
|
||||||
|
// 2.9.0+.
|
||||||
|
(0, ava_1.default)(mlPoweredQueriesMacro, "2.9.0", true, undefined, "security-extended", "~0.2.0");
|
||||||
|
// Test that ML-powered queries are run on all platforms running `security-and-quality` on CodeQL
|
||||||
|
// CLI 2.9.0+.
|
||||||
|
(0, ava_1.default)(mlPoweredQueriesMacro, "2.9.0", true, undefined, "security-and-quality", "~0.2.0");
|
||||||
// Test that we don't inject an ML-powered query pack if the user has already specified one.
|
// Test that we don't inject an ML-powered query pack if the user has already specified one.
|
||||||
(0, ava_1.default)(mlPoweredQueriesMacro, "2.7.5", true, "codeql/javascript-experimental-atm-queries@0.0.1", "security-and-quality", process.platform === "win32" ? undefined : "0.0.1");
|
(0, ava_1.default)(mlPoweredQueriesMacro, "2.9.0", true, "codeql/javascript-experimental-atm-queries@0.0.1", "security-and-quality", "0.0.1");
|
||||||
// Test that the ~0.2.0 version of ML-powered queries is run on v2.8.4 of the CLI.
|
// Test that ML-powered queries are run on all platforms running `security-extended` on CodeQL
|
||||||
(0, ava_1.default)(mlPoweredQueriesMacro, "2.8.4", true, undefined, "security-extended", process.platform === "win32" ? undefined : "~0.2.0");
|
// CLI 2.9.3+.
|
||||||
|
(0, ava_1.default)(mlPoweredQueriesMacro, "2.9.3", true, undefined, "security-extended", "~0.3.0");
|
||||||
|
// Test that ML-powered queries are run on all platforms running `security-and-quality` on CodeQL
|
||||||
|
// CLI 2.9.3+.
|
||||||
|
(0, ava_1.default)(mlPoweredQueriesMacro, "2.9.3", true, undefined, "security-and-quality", "~0.3.0");
|
||||||
//# sourceMappingURL=config-utils.test.js.map
|
//# sourceMappingURL=config-utils.test.js.map
|
||||||
File diff suppressed because one or more lines are too long
1
lib/database-upload.test.js
generated
1
lib/database-upload.test.js
generated
@@ -50,7 +50,6 @@ function getTestConfig(tmpDir) {
|
|||||||
paths: [],
|
paths: [],
|
||||||
originalUserInput: {},
|
originalUserInput: {},
|
||||||
tempDir: tmpDir,
|
tempDir: tmpDir,
|
||||||
toolCacheDir: tmpDir,
|
|
||||||
codeQLCmd: "foo",
|
codeQLCmd: "foo",
|
||||||
gitHubVersion: { type: util_1.GitHubVariant.DOTCOM },
|
gitHubVersion: { type: util_1.GitHubVariant.DOTCOM },
|
||||||
dbLocation: tmpDir,
|
dbLocation: tmpDir,
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"bundleVersion": "codeql-bundle-20220421"
|
"bundleVersion": "codeql-bundle-20220714"
|
||||||
}
|
}
|
||||||
|
|||||||
10
lib/feature-flags.js
generated
10
lib/feature-flags.js
generated
@@ -25,6 +25,7 @@ const util = __importStar(require("./util"));
|
|||||||
var FeatureFlag;
|
var FeatureFlag;
|
||||||
(function (FeatureFlag) {
|
(function (FeatureFlag) {
|
||||||
FeatureFlag["MlPoweredQueriesEnabled"] = "ml_powered_queries_enabled";
|
FeatureFlag["MlPoweredQueriesEnabled"] = "ml_powered_queries_enabled";
|
||||||
|
FeatureFlag["LuaTracerConfigEnabled"] = "lua_tracer_config_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) {
|
||||||
@@ -34,12 +35,17 @@ class GitHubFeatureFlags {
|
|||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
}
|
}
|
||||||
async getValue(flag) {
|
async getValue(flag) {
|
||||||
const response = (await this.getApiResponse())[flag];
|
const response = await this.getApiResponse();
|
||||||
if (response === undefined) {
|
if (response === undefined) {
|
||||||
|
this.logger.debug(`No feature flags API response for ${flag}, considering it disabled.`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const flagValue = response[flag];
|
||||||
|
if (flagValue === undefined) {
|
||||||
this.logger.debug(`Feature flag '${flag}' undefined in API response, considering it disabled.`);
|
this.logger.debug(`Feature flag '${flag}' undefined in API response, considering it disabled.`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return response;
|
return flagValue;
|
||||||
}
|
}
|
||||||
async getApiResponse() {
|
async getApiResponse() {
|
||||||
const loadApiResponse = async () => {
|
const loadApiResponse = async () => {
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"feature-flags.js","sourceRoot":"","sources":["../src/feature-flags.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA8D;AAG9D,6CAA+B;AAM/B,IAAY,WAEX;AAFD,WAAY,WAAW;IACrB,qEAAsD,CAAA;AACxD,CAAC,EAFW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAEtB;AAUD,MAAa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,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;AAvED,gDAuEC;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"}
|
||||||
22
lib/feature-flags.test.js
generated
22
lib/feature-flags.test.js
generated
@@ -40,6 +40,22 @@ for (const variant of ALL_FEATURE_FLAGS_DISABLED_VARIANTS) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
(0, ava_1.default)("API response missing", async (t) => {
|
||||||
|
await (0, util_1.withTmpDir)(async (tmpDir) => {
|
||||||
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
|
const loggedMessages = [];
|
||||||
|
const featureFlags = new feature_flags_1.GitHubFeatureFlags({ type: util_1.GitHubVariant.DOTCOM }, testApiDetails, testRepositoryNwo, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
|
||||||
|
(0, testing_utils_1.mockFeatureFlagApiEndpoint)(403, {});
|
||||||
|
for (const flag of Object.values(feature_flags_1.FeatureFlag)) {
|
||||||
|
t.assert((await featureFlags.getValue(flag)) === false);
|
||||||
|
}
|
||||||
|
for (const featureFlag of ["ml_powered_queries_enabled"]) {
|
||||||
|
t.assert(loggedMessages.find((v) => v.type === "debug" &&
|
||||||
|
v.message ===
|
||||||
|
`No feature flags API response for ${featureFlag}, considering it disabled.`) !== undefined);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
(0, ava_1.default)("Feature flags are disabled if they're not returned in API response", async (t) => {
|
(0, ava_1.default)("Feature flags are disabled if they're not returned in API response", async (t) => {
|
||||||
await (0, util_1.withTmpDir)(async (tmpDir) => {
|
await (0, util_1.withTmpDir)(async (tmpDir) => {
|
||||||
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
@@ -66,7 +82,10 @@ for (const variant of ALL_FEATURE_FLAGS_DISABLED_VARIANTS) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
const FEATURE_FLAGS = ["ml_powered_queries_enabled"];
|
const FEATURE_FLAGS = [
|
||||||
|
"ml_powered_queries_enabled",
|
||||||
|
"lua_tracer_config_enabled",
|
||||||
|
];
|
||||||
for (const featureFlag of FEATURE_FLAGS) {
|
for (const featureFlag of FEATURE_FLAGS) {
|
||||||
(0, ava_1.default)(`Feature flag '${featureFlag}' is enabled if enabled in the API response`, async (t) => {
|
(0, ava_1.default)(`Feature flag '${featureFlag}' is enabled if enabled in the API response`, async (t) => {
|
||||||
await (0, util_1.withTmpDir)(async (tmpDir) => {
|
await (0, util_1.withTmpDir)(async (tmpDir) => {
|
||||||
@@ -80,6 +99,7 @@ for (const featureFlag of FEATURE_FLAGS) {
|
|||||||
(0, testing_utils_1.mockFeatureFlagApiEndpoint)(200, expectedFeatureFlags);
|
(0, testing_utils_1.mockFeatureFlagApiEndpoint)(200, expectedFeatureFlags);
|
||||||
const actualFeatureFlags = {
|
const actualFeatureFlags = {
|
||||||
ml_powered_queries_enabled: await featureFlags.getValue(feature_flags_1.FeatureFlag.MlPoweredQueriesEnabled),
|
ml_powered_queries_enabled: await featureFlags.getValue(feature_flags_1.FeatureFlag.MlPoweredQueriesEnabled),
|
||||||
|
lua_tracer_config_enabled: await featureFlags.getValue(feature_flags_1.FeatureFlag.LuaTracerConfigEnabled),
|
||||||
};
|
};
|
||||||
t.deepEqual(actualFeatureFlags, expectedFeatureFlags);
|
t.deepEqual(actualFeatureFlags, expectedFeatureFlags);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"feature-flags.test.js","sourceRoot":"","sources":["../src/feature-flags.test.ts"],"names":[],"mappings":";;;;;AAAA,8CAAuB;AAGvB,mDAAkE;AAClE,uCAA4C;AAC5C,6CAAkD;AAClD,mDAMyB;AAEzB,iCAAgF;AAEhF,IAAA,0BAAU,EAAC,aAAI,CAAC,CAAC;AAEjB,aAAI,CAAC,UAAU,CAAC,GAAG,EAAE;IACnB,IAAA,4BAAqB,EAAC,WAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC/C,CAAC,CAAC,CAAC;AAEH,MAAM,cAAc,GAAqB;IACvC,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,oBAAoB;CAC1B,CAAC;AAEF,MAAM,iBAAiB,GAAG,IAAA,+BAAkB,EAAC,gBAAgB,CAAC,CAAC;AAE/D,MAAM,mCAAmC,GAGpC;IACH;QACE,WAAW,EAAE,MAAM;QACnB,aAAa,EAAE,EAAE,IAAI,EAAE,oBAAa,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE;KAC9D;IACD,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE,IAAI,EAAE,oBAAa,CAAC,IAAI,EAAE,EAAE;CACrE,CAAC;AAEF,KAAK,MAAM,OAAO,IAAI,mCAAmC,EAAE;IACzD,IAAA,aAAI,EAAC,qDAAqD,OAAO,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;QAC3F,MAAM,IAAA,iBAAU,EAAC,KAAK,EAAE,MAAM,EAAE,EAAE;YAChC,IAAA,gCAAgB,EAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAEjC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AAK,EAAE,CAAC,EAAE,EAAE;QAC1F,MAAM,IAAA,iBAAU,EAAC,KAAK,EAAE,MAAM,EAAE,EAAE;YAChC,IAAA,gCAAgB,EAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAEjC,MAAM,YAAY,GAAG,IAAI,kCAAkB,CACzC,EAAE,IAAI,EAAE,oBAAa,CAAC,MAAM,EAAE,EAC9B,cAAc,EACd,iBAAiB,EACjB,IAAA,yBAAe,EAAC,IAAI,CAAC,CACtB,CAAC;YAEF,MAAM,oBAAoB,GAAgC,EAAE,CAAC;YAC7D,KAAK,MAAM,CAAC,IAAI,aAAa,EAAE;gBAC7B,oBAAoB,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;aACjC;YACD,oBAAoB,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC;YACzC,IAAA,0CAA0B,EAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC;YAEtD,MAAM,kBAAkB,GAAgC;gBACtD,0BAA0B,EAAE,MAAM,YAAY,CAAC,QAAQ,CACrD,2BAAW,CAAC,uBAAuB,CACpC;gBACD,yBAAyB,EAAE,MAAM,YAAY,CAAC,QAAQ,CACpD,2BAAW,CAAC,sBAAsB,CACnC;aACF,CAAC;YAEF,CAAC,CAAC,SAAS,CAAC,kBAAkB,EAAE,oBAAoB,CAAC,CAAC;QACxD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;CACJ"}
|
||||||
3
lib/fingerprints.js
generated
3
lib/fingerprints.js
generated
@@ -24,6 +24,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.addFingerprints = exports.resolveUriToFile = exports.hash = void 0;
|
exports.addFingerprints = exports.resolveUriToFile = exports.hash = void 0;
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
|
const path_1 = __importDefault(require("path"));
|
||||||
const long_1 = __importDefault(require("long"));
|
const long_1 = __importDefault(require("long"));
|
||||||
const tab = "\t".charCodeAt(0);
|
const tab = "\t".charCodeAt(0);
|
||||||
const space = " ".charCodeAt(0);
|
const space = " ".charCodeAt(0);
|
||||||
@@ -209,7 +210,7 @@ function resolveUriToFile(location, artifacts, sourceRoot, logger) {
|
|||||||
// Just assume a relative path is relative to the src root.
|
// Just assume a relative path is relative to the src root.
|
||||||
// This is not necessarily true but should be a good approximation
|
// This is not necessarily true but should be a good approximation
|
||||||
// and here we likely want to err on the side of handling more cases.
|
// and here we likely want to err on the side of handling more cases.
|
||||||
if (!uri.startsWith("/")) {
|
if (!path_1.default.isAbsolute(uri)) {
|
||||||
uri = srcRootPrefix + uri;
|
uri = srcRootPrefix + uri;
|
||||||
}
|
}
|
||||||
// Check the file exists
|
// Check the file exists
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
14
lib/fingerprints.test.js
generated
14
lib/fingerprints.test.js
generated
@@ -131,20 +131,22 @@ function testResolveUriToFile(uri, index, artifactsURIs) {
|
|||||||
return fingerprints.resolveUriToFile(location, artifacts, process.cwd(), (0, logging_1.getRunnerLogger)(true));
|
return fingerprints.resolveUriToFile(location, artifacts, process.cwd(), (0, logging_1.getRunnerLogger)(true));
|
||||||
}
|
}
|
||||||
(0, ava_1.default)("resolveUriToFile", (t) => {
|
(0, ava_1.default)("resolveUriToFile", (t) => {
|
||||||
|
var _a, _b;
|
||||||
// The resolveUriToFile method checks that the file exists and is in the right directory
|
// The resolveUriToFile method checks that the file exists and is in the right directory
|
||||||
// so we need to give it real files to look at. We will use this file as an example.
|
// so we need to give it real files to look at. We will use this file as an example.
|
||||||
// For this to work we require the current working directory to be a parent, but this
|
// For this to work we require the current working directory to be a parent, but this
|
||||||
// should generally always be the case so this is fine.
|
// should generally always be the case so this is fine.
|
||||||
const cwd = process.cwd();
|
const filepath = __filename.split(path.sep).join("/");
|
||||||
const filepath = __filename;
|
const relativeFilepath = path
|
||||||
t.true(filepath.startsWith(`${cwd}/`));
|
.relative(process.cwd(), __filename)
|
||||||
const relativeFilepath = filepath.substring(cwd.length + 1);
|
.split(path.sep)
|
||||||
|
.join("/");
|
||||||
// Absolute paths are unmodified
|
// Absolute paths are unmodified
|
||||||
t.is(testResolveUriToFile(filepath, undefined, []), filepath);
|
t.is(testResolveUriToFile(filepath, undefined, []), filepath);
|
||||||
t.is(testResolveUriToFile(`file://${filepath}`, undefined, []), filepath);
|
t.is(testResolveUriToFile(`file://${filepath}`, undefined, []), filepath);
|
||||||
// Relative paths are made absolute
|
// Relative paths are made absolute
|
||||||
t.is(testResolveUriToFile(relativeFilepath, undefined, []), filepath);
|
t.is((_a = testResolveUriToFile(relativeFilepath, undefined, [])) === null || _a === void 0 ? void 0 : _a.split(path.sep).join("/"), filepath);
|
||||||
t.is(testResolveUriToFile(`file://${relativeFilepath}`, undefined, []), filepath);
|
t.is((_b = testResolveUriToFile(`file://${relativeFilepath}`, undefined, [])) === null || _b === void 0 ? void 0 : _b.split(path.sep).join("/"), filepath);
|
||||||
// Absolute paths outside the src root are discarded
|
// Absolute paths outside the src root are discarded
|
||||||
t.is(testResolveUriToFile("/src/foo/bar.js", undefined, []), undefined);
|
t.is(testResolveUriToFile("/src/foo/bar.js", undefined, []), undefined);
|
||||||
t.is(testResolveUriToFile("file:///src/foo/bar.js", undefined, []), undefined);
|
t.is(testResolveUriToFile("file:///src/foo/bar.js", undefined, []), undefined);
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
12
lib/init-action.js
generated
12
lib/init-action.js
generated
@@ -71,6 +71,7 @@ async function run() {
|
|||||||
const startedAt = new Date();
|
const startedAt = new Date();
|
||||||
const logger = (0, logging_1.getActionsLogger)();
|
const logger = (0, logging_1.getActionsLogger)();
|
||||||
(0, util_1.initializeEnvironment)(util_1.Mode.actions, pkg.version);
|
(0, util_1.initializeEnvironment)(util_1.Mode.actions, pkg.version);
|
||||||
|
await (0, util_1.checkActionVersion)(pkg.version);
|
||||||
let config;
|
let config;
|
||||||
let codeql;
|
let codeql;
|
||||||
let toolsVersion;
|
let toolsVersion;
|
||||||
@@ -88,11 +89,16 @@ async function run() {
|
|||||||
if (!(await (0, actions_util_1.sendStatusReport)(await (0, actions_util_1.createStatusReportBase)("init", "starting", startedAt, workflowErrors)))) {
|
if (!(await (0, actions_util_1.sendStatusReport)(await (0, actions_util_1.createStatusReportBase)("init", "starting", startedAt, workflowErrors)))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const initCodeQLResult = await (0, init_1.initCodeQL)((0, actions_util_1.getOptionalInput)("tools"), apiDetails, (0, actions_util_1.getTemporaryDirectory)(), (0, actions_util_1.getToolCacheDirectory)(), gitHubVersion.type, logger);
|
const initCodeQLResult = await (0, init_1.initCodeQL)((0, actions_util_1.getOptionalInput)("tools"), apiDetails, (0, actions_util_1.getTemporaryDirectory)(), gitHubVersion.type, logger);
|
||||||
codeql = initCodeQLResult.codeql;
|
codeql = initCodeQLResult.codeql;
|
||||||
toolsVersion = initCodeQLResult.toolsVersion;
|
toolsVersion = initCodeQLResult.toolsVersion;
|
||||||
await (0, util_1.enrichEnvironment)(util_1.Mode.actions, codeql);
|
await (0, util_1.enrichEnvironment)(util_1.Mode.actions, codeql);
|
||||||
config = await (0, init_1.initConfig)((0, actions_util_1.getOptionalInput)("languages"), (0, actions_util_1.getOptionalInput)("queries"), (0, actions_util_1.getOptionalInput)("packs"), (0, actions_util_1.getOptionalInput)("config-file"), (0, actions_util_1.getOptionalInput)("db-location"), (0, actions_util_1.getOptionalInput)("debug") === "true", (0, actions_util_1.getOptionalInput)("debug-artifact-name") || util_1.DEFAULT_DEBUG_ARTIFACT_NAME, (0, actions_util_1.getOptionalInput)("debug-database-name") || util_1.DEFAULT_DEBUG_DATABASE_NAME, repositoryNwo, (0, actions_util_1.getTemporaryDirectory)(), (0, util_1.getRequiredEnvParam)("RUNNER_TOOL_CACHE"), codeql, (0, util_1.getRequiredEnvParam)("GITHUB_WORKSPACE"), gitHubVersion, apiDetails, featureFlags, logger);
|
config = await (0, init_1.initConfig)((0, actions_util_1.getOptionalInput)("languages"), (0, actions_util_1.getOptionalInput)("queries"), (0, actions_util_1.getOptionalInput)("packs"), (0, actions_util_1.getOptionalInput)("config-file"), (0, actions_util_1.getOptionalInput)("db-location"),
|
||||||
|
// Debug mode is enabled if:
|
||||||
|
// - The `init` Action is passed `debug: true`.
|
||||||
|
// - Actions step debugging is enabled (e.g. by [enabling debug logging for a rerun](https://docs.github.com/en/actions/managing-workflow-runs/re-running-workflows-and-jobs#re-running-all-the-jobs-in-a-workflow),
|
||||||
|
// or by setting the `ACTIONS_STEP_DEBUG` secret to `true`).
|
||||||
|
(0, actions_util_1.getOptionalInput)("debug") === "true" || core.isDebug(), (0, actions_util_1.getOptionalInput)("debug-artifact-name") || util_1.DEFAULT_DEBUG_ARTIFACT_NAME, (0, actions_util_1.getOptionalInput)("debug-database-name") || util_1.DEFAULT_DEBUG_DATABASE_NAME, repositoryNwo, (0, actions_util_1.getTemporaryDirectory)(), codeql, (0, util_1.getRequiredEnvParam)("GITHUB_WORKSPACE"), gitHubVersion, apiDetails, featureFlags, logger);
|
||||||
if (config.languages.includes(languages_1.Language.python) &&
|
if (config.languages.includes(languages_1.Language.python) &&
|
||||||
(0, actions_util_1.getRequiredInput)("setup-python-dependencies") === "true") {
|
(0, actions_util_1.getRequiredInput)("setup-python-dependencies") === "true") {
|
||||||
try {
|
try {
|
||||||
@@ -127,7 +133,7 @@ async function run() {
|
|||||||
(0, util_1.getMemoryFlagValue)((0, actions_util_1.getOptionalInput)("ram")).toString());
|
(0, util_1.getMemoryFlagValue)((0, actions_util_1.getOptionalInput)("ram")).toString());
|
||||||
core.exportVariable("CODEQL_THREADS", (0, util_1.getThreadsFlagValue)((0, actions_util_1.getOptionalInput)("threads"), logger).toString());
|
core.exportVariable("CODEQL_THREADS", (0, util_1.getThreadsFlagValue)((0, actions_util_1.getOptionalInput)("threads"), logger).toString());
|
||||||
const sourceRoot = path.resolve((0, util_1.getRequiredEnvParam)("GITHUB_WORKSPACE"), (0, actions_util_1.getOptionalInput)("source-root") || "");
|
const sourceRoot = path.resolve((0, util_1.getRequiredEnvParam)("GITHUB_WORKSPACE"), (0, actions_util_1.getOptionalInput)("source-root") || "");
|
||||||
const tracerConfig = await (0, init_1.runInit)(codeql, config, sourceRoot, "Runner.Worker.exe", undefined);
|
const tracerConfig = await (0, init_1.runInit)(codeql, config, sourceRoot, "Runner.Worker.exe", undefined, featureFlags);
|
||||||
if (tracerConfig !== undefined) {
|
if (tracerConfig !== undefined) {
|
||||||
for (const [key, value] of Object.entries(tracerConfig.env)) {
|
for (const [key, value] of Object.entries(tracerConfig.env)) {
|
||||||
core.exportVariable(key, value);
|
core.exportVariable(key, value);
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
17
lib/init.js
generated
17
lib/init.js
generated
@@ -30,29 +30,29 @@ const configUtils = __importStar(require("./config-utils"));
|
|||||||
const tracer_config_1 = require("./tracer-config");
|
const tracer_config_1 = require("./tracer-config");
|
||||||
const util = __importStar(require("./util"));
|
const util = __importStar(require("./util"));
|
||||||
const util_1 = require("./util");
|
const util_1 = require("./util");
|
||||||
async function initCodeQL(codeqlURL, apiDetails, tempDir, toolCacheDir, variant, logger) {
|
async function initCodeQL(codeqlURL, apiDetails, tempDir, variant, logger) {
|
||||||
logger.startGroup("Setup CodeQL tools");
|
logger.startGroup("Setup CodeQL tools");
|
||||||
const { codeql, toolsVersion } = await (0, codeql_1.setupCodeQL)(codeqlURL, apiDetails, tempDir, toolCacheDir, variant, logger, true);
|
const { codeql, toolsVersion } = await (0, codeql_1.setupCodeQL)(codeqlURL, apiDetails, tempDir, variant, logger, true);
|
||||||
await codeql.printVersion();
|
await codeql.printVersion();
|
||||||
logger.endGroup();
|
logger.endGroup();
|
||||||
return { codeql, toolsVersion };
|
return { codeql, toolsVersion };
|
||||||
}
|
}
|
||||||
exports.initCodeQL = initCodeQL;
|
exports.initCodeQL = initCodeQL;
|
||||||
async function initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger) {
|
async function initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger) {
|
||||||
logger.startGroup("Load language configuration");
|
logger.startGroup("Load language configuration");
|
||||||
const config = await configUtils.initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger);
|
const config = await configUtils.initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeQL, workspacePath, gitHubVersion, apiDetails, featureFlags, logger);
|
||||||
analysisPaths.printPathFiltersWarning(config, logger);
|
analysisPaths.printPathFiltersWarning(config, logger);
|
||||||
logger.endGroup();
|
logger.endGroup();
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
exports.initConfig = initConfig;
|
exports.initConfig = initConfig;
|
||||||
async function runInit(codeql, config, sourceRoot, processName, processLevel) {
|
async function runInit(codeql, config, sourceRoot, processName, processLevel, featureFlags) {
|
||||||
var _a, _b;
|
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)) {
|
||||||
// Init a database cluster
|
// Init a database cluster
|
||||||
await codeql.databaseInitCluster(config, sourceRoot, processName, processLevel);
|
await codeql.databaseInitCluster(config, sourceRoot, processName, processLevel, featureFlags);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (const language of config.languages) {
|
for (const language of config.languages) {
|
||||||
@@ -179,12 +179,15 @@ async function installPythonDeps(codeql, logger) {
|
|||||||
if (process.platform === "win32") {
|
if (process.platform === "win32") {
|
||||||
await new toolrunner.ToolRunner(await safeWhich.safeWhich("py"), [
|
await new toolrunner.ToolRunner(await safeWhich.safeWhich("py"), [
|
||||||
"-3",
|
"-3",
|
||||||
|
"-B",
|
||||||
path.join(scriptsFolder, script),
|
path.join(scriptsFolder, script),
|
||||||
path.dirname(codeql.getPath()),
|
path.dirname(codeql.getPath()),
|
||||||
]).exec();
|
]).exec();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
await new toolrunner.ToolRunner(path.join(scriptsFolder, script), [
|
await new toolrunner.ToolRunner(await safeWhich.safeWhich("python3"), [
|
||||||
|
"-B",
|
||||||
|
path.join(scriptsFolder, script),
|
||||||
path.dirname(codeql.getPath()),
|
path.dirname(codeql.getPath()),
|
||||||
]).exec();
|
]).exec();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,YAAoB,EACpB,OAA2B,EAC3B,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,YAAY,EACZ,OAAO,EACP,MAAM,EACN,IAAI,CACL,CAAC;IACF,MAAM,MAAM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,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,mBAAmB,CAAC;aAC9C,CAAC,CAAC,IAAI,EAAE,CAAC;SACX;aAAM;YACL,MAAM,IAAI,UAAU,CAAC,UAAU,CAC7B,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAC7C,CAAC,IAAI,EAAE,CAAC;SACV;QACD,MAAM,MAAM,GAAG,0BAA0B,CAAC;QAC1C,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE;YAChC,MAAM,IAAI,UAAU,CAAC,UAAU,CAAC,MAAM,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE;gBAC/D,IAAI;gBACJ,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;aAAM;YACL,MAAM,IAAI,UAAU,CAAC,UAAU,CAAC,MAAM,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE;gBACpE,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"}
|
||||||
3
lib/languages.js
generated
3
lib/languages.js
generated
@@ -11,6 +11,7 @@ var Language;
|
|||||||
Language["javascript"] = "javascript";
|
Language["javascript"] = "javascript";
|
||||||
Language["python"] = "python";
|
Language["python"] = "python";
|
||||||
Language["ruby"] = "ruby";
|
Language["ruby"] = "ruby";
|
||||||
|
Language["swift"] = "swift";
|
||||||
})(Language = exports.Language || (exports.Language = {}));
|
})(Language = exports.Language || (exports.Language = {}));
|
||||||
// Additional names for languages
|
// Additional names for languages
|
||||||
const LANGUAGE_ALIASES = {
|
const LANGUAGE_ALIASES = {
|
||||||
@@ -35,7 +36,7 @@ function parseLanguage(language) {
|
|||||||
}
|
}
|
||||||
exports.parseLanguage = parseLanguage;
|
exports.parseLanguage = parseLanguage;
|
||||||
function isTracedLanguage(language) {
|
function isTracedLanguage(language) {
|
||||||
return (["cpp", "java", "csharp"].includes(language) ||
|
return (["cpp", "java", "csharp", "swift"].includes(language) ||
|
||||||
(process.env["CODEQL_EXTRACTOR_GO_BUILD_TRACING"] === "on" &&
|
(process.env["CODEQL_EXTRACTOR_GO_BUILD_TRACING"] === "on" &&
|
||||||
language === Language.go));
|
language === Language.go));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"languages.js","sourceRoot":"","sources":["../src/languages.ts"],"names":[],"mappings":";;;AAAA,wCAAwC;AACxC,IAAY,QAQX;AARD,WAAY,QAAQ;IAClB,6BAAiB,CAAA;IACjB,uBAAW,CAAA;IACX,qBAAS,CAAA;IACT,yBAAa,CAAA;IACb,qCAAyB,CAAA;IACzB,6BAAiB,CAAA;IACjB,yBAAa,CAAA;AACf,CAAC,EARW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAQnB;AAED,iCAAiC;AACjC,MAAM,gBAAgB,GAAiC;IACrD,CAAC,EAAE,QAAQ,CAAC,GAAG;IACf,KAAK,EAAE,QAAQ,CAAC,GAAG;IACnB,IAAI,EAAE,QAAQ,CAAC,MAAM;IACrB,UAAU,EAAE,QAAQ,CAAC,UAAU;CAChC,CAAC;AAEF,gGAAgG;AAChG,SAAgB,aAAa,CAAC,QAAgB;IAC5C,0BAA0B;IAC1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AAC,QAAgB;IAC5C,0BAA0B;IAC1B,QAAQ,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;IAElC,6BAA6B;IAC7B,IAAI,QAAQ,IAAI,QAAQ,EAAE;QACxB,OAAO,QAAoB,CAAC;KAC7B;IAED,yBAAyB;IACzB,IAAI,QAAQ,IAAI,gBAAgB,EAAE;QAChC,OAAO,gBAAgB,CAAC,QAAQ,CAAC,CAAC;KACnC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAfD,sCAeC;AAED,SAAgB,gBAAgB,CAAC,QAAkB;IACjD,OAAO,CACL,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;QACrD,CAAC,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,KAAK,IAAI;YACxD,QAAQ,KAAK,QAAQ,CAAC,EAAE,CAAC,CAC5B,CAAC;AACJ,CAAC;AAND,4CAMC;AAED,SAAgB,iBAAiB,CAAC,QAAkB;IAClD,OAAO,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;AACrC,CAAC;AAFD,8CAEC"}
|
||||||
17
lib/runner.js
generated
17
lib/runner.js
generated
@@ -23,7 +23,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const os = __importStar(require("os"));
|
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const commander_1 = require("commander");
|
const commander_1 = require("commander");
|
||||||
const del_1 = __importDefault(require("del"));
|
const del_1 = __importDefault(require("del"));
|
||||||
@@ -51,13 +50,6 @@ function getTempDir(userInput) {
|
|||||||
}
|
}
|
||||||
return tempDir;
|
return tempDir;
|
||||||
}
|
}
|
||||||
function getToolsDir(userInput) {
|
|
||||||
const toolsDir = userInput || path.join(os.homedir(), "codeql-runner-tools");
|
|
||||||
if (!fs.existsSync(toolsDir)) {
|
|
||||||
fs.mkdirSync(toolsDir, { recursive: true });
|
|
||||||
}
|
|
||||||
return toolsDir;
|
|
||||||
}
|
|
||||||
const codeqlEnvJsonFilename = "codeql-env.json";
|
const codeqlEnvJsonFilename = "codeql-env.json";
|
||||||
function loadTracerEnvironment(config) {
|
function loadTracerEnvironment(config) {
|
||||||
const jsonEnvFile = path.join(config.tempDir, codeqlEnvJsonFilename);
|
const jsonEnvFile = path.join(config.tempDir, codeqlEnvJsonFilename);
|
||||||
@@ -134,7 +126,6 @@ program
|
|||||||
const logger = (0, logging_1.getRunnerLogger)(cmd.debug);
|
const logger = (0, logging_1.getRunnerLogger)(cmd.debug);
|
||||||
try {
|
try {
|
||||||
const tempDir = getTempDir(cmd.tempDir);
|
const tempDir = getTempDir(cmd.tempDir);
|
||||||
const toolsDir = getToolsDir(cmd.toolsDir);
|
|
||||||
const checkoutPath = cmd.checkoutPath || process.cwd();
|
const checkoutPath = cmd.checkoutPath || process.cwd();
|
||||||
// Wipe the temp dir
|
// Wipe the temp dir
|
||||||
logger.info(`Cleaning temp directory ${tempDir}`);
|
logger.info(`Cleaning temp directory ${tempDir}`);
|
||||||
@@ -160,13 +151,13 @@ program
|
|||||||
codeql = await (0, codeql_1.getCodeQL)(cmd.codeqlPath);
|
codeql = await (0, codeql_1.getCodeQL)(cmd.codeqlPath);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
codeql = (await (0, init_1.initCodeQL)(undefined, apiDetails, tempDir, toolsDir, gitHubVersion.type, logger)).codeql;
|
codeql = (await (0, init_1.initCodeQL)(undefined, apiDetails, tempDir, gitHubVersion.type, logger)).codeql;
|
||||||
}
|
}
|
||||||
await (0, util_1.enrichEnvironment)(util_1.Mode.runner, codeql);
|
await (0, util_1.enrichEnvironment)(util_1.Mode.runner, codeql);
|
||||||
const workspacePath = checkoutPath;
|
const workspacePath = checkoutPath;
|
||||||
const config = await (0, init_1.initConfig)(cmd.languages, cmd.queries, cmd.packs, cmd.configFile, undefined, false, "", "", (0, repository_1.parseRepositoryNwo)(cmd.repository), tempDir, toolsDir, codeql, workspacePath, gitHubVersion, apiDetails, (0, feature_flags_1.createFeatureFlags)([]), logger);
|
const config = await (0, init_1.initConfig)(cmd.languages, cmd.queries, cmd.packs, cmd.configFile, undefined, false, "", "", (0, repository_1.parseRepositoryNwo)(cmd.repository), tempDir, codeql, workspacePath, gitHubVersion, apiDetails, (0, feature_flags_1.createFeatureFlags)([]), logger);
|
||||||
const sourceRoot = checkoutPath;
|
const sourceRoot = checkoutPath;
|
||||||
const tracerConfig = await (0, init_1.runInit)(codeql, config, sourceRoot, parseTraceProcessName(), parseTraceProcessLevel());
|
const tracerConfig = await (0, init_1.runInit)(codeql, config, sourceRoot, parseTraceProcessName(), parseTraceProcessLevel(), (0, feature_flags_1.createFeatureFlags)([]));
|
||||||
if (tracerConfig === undefined) {
|
if (tracerConfig === undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -297,7 +288,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);
|
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);
|
||||||
if (!cmd.upload) {
|
if (!cmd.upload) {
|
||||||
logger.info("Not uploading results");
|
logger.info("Not uploading results");
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
7
lib/testing-utils.js
generated
7
lib/testing-utils.js
generated
@@ -64,6 +64,13 @@ function setupTests(test) {
|
|||||||
const processStderrWrite = process.stderr.write.bind(process.stderr);
|
const processStderrWrite = process.stderr.write.bind(process.stderr);
|
||||||
t.context.stderrWrite = processStderrWrite;
|
t.context.stderrWrite = processStderrWrite;
|
||||||
process.stderr.write = wrapOutput(t.context);
|
process.stderr.write = wrapOutput(t.context);
|
||||||
|
// Workaround an issue in tests where the case insensitivity of the `$PATH`
|
||||||
|
// environment variable on Windows isn't preserved, i.e. `process.env.PATH`
|
||||||
|
// is not the same as `process.env.Path`.
|
||||||
|
const pathKeys = Object.keys(process.env).filter((k) => k.toLowerCase() === "path");
|
||||||
|
if (pathKeys.length > 0) {
|
||||||
|
process.env.PATH = process.env[pathKeys[0]];
|
||||||
|
}
|
||||||
// Many tests modify environment variables. Take a copy now so that
|
// Many tests modify environment variables. Take a copy now so that
|
||||||
// we reset them after the test to keep tests independent of each other.
|
// we reset them after the test to keep tests independent of each other.
|
||||||
// process.env only has strings fields, so a shallow copy is fine.
|
// process.env only has strings fields, so a shallow copy is fine.
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"testing-utils.js","sourceRoot":"","sources":["../src/testing-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,wDAA0C;AAE1C,6CAA+B;AAE/B,wDAA0C;AAC1C,iDAAmC;AAEnC,iCAAmC;AASnC,SAAS,UAAU,CAAC,OAAoB;IACtC,8CAA8C;IAC9C,gCAAgC;IAChC,2EAA2E;IAC3E,2FAA2F;IAC3F,OAAO,CACL,KAA0B,EAC1B,QAAiB,EACjB,EAA0B,EACjB,EAAE;QACX,2CAA2C;QAC3C,IAAI,EAAE,KAAK,SAAS,IAAI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M,CAAC,IAAI,gBAAS,CAAC,oBAAoB,EAAE,kBAAkB,CAAC,CAAC,CAAC;KAC1E;IAED,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC;AAC5D,CAAC;AAxBD,gEAwBC"}
|
||||||
286
lib/toolcache.js
generated
286
lib/toolcache.js
generated
@@ -1,286 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
||||||
__setModuleDefault(result, mod);
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.downloadTool = exports.findAllVersions = exports.find = exports.cacheDir = exports.extractTar = void 0;
|
|
||||||
const fs = __importStar(require("fs"));
|
|
||||||
const os = __importStar(require("os"));
|
|
||||||
const path = __importStar(require("path"));
|
|
||||||
const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
|
|
||||||
const io = __importStar(require("@actions/io"));
|
|
||||||
const actionsToolcache = __importStar(require("@actions/tool-cache"));
|
|
||||||
const safeWhich = __importStar(require("@chrisgavin/safe-which"));
|
|
||||||
const del_1 = __importDefault(require("del"));
|
|
||||||
const semver = __importStar(require("semver"));
|
|
||||||
const uuid_1 = require("uuid");
|
|
||||||
const util_1 = require("./util");
|
|
||||||
/*
|
|
||||||
* This file acts as an interface to the functionality of the actions toolcache.
|
|
||||||
* That library is not safe to use outside of actions as it makes assumptions about
|
|
||||||
* the state of the filesystem and available environment variables.
|
|
||||||
*
|
|
||||||
* On actions we can just delegate to the toolcache library, however outside of
|
|
||||||
* actions we provide our own implementation.
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* Extract a compressed tar archive.
|
|
||||||
*
|
|
||||||
* See extractTar function from node_modules/@actions/tool-cache/lib/tool-cache.d.ts
|
|
||||||
*
|
|
||||||
* @param file path to the tar
|
|
||||||
* @param mode should run the actions or runner implementation
|
|
||||||
* @param tempDir path to the temporary directory
|
|
||||||
* @param logger logger to use
|
|
||||||
* @returns path to the destination directory
|
|
||||||
*/
|
|
||||||
async function extractTar(file, tempDir, logger) {
|
|
||||||
if ((0, util_1.isActions)()) {
|
|
||||||
return await actionsToolcache.extractTar(file);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Initial implementation copied from node_modules/@actions/tool-cache/lib/tool-cache.js
|
|
||||||
if (!file) {
|
|
||||||
throw new Error("parameter 'file' is required");
|
|
||||||
}
|
|
||||||
// Create dest
|
|
||||||
const dest = createExtractFolder(tempDir);
|
|
||||||
// Determine whether GNU tar
|
|
||||||
logger.debug("Checking tar --version");
|
|
||||||
let versionOutput = "";
|
|
||||||
await new toolrunner.ToolRunner(await safeWhich.safeWhich("tar"), ["--version"], {
|
|
||||||
ignoreReturnCode: true,
|
|
||||||
silent: true,
|
|
||||||
listeners: {
|
|
||||||
stdout: (data) => (versionOutput += data.toString()),
|
|
||||||
stderr: (data) => (versionOutput += data.toString()),
|
|
||||||
},
|
|
||||||
}).exec();
|
|
||||||
logger.debug(versionOutput.trim());
|
|
||||||
const isGnuTar = versionOutput.toUpperCase().includes("GNU TAR");
|
|
||||||
// Initialize args
|
|
||||||
const args = ["xz"];
|
|
||||||
if (logger.isDebug()) {
|
|
||||||
args.push("-v");
|
|
||||||
}
|
|
||||||
let destArg = dest;
|
|
||||||
let fileArg = file;
|
|
||||||
if (process.platform === "win32" && isGnuTar) {
|
|
||||||
args.push("--force-local");
|
|
||||||
destArg = dest.replace(/\\/g, "/");
|
|
||||||
// Technically only the dest needs to have `/` but for aesthetic consistency
|
|
||||||
// convert slashes in the file arg too.
|
|
||||||
fileArg = file.replace(/\\/g, "/");
|
|
||||||
}
|
|
||||||
if (isGnuTar) {
|
|
||||||
// Suppress warnings when using GNU tar to extract archives created by BSD tar
|
|
||||||
args.push("--warning=no-unknown-keyword");
|
|
||||||
}
|
|
||||||
args.push("-C", destArg, "-f", fileArg);
|
|
||||||
await new toolrunner.ToolRunner(`tar`, args).exec();
|
|
||||||
return dest;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.extractTar = extractTar;
|
|
||||||
/**
|
|
||||||
* Caches a directory and installs it into the tool cacheDir.
|
|
||||||
*
|
|
||||||
* Also see cacheDir function from node_modules/@actions/tool-cache/lib/tool-cache.d.ts
|
|
||||||
*
|
|
||||||
* @param sourceDir the directory to cache into tools
|
|
||||||
* @param tool tool name
|
|
||||||
* @param version version of the tool. semver format
|
|
||||||
* @param mode should run the actions or runner implementation
|
|
||||||
* @param toolCacheDir path to the tool cache directory
|
|
||||||
* @param logger logger to use
|
|
||||||
*/
|
|
||||||
async function cacheDir(sourceDir, tool, version, toolCacheDir, logger) {
|
|
||||||
if ((0, util_1.isActions)()) {
|
|
||||||
return await actionsToolcache.cacheDir(sourceDir, tool, version);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Initial implementation copied from node_modules/@actions/tool-cache/lib/tool-cache.js
|
|
||||||
version = semver.clean(version) || version;
|
|
||||||
const arch = os.arch();
|
|
||||||
logger.debug(`Caching tool ${tool} ${version} ${arch}`);
|
|
||||||
logger.debug(`source dir: ${sourceDir}`);
|
|
||||||
if (!fs.statSync(sourceDir).isDirectory()) {
|
|
||||||
throw new Error("sourceDir is not a directory");
|
|
||||||
}
|
|
||||||
// Create the tool dir
|
|
||||||
const destPath = await createToolPath(tool, version, arch, toolCacheDir, logger);
|
|
||||||
// copy each child item. do not move. move can fail on Windows
|
|
||||||
// due to anti-virus software having an open handle on a file.
|
|
||||||
for (const itemName of fs.readdirSync(sourceDir)) {
|
|
||||||
const s = path.join(sourceDir, itemName);
|
|
||||||
await io.cp(s, destPath, { recursive: true });
|
|
||||||
}
|
|
||||||
// write .complete
|
|
||||||
completeToolPath(tool, version, arch, toolCacheDir, logger);
|
|
||||||
return destPath;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.cacheDir = cacheDir;
|
|
||||||
/**
|
|
||||||
* Finds the path to a tool version in the local installed tool cache.
|
|
||||||
*
|
|
||||||
* Also see find function from node_modules/@actions/tool-cache/lib/tool-cache.d.ts
|
|
||||||
*
|
|
||||||
* @param toolName name of the tool
|
|
||||||
* @param versionSpec version of the tool
|
|
||||||
* @param mode should run the actions or runner implementation
|
|
||||||
* @param toolCacheDir path to the tool cache directory
|
|
||||||
* @param logger logger to use
|
|
||||||
*/
|
|
||||||
function find(toolName, versionSpec, toolCacheDir, logger) {
|
|
||||||
if ((0, util_1.isActions)()) {
|
|
||||||
return actionsToolcache.find(toolName, versionSpec);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Initial implementation copied from node_modules/@actions/tool-cache/lib/tool-cache.js
|
|
||||||
if (!toolName) {
|
|
||||||
throw new Error("toolName parameter is required");
|
|
||||||
}
|
|
||||||
if (!versionSpec) {
|
|
||||||
throw new Error("versionSpec parameter is required");
|
|
||||||
}
|
|
||||||
const arch = os.arch();
|
|
||||||
// attempt to resolve an explicit version
|
|
||||||
if (!isExplicitVersion(versionSpec, logger)) {
|
|
||||||
const localVersions = findAllVersions(toolName, toolCacheDir, logger);
|
|
||||||
const match = evaluateVersions(localVersions, versionSpec, logger);
|
|
||||||
versionSpec = match;
|
|
||||||
}
|
|
||||||
// check for the explicit version in the cache
|
|
||||||
let toolPath = "";
|
|
||||||
if (versionSpec) {
|
|
||||||
versionSpec = semver.clean(versionSpec) || "";
|
|
||||||
const cachePath = path.join(toolCacheDir, toolName, versionSpec, arch);
|
|
||||||
logger.debug(`checking cache: ${cachePath}`);
|
|
||||||
if (fs.existsSync(cachePath) && fs.existsSync(`${cachePath}.complete`)) {
|
|
||||||
logger.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch}`);
|
|
||||||
toolPath = cachePath;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
logger.debug("not found");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return toolPath;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.find = find;
|
|
||||||
/**
|
|
||||||
* Finds the paths to all versions of a tool that are installed in the local tool cache.
|
|
||||||
*
|
|
||||||
* Also see findAllVersions function from node_modules/@actions/tool-cache/lib/tool-cache.d.ts
|
|
||||||
*
|
|
||||||
* @param toolName name of the tool
|
|
||||||
* @param toolCacheDir path to the tool cache directory
|
|
||||||
* @param logger logger to use
|
|
||||||
*/
|
|
||||||
function findAllVersions(toolName, toolCacheDir, logger) {
|
|
||||||
if ((0, util_1.isActions)()) {
|
|
||||||
return actionsToolcache.findAllVersions(toolName);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Initial implementation copied from node_modules/@actions/tool-cache/lib/tool-cache.js
|
|
||||||
const versions = [];
|
|
||||||
const arch = os.arch();
|
|
||||||
const toolPath = path.join(toolCacheDir, toolName);
|
|
||||||
if (fs.existsSync(toolPath)) {
|
|
||||||
const children = fs.readdirSync(toolPath);
|
|
||||||
for (const child of children) {
|
|
||||||
if (isExplicitVersion(child, logger)) {
|
|
||||||
const fullPath = path.join(toolPath, child, arch || "");
|
|
||||||
if (fs.existsSync(fullPath) &&
|
|
||||||
fs.existsSync(`${fullPath}.complete`)) {
|
|
||||||
versions.push(child);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return versions;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.findAllVersions = findAllVersions;
|
|
||||||
async function downloadTool(url, tempDir, headers) {
|
|
||||||
const dest = path.join(tempDir, (0, uuid_1.v4)());
|
|
||||||
const finalHeaders = Object.assign({ "User-Agent": "CodeQL Action" }, headers);
|
|
||||||
return await actionsToolcache.downloadTool(url, dest, undefined, finalHeaders);
|
|
||||||
}
|
|
||||||
exports.downloadTool = downloadTool;
|
|
||||||
function createExtractFolder(tempDir) {
|
|
||||||
// create a temp dir
|
|
||||||
const dest = path.join(tempDir, "toolcache-temp");
|
|
||||||
if (!fs.existsSync(dest)) {
|
|
||||||
fs.mkdirSync(dest);
|
|
||||||
}
|
|
||||||
return dest;
|
|
||||||
}
|
|
||||||
async function createToolPath(tool, version, arch, toolCacheDir, logger) {
|
|
||||||
const folderPath = path.join(toolCacheDir, tool, semver.clean(version) || version, arch || "");
|
|
||||||
logger.debug(`destination ${folderPath}`);
|
|
||||||
const markerPath = `${folderPath}.complete`;
|
|
||||||
await (0, del_1.default)(folderPath, { force: true });
|
|
||||||
await (0, del_1.default)(markerPath, { force: true });
|
|
||||||
fs.mkdirSync(folderPath, { recursive: true });
|
|
||||||
return folderPath;
|
|
||||||
}
|
|
||||||
function completeToolPath(tool, version, arch, toolCacheDir, logger) {
|
|
||||||
const folderPath = path.join(toolCacheDir, tool, semver.clean(version) || version, arch || "");
|
|
||||||
const markerPath = `${folderPath}.complete`;
|
|
||||||
fs.writeFileSync(markerPath, "");
|
|
||||||
logger.debug("finished caching tool");
|
|
||||||
}
|
|
||||||
function isExplicitVersion(versionSpec, logger) {
|
|
||||||
const c = semver.clean(versionSpec) || "";
|
|
||||||
logger.debug(`isExplicit: ${c}`);
|
|
||||||
const valid = semver.valid(c) != null;
|
|
||||||
logger.debug(`explicit? ${valid}`);
|
|
||||||
return valid;
|
|
||||||
}
|
|
||||||
function evaluateVersions(versions, versionSpec, logger) {
|
|
||||||
let version = "";
|
|
||||||
logger.debug(`evaluating ${versions.length} versions`);
|
|
||||||
versions = versions.sort((a, b) => {
|
|
||||||
if (semver.gt(a, b)) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
});
|
|
||||||
for (let i = versions.length - 1; i >= 0; i--) {
|
|
||||||
const potential = versions[i];
|
|
||||||
const satisfied = semver.satisfies(potential, versionSpec);
|
|
||||||
if (satisfied) {
|
|
||||||
version = potential;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (version) {
|
|
||||||
logger.debug(`matched: ${version}`);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
logger.debug("match not found");
|
|
||||||
}
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=toolcache.js.map
|
|
||||||
File diff suppressed because one or more lines are too long
1
lib/tracer-config.test.js
generated
1
lib/tracer-config.test.js
generated
@@ -39,7 +39,6 @@ function getTestConfig(tmpDir) {
|
|||||||
paths: [],
|
paths: [],
|
||||||
originalUserInput: {},
|
originalUserInput: {},
|
||||||
tempDir: tmpDir,
|
tempDir: tmpDir,
|
||||||
toolCacheDir: tmpDir,
|
|
||||||
codeQLCmd: "",
|
codeQLCmd: "",
|
||||||
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
||||||
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
29
lib/upload-lib.js
generated
29
lib/upload-lib.js
generated
@@ -93,8 +93,7 @@ function getAutomationID(category, analysis_key, environment) {
|
|||||||
async function uploadPayload(payload, repositoryNwo, apiDetails, logger) {
|
async function uploadPayload(payload, repositoryNwo, apiDetails, logger) {
|
||||||
logger.info("Uploading results");
|
logger.info("Uploading results");
|
||||||
// If in test mode we don't want to upload the results
|
// If in test mode we don't want to upload the results
|
||||||
const testMode = process.env["TEST_MODE"] === "true" || false;
|
if (util.isInTestMode()) {
|
||||||
if (testMode) {
|
|
||||||
const payloadSaveFile = path.join(actionsUtil.getTemporaryDirectory(), "payload.json");
|
const payloadSaveFile = path.join(actionsUtil.getTemporaryDirectory(), "payload.json");
|
||||||
logger.info(`In test mode. Results are not uploaded. Saving to ${payloadSaveFile}`);
|
logger.info(`In test mode. Results are not uploaded. Saving to ${payloadSaveFile}`);
|
||||||
logger.info(`Payload: ${JSON.stringify(payload, null, 2)}`);
|
logger.info(`Payload: ${JSON.stringify(payload, null, 2)}`);
|
||||||
@@ -311,26 +310,28 @@ async function waitForProcessing(repositoryNwo, sarifID, apiDetails, logger) {
|
|||||||
logger.warning("Timed out waiting for analysis to finish processing. Continuing.");
|
logger.warning("Timed out waiting for analysis to finish processing. Continuing.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
let response = undefined;
|
||||||
try {
|
try {
|
||||||
const response = await client.request("GET /repos/:owner/:repo/code-scanning/sarifs/:sarif_id", {
|
response = await client.request("GET /repos/:owner/:repo/code-scanning/sarifs/:sarif_id", {
|
||||||
owner: repositoryNwo.owner,
|
owner: repositoryNwo.owner,
|
||||||
repo: repositoryNwo.repo,
|
repo: repositoryNwo.repo,
|
||||||
sarif_id: sarifID,
|
sarif_id: sarifID,
|
||||||
});
|
});
|
||||||
const status = response.data.processing_status;
|
|
||||||
logger.info(`Analysis upload status is ${status}.`);
|
|
||||||
if (status === "complete") {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (status === "pending") {
|
|
||||||
logger.debug("Analysis processing is still pending...");
|
|
||||||
}
|
|
||||||
else if (status === "failed") {
|
|
||||||
throw new Error(`Code Scanning could not process the submitted SARIF file:\n${response.data.errors}`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
logger.warning(`An error occurred checking the status of the delivery. ${e} It should still be processed in the background, but errors that occur during processing may not be reported.`);
|
logger.warning(`An error occurred checking the status of the delivery. ${e} It should still be processed in the background, but errors that occur during processing may not be reported.`);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
const status = response.data.processing_status;
|
||||||
|
logger.info(`Analysis upload status is ${status}.`);
|
||||||
|
if (status === "complete") {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (status === "pending") {
|
||||||
|
logger.debug("Analysis processing is still pending...");
|
||||||
|
}
|
||||||
|
else if (status === "failed") {
|
||||||
|
throw new Error(`Code Scanning could not process the submitted SARIF file:\n${response.data.errors}`);
|
||||||
}
|
}
|
||||||
await util.delay(STATUS_CHECK_FREQUENCY_MILLISECONDS);
|
await util.delay(STATUS_CHECK_FREQUENCY_MILLISECONDS);
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
9
lib/upload-sarif-action.js
generated
9
lib/upload-sarif-action.js
generated
@@ -37,8 +37,9 @@ async function sendSuccessStatusReport(startedAt, uploadStats) {
|
|||||||
await actionsUtil.sendStatusReport(statusReport);
|
await actionsUtil.sendStatusReport(statusReport);
|
||||||
}
|
}
|
||||||
async function run() {
|
async function run() {
|
||||||
(0, util_1.initializeEnvironment)(util_1.Mode.actions, pkg.version);
|
|
||||||
const startedAt = new Date();
|
const startedAt = new Date();
|
||||||
|
(0, util_1.initializeEnvironment)(util_1.Mode.actions, pkg.version);
|
||||||
|
await (0, util_1.checkActionVersion)(pkg.version);
|
||||||
if (!(await actionsUtil.sendStatusReport(await actionsUtil.createStatusReportBase("upload-sarif", "starting", startedAt)))) {
|
if (!(await actionsUtil.sendStatusReport(await actionsUtil.createStatusReportBase("upload-sarif", "starting", startedAt)))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -50,7 +51,11 @@ async function run() {
|
|||||||
const gitHubVersion = await (0, api_client_1.getGitHubVersionActionsOnly)();
|
const gitHubVersion = await (0, api_client_1.getGitHubVersionActionsOnly)();
|
||||||
const uploadResult = await upload_lib.uploadFromActions(actionsUtil.getRequiredInput("sarif_file"), gitHubVersion, apiDetails, (0, logging_1.getActionsLogger)());
|
const uploadResult = await upload_lib.uploadFromActions(actionsUtil.getRequiredInput("sarif_file"), gitHubVersion, apiDetails, (0, logging_1.getActionsLogger)());
|
||||||
core.setOutput("sarif-id", uploadResult.sarifID);
|
core.setOutput("sarif-id", uploadResult.sarifID);
|
||||||
if (actionsUtil.getRequiredInput("wait-for-processing") === "true") {
|
// We don't upload results in test mode, so don't wait for processing
|
||||||
|
if ((0, util_1.isInTestMode)()) {
|
||||||
|
core.debug("In test mode. Waiting for processing is disabled.");
|
||||||
|
}
|
||||||
|
else if (actionsUtil.getRequiredInput("wait-for-processing") === "true") {
|
||||||
await upload_lib.waitForProcessing((0, repository_1.parseRepositoryNwo)((0, util_1.getRequiredEnvParam)("GITHUB_REPOSITORY")), uploadResult.sarifID, apiDetails, (0, logging_1.getActionsLogger)());
|
await upload_lib.waitForProcessing((0, repository_1.parseRepositoryNwo)((0, util_1.getRequiredEnvParam)("GITHUB_REPOSITORY")), uploadResult.sarifID, apiDetails, (0, logging_1.getActionsLogger)());
|
||||||
}
|
}
|
||||||
await sendSuccessStatusReport(startedAt, uploadResult.statusReport);
|
await sendSuccessStatusReport(startedAt, uploadResult.statusReport);
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"upload-sarif-action.js","sourceRoot":"","sources":["../src/upload-sarif-action.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsC;AAEtC,4DAA8C;AAC9C,6CAA2D;AAC3D,uCAA6C;AAC7C,6CAAkD;AAClD,yDAA2C;AAC3C,iCAA0E;AAE1E,8CAA8C;AAC9C,MAAM,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAMvC,KAAK,UAAU,uBAAuB,CACpC,SA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AK,MAAM,EAAE;YACzE,MAAM,UAAU,CAAC,iBAAiB,CAChC,IAAA,+BAAkB,EAAC,IAAA,0BAAmB,EAAC,mBAAmB,CAAC,CAAC,EAC5D,YAAY,CAAC,OAAO,EACpB,UAAU,EACV,IAAA,0BAAgB,GAAE,CACnB,CAAC;SACH;QACD,MAAM,uBAAuB,CAAC,SAAS,EAAE,YAAY,CAAC,YAAY,CAAC,CAAC;KACrE;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,MAAM,KAAK,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACnE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACxB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACnB,MAAM,WAAW,CAAC,gBAAgB,CAChC,MAAM,WAAW,CAAC,sBAAsB,CACtC,cAAc,EACd,WAAW,CAAC,gBAAgB,CAAC,KAAK,CAAC,EACnC,SAAS,EACT,OAAO,EACP,KAAK,CACN,CACF,CAAC;QACF,OAAO;KACR;AACH,CAAC;AAED,KAAK,UAAU,UAAU;IACvB,IAAI;QACF,MAAM,GAAG,EAAE,CAAC;KACb;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,SAAS,CAAC,sCAAsC,KAAK,EAAE,CAAC,CAAC;QAC9D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;KACpB;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"}
|
||||||
65
lib/util.js
generated
65
lib/util.js
generated
@@ -22,13 +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.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.DEFAULT_DEBUG_DATABASE_NAME = exports.DEFAULT_DEBUG_ARTIFACT_NAME = exports.GITHUB_DOTCOM_URL = void 0;
|
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.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 core = __importStar(require("@actions/core"));
|
const core = __importStar(require("@actions/core"));
|
||||||
const del_1 = __importDefault(require("del"));
|
const del_1 = __importDefault(require("del"));
|
||||||
const semver = __importStar(require("semver"));
|
const semver = __importStar(require("semver"));
|
||||||
|
const api = __importStar(require("./api-client"));
|
||||||
const api_client_1 = require("./api-client");
|
const api_client_1 = require("./api-client");
|
||||||
const apiCompatibility = __importStar(require("./api-compatibility.json"));
|
const apiCompatibility = __importStar(require("./api-compatibility.json"));
|
||||||
const codeql_1 = require("./codeql");
|
const codeql_1 = require("./codeql");
|
||||||
@@ -88,11 +89,7 @@ exports.getToolNames = getToolNames;
|
|||||||
// Mostly intended for use within tests.
|
// Mostly intended for use within tests.
|
||||||
async function withTmpDir(body) {
|
async function withTmpDir(body) {
|
||||||
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "codeql-action-"));
|
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "codeql-action-"));
|
||||||
const realSubdir = path.join(tmpDir, "real");
|
const result = await body(tmpDir);
|
||||||
fs.mkdirSync(realSubdir);
|
|
||||||
const symlinkSubdir = path.join(tmpDir, "symlink");
|
|
||||||
fs.symlinkSync(realSubdir, symlinkSubdir, "dir");
|
|
||||||
const result = await body(symlinkSubdir);
|
|
||||||
await (0, del_1.default)(tmpDir, { force: true });
|
await (0, del_1.default)(tmpDir, { force: true });
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -551,10 +548,17 @@ exports.ML_POWERED_JS_QUERIES_PACK_NAME = "codeql/javascript-experimental-atm-qu
|
|||||||
* queries beta.
|
* queries beta.
|
||||||
*/
|
*/
|
||||||
async function getMlPoweredJsQueriesPack(codeQL) {
|
async function getMlPoweredJsQueriesPack(codeQL) {
|
||||||
if (await codeQlVersionAbove(codeQL, "2.8.4")) {
|
let version;
|
||||||
return { packName: exports.ML_POWERED_JS_QUERIES_PACK_NAME, version: "~0.2.0" };
|
if (await codeQlVersionAbove(codeQL, "2.9.3")) {
|
||||||
|
version = `~0.3.0`;
|
||||||
}
|
}
|
||||||
return { packName: exports.ML_POWERED_JS_QUERIES_PACK_NAME, version: "~0.1.0" };
|
else if (await codeQlVersionAbove(codeQL, "2.8.4")) {
|
||||||
|
version = `~0.2.0`;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
version = `~0.1.0`;
|
||||||
|
}
|
||||||
|
return `${exports.ML_POWERED_JS_QUERIES_PACK_NAME}@${version}`;
|
||||||
}
|
}
|
||||||
exports.getMlPoweredJsQueriesPack = getMlPoweredJsQueriesPack;
|
exports.getMlPoweredJsQueriesPack = getMlPoweredJsQueriesPack;
|
||||||
/**
|
/**
|
||||||
@@ -579,7 +583,10 @@ exports.getMlPoweredJsQueriesPack = getMlPoweredJsQueriesPack;
|
|||||||
* explanation as to why this is.
|
* explanation as to why this is.
|
||||||
*/
|
*/
|
||||||
function getMlPoweredJsQueriesStatus(config) {
|
function getMlPoweredJsQueriesStatus(config) {
|
||||||
const mlPoweredJsQueryPacks = (config.packs.javascript || []).filter((pack) => pack.packName === exports.ML_POWERED_JS_QUERIES_PACK_NAME);
|
const mlPoweredJsQueryPacks = (config.packs.javascript || [])
|
||||||
|
.map((pack) => pack.split("@"))
|
||||||
|
.filter((packNameVersion) => packNameVersion[0] === "codeql/javascript-experimental-atm-queries" &&
|
||||||
|
packNameVersion.length <= 2);
|
||||||
switch (mlPoweredJsQueryPacks.length) {
|
switch (mlPoweredJsQueryPacks.length) {
|
||||||
case 1:
|
case 1:
|
||||||
// We should always specify an explicit version string in `getMlPoweredJsQueriesPack`,
|
// We should always specify an explicit version string in `getMlPoweredJsQueriesPack`,
|
||||||
@@ -587,7 +594,7 @@ function getMlPoweredJsQueriesStatus(config) {
|
|||||||
// with each version of the CodeQL Action. Therefore in practice we should only hit the
|
// with each version of the CodeQL Action. Therefore in practice we should only hit the
|
||||||
// `latest` case here when customers have explicitly added the ML-powered query pack to their
|
// `latest` case here when customers have explicitly added the ML-powered query pack to their
|
||||||
// CodeQL config.
|
// CodeQL config.
|
||||||
return mlPoweredJsQueryPacks[0].version || "latest";
|
return mlPoweredJsQueryPacks[0][1] || "latest";
|
||||||
case 0:
|
case 0:
|
||||||
return "false";
|
return "false";
|
||||||
default:
|
default:
|
||||||
@@ -595,4 +602,40 @@ function getMlPoweredJsQueriesStatus(config) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.getMlPoweredJsQueriesStatus = getMlPoweredJsQueriesStatus;
|
exports.getMlPoweredJsQueriesStatus = getMlPoweredJsQueriesStatus;
|
||||||
|
/**
|
||||||
|
* Prompt the customer to upgrade to CodeQL Action v2, if appropriate.
|
||||||
|
*
|
||||||
|
* Check whether a customer is running v1. If they are, and we can determine that the GitHub
|
||||||
|
* instance supports v2, then log a warning about v1's upcoming deprecation prompting the customer
|
||||||
|
* to upgrade to v2.
|
||||||
|
*/
|
||||||
|
async function checkActionVersion(version) {
|
||||||
|
var _a;
|
||||||
|
if (!semver.satisfies(version, ">=2")) {
|
||||||
|
const githubVersion = await api.getGitHubVersionActionsOnly();
|
||||||
|
// Only log a warning for versions of GHES that are compatible with CodeQL Action version 2.
|
||||||
|
//
|
||||||
|
// GHES 3.4 shipped without the v2 tag, but it also shipped without this warning message code.
|
||||||
|
// Therefore users who are seeing this warning message code have pulled in a new version of the
|
||||||
|
// Action, and with it the v2 tag.
|
||||||
|
if (githubVersion.type === GitHubVariant.DOTCOM ||
|
||||||
|
githubVersion.type === GitHubVariant.GHAE ||
|
||||||
|
(githubVersion.type === GitHubVariant.GHES &&
|
||||||
|
semver.satisfies((_a = semver.coerce(githubVersion.version)) !== null && _a !== void 0 ? _a : "0.0.0", ">=3.4"))) {
|
||||||
|
core.warning("CodeQL Action v1 will be deprecated on December 7th, 2022. Please upgrade to v2. For " +
|
||||||
|
"more information, see " +
|
||||||
|
"https://github.blog/changelog/2022-04-27-code-scanning-deprecation-of-codeql-action-v1/");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.checkActionVersion = checkActionVersion;
|
||||||
|
/*
|
||||||
|
* Returns whether we are in test mode.
|
||||||
|
*
|
||||||
|
* In test mode, we don't upload SARIF results or status reports to the GitHub API.
|
||||||
|
*/
|
||||||
|
function isInTestMode() {
|
||||||
|
return process.env["TEST_MODE"] === "true" || false;
|
||||||
|
}
|
||||||
|
exports.isInTestMode = isInTestMode;
|
||||||
//# sourceMappingURL=util.js.map
|
//# sourceMappingURL=util.js.map
|
||||||
File diff suppressed because one or more lines are too long
74
lib/util.test.js
generated
74
lib/util.test.js
generated
@@ -25,6 +25,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const os = __importStar(require("os"));
|
const os = __importStar(require("os"));
|
||||||
const stream = __importStar(require("stream"));
|
const stream = __importStar(require("stream"));
|
||||||
|
const core = __importStar(require("@actions/core"));
|
||||||
const github = __importStar(require("@actions/github"));
|
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"));
|
||||||
@@ -208,40 +209,28 @@ const ML_POWERED_JS_STATUS_TESTS = [
|
|||||||
// If no packs are loaded, status is false.
|
// If no packs are loaded, status is false.
|
||||||
[[], "false"],
|
[[], "false"],
|
||||||
// If another pack is loaded but not the ML-powered query pack, status is false.
|
// If another pack is loaded but not the ML-powered query pack, status is false.
|
||||||
[[{ packName: "someOtherPack" }], "false"],
|
[["someOtherPack"], "false"],
|
||||||
// If the ML-powered query pack is loaded with a specific version, status is that version.
|
// If the ML-powered query pack is loaded with a specific version, status is that version.
|
||||||
[
|
[[`${util.ML_POWERED_JS_QUERIES_PACK_NAME}@~0.1.0`], "~0.1.0"],
|
||||||
[{ packName: util.ML_POWERED_JS_QUERIES_PACK_NAME, version: "~0.1.0" }],
|
|
||||||
"~0.1.0",
|
|
||||||
],
|
|
||||||
// If the ML-powered query pack is loaded with a specific version and another pack is loaded, the
|
// If the ML-powered query pack is loaded with a specific version and another pack is loaded, the
|
||||||
// status is the version of the ML-powered query pack.
|
// status is the version of the ML-powered query pack.
|
||||||
[
|
[
|
||||||
[
|
["someOtherPack", `${util.ML_POWERED_JS_QUERIES_PACK_NAME}@~0.1.0`],
|
||||||
{ packName: "someOtherPack" },
|
|
||||||
{ packName: util.ML_POWERED_JS_QUERIES_PACK_NAME, version: "~0.1.0" },
|
|
||||||
],
|
|
||||||
"~0.1.0",
|
"~0.1.0",
|
||||||
],
|
],
|
||||||
// If the ML-powered query pack is loaded without a version, the status is "latest".
|
// If the ML-powered query pack is loaded without a version, the status is "latest".
|
||||||
[[{ packName: util.ML_POWERED_JS_QUERIES_PACK_NAME }], "latest"],
|
[[util.ML_POWERED_JS_QUERIES_PACK_NAME], "latest"],
|
||||||
// If the ML-powered query pack is loaded with two different versions, the status is "other".
|
// If the ML-powered query pack is loaded with two different versions, the status is "other".
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
{ packName: util.ML_POWERED_JS_QUERIES_PACK_NAME, version: "0.0.1" },
|
`${util.ML_POWERED_JS_QUERIES_PACK_NAME}@~0.0.1`,
|
||||||
{ packName: util.ML_POWERED_JS_QUERIES_PACK_NAME, version: "0.0.2" },
|
`${util.ML_POWERED_JS_QUERIES_PACK_NAME}@~0.0.2`,
|
||||||
],
|
],
|
||||||
"other",
|
"other",
|
||||||
],
|
],
|
||||||
// If the ML-powered query pack is loaded with no specific version, and another pack is loaded,
|
// If the ML-powered query pack is loaded with no specific version, and another pack is loaded,
|
||||||
// the status is "latest".
|
// the status is "latest".
|
||||||
[
|
[["someOtherPack", util.ML_POWERED_JS_QUERIES_PACK_NAME], "latest"],
|
||||||
[
|
|
||||||
{ packName: "someOtherPack" },
|
|
||||||
{ packName: util.ML_POWERED_JS_QUERIES_PACK_NAME },
|
|
||||||
],
|
|
||||||
"latest",
|
|
||||||
],
|
|
||||||
];
|
];
|
||||||
for (const [packs, expectedStatus] of ML_POWERED_JS_STATUS_TESTS) {
|
for (const [packs, expectedStatus] of ML_POWERED_JS_STATUS_TESTS) {
|
||||||
const packDescriptions = `[${packs
|
const packDescriptions = `[${packs
|
||||||
@@ -256,7 +245,6 @@ for (const [packs, expectedStatus] of ML_POWERED_JS_STATUS_TESTS) {
|
|||||||
pathsIgnore: [],
|
pathsIgnore: [],
|
||||||
originalUserInput: {},
|
originalUserInput: {},
|
||||||
tempDir: tmpDir,
|
tempDir: tmpDir,
|
||||||
toolCacheDir: tmpDir,
|
|
||||||
codeQLCmd: "",
|
codeQLCmd: "",
|
||||||
gitHubVersion: {
|
gitHubVersion: {
|
||||||
type: util.GitHubVariant.DOTCOM,
|
type: util.GitHubVariant.DOTCOM,
|
||||||
@@ -281,4 +269,50 @@ for (const [packs, expectedStatus] of ML_POWERED_JS_STATUS_TESTS) {
|
|||||||
t.falsy(util.isGitHubGhesVersionBelow({ type: util.GitHubVariant.GHES, version: "3.2.0" }, "3.2.0"));
|
t.falsy(util.isGitHubGhesVersionBelow({ type: util.GitHubVariant.GHES, version: "3.2.0" }, "3.2.0"));
|
||||||
t.true(util.isGitHubGhesVersionBelow({ type: util.GitHubVariant.GHES, version: "3.1.2" }, "3.2.0"));
|
t.true(util.isGitHubGhesVersionBelow({ type: util.GitHubVariant.GHES, version: "3.1.2" }, "3.2.0"));
|
||||||
});
|
});
|
||||||
|
function formatGitHubVersion(version) {
|
||||||
|
switch (version.type) {
|
||||||
|
case util.GitHubVariant.DOTCOM:
|
||||||
|
return "dotcom";
|
||||||
|
case util.GitHubVariant.GHAE:
|
||||||
|
return "GHAE";
|
||||||
|
case util.GitHubVariant.GHES:
|
||||||
|
return `GHES ${version.version}`;
|
||||||
|
default:
|
||||||
|
util.assertNever(version);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const CHECK_ACTION_VERSION_TESTS = [
|
||||||
|
["1.2.1", { type: util.GitHubVariant.DOTCOM }, true],
|
||||||
|
["1.2.1", { type: util.GitHubVariant.GHAE }, true],
|
||||||
|
["1.2.1", { type: util.GitHubVariant.GHES, version: "3.3" }, false],
|
||||||
|
["1.2.1", { type: util.GitHubVariant.GHES, version: "3.4" }, true],
|
||||||
|
["1.2.1", { type: util.GitHubVariant.GHES, version: "3.5" }, true],
|
||||||
|
["2.2.1", { type: util.GitHubVariant.DOTCOM }, false],
|
||||||
|
["2.2.1", { type: util.GitHubVariant.GHAE }, false],
|
||||||
|
["2.2.1", { type: util.GitHubVariant.GHES, version: "3.3" }, false],
|
||||||
|
["2.2.1", { type: util.GitHubVariant.GHES, version: "3.4" }, false],
|
||||||
|
["2.2.1", { type: util.GitHubVariant.GHES, version: "3.5" }, false],
|
||||||
|
];
|
||||||
|
for (const [version, githubVersion, shouldReportWarning,] of CHECK_ACTION_VERSION_TESTS) {
|
||||||
|
const reportWarningDescription = shouldReportWarning
|
||||||
|
? "reports warning"
|
||||||
|
: "doesn't report warning";
|
||||||
|
const versionsDescription = `CodeQL Action version ${version} and GitHub version ${formatGitHubVersion(githubVersion)}`;
|
||||||
|
(0, ava_1.default)(`checkActionVersion ${reportWarningDescription} for ${versionsDescription}`, async (t) => {
|
||||||
|
const warningSpy = sinon.spy(core, "warning");
|
||||||
|
const versionStub = sinon
|
||||||
|
.stub(api, "getGitHubVersionActionsOnly")
|
||||||
|
.resolves(githubVersion);
|
||||||
|
const isActionsStub = sinon.stub(util, "isActions").returns(true);
|
||||||
|
await util.checkActionVersion(version);
|
||||||
|
if (shouldReportWarning) {
|
||||||
|
t.true(warningSpy.calledOnceWithExactly(sinon.match("CodeQL Action v1 will be deprecated")));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
t.false(warningSpy.called);
|
||||||
|
}
|
||||||
|
versionStub.restore();
|
||||||
|
isActionsStub.restore();
|
||||||
|
});
|
||||||
|
}
|
||||||
//# sourceMappingURL=util.test.js.map
|
//# sourceMappingURL=util.test.js.map
|
||||||
File diff suppressed because one or more lines are too long
44
node_modules/.package-lock.json
generated
vendored
44
node_modules/.package-lock.json
generated
vendored
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "codeql",
|
"name": "codeql",
|
||||||
"version": "2.1.9",
|
"version": "2.1.17",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
@@ -15,6 +15,14 @@
|
|||||||
"tmp-promise": "^3.0.2"
|
"tmp-promise": "^3.0.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@actions/artifact/node_modules/@actions/http-client": {
|
||||||
|
"version": "1.0.11",
|
||||||
|
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz",
|
||||||
|
"integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==",
|
||||||
|
"dependencies": {
|
||||||
|
"tunnel": "0.0.6"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@actions/core": {
|
"node_modules/@actions/core": {
|
||||||
"version": "1.4.0",
|
"version": "1.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.4.0.tgz",
|
||||||
@@ -38,7 +46,7 @@
|
|||||||
"@octokit/plugin-rest-endpoint-methods": "^4.0.0"
|
"@octokit/plugin-rest-endpoint-methods": "^4.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@actions/http-client": {
|
"node_modules/@actions/github/node_modules/@actions/http-client": {
|
||||||
"version": "1.0.11",
|
"version": "1.0.11",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz",
|
||||||
"integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==",
|
"integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==",
|
||||||
@@ -46,12 +54,10 @@
|
|||||||
"tunnel": "0.0.6"
|
"tunnel": "0.0.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@actions/http-client/node_modules/tunnel": {
|
"node_modules/@actions/http-client": {
|
||||||
"version": "0.0.6",
|
"version": "2.0.0",
|
||||||
"integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==",
|
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.0.tgz",
|
||||||
"engines": {
|
"integrity": "sha512-fm1+OPPey5ypgStT9K8zbBhICj4J4UV/TJIHDhuWlkb8KyJaAtjcZK184dTqul0dV0nPKX97FNtDXX20BTLXSA=="
|
||||||
"node": ">=0.6.11 <=0.7.0 || >=0.7.3"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"node_modules/@actions/io": {
|
"node_modules/@actions/io": {
|
||||||
"version": "1.1.1",
|
"version": "1.1.1",
|
||||||
@@ -59,13 +65,13 @@
|
|||||||
"integrity": "sha512-Qi4JoKXjmE0O67wAOH6y0n26QXhMKMFo7GD/4IXNVcrtLjUlGjGuVys6pQgwF3ArfGTQu0XpqaNr0YhED2RaRA=="
|
"integrity": "sha512-Qi4JoKXjmE0O67wAOH6y0n26QXhMKMFo7GD/4IXNVcrtLjUlGjGuVys6pQgwF3ArfGTQu0XpqaNr0YhED2RaRA=="
|
||||||
},
|
},
|
||||||
"node_modules/@actions/tool-cache": {
|
"node_modules/@actions/tool-cache": {
|
||||||
"version": "1.7.1",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-1.7.1.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-2.0.0.tgz",
|
||||||
"integrity": "sha512-y1xxxOhXaBUIUit3lhepmu/0xdgiTMpnZRLmVdtF0hTm521doi+MdRRRP62czHvM7wxH6epj4JPNJQ3iJpOrkQ==",
|
"integrity": "sha512-/5/R16ddC2hw48UO5T/d1gwzsyZjBTttGLV74xnLgfD/7nJKk17ArgCi3YXj3et/IAatMDEqaTM5kw5Hevgd5A==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.2.6",
|
"@actions/core": "^1.2.6",
|
||||||
"@actions/exec": "^1.0.0",
|
"@actions/exec": "^1.0.0",
|
||||||
"@actions/http-client": "^1.0.8",
|
"@actions/http-client": "^2.0.0",
|
||||||
"@actions/io": "^1.1.1",
|
"@actions/io": "^1.1.1",
|
||||||
"semver": "^6.1.0",
|
"semver": "^6.1.0",
|
||||||
"uuid": "^3.3.2"
|
"uuid": "^3.3.2"
|
||||||
@@ -463,6 +469,12 @@
|
|||||||
"integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==",
|
"integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/js-yaml": {
|
||||||
|
"version": "4.0.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/js-yaml/-/js-yaml-4.0.5.tgz",
|
||||||
|
"integrity": "sha512-FhpRzf927MNQdRZP0J5DLIdTXhjLYzeUTmLAu69mnVksLH9CJY3IuSeEgbKUki7GQZm0WqDkGzyxju2EZGD2wA==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"node_modules/@types/json-schema": {
|
"node_modules/@types/json-schema": {
|
||||||
"version": "7.0.8",
|
"version": "7.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.8.tgz",
|
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.8.tgz",
|
||||||
@@ -5072,6 +5084,14 @@
|
|||||||
"typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta"
|
"typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/tunnel": {
|
||||||
|
"version": "0.0.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz",
|
||||||
|
"integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.6.11 <=0.7.0 || >=0.7.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/type-check": {
|
"node_modules/type-check": {
|
||||||
"version": "0.4.0",
|
"version": "0.4.0",
|
||||||
"integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==",
|
"integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==",
|
||||||
|
|||||||
21
node_modules/@actions/artifact/node_modules/@actions/http-client/LICENSE
generated
vendored
Normal file
21
node_modules/@actions/artifact/node_modules/@actions/http-client/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
Actions Http Client for Node.js
|
||||||
|
|
||||||
|
Copyright (c) GitHub, Inc.
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||||
|
associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||||
|
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||||
|
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||||
|
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
79
node_modules/@actions/artifact/node_modules/@actions/http-client/README.md
generated
vendored
Normal file
79
node_modules/@actions/artifact/node_modules/@actions/http-client/README.md
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<img src="actions.png">
|
||||||
|
</p>
|
||||||
|
|
||||||
|
# Actions Http-Client
|
||||||
|
|
||||||
|
[](https://github.com/actions/http-client/actions)
|
||||||
|
|
||||||
|
A lightweight HTTP client optimized for use with actions, TypeScript with generics and async await.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- HTTP client with TypeScript generics and async/await/Promises
|
||||||
|
- Typings included so no need to acquire separately (great for intellisense and no versioning drift)
|
||||||
|
- [Proxy support](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/about-self-hosted-runners#using-a-proxy-server-with-self-hosted-runners) just works with actions and the runner
|
||||||
|
- Targets ES2019 (runner runs actions with node 12+). Only supported on node 12+.
|
||||||
|
- Basic, Bearer and PAT Support out of the box. Extensible handlers for others.
|
||||||
|
- Redirects supported
|
||||||
|
|
||||||
|
Features and releases [here](./RELEASES.md)
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
```
|
||||||
|
npm install @actions/http-client --save
|
||||||
|
```
|
||||||
|
|
||||||
|
## Samples
|
||||||
|
|
||||||
|
See the [HTTP](./__tests__) tests for detailed examples.
|
||||||
|
|
||||||
|
## Errors
|
||||||
|
|
||||||
|
### HTTP
|
||||||
|
|
||||||
|
The HTTP client does not throw unless truly exceptional.
|
||||||
|
|
||||||
|
* A request that successfully executes resulting in a 404, 500 etc... will return a response object with a status code and a body.
|
||||||
|
* Redirects (3xx) will be followed by default.
|
||||||
|
|
||||||
|
See [HTTP tests](./__tests__) for detailed examples.
|
||||||
|
|
||||||
|
## Debugging
|
||||||
|
|
||||||
|
To enable detailed console logging of all HTTP requests and responses, set the NODE_DEBUG environment varible:
|
||||||
|
|
||||||
|
```
|
||||||
|
export NODE_DEBUG=http
|
||||||
|
```
|
||||||
|
|
||||||
|
## Node support
|
||||||
|
|
||||||
|
The http-client is built using the latest LTS version of Node 12. It may work on previous node LTS versions but it's tested and officially supported on Node12+.
|
||||||
|
|
||||||
|
## Support and Versioning
|
||||||
|
|
||||||
|
We follow semver and will hold compatibility between major versions and increment the minor version with new features and capabilities (while holding compat).
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
We welcome PRs. Please create an issue and if applicable, a design before proceeding with code.
|
||||||
|
|
||||||
|
once:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
To build:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
To run all tests:
|
||||||
|
```bash
|
||||||
|
$ npm test
|
||||||
|
```
|
||||||
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
39
node_modules/@actions/artifact/node_modules/@actions/http-client/package.json
generated
vendored
Normal file
39
node_modules/@actions/artifact/node_modules/@actions/http-client/package.json
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
{
|
||||||
|
"name": "@actions/http-client",
|
||||||
|
"version": "1.0.11",
|
||||||
|
"description": "Actions Http Client",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"build": "rm -Rf ./_out && tsc && cp package*.json ./_out && cp *.md ./_out && cp LICENSE ./_out && cp actions.png ./_out",
|
||||||
|
"test": "jest",
|
||||||
|
"format": "prettier --write *.ts && prettier --write **/*.ts",
|
||||||
|
"format-check": "prettier --check *.ts && prettier --check **/*.ts",
|
||||||
|
"audit-check": "npm audit --audit-level=moderate"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/actions/http-client.git"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"Actions",
|
||||||
|
"Http"
|
||||||
|
],
|
||||||
|
"author": "GitHub, Inc.",
|
||||||
|
"license": "MIT",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/actions/http-client/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/actions/http-client#readme",
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/jest": "^25.1.4",
|
||||||
|
"@types/node": "^12.12.31",
|
||||||
|
"jest": "^25.1.0",
|
||||||
|
"prettier": "^2.0.4",
|
||||||
|
"proxy": "^1.0.1",
|
||||||
|
"ts-jest": "^25.2.1",
|
||||||
|
"typescript": "^3.8.3"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"tunnel": "0.0.6"
|
||||||
|
}
|
||||||
|
}
|
||||||
21
node_modules/@actions/github/node_modules/@actions/http-client/LICENSE
generated
vendored
Normal file
21
node_modules/@actions/github/node_modules/@actions/http-client/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
Actions Http Client for Node.js
|
||||||
|
|
||||||
|
Copyright (c) GitHub, Inc.
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||||
|
associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||||
|
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
||||||
|
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
||||||
|
NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
79
node_modules/@actions/github/node_modules/@actions/http-client/README.md
generated
vendored
Normal file
79
node_modules/@actions/github/node_modules/@actions/http-client/README.md
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<img src="actions.png">
|
||||||
|
</p>
|
||||||
|
|
||||||
|
# Actions Http-Client
|
||||||
|
|
||||||
|
[](https://github.com/actions/http-client/actions)
|
||||||
|
|
||||||
|
A lightweight HTTP client optimized for use with actions, TypeScript with generics and async await.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- HTTP client with TypeScript generics and async/await/Promises
|
||||||
|
- Typings included so no need to acquire separately (great for intellisense and no versioning drift)
|
||||||
|
- [Proxy support](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/about-self-hosted-runners#using-a-proxy-server-with-self-hosted-runners) just works with actions and the runner
|
||||||
|
- Targets ES2019 (runner runs actions with node 12+). Only supported on node 12+.
|
||||||
|
- Basic, Bearer and PAT Support out of the box. Extensible handlers for others.
|
||||||
|
- Redirects supported
|
||||||
|
|
||||||
|
Features and releases [here](./RELEASES.md)
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
```
|
||||||
|
npm install @actions/http-client --save
|
||||||
|
```
|
||||||
|
|
||||||
|
## Samples
|
||||||
|
|
||||||
|
See the [HTTP](./__tests__) tests for detailed examples.
|
||||||
|
|
||||||
|
## Errors
|
||||||
|
|
||||||
|
### HTTP
|
||||||
|
|
||||||
|
The HTTP client does not throw unless truly exceptional.
|
||||||
|
|
||||||
|
* A request that successfully executes resulting in a 404, 500 etc... will return a response object with a status code and a body.
|
||||||
|
* Redirects (3xx) will be followed by default.
|
||||||
|
|
||||||
|
See [HTTP tests](./__tests__) for detailed examples.
|
||||||
|
|
||||||
|
## Debugging
|
||||||
|
|
||||||
|
To enable detailed console logging of all HTTP requests and responses, set the NODE_DEBUG environment varible:
|
||||||
|
|
||||||
|
```
|
||||||
|
export NODE_DEBUG=http
|
||||||
|
```
|
||||||
|
|
||||||
|
## Node support
|
||||||
|
|
||||||
|
The http-client is built using the latest LTS version of Node 12. It may work on previous node LTS versions but it's tested and officially supported on Node12+.
|
||||||
|
|
||||||
|
## Support and Versioning
|
||||||
|
|
||||||
|
We follow semver and will hold compatibility between major versions and increment the minor version with new features and capabilities (while holding compat).
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
We welcome PRs. Please create an issue and if applicable, a design before proceeding with code.
|
||||||
|
|
||||||
|
once:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
To build:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
To run all tests:
|
||||||
|
```bash
|
||||||
|
$ npm test
|
||||||
|
```
|
||||||
26
node_modules/@actions/github/node_modules/@actions/http-client/RELEASES.md
generated
vendored
Normal file
26
node_modules/@actions/github/node_modules/@actions/http-client/RELEASES.md
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
## Releases
|
||||||
|
|
||||||
|
## 1.0.10
|
||||||
|
|
||||||
|
Contains a bug fix where proxy is defined without a user and password. see [PR here](https://github.com/actions/http-client/pull/42)
|
||||||
|
|
||||||
|
## 1.0.9
|
||||||
|
Throw HttpClientError instead of a generic Error from the \<verb>Json() helper methods when the server responds with a non-successful status code.
|
||||||
|
|
||||||
|
## 1.0.8
|
||||||
|
Fixed security issue where a redirect (e.g. 302) to another domain would pass headers. The fix was to strip the authorization header if the hostname was different. More [details in PR #27](https://github.com/actions/http-client/pull/27)
|
||||||
|
|
||||||
|
## 1.0.7
|
||||||
|
Update NPM dependencies and add 429 to the list of HttpCodes
|
||||||
|
|
||||||
|
## 1.0.6
|
||||||
|
Automatically sends Content-Type and Accept application/json headers for \<verb>Json() helper methods if not set in the client or parameters.
|
||||||
|
|
||||||
|
## 1.0.5
|
||||||
|
Adds \<verb>Json() helper methods for json over http scenarios.
|
||||||
|
|
||||||
|
## 1.0.4
|
||||||
|
Started to add \<verb>Json() helper methods. Do not use this release for that. Use >= 1.0.5 since there was an issue with types.
|
||||||
|
|
||||||
|
## 1.0.1 to 1.0.3
|
||||||
|
Adds proxy support.
|
||||||
BIN
node_modules/@actions/github/node_modules/@actions/http-client/actions.png
generated
vendored
Normal file
BIN
node_modules/@actions/github/node_modules/@actions/http-client/actions.png
generated
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 33 KiB |
23
node_modules/@actions/github/node_modules/@actions/http-client/auth.d.ts
generated
vendored
Normal file
23
node_modules/@actions/github/node_modules/@actions/http-client/auth.d.ts
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import ifm = require('./interfaces');
|
||||||
|
export declare class BasicCredentialHandler implements ifm.IRequestHandler {
|
||||||
|
username: string;
|
||||||
|
password: string;
|
||||||
|
constructor(username: string, password: string);
|
||||||
|
prepareRequest(options: any): void;
|
||||||
|
canHandleAuthentication(response: ifm.IHttpClientResponse): boolean;
|
||||||
|
handleAuthentication(httpClient: ifm.IHttpClient, requestInfo: ifm.IRequestInfo, objs: any): Promise<ifm.IHttpClientResponse>;
|
||||||
|
}
|
||||||
|
export declare class BearerCredentialHandler implements ifm.IRequestHandler {
|
||||||
|
token: string;
|
||||||
|
constructor(token: string);
|
||||||
|
prepareRequest(options: any): void;
|
||||||
|
canHandleAuthentication(response: ifm.IHttpClientResponse): boolean;
|
||||||
|
handleAuthentication(httpClient: ifm.IHttpClient, requestInfo: ifm.IRequestInfo, objs: any): Promise<ifm.IHttpClientResponse>;
|
||||||
|
}
|
||||||
|
export declare class PersonalAccessTokenCredentialHandler implements ifm.IRequestHandler {
|
||||||
|
token: string;
|
||||||
|
constructor(token: string);
|
||||||
|
prepareRequest(options: any): void;
|
||||||
|
canHandleAuthentication(response: ifm.IHttpClientResponse): boolean;
|
||||||
|
handleAuthentication(httpClient: ifm.IHttpClient, requestInfo: ifm.IRequestInfo, objs: any): Promise<ifm.IHttpClientResponse>;
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user