mirror of
https://github.com/github/codeql-action.git
synced 2025-12-10 01:34:36 +08:00
Compare commits
159 Commits
v1.1.12
...
angelapwen
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9cb33846e5 | ||
|
|
7f86ddc26d | ||
|
|
a758ec55e8 | ||
|
|
eeee462f05 | ||
|
|
5895ab0c0b | ||
|
|
44a27e6a51 | ||
|
|
a557279135 | ||
|
|
daaac4306e | ||
|
|
5229df1eef | ||
|
|
5da7870265 | ||
|
|
8a4a573d59 | ||
|
|
6630cbeccb | ||
|
|
af87cc6ba5 | ||
|
|
ebc59ec8da | ||
|
|
52de49c899 | ||
|
|
2c25894c5f | ||
|
|
2746051310 | ||
|
|
1016eba538 | ||
|
|
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 | ||
|
|
16c620dea4 | ||
|
|
bfe9d7da56 |
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/workflows/check-for-conflicts.yml
vendored
2
.github/workflows/check-for-conflicts.yml
vendored
@@ -4,7 +4,7 @@ name: Check for conflicts
|
||||
|
||||
on:
|
||||
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
|
||||
# by other workflows.
|
||||
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
|
||||
10
.github/workflows/pr-checks.yml
vendored
10
.github/workflows/pr-checks.yml
vendored
@@ -90,14 +90,18 @@ jobs:
|
||||
needs: [check-js, check-node-modules]
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest]
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
timeout-minutes: 45
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: npm run-script test
|
||||
run: npm run-script test
|
||||
- name: npm 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:
|
||||
name: Runner ubuntu JS analyze
|
||||
|
||||
9
.github/workflows/python-deps.yml
vendored
9
.github/workflows/python-deps.yml
vendored
@@ -18,6 +18,11 @@ jobs:
|
||||
os: [ubuntu-latest, macos-latest]
|
||||
python_deps_type: [pipenv, poetry, requirements, setup_py]
|
||||
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:
|
||||
PYTHON_DEPS_TYPE: ${{ matrix.python_deps_type }}
|
||||
@@ -115,6 +120,10 @@ jobs:
|
||||
matrix:
|
||||
python_deps_type: [pipenv, poetry, requirements, setup_py]
|
||||
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:
|
||||
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
|
||||
if [ ! -z "$(git status --porcelain)" ]; then
|
||||
# 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
|
||||
exit 1
|
||||
fi
|
||||
echo "Success: JavaScript files are up to date"
|
||||
echo "Success: JavaScript files are up to date"
|
||||
|
||||
@@ -2,17 +2,19 @@
|
||||
# Update the required checks based on the current branch.
|
||||
# Typically, this will be main.
|
||||
|
||||
if [ -z "$GITHUB_TOKEN" ]; then
|
||||
echo "Failed: No GitHub token found. This script requires admin access to `github/codeql-action`."
|
||||
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, pass it as a query to fzf
|
||||
GITHUB_SHA="$@"
|
||||
# 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)"
|
||||
@@ -21,7 +23,7 @@ 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") | not)] | sort')"
|
||||
CHECKS="$(gh api repos/github/codeql-action/commits/"${GITHUB_SHA}"/check-runs --paginate | jq --slurp --compact-output --raw-output '[.[].check_runs | .[].name | select(contains("https://") or . == "CodeQL" or . == "LGTM.com" or contains("Update") or contains("update") | not)] | unique | sort')"
|
||||
|
||||
echo "$CHECKS" | jq
|
||||
|
||||
|
||||
23
CHANGELOG.md
23
CHANGELOG.md
@@ -1,5 +1,28 @@
|
||||
# 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)
|
||||
|
||||
@@ -74,3 +74,4 @@ outputs:
|
||||
runs:
|
||||
using: "node16"
|
||||
main: "../lib/analyze-action.js"
|
||||
post: "../lib/analyze-action-post.js"
|
||||
|
||||
@@ -56,7 +56,10 @@ inputs:
|
||||
This input also sets the number of threads that can later be used by the "analyze" action.
|
||||
required: false
|
||||
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
|
||||
default: 'false'
|
||||
debug-artifact-name:
|
||||
@@ -75,3 +78,4 @@ outputs:
|
||||
runs:
|
||||
using: 'node16'
|
||||
main: '../lib/init-action.js'
|
||||
post: '../lib/init-action-post.js'
|
||||
40
lib/actions-util.js
generated
40
lib/actions-util.js
generated
@@ -19,7 +19,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||
return result;
|
||||
};
|
||||
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.printDebugLogs = 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 os = __importStar(require("os"));
|
||||
const path = __importStar(require("path"));
|
||||
@@ -66,13 +66,6 @@ function getTemporaryDirectory() {
|
||||
: (0, util_1.getRequiredEnvParam)("RUNNER_TEMP");
|
||||
}
|
||||
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.
|
||||
*/
|
||||
@@ -684,8 +677,33 @@ async function isAnalyzingDefaultBranch() {
|
||||
return currentRef === defaultBranch;
|
||||
}
|
||||
exports.isAnalyzingDefaultBranch = isAnalyzingDefaultBranch;
|
||||
function sanitizeArifactName(name) {
|
||||
return name.replace(/[^a-zA-Z0-9_\\-]+/g, "");
|
||||
async function printDebugLogs(config) {
|
||||
core.info("Debug mode is on. Printing CodeQL debug logs...");
|
||||
for (const language of config.languages) {
|
||||
const databaseDirectory = (0, util_1.getCodeQLDatabasePath)(config, language);
|
||||
const logsDirectory = path.join(databaseDirectory, "log");
|
||||
if (!(0, util_1.doesDirectoryExist)(logsDirectory)) {
|
||||
core.info(`Directory ${logsDirectory} does not exist.`);
|
||||
continue; // Skip this language database.
|
||||
}
|
||||
const walkLogFiles = (dir) => {
|
||||
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
||||
if (entries.length === 0) {
|
||||
core.info(`No debug logs found at directory ${logsDirectory}.`);
|
||||
}
|
||||
for (const entry of entries) {
|
||||
if (entry.isFile()) {
|
||||
core.startGroup(`CodeQL Debug Logs - ${language} - ${entry.name}`);
|
||||
process.stdout.write(fs.readFileSync(path.resolve(dir, entry.name)));
|
||||
core.endGroup();
|
||||
}
|
||||
else if (entry.isDirectory()) {
|
||||
walkLogFiles(path.resolve(dir, entry.name));
|
||||
}
|
||||
}
|
||||
};
|
||||
walkLogFiles(logsDirectory);
|
||||
}
|
||||
}
|
||||
exports.sanitizeArifactName = sanitizeArifactName;
|
||||
exports.printDebugLogs = printDebugLogs;
|
||||
//# sourceMappingURL=actions-util.js.map
|
||||
File diff suppressed because one or more lines are too long
6
lib/actions-util.test.js
generated
6
lib/actions-util.test.js
generated
@@ -497,10 +497,4 @@ on: ["push"]
|
||||
t.deepEqual(await actionsutil.isAnalyzingDefaultBranch(), false);
|
||||
});
|
||||
});
|
||||
(0, ava_1.default)("sanitizeArifactName", (t) => {
|
||||
t.deepEqual(actionsutil.sanitizeArifactName("hello-world_"), "hello-world_");
|
||||
t.deepEqual(actionsutil.sanitizeArifactName("hello`world`"), "helloworld");
|
||||
t.deepEqual(actionsutil.sanitizeArifactName("hello===123"), "hello123");
|
||||
t.deepEqual(actionsutil.sanitizeArifactName("*m)a&n^y%i££n+v!a:l[i]d"), "manyinvalid");
|
||||
});
|
||||
//# sourceMappingURL=actions-util.test.js.map
|
||||
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.
|
||||
const tempRelativeToWorking = path.relative(process.cwd(), config.tempDir);
|
||||
const toolsRelativeToWorking = path.relative(process.cwd(), config.toolCacheDir);
|
||||
let pathsIgnore = config.pathsIgnore;
|
||||
if (!tempRelativeToWorking.startsWith("..")) {
|
||||
if (!tempRelativeToWorking.startsWith("..") &&
|
||||
!path.isAbsolute(tempRelativeToWorking)) {
|
||||
pathsIgnore = pathsIgnore.concat(tempRelativeToWorking);
|
||||
}
|
||||
if (!toolsRelativeToWorking.startsWith("..")) {
|
||||
pathsIgnore = pathsIgnore.concat(toolsRelativeToWorking);
|
||||
}
|
||||
if (pathsIgnore.length !== 0) {
|
||||
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,CAA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,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IAC3E,IAAI,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;IACrC,IACE,CAAC,qBAAqB,CAAC,UAAU,CAAC,IAAI,CAAC;QACvC,CAAC,IAAI,CAAC,UAAU,CAAC,qBAAqB,CAAC,EACvC;QACA,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;KACzD;IACD,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE;QAC5B,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,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: [],
|
||||
originalUserInput: {},
|
||||
tempDir: tmpDir,
|
||||
toolCacheDir: tmpDir,
|
||||
codeQLCmd: "",
|
||||
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
||||
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
||||
@@ -62,7 +61,6 @@ const util = __importStar(require("./util"));
|
||||
pathsIgnore: ["path4", "path5", "path6/**"],
|
||||
originalUserInput: {},
|
||||
tempDir: tmpDir,
|
||||
toolCacheDir: tmpDir,
|
||||
codeQLCmd: "",
|
||||
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
||||
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
||||
@@ -79,29 +77,26 @@ const util = __importStar(require("./util"));
|
||||
});
|
||||
});
|
||||
(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 config = {
|
||||
languages: [],
|
||||
queries: {},
|
||||
pathsIgnore: [],
|
||||
paths: [],
|
||||
originalUserInput: {},
|
||||
tempDir,
|
||||
toolCacheDir,
|
||||
codeQLCmd: "",
|
||||
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
||||
dbLocation: path.resolve(tempDir, "codeql_databases"),
|
||||
packs: {},
|
||||
debugMode: false,
|
||||
debugArtifactName: util.DEFAULT_DEBUG_ARTIFACT_NAME,
|
||||
debugDatabaseName: util.DEFAULT_DEBUG_DATABASE_NAME,
|
||||
injectedMlQueries: false,
|
||||
};
|
||||
analysisPaths.includeAndExcludeAnalysisPaths(config);
|
||||
t.is(process.env["LGTM_INDEX_INCLUDE"], undefined);
|
||||
t.is(process.env["LGTM_INDEX_EXCLUDE"], "codeql-runner-temp");
|
||||
t.is(process.env["LGTM_INDEX_FILTERS"], undefined);
|
||||
});
|
||||
const tempDir = path.join(process.cwd(), "codeql-runner-temp");
|
||||
const config = {
|
||||
languages: [],
|
||||
queries: {},
|
||||
pathsIgnore: [],
|
||||
paths: [],
|
||||
originalUserInput: {},
|
||||
tempDir,
|
||||
codeQLCmd: "",
|
||||
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
||||
dbLocation: path.resolve(tempDir, "codeql_databases"),
|
||||
packs: {},
|
||||
debugMode: false,
|
||||
debugArtifactName: util.DEFAULT_DEBUG_ARTIFACT_NAME,
|
||||
debugDatabaseName: util.DEFAULT_DEBUG_DATABASE_NAME,
|
||||
injectedMlQueries: false,
|
||||
};
|
||||
analysisPaths.includeAndExcludeAnalysisPaths(config);
|
||||
t.is(process.env["LGTM_INDEX_INCLUDE"], 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
|
||||
@@ -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,i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,CAAC;AACL,CAAC,CAAC,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"}
|
||||
55
lib/analyze-action-post.js
generated
Normal file
55
lib/analyze-action-post.js
generated
Normal file
@@ -0,0 +1,55 @@
|
||||
"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;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
/**
|
||||
* This file is the entry point for the `post:` hook of `analyze-action.yml`.
|
||||
* It will run after the all steps in this job, in reverse order in relation to
|
||||
* other `post:` hooks.
|
||||
*/
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const actionsUtil = __importStar(require("./actions-util"));
|
||||
const config_utils_1 = require("./config-utils");
|
||||
const debugArtifacts = __importStar(require("./debug-artifacts"));
|
||||
const logging_1 = require("./logging");
|
||||
async function run(uploadSarifDebugArtifact) {
|
||||
const logger = (0, logging_1.getActionsLogger)();
|
||||
const config = await (0, config_utils_1.getConfig)(actionsUtil.getTemporaryDirectory(), logger);
|
||||
if (config === undefined) {
|
||||
throw new Error("Config file could not be found at expected location. Did the 'init' action fail to start?");
|
||||
}
|
||||
// Upload Actions SARIF artifacts for debugging
|
||||
if (config === null || config === void 0 ? void 0 : config.debugMode) {
|
||||
core.info("Debug mode is on. Uploading available SARIF files as Actions debugging artifact...");
|
||||
const outputDir = actionsUtil.getRequiredInput("output");
|
||||
await uploadSarifDebugArtifact(config, outputDir);
|
||||
}
|
||||
}
|
||||
async function runWrapper() {
|
||||
try {
|
||||
await run(debugArtifacts.uploadSarifDebugArtifact);
|
||||
}
|
||||
catch (error) {
|
||||
core.setFailed(`analyze action cleanup failed: ${error}`);
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
void runWrapper();
|
||||
//# sourceMappingURL=analyze-action-post.js.map
|
||||
1
lib/analyze-action-post.js.map
Normal file
1
lib/analyze-action-post.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"analyze-action-post.js","sourceRoot":"","sources":["../src/analyze-action-post.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;GAIG;AACH,oDAAsC;AAEtC,4DAA8C;AAC9C,iDAA2C;AAC3C,kEAAoD;AACpD,uCAA6C;AAE7C,KAAK,UAAU,GAAG,CAAC,wBAAkC;IACnD,MAAM,MAAM,GAAG,IAAA,0BAAgB,GAAE,CAAC;IAElC,MAAM,MAAM,GAAG,MAAM,IAAA,wBAAS,EAAC,WAAW,CAAC,qBAAqB,EAAE,EAAE,MAAM,CAAC,CAAC;IAC5E,IAAI,MAAM,KAAK,SAAS,EAAE;QACxB,MAAM,IAAI,KAAK,CACb,2FAA2F,CAC5F,CAAC;KACH;IAED,+CAA+C;IAC/C,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,SAAS,EAAE;QACrB,IAAI,CAAC,IAAI,CACP,oFAAoF,CACrF,CAAC;QACF,MAAM,SAAS,GAAG,WAAW,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QACzD,MAAM,wBAAwB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;KACnD;AACH,CAAC;AAED,KAAK,UAAU,UAAU;IACvB,IAAI;QACF,MAAM,GAAG,CAAC,cAAc,CAAC,wBAAwB,CAAC,CAAC;KACpD;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,SAAS,CAAC,kCAAkC,KAAK,EAAE,CAAC,CAAC;QAC1D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;KACpB;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"}
|
||||
3
lib/analyze-action-post.test.js
generated
Normal file
3
lib/analyze-action-post.test.js
generated
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
// TODO(angelapwen): Test run() here
|
||||
//# sourceMappingURL=analyze-action-post.test.js.map
|
||||
1
lib/analyze-action-post.test.js.map
Normal file
1
lib/analyze-action-post.test.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"analyze-action-post.test.js","sourceRoot":"","sources":["../src/analyze-action-post.test.ts"],"names":[],"mappings":";AAAA,oCAAoC"}
|
||||
89
lib/analyze-action.js
generated
89
lib/analyze-action.js
generated
@@ -20,20 +20,18 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.runPromise = exports.sendStatusReport = void 0;
|
||||
const fs = __importStar(require("fs"));
|
||||
const path = __importStar(require("path"));
|
||||
const artifact = __importStar(require("@actions/artifact"));
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const actionsUtil = __importStar(require("./actions-util"));
|
||||
const analyze_1 = require("./analyze");
|
||||
const api_client_1 = require("./api-client");
|
||||
const codeql_1 = require("./codeql");
|
||||
const config_utils_1 = require("./config-utils");
|
||||
const database_upload_1 = require("./database-upload");
|
||||
const feature_flags_1 = require("./feature-flags");
|
||||
const logging_1 = require("./logging");
|
||||
const repository_1 = require("./repository");
|
||||
const upload_lib = __importStar(require("./upload-lib"));
|
||||
const util = __importStar(require("./util"));
|
||||
const util_1 = require("./util");
|
||||
// eslint-disable-next-line import/no-commonjs
|
||||
const pkg = require("../package.json");
|
||||
async function sendStatusReport(startedAt, config, stats, error) {
|
||||
@@ -76,30 +74,11 @@ async function run() {
|
||||
const threads = util.getThreadsFlag(actionsUtil.getOptionalInput("threads") || process.env["CODEQL_THREADS"], logger);
|
||||
const memory = util.getMemoryFlag(actionsUtil.getOptionalInput("ram") || process.env["CODEQL_RAM"]);
|
||||
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") {
|
||||
runStats = await (0, analyze_1.runQueries)(outputDir, memory, util.getAddSnippetsFlag(actionsUtil.getRequiredInput("add-snippets")), threads, actionsUtil.getOptionalInput("category"), config, logger);
|
||||
if (config.debugMode) {
|
||||
// Upload the SARIF files as an Actions artifact for debugging
|
||||
await uploadDebugArtifacts(config.languages.map((lang) => path.resolve(outputDir, `${lang}.sarif`)), outputDir, config.debugArtifactName);
|
||||
}
|
||||
}
|
||||
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
||||
if (config.debugMode) {
|
||||
// Upload the logs as an Actions artifact for debugging
|
||||
const toUpload = [];
|
||||
for (const language of config.languages) {
|
||||
toUpload.push(...listFolder(path.resolve(util.getCodeQLDatabasePath(config, language), "log")));
|
||||
}
|
||||
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
|
||||
toUpload.push(...listFolder(path.resolve(config.dbLocation, "log")));
|
||||
}
|
||||
await uploadDebugArtifacts(toUpload, config.dbLocation, config.debugArtifactName);
|
||||
if (!(await (0, util_1.codeQlVersionAbove)(codeql, codeql_1.CODEQL_VERSION_NEW_TRACING))) {
|
||||
// Before multi-language tracing, we wrote a compound-build-tracer.log in the temp dir
|
||||
await uploadDebugArtifacts([path.resolve(config.tempDir, "compound-build-tracer.log")], config.tempDir, config.debugArtifactName);
|
||||
}
|
||||
}
|
||||
if (actionsUtil.getOptionalInput("cleanup-level") !== "none") {
|
||||
await (0, analyze_1.runCleanup)(config, actionsUtil.getOptionalInput("cleanup-level") || "brutal", logger);
|
||||
@@ -140,42 +119,6 @@ async function run() {
|
||||
}
|
||||
return;
|
||||
}
|
||||
finally {
|
||||
if (config !== undefined && config.debugMode) {
|
||||
try {
|
||||
// Upload the database bundles as an Actions artifact for debugging
|
||||
const toUpload = [];
|
||||
for (const language of config.languages) {
|
||||
toUpload.push(await (0, util_1.bundleDb)(config, language, await (0, codeql_1.getCodeQL)(config.codeQLCmd), `${config.debugDatabaseName}-${language}`));
|
||||
}
|
||||
await uploadDebugArtifacts(toUpload, config.dbLocation, config.debugArtifactName);
|
||||
}
|
||||
catch (error) {
|
||||
console.log(`Failed to upload database debug bundles: ${error}`);
|
||||
}
|
||||
}
|
||||
if (core.isDebug() && config !== undefined) {
|
||||
core.info("Debug mode is on. Printing CodeQL debug logs...");
|
||||
for (const language of config.languages) {
|
||||
const databaseDirectory = util.getCodeQLDatabasePath(config, language);
|
||||
const logsDirectory = path.join(databaseDirectory, "log");
|
||||
const walkLogFiles = (dir) => {
|
||||
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
||||
for (const entry of entries) {
|
||||
if (entry.isFile()) {
|
||||
core.startGroup(`CodeQL Debug Logs - ${language} - ${entry.name}`);
|
||||
process.stdout.write(fs.readFileSync(path.resolve(dir, entry.name)));
|
||||
core.endGroup();
|
||||
}
|
||||
else if (entry.isDirectory()) {
|
||||
walkLogFiles(path.resolve(dir, entry.name));
|
||||
}
|
||||
}
|
||||
};
|
||||
walkLogFiles(logsDirectory);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (runStats && uploadResult) {
|
||||
await sendStatusReport(startedAt, config, {
|
||||
...runStats,
|
||||
@@ -189,28 +132,6 @@ async function run() {
|
||||
await sendStatusReport(startedAt, config, undefined);
|
||||
}
|
||||
}
|
||||
async function uploadDebugArtifacts(toUpload, rootDir, artifactName) {
|
||||
let suffix = "";
|
||||
const matrix = actionsUtil.getRequiredInput("matrix");
|
||||
if (matrix !== undefined && matrix !== "null") {
|
||||
for (const entry of Object.entries(JSON.parse(matrix)).sort())
|
||||
suffix += `-${entry[1]}`;
|
||||
}
|
||||
await artifact.create().uploadArtifact(actionsUtil.sanitizeArifactName(`${artifactName}${suffix}`), toUpload.map((file) => path.normalize(file)), path.normalize(rootDir));
|
||||
}
|
||||
function listFolder(dir) {
|
||||
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
||||
const files = [];
|
||||
for (const entry of entries) {
|
||||
if (entry.isFile()) {
|
||||
files.push(path.resolve(dir, entry.name));
|
||||
}
|
||||
else if (entry.isDirectory()) {
|
||||
files.push(...listFolder(path.resolve(dir, entry.name)));
|
||||
}
|
||||
}
|
||||
return files;
|
||||
}
|
||||
exports.runPromise = run();
|
||||
async function runWrapper() {
|
||||
try {
|
||||
|
||||
File diff suppressed because one or more lines are too long
63
lib/analyze.js
generated
63
lib/analyze.js
generated
@@ -18,11 +18,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||
__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.runCleanup = exports.runFinalize = exports.runQueries = exports.CodeQLAnalysisError = void 0;
|
||||
exports.runCleanup = exports.runFinalize = exports.runQueries = exports.dbIsFinalized = exports.createdDBForScannedLanguages = exports.CodeQLAnalysisError = void 0;
|
||||
const fs = __importStar(require("fs"));
|
||||
const path = __importStar(require("path"));
|
||||
const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
|
||||
const del_1 = __importDefault(require("del"));
|
||||
const yaml = __importStar(require("js-yaml"));
|
||||
const analysisPaths = __importStar(require("./analysis-paths"));
|
||||
const codeql_1 = require("./codeql");
|
||||
@@ -64,11 +68,10 @@ async function setupPythonExtractor(logger) {
|
||||
logger.info(`Setting 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
|
||||
// we extract any scanned languages.
|
||||
analysisPaths.includeAndExcludeAnalysisPaths(config);
|
||||
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
||||
for (const language of config.languages) {
|
||||
if ((0, languages_1.isScannedLanguage)(language) &&
|
||||
!dbIsFinalized(config, language, logger)) {
|
||||
@@ -76,11 +79,12 @@ async function createdDBForScannedLanguages(config, logger) {
|
||||
if (language === languages_1.Language.python) {
|
||||
await setupPythonExtractor(logger);
|
||||
}
|
||||
await codeql.extractScannedLanguage(util.getCodeQLDatabasePath(config, language), language);
|
||||
await codeql.extractScannedLanguage(util.getCodeQLDatabasePath(config, language), language, featureFlags);
|
||||
logger.endGroup();
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.createdDBForScannedLanguages = createdDBForScannedLanguages;
|
||||
function dbIsFinalized(config, language, logger) {
|
||||
const dbPath = util.getCodeQLDatabasePath(config, language);
|
||||
try {
|
||||
@@ -92,9 +96,10 @@ function dbIsFinalized(config, language, logger) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
async function finalizeDatabaseCreation(config, threadsFlag, memoryFlag, logger) {
|
||||
await createdDBForScannedLanguages(config, logger);
|
||||
exports.dbIsFinalized = dbIsFinalized;
|
||||
async function finalizeDatabaseCreation(config, threadsFlag, memoryFlag, logger, featureFlags) {
|
||||
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
||||
await createdDBForScannedLanguages(codeql, config, logger, featureFlags);
|
||||
for (const language of config.languages) {
|
||||
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.`);
|
||||
@@ -111,10 +116,8 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
|
||||
const statusReport = {};
|
||||
let locPromise = Promise.resolve({});
|
||||
const cliCanCountBaseline = await cliCanCountLoC();
|
||||
const debugMode = process.env["INTERNAL_CODEQL_ACTION_DEBUG_LOC"] ||
|
||||
process.env["ACTIONS_RUNNER_DEBUG"] ||
|
||||
process.env["ACTIONS_STEP_DEBUG"];
|
||||
if (!cliCanCountBaseline || debugMode) {
|
||||
const countLocDebugMode = process.env["INTERNAL_CODEQL_ACTION_DEBUG_LOC"] || config.debugMode;
|
||||
if (!cliCanCountBaseline || countLocDebugMode) {
|
||||
// count the number of lines in the background
|
||||
locPromise = (0, count_loc_1.countLoc)(path.resolve(),
|
||||
// config.paths specifies external directories. the current
|
||||
@@ -170,14 +173,14 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
|
||||
logger.startGroup(`Interpreting results for ${language}`);
|
||||
const startTimeInterpretResults = new Date().getTime();
|
||||
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)
|
||||
await injectLinesOfCode(sarifFile, language, locPromise);
|
||||
statusReport[`interpret_results_${language}_duration_ms`] =
|
||||
new Date().getTime() - startTimeInterpretResults;
|
||||
logger.endGroup();
|
||||
logger.info(analysisSummary);
|
||||
if (!cliCanCountBaseline || debugMode)
|
||||
if (!cliCanCountBaseline || countLocDebugMode)
|
||||
printLinesOfCodeSummary(logger, language, await locPromise);
|
||||
if (cliCanCountBaseline)
|
||||
logger.info(await runPrintLinesOfCode(language));
|
||||
@@ -192,10 +195,10 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
|
||||
}
|
||||
}
|
||||
return statusReport;
|
||||
async function runInterpretResults(language, queries, sarifFile) {
|
||||
async function runInterpretResults(language, queries, sarifFile, enableDebugLogging) {
|
||||
const databasePath = util.getCodeQLDatabasePath(config, language);
|
||||
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() {
|
||||
return await util.codeQlVersionAbove(await (0, codeql_1.getCodeQL)(config.codeQLCmd), codeql_1.CODEQL_VERSION_COUNTS_LINES);
|
||||
@@ -234,8 +237,23 @@ exports.runQueries = runQueries;
|
||||
function createQuerySuiteContents(queries) {
|
||||
return queries.map((q) => `- query: ${q}`).join("\n");
|
||||
}
|
||||
async function runFinalize(outputDir, threadsFlag, memoryFlag, config, logger) {
|
||||
async function runFinalize(outputDir, threadsFlag, memoryFlag, config, logger, featureFlags) {
|
||||
try {
|
||||
await (0, del_1.default)(outputDir, { force: true });
|
||||
}
|
||||
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, featureFlags);
|
||||
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)) {
|
||||
// Delete variables as specified by the end-tracing script
|
||||
await (0, tracer_config_1.endTracingForCluster)(config);
|
||||
@@ -244,21 +262,6 @@ async function runFinalize(outputDir, threadsFlag, memoryFlag, config, logger) {
|
||||
// Delete the tracer config env var to avoid tracing ourselves
|
||||
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;
|
||||
async function runCleanup(config, cleanupLevel, logger) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
70
lib/analyze.test.js
generated
70
lib/analyze.test.js
generated
@@ -29,7 +29,9 @@ const yaml = __importStar(require("js-yaml"));
|
||||
const sinon = __importStar(require("sinon"));
|
||||
const analyze_1 = require("./analyze");
|
||||
const codeql_1 = require("./codeql");
|
||||
const codeql_test_1 = require("./codeql.test");
|
||||
const count = __importStar(require("./count-loc"));
|
||||
const feature_flags_1 = require("./feature-flags");
|
||||
const languages_1 = require("./languages");
|
||||
const logging_1 = require("./logging");
|
||||
const testing_utils_1 = require("./testing-utils");
|
||||
@@ -107,7 +109,6 @@ const util = __importStar(require("./util"));
|
||||
paths: [],
|
||||
originalUserInput: {},
|
||||
tempDir: tmpDir,
|
||||
toolCacheDir: tmpDir,
|
||||
codeQLCmd: "",
|
||||
gitHubVersion: {
|
||||
type: util.GitHubVariant.DOTCOM,
|
||||
@@ -210,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
|
||||
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" }
|
||||
|
||||
44
lib/codeql.js
generated
44
lib/codeql.js
generated
@@ -26,16 +26,17 @@ exports.getExtraOptions = exports.getCodeQLForTesting = exports.getCachedCodeQL
|
||||
const fs = __importStar(require("fs"));
|
||||
const path = __importStar(require("path"));
|
||||
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 query_string_1 = __importDefault(require("query-string"));
|
||||
const semver = __importStar(require("semver"));
|
||||
const uuid_1 = require("uuid");
|
||||
const actions_util_1 = require("./actions-util");
|
||||
const api = __importStar(require("./api-client"));
|
||||
const defaults = __importStar(require("./defaults.json")); // Referenced from codeql-action-sync-tool!
|
||||
const error_matcher_1 = require("./error-matcher");
|
||||
const feature_flags_1 = require("./feature-flags");
|
||||
const languages_1 = require("./languages");
|
||||
const toolcache = __importStar(require("./toolcache"));
|
||||
const toolrunner_error_catcher_1 = require("./toolrunner-error-catcher");
|
||||
const util = __importStar(require("./util"));
|
||||
const util_1 = require("./util");
|
||||
@@ -77,7 +78,7 @@ const CODEQL_VERSION_SARIF_GROUP = "2.5.3";
|
||||
exports.CODEQL_VERSION_COUNTS_LINES = "2.6.2";
|
||||
const CODEQL_VERSION_CUSTOM_QUERY_HELP = "2.7.1";
|
||||
exports.CODEQL_VERSION_ML_POWERED_QUERIES = "2.7.5";
|
||||
const CODEQL_VERSION_LUA_TRACER_CONFIG = "2.9.3";
|
||||
const CODEQL_VERSION_LUA_TRACER_CONFIG = "2.10.0";
|
||||
/**
|
||||
* This variable controls using the new style of tracing from the CodeQL
|
||||
* CLI. In particular, with versions above this we will use both indirect
|
||||
@@ -208,14 +209,13 @@ async function getCodeQLBundleDownloadURL(apiDetails, variant, logger) {
|
||||
* @param codeqlURL
|
||||
* @param apiDetails
|
||||
* @param tempDir
|
||||
* @param toolCacheDir
|
||||
* @param variant
|
||||
* @param logger
|
||||
* @param checkVersion Whether to check that CodeQL CLI meets the minimum
|
||||
* version requirement. Must be set to true outside tests.
|
||||
* @returns
|
||||
*/
|
||||
async function setupCodeQL(codeqlURL, apiDetails, tempDir, toolCacheDir, variant, logger, checkVersion) {
|
||||
async function setupCodeQL(codeqlURL, apiDetails, tempDir, variant, logger, checkVersion) {
|
||||
try {
|
||||
// We use the special value of 'latest' to prioritize the version in the
|
||||
// defaults over any pinned cached version.
|
||||
@@ -226,21 +226,21 @@ async function setupCodeQL(codeqlURL, apiDetails, tempDir, toolCacheDir, variant
|
||||
let codeqlFolder;
|
||||
let codeqlURLVersion;
|
||||
if (codeqlURL && !codeqlURL.startsWith("http")) {
|
||||
codeqlFolder = await toolcache.extractTar(codeqlURL, tempDir, logger);
|
||||
codeqlFolder = await toolcache.extractTar(codeqlURL);
|
||||
codeqlURLVersion = "local";
|
||||
}
|
||||
else {
|
||||
codeqlURLVersion = getCodeQLURLVersion(codeqlURL || `/${CODEQL_BUNDLE_VERSION}/`);
|
||||
const codeqlURLSemVer = convertToSemVer(codeqlURLVersion, logger);
|
||||
// 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
|
||||
// different version to save download time if the version hasn't been
|
||||
// specified explicitly (in which case we always honor it).
|
||||
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])) {
|
||||
const tmpCodeqlFolder = toolcache.find("CodeQL", codeqlVersions[0], toolCacheDir, logger);
|
||||
const tmpCodeqlFolder = toolcache.find("CodeQL", codeqlVersions[0]);
|
||||
if (fs.existsSync(path.join(tmpCodeqlFolder, "pinned-version"))) {
|
||||
logger.debug(`CodeQL in cache overriding the default ${CODEQL_BUNDLE_VERSION}`);
|
||||
codeqlFolder = tmpCodeqlFolder;
|
||||
@@ -272,10 +272,12 @@ async function setupCodeQL(codeqlURL, apiDetails, tempDir, toolCacheDir, variant
|
||||
logger.debug("Downloading CodeQL bundle without token.");
|
||||
}
|
||||
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.`);
|
||||
const codeqlExtracted = await toolcache.extractTar(codeqlPath, tempDir, logger);
|
||||
codeqlFolder = await toolcache.cacheDir(codeqlExtracted, "CodeQL", codeqlURLSemVer, toolCacheDir, logger);
|
||||
const codeqlExtracted = await toolcache.extractTar(codeqlPath);
|
||||
codeqlFolder = await toolcache.cacheDir(codeqlExtracted, "CodeQL", codeqlURLSemVer);
|
||||
}
|
||||
}
|
||||
let codeqlCmd = path.join(codeqlFolder, "codeql", "codeql");
|
||||
@@ -384,8 +386,8 @@ exports.getCachedCodeQL = getCachedCodeQL;
|
||||
* a non-existent placeholder codeql command, so tests that use this function
|
||||
* should also stub the toolrunner.ToolRunner constructor.
|
||||
*/
|
||||
async function getCodeQLForTesting() {
|
||||
return getCodeQLForCmd("codeql-for-testing", false);
|
||||
async function getCodeQLForTesting(cmd = "codeql-for-testing") {
|
||||
return getCodeQLForCmd(cmd, false);
|
||||
}
|
||||
exports.getCodeQLForTesting = getCodeQLForTesting;
|
||||
/**
|
||||
@@ -510,7 +512,7 @@ async function getCodeQLForCmd(cmd, checkVersion) {
|
||||
].join(" ");
|
||||
await runTool(autobuildCmd);
|
||||
},
|
||||
async extractScannedLanguage(databasePath, language) {
|
||||
async extractScannedLanguage(databasePath, language, featureFlags) {
|
||||
// Get extractor location
|
||||
let extractorPath = "";
|
||||
await new toolrunner.ToolRunner(cmd, [
|
||||
@@ -533,10 +535,20 @@ async function getCodeQLForCmd(cmd, checkVersion) {
|
||||
// Set trace command
|
||||
const ext = process.platform === "win32" ? ".cmd" : ".sh";
|
||||
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
|
||||
await (0, toolrunner_error_catcher_1.toolrunnerErrorCatcher)(cmd, [
|
||||
"database",
|
||||
"trace-command",
|
||||
...extraArgs,
|
||||
...getExtraOptionsFromEnv(["database", "trace-command"]),
|
||||
databasePath,
|
||||
"--",
|
||||
@@ -607,13 +619,13 @@ async function getCodeQLForCmd(cmd, checkVersion) {
|
||||
codeqlArgs.push(querySuitePath);
|
||||
await runTool(cmd, codeqlArgs);
|
||||
},
|
||||
async databaseInterpretResults(databasePath, querySuitePaths, sarifFile, addSnippetsFlag, threadsFlag, automationDetailsId) {
|
||||
async databaseInterpretResults(databasePath, querySuitePaths, sarifFile, addSnippetsFlag, threadsFlag, verbosityFlag, automationDetailsId) {
|
||||
const codeqlArgs = [
|
||||
"database",
|
||||
"interpret-results",
|
||||
threadsFlag,
|
||||
"--format=sarif-latest",
|
||||
"-v",
|
||||
verbosityFlag,
|
||||
`--output=${sarifFile}`,
|
||||
addSnippetsFlag,
|
||||
...getExtraOptionsFromEnv(["database", "interpret-results"]),
|
||||
|
||||
File diff suppressed because one or more lines are too long
27
lib/codeql.test.js
generated
27
lib/codeql.test.js
generated
@@ -22,6 +22,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.stubToolRunnerConstructor = void 0;
|
||||
const path = __importStar(require("path"));
|
||||
const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
|
||||
const toolcache = __importStar(require("@actions/tool-cache"));
|
||||
@@ -57,7 +58,7 @@ ava_1.default.beforeEach(() => {
|
||||
(0, nock_1.default)("https://example.com")
|
||||
.get(`/download/codeql-bundle-${version}/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}`));
|
||||
}
|
||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||
@@ -70,12 +71,12 @@ ava_1.default.beforeEach(() => {
|
||||
(0, nock_1.default)("https://example.com")
|
||||
.get(`/download/codeql-bundle-20200601/codeql-bundle.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"));
|
||||
(0, nock_1.default)("https://example.com")
|
||||
.get(`/download/codeql-bundle-20200610/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"));
|
||||
});
|
||||
});
|
||||
@@ -85,9 +86,9 @@ ava_1.default.beforeEach(() => {
|
||||
(0, nock_1.default)("https://example.com")
|
||||
.get(`/download/codeql-bundle-20200601/codeql-bundle.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"));
|
||||
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");
|
||||
t.is(cachedVersions.length, 1);
|
||||
});
|
||||
@@ -98,7 +99,7 @@ ava_1.default.beforeEach(() => {
|
||||
(0, nock_1.default)("https://example.com")
|
||||
.get(`/download/codeql-bundle-20200601/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"));
|
||||
const platform = process.platform === "win32"
|
||||
? "win64"
|
||||
@@ -108,7 +109,7 @@ ava_1.default.beforeEach(() => {
|
||||
(0, nock_1.default)("https://github.com")
|
||||
.get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/codeql-bundle-${platform}.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");
|
||||
t.is(cachedVersions.length, 2);
|
||||
});
|
||||
@@ -119,7 +120,7 @@ ava_1.default.beforeEach(() => {
|
||||
(0, nock_1.default)("https://example.com")
|
||||
.get(`/download/codeql-bundle-20200601/codeql-bundle.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"));
|
||||
const platform = process.platform === "win32"
|
||||
? "win64"
|
||||
@@ -129,7 +130,7 @@ ava_1.default.beforeEach(() => {
|
||||
(0, nock_1.default)("https://github.com")
|
||||
.get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/codeql-bundle-${platform}.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");
|
||||
t.is(cachedVersions.length, 2);
|
||||
});
|
||||
@@ -157,7 +158,7 @@ ava_1.default.beforeEach(() => {
|
||||
(0, nock_1.default)("https://example.githubenterprise.com")
|
||||
.get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/${codeQLBundleName}`)
|
||||
.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");
|
||||
t.is(cachedVersions.length, 1);
|
||||
});
|
||||
@@ -225,14 +226,14 @@ ava_1.default.beforeEach(() => {
|
||||
const runnerConstructorStub = stubToolRunnerConstructor();
|
||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
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");
|
||||
});
|
||||
(0, ava_1.default)("databaseInterpretResults() sets --sarif-add-query-help for 2.7.1", async (t) => {
|
||||
const runnerConstructorStub = stubToolRunnerConstructor();
|
||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
||||
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");
|
||||
});
|
||||
const stubConfig = {
|
||||
@@ -242,7 +243,6 @@ const stubConfig = {
|
||||
paths: [],
|
||||
originalUserInput: {},
|
||||
tempDir: "",
|
||||
toolCacheDir: "",
|
||||
codeQLCmd: "",
|
||||
gitHubVersion: {
|
||||
type: util.GitHubVariant.DOTCOM,
|
||||
@@ -291,4 +291,5 @@ function stubToolRunnerConstructor() {
|
||||
runnerConstructorStub.returns(runnerObjectStub);
|
||||
return runnerConstructorStub;
|
||||
}
|
||||
exports.stubToolRunnerConstructor = stubToolRunnerConstructor;
|
||||
//# sourceMappingURL=codeql.test.js.map
|
||||
File diff suppressed because one or more lines are too long
43
lib/config-utils.js
generated
43
lib/config-utils.js
generated
@@ -19,7 +19,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
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.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 path = __importStar(require("path"));
|
||||
const yaml = __importStar(require("js-yaml"));
|
||||
@@ -306,9 +306,8 @@ function getPathsInvalid(configFile) {
|
||||
}
|
||||
exports.getPathsInvalid = getPathsInvalid;
|
||||
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) {
|
||||
return getConfigFilePropertyError(configFile, PACKS_PROPERTY, "must split packages by language");
|
||||
}
|
||||
@@ -463,7 +462,7 @@ function shouldAddConfigFileQueries(queriesInput) {
|
||||
/**
|
||||
* 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;
|
||||
const languages = await getLanguages(codeQL, languagesInput, repository, apiDetails, logger);
|
||||
const queries = {};
|
||||
@@ -487,7 +486,6 @@ async function getDefaultConfig(languagesInput, queriesInput, packsInput, dbLoca
|
||||
packs,
|
||||
originalUserInput: {},
|
||||
tempDir,
|
||||
toolCacheDir,
|
||||
codeQLCmd: codeQL.getPath(),
|
||||
gitHubVersion,
|
||||
dbLocation: dbLocationOrDefault(dbLocation, tempDir),
|
||||
@@ -501,7 +499,7 @@ exports.getDefaultConfig = getDefaultConfig;
|
||||
/**
|
||||
* 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;
|
||||
let parsedYAML;
|
||||
if (isLocal(configFile)) {
|
||||
@@ -542,7 +540,7 @@ async function loadConfig(languagesInput, queriesInput, packsInput, configFile,
|
||||
if (!disableDefaultQueries) {
|
||||
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,
|
||||
// they should take precedence over the queries in the config file
|
||||
// unless they're prefixed with "+", in which case they supplement those
|
||||
@@ -595,7 +593,6 @@ async function loadConfig(languagesInput, queriesInput, packsInput, configFile,
|
||||
packs,
|
||||
originalUserInput: parsedYAML,
|
||||
tempDir,
|
||||
toolCacheDir,
|
||||
codeQLCmd: codeQL.getPath(),
|
||||
gitHubVersion,
|
||||
dbLocation: dbLocationOrDefault(dbLocation, tempDir),
|
||||
@@ -616,7 +613,7 @@ const PACK_IDENTIFIER_PATTERN = (function () {
|
||||
return new RegExp(`^${component}/${component}$`);
|
||||
})();
|
||||
// Exported for testing
|
||||
function parsePacksFromConfig(packsByLanguage, languages, configFile) {
|
||||
function parsePacksFromConfig(packsByLanguage, languages, configFile, logger) {
|
||||
const packs = {};
|
||||
if (Array.isArray(packsByLanguage)) {
|
||||
if (languages.length === 1) {
|
||||
@@ -636,7 +633,15 @@ function parsePacksFromConfig(packsByLanguage, languages, configFile) {
|
||||
throw new Error(getPacksInvalid(configFile));
|
||||
}
|
||||
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] = [];
|
||||
for (const packStr of packsArr) {
|
||||
@@ -723,7 +728,13 @@ function validatePacksSpecification(packStr, configFile) {
|
||||
}
|
||||
}
|
||||
if (packPath &&
|
||||
(path.isAbsolute(packPath) || path.normalize(packPath) !== packPath)) {
|
||||
(path.isAbsolute(packPath) ||
|
||||
// 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) {
|
||||
@@ -734,9 +745,9 @@ function validatePacksSpecification(packStr, configFile) {
|
||||
}
|
||||
exports.validatePacksSpecification = validatePacksSpecification;
|
||||
// exported for testing
|
||||
function parsePacks(rawPacksFromConfig, rawPacksInput, languages, configFile) {
|
||||
function parsePacks(rawPacksFromConfig, rawPacksInput, languages, configFile, logger) {
|
||||
const packsFromInput = parsePacksFromInput(rawPacksInput, languages);
|
||||
const packsFomConfig = parsePacksFromConfig(rawPacksFromConfig, languages, configFile);
|
||||
const packsFomConfig = parsePacksFromConfig(rawPacksFromConfig, languages, configFile, logger);
|
||||
if (!packsFromInput) {
|
||||
return packsFomConfig;
|
||||
}
|
||||
@@ -770,16 +781,16 @@ function dbLocationOrDefault(dbLocation, tempDir) {
|
||||
* 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.
|
||||
*/
|
||||
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;
|
||||
let config;
|
||||
// If no config file was provided create an empty one
|
||||
if (!configFile) {
|
||||
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 {
|
||||
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
|
||||
// it is a user configuration error.
|
||||
|
||||
File diff suppressed because one or more lines are too long
113
lib/config-utils.test.js
generated
113
lib/config-utils.test.js
generated
@@ -88,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);
|
||||
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));
|
||||
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, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, feature_flags_1.createFeatureFlags)([]), logger));
|
||||
});
|
||||
});
|
||||
(0, ava_1.default)("loading config saves config", async (t) => {
|
||||
@@ -111,7 +111,7 @@ function mockListLanguages(languages) {
|
||||
t.false(fs.existsSync(configUtils.getPathToParsedConfigFile(tmpDir)));
|
||||
// Sanity check that getConfig returns undefined before we have called initConfig
|
||||
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
|
||||
t.true(fs.existsSync(configUtils.getPathToParsedConfigFile(tmpDir)));
|
||||
// And that same newly-initialised config should now be returned by getConfig
|
||||
@@ -125,7 +125,7 @@ function mockListLanguages(languages) {
|
||||
(0, ava_1.default)("load input outside of workspace", async (t) => {
|
||||
return await util.withTmpDir(async (tmpDir) => {
|
||||
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");
|
||||
}
|
||||
catch (err) {
|
||||
@@ -138,7 +138,7 @@ function mockListLanguages(languages) {
|
||||
// no filename given, just a repo
|
||||
const configFile = "octo-org/codeql-config@main";
|
||||
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");
|
||||
}
|
||||
catch (err) {
|
||||
@@ -152,7 +152,7 @@ function mockListLanguages(languages) {
|
||||
const configFile = "input";
|
||||
t.false(fs.existsSync(path.join(tmpDir, configFile)));
|
||||
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");
|
||||
}
|
||||
catch (err) {
|
||||
@@ -212,7 +212,6 @@ function mockListLanguages(languages) {
|
||||
paths: ["c/d"],
|
||||
},
|
||||
tempDir: tmpDir,
|
||||
toolCacheDir: tmpDir,
|
||||
codeQLCmd: codeQL.getPath(),
|
||||
gitHubVersion,
|
||||
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
||||
@@ -224,7 +223,7 @@ function mockListLanguages(languages) {
|
||||
};
|
||||
const languages = "javascript";
|
||||
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
|
||||
t.deepEqual(actualConfig, expectedConfig);
|
||||
});
|
||||
@@ -260,7 +259,7 @@ function mockListLanguages(languages) {
|
||||
fs.mkdirSync(path.join(tmpDir, "foo"));
|
||||
const languages = "javascript";
|
||||
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
|
||||
t.deepEqual(resolveQueriesArgs.length, 1);
|
||||
t.deepEqual(resolveQueriesArgs[0].queries, [
|
||||
@@ -303,18 +302,18 @@ function queriesToResolvedQueryForm(queries) {
|
||||
},
|
||||
});
|
||||
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
|
||||
// It'll be called once for the default queries
|
||||
// and once for `./foo` from the config file.
|
||||
t.deepEqual(resolveQueriesArgs.length, 2);
|
||||
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
|
||||
t.deepEqual(config.queries["javascript"].builtin.length, 1);
|
||||
t.deepEqual(config.queries["javascript"].custom.length, 1);
|
||||
t.regex(config.queries["javascript"].builtin[0], /javascript-code-scanning.qls$/);
|
||||
t.regex(config.queries["javascript"].custom[0].queries[0], /.*\/foo$/);
|
||||
t.true(config.queries["javascript"].builtin[0].endsWith("javascript-code-scanning.qls"));
|
||||
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) => {
|
||||
@@ -336,18 +335,18 @@ function queriesToResolvedQueryForm(queries) {
|
||||
},
|
||||
});
|
||||
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
|
||||
// It'll be called once for the default queries and once for `./override`,
|
||||
// but won't be called for './foo' from the config file.
|
||||
t.deepEqual(resolveQueriesArgs.length, 2);
|
||||
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
|
||||
t.deepEqual(config.queries["javascript"].builtin.length, 1);
|
||||
t.deepEqual(config.queries["javascript"].custom.length, 1);
|
||||
t.regex(config.queries["javascript"].builtin[0], /javascript-code-scanning.qls$/);
|
||||
t.regex(config.queries["javascript"].custom[0].queries[0], /.*\/override$/);
|
||||
t.true(config.queries["javascript"].builtin[0].endsWith("javascript-code-scanning.qls"));
|
||||
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) => {
|
||||
@@ -368,17 +367,17 @@ function queriesToResolvedQueryForm(queries) {
|
||||
},
|
||||
});
|
||||
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
|
||||
// It'll be called once for `./workflow-query`,
|
||||
// but won't be called for the default one since that was disabled
|
||||
t.deepEqual(resolveQueriesArgs.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
|
||||
t.deepEqual(config.queries["javascript"].builtin.length, 0);
|
||||
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) => {
|
||||
@@ -394,21 +393,21 @@ function queriesToResolvedQueryForm(queries) {
|
||||
},
|
||||
});
|
||||
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:
|
||||
// It'll be called once for the default queries,
|
||||
// and then once for each of the two queries from the workflow
|
||||
t.deepEqual(resolveQueriesArgs.length, 3);
|
||||
t.deepEqual(resolveQueriesArgs[1].queries.length, 1);
|
||||
t.deepEqual(resolveQueriesArgs[2].queries.length, 1);
|
||||
t.regex(resolveQueriesArgs[1].queries[0], /.*\/override1$/);
|
||||
t.regex(resolveQueriesArgs[2].queries[0], /.*\/override2$/);
|
||||
t.true(resolveQueriesArgs[1].queries[0].endsWith(`${path.sep}override1`));
|
||||
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
|
||||
t.deepEqual(config.queries["javascript"].builtin.length, 1);
|
||||
t.deepEqual(config.queries["javascript"].custom.length, 2);
|
||||
t.regex(config.queries["javascript"].builtin[0], /javascript-code-scanning.qls$/);
|
||||
t.regex(config.queries["javascript"].custom[0].queries[0], /.*\/override1$/);
|
||||
t.regex(config.queries["javascript"].custom[1].queries[0], /.*\/override2$/);
|
||||
t.true(config.queries["javascript"].builtin[0].endsWith("javascript-code-scanning.qls"));
|
||||
t.true(config.queries["javascript"].custom[0].queries[0].endsWith(`${path.sep}override1`));
|
||||
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) => {
|
||||
@@ -433,25 +432,25 @@ function queriesToResolvedQueryForm(queries) {
|
||||
},
|
||||
});
|
||||
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
|
||||
// It'll be called once for the default queries,
|
||||
// once for each of additional1 and additional2,
|
||||
// and once for './foo' from the config file
|
||||
t.deepEqual(resolveQueriesArgs.length, 4);
|
||||
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.regex(resolveQueriesArgs[2].queries[0], /.*\/additional2$/);
|
||||
t.true(resolveQueriesArgs[2].queries[0].endsWith(`${path.sep}additional2`));
|
||||
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
|
||||
t.deepEqual(config.queries["javascript"].builtin.length, 1);
|
||||
t.deepEqual(config.queries["javascript"].custom.length, 3);
|
||||
t.regex(config.queries["javascript"].builtin[0], /javascript-code-scanning.qls$/);
|
||||
t.regex(config.queries["javascript"].custom[0].queries[0], /.*\/additional1$/);
|
||||
t.regex(config.queries["javascript"].custom[1].queries[0], /.*\/additional2$/);
|
||||
t.regex(config.queries["javascript"].custom[2].queries[0], /.*\/foo$/);
|
||||
t.true(config.queries["javascript"].builtin[0].endsWith("javascript-code-scanning.qls"));
|
||||
t.true(config.queries["javascript"].custom[0].queries[0].endsWith(`${path.sep}additional1`));
|
||||
t.true(config.queries["javascript"].custom[1].queries[0].endsWith(`${path.sep}additional2`));
|
||||
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) => {
|
||||
@@ -472,7 +471,7 @@ function queriesToResolvedQueryForm(queries) {
|
||||
},
|
||||
});
|
||||
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");
|
||||
}
|
||||
catch (err) {
|
||||
@@ -515,7 +514,7 @@ function queriesToResolvedQueryForm(queries) {
|
||||
fs.mkdirSync(path.join(tmpDir, "foo/bar/dev"), { recursive: true });
|
||||
const configFile = "octo-org/codeql-config/config.yaml@main";
|
||||
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);
|
||||
});
|
||||
});
|
||||
@@ -525,7 +524,7 @@ function queriesToResolvedQueryForm(queries) {
|
||||
mockGetContents(dummyResponse);
|
||||
const repoReference = "octo-org/codeql-config/config.yaml@main";
|
||||
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");
|
||||
}
|
||||
catch (err) {
|
||||
@@ -541,7 +540,7 @@ function queriesToResolvedQueryForm(queries) {
|
||||
mockGetContents(dummyResponse);
|
||||
const repoReference = "octo-org/codeql-config/config.yaml@main";
|
||||
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");
|
||||
}
|
||||
catch (err) {
|
||||
@@ -558,7 +557,7 @@ function queriesToResolvedQueryForm(queries) {
|
||||
},
|
||||
});
|
||||
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");
|
||||
}
|
||||
catch (err) {
|
||||
@@ -570,7 +569,7 @@ function queriesToResolvedQueryForm(queries) {
|
||||
return await util.withTmpDir(async (tmpDir) => {
|
||||
const languages = "rubbish,english";
|
||||
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");
|
||||
}
|
||||
catch (err) {
|
||||
@@ -598,7 +597,7 @@ function queriesToResolvedQueryForm(queries) {
|
||||
const configFile = path.join(tmpDir, "codeql-config.yaml");
|
||||
fs.writeFileSync(configFile, inputFileContents);
|
||||
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, {
|
||||
[languages_1.Language.javascript]: ["a/b@1.2.3"],
|
||||
});
|
||||
@@ -632,7 +631,7 @@ function queriesToResolvedQueryForm(queries) {
|
||||
fs.writeFileSync(configFile, inputFileContents);
|
||||
fs.mkdirSync(path.join(tmpDir, "foo"));
|
||||
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, {
|
||||
[languages_1.Language.javascript]: ["a/b@1.2.3"],
|
||||
[languages_1.Language.python]: ["c/d@1.2.3"],
|
||||
@@ -675,7 +674,7 @@ function doInvalidInputTest(testName, inputFileContents, expectedErrorMessageGen
|
||||
const inputFile = path.join(tmpDir, configFile);
|
||||
fs.writeFileSync(inputFile, inputFileContents, "utf8");
|
||||
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");
|
||||
}
|
||||
catch (err) {
|
||||
@@ -749,14 +748,14 @@ const invalidPaths = ["a/***/b", "a/**b", "a/b**", "**"];
|
||||
* Test macro for ensuring the packs block is valid
|
||||
*/
|
||||
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}`,
|
||||
});
|
||||
/**
|
||||
* Test macro for testing when the packs block is invalid
|
||||
*/
|
||||
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,
|
||||
}),
|
||||
title: (providedTitle = "") => `Parse Packs Error: ${providedTitle}`,
|
||||
@@ -782,6 +781,12 @@ const invalidPackNameMacro = ava_1.default.macro({
|
||||
[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",
|
||||
@@ -814,7 +819,6 @@ const invalidPackNameMacro = ava_1.default.macro({
|
||||
],
|
||||
});
|
||||
(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)(invalidPackNameMacro, "c"); // all packs require at least a scope and a name
|
||||
(0, ava_1.default)(invalidPackNameMacro, "c-/d");
|
||||
@@ -832,12 +836,17 @@ const invalidPackNameMacro = ava_1.default.macro({
|
||||
* Test macro for testing the packs block and the packs input
|
||||
*/
|
||||
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}`;
|
||||
const mockLogger = {
|
||||
info: (message) => {
|
||||
console.log(message);
|
||||
},
|
||||
};
|
||||
function parseInputAndConfigErrorMacro(t, packsFromConfig, packsFromInput, languages, expected) {
|
||||
t.throws(() => {
|
||||
configUtils.parsePacks(packsFromConfig, packsFromInput, languages, "/a/b");
|
||||
configUtils.parsePacks(packsFromConfig, packsFromInput, languages, "/a/b", mockLogger);
|
||||
}, {
|
||||
message: expected,
|
||||
});
|
||||
@@ -882,7 +891,7 @@ 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]
|
||||
: []), (0, logging_1.getRunnerLogger)(true));
|
||||
if (expectedVersionString !== undefined) {
|
||||
@@ -925,4 +934,10 @@ const mlPoweredQueriesMacro = ava_1.default.macro({
|
||||
(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.
|
||||
(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 ML-powered queries are run on all platforms running `security-extended` on CodeQL
|
||||
// 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
|
||||
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: [],
|
||||
originalUserInput: {},
|
||||
tempDir: tmpDir,
|
||||
toolCacheDir: tmpDir,
|
||||
codeQLCmd: "foo",
|
||||
gitHubVersion: { type: util_1.GitHubVariant.DOTCOM },
|
||||
dbLocation: tmpDir,
|
||||
|
||||
File diff suppressed because one or more lines are too long
152
lib/debug-artifacts.js
generated
Normal file
152
lib/debug-artifacts.js
generated
Normal file
@@ -0,0 +1,152 @@
|
||||
"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.uploadDatabaseBundleDebugArtifact = exports.uploadLogsDebugArtifact = exports.uploadSarifDebugArtifact = exports.uploadDebugArtifacts = exports.sanitizeArifactName = void 0;
|
||||
const fs = __importStar(require("fs"));
|
||||
const path = __importStar(require("path"));
|
||||
const zlib_1 = __importDefault(require("zlib"));
|
||||
const artifact = __importStar(require("@actions/artifact"));
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const adm_zip_1 = __importDefault(require("adm-zip"));
|
||||
const del_1 = __importDefault(require("del"));
|
||||
const actions_util_1 = require("./actions-util");
|
||||
const analyze_1 = require("./analyze");
|
||||
const codeql_1 = require("./codeql");
|
||||
const util_1 = require("./util");
|
||||
function sanitizeArifactName(name) {
|
||||
return name.replace(/[^a-zA-Z0-9_\\-]+/g, "");
|
||||
}
|
||||
exports.sanitizeArifactName = sanitizeArifactName;
|
||||
async function uploadDebugArtifacts(toUpload, rootDir, artifactName) {
|
||||
if (toUpload.length === 0) {
|
||||
return;
|
||||
}
|
||||
let suffix = "";
|
||||
const matrix = (0, actions_util_1.getRequiredInput)("matrix");
|
||||
if (matrix) {
|
||||
try {
|
||||
for (const [, matrixVal] of Object.entries(JSON.parse(matrix)).sort())
|
||||
suffix += `-${matrixVal}`;
|
||||
}
|
||||
catch (e) {
|
||||
core.info("Could not parse user-specified `matrix` input into JSON. The debug artifact will not be named with the user's `matrix` input.");
|
||||
}
|
||||
}
|
||||
await artifact.create().uploadArtifact(sanitizeArifactName(`${artifactName}${suffix}`), toUpload.map((file) => path.normalize(file)), path.normalize(rootDir));
|
||||
}
|
||||
exports.uploadDebugArtifacts = uploadDebugArtifacts;
|
||||
async function uploadSarifDebugArtifact(config, outputDir) {
|
||||
if (!(0, util_1.doesDirectoryExist)(outputDir)) {
|
||||
return;
|
||||
}
|
||||
let toUpload = [];
|
||||
for (const lang of config.languages) {
|
||||
const sarifFile = path.resolve(outputDir, `${lang}.sarif`);
|
||||
if (fs.existsSync(sarifFile)) {
|
||||
toUpload = toUpload.concat(sarifFile);
|
||||
}
|
||||
}
|
||||
await uploadDebugArtifacts(toUpload, outputDir, config.debugArtifactName);
|
||||
}
|
||||
exports.uploadSarifDebugArtifact = uploadSarifDebugArtifact;
|
||||
async function uploadLogsDebugArtifact(config) {
|
||||
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
||||
let toUpload = [];
|
||||
for (const language of config.languages) {
|
||||
const databaseDirectory = (0, util_1.getCodeQLDatabasePath)(config, language);
|
||||
const logsDirectory = path.resolve(databaseDirectory, "log");
|
||||
if ((0, util_1.doesDirectoryExist)(logsDirectory)) {
|
||||
toUpload = toUpload.concat((0, util_1.listFolder)(logsDirectory));
|
||||
}
|
||||
}
|
||||
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
|
||||
const multiLanguageTracingLogsDirectory = path.resolve(config.dbLocation, "log");
|
||||
if ((0, util_1.doesDirectoryExist)(multiLanguageTracingLogsDirectory)) {
|
||||
toUpload = toUpload.concat((0, util_1.listFolder)(multiLanguageTracingLogsDirectory));
|
||||
}
|
||||
}
|
||||
await uploadDebugArtifacts(toUpload, config.dbLocation, config.debugArtifactName);
|
||||
// Before multi-language tracing, we wrote a compound-build-tracer.log in the temp dir
|
||||
if (!(await (0, util_1.codeQlVersionAbove)(codeql, codeql_1.CODEQL_VERSION_NEW_TRACING))) {
|
||||
const compoundBuildTracerLogDirectory = path.resolve(config.tempDir, "compound-build-tracer.log");
|
||||
if ((0, util_1.doesDirectoryExist)(compoundBuildTracerLogDirectory)) {
|
||||
await uploadDebugArtifacts([compoundBuildTracerLogDirectory], config.tempDir, config.debugArtifactName);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.uploadLogsDebugArtifact = uploadLogsDebugArtifact;
|
||||
/**
|
||||
* If a database has not been finalized, we cannot run the `codeql database bundle`
|
||||
* command in the CLI because it will return an error. Instead we directly zip
|
||||
* all files in the database folder and upload it as an artifact.
|
||||
*/
|
||||
async function uploadPartialDatabaseBundle(config, language) {
|
||||
const databasePath = (0, util_1.getCodeQLDatabasePath)(config, language);
|
||||
const databaseBundlePath = path.resolve(config.dbLocation, `${config.debugDatabaseName}-${language}-partial.zip`);
|
||||
core.info(`${config.debugDatabaseName}-${language} is not finalized. Uploading partial database bundle at ${databaseBundlePath}...`);
|
||||
// See `bundleDb` for explanation behind deleting existing db bundle.
|
||||
if (fs.existsSync(databaseBundlePath)) {
|
||||
await (0, del_1.default)(databaseBundlePath, { force: true });
|
||||
}
|
||||
const zip = new adm_zip_1.default();
|
||||
zip.addLocalFolder(databasePath);
|
||||
zip.writeZip(databaseBundlePath);
|
||||
await uploadDebugArtifacts([databaseBundlePath], config.dbLocation, config.debugArtifactName);
|
||||
}
|
||||
async function uploadPartialDatabaseBundleZlib(config, language) {
|
||||
const databasePath = (0, util_1.getCodeQLDatabasePath)(config, language);
|
||||
const databaseBundlePath = path.resolve(config.dbLocation, `${config.debugDatabaseName}-${language}-partial.gz`);
|
||||
core.info(`${config.debugDatabaseName}-${language} is not finalized. Uploading partial database bundle at ${databaseBundlePath}...`);
|
||||
// See `bundleDb` for explanation behind deleting existing db bundle.
|
||||
if (fs.existsSync(databaseBundlePath)) {
|
||||
await (0, del_1.default)(databaseBundlePath, { force: true });
|
||||
}
|
||||
const gzip = zlib_1.default.createGzip();
|
||||
const outputStream = fs.createWriteStream(databaseBundlePath);
|
||||
// Write all files in database folder to gz location
|
||||
(0, util_1.listFolder)(databasePath).map((file) => {
|
||||
const readStream = fs.createReadStream(file);
|
||||
readStream.pipe(gzip).pipe(outputStream);
|
||||
});
|
||||
await uploadDebugArtifacts([databaseBundlePath], config.dbLocation, config.debugArtifactName);
|
||||
}
|
||||
async function uploadDatabaseBundleDebugArtifact(config, logger) {
|
||||
for (const language of config.languages) {
|
||||
if (!(0, analyze_1.dbIsFinalized)(config, language, logger)) {
|
||||
await uploadPartialDatabaseBundleZlib(config, language);
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
// Otherwise run `codeql database bundle` command.
|
||||
const bundlePath = await (0, util_1.bundleDb)(config, language, await (0, codeql_1.getCodeQL)(config.codeQLCmd), `${config.debugDatabaseName}-${language}`);
|
||||
await uploadDebugArtifacts([bundlePath], config.dbLocation, config.debugArtifactName);
|
||||
}
|
||||
catch (error) {
|
||||
core.info(`Failed to upload database debug bundles for ${config.debugDatabaseName}-${language}: ${error}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.uploadDatabaseBundleDebugArtifact = uploadDatabaseBundleDebugArtifact;
|
||||
//# sourceMappingURL=debug-artifacts.js.map
|
||||
1
lib/debug-artifacts.js.map
Normal file
1
lib/debug-artifacts.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"debug-artifacts.js","sourceRoot":"","sources":["../src/debug-artifacts.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAC7B,gDAAwB;AAExB,4DAA8C;AAC9C,oDAAsC;AACtC,sDAA6B;AAC7B,8CAAsB;AAEtB,iDAAkD;AAClD,uCAA0C;AAC1C,qCAAiE;AAIjE,iCAMgB;AAEhB,SAAgB,mBAAmB,CAAC,IAAY;IAC9C,OAAO,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC;AAChD,CAAC;AAFD,kDAEC;AAEM,KAAK,UAAU,oBAAoB,CACxC,QAAkB,EAClB,OAAe,EACf,YAAoB;IAEpB,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;QACzB,OAAO;KACR;IACD,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,MAAM,MAAM,GAAG,IAAA,+BAAgB,EAAC,QAAQ,CAAC,CAAC;IAC1C,IAAI,MAAM,EAAE;QACV,IAAI;YACF,KAAK,MAAM,CAAC,EAAE,SAAS,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE;gBACnE,MA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test.js
generated
Normal file
34
lib/debug-artifacts.test.js
generated
Normal file
@@ -0,0 +1,34 @@
|
||||
"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 });
|
||||
const ava_1 = __importDefault(require("ava"));
|
||||
const debugArtifacts = __importStar(require("./debug-artifacts"));
|
||||
(0, ava_1.default)("sanitizeArifactName", (t) => {
|
||||
t.deepEqual(debugArtifacts.sanitizeArifactName("hello-world_"), "hello-world_");
|
||||
t.deepEqual(debugArtifacts.sanitizeArifactName("hello`world`"), "helloworld");
|
||||
t.deepEqual(debugArtifacts.sanitizeArifactName("hello===123"), "hello123");
|
||||
t.deepEqual(debugArtifacts.sanitizeArifactName("*m)a&n^y%i££n+v!a:l[i]d"), "manyinvalid");
|
||||
});
|
||||
// TODO(angelapwen): Test uploadDebugArtifacts if toUpload is empty
|
||||
//# sourceMappingURL=debug-artifacts.test.js.map
|
||||
1
lib/debug-artifacts.test.js.map
Normal file
1
lib/debug-artifacts.test.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"debug-artifacts.test.js","sourceRoot":"","sources":["../src/debug-artifacts.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAuB;AAEvB,kEAAoD;AAEpD,IAAA,aAAI,EAAC,qBAAqB,EAAE,CAAC,CAAC,EAAE,EAAE;IAChC,CAAC,CAAC,SAAS,CACT,cAAc,CAAC,mBAAmB,CAAC,cAAc,CAAC,EAClD,cAAc,CACf,CAAC;IACF,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,mBAAmB,CAAC,cAAc,CAAC,EAAE,YAAY,CAAC,CAAC;IAC9E,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,mBAAmB,CAAC,aAAa,CAAC,EAAE,UAAU,CAAC,CAAC;IAC3E,CAAC,CAAC,SAAS,CACT,cAAc,CAAC,mBAAmB,CAAC,yBAAyB,CAAC,EAC7D,aAAa,CACd,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,mEAAmE"}
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"bundleVersion": "codeql-bundle-20220527"
|
||||
"bundleVersion": "codeql-bundle-20220714"
|
||||
}
|
||||
|
||||
9
lib/feature-flags.js
generated
9
lib/feature-flags.js
generated
@@ -35,12 +35,17 @@ class GitHubFeatureFlags {
|
||||
this.logger = logger;
|
||||
}
|
||||
async getValue(flag) {
|
||||
const response = (await this.getApiResponse())[flag];
|
||||
const response = await this.getApiResponse();
|
||||
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.`);
|
||||
return false;
|
||||
}
|
||||
return response;
|
||||
return flagValue;
|
||||
}
|
||||
async getApiResponse() {
|
||||
const loadApiResponse = async () => {
|
||||
|
||||
@@ -1 +1 @@
|
||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AAI,CAAC;aACtB;YAAC,OAAO,CAAC,EAAE;gBACV,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,GAAG,EAAE;oBAC3C,IAAI,CAAC,MAAM,CAAC,OAAO,CACjB,gGAAgG;wBAC9F,oEAAoE;wBACpE,qFAAqF;wBACrF,kFAAkF,CAAC,EAAE,CACxF,CAAC;iBACH;qBAAM;oBACL,uFAAuF;oBACvF,mFAAmF;oBACnF,2FAA2F;oBAC3F,qBAAqB;oBACrB,MAAM,IAAI,KAAK,CACb,4DAA4D,CAAC,EAAE,CAChE,CAAC;iBACH;aACF;QACH,CAAC,CAAC;QAEF,MAAM,WAAW,GAAG,IAAI,CAAC,iBAAiB,IAAI,CAAC,MAAM,eAAe,EAAE,CAAC,CAAC;QACxE,IAAI,CAAC,iBAAiB,GAAG,WAAW,CAAC;QACrC,OAAO,WAAW,CAAC;IACrB,CAAC;CACF;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"}
|
||||
16
lib/feature-flags.test.js
generated
16
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) => {
|
||||
await (0, util_1.withTmpDir)(async (tmpDir) => {
|
||||
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||
|
||||
@@ -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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||
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 });
|
||||
exports.addFingerprints = exports.resolveUriToFile = exports.hash = void 0;
|
||||
const fs = __importStar(require("fs"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const long_1 = __importDefault(require("long"));
|
||||
const tab = "\t".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.
|
||||
// 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.
|
||||
if (!uri.startsWith("/")) {
|
||||
if (!path_1.default.isAbsolute(uri)) {
|
||||
uri = srcRootPrefix + uri;
|
||||
}
|
||||
// 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));
|
||||
}
|
||||
(0, ava_1.default)("resolveUriToFile", (t) => {
|
||||
var _a, _b;
|
||||
// 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.
|
||||
// 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.
|
||||
const cwd = process.cwd();
|
||||
const filepath = __filename;
|
||||
t.true(filepath.startsWith(`${cwd}/`));
|
||||
const relativeFilepath = filepath.substring(cwd.length + 1);
|
||||
const filepath = __filename.split(path.sep).join("/");
|
||||
const relativeFilepath = path
|
||||
.relative(process.cwd(), __filename)
|
||||
.split(path.sep)
|
||||
.join("/");
|
||||
// Absolute paths are unmodified
|
||||
t.is(testResolveUriToFile(filepath, undefined, []), filepath);
|
||||
t.is(testResolveUriToFile(`file://${filepath}`, undefined, []), filepath);
|
||||
// Relative paths are made absolute
|
||||
t.is(testResolveUriToFile(relativeFilepath, undefined, []), filepath);
|
||||
t.is(testResolveUriToFile(`file://${relativeFilepath}`, undefined, []), filepath);
|
||||
t.is((_a = testResolveUriToFile(relativeFilepath, undefined, [])) === null || _a === void 0 ? void 0 : _a.split(path.sep).join("/"), 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
|
||||
t.is(testResolveUriToFile("/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
56
lib/init-action-post.js
generated
Normal file
56
lib/init-action-post.js
generated
Normal file
@@ -0,0 +1,56 @@
|
||||
"use strict";
|
||||
/**
|
||||
* This file is the entry point for the `post:` hook of `init-action.yml`.
|
||||
* It will run after the all steps in this job, in reverse order in relation to
|
||||
* other `post:` hooks.
|
||||
*/
|
||||
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;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const actionsUtil = __importStar(require("./actions-util"));
|
||||
const config_utils_1 = require("./config-utils");
|
||||
const debugArtifacts = __importStar(require("./debug-artifacts"));
|
||||
const logging_1 = require("./logging");
|
||||
async function run(uploadDatabaseBundleDebugArtifact, uploadLogsDebugArtifact, printDebugLogs) {
|
||||
const logger = (0, logging_1.getActionsLogger)();
|
||||
const config = await (0, config_utils_1.getConfig)(actionsUtil.getTemporaryDirectory(), logger);
|
||||
if (config === undefined) {
|
||||
throw new Error("Config file could not be found at expected location. Did the 'init' action fail to start?");
|
||||
}
|
||||
// Upload appropriate Actions artifacts for debugging
|
||||
if (config === null || config === void 0 ? void 0 : config.debugMode) {
|
||||
core.info("Debug mode is on. Uploading available database bundles and logs as Actions debugging artifacts...");
|
||||
await uploadDatabaseBundleDebugArtifact(config, logger);
|
||||
await uploadLogsDebugArtifact(config);
|
||||
await printDebugLogs(config);
|
||||
}
|
||||
}
|
||||
async function runWrapper() {
|
||||
try {
|
||||
await run(debugArtifacts.uploadDatabaseBundleDebugArtifact, debugArtifacts.uploadLogsDebugArtifact, actionsUtil.printDebugLogs);
|
||||
}
|
||||
catch (error) {
|
||||
core.setFailed(`init action cleanup failed: ${error}`);
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
void runWrapper();
|
||||
//# sourceMappingURL=init-action-post.js.map
|
||||
1
lib/init-action-post.js.map
Normal file
1
lib/init-action-post.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"init-action-post.js","sourceRoot":"","sources":["../src/init-action-post.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;AAEH,oDAAsC;AAEtC,4DAA8C;AAC9C,iDAA2C;AAC3C,kEAAoD;AACpD,uCAA6C;AAE7C,KAAK,UAAU,GAAG,CAChB,iCAA2C,EAC3C,uBAAiC,EACjC,cAAwB;IAExB,MAAM,MAAM,GAAG,IAAA,0BAAgB,GAAE,CAAC;IAElC,MAAM,MAAM,GAAG,MAAM,IAAA,wBAAS,EAAC,WAAW,CAAC,qBAAqB,EAAE,EAAE,MAAM,CAAC,CAAC;IAC5E,IAAI,MAAM,KAAK,SAAS,EAAE;QACxB,MAAM,IAAI,KAAK,CACb,2FAA2F,CAC5F,CAAC;KACH;IAED,qDAAqD;IACrD,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,SAAS,EAAE;QACrB,IAAI,CAAC,IAAI,CACP,mGAAmG,CACpG,CAAC;QACF,MAAM,iCAAiC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACxD,MAAM,uBAAuB,CAAC,MAAM,CAAC,CAAC;QAEtC,MAAM,cAAc,CAAC,MAAM,CAAC,CAAC;KAC9B;AACH,CAAC;AAED,KAAK,UAAU,UAAU;IACvB,IAAI;QACF,MAAM,GAAG,CACP,cAAc,CAAC,iCAAiC,EAChD,cAAc,CAAC,uBAAuB,EACtC,WAAW,CAAC,cAAc,CAC3B,CAAC;KACH;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,SAAS,CAAC,+BAA+B,KAAK,EAAE,CAAC,CAAC;QACvD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;KACpB;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"}
|
||||
3
lib/init-action-post.test.js
generated
Normal file
3
lib/init-action-post.test.js
generated
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
// TODO(angelapwen): Test run() here.
|
||||
//# sourceMappingURL=init-action-post.test.js.map
|
||||
1
lib/init-action-post.test.js.map
Normal file
1
lib/init-action-post.test.js.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"init-action-post.test.js","sourceRoot":"","sources":["../src/init-action-post.test.ts"],"names":[],"mappings":";AAAA,qCAAqC"}
|
||||
9
lib/init-action.js
generated
9
lib/init-action.js
generated
@@ -89,11 +89,16 @@ async function run() {
|
||||
if (!(await (0, actions_util_1.sendStatusReport)(await (0, actions_util_1.createStatusReportBase)("init", "starting", startedAt, workflowErrors)))) {
|
||||
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;
|
||||
toolsVersion = initCodeQLResult.toolsVersion;
|
||||
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) &&
|
||||
(0, actions_util_1.getRequiredInput)("setup-python-dependencies") === "true") {
|
||||
try {
|
||||
|
||||
File diff suppressed because one or more lines are too long
13
lib/init.js
generated
13
lib/init.js
generated
@@ -30,17 +30,17 @@ const configUtils = __importStar(require("./config-utils"));
|
||||
const tracer_config_1 = require("./tracer-config");
|
||||
const util = __importStar(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");
|
||||
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();
|
||||
logger.endGroup();
|
||||
return { codeql, toolsVersion };
|
||||
}
|
||||
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");
|
||||
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);
|
||||
logger.endGroup();
|
||||
return config;
|
||||
@@ -179,12 +179,15 @@ async function installPythonDeps(codeql, logger) {
|
||||
if (process.platform === "win32") {
|
||||
await new toolrunner.ToolRunner(await safeWhich.safeWhich("py"), [
|
||||
"-3",
|
||||
"-B",
|
||||
path.join(scriptsFolder, script),
|
||||
path.dirname(codeql.getPath()),
|
||||
]).exec();
|
||||
}
|
||||
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()),
|
||||
]).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;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,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["python"] = "python";
|
||||
Language["ruby"] = "ruby";
|
||||
Language["swift"] = "swift";
|
||||
})(Language = exports.Language || (exports.Language = {}));
|
||||
// Additional names for languages
|
||||
const LANGUAGE_ALIASES = {
|
||||
@@ -35,7 +36,7 @@ function parseLanguage(language) {
|
||||
}
|
||||
exports.parseLanguage = parseLanguage;
|
||||
function isTracedLanguage(language) {
|
||||
return (["cpp", "java", "csharp"].includes(language) ||
|
||||
return (["cpp", "java", "csharp", "swift"].includes(language) ||
|
||||
(process.env["CODEQL_EXTRACTOR_GO_BUILD_TRACING"] === "on" &&
|
||||
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;IAC1B,QAAQ,GAA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B;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"}
|
||||
15
lib/runner.js
generated
15
lib/runner.js
generated
@@ -23,7 +23,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const fs = __importStar(require("fs"));
|
||||
const os = __importStar(require("os"));
|
||||
const path = __importStar(require("path"));
|
||||
const commander_1 = require("commander");
|
||||
const del_1 = __importDefault(require("del"));
|
||||
@@ -51,13 +50,6 @@ function getTempDir(userInput) {
|
||||
}
|
||||
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";
|
||||
function loadTracerEnvironment(config) {
|
||||
const jsonEnvFile = path.join(config.tempDir, codeqlEnvJsonFilename);
|
||||
@@ -134,7 +126,6 @@ program
|
||||
const logger = (0, logging_1.getRunnerLogger)(cmd.debug);
|
||||
try {
|
||||
const tempDir = getTempDir(cmd.tempDir);
|
||||
const toolsDir = getToolsDir(cmd.toolsDir);
|
||||
const checkoutPath = cmd.checkoutPath || process.cwd();
|
||||
// Wipe the temp dir
|
||||
logger.info(`Cleaning temp directory ${tempDir}`);
|
||||
@@ -160,11 +151,11 @@ program
|
||||
codeql = await (0, codeql_1.getCodeQL)(cmd.codeqlPath);
|
||||
}
|
||||
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);
|
||||
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 tracerConfig = await (0, init_1.runInit)(codeql, config, sourceRoot, parseTraceProcessName(), parseTraceProcessLevel(), (0, feature_flags_1.createFeatureFlags)([]));
|
||||
if (tracerConfig === undefined) {
|
||||
@@ -297,7 +288,7 @@ program
|
||||
}
|
||||
const threads = (0, util_1.getThreadsFlag)(cmd.threads || initEnv["CODEQL_THREADS"], logger);
|
||||
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);
|
||||
if (!cmd.upload) {
|
||||
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);
|
||||
t.context.stderrWrite = processStderrWrite;
|
||||
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
|
||||
// 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.
|
||||
|
||||
@@ -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,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AAM;QACL,QAAQ,CAAC,MAAM,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: [],
|
||||
originalUserInput: {},
|
||||
tempDir: tmpDir,
|
||||
toolCacheDir: tmpDir,
|
||||
codeQLCmd: "",
|
||||
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
||||
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
||||
|
||||
File diff suppressed because one or more lines are too long
51
lib/util.js
generated
51
lib/util.js
generated
@@ -22,7 +22,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.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;
|
||||
exports.listFolder = exports.doesDirectoryExist = 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 os = __importStar(require("os"));
|
||||
const path = __importStar(require("path"));
|
||||
@@ -89,11 +89,7 @@ exports.getToolNames = getToolNames;
|
||||
// Mostly intended for use within tests.
|
||||
async function withTmpDir(body) {
|
||||
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "codeql-action-"));
|
||||
const realSubdir = path.join(tmpDir, "real");
|
||||
fs.mkdirSync(realSubdir);
|
||||
const symlinkSubdir = path.join(tmpDir, "symlink");
|
||||
fs.symlinkSync(realSubdir, symlinkSubdir, "dir");
|
||||
const result = await body(symlinkSubdir);
|
||||
const result = await body(tmpDir);
|
||||
await (0, del_1.default)(tmpDir, { force: true });
|
||||
return result;
|
||||
}
|
||||
@@ -552,10 +548,17 @@ exports.ML_POWERED_JS_QUERIES_PACK_NAME = "codeql/javascript-experimental-atm-qu
|
||||
* queries beta.
|
||||
*/
|
||||
async function getMlPoweredJsQueriesPack(codeQL) {
|
||||
if (await codeQlVersionAbove(codeQL, "2.8.4")) {
|
||||
return `${exports.ML_POWERED_JS_QUERIES_PACK_NAME}@~0.2.0`;
|
||||
let version;
|
||||
if (await codeQlVersionAbove(codeQL, "2.9.3")) {
|
||||
version = `~0.3.0`;
|
||||
}
|
||||
return `${exports.ML_POWERED_JS_QUERIES_PACK_NAME}@~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;
|
||||
/**
|
||||
@@ -635,4 +638,34 @@ function isInTestMode() {
|
||||
return process.env["TEST_MODE"] === "true" || false;
|
||||
}
|
||||
exports.isInTestMode = isInTestMode;
|
||||
/*
|
||||
* Returns whether the path in the argument represents an existing directory.
|
||||
*/
|
||||
function doesDirectoryExist(dirPath) {
|
||||
try {
|
||||
const stats = fs.lstatSync(dirPath);
|
||||
return stats.isDirectory();
|
||||
}
|
||||
catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
exports.doesDirectoryExist = doesDirectoryExist;
|
||||
/**
|
||||
* Returns a list of files in a given directory.
|
||||
*/
|
||||
function listFolder(dir) {
|
||||
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
||||
let files = [];
|
||||
for (const entry of entries) {
|
||||
if (entry.isFile()) {
|
||||
files.push(path.resolve(dir, entry.name));
|
||||
}
|
||||
else if (entry.isDirectory()) {
|
||||
files = files.concat(listFolder(path.resolve(dir, entry.name)));
|
||||
}
|
||||
}
|
||||
return files;
|
||||
}
|
||||
exports.listFolder = listFolder;
|
||||
//# sourceMappingURL=util.js.map
|
||||
File diff suppressed because one or more lines are too long
7
lib/util.test.js
generated
7
lib/util.test.js
generated
@@ -245,7 +245,6 @@ for (const [packs, expectedStatus] of ML_POWERED_JS_STATUS_TESTS) {
|
||||
pathsIgnore: [],
|
||||
originalUserInput: {},
|
||||
tempDir: tmpDir,
|
||||
toolCacheDir: tmpDir,
|
||||
codeQLCmd: "",
|
||||
gitHubVersion: {
|
||||
type: util.GitHubVariant.DOTCOM,
|
||||
@@ -316,4 +315,10 @@ for (const [version, githubVersion, shouldReportWarning,] of CHECK_ACTION_VERSIO
|
||||
isActionsStub.restore();
|
||||
});
|
||||
}
|
||||
// TODO(angelapwen): Test doesDirectoryExist() returns true if directory
|
||||
// TODO(angelapwen): Test doesDirectoryExist() returns false if file
|
||||
// TODO(angelapwen): Test doesDirectoryExist() returns false if no file of this type exists
|
||||
// TODO(angelapwen): Test listFolder() returns files in directory
|
||||
// TODO(angelapwen): Test listFolder() returns empty if not a directory
|
||||
// TODO(angelapwen): Test doesDirectoryExist() returns empty if directory is empty
|
||||
//# sourceMappingURL=util.test.js.map
|
||||
File diff suppressed because one or more lines are too long
25
node_modules/.package-lock.json
generated
vendored
25
node_modules/.package-lock.json
generated
vendored
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "codeql",
|
||||
"version": "2.1.12",
|
||||
"version": "2.1.17",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
@@ -464,11 +464,26 @@
|
||||
"integrity": "sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/adm-zip": {
|
||||
"version": "0.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/adm-zip/-/adm-zip-0.5.0.tgz",
|
||||
"integrity": "sha512-FCJBJq9ODsQZUNURo5ILAQueuA8WJhRvuihS3ke2iI25mJlfV2LK8jG2Qj2z2AWg8U0FtWWqBHVRetceLskSaw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/color-name": {
|
||||
"version": "1.1.1",
|
||||
"integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==",
|
||||
"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": {
|
||||
"version": "7.0.8",
|
||||
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.8.tgz",
|
||||
@@ -793,6 +808,14 @@
|
||||
"node": ">=0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/adm-zip": {
|
||||
"version": "0.5.9",
|
||||
"resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.5.9.tgz",
|
||||
"integrity": "sha512-s+3fXLkeeLjZ2kLjCBwQufpI5fuN+kIGBxu6530nVQZGVol0d7Y/M88/xw9HGGUcJjKf8LutN3VPRUBq6N7Ajg==",
|
||||
"engines": {
|
||||
"node": ">=6.0"
|
||||
}
|
||||
},
|
||||
"node_modules/aggregate-error": {
|
||||
"version": "3.0.1",
|
||||
"integrity": "sha512-quoaXsZ9/BLNae5yiNoUz+Nhkwz83GhWwtYFglcjEQB2NDHCIpApbqXxIFnm4Pq/Nvhrsq5sYJFyohrrxnTGAA==",
|
||||
|
||||
21
node_modules/@types/adm-zip/LICENSE
generated
vendored
Executable file
21
node_modules/@types/adm-zip/LICENSE
generated
vendored
Executable file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
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
|
||||
16
node_modules/@types/adm-zip/README.md
generated
vendored
Executable file
16
node_modules/@types/adm-zip/README.md
generated
vendored
Executable file
@@ -0,0 +1,16 @@
|
||||
# Installation
|
||||
> `npm install --save @types/adm-zip`
|
||||
|
||||
# Summary
|
||||
This package contains type definitions for adm-zip (https://github.com/cthackers/adm-zip).
|
||||
|
||||
# Details
|
||||
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/adm-zip.
|
||||
|
||||
### Additional Details
|
||||
* Last updated: Fri, 01 Apr 2022 08:01:43 GMT
|
||||
* Dependencies: [@types/node](https://npmjs.com/package/@types/node)
|
||||
* Global values: none
|
||||
|
||||
# Credits
|
||||
These definitions were written by [John Vilk](https://github.com/jvilk), [Abner Oliveira](https://github.com/abner), [BendingBender](https://github.com/BendingBender), [Matthew Sainsbury](https://github.com/mattsains), and [Lei Nelissen](https://github.com/LeiNelissen).
|
||||
380
node_modules/@types/adm-zip/index.d.ts
generated
vendored
Executable file
380
node_modules/@types/adm-zip/index.d.ts
generated
vendored
Executable file
@@ -0,0 +1,380 @@
|
||||
// Type definitions for adm-zip 0.5
|
||||
// Project: https://github.com/cthackers/adm-zip
|
||||
// Definitions by: John Vilk <https://github.com/jvilk>
|
||||
// Abner Oliveira <https://github.com/abner>
|
||||
// BendingBender <https://github.com/BendingBender>
|
||||
// Matthew Sainsbury <https://github.com/mattsains>
|
||||
// Lei Nelissen <https://github.com/LeiNelissen>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
import * as FS from 'fs';
|
||||
import { Constants } from './util';
|
||||
|
||||
declare class AdmZip {
|
||||
/**
|
||||
* @param fileNameOrRawData If provided, reads an existing archive. Otherwise creates a new, empty archive.
|
||||
* @param options Options when initializing the ZIP file
|
||||
*/
|
||||
constructor(fileNameOrRawData?: string | Buffer, options?: Partial<AdmZip.InitOptions>);
|
||||
/**
|
||||
* Extracts the given entry from the archive and returns the content as a Buffer object
|
||||
* @param entry ZipEntry object or String with the full path of the entry
|
||||
* @param pass Password used for decrypting the file
|
||||
* @return Buffer or Null in case of error
|
||||
*/
|
||||
readFile(entry: string | AdmZip.IZipEntry, pass?: string | Buffer): Buffer | null;
|
||||
/**
|
||||
* Asynchronous `readFile`.
|
||||
* @param entry The full path of the entry or a `IZipEntry` object.
|
||||
* @param callback Called with a `Buffer` or `null` in case of error.
|
||||
*/
|
||||
readFileAsync(entry: string | AdmZip.IZipEntry, callback: (data: Buffer | null, err: string) => void): void;
|
||||
/**
|
||||
* Extracts the given entry from the archive and returns the content as
|
||||
* plain text in the given encoding.
|
||||
* @param entry The full path of the entry or a `IZipEntry` object.
|
||||
* @param encoding If no encoding is specified `"utf8"` is used.
|
||||
*/
|
||||
readAsText(fileName: string | AdmZip.IZipEntry, encoding?: string): string;
|
||||
/**
|
||||
* Asynchronous `readAsText`.
|
||||
* @param entry The full path of the entry or a `IZipEntry` object.
|
||||
* @param callback Called with the resulting string.
|
||||
* @param encoding If no encoding is specified `"utf8"` is used.
|
||||
*/
|
||||
readAsTextAsync(
|
||||
fileName: string | AdmZip.IZipEntry,
|
||||
callback: (data: string, err: string) => void,
|
||||
encoding?: string
|
||||
): void;
|
||||
/**
|
||||
* Remove the entry from the file or the entry and all its nested directories
|
||||
* and files if the given entry is a directory.
|
||||
* @param entry The full path of the entry or a `IZipEntry` object.
|
||||
*/
|
||||
deleteFile(entry: string | AdmZip.IZipEntry): void;
|
||||
/**
|
||||
* Adds a comment to the zip. The zip must be rewritten after
|
||||
* adding the comment.
|
||||
* @param comment Content of the comment.
|
||||
*/
|
||||
addZipComment(comment: string): void;
|
||||
/**
|
||||
* @return The zip comment.
|
||||
*/
|
||||
getZipComment(): string;
|
||||
/**
|
||||
* Adds a comment to a specified file or `IZipEntry`. The zip must be rewritten after
|
||||
* adding the comment.
|
||||
* The comment cannot exceed 65535 characters in length.
|
||||
* @param entry The full path of the entry or a `IZipEntry` object.
|
||||
* @param comment The comment to add to the entry.
|
||||
*/
|
||||
addZipEntryComment(entry: string | AdmZip.IZipEntry, comment: string): void;
|
||||
/**
|
||||
* Returns the comment of the specified entry.
|
||||
* @param entry The full path of the entry or a `IZipEntry` object.
|
||||
* @return The comment of the specified entry.
|
||||
*/
|
||||
getZipEntryComment(entry: string | AdmZip.IZipEntry): string;
|
||||
/**
|
||||
* Updates the content of an existing entry inside the archive. The zip
|
||||
* must be rewritten after updating the content.
|
||||
* @param entry The full path of the entry or a `IZipEntry` object.
|
||||
* @param content The entry's new contents.
|
||||
*/
|
||||
updateFile(entry: string | AdmZip.IZipEntry, content: Buffer): void;
|
||||
/**
|
||||
* Adds a file from the disk to the archive.
|
||||
* @param localPath Path to a file on disk.
|
||||
* @param zipPath Path to a directory in the archive. Defaults to the empty
|
||||
* string.
|
||||
* @param zipName Name for the file.
|
||||
* @param comment Comment to be attached to the file
|
||||
*/
|
||||
addLocalFile(localPath: string, zipPath?: string, zipName?: string, comment?: string): void;
|
||||
/**
|
||||
* Adds a local directory and all its nested files and directories to the
|
||||
* archive.
|
||||
* @param localPath Path to a folder on disk.
|
||||
* @param zipPath Path to a folder in the archive. Default: `""`.
|
||||
* @param filter RegExp or Function if files match will be included.
|
||||
*/
|
||||
addLocalFolder(localPath: string, zipPath?: string, filter?: RegExp | ((filename: string) => boolean)): void;
|
||||
/**
|
||||
* Asynchronous addLocalFile
|
||||
* @param localPath
|
||||
* @param callback
|
||||
* @param zipPath optional path inside zip
|
||||
* @param filter optional RegExp or Function if files match will
|
||||
* be included.
|
||||
*/
|
||||
addLocalFolderAsync(
|
||||
localPath: string,
|
||||
callback: (success?: boolean, err?: string) => void,
|
||||
zipPath?: string,
|
||||
filter?: RegExp | ((filename: string) => boolean)
|
||||
): void;
|
||||
/**
|
||||
*
|
||||
* @param localPath - path where files will be extracted
|
||||
* @param props - optional properties
|
||||
* @param props.zipPath - optional path inside zip
|
||||
* @param props.filter - RegExp or Function if files match will be included.
|
||||
*/
|
||||
addLocalFolderPromise(
|
||||
localPath: string,
|
||||
props: { zipPath?: string, filter?: RegExp | ((filename: string) => boolean) }
|
||||
): Promise<void>;
|
||||
/**
|
||||
* Allows you to create a entry (file or directory) in the zip file.
|
||||
* If you want to create a directory the `entryName` must end in `"/"` and a `null`
|
||||
* buffer should be provided.
|
||||
* @param entryName Entry path.
|
||||
* @param content Content to add to the entry; must be a 0-length buffer
|
||||
* for a directory.
|
||||
* @param comment Comment to add to the entry.
|
||||
* @param attr Attribute to add to the entry.
|
||||
*/
|
||||
addFile(entryName: string, content: Buffer, comment?: string, attr?: number): void;
|
||||
/**
|
||||
* Returns an array of `IZipEntry` objects representing the files and folders
|
||||
* inside the archive.
|
||||
*/
|
||||
getEntries(): AdmZip.IZipEntry[];
|
||||
/**
|
||||
* Returns a `IZipEntry` object representing the file or folder specified by `name`.
|
||||
* @param name Name of the file or folder to retrieve.
|
||||
* @return The entry corresponding to the `name`.
|
||||
*/
|
||||
getEntry(name: string): AdmZip.IZipEntry | null;
|
||||
/**
|
||||
* Returns the number of entries in the ZIP
|
||||
* @return The amount of entries in the ZIP
|
||||
*/
|
||||
getEntryCount(): number;
|
||||
/**
|
||||
* Loop through each entry in the ZIP
|
||||
* @param callback The callback that receives each individual entry
|
||||
*/
|
||||
forEach(callback: (entry: AdmZip.IZipEntry) => void): void;
|
||||
/**
|
||||
* Extracts the given entry to the given `targetPath`.
|
||||
* If the entry is a directory inside the archive, the entire directory and
|
||||
* its subdirectories will be extracted.
|
||||
* @param entry The full path of the entry or a `IZipEntry` object.
|
||||
* @param targetPath Target folder where to write the file.
|
||||
* @param maintainEntryPath If maintainEntryPath is `true` and the entry is
|
||||
* inside a folder, the entry folder will be created in `targetPath` as
|
||||
* well. Default: `true`.
|
||||
* @param overwrite If the file already exists at the target path, the file
|
||||
* will be overwriten if this is `true`. Default: `false`.
|
||||
* @param keepOriginalPermission The file will be set as the permission from
|
||||
* the entry if this is true. Default: `false`.
|
||||
* @param outFileName String If set will override the filename of the
|
||||
* extracted file (Only works if the entry is a file)
|
||||
* @return Boolean
|
||||
*/
|
||||
extractEntryTo(
|
||||
entryPath: string | AdmZip.IZipEntry,
|
||||
targetPath: string,
|
||||
maintainEntryPath?: boolean,
|
||||
overwrite?: boolean,
|
||||
keepOriginalPermission?: boolean,
|
||||
outFileName?: string,
|
||||
): boolean;
|
||||
/**
|
||||
* Test the archive
|
||||
* @param password The password for the archive
|
||||
*/
|
||||
test(password?: string | Buffer): boolean;
|
||||
/**
|
||||
* Extracts the entire archive to the given location.
|
||||
* @param targetPath Target location.
|
||||
* @param overwrite If the file already exists at the target path, the file
|
||||
* will be overwriten if this is `true`. Default: `false`.
|
||||
* @param keepOriginalPermission The file will be set as the permission from
|
||||
* the entry if this is true. Default: `false`.
|
||||
* @param password The password for the archive
|
||||
*/
|
||||
extractAllTo(
|
||||
targetPath: string,
|
||||
overwrite?: boolean,
|
||||
keepOriginalPermission?: boolean,
|
||||
password?: string | Buffer
|
||||
): void;
|
||||
/**
|
||||
* Extracts the entire archive to the given location.
|
||||
* @param targetPath Target location.
|
||||
* @param overwrite If the file already exists at the target path, the file
|
||||
* will be overwriten if this is `true`. Default: `false`.
|
||||
* @param keepOriginalPermission The file will be set as the permission from
|
||||
* the entry if this is true. Default: `false`.
|
||||
* @param callback The callback function will be called after extraction.
|
||||
*/
|
||||
extractAllToAsync(
|
||||
targetPath: string,
|
||||
overwrite?: boolean,
|
||||
keepOriginalPermission?: boolean,
|
||||
callback?: (error?: Error) => void,
|
||||
): void;
|
||||
/**
|
||||
* Writes the newly created zip file to disk at the specified location or
|
||||
* if a zip was opened and no `targetFileName` is provided, it will
|
||||
* overwrite the opened zip.
|
||||
*/
|
||||
writeZip(targetFileName?: string, callback?: (error: Error | null) => void): void;
|
||||
/**
|
||||
* Writes the newly created zip file to disk at the specified location or
|
||||
* if a zip was opened and no `targetFileName` is provided, it will
|
||||
* overwrite the opened zip.
|
||||
*/
|
||||
writeZipPromise(
|
||||
targetFileName?: string,
|
||||
props?: { overwrite?: boolean, perm?: number }
|
||||
): Promise<boolean>;
|
||||
/**
|
||||
* Returns the content of the entire zip file.
|
||||
*/
|
||||
toBuffer(): Buffer;
|
||||
/**
|
||||
* Asynchronously returns the content of the entire zip file.
|
||||
* @param onSuccess called with the content of the zip file, once it has been generated.
|
||||
* @param onFail unused.
|
||||
* @param onItemStart called before an entry is compressed.
|
||||
* @param onItemEnd called after an entry is compressed.
|
||||
*/
|
||||
toBuffer(
|
||||
onSuccess: (buffer: Buffer) => void,
|
||||
onFail?: (...args: any[]) => void,
|
||||
onItemStart?: (name: string) => void,
|
||||
onItemEnd?: (name: string) => void,
|
||||
): void;
|
||||
/**
|
||||
* Asynchronously convert the promise to a Buffer
|
||||
*/
|
||||
toBufferPromise(): Promise<Buffer>;
|
||||
}
|
||||
|
||||
declare namespace AdmZip {
|
||||
/**
|
||||
* The `IZipEntry` is more than a structure representing the entry inside the
|
||||
* zip file. Beside the normal attributes and headers a entry can have, the
|
||||
* class contains a reference to the part of the file where the compressed
|
||||
* data resides and decompresses it when requested. It also compresses the
|
||||
* data and creates the headers required to write in the zip file.
|
||||
*/
|
||||
// disable warning about the I-prefix in interface name to prevent breaking stuff for users without a major bump
|
||||
// tslint:disable-next-line:interface-name
|
||||
interface IZipEntry {
|
||||
/**
|
||||
* Represents the full name and path of the file
|
||||
*/
|
||||
entryName: string;
|
||||
readonly rawEntryName: Buffer;
|
||||
/**
|
||||
* Extra data associated with this entry.
|
||||
*/
|
||||
extra: Buffer;
|
||||
/**
|
||||
* Entry comment.
|
||||
*/
|
||||
comment: string;
|
||||
readonly name: string;
|
||||
/**
|
||||
* Read-Only property that indicates the type of the entry.
|
||||
*/
|
||||
readonly isDirectory: boolean;
|
||||
/**
|
||||
* Get the header associated with this ZipEntry.
|
||||
*/
|
||||
readonly header: EntryHeader;
|
||||
attr: number;
|
||||
/**
|
||||
* Retrieve the compressed data for this entry. Note that this may trigger
|
||||
* compression if any properties were modified.
|
||||
*/
|
||||
getCompressedData(): Buffer;
|
||||
/**
|
||||
* Asynchronously retrieve the compressed data for this entry. Note that
|
||||
* this may trigger compression if any properties were modified.
|
||||
*/
|
||||
getCompressedDataAsync(callback: (data: Buffer) => void): void;
|
||||
/**
|
||||
* Set the (uncompressed) data to be associated with this entry.
|
||||
*/
|
||||
setData(value: string | Buffer): void;
|
||||
/**
|
||||
* Get the decompressed data associated with this entry.
|
||||
*/
|
||||
getData(): Buffer;
|
||||
/**
|
||||
* Asynchronously get the decompressed data associated with this entry.
|
||||
*/
|
||||
getDataAsync(callback: (data: Buffer, err: string) => void): void;
|
||||
/**
|
||||
* Returns the CEN Entry Header to be written to the output zip file, plus
|
||||
* the extra data and the entry comment.
|
||||
*/
|
||||
packHeader(): Buffer;
|
||||
/**
|
||||
* Returns a nicely formatted string with the most important properties of
|
||||
* the ZipEntry.
|
||||
*/
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
interface EntryHeader {
|
||||
made: number;
|
||||
version: number;
|
||||
flags: number;
|
||||
method: number;
|
||||
time: Date;
|
||||
crc: number;
|
||||
compressedSize: number;
|
||||
size: number;
|
||||
fileNameLength: number;
|
||||
extraLength: number;
|
||||
commentLength: number;
|
||||
diskNumStart: number;
|
||||
inAttr: number;
|
||||
attr: number;
|
||||
offset: number;
|
||||
readonly encripted: boolean;
|
||||
readonly entryHeaderSize: number;
|
||||
readonly realDataOffset: number;
|
||||
readonly dataHeader: DataHeader;
|
||||
loadDataHeaderFromBinary(data: Buffer): void;
|
||||
loadFromBinary(data: Buffer): void;
|
||||
dataHeaderToBinary(): Buffer;
|
||||
entryHeaderToBinary(): Buffer;
|
||||
toString(): string;
|
||||
}
|
||||
|
||||
interface DataHeader {
|
||||
version: number;
|
||||
flags: number;
|
||||
method: number;
|
||||
time: number;
|
||||
crc: number;
|
||||
compressedSize: number;
|
||||
size: number;
|
||||
fnameLen: number;
|
||||
extraLen: number;
|
||||
}
|
||||
|
||||
interface InitOptions {
|
||||
/* If true it disables files sorting */
|
||||
noSort: boolean;
|
||||
/* Read entries during load (initial loading may be slower) */
|
||||
readEntries: boolean;
|
||||
/* Read method */
|
||||
method: typeof Constants[keyof typeof Constants] | number;
|
||||
/* file system */
|
||||
fs: null | typeof FS;
|
||||
}
|
||||
}
|
||||
|
||||
export = AdmZip;
|
||||
47
node_modules/@types/adm-zip/package.json
generated
vendored
Executable file
47
node_modules/@types/adm-zip/package.json
generated
vendored
Executable file
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"name": "@types/adm-zip",
|
||||
"version": "0.5.0",
|
||||
"description": "TypeScript definitions for adm-zip",
|
||||
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/adm-zip",
|
||||
"license": "MIT",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "John Vilk",
|
||||
"url": "https://github.com/jvilk",
|
||||
"githubUsername": "jvilk"
|
||||
},
|
||||
{
|
||||
"name": "Abner Oliveira",
|
||||
"url": "https://github.com/abner",
|
||||
"githubUsername": "abner"
|
||||
},
|
||||
{
|
||||
"name": "BendingBender",
|
||||
"url": "https://github.com/BendingBender",
|
||||
"githubUsername": "BendingBender"
|
||||
},
|
||||
{
|
||||
"name": "Matthew Sainsbury",
|
||||
"url": "https://github.com/mattsains",
|
||||
"githubUsername": "mattsains"
|
||||
},
|
||||
{
|
||||
"name": "Lei Nelissen",
|
||||
"url": "https://github.com/LeiNelissen",
|
||||
"githubUsername": "LeiNelissen"
|
||||
}
|
||||
],
|
||||
"main": "",
|
||||
"types": "index.d.ts",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
||||
"directory": "types/adm-zip"
|
||||
},
|
||||
"scripts": {},
|
||||
"dependencies": {
|
||||
"@types/node": "*"
|
||||
},
|
||||
"typesPublisherContentHash": "e7f9407982926b4743453eb7e13bc93b66f3e599200f0d101fe305016af41e50",
|
||||
"typeScriptVersion": "3.9"
|
||||
}
|
||||
142
node_modules/@types/adm-zip/util.d.ts
generated
vendored
Executable file
142
node_modules/@types/adm-zip/util.d.ts
generated
vendored
Executable file
@@ -0,0 +1,142 @@
|
||||
export const Constants: {
|
||||
/* The local file header */
|
||||
LOCHDR: 30; // LOC header size
|
||||
LOCSIG: 0x04034b50; // "PK\003\004"
|
||||
LOCVER: 4; // version needed to extract
|
||||
LOCFLG: 6; // general purpose bit flag
|
||||
LOCHOW: 8; // compression method
|
||||
LOCTIM: 10; // modification time (2 bytes time, 2 bytes date)
|
||||
LOCCRC: 14; // uncompressed file crc-32 value
|
||||
LOCSIZ: 18; // compressed size
|
||||
LOCLEN: 22; // uncompressed size
|
||||
LOCNAM: 26; // filename length
|
||||
LOCEXT: 28; // extra field length
|
||||
|
||||
/* The Data descriptor */
|
||||
EXTSIG: 0x08074b50; // "PK\007\008"
|
||||
EXTHDR: 16; // EXT header size
|
||||
EXTCRC: 4; // uncompressed file crc-32 value
|
||||
EXTSIZ: 8; // compressed size
|
||||
EXTLEN: 12; // uncompressed size
|
||||
|
||||
/* The central directory file header */
|
||||
CENHDR: 46; // CEN header size
|
||||
CENSIG: 0x02014b50; // "PK\001\002"
|
||||
CENVEM: 4; // version made by
|
||||
CENVER: 6; // version needed to extract
|
||||
CENFLG: 8; // encrypt, decrypt flags
|
||||
CENHOW: 10; // compression method
|
||||
CENTIM: 12; // modification time (2 bytes time, 2 bytes date)
|
||||
CENCRC: 16; // uncompressed file crc-32 value
|
||||
CENSIZ: 20; // compressed size
|
||||
CENLEN: 24; // uncompressed size
|
||||
CENNAM: 28; // filename length
|
||||
CENEXT: 30; // extra field length
|
||||
CENCOM: 32; // file comment length
|
||||
CENDSK: 34; // volume number start
|
||||
CENATT: 36; // internal file attributes
|
||||
CENATX: 38; // external file attributes (host system dependent)
|
||||
CENOFF: 42; // LOC header offset
|
||||
|
||||
/* The entries in the end of central directory */
|
||||
ENDHDR: 22; // END header size
|
||||
ENDSIG: 0x06054b50; // "PK\005\006"
|
||||
ENDSUB: 8; // number of entries on this disk
|
||||
ENDTOT: 10; // total number of entries
|
||||
ENDSIZ: 12; // central directory size in bytes
|
||||
ENDOFF: 16; // offset of first CEN header
|
||||
ENDCOM: 20; // zip file comment length
|
||||
|
||||
END64HDR: 20; // zip64 END header size
|
||||
END64SIG: 0x07064b50; // zip64 Locator signature, "PK\006\007"
|
||||
END64START: 4; // number of the disk with the start of the zip64
|
||||
END64OFF: 8; // relative offset of the zip64 end of central directory
|
||||
END64NUMDISKS: 16; // total number of disks
|
||||
|
||||
ZIP64SIG: 0x06064b50; // zip64 signature, "PK\006\006"
|
||||
ZIP64HDR: 56; // zip64 record minimum size
|
||||
ZIP64LEAD: 12; // leading bytes at the start of the record, not counted by the value stored in ZIP64SIZE
|
||||
ZIP64SIZE: 4; // zip64 size of the central directory record
|
||||
ZIP64VEM: 12; // zip64 version made by
|
||||
ZIP64VER: 14; // zip64 version needed to extract
|
||||
ZIP64DSK: 16; // zip64 number of this disk
|
||||
ZIP64DSKDIR: 20; // number of the disk with the start of the record directory
|
||||
ZIP64SUB: 24; // number of entries on this disk
|
||||
ZIP64TOT: 32; // total number of entries
|
||||
ZIP64SIZB: 40; // zip64 central directory size in bytes
|
||||
ZIP64OFF: 48; // offset of start of central directory with respect to the starting disk number
|
||||
ZIP64EXTRA: 56; // extensible data sector
|
||||
|
||||
/* Compression methods */
|
||||
STORED: 0; // no compression
|
||||
SHRUNK: 1; // shrunk
|
||||
REDUCED1: 2; // reduced with compression factor 1
|
||||
REDUCED2: 3; // reduced with compression factor 2
|
||||
REDUCED3: 4; // reduced with compression factor 3
|
||||
REDUCED4: 5; // reduced with compression factor 4
|
||||
IMPLODED: 6; // imploded
|
||||
// 7 reserved for Tokenizing compression algorithm
|
||||
DEFLATED: 8; // deflated
|
||||
ENHANCED_DEFLATED: 9; // enhanced deflated
|
||||
PKWARE: 10; // PKWare DCL imploded
|
||||
// 11 reserved by PKWARE
|
||||
BZIP2: 12; // compressed using BZIP2
|
||||
// 13 reserved by PKWARE
|
||||
LZMA: 14; // LZMA
|
||||
// 15-17 reserved by PKWARE
|
||||
IBM_TERSE: 18; // compressed using IBM TERSE
|
||||
IBM_LZ77: 19; // IBM LZ77 z
|
||||
AES_ENCRYPT: 99; // WinZIP AES encryption method
|
||||
|
||||
/* General purpose bit flag */
|
||||
// values can obtained with expression 2**bitnr
|
||||
FLG_ENC: 1; // Bit 0: encrypted file
|
||||
FLG_COMP1: 2; // Bit 1, compression option
|
||||
FLG_COMP2: 4; // Bit 2, compression option
|
||||
FLG_DESC: 8; // Bit 3, data descriptor
|
||||
FLG_ENH: 16; // Bit 4, enhanced deflating
|
||||
FLG_PATCH: 32; // Bit 5, indicates that the file is compressed patched data.
|
||||
FLG_STR: 64; // Bit 6, strong encryption (patented)
|
||||
// Bits 7-10: Currently unused.
|
||||
FLG_EFS: 2048; // Bit 11: Language encoding flag (EFS)
|
||||
// Bit 12: Reserved by PKWARE for enhanced compression.
|
||||
// Bit 13: encrypted the Central Directory (patented).
|
||||
// Bits 14-15: Reserved by PKWARE.
|
||||
FLG_MSK: 4096; // mask header values
|
||||
|
||||
/* Load type */
|
||||
FILE: 2;
|
||||
BUFFER: 1;
|
||||
NONE: 0;
|
||||
|
||||
/* 4.5 Extensible data fields */
|
||||
EF_ID: 0;
|
||||
EF_SIZE: 2;
|
||||
|
||||
/* Header IDs */
|
||||
ID_ZIP64: 0x0001;
|
||||
ID_AVINFO: 0x0007;
|
||||
ID_PFS: 0x0008;
|
||||
ID_OS2: 0x0009;
|
||||
ID_NTFS: 0x000a;
|
||||
ID_OPENVMS: 0x000c;
|
||||
ID_UNIX: 0x000d;
|
||||
ID_FORK: 0x000e;
|
||||
ID_PATCH: 0x000f;
|
||||
ID_X509_PKCS7: 0x0014;
|
||||
ID_X509_CERTID_F: 0x0015;
|
||||
ID_X509_CERTID_C: 0x0016;
|
||||
ID_STRONGENC: 0x0017;
|
||||
ID_RECORD_MGT: 0x0018;
|
||||
ID_X509_PKCS7_RL: 0x0019;
|
||||
ID_IBM1: 0x0065;
|
||||
ID_IBM2: 0x0066;
|
||||
ID_POSZIP: 0x4690;
|
||||
|
||||
EF_ZIP64_OR_32: 0xffffffff;
|
||||
EF_ZIP64_OR_16: 0xffff;
|
||||
EF_ZIP64_SUNCOMP: 0;
|
||||
EF_ZIP64_SCOMP: 8;
|
||||
EF_ZIP64_RHO: 16;
|
||||
EF_ZIP64_DSN: 24;
|
||||
};
|
||||
21
node_modules/@types/js-yaml/LICENSE
generated
vendored
Executable file
21
node_modules/@types/js-yaml/LICENSE
generated
vendored
Executable file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
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
|
||||
16
node_modules/@types/js-yaml/README.md
generated
vendored
Executable file
16
node_modules/@types/js-yaml/README.md
generated
vendored
Executable file
@@ -0,0 +1,16 @@
|
||||
# Installation
|
||||
> `npm install --save @types/js-yaml`
|
||||
|
||||
# Summary
|
||||
This package contains type definitions for js-yaml (https://github.com/nodeca/js-yaml).
|
||||
|
||||
# Details
|
||||
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/js-yaml.
|
||||
|
||||
### Additional Details
|
||||
* Last updated: Fri, 19 Nov 2021 18:01:12 GMT
|
||||
* Dependencies: none
|
||||
* Global values: `jsyaml`
|
||||
|
||||
# Credits
|
||||
These definitions were written by [Bart van der Schoor](https://github.com/Bartvds), [Sebastian Clausen](https://github.com/sclausen), [ExE Boss](https://github.com/ExE-Boss), [Armaan Tobaccowalla](https://github.com/ArmaanT), and [Linus Unnebäck](https://github.com/LinusU).
|
||||
2
node_modules/@types/js-yaml/index.d.mts
generated
vendored
Executable file
2
node_modules/@types/js-yaml/index.d.mts
generated
vendored
Executable file
@@ -0,0 +1,2 @@
|
||||
export * from "./index.js";
|
||||
export { default } from "./index.js";
|
||||
154
node_modules/@types/js-yaml/index.d.ts
generated
vendored
Executable file
154
node_modules/@types/js-yaml/index.d.ts
generated
vendored
Executable file
@@ -0,0 +1,154 @@
|
||||
// Type definitions for js-yaml 4.0
|
||||
// Project: https://github.com/nodeca/js-yaml
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
||||
// Sebastian Clausen <https://github.com/sclausen>
|
||||
// ExE Boss <https://github.com/ExE-Boss>
|
||||
// Armaan Tobaccowalla <https://github.com/ArmaanT>
|
||||
// Linus Unnebäck <https://github.com/LinusU>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
export as namespace jsyaml;
|
||||
|
||||
export function load(str: string, opts?: LoadOptions): unknown;
|
||||
|
||||
export class Type {
|
||||
constructor(tag: string, opts?: TypeConstructorOptions);
|
||||
kind: 'sequence' | 'scalar' | 'mapping' | null;
|
||||
resolve(data: any): boolean;
|
||||
construct(data: any, type?: string): any;
|
||||
instanceOf: object | null;
|
||||
predicate: ((data: object) => boolean) | null;
|
||||
represent: ((data: object) => any) | { [x: string]: (data: object) => any } | null;
|
||||
representName: ((data: object) => any) | null;
|
||||
defaultStyle: string | null;
|
||||
multi: boolean;
|
||||
styleAliases: { [x: string]: any };
|
||||
}
|
||||
|
||||
export class Schema {
|
||||
constructor(definition: SchemaDefinition | Type[] | Type);
|
||||
extend(types: SchemaDefinition | Type[] | Type): Schema;
|
||||
}
|
||||
|
||||
export function loadAll(str: string, iterator?: null, opts?: LoadOptions): unknown[];
|
||||
export function loadAll(str: string, iterator: (doc: unknown) => void, opts?: LoadOptions): void;
|
||||
|
||||
export function dump(obj: any, opts?: DumpOptions): string;
|
||||
|
||||
export interface LoadOptions {
|
||||
/** string to be used as a file path in error/warning messages. */
|
||||
filename?: string | undefined;
|
||||
/** function to call on warning messages. */
|
||||
onWarning?(this: null, e: YAMLException): void;
|
||||
/** specifies a schema to use. */
|
||||
schema?: Schema | undefined;
|
||||
/** compatibility with JSON.parse behaviour. */
|
||||
json?: boolean | undefined;
|
||||
/** listener for parse events */
|
||||
listener?(this: State, eventType: EventType, state: State): void;
|
||||
}
|
||||
|
||||
export type EventType = 'open' | 'close';
|
||||
|
||||
export interface State {
|
||||
input: string;
|
||||
filename: string | null;
|
||||
schema: Schema;
|
||||
onWarning: (this: null, e: YAMLException) => void;
|
||||
json: boolean;
|
||||
length: number;
|
||||
position: number;
|
||||
line: number;
|
||||
lineStart: number;
|
||||
lineIndent: number;
|
||||
version: null | number;
|
||||
checkLineBreaks: boolean;
|
||||
kind: string;
|
||||
result: any;
|
||||
implicitTypes: Type[];
|
||||
}
|
||||
|
||||
export interface DumpOptions {
|
||||
/** indentation width to use (in spaces). */
|
||||
indent?: number | undefined;
|
||||
/** when true, will not add an indentation level to array elements */
|
||||
noArrayIndent?: boolean | undefined;
|
||||
/** do not throw on invalid types (like function in the safe schema) and skip pairs and single values with such types. */
|
||||
skipInvalid?: boolean | undefined;
|
||||
/** specifies level of nesting, when to switch from block to flow style for collections. -1 means block style everwhere */
|
||||
flowLevel?: number | undefined;
|
||||
/** Each tag may have own set of styles. - "tag" => "style" map. */
|
||||
styles?: { [x: string]: any } | undefined;
|
||||
/** specifies a schema to use. */
|
||||
schema?: Schema | undefined;
|
||||
/** if true, sort keys when dumping YAML. If a function, use the function to sort the keys. (default: false) */
|
||||
sortKeys?: boolean | ((a: any, b: any) => number) | undefined;
|
||||
/** set max line width. (default: 80) */
|
||||
lineWidth?: number | undefined;
|
||||
/** if true, don't convert duplicate objects into references (default: false) */
|
||||
noRefs?: boolean | undefined;
|
||||
/** if true don't try to be compatible with older yaml versions. Currently: don't quote "yes", "no" and so on, as required for YAML 1.1 (default: false) */
|
||||
noCompatMode?: boolean | undefined;
|
||||
/**
|
||||
* if true flow sequences will be condensed, omitting the space between `key: value` or `a, b`. Eg. `'[a,b]'` or `{a:{b:c}}`.
|
||||
* Can be useful when using yaml for pretty URL query params as spaces are %-encoded. (default: false).
|
||||
*/
|
||||
condenseFlow?: boolean | undefined;
|
||||
/** strings will be quoted using this quoting style. If you specify single quotes, double quotes will still be used for non-printable characters. (default: `'`) */
|
||||
quotingType?: "'" | '"' | undefined;
|
||||
/** if true, all non-key strings will be quoted even if they normally don't need to. (default: false) */
|
||||
forceQuotes?: boolean | undefined;
|
||||
/** callback `function (key, value)` called recursively on each key/value in source object (see `replacer` docs for `JSON.stringify`). */
|
||||
replacer?: ((key: string, value: any) => any) | undefined;
|
||||
}
|
||||
|
||||
export interface TypeConstructorOptions {
|
||||
kind?: 'sequence' | 'scalar' | 'mapping' | undefined;
|
||||
resolve?: ((data: any) => boolean) | undefined;
|
||||
construct?: ((data: any, type?: string) => any) | undefined;
|
||||
instanceOf?: object | undefined;
|
||||
predicate?: ((data: object) => boolean) | undefined;
|
||||
represent?: ((data: object) => any) | { [x: string]: (data: object) => any } | undefined;
|
||||
representName?: ((data: object) => any) | undefined;
|
||||
defaultStyle?: string | undefined;
|
||||
multi?: boolean | undefined;
|
||||
styleAliases?: { [x: string]: any } | undefined;
|
||||
}
|
||||
|
||||
export interface SchemaDefinition {
|
||||
implicit?: Type[] | undefined;
|
||||
explicit?: Type[] | undefined;
|
||||
}
|
||||
|
||||
/** only strings, arrays and plain objects: http://www.yaml.org/spec/1.2/spec.html#id2802346 */
|
||||
export let FAILSAFE_SCHEMA: Schema;
|
||||
/** only strings, arrays and plain objects: http://www.yaml.org/spec/1.2/spec.html#id2802346 */
|
||||
export let JSON_SCHEMA: Schema;
|
||||
/** same as JSON_SCHEMA: http://www.yaml.org/spec/1.2/spec.html#id2804923 */
|
||||
export let CORE_SCHEMA: Schema;
|
||||
/** all supported YAML types */
|
||||
export let DEFAULT_SCHEMA: Schema;
|
||||
|
||||
export interface Mark {
|
||||
buffer: string;
|
||||
column: number;
|
||||
line: number;
|
||||
name: string;
|
||||
position: number;
|
||||
snippet: string;
|
||||
}
|
||||
|
||||
export class YAMLException extends Error {
|
||||
constructor(reason?: string, mark?: Mark);
|
||||
|
||||
toString(compact?: boolean): string;
|
||||
|
||||
name: string;
|
||||
|
||||
reason: string;
|
||||
|
||||
message: string;
|
||||
|
||||
mark: Mark;
|
||||
}
|
||||
53
node_modules/@types/js-yaml/package.json
generated
vendored
Executable file
53
node_modules/@types/js-yaml/package.json
generated
vendored
Executable file
@@ -0,0 +1,53 @@
|
||||
{
|
||||
"name": "@types/js-yaml",
|
||||
"version": "4.0.5",
|
||||
"description": "TypeScript definitions for js-yaml",
|
||||
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/js-yaml",
|
||||
"license": "MIT",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Bart van der Schoor",
|
||||
"url": "https://github.com/Bartvds",
|
||||
"githubUsername": "Bartvds"
|
||||
},
|
||||
{
|
||||
"name": "Sebastian Clausen",
|
||||
"url": "https://github.com/sclausen",
|
||||
"githubUsername": "sclausen"
|
||||
},
|
||||
{
|
||||
"name": "ExE Boss",
|
||||
"url": "https://github.com/ExE-Boss",
|
||||
"githubUsername": "ExE-Boss"
|
||||
},
|
||||
{
|
||||
"name": "Armaan Tobaccowalla",
|
||||
"url": "https://github.com/ArmaanT",
|
||||
"githubUsername": "ArmaanT"
|
||||
},
|
||||
{
|
||||
"name": "Linus Unnebäck",
|
||||
"url": "https://github.com/LinusU",
|
||||
"githubUsername": "LinusU"
|
||||
}
|
||||
],
|
||||
"main": "",
|
||||
"types": "index.d.ts",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
||||
"directory": "types/js-yaml"
|
||||
},
|
||||
"scripts": {},
|
||||
"dependencies": {},
|
||||
"typesPublisherContentHash": "6f40877154edac83ffa22d53a6aca74f151a0d094074c81ce7fb21df57ea5725",
|
||||
"typeScriptVersion": "3.8",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": {
|
||||
"import": "./index.d.mts",
|
||||
"default": "./index.d.ts"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
21
node_modules/adm-zip/LICENSE
generated
vendored
Normal file
21
node_modules/adm-zip/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2012 Another-D-Mention Software and other contributors
|
||||
|
||||
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.
|
||||
65
node_modules/adm-zip/README.md
generated
vendored
Normal file
65
node_modules/adm-zip/README.md
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
# ADM-ZIP for NodeJS with added support for electron original-fs
|
||||
|
||||
ADM-ZIP is a pure JavaScript implementation for zip data compression for [NodeJS](https://nodejs.org/).
|
||||
|
||||
# Installation
|
||||
|
||||
With [npm](https://www.npmjs.com/) do:
|
||||
|
||||
$ npm install adm-zip
|
||||
|
||||
## What is it good for?
|
||||
|
||||
The library allows you to:
|
||||
|
||||
- decompress zip files directly to disk or in memory buffers
|
||||
- compress files and store them to disk in .zip format or in compressed buffers
|
||||
- update content of/add new/delete files from an existing .zip
|
||||
|
||||
# Dependencies
|
||||
|
||||
There are no other nodeJS libraries that ADM-ZIP is dependent of
|
||||
|
||||
# Examples
|
||||
|
||||
## Basic usage
|
||||
|
||||
```javascript
|
||||
var AdmZip = require("adm-zip");
|
||||
|
||||
// reading archives
|
||||
var zip = new AdmZip("./my_file.zip");
|
||||
var zipEntries = zip.getEntries(); // an array of ZipEntry records
|
||||
|
||||
zipEntries.forEach(function (zipEntry) {
|
||||
console.log(zipEntry.toString()); // outputs zip entries information
|
||||
if (zipEntry.entryName == "my_file.txt") {
|
||||
console.log(zipEntry.getData().toString("utf8"));
|
||||
}
|
||||
});
|
||||
// outputs the content of some_folder/my_file.txt
|
||||
console.log(zip.readAsText("some_folder/my_file.txt"));
|
||||
// extracts the specified file to the specified location
|
||||
zip.extractEntryTo(/*entry name*/ "some_folder/my_file.txt", /*target path*/ "/home/me/tempfolder", /*maintainEntryPath*/ false, /*overwrite*/ true);
|
||||
// extracts everything
|
||||
zip.extractAllTo(/*target path*/ "/home/me/zipcontent/", /*overwrite*/ true);
|
||||
|
||||
// creating archives
|
||||
var zip = new AdmZip();
|
||||
|
||||
// add file directly
|
||||
var content = "inner content of the file";
|
||||
zip.addFile("test.txt", Buffer.from(content, "utf8"), "entry comment goes here");
|
||||
// add local file
|
||||
zip.addLocalFile("/home/me/some_picture.png");
|
||||
// get everything as a buffer
|
||||
var willSendthis = zip.toBuffer();
|
||||
// or write everything to disk
|
||||
zip.writeZip(/*target file name*/ "/home/me/files.zip");
|
||||
|
||||
// ... more examples in the wiki
|
||||
```
|
||||
|
||||
For more detailed information please check out the [wiki](https://github.com/cthackers/adm-zip/wiki).
|
||||
|
||||
[](https://travis-ci.org/cthackers/adm-zip)
|
||||
783
node_modules/adm-zip/adm-zip.js
generated
vendored
Normal file
783
node_modules/adm-zip/adm-zip.js
generated
vendored
Normal file
@@ -0,0 +1,783 @@
|
||||
const Utils = require("./util");
|
||||
const pth = require("path");
|
||||
const ZipEntry = require("./zipEntry");
|
||||
const ZipFile = require("./zipFile");
|
||||
|
||||
const get_Bool = (val, def) => (typeof val === "boolean" ? val : def);
|
||||
const get_Str = (val, def) => (typeof val === "string" ? val : def);
|
||||
|
||||
const defaultOptions = {
|
||||
// option "noSort" : if true it disables files sorting
|
||||
noSort: false,
|
||||
// read entries during load (initial loading may be slower)
|
||||
readEntries: false,
|
||||
// default method is none
|
||||
method: Utils.Constants.NONE,
|
||||
// file system
|
||||
fs: null
|
||||
};
|
||||
|
||||
module.exports = function (/**String*/ input, /** object */ options) {
|
||||
let inBuffer = null;
|
||||
|
||||
// create object based default options, allowing them to be overwritten
|
||||
const opts = Object.assign(Object.create(null), defaultOptions);
|
||||
|
||||
// test input variable
|
||||
if (input && "object" === typeof input) {
|
||||
// if value is not buffer we accept it to be object with options
|
||||
if (!(input instanceof Uint8Array)) {
|
||||
Object.assign(opts, input);
|
||||
input = opts.input ? opts.input : undefined;
|
||||
if (opts.input) delete opts.input;
|
||||
}
|
||||
|
||||
// if input is buffer
|
||||
if (Buffer.isBuffer(input)) {
|
||||
inBuffer = input;
|
||||
opts.method = Utils.Constants.BUFFER;
|
||||
input = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
// assign options
|
||||
Object.assign(opts, options);
|
||||
|
||||
// instanciate utils filesystem
|
||||
const filetools = new Utils(opts);
|
||||
|
||||
// if input is file name we retrieve its content
|
||||
if (input && "string" === typeof input) {
|
||||
// load zip file
|
||||
if (filetools.fs.existsSync(input)) {
|
||||
opts.method = Utils.Constants.FILE;
|
||||
opts.filename = input;
|
||||
inBuffer = filetools.fs.readFileSync(input);
|
||||
} else {
|
||||
throw new Error(Utils.Errors.INVALID_FILENAME);
|
||||
}
|
||||
}
|
||||
|
||||
// create variable
|
||||
const _zip = new ZipFile(inBuffer, opts);
|
||||
|
||||
const { canonical, sanitize } = Utils;
|
||||
|
||||
function getEntry(/**Object*/ entry) {
|
||||
if (entry && _zip) {
|
||||
var item;
|
||||
// If entry was given as a file name
|
||||
if (typeof entry === "string") item = _zip.getEntry(entry);
|
||||
// if entry was given as a ZipEntry object
|
||||
if (typeof entry === "object" && typeof entry.entryName !== "undefined" && typeof entry.header !== "undefined") item = _zip.getEntry(entry.entryName);
|
||||
|
||||
if (item) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function fixPath(zipPath) {
|
||||
const { join, normalize, sep } = pth.posix;
|
||||
// convert windows file separators and normalize
|
||||
return join(".", normalize(sep + zipPath.split("\\").join(sep) + sep));
|
||||
}
|
||||
|
||||
return {
|
||||
/**
|
||||
* Extracts the given entry from the archive and returns the content as a Buffer object
|
||||
* @param entry ZipEntry object or String with the full path of the entry
|
||||
*
|
||||
* @return Buffer or Null in case of error
|
||||
*/
|
||||
readFile: function (/**Object*/ entry, /*String, Buffer*/ pass) {
|
||||
var item = getEntry(entry);
|
||||
return (item && item.getData(pass)) || null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Asynchronous readFile
|
||||
* @param entry ZipEntry object or String with the full path of the entry
|
||||
* @param callback
|
||||
*
|
||||
* @return Buffer or Null in case of error
|
||||
*/
|
||||
readFileAsync: function (/**Object*/ entry, /**Function*/ callback) {
|
||||
var item = getEntry(entry);
|
||||
if (item) {
|
||||
item.getDataAsync(callback);
|
||||
} else {
|
||||
callback(null, "getEntry failed for:" + entry);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Extracts the given entry from the archive and returns the content as plain text in the given encoding
|
||||
* @param entry ZipEntry object or String with the full path of the entry
|
||||
* @param encoding Optional. If no encoding is specified utf8 is used
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
readAsText: function (/**Object*/ entry, /**String=*/ encoding) {
|
||||
var item = getEntry(entry);
|
||||
if (item) {
|
||||
var data = item.getData();
|
||||
if (data && data.length) {
|
||||
return data.toString(encoding || "utf8");
|
||||
}
|
||||
}
|
||||
return "";
|
||||
},
|
||||
|
||||
/**
|
||||
* Asynchronous readAsText
|
||||
* @param entry ZipEntry object or String with the full path of the entry
|
||||
* @param callback
|
||||
* @param encoding Optional. If no encoding is specified utf8 is used
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
readAsTextAsync: function (/**Object*/ entry, /**Function*/ callback, /**String=*/ encoding) {
|
||||
var item = getEntry(entry);
|
||||
if (item) {
|
||||
item.getDataAsync(function (data, err) {
|
||||
if (err) {
|
||||
callback(data, err);
|
||||
return;
|
||||
}
|
||||
|
||||
if (data && data.length) {
|
||||
callback(data.toString(encoding || "utf8"));
|
||||
} else {
|
||||
callback("");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
callback("");
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Remove the entry from the file or the entry and all it's nested directories and files if the given entry is a directory
|
||||
*
|
||||
* @param entry
|
||||
*/
|
||||
deleteFile: function (/**Object*/ entry) {
|
||||
// @TODO: test deleteFile
|
||||
var item = getEntry(entry);
|
||||
if (item) {
|
||||
_zip.deleteEntry(item.entryName);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds a comment to the zip. The zip must be rewritten after adding the comment.
|
||||
*
|
||||
* @param comment
|
||||
*/
|
||||
addZipComment: function (/**String*/ comment) {
|
||||
// @TODO: test addZipComment
|
||||
_zip.comment = comment;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the zip comment
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
getZipComment: function () {
|
||||
return _zip.comment || "";
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds a comment to a specified zipEntry. The zip must be rewritten after adding the comment
|
||||
* The comment cannot exceed 65535 characters in length
|
||||
*
|
||||
* @param entry
|
||||
* @param comment
|
||||
*/
|
||||
addZipEntryComment: function (/**Object*/ entry, /**String*/ comment) {
|
||||
var item = getEntry(entry);
|
||||
if (item) {
|
||||
item.comment = comment;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the comment of the specified entry
|
||||
*
|
||||
* @param entry
|
||||
* @return String
|
||||
*/
|
||||
getZipEntryComment: function (/**Object*/ entry) {
|
||||
var item = getEntry(entry);
|
||||
if (item) {
|
||||
return item.comment || "";
|
||||
}
|
||||
return "";
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates the content of an existing entry inside the archive. The zip must be rewritten after updating the content
|
||||
*
|
||||
* @param entry
|
||||
* @param content
|
||||
*/
|
||||
updateFile: function (/**Object*/ entry, /**Buffer*/ content) {
|
||||
var item = getEntry(entry);
|
||||
if (item) {
|
||||
item.setData(content);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds a file from the disk to the archive
|
||||
*
|
||||
* @param localPath File to add to zip
|
||||
* @param zipPath Optional path inside the zip
|
||||
* @param zipName Optional name for the file
|
||||
*/
|
||||
addLocalFile: function (/**String*/ localPath, /**String=*/ zipPath, /**String=*/ zipName, /**String*/ comment) {
|
||||
if (filetools.fs.existsSync(localPath)) {
|
||||
// fix ZipPath
|
||||
zipPath = zipPath ? fixPath(zipPath) : "";
|
||||
|
||||
// p - local file name
|
||||
var p = localPath.split("\\").join("/").split("/").pop();
|
||||
|
||||
// add file name into zippath
|
||||
zipPath += zipName ? zipName : p;
|
||||
|
||||
// read file attributes
|
||||
const _attr = filetools.fs.statSync(localPath);
|
||||
|
||||
// add file into zip file
|
||||
this.addFile(zipPath, filetools.fs.readFileSync(localPath), comment, _attr);
|
||||
} else {
|
||||
throw new Error(Utils.Errors.FILE_NOT_FOUND.replace("%s", localPath));
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds a local directory and all its nested files and directories to the archive
|
||||
*
|
||||
* @param localPath
|
||||
* @param zipPath optional path inside zip
|
||||
* @param filter optional RegExp or Function if files match will
|
||||
* be included.
|
||||
*/
|
||||
addLocalFolder: function (/**String*/ localPath, /**String=*/ zipPath, /**=RegExp|Function*/ filter) {
|
||||
// Prepare filter
|
||||
if (filter instanceof RegExp) {
|
||||
// if filter is RegExp wrap it
|
||||
filter = (function (rx) {
|
||||
return function (filename) {
|
||||
return rx.test(filename);
|
||||
};
|
||||
})(filter);
|
||||
} else if ("function" !== typeof filter) {
|
||||
// if filter is not function we will replace it
|
||||
filter = function () {
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
// fix ZipPath
|
||||
zipPath = zipPath ? fixPath(zipPath) : "";
|
||||
|
||||
// normalize the path first
|
||||
localPath = pth.normalize(localPath);
|
||||
|
||||
if (filetools.fs.existsSync(localPath)) {
|
||||
const items = filetools.findFiles(localPath);
|
||||
const self = this;
|
||||
|
||||
if (items.length) {
|
||||
items.forEach(function (filepath) {
|
||||
var p = pth.relative(localPath, filepath).split("\\").join("/"); //windows fix
|
||||
if (filter(p)) {
|
||||
var stats = filetools.fs.statSync(filepath);
|
||||
if (stats.isFile()) {
|
||||
self.addFile(zipPath + p, filetools.fs.readFileSync(filepath), "", stats);
|
||||
} else {
|
||||
self.addFile(zipPath + p + "/", Buffer.alloc(0), "", stats);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
throw new Error(Utils.Errors.FILE_NOT_FOUND.replace("%s", localPath));
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Asynchronous addLocalFile
|
||||
* @param localPath
|
||||
* @param callback
|
||||
* @param zipPath optional path inside zip
|
||||
* @param filter optional RegExp or Function if files match will
|
||||
* be included.
|
||||
*/
|
||||
addLocalFolderAsync: function (/*String*/ localPath, /*Function*/ callback, /*String*/ zipPath, /*RegExp|Function*/ filter) {
|
||||
if (filter instanceof RegExp) {
|
||||
filter = (function (rx) {
|
||||
return function (filename) {
|
||||
return rx.test(filename);
|
||||
};
|
||||
})(filter);
|
||||
} else if ("function" !== typeof filter) {
|
||||
filter = function () {
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
// fix ZipPath
|
||||
zipPath = zipPath ? fixPath(zipPath) : "";
|
||||
|
||||
// normalize the path first
|
||||
localPath = pth.normalize(localPath);
|
||||
|
||||
var self = this;
|
||||
filetools.fs.open(localPath, "r", function (err) {
|
||||
if (err && err.code === "ENOENT") {
|
||||
callback(undefined, Utils.Errors.FILE_NOT_FOUND.replace("%s", localPath));
|
||||
} else if (err) {
|
||||
callback(undefined, err);
|
||||
} else {
|
||||
var items = filetools.findFiles(localPath);
|
||||
var i = -1;
|
||||
|
||||
var next = function () {
|
||||
i += 1;
|
||||
if (i < items.length) {
|
||||
var filepath = items[i];
|
||||
var p = pth.relative(localPath, filepath).split("\\").join("/"); //windows fix
|
||||
p = p
|
||||
.normalize("NFD")
|
||||
.replace(/[\u0300-\u036f]/g, "")
|
||||
.replace(/[^\x20-\x7E]/g, ""); // accent fix
|
||||
if (filter(p)) {
|
||||
filetools.fs.stat(filepath, function (er0, stats) {
|
||||
if (er0) callback(undefined, er0);
|
||||
if (stats.isFile()) {
|
||||
filetools.fs.readFile(filepath, function (er1, data) {
|
||||
if (er1) {
|
||||
callback(undefined, er1);
|
||||
} else {
|
||||
self.addFile(zipPath + p, data, "", stats);
|
||||
next();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
self.addFile(zipPath + p + "/", Buffer.alloc(0), "", stats);
|
||||
next();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
} else {
|
||||
callback(true, undefined);
|
||||
}
|
||||
};
|
||||
|
||||
next();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} localPath - path where files will be extracted
|
||||
* @param {object} props - optional properties
|
||||
* @param {string} props.zipPath - optional path inside zip
|
||||
* @param {regexp, function} props.filter - RegExp or Function if files match will be included.
|
||||
*/
|
||||
addLocalFolderPromise: function (/*String*/ localPath, /* object */ props) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const { filter, zipPath } = Object.assign({}, props);
|
||||
this.addLocalFolderAsync(
|
||||
localPath,
|
||||
(done, err) => {
|
||||
if (err) reject(err);
|
||||
if (done) resolve(this);
|
||||
},
|
||||
zipPath,
|
||||
filter
|
||||
);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Allows you to create a entry (file or directory) in the zip file.
|
||||
* If you want to create a directory the entryName must end in / and a null buffer should be provided.
|
||||
* Comment and attributes are optional
|
||||
*
|
||||
* @param {string} entryName
|
||||
* @param {Buffer | string} content - file content as buffer or utf8 coded string
|
||||
* @param {string} comment - file comment
|
||||
* @param {number | object} attr - number as unix file permissions, object as filesystem Stats object
|
||||
*/
|
||||
addFile: function (/**String*/ entryName, /**Buffer*/ content, /**String*/ comment, /**Number*/ attr) {
|
||||
let entry = getEntry(entryName);
|
||||
const update = entry != null;
|
||||
|
||||
// prepare new entry
|
||||
if (!update) {
|
||||
entry = new ZipEntry();
|
||||
entry.entryName = entryName;
|
||||
}
|
||||
entry.comment = comment || "";
|
||||
|
||||
const isStat = "object" === typeof attr && attr instanceof filetools.fs.Stats;
|
||||
|
||||
// last modification time from file stats
|
||||
if (isStat) {
|
||||
entry.header.time = attr.mtime;
|
||||
}
|
||||
|
||||
// Set file attribute
|
||||
var fileattr = entry.isDirectory ? 0x10 : 0; // (MS-DOS directory flag)
|
||||
|
||||
// extended attributes field for Unix
|
||||
if (!Utils.isWin) {
|
||||
// set file type either S_IFDIR / S_IFREG
|
||||
let unix = entry.isDirectory ? 0x4000 : 0x8000;
|
||||
|
||||
if (isStat) {
|
||||
// File attributes from file stats
|
||||
unix |= 0xfff & attr.mode;
|
||||
} else if ("number" === typeof attr) {
|
||||
// attr from given attr values
|
||||
unix |= 0xfff & attr;
|
||||
} else {
|
||||
// Default values:
|
||||
unix |= entry.isDirectory ? 0o755 : 0o644; // permissions (drwxr-xr-x) or (-r-wr--r--)
|
||||
}
|
||||
|
||||
fileattr = (fileattr | (unix << 16)) >>> 0; // add attributes
|
||||
}
|
||||
|
||||
entry.attr = fileattr;
|
||||
|
||||
entry.setData(content);
|
||||
if (!update) _zip.setEntry(entry);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns an array of ZipEntry objects representing the files and folders inside the archive
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
getEntries: function () {
|
||||
return _zip ? _zip.entries : [];
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns a ZipEntry object representing the file or folder specified by ``name``.
|
||||
*
|
||||
* @param name
|
||||
* @return ZipEntry
|
||||
*/
|
||||
getEntry: function (/**String*/ name) {
|
||||
return getEntry(name);
|
||||
},
|
||||
|
||||
getEntryCount: function () {
|
||||
return _zip.getEntryCount();
|
||||
},
|
||||
|
||||
forEach: function (callback) {
|
||||
return _zip.forEach(callback);
|
||||
},
|
||||
|
||||
/**
|
||||
* Extracts the given entry to the given targetPath
|
||||
* If the entry is a directory inside the archive, the entire directory and it's subdirectories will be extracted
|
||||
*
|
||||
* @param entry ZipEntry object or String with the full path of the entry
|
||||
* @param targetPath Target folder where to write the file
|
||||
* @param maintainEntryPath If maintainEntryPath is true and the entry is inside a folder, the entry folder
|
||||
* will be created in targetPath as well. Default is TRUE
|
||||
* @param overwrite If the file already exists at the target path, the file will be overwriten if this is true.
|
||||
* Default is FALSE
|
||||
* @param keepOriginalPermission The file will be set as the permission from the entry if this is true.
|
||||
* Default is FALSE
|
||||
* @param outFileName String If set will override the filename of the extracted file (Only works if the entry is a file)
|
||||
*
|
||||
* @return Boolean
|
||||
*/
|
||||
extractEntryTo: function (
|
||||
/**Object*/ entry,
|
||||
/**String*/ targetPath,
|
||||
/**Boolean*/ maintainEntryPath,
|
||||
/**Boolean*/ overwrite,
|
||||
/**Boolean*/ keepOriginalPermission,
|
||||
/**String**/ outFileName
|
||||
) {
|
||||
overwrite = get_Bool(overwrite, false);
|
||||
keepOriginalPermission = get_Bool(keepOriginalPermission, false);
|
||||
maintainEntryPath = get_Bool(maintainEntryPath, true);
|
||||
outFileName = get_Str(outFileName, get_Str(keepOriginalPermission, undefined));
|
||||
|
||||
var item = getEntry(entry);
|
||||
if (!item) {
|
||||
throw new Error(Utils.Errors.NO_ENTRY);
|
||||
}
|
||||
|
||||
var entryName = canonical(item.entryName);
|
||||
|
||||
var target = sanitize(targetPath, outFileName && !item.isDirectory ? outFileName : maintainEntryPath ? entryName : pth.basename(entryName));
|
||||
|
||||
if (item.isDirectory) {
|
||||
var children = _zip.getEntryChildren(item);
|
||||
children.forEach(function (child) {
|
||||
if (child.isDirectory) return;
|
||||
var content = child.getData();
|
||||
if (!content) {
|
||||
throw new Error(Utils.Errors.CANT_EXTRACT_FILE);
|
||||
}
|
||||
var name = canonical(child.entryName);
|
||||
var childName = sanitize(targetPath, maintainEntryPath ? name : pth.basename(name));
|
||||
// The reverse operation for attr depend on method addFile()
|
||||
const fileAttr = keepOriginalPermission ? child.header.fileAttr : undefined;
|
||||
filetools.writeFileTo(childName, content, overwrite, fileAttr);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
var content = item.getData();
|
||||
if (!content) throw new Error(Utils.Errors.CANT_EXTRACT_FILE);
|
||||
|
||||
if (filetools.fs.existsSync(target) && !overwrite) {
|
||||
throw new Error(Utils.Errors.CANT_OVERRIDE);
|
||||
}
|
||||
// The reverse operation for attr depend on method addFile()
|
||||
const fileAttr = keepOriginalPermission ? entry.header.fileAttr : undefined;
|
||||
filetools.writeFileTo(target, content, overwrite, fileAttr);
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Test the archive
|
||||
*
|
||||
*/
|
||||
test: function (pass) {
|
||||
if (!_zip) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (var entry in _zip.entries) {
|
||||
try {
|
||||
if (entry.isDirectory) {
|
||||
continue;
|
||||
}
|
||||
var content = _zip.entries[entry].getData(pass);
|
||||
if (!content) {
|
||||
return false;
|
||||
}
|
||||
} catch (err) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Extracts the entire archive to the given location
|
||||
*
|
||||
* @param targetPath Target location
|
||||
* @param overwrite If the file already exists at the target path, the file will be overwriten if this is true.
|
||||
* Default is FALSE
|
||||
* @param keepOriginalPermission The file will be set as the permission from the entry if this is true.
|
||||
* Default is FALSE
|
||||
*/
|
||||
extractAllTo: function (/**String*/ targetPath, /**Boolean*/ overwrite, /**Boolean*/ keepOriginalPermission, /*String, Buffer*/ pass) {
|
||||
overwrite = get_Bool(overwrite, false);
|
||||
pass = get_Str(keepOriginalPermission, pass);
|
||||
keepOriginalPermission = get_Bool(keepOriginalPermission, false);
|
||||
if (!_zip) {
|
||||
throw new Error(Utils.Errors.NO_ZIP);
|
||||
}
|
||||
_zip.entries.forEach(function (entry) {
|
||||
var entryName = sanitize(targetPath, canonical(entry.entryName.toString()));
|
||||
if (entry.isDirectory) {
|
||||
filetools.makeDir(entryName);
|
||||
return;
|
||||
}
|
||||
var content = entry.getData(pass);
|
||||
if (!content) {
|
||||
throw new Error(Utils.Errors.CANT_EXTRACT_FILE);
|
||||
}
|
||||
// The reverse operation for attr depend on method addFile()
|
||||
const fileAttr = keepOriginalPermission ? entry.header.fileAttr : undefined;
|
||||
filetools.writeFileTo(entryName, content, overwrite, fileAttr);
|
||||
try {
|
||||
filetools.fs.utimesSync(entryName, entry.header.time, entry.header.time);
|
||||
} catch (err) {
|
||||
throw new Error(Utils.Errors.CANT_EXTRACT_FILE);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Asynchronous extractAllTo
|
||||
*
|
||||
* @param targetPath Target location
|
||||
* @param overwrite If the file already exists at the target path, the file will be overwriten if this is true.
|
||||
* Default is FALSE
|
||||
* @param keepOriginalPermission The file will be set as the permission from the entry if this is true.
|
||||
* Default is FALSE
|
||||
* @param callback The callback will be executed when all entries are extracted successfully or any error is thrown.
|
||||
*/
|
||||
extractAllToAsync: function (/**String*/ targetPath, /**Boolean*/ overwrite, /**Boolean*/ keepOriginalPermission, /**Function*/ callback) {
|
||||
if (!callback) {
|
||||
callback = function () {};
|
||||
}
|
||||
overwrite = get_Bool(overwrite, false);
|
||||
if (typeof keepOriginalPermission === "function" && !callback) callback = keepOriginalPermission;
|
||||
keepOriginalPermission = get_Bool(keepOriginalPermission, false);
|
||||
if (!_zip) {
|
||||
callback(new Error(Utils.Errors.NO_ZIP));
|
||||
return;
|
||||
}
|
||||
|
||||
targetPath = pth.resolve(targetPath);
|
||||
// convert entryName to
|
||||
const getPath = (entry) => sanitize(targetPath, pth.normalize(canonical(entry.entryName.toString())));
|
||||
const getError = (msg, file) => new Error(msg + ': "' + file + '"');
|
||||
|
||||
// separate directories from files
|
||||
const dirEntries = [];
|
||||
const fileEntries = new Set();
|
||||
_zip.entries.forEach((e) => {
|
||||
if (e.isDirectory) {
|
||||
dirEntries.push(e);
|
||||
} else {
|
||||
fileEntries.add(e);
|
||||
}
|
||||
});
|
||||
|
||||
// Create directory entries first synchronously
|
||||
// this prevents race condition and assures folders are there before writing files
|
||||
for (const entry of dirEntries) {
|
||||
const dirPath = getPath(entry);
|
||||
// The reverse operation for attr depend on method addFile()
|
||||
const dirAttr = keepOriginalPermission ? entry.header.fileAttr : undefined;
|
||||
try {
|
||||
filetools.makeDir(dirPath);
|
||||
if (dirAttr) filetools.fs.chmodSync(dirPath, dirAttr);
|
||||
// in unix timestamp will change if files are later added to folder, but still
|
||||
filetools.fs.utimesSync(dirPath, entry.header.time, entry.header.time);
|
||||
} catch (er) {
|
||||
callback(getError("Unable to create folder", dirPath));
|
||||
}
|
||||
}
|
||||
|
||||
// callback wrapper, for some house keeping
|
||||
const done = () => {
|
||||
if (fileEntries.size === 0) {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
|
||||
// Extract file entries asynchronously
|
||||
for (const entry of fileEntries.values()) {
|
||||
const entryName = pth.normalize(canonical(entry.entryName.toString()));
|
||||
const filePath = sanitize(targetPath, entryName);
|
||||
entry.getDataAsync(function (content, err_1) {
|
||||
if (err_1) {
|
||||
callback(new Error(err_1));
|
||||
return;
|
||||
}
|
||||
if (!content) {
|
||||
callback(new Error(Utils.Errors.CANT_EXTRACT_FILE));
|
||||
} else {
|
||||
// The reverse operation for attr depend on method addFile()
|
||||
const fileAttr = keepOriginalPermission ? entry.header.fileAttr : undefined;
|
||||
filetools.writeFileToAsync(filePath, content, overwrite, fileAttr, function (succ) {
|
||||
if (!succ) {
|
||||
callback(getError("Unable to write file", filePath));
|
||||
return;
|
||||
}
|
||||
filetools.fs.utimes(filePath, entry.header.time, entry.header.time, function (err_2) {
|
||||
if (err_2) {
|
||||
callback(getError("Unable to set times", filePath));
|
||||
return;
|
||||
}
|
||||
fileEntries.delete(entry);
|
||||
// call the callback if it was last entry
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
// call the callback if fileEntries was empty
|
||||
done();
|
||||
},
|
||||
|
||||
/**
|
||||
* Writes the newly created zip file to disk at the specified location or if a zip was opened and no ``targetFileName`` is provided, it will overwrite the opened zip
|
||||
*
|
||||
* @param targetFileName
|
||||
* @param callback
|
||||
*/
|
||||
writeZip: function (/**String*/ targetFileName, /**Function*/ callback) {
|
||||
if (arguments.length === 1) {
|
||||
if (typeof targetFileName === "function") {
|
||||
callback = targetFileName;
|
||||
targetFileName = "";
|
||||
}
|
||||
}
|
||||
|
||||
if (!targetFileName && opts.filename) {
|
||||
targetFileName = opts.filename;
|
||||
}
|
||||
if (!targetFileName) return;
|
||||
|
||||
var zipData = _zip.compressToBuffer();
|
||||
if (zipData) {
|
||||
var ok = filetools.writeFileTo(targetFileName, zipData, true);
|
||||
if (typeof callback === "function") callback(!ok ? new Error("failed") : null, "");
|
||||
}
|
||||
},
|
||||
|
||||
writeZipPromise: function (/**String*/ targetFileName, /* object */ props) {
|
||||
const { overwrite, perm } = Object.assign({ overwrite: true }, props);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
// find file name
|
||||
if (!targetFileName && opts.filename) targetFileName = opts.filename;
|
||||
if (!targetFileName) reject("ADM-ZIP: ZIP File Name Missing");
|
||||
|
||||
this.toBufferPromise().then((zipData) => {
|
||||
const ret = (done) => (done ? resolve(done) : reject("ADM-ZIP: Wasn't able to write zip file"));
|
||||
filetools.writeFileToAsync(targetFileName, zipData, overwrite, perm, ret);
|
||||
}, reject);
|
||||
});
|
||||
},
|
||||
|
||||
toBufferPromise: function () {
|
||||
return new Promise((resolve, reject) => {
|
||||
_zip.toAsyncBuffer(resolve, reject);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the content of the entire zip file as a Buffer object
|
||||
*
|
||||
* @return Buffer
|
||||
*/
|
||||
toBuffer: function (/**Function=*/ onSuccess, /**Function=*/ onFail, /**Function=*/ onItemStart, /**Function=*/ onItemEnd) {
|
||||
this.valueOf = 2;
|
||||
if (typeof onSuccess === "function") {
|
||||
_zip.toAsyncBuffer(onSuccess, onFail, onItemStart, onItemEnd);
|
||||
return null;
|
||||
}
|
||||
return _zip.compressToBuffer();
|
||||
}
|
||||
};
|
||||
};
|
||||
338
node_modules/adm-zip/headers/entryHeader.js
generated
vendored
Normal file
338
node_modules/adm-zip/headers/entryHeader.js
generated
vendored
Normal file
@@ -0,0 +1,338 @@
|
||||
var Utils = require("../util"),
|
||||
Constants = Utils.Constants;
|
||||
|
||||
/* The central directory file header */
|
||||
module.exports = function () {
|
||||
var _verMade = 20, // v2.0
|
||||
_version = 10, // v1.0
|
||||
_flags = 0,
|
||||
_method = 0,
|
||||
_time = 0,
|
||||
_crc = 0,
|
||||
_compressedSize = 0,
|
||||
_size = 0,
|
||||
_fnameLen = 0,
|
||||
_extraLen = 0,
|
||||
_comLen = 0,
|
||||
_diskStart = 0,
|
||||
_inattr = 0,
|
||||
_attr = 0,
|
||||
_offset = 0;
|
||||
|
||||
_verMade |= Utils.isWin ? 0x0a00 : 0x0300;
|
||||
|
||||
// Set EFS flag since filename and comment fields are all by default encoded using UTF-8.
|
||||
// Without it file names may be corrupted for other apps when file names use unicode chars
|
||||
_flags |= Constants.FLG_EFS;
|
||||
|
||||
var _dataHeader = {};
|
||||
|
||||
function setTime(val) {
|
||||
val = new Date(val);
|
||||
_time =
|
||||
(((val.getFullYear() - 1980) & 0x7f) << 25) | // b09-16 years from 1980
|
||||
((val.getMonth() + 1) << 21) | // b05-08 month
|
||||
(val.getDate() << 16) | // b00-04 hour
|
||||
// 2 bytes time
|
||||
(val.getHours() << 11) | // b11-15 hour
|
||||
(val.getMinutes() << 5) | // b05-10 minute
|
||||
(val.getSeconds() >> 1); // b00-04 seconds divided by 2
|
||||
}
|
||||
|
||||
setTime(+new Date());
|
||||
|
||||
return {
|
||||
get made() {
|
||||
return _verMade;
|
||||
},
|
||||
set made(val) {
|
||||
_verMade = val;
|
||||
},
|
||||
|
||||
get version() {
|
||||
return _version;
|
||||
},
|
||||
set version(val) {
|
||||
_version = val;
|
||||
},
|
||||
|
||||
get flags() {
|
||||
return _flags;
|
||||
},
|
||||
set flags(val) {
|
||||
_flags = val;
|
||||
},
|
||||
|
||||
get method() {
|
||||
return _method;
|
||||
},
|
||||
set method(val) {
|
||||
switch (val) {
|
||||
case Constants.STORED:
|
||||
this.version = 10;
|
||||
case Constants.DEFLATED:
|
||||
default:
|
||||
this.version = 20;
|
||||
}
|
||||
_method = val;
|
||||
},
|
||||
|
||||
get time() {
|
||||
return new Date(((_time >> 25) & 0x7f) + 1980, ((_time >> 21) & 0x0f) - 1, (_time >> 16) & 0x1f, (_time >> 11) & 0x1f, (_time >> 5) & 0x3f, (_time & 0x1f) << 1);
|
||||
},
|
||||
set time(val) {
|
||||
setTime(val);
|
||||
},
|
||||
|
||||
get crc() {
|
||||
return _crc;
|
||||
},
|
||||
set crc(val) {
|
||||
_crc = Math.max(0, val) >>> 0;
|
||||
},
|
||||
|
||||
get compressedSize() {
|
||||
return _compressedSize;
|
||||
},
|
||||
set compressedSize(val) {
|
||||
_compressedSize = Math.max(0, val) >>> 0;
|
||||
},
|
||||
|
||||
get size() {
|
||||
return _size;
|
||||
},
|
||||
set size(val) {
|
||||
_size = Math.max(0, val) >>> 0;
|
||||
},
|
||||
|
||||
get fileNameLength() {
|
||||
return _fnameLen;
|
||||
},
|
||||
set fileNameLength(val) {
|
||||
_fnameLen = val;
|
||||
},
|
||||
|
||||
get extraLength() {
|
||||
return _extraLen;
|
||||
},
|
||||
set extraLength(val) {
|
||||
_extraLen = val;
|
||||
},
|
||||
|
||||
get commentLength() {
|
||||
return _comLen;
|
||||
},
|
||||
set commentLength(val) {
|
||||
_comLen = val;
|
||||
},
|
||||
|
||||
get diskNumStart() {
|
||||
return _diskStart;
|
||||
},
|
||||
set diskNumStart(val) {
|
||||
_diskStart = Math.max(0, val) >>> 0;
|
||||
},
|
||||
|
||||
get inAttr() {
|
||||
return _inattr;
|
||||
},
|
||||
set inAttr(val) {
|
||||
_inattr = Math.max(0, val) >>> 0;
|
||||
},
|
||||
|
||||
get attr() {
|
||||
return _attr;
|
||||
},
|
||||
set attr(val) {
|
||||
_attr = Math.max(0, val) >>> 0;
|
||||
},
|
||||
|
||||
// get Unix file permissions
|
||||
get fileAttr() {
|
||||
return _attr ? (((_attr >>> 0) | 0) >> 16) & 0xfff : 0;
|
||||
},
|
||||
|
||||
get offset() {
|
||||
return _offset;
|
||||
},
|
||||
set offset(val) {
|
||||
_offset = Math.max(0, val) >>> 0;
|
||||
},
|
||||
|
||||
get encripted() {
|
||||
return (_flags & 1) === 1;
|
||||
},
|
||||
|
||||
get entryHeaderSize() {
|
||||
return Constants.CENHDR + _fnameLen + _extraLen + _comLen;
|
||||
},
|
||||
|
||||
get realDataOffset() {
|
||||
return _offset + Constants.LOCHDR + _dataHeader.fnameLen + _dataHeader.extraLen;
|
||||
},
|
||||
|
||||
get dataHeader() {
|
||||
return _dataHeader;
|
||||
},
|
||||
|
||||
loadDataHeaderFromBinary: function (/*Buffer*/ input) {
|
||||
var data = input.slice(_offset, _offset + Constants.LOCHDR);
|
||||
// 30 bytes and should start with "PK\003\004"
|
||||
if (data.readUInt32LE(0) !== Constants.LOCSIG) {
|
||||
throw new Error(Utils.Errors.INVALID_LOC);
|
||||
}
|
||||
_dataHeader = {
|
||||
// version needed to extract
|
||||
version: data.readUInt16LE(Constants.LOCVER),
|
||||
// general purpose bit flag
|
||||
flags: data.readUInt16LE(Constants.LOCFLG),
|
||||
// compression method
|
||||
method: data.readUInt16LE(Constants.LOCHOW),
|
||||
// modification time (2 bytes time, 2 bytes date)
|
||||
time: data.readUInt32LE(Constants.LOCTIM),
|
||||
// uncompressed file crc-32 value
|
||||
crc: data.readUInt32LE(Constants.LOCCRC),
|
||||
// compressed size
|
||||
compressedSize: data.readUInt32LE(Constants.LOCSIZ),
|
||||
// uncompressed size
|
||||
size: data.readUInt32LE(Constants.LOCLEN),
|
||||
// filename length
|
||||
fnameLen: data.readUInt16LE(Constants.LOCNAM),
|
||||
// extra field length
|
||||
extraLen: data.readUInt16LE(Constants.LOCEXT)
|
||||
};
|
||||
},
|
||||
|
||||
loadFromBinary: function (/*Buffer*/ data) {
|
||||
// data should be 46 bytes and start with "PK 01 02"
|
||||
if (data.length !== Constants.CENHDR || data.readUInt32LE(0) !== Constants.CENSIG) {
|
||||
throw new Error(Utils.Errors.INVALID_CEN);
|
||||
}
|
||||
// version made by
|
||||
_verMade = data.readUInt16LE(Constants.CENVEM);
|
||||
// version needed to extract
|
||||
_version = data.readUInt16LE(Constants.CENVER);
|
||||
// encrypt, decrypt flags
|
||||
_flags = data.readUInt16LE(Constants.CENFLG);
|
||||
// compression method
|
||||
_method = data.readUInt16LE(Constants.CENHOW);
|
||||
// modification time (2 bytes time, 2 bytes date)
|
||||
_time = data.readUInt32LE(Constants.CENTIM);
|
||||
// uncompressed file crc-32 value
|
||||
_crc = data.readUInt32LE(Constants.CENCRC);
|
||||
// compressed size
|
||||
_compressedSize = data.readUInt32LE(Constants.CENSIZ);
|
||||
// uncompressed size
|
||||
_size = data.readUInt32LE(Constants.CENLEN);
|
||||
// filename length
|
||||
_fnameLen = data.readUInt16LE(Constants.CENNAM);
|
||||
// extra field length
|
||||
_extraLen = data.readUInt16LE(Constants.CENEXT);
|
||||
// file comment length
|
||||
_comLen = data.readUInt16LE(Constants.CENCOM);
|
||||
// volume number start
|
||||
_diskStart = data.readUInt16LE(Constants.CENDSK);
|
||||
// internal file attributes
|
||||
_inattr = data.readUInt16LE(Constants.CENATT);
|
||||
// external file attributes
|
||||
_attr = data.readUInt32LE(Constants.CENATX);
|
||||
// LOC header offset
|
||||
_offset = data.readUInt32LE(Constants.CENOFF);
|
||||
},
|
||||
|
||||
dataHeaderToBinary: function () {
|
||||
// LOC header size (30 bytes)
|
||||
var data = Buffer.alloc(Constants.LOCHDR);
|
||||
// "PK\003\004"
|
||||
data.writeUInt32LE(Constants.LOCSIG, 0);
|
||||
// version needed to extract
|
||||
data.writeUInt16LE(_version, Constants.LOCVER);
|
||||
// general purpose bit flag
|
||||
data.writeUInt16LE(_flags, Constants.LOCFLG);
|
||||
// compression method
|
||||
data.writeUInt16LE(_method, Constants.LOCHOW);
|
||||
// modification time (2 bytes time, 2 bytes date)
|
||||
data.writeUInt32LE(_time, Constants.LOCTIM);
|
||||
// uncompressed file crc-32 value
|
||||
data.writeUInt32LE(_crc, Constants.LOCCRC);
|
||||
// compressed size
|
||||
data.writeUInt32LE(_compressedSize, Constants.LOCSIZ);
|
||||
// uncompressed size
|
||||
data.writeUInt32LE(_size, Constants.LOCLEN);
|
||||
// filename length
|
||||
data.writeUInt16LE(_fnameLen, Constants.LOCNAM);
|
||||
// extra field length
|
||||
data.writeUInt16LE(_extraLen, Constants.LOCEXT);
|
||||
return data;
|
||||
},
|
||||
|
||||
entryHeaderToBinary: function () {
|
||||
// CEN header size (46 bytes)
|
||||
var data = Buffer.alloc(Constants.CENHDR + _fnameLen + _extraLen + _comLen);
|
||||
// "PK\001\002"
|
||||
data.writeUInt32LE(Constants.CENSIG, 0);
|
||||
// version made by
|
||||
data.writeUInt16LE(_verMade, Constants.CENVEM);
|
||||
// version needed to extract
|
||||
data.writeUInt16LE(_version, Constants.CENVER);
|
||||
// encrypt, decrypt flags
|
||||
data.writeUInt16LE(_flags, Constants.CENFLG);
|
||||
// compression method
|
||||
data.writeUInt16LE(_method, Constants.CENHOW);
|
||||
// modification time (2 bytes time, 2 bytes date)
|
||||
data.writeUInt32LE(_time, Constants.CENTIM);
|
||||
// uncompressed file crc-32 value
|
||||
data.writeUInt32LE(_crc, Constants.CENCRC);
|
||||
// compressed size
|
||||
data.writeUInt32LE(_compressedSize, Constants.CENSIZ);
|
||||
// uncompressed size
|
||||
data.writeUInt32LE(_size, Constants.CENLEN);
|
||||
// filename length
|
||||
data.writeUInt16LE(_fnameLen, Constants.CENNAM);
|
||||
// extra field length
|
||||
data.writeUInt16LE(_extraLen, Constants.CENEXT);
|
||||
// file comment length
|
||||
data.writeUInt16LE(_comLen, Constants.CENCOM);
|
||||
// volume number start
|
||||
data.writeUInt16LE(_diskStart, Constants.CENDSK);
|
||||
// internal file attributes
|
||||
data.writeUInt16LE(_inattr, Constants.CENATT);
|
||||
// external file attributes
|
||||
data.writeUInt32LE(_attr, Constants.CENATX);
|
||||
// LOC header offset
|
||||
data.writeUInt32LE(_offset, Constants.CENOFF);
|
||||
// fill all with
|
||||
data.fill(0x00, Constants.CENHDR);
|
||||
return data;
|
||||
},
|
||||
|
||||
toJSON: function () {
|
||||
const bytes = function (nr) {
|
||||
return nr + " bytes";
|
||||
};
|
||||
|
||||
return {
|
||||
made: _verMade,
|
||||
version: _version,
|
||||
flags: _flags,
|
||||
method: Utils.methodToString(_method),
|
||||
time: this.time,
|
||||
crc: "0x" + _crc.toString(16).toUpperCase(),
|
||||
compressedSize: bytes(_compressedSize),
|
||||
size: bytes(_size),
|
||||
fileNameLength: bytes(_fnameLen),
|
||||
extraLength: bytes(_extraLen),
|
||||
commentLength: bytes(_comLen),
|
||||
diskNumStart: _diskStart,
|
||||
inAttr: _inattr,
|
||||
attr: _attr,
|
||||
offset: _offset,
|
||||
entryHeaderSize: bytes(Constants.CENHDR + _fnameLen + _extraLen + _comLen)
|
||||
};
|
||||
},
|
||||
|
||||
toString: function () {
|
||||
return JSON.stringify(this.toJSON(), null, "\t");
|
||||
}
|
||||
};
|
||||
};
|
||||
2
node_modules/adm-zip/headers/index.js
generated
vendored
Normal file
2
node_modules/adm-zip/headers/index.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
exports.EntryHeader = require("./entryHeader");
|
||||
exports.MainHeader = require("./mainHeader");
|
||||
129
node_modules/adm-zip/headers/mainHeader.js
generated
vendored
Normal file
129
node_modules/adm-zip/headers/mainHeader.js
generated
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
var Utils = require("../util"),
|
||||
Constants = Utils.Constants;
|
||||
|
||||
/* The entries in the end of central directory */
|
||||
module.exports = function () {
|
||||
var _volumeEntries = 0,
|
||||
_totalEntries = 0,
|
||||
_size = 0,
|
||||
_offset = 0,
|
||||
_commentLength = 0;
|
||||
|
||||
return {
|
||||
get diskEntries() {
|
||||
return _volumeEntries;
|
||||
},
|
||||
set diskEntries(/*Number*/ val) {
|
||||
_volumeEntries = _totalEntries = val;
|
||||
},
|
||||
|
||||
get totalEntries() {
|
||||
return _totalEntries;
|
||||
},
|
||||
set totalEntries(/*Number*/ val) {
|
||||
_totalEntries = _volumeEntries = val;
|
||||
},
|
||||
|
||||
get size() {
|
||||
return _size;
|
||||
},
|
||||
set size(/*Number*/ val) {
|
||||
_size = val;
|
||||
},
|
||||
|
||||
get offset() {
|
||||
return _offset;
|
||||
},
|
||||
set offset(/*Number*/ val) {
|
||||
_offset = val;
|
||||
},
|
||||
|
||||
get commentLength() {
|
||||
return _commentLength;
|
||||
},
|
||||
set commentLength(/*Number*/ val) {
|
||||
_commentLength = val;
|
||||
},
|
||||
|
||||
get mainHeaderSize() {
|
||||
return Constants.ENDHDR + _commentLength;
|
||||
},
|
||||
|
||||
loadFromBinary: function (/*Buffer*/ data) {
|
||||
// data should be 22 bytes and start with "PK 05 06"
|
||||
// or be 56+ bytes and start with "PK 06 06" for Zip64
|
||||
if (
|
||||
(data.length !== Constants.ENDHDR || data.readUInt32LE(0) !== Constants.ENDSIG) &&
|
||||
(data.length < Constants.ZIP64HDR || data.readUInt32LE(0) !== Constants.ZIP64SIG)
|
||||
) {
|
||||
throw new Error(Utils.Errors.INVALID_END);
|
||||
}
|
||||
|
||||
if (data.readUInt32LE(0) === Constants.ENDSIG) {
|
||||
// number of entries on this volume
|
||||
_volumeEntries = data.readUInt16LE(Constants.ENDSUB);
|
||||
// total number of entries
|
||||
_totalEntries = data.readUInt16LE(Constants.ENDTOT);
|
||||
// central directory size in bytes
|
||||
_size = data.readUInt32LE(Constants.ENDSIZ);
|
||||
// offset of first CEN header
|
||||
_offset = data.readUInt32LE(Constants.ENDOFF);
|
||||
// zip file comment length
|
||||
_commentLength = data.readUInt16LE(Constants.ENDCOM);
|
||||
} else {
|
||||
// number of entries on this volume
|
||||
_volumeEntries = Utils.readBigUInt64LE(data, Constants.ZIP64SUB);
|
||||
// total number of entries
|
||||
_totalEntries = Utils.readBigUInt64LE(data, Constants.ZIP64TOT);
|
||||
// central directory size in bytes
|
||||
_size = Utils.readBigUInt64LE(data, Constants.ZIP64SIZ);
|
||||
// offset of first CEN header
|
||||
_offset = Utils.readBigUInt64LE(data, Constants.ZIP64OFF);
|
||||
|
||||
_commentLength = 0;
|
||||
}
|
||||
},
|
||||
|
||||
toBinary: function () {
|
||||
var b = Buffer.alloc(Constants.ENDHDR + _commentLength);
|
||||
// "PK 05 06" signature
|
||||
b.writeUInt32LE(Constants.ENDSIG, 0);
|
||||
b.writeUInt32LE(0, 4);
|
||||
// number of entries on this volume
|
||||
b.writeUInt16LE(_volumeEntries, Constants.ENDSUB);
|
||||
// total number of entries
|
||||
b.writeUInt16LE(_totalEntries, Constants.ENDTOT);
|
||||
// central directory size in bytes
|
||||
b.writeUInt32LE(_size, Constants.ENDSIZ);
|
||||
// offset of first CEN header
|
||||
b.writeUInt32LE(_offset, Constants.ENDOFF);
|
||||
// zip file comment length
|
||||
b.writeUInt16LE(_commentLength, Constants.ENDCOM);
|
||||
// fill comment memory with spaces so no garbage is left there
|
||||
b.fill(" ", Constants.ENDHDR);
|
||||
|
||||
return b;
|
||||
},
|
||||
|
||||
toJSON: function () {
|
||||
// creates 0x0000 style output
|
||||
const offset = function (nr, len) {
|
||||
let offs = nr.toString(16).toUpperCase();
|
||||
while (offs.length < len) offs = "0" + offs;
|
||||
return "0x" + offs;
|
||||
};
|
||||
|
||||
return {
|
||||
diskEntries: _volumeEntries,
|
||||
totalEntries: _totalEntries,
|
||||
size: _size + " bytes",
|
||||
offset: offset(_offset, 4),
|
||||
commentLength: _commentLength
|
||||
};
|
||||
},
|
||||
|
||||
toString: function () {
|
||||
return JSON.stringify(this.toJSON(), null, "\t");
|
||||
}
|
||||
};
|
||||
};
|
||||
33
node_modules/adm-zip/methods/deflater.js
generated
vendored
Normal file
33
node_modules/adm-zip/methods/deflater.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
module.exports = function (/*Buffer*/ inbuf) {
|
||||
var zlib = require("zlib");
|
||||
|
||||
var opts = { chunkSize: (parseInt(inbuf.length / 1024) + 1) * 1024 };
|
||||
|
||||
return {
|
||||
deflate: function () {
|
||||
return zlib.deflateRawSync(inbuf, opts);
|
||||
},
|
||||
|
||||
deflateAsync: function (/*Function*/ callback) {
|
||||
var tmp = zlib.createDeflateRaw(opts),
|
||||
parts = [],
|
||||
total = 0;
|
||||
tmp.on("data", function (data) {
|
||||
parts.push(data);
|
||||
total += data.length;
|
||||
});
|
||||
tmp.on("end", function () {
|
||||
var buf = Buffer.alloc(total),
|
||||
written = 0;
|
||||
buf.fill(0);
|
||||
for (var i = 0; i < parts.length; i++) {
|
||||
var part = parts[i];
|
||||
part.copy(buf, written);
|
||||
written += part.length;
|
||||
}
|
||||
callback && callback(buf);
|
||||
});
|
||||
tmp.end(inbuf);
|
||||
}
|
||||
};
|
||||
};
|
||||
3
node_modules/adm-zip/methods/index.js
generated
vendored
Normal file
3
node_modules/adm-zip/methods/index.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
exports.Deflater = require("./deflater");
|
||||
exports.Inflater = require("./inflater");
|
||||
exports.ZipCrypto = require("./zipcrypto");
|
||||
31
node_modules/adm-zip/methods/inflater.js
generated
vendored
Normal file
31
node_modules/adm-zip/methods/inflater.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
module.exports = function (/*Buffer*/ inbuf) {
|
||||
var zlib = require("zlib");
|
||||
|
||||
return {
|
||||
inflate: function () {
|
||||
return zlib.inflateRawSync(inbuf);
|
||||
},
|
||||
|
||||
inflateAsync: function (/*Function*/ callback) {
|
||||
var tmp = zlib.createInflateRaw(),
|
||||
parts = [],
|
||||
total = 0;
|
||||
tmp.on("data", function (data) {
|
||||
parts.push(data);
|
||||
total += data.length;
|
||||
});
|
||||
tmp.on("end", function () {
|
||||
var buf = Buffer.alloc(total),
|
||||
written = 0;
|
||||
buf.fill(0);
|
||||
for (var i = 0; i < parts.length; i++) {
|
||||
var part = parts[i];
|
||||
part.copy(buf, written);
|
||||
written += part.length;
|
||||
}
|
||||
callback && callback(buf);
|
||||
});
|
||||
tmp.end(inbuf);
|
||||
}
|
||||
};
|
||||
};
|
||||
170
node_modules/adm-zip/methods/zipcrypto.js
generated
vendored
Normal file
170
node_modules/adm-zip/methods/zipcrypto.js
generated
vendored
Normal file
@@ -0,0 +1,170 @@
|
||||
"use strict";
|
||||
|
||||
// node crypt, we use it for generate salt
|
||||
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
||||
const { randomFillSync } = require("crypto");
|
||||
|
||||
// generate CRC32 lookup table
|
||||
const crctable = new Uint32Array(256).map((t, crc) => {
|
||||
for (let j = 0; j < 8; j++) {
|
||||
if (0 !== (crc & 1)) {
|
||||
crc = (crc >>> 1) ^ 0xedb88320;
|
||||
} else {
|
||||
crc >>>= 1;
|
||||
}
|
||||
}
|
||||
return crc >>> 0;
|
||||
});
|
||||
|
||||
// C-style uInt32 Multiply (discards higher bits, when JS multiply discards lower bits)
|
||||
const uMul = (a, b) => Math.imul(a, b) >>> 0;
|
||||
|
||||
// crc32 byte single update (actually same function is part of utils.crc32 function :) )
|
||||
const crc32update = (pCrc32, bval) => {
|
||||
return crctable[(pCrc32 ^ bval) & 0xff] ^ (pCrc32 >>> 8);
|
||||
};
|
||||
|
||||
// function for generating salt for encrytion header
|
||||
const genSalt = () => {
|
||||
if ("function" === typeof randomFillSync) {
|
||||
return randomFillSync(Buffer.alloc(12));
|
||||
} else {
|
||||
// fallback if function is not defined
|
||||
return genSalt.node();
|
||||
}
|
||||
};
|
||||
|
||||
// salt generation with node random function (mainly as fallback)
|
||||
genSalt.node = () => {
|
||||
const salt = Buffer.alloc(12);
|
||||
const len = salt.length;
|
||||
for (let i = 0; i < len; i++) salt[i] = (Math.random() * 256) & 0xff;
|
||||
return salt;
|
||||
};
|
||||
|
||||
// general config
|
||||
const config = {
|
||||
genSalt
|
||||
};
|
||||
|
||||
// Class Initkeys handles same basic ops with keys
|
||||
function Initkeys(pw) {
|
||||
const pass = Buffer.isBuffer(pw) ? pw : Buffer.from(pw);
|
||||
this.keys = new Uint32Array([0x12345678, 0x23456789, 0x34567890]);
|
||||
for (let i = 0; i < pass.length; i++) {
|
||||
this.updateKeys(pass[i]);
|
||||
}
|
||||
}
|
||||
|
||||
Initkeys.prototype.updateKeys = function (byteValue) {
|
||||
const keys = this.keys;
|
||||
keys[0] = crc32update(keys[0], byteValue);
|
||||
keys[1] += keys[0] & 0xff;
|
||||
keys[1] = uMul(keys[1], 134775813) + 1;
|
||||
keys[2] = crc32update(keys[2], keys[1] >>> 24);
|
||||
return byteValue;
|
||||
};
|
||||
|
||||
Initkeys.prototype.next = function () {
|
||||
const k = (this.keys[2] | 2) >>> 0; // key
|
||||
return (uMul(k, k ^ 1) >> 8) & 0xff; // decode
|
||||
};
|
||||
|
||||
function make_decrypter(/*Buffer*/ pwd) {
|
||||
// 1. Stage initialize key
|
||||
const keys = new Initkeys(pwd);
|
||||
|
||||
// return decrypter function
|
||||
return function (/*Buffer*/ data) {
|
||||
// result - we create new Buffer for results
|
||||
const result = Buffer.alloc(data.length);
|
||||
let pos = 0;
|
||||
// process input data
|
||||
for (let c of data) {
|
||||
//c ^= keys.next();
|
||||
//result[pos++] = c; // decode & Save Value
|
||||
result[pos++] = keys.updateKeys(c ^ keys.next()); // update keys with decoded byte
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
function make_encrypter(/*Buffer*/ pwd) {
|
||||
// 1. Stage initialize key
|
||||
const keys = new Initkeys(pwd);
|
||||
|
||||
// return encrypting function, result and pos is here so we dont have to merge buffers later
|
||||
return function (/*Buffer*/ data, /*Buffer*/ result, /* Number */ pos = 0) {
|
||||
// result - we create new Buffer for results
|
||||
if (!result) result = Buffer.alloc(data.length);
|
||||
// process input data
|
||||
for (let c of data) {
|
||||
const k = keys.next(); // save key byte
|
||||
result[pos++] = c ^ k; // save val
|
||||
keys.updateKeys(c); // update keys with decoded byte
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
function decrypt(/*Buffer*/ data, /*Object*/ header, /*String, Buffer*/ pwd) {
|
||||
if (!data || !Buffer.isBuffer(data) || data.length < 12) {
|
||||
return Buffer.alloc(0);
|
||||
}
|
||||
|
||||
// 1. We Initialize and generate decrypting function
|
||||
const decrypter = make_decrypter(pwd);
|
||||
|
||||
// 2. decrypt salt what is always 12 bytes and is a part of file content
|
||||
const salt = decrypter(data.slice(0, 12));
|
||||
|
||||
// 3. does password meet expectations
|
||||
if (salt[11] !== header.crc >>> 24) {
|
||||
throw "ADM-ZIP: Wrong Password";
|
||||
}
|
||||
|
||||
// 4. decode content
|
||||
return decrypter(data.slice(12));
|
||||
}
|
||||
|
||||
// lets add way to populate salt, NOT RECOMMENDED for production but maybe useful for testing general functionality
|
||||
function _salter(data) {
|
||||
if (Buffer.isBuffer(data) && data.length >= 12) {
|
||||
// be aware - currently salting buffer data is modified
|
||||
config.genSalt = function () {
|
||||
return data.slice(0, 12);
|
||||
};
|
||||
} else if (data === "node") {
|
||||
// test salt generation with node random function
|
||||
config.genSalt = genSalt.node;
|
||||
} else {
|
||||
// if value is not acceptable config gets reset.
|
||||
config.genSalt = genSalt;
|
||||
}
|
||||
}
|
||||
|
||||
function encrypt(/*Buffer*/ data, /*Object*/ header, /*String, Buffer*/ pwd, /*Boolean*/ oldlike = false) {
|
||||
// 1. test data if data is not Buffer we make buffer from it
|
||||
if (data == null) data = Buffer.alloc(0);
|
||||
// if data is not buffer be make buffer from it
|
||||
if (!Buffer.isBuffer(data)) data = Buffer.from(data.toString());
|
||||
|
||||
// 2. We Initialize and generate encrypting function
|
||||
const encrypter = make_encrypter(pwd);
|
||||
|
||||
// 3. generate salt (12-bytes of random data)
|
||||
const salt = config.genSalt();
|
||||
salt[11] = (header.crc >>> 24) & 0xff;
|
||||
|
||||
// old implementations (before PKZip 2.04g) used two byte check
|
||||
if (oldlike) salt[10] = (header.crc >>> 16) & 0xff;
|
||||
|
||||
// 4. create output
|
||||
const result = Buffer.alloc(data.length + 12);
|
||||
encrypter(salt, result);
|
||||
|
||||
// finally encode content
|
||||
return encrypter(data, result, 12);
|
||||
}
|
||||
|
||||
module.exports = { decrypt, encrypt, _salter };
|
||||
48
node_modules/adm-zip/package.json
generated
vendored
Normal file
48
node_modules/adm-zip/package.json
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"name": "adm-zip",
|
||||
"version": "0.5.9",
|
||||
"description": "Javascript implementation of zip for nodejs with support for electron original-fs. Allows user to create or extract zip files both in memory or to/from disk",
|
||||
"scripts": {
|
||||
"test": "mocha -R spec",
|
||||
"test:format": "npm run format:prettier:raw -- --check",
|
||||
"format": "npm run format:prettier",
|
||||
"format:prettier": "npm run format:prettier:raw -- --write",
|
||||
"format:prettier:raw": "prettier \"**/*.{js,yml,json}\""
|
||||
},
|
||||
"keywords": [
|
||||
"zip",
|
||||
"methods",
|
||||
"archive",
|
||||
"unzip"
|
||||
],
|
||||
"homepage": "https://github.com/cthackers/adm-zip",
|
||||
"author": "Nasca Iacob <sy@another-d-mention.ro> (https://github.com/cthackers)",
|
||||
"bugs": {
|
||||
"email": "sy@another-d-mention.ro",
|
||||
"url": "https://github.com/cthackers/adm-zip/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
"adm-zip.js",
|
||||
"headers",
|
||||
"methods",
|
||||
"util",
|
||||
"zipEntry.js",
|
||||
"zipFile.js",
|
||||
"LICENSE"
|
||||
],
|
||||
"main": "adm-zip.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/cthackers/adm-zip.git"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"chai": "^4.3.4",
|
||||
"mocha": "^8.3.2",
|
||||
"prettier": "^2.2.1",
|
||||
"rimraf": "^3.0.2"
|
||||
}
|
||||
}
|
||||
142
node_modules/adm-zip/util/constants.js
generated
vendored
Normal file
142
node_modules/adm-zip/util/constants.js
generated
vendored
Normal file
@@ -0,0 +1,142 @@
|
||||
module.exports = {
|
||||
/* The local file header */
|
||||
LOCHDR : 30, // LOC header size
|
||||
LOCSIG : 0x04034b50, // "PK\003\004"
|
||||
LOCVER : 4, // version needed to extract
|
||||
LOCFLG : 6, // general purpose bit flag
|
||||
LOCHOW : 8, // compression method
|
||||
LOCTIM : 10, // modification time (2 bytes time, 2 bytes date)
|
||||
LOCCRC : 14, // uncompressed file crc-32 value
|
||||
LOCSIZ : 18, // compressed size
|
||||
LOCLEN : 22, // uncompressed size
|
||||
LOCNAM : 26, // filename length
|
||||
LOCEXT : 28, // extra field length
|
||||
|
||||
/* The Data descriptor */
|
||||
EXTSIG : 0x08074b50, // "PK\007\008"
|
||||
EXTHDR : 16, // EXT header size
|
||||
EXTCRC : 4, // uncompressed file crc-32 value
|
||||
EXTSIZ : 8, // compressed size
|
||||
EXTLEN : 12, // uncompressed size
|
||||
|
||||
/* The central directory file header */
|
||||
CENHDR : 46, // CEN header size
|
||||
CENSIG : 0x02014b50, // "PK\001\002"
|
||||
CENVEM : 4, // version made by
|
||||
CENVER : 6, // version needed to extract
|
||||
CENFLG : 8, // encrypt, decrypt flags
|
||||
CENHOW : 10, // compression method
|
||||
CENTIM : 12, // modification time (2 bytes time, 2 bytes date)
|
||||
CENCRC : 16, // uncompressed file crc-32 value
|
||||
CENSIZ : 20, // compressed size
|
||||
CENLEN : 24, // uncompressed size
|
||||
CENNAM : 28, // filename length
|
||||
CENEXT : 30, // extra field length
|
||||
CENCOM : 32, // file comment length
|
||||
CENDSK : 34, // volume number start
|
||||
CENATT : 36, // internal file attributes
|
||||
CENATX : 38, // external file attributes (host system dependent)
|
||||
CENOFF : 42, // LOC header offset
|
||||
|
||||
/* The entries in the end of central directory */
|
||||
ENDHDR : 22, // END header size
|
||||
ENDSIG : 0x06054b50, // "PK\005\006"
|
||||
ENDSUB : 8, // number of entries on this disk
|
||||
ENDTOT : 10, // total number of entries
|
||||
ENDSIZ : 12, // central directory size in bytes
|
||||
ENDOFF : 16, // offset of first CEN header
|
||||
ENDCOM : 20, // zip file comment length
|
||||
|
||||
END64HDR : 20, // zip64 END header size
|
||||
END64SIG : 0x07064b50, // zip64 Locator signature, "PK\006\007"
|
||||
END64START : 4, // number of the disk with the start of the zip64
|
||||
END64OFF : 8, // relative offset of the zip64 end of central directory
|
||||
END64NUMDISKS : 16, // total number of disks
|
||||
|
||||
ZIP64SIG : 0x06064b50, // zip64 signature, "PK\006\006"
|
||||
ZIP64HDR : 56, // zip64 record minimum size
|
||||
ZIP64LEAD : 12, // leading bytes at the start of the record, not counted by the value stored in ZIP64SIZE
|
||||
ZIP64SIZE : 4, // zip64 size of the central directory record
|
||||
ZIP64VEM : 12, // zip64 version made by
|
||||
ZIP64VER : 14, // zip64 version needed to extract
|
||||
ZIP64DSK : 16, // zip64 number of this disk
|
||||
ZIP64DSKDIR : 20, // number of the disk with the start of the record directory
|
||||
ZIP64SUB : 24, // number of entries on this disk
|
||||
ZIP64TOT : 32, // total number of entries
|
||||
ZIP64SIZB : 40, // zip64 central directory size in bytes
|
||||
ZIP64OFF : 48, // offset of start of central directory with respect to the starting disk number
|
||||
ZIP64EXTRA : 56, // extensible data sector
|
||||
|
||||
/* Compression methods */
|
||||
STORED : 0, // no compression
|
||||
SHRUNK : 1, // shrunk
|
||||
REDUCED1 : 2, // reduced with compression factor 1
|
||||
REDUCED2 : 3, // reduced with compression factor 2
|
||||
REDUCED3 : 4, // reduced with compression factor 3
|
||||
REDUCED4 : 5, // reduced with compression factor 4
|
||||
IMPLODED : 6, // imploded
|
||||
// 7 reserved for Tokenizing compression algorithm
|
||||
DEFLATED : 8, // deflated
|
||||
ENHANCED_DEFLATED: 9, // enhanced deflated
|
||||
PKWARE : 10,// PKWare DCL imploded
|
||||
// 11 reserved by PKWARE
|
||||
BZIP2 : 12, // compressed using BZIP2
|
||||
// 13 reserved by PKWARE
|
||||
LZMA : 14, // LZMA
|
||||
// 15-17 reserved by PKWARE
|
||||
IBM_TERSE : 18, // compressed using IBM TERSE
|
||||
IBM_LZ77 : 19, // IBM LZ77 z
|
||||
AES_ENCRYPT : 99, // WinZIP AES encryption method
|
||||
|
||||
/* General purpose bit flag */
|
||||
// values can obtained with expression 2**bitnr
|
||||
FLG_ENC : 1, // Bit 0: encrypted file
|
||||
FLG_COMP1 : 2, // Bit 1, compression option
|
||||
FLG_COMP2 : 4, // Bit 2, compression option
|
||||
FLG_DESC : 8, // Bit 3, data descriptor
|
||||
FLG_ENH : 16, // Bit 4, enhanced deflating
|
||||
FLG_PATCH : 32, // Bit 5, indicates that the file is compressed patched data.
|
||||
FLG_STR : 64, // Bit 6, strong encryption (patented)
|
||||
// Bits 7-10: Currently unused.
|
||||
FLG_EFS : 2048, // Bit 11: Language encoding flag (EFS)
|
||||
// Bit 12: Reserved by PKWARE for enhanced compression.
|
||||
// Bit 13: encrypted the Central Directory (patented).
|
||||
// Bits 14-15: Reserved by PKWARE.
|
||||
FLG_MSK : 4096, // mask header values
|
||||
|
||||
/* Load type */
|
||||
FILE : 2,
|
||||
BUFFER : 1,
|
||||
NONE : 0,
|
||||
|
||||
/* 4.5 Extensible data fields */
|
||||
EF_ID : 0,
|
||||
EF_SIZE : 2,
|
||||
|
||||
/* Header IDs */
|
||||
ID_ZIP64 : 0x0001,
|
||||
ID_AVINFO : 0x0007,
|
||||
ID_PFS : 0x0008,
|
||||
ID_OS2 : 0x0009,
|
||||
ID_NTFS : 0x000a,
|
||||
ID_OPENVMS : 0x000c,
|
||||
ID_UNIX : 0x000d,
|
||||
ID_FORK : 0x000e,
|
||||
ID_PATCH : 0x000f,
|
||||
ID_X509_PKCS7 : 0x0014,
|
||||
ID_X509_CERTID_F : 0x0015,
|
||||
ID_X509_CERTID_C : 0x0016,
|
||||
ID_STRONGENC : 0x0017,
|
||||
ID_RECORD_MGT : 0x0018,
|
||||
ID_X509_PKCS7_RL : 0x0019,
|
||||
ID_IBM1 : 0x0065,
|
||||
ID_IBM2 : 0x0066,
|
||||
ID_POSZIP : 0x4690,
|
||||
|
||||
EF_ZIP64_OR_32 : 0xffffffff,
|
||||
EF_ZIP64_OR_16 : 0xffff,
|
||||
EF_ZIP64_SUNCOMP : 0,
|
||||
EF_ZIP64_SCOMP : 8,
|
||||
EF_ZIP64_RHO : 16,
|
||||
EF_ZIP64_DSN : 24
|
||||
};
|
||||
35
node_modules/adm-zip/util/errors.js
generated
vendored
Normal file
35
node_modules/adm-zip/util/errors.js
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
module.exports = {
|
||||
/* Header error messages */
|
||||
INVALID_LOC: "Invalid LOC header (bad signature)",
|
||||
INVALID_CEN: "Invalid CEN header (bad signature)",
|
||||
INVALID_END: "Invalid END header (bad signature)",
|
||||
|
||||
/* ZipEntry error messages*/
|
||||
NO_DATA: "Nothing to decompress",
|
||||
BAD_CRC: "CRC32 checksum failed",
|
||||
FILE_IN_THE_WAY: "There is a file in the way: %s",
|
||||
UNKNOWN_METHOD: "Invalid/unsupported compression method",
|
||||
|
||||
/* Inflater error messages */
|
||||
AVAIL_DATA: "inflate::Available inflate data did not terminate",
|
||||
INVALID_DISTANCE: "inflate::Invalid literal/length or distance code in fixed or dynamic block",
|
||||
TO_MANY_CODES: "inflate::Dynamic block code description: too many length or distance codes",
|
||||
INVALID_REPEAT_LEN: "inflate::Dynamic block code description: repeat more than specified lengths",
|
||||
INVALID_REPEAT_FIRST: "inflate::Dynamic block code description: repeat lengths with no first length",
|
||||
INCOMPLETE_CODES: "inflate::Dynamic block code description: code lengths codes incomplete",
|
||||
INVALID_DYN_DISTANCE: "inflate::Dynamic block code description: invalid distance code lengths",
|
||||
INVALID_CODES_LEN: "inflate::Dynamic block code description: invalid literal/length code lengths",
|
||||
INVALID_STORE_BLOCK: "inflate::Stored block length did not match one's complement",
|
||||
INVALID_BLOCK_TYPE: "inflate::Invalid block type (type == 3)",
|
||||
|
||||
/* ADM-ZIP error messages */
|
||||
CANT_EXTRACT_FILE: "Could not extract the file",
|
||||
CANT_OVERRIDE: "Target file already exists",
|
||||
NO_ZIP: "No zip file was loaded",
|
||||
NO_ENTRY: "Entry doesn't exist",
|
||||
DIRECTORY_CONTENT_ERROR: "A directory cannot have content",
|
||||
FILE_NOT_FOUND: "File not found: %s",
|
||||
NOT_IMPLEMENTED: "Not implemented",
|
||||
INVALID_FILENAME: "Invalid filename",
|
||||
INVALID_FORMAT: "Invalid or unsupported zip format. No END header found"
|
||||
};
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user