Compare commits

...

85 Commits

Author SHA1 Message Date
Henry Mercer
76621b61de Merge pull request #3019 from github/update-v3.29.8-679a40d33
Merge main into releases/v3
2025-08-08 11:09:06 +01:00
Henry Mercer
29ac3cefbb Add release notes for 3.29.7 2025-08-08 10:46:17 +01:00
github-actions[bot]
737cfdebe6 Update changelog for v3.29.8 2025-08-08 09:36:40 +00:00
Henry Mercer
679a40d337 Merge pull request #3014 from github/henrymercer/rebuild-dispatch
Enable rebuilding PRs with conflicts
2025-08-08 09:45:36 +01:00
Henry Mercer
6fe50b283a Merge pull request #3015 from github/henrymercer/language-autodetection-workaround
Fix auto-detection of extractors that aren't languages
2025-08-07 21:28:43 +01:00
Henry Mercer
6bc91d64f6 Add changelog note 2025-08-07 21:13:25 +01:00
Henry Mercer
6b4fedca4f Bump Action patch version 2025-08-07 21:12:21 +01:00
Henry Mercer
5794ffcb4a Fix auto-detection of extractors that aren't languages 2025-08-07 21:09:22 +01:00
Henry Mercer
bd62bf449c Finish in-progress merges 2025-08-07 18:21:57 +01:00
Henry Mercer
2afb4e6f3c Avoid specifying branch unnecessarily 2025-08-07 17:51:55 +01:00
Henry Mercer
1fd38a4712 Improve logging 2025-08-07 17:50:25 +01:00
Henry Mercer
bf301d1b77 Finish merge if in progress 2025-08-07 17:46:04 +01:00
Henry Mercer
2ee230f7c4 Update .github/workflows/rebuild.yml 2025-08-07 17:34:44 +01:00
Henry Mercer
3425bf931d Use updated output API 2025-08-07 17:21:48 +01:00
Henry Mercer
ddc8e21357 Allow running rebuild workflow on workflow dispatch 2025-08-07 16:52:41 +01:00
Chuan-kai Lin
afbbdf51df Merge pull request #3013 from github/mergeback/v3.29.6-to-main-a4e1a019
Mergeback v3.29.6 refs/heads/releases/v3 into main
2025-08-07 08:30:35 -07:00
github-actions[bot]
e1be6ef300 Update checked-in dependencies 2025-08-07 15:08:18 +00:00
github-actions[bot]
3c7d12c160 Update changelog and version after v3.29.6 2025-08-07 15:06:41 +00:00
Chuan-kai Lin
a4e1a019f5 Merge pull request #3012 from github/update-v3.29.6-67a6ea72b
Merge main into releases/v3
2025-08-07 08:06:12 -07:00
Henry Mercer
4a32399f5f Merge pull request #3011 from github/henrymercer/prefer-injecting-codeql
Prefer providing CodeQL via dependency injection
2025-08-07 15:45:58 +01:00
github-actions[bot]
c587f0a77d Update changelog for v3.29.6 2025-08-07 14:44:41 +00:00
Henry Mercer
8e6104d51e Merge branch 'main' into henrymercer/prefer-injecting-codeql 2025-08-07 15:32:20 +01:00
Henry Mercer
67a6ea72bf Merge pull request #3010 from github/henrymercer/cleanup-for-mrva
Clean up the database if it will be uploaded
2025-08-07 15:31:02 +01:00
Paolo Tranquilli
588ff737e7 Merge pull request #3005 from github/redsun82/unsupported-plat
Make all errors on an unsupported platform `ConfigurationError`s
2025-08-07 16:24:35 +02:00
Henry Mercer
239ed87059 Fix bad merge 2025-08-07 15:10:28 +01:00
Henry Mercer
8c8bdce638 Update log message for cleanup 2025-08-07 15:09:42 +01:00
Henry Mercer
b7beff905a Merge branch 'main' into henrymercer/cleanup-for-mrva 2025-08-07 15:06:26 +01:00
Henry Mercer
6422cf7859 Simplify: Remove databaseCleanup 2025-08-07 15:05:29 +01:00
Henry Mercer
eddeaf42e5 Update changelog note 2025-08-07 15:03:03 +01:00
Paolo Tranquilli
739fb03359 Merge branch 'main' into redsun82/unsupported-plat 2025-08-07 15:47:22 +02:00
Paolo Tranquilli
bb56324516 Address review 2025-08-07 15:43:56 +02:00
Michael B. Gale
bc90418e92 Merge pull request #3009 from github/mbg/auto-detect-actions
Support auto-detecting Actions workflows
2025-08-07 12:58:47 +01:00
Michael B. Gale
f28436bcbf Update log message in getRawLanguagesInRepo 2025-08-07 12:43:21 +01:00
Henry Mercer
f8c2086872 Prefer providing CodeQL via dependency injection 2025-08-07 12:16:00 +01:00
Henry Mercer
c7884c6fd8 Clean up the database if it will be uploaded 2025-08-07 11:47:45 +01:00
Michael B. Gale
a625e1693a Merge pull request #3003 from github/mbg/rewrite-quality-category
Rewrite legacy SARIF categories for CQ
2025-08-07 11:30:12 +01:00
Michael B. Gale
5e22b5feee Merge pull request #3007 from github/dependabot/npm_and_yarn/npm_and_yarn-5a0513363d
Bump tmp from 0.2.3 to 0.2.4 in the npm_and_yarn group
2025-08-07 11:25:38 +01:00
Michael B. Gale
0d72a5b371 Check that stats isn't undefined before trying to call isDirectory 2025-08-07 11:25:01 +01:00
Michael B. Gale
43638b10a0 Support auto-detecting Actions workflows 2025-08-07 11:04:21 +01:00
Paolo Tranquilli
1cfc0c2621 Add tests for cli-errors and fix one bug
Tests were added with copilot, and uncovered a bug where one of the
regexps looking for `[autobuild]` was not escaping the square brackets.
2025-08-07 09:55:59 +02:00
Paolo Tranquilli
7b33b610d4 Make all errors on an unsupported platform ConfigurationErrors 2025-08-07 09:53:36 +02:00
Chuan-kai Lin
e2b6f0f4a3 Merge pull request #3000 from github/update-bundle/codeql-bundle-v2.22.3
Update default bundle to 2.22.3
2025-08-06 13:25:55 -07:00
Chuan-kai Lin
ec8d9c637a Merge branch 'main' into update-bundle/codeql-bundle-v2.22.3 2025-08-06 10:44:20 -07:00
github-actions[bot]
6db9524876 Update checked-in dependencies 2025-08-06 17:24:01 +00:00
dependabot[bot]
ae2a79254b Bump tmp from 0.2.3 to 0.2.4 in the npm_and_yarn group
Bumps the npm_and_yarn group with 1 update: [tmp](https://github.com/raszi/node-tmp).


Updates `tmp` from 0.2.3 to 0.2.4
- [Changelog](https://github.com/raszi/node-tmp/blob/master/CHANGELOG.md)
- [Commits](https://github.com/raszi/node-tmp/compare/v0.2.3...v0.2.4)

---
updated-dependencies:
- dependency-name: tmp
  dependency-version: 0.2.4
  dependency-type: indirect
  dependency-group: npm_and_yarn
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-06 17:23:23 +00:00
Michael B. Gale
2d082457bf Update src/analyze.ts
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-08-06 16:33:06 +01:00
Michael B. Gale
594623d72f Fix linter errors 2025-08-06 16:19:09 +01:00
Michael B. Gale
e448add687 Merge branch 'main' into mbg/rewrite-quality-category 2025-08-06 16:16:22 +01:00
Michael B. Gale
1b76c0b9c1 Use withMockedEnv 2025-08-06 12:39:35 +01:00
Henry Mercer
b1228d060c Merge pull request #3004 from github/mbg/missing-query-pack-config-error
Treat missing pack errors as configuration errors
2025-08-06 12:22:06 +01:00
Michael B. Gale
c87fc48ec5 Treat missing pack errors as configuration errors 2025-08-06 12:09:30 +01:00
Michael B. Gale
9fb8f2d0c2 Update src/actions-util.ts
Co-authored-by: Henry Mercer <henrymercer@github.com>
2025-08-06 10:38:34 +01:00
Michael B. Gale
72770345eb Fix legacy SARIF categories for CQ in default setup 2025-08-06 10:14:36 +01:00
Michael B. Gale
f5d3601aaa Make SARIF category a parameter of runInterpretResults 2025-08-06 09:58:48 +01:00
Michael B. Gale
06e521573a Log qualityAnalysisSummary after analysisSummary 2025-08-06 09:58:31 +01:00
Henry Mercer
60bf7dfc0e Merge pull request #2914 from github/henrymercer/language-extensibility
Allow using new CodeQL languages without updating the CodeQL Action
2025-08-06 09:38:35 +01:00
Henry Mercer
f30d00fe8d Update Language doc 2025-08-06 09:23:40 +01:00
Henry Mercer
377976a96e Improve type of trapCaches now Language is non-exhaustive 2025-08-05 18:09:37 +01:00
Henry Mercer
ea05bf27b6 Use more explicit checks on .length for readability 2025-08-05 17:55:50 +01:00
Henry Mercer
e682065360 Fix docstring in start-proxy 2025-08-05 17:51:51 +01:00
Henry Mercer
fa18cc9db4 Improve docstrings for language types 2025-08-05 17:49:01 +01:00
Henry Mercer
bf692c08e7 Merge branch 'main' into henrymercer/language-extensibility 2025-08-05 13:21:29 +01:00
Henry Mercer
83e92edc4b Improve detection of Rust in languages input 2025-08-05 11:43:04 +01:00
Henry Mercer
bbfff2f20a Merge pull request #2999 from github/henrymercer/deprecate-cleanup-level
Deprecate the 'cleanup-level' option
2025-08-05 11:22:53 +01:00
Henry Mercer
cfb8d07200 Remove unnecessary String initializations
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-08-05 11:18:46 +01:00
Henry Mercer
87e59d0f95 Improve changelog formatting
Co-authored-by: Michael B. Gale <mbg@github.com>
2025-08-05 11:08:19 +01:00
Henry Mercer
c481481d7d Merge branch 'main' into henrymercer/language-extensibility 2025-08-05 11:07:39 +01:00
Henry Mercer
e37c03628f Merge pull request #3001 from github/dependabot/npm_and_yarn/npm-5c47c8ab2f
Bump the npm group with 5 updates
2025-08-05 11:05:58 +01:00
github-actions[bot]
563cbbb24d Update checked-in dependencies 2025-08-05 09:51:38 +00:00
Henry Mercer
443f94c758 Bump @types/node 2025-08-05 10:45:17 +01:00
Henry Mercer
a5cdb299bc Merge pull request #3002 from github/dependabot/github_actions/actions-f69d1f6078
Bump ruby/setup-ruby from 1.253.0 to 1.254.0 in the actions group
2025-08-05 10:27:07 +01:00
Henry Mercer
5547ed31c9 Bump version in generated source 2025-08-05 10:14:47 +01:00
dependabot[bot]
69ccd54e34 Bump ruby/setup-ruby from 1.253.0 to 1.254.0 in the actions group
Bumps the actions group with 1 update: [ruby/setup-ruby](https://github.com/ruby/setup-ruby).


Updates `ruby/setup-ruby` from 1.253.0 to 1.254.0
- [Release notes](https://github.com/ruby/setup-ruby/releases)
- [Changelog](https://github.com/ruby/setup-ruby/blob/master/release.rb)
- [Commits](bb6434c747...2a7b30092b)

---
updated-dependencies:
- dependency-name: ruby/setup-ruby
  dependency-version: 1.254.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-04 23:16:04 +00:00
github-actions[bot]
a3810fa54b Update checked-in dependencies 2025-08-04 22:26:01 +00:00
dependabot[bot]
a28b9b5e2f Bump the npm group with 5 updates
Bumps the npm group with 5 updates:

| Package | From | To |
| --- | --- | --- |
| [follow-redirects](https://github.com/follow-redirects/follow-redirects) | `1.15.9` | `1.15.11` |
| [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin) | `8.38.0` | `8.39.0` |
| [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) | `8.38.0` | `8.39.0` |
| [nock](https://github.com/nock/nock) | `14.0.7` | `14.0.8` |
| [typescript](https://github.com/microsoft/TypeScript) | `5.8.3` | `5.9.2` |


Updates `follow-redirects` from 1.15.9 to 1.15.11
- [Release notes](https://github.com/follow-redirects/follow-redirects/releases)
- [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.15.9...v1.15.11)

Updates `@typescript-eslint/eslint-plugin` from 8.38.0 to 8.39.0
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.39.0/packages/eslint-plugin)

Updates `@typescript-eslint/parser` from 8.38.0 to 8.39.0
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v8.39.0/packages/parser)

Updates `nock` from 14.0.7 to 14.0.8
- [Release notes](https://github.com/nock/nock/releases)
- [Changelog](https://github.com/nock/nock/blob/main/CHANGELOG.md)
- [Commits](https://github.com/nock/nock/compare/v14.0.7...v14.0.8)

Updates `typescript` from 5.8.3 to 5.9.2
- [Release notes](https://github.com/microsoft/TypeScript/releases)
- [Changelog](https://github.com/microsoft/TypeScript/blob/main/azure-pipelines.release-publish.yml)
- [Commits](https://github.com/microsoft/TypeScript/compare/v5.8.3...v5.9.2)

---
updated-dependencies:
- dependency-name: follow-redirects
  dependency-version: 1.15.11
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: npm
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-version: 8.39.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: npm
- dependency-name: "@typescript-eslint/parser"
  dependency-version: 8.39.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: npm
- dependency-name: nock
  dependency-version: 14.0.8
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: npm
- dependency-name: typescript
  dependency-version: 5.9.2
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: npm
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-04 22:25:25 +00:00
github-actions[bot]
fff9bbe33f Add changelog note 2025-08-04 18:41:52 +00:00
github-actions[bot]
cfa0a4e416 Update default bundle to codeql-bundle-v2.22.3 2025-08-04 18:41:48 +00:00
Henry Mercer
f9d6919415 Add changelog note 2025-08-04 18:00:50 +01:00
Henry Mercer
e95a3a9768 Deprecate the 'cleanup-level' option 2025-08-04 17:52:09 +01:00
Henry Mercer
a28197c30c Fix early return for no autobuild languages 2025-05-30 18:11:05 +01:00
Henry Mercer
1d22e8316c Rust: Set experimental features variable before language parsing 2025-05-30 18:09:25 +01:00
Henry Mercer
932be8feda Rename Language enum and use generic Language where possible 2025-05-30 18:02:15 +01:00
Henry Mercer
e303175b83 Use CodeQL CLI to parse languages 2025-05-30 18:02:14 +01:00
Henry Mercer
fa0b6fff20 Clarify meaning of Language enum 2025-05-30 17:58:20 +01:00
Henry Mercer
3b57965c44 Remove per-language hardcoded traced/scanned info 2025-05-30 17:58:19 +01:00
467 changed files with 50977 additions and 72239 deletions

View File

@@ -46,7 +46,7 @@ jobs:
use-all-platform-bundle: 'false'
setup-kotlin: 'true'
- name: Set up Ruby
uses: ruby/setup-ruby@bb6434c747fa7022e12fa1cae2a0951fcffcff26 # v1.253.0
uses: ruby/setup-ruby@2a7b30092b0caf9c046252510f9273b4875f3db9 # v1.254.0
with:
ruby-version: 2.6
- name: Install Code Scanning integration

View File

@@ -9,7 +9,7 @@ jobs:
rebuild:
name: Rebuild Action
runs-on: ubuntu-latest
if: github.event.label.name == 'Rebuild'
if: github.event.label.name == 'Rebuild' || github.event_name == 'workflow_dispatch'
permissions:
contents: write # needed to push rebuilt commit
@@ -18,9 +18,11 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref || github.event.ref }}
- name: Remove label
if: github.event_name == 'pull_request'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
@@ -28,21 +30,35 @@ jobs:
gh pr edit --repo github/codeql-action "$PR_NUMBER" \
--remove-label "Rebuild"
- name: Configure git
run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Merge in changes from base branch
id: merge
env:
BASE_BRANCH: ${{ github.event.pull_request.base.ref }}
BASE_BRANCH: ${{ github.event.pull_request.base.ref || 'main' }}
run: |
git fetch origin "$BASE_BRANCH"
# Allow merge conflicts in `lib`, since rebuilding should resolve them.
git merge "origin/$BASE_BRANCH" || echo "Merge conflicts detected"
git merge "origin/$BASE_BRANCH" || echo "Merge conflicts detected, continuing."
MERGE_RESULT=$?
# Check for merge conflicts outside of `lib`. Disable git diff's trailing whitespace check
# since `node_modules/@types/semver/README.md` fails it.
if git -c core.whitespace=-trailing-space diff --check | grep --invert-match '^lib/'; then
echo "Merge conflicts detected outside of lib/ directory. Please resolve them manually."
git -c core.whitespace=-trailing-space diff --check | grep --invert-match '^lib/' || true
exit 1
if [ "$MERGE_RESULT" -ne 0 ]; then
echo "merge-in-progress=true" >> $GITHUB_OUTPUT
# Check for merge conflicts outside of `lib`. Disable git diff's trailing whitespace check
# since `node_modules/@types/semver/README.md` fails it.
if git -c core.whitespace=-trailing-space diff --check | grep --invert-match '^lib/'; then
echo "Merge conflicts were detected outside of the lib directory. Please resolve them manually."
git -c core.whitespace=-trailing-space diff --check | grep --invert-match '^lib/' || true
exit 1
fi
echo "No merge conflicts found outside the lib directory. We should be able to resolve all of" \
"these by rebuilding the Action."
fi
- name: Compile TypeScript
@@ -63,20 +79,49 @@ jobs:
pip install ruamel.yaml==0.17.31
python3 sync.py
- name: Check for changes and push
- name: "Merge in progress: Finish merge and push"
if: steps.merge.outputs.merge-in-progress == 'true'
run: |
echo "Finishing merge and pushing changes."
git add --all
git commit --no-edit
git push
- name: "No merge in progress: Check for changes and push"
if: steps.merge.outputs.merge-in-progress != 'true'
id: push
run: |
if [ ! -z "$(git status --porcelain)" ]; then
echo "Changes detected, committing and pushing."
git add --all
# If the merge originally had conflicts, finish the merge.
# Otherwise, just commit the changes.
if git rev-parse --verify MERGE_HEAD >/dev/null 2>&1; then
echo "In progress merge detected, finishing it up."
git merge --continue
else
echo "No in-progress merge detected, committing changes."
git commit -m "Rebuild"
fi
echo "Pushing changes"
git push
echo "changes=true" >> $GITHUB_OUTPUT
else
echo "No changes detected, nothing to commit."
fi
- name: Notify about rebuild
if: >-
github.event_name == 'pull_request' &&
(
steps.merge.outputs.merge-in-progress == 'true' ||
steps.push.outputs.changes == 'true'
)
env:
BRANCH: ${{ github.event.pull_request.head.ref }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
if [ ! -z "$(git status --porcelain)" ]; then
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git add --all
git commit -m "Rebuild"
git push origin "HEAD:$BRANCH"
echo "Pushed a commit to rebuild the Action." \
"Please mark the PR as ready for review to trigger PR checks." |
gh pr comment --body-file - --repo github/codeql-action "$PR_NUMBER"
gh pr ready --undo --repo github/codeql-action "$PR_NUMBER"
fi
echo "Pushed a commit to rebuild the Action." \
"Please mark the PR as ready for review to trigger PR checks." |
gh pr comment --body-file - --repo github/codeql-action "$PR_NUMBER"
gh pr ready --undo --repo github/codeql-action "$PR_NUMBER"

View File

@@ -2,9 +2,18 @@
See the [releases page](https://github.com/github/codeql-action/releases) for the relevant changes to the CodeQL CLI and language packs.
## [UNRELEASED]
## 3.29.8 - 08 Aug 2025
No user facing changes.
- Fix an issue where the Action would autodetect unsupported languages such as HTML. [#3015](https://github.com/github/codeql-action/pull/3015)
## 3.29.7 - 07 Aug 2025
This release rolls back 3.29.6 to address issues with language autodetection. It is identical to 3.29.5.
## 3.29.6 - 07 Aug 2025
- The `cleanup-level` input to the `analyze` Action is now deprecated. The CodeQL Action has written a limited amount of intermediate results to the database since version 2.2.5, and now automatically manages cleanup. [#2999](https://github.com/github/codeql-action/pull/2999)
- Update default CodeQL bundle version to 2.22.3. [#3000](https://github.com/github/codeql-action/pull/3000)
## 3.29.5 - 29 Jul 2025

View File

@@ -19,9 +19,10 @@ inputs:
# If changing this, make sure to update workflow.ts accordingly.
default: "always"
cleanup-level:
description: "Level of cleanup to perform on CodeQL databases at the end of the analyze step. This should either be 'none' to skip cleanup, or be a valid argument for the --cache-cleanup flag of the CodeQL CLI command 'codeql database cleanup' as documented at https://codeql.github.com/docs/codeql-cli/manual/database-cleanup"
description: >-
DEPRECATED. This option is ignored since, for performance reasons, the CodeQL Action no longer saves
intermediate results during evaluation.
required: false
default: "brutal"
ram:
description: >-
The amount of memory in MB that can be used by CodeQL for database finalization and query execution.

View File

@@ -138,6 +138,7 @@ export default [
rules: {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-enum-comparison": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/prefer-regexp-exec": "off",

37
lib/actions-util.js generated
View File

@@ -51,6 +51,7 @@ exports.ensureEndsInPeriod = ensureEndsInPeriod;
exports.runTool = runTool;
exports.getPullRequestBranches = getPullRequestBranches;
exports.isAnalyzingPullRequest = isAnalyzingPullRequest;
exports.fixCodeQualityCategory = fixCodeQualityCategory;
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
const core = __importStar(require("@actions/core"));
@@ -264,7 +265,7 @@ function prettyPrintInvocation(cmd, args) {
* An error from a tool invocation, with associated exit code, stderr, etc.
*/
class CommandInvocationError extends Error {
constructor(cmd, args, exitCode, stderr, stdout) {
constructor(cmd, args, exitCode, stderr, stdout = "") {
const prettyCommand = prettyPrintInvocation(cmd, args);
const lastLine = ensureEndsInPeriod(stderr.trim().split("\n").pop()?.trim() || "n/a");
super(`Failed to run "${prettyCommand}". ` +
@@ -392,4 +393,38 @@ function getPullRequestBranches() {
function isAnalyzingPullRequest() {
return getPullRequestBranches() !== undefined;
}
/**
* A workaround for code quality to map category names from old default setup workflows
* to ones that the code quality service expects.
*/
const qualityCategoryMapping = {
"c#": "csharp",
cpp: "c-cpp",
c: "c-cpp",
"c++": "c-cpp",
java: "java-kotlin",
javascript: "javascript-typescript",
typescript: "javascript-typescript",
kotlin: "java-kotlin",
};
/** Adjusts the category string for a Code Quality SARIF file if an "old"
* category identifier is used by Default Setup.
*/
function fixCodeQualityCategory(logger, category) {
// The `category` should always be set by Default Setup. We perform this check
// to avoid potential issues if Code Quality supports Advanced Setup in the future
// and before this workaround is removed.
if (category !== undefined &&
isDefaultSetup() &&
category.startsWith("/language:")) {
const language = category.substring("/language:".length);
const mappedLanguage = qualityCategoryMapping[language];
if (mappedLanguage) {
const newCategory = `/language:${mappedLanguage}`;
logger.info(`Adjusted category for Code Quality from '${category}' to '${newCategory}'.`);
return newCategory;
}
}
return category;
}
//# sourceMappingURL=actions-util.js.map

File diff suppressed because one or more lines are too long

View File

@@ -41,6 +41,7 @@ const ava_1 = __importDefault(require("ava"));
const actions_util_1 = require("./actions-util");
const api_client_1 = require("./api-client");
const environment_1 = require("./environment");
const logging_1 = require("./logging");
const testing_utils_1 = require("./testing-utils");
const util_1 = require("./util");
(0, testing_utils_1.setupTests)(ava_1.default);
@@ -165,4 +166,27 @@ function withMockedEnv(envVars, testFn) {
(0, util_1.initializeEnvironment)("1.2.3");
t.deepEqual(process.env[environment_1.EnvVar.VERSION], "1.2.3");
});
(0, ava_1.default)("fixCodeQualityCategory", (t) => {
withMockedEnv({
GITHUB_EVENT_NAME: "dynamic",
}, () => {
const logger = (0, logging_1.getRunnerLogger)(true);
// Categories that should get adjusted.
t.is((0, actions_util_1.fixCodeQualityCategory)(logger, "/language:c#"), "/language:csharp");
t.is((0, actions_util_1.fixCodeQualityCategory)(logger, "/language:cpp"), "/language:c-cpp");
t.is((0, actions_util_1.fixCodeQualityCategory)(logger, "/language:c"), "/language:c-cpp");
t.is((0, actions_util_1.fixCodeQualityCategory)(logger, "/language:java"), "/language:java-kotlin");
t.is((0, actions_util_1.fixCodeQualityCategory)(logger, "/language:javascript"), "/language:javascript-typescript");
t.is((0, actions_util_1.fixCodeQualityCategory)(logger, "/language:typescript"), "/language:javascript-typescript");
t.is((0, actions_util_1.fixCodeQualityCategory)(logger, "/language:kotlin"), "/language:java-kotlin");
// Categories that should not get adjusted.
t.is((0, actions_util_1.fixCodeQualityCategory)(logger, "/language:csharp"), "/language:csharp");
t.is((0, actions_util_1.fixCodeQualityCategory)(logger, "/language:go"), "/language:go");
t.is((0, actions_util_1.fixCodeQualityCategory)(logger, "/language:actions"), "/language:actions");
// Other cases.
t.is((0, actions_util_1.fixCodeQualityCategory)(logger, undefined), undefined);
t.is((0, actions_util_1.fixCodeQualityCategory)(logger, "random string"), "random string");
t.is((0, actions_util_1.fixCodeQualityCategory)(logger, "kotlin"), "kotlin");
});
});
//# sourceMappingURL=actions-util.test.js.map

File diff suppressed because one or more lines are too long

View File

@@ -78,7 +78,6 @@ const util = __importStar(require("./util"));
requiredInputStub.withArgs("upload-database").returns("false");
requiredInputStub.withArgs("output").returns("out");
const optionalInputStub = sinon.stub(actionsUtil, "getOptionalInput");
optionalInputStub.withArgs("cleanup-level").returns("none");
optionalInputStub.withArgs("expect-error").returns("false");
sinon.stub(api, "getGitHubVersion").resolves(gitHubVersion);
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
@@ -97,8 +96,10 @@ const util = __importStar(require("./util"));
// runFinalize and runQueries are correctly captured by spies, we explicitly
// wait for the action promise to complete before starting verification.
await analyzeAction.runPromise;
t.assert(runFinalizeStub.calledOnce);
t.deepEqual(runFinalizeStub.firstCall.args[1], "--threads=-1");
t.deepEqual(runFinalizeStub.firstCall.args[2], "--ram=4992");
t.assert(runQueriesStub.calledOnce);
t.deepEqual(runQueriesStub.firstCall.args[3], "--threads=-1");
t.deepEqual(runQueriesStub.firstCall.args[1], "--ram=4992");
});

View File

@@ -1 +1 @@
{"version":3,"file":"analyze-action-env.test.js","sourceRoot":"","sources":["../src/analyze-action-env.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAuB;AACvB,6CAA+B;AAE/B,4DAA8C;AAC9C,mDAAqC;AACrC,kDAAoC;AACpC,4DAA8C;AAC9C,sDAAwC;AACxC,8DAAgD;AAChD,mDAIyB;AACzB,6CAA+B;AAE/B,IAAA,0BAAU,EAAC,aAAI,CAAC,CAAC;AAEjB,4EAA4E;AAC5E,4EAA4E;AAC5E,+EAA+E;AAC/E,+EAA+E;AAC/E,gFAAgF;AAChF,iCAAiC;AAEjC,IAAA,aAAI,EAAC,8DAA8D,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAC/E,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QACrC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,GAAG,IAAI,CAAC,iBAAiB,CAAC;QAC1D,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,GAAG,sCAAsC,CAAC;QAC1E,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,GAAG,wBAAwB,CAAC;QACzD,KAAK;aACF,IAAI,CAAC,YAAY,EAAE,wBAAwB,CAAC;aAC5C,QAAQ,CAAC,EAAmC,CAAC,CAAC;QACjD,KAAK,CAAC,IAAI,CAAC,YAAY,EAAE,kBAAkB,CAAC,CAAC,QAAQ,EAAE,CAAC;QACxD,KAAK,CAAC,IAAI,CAAC,QAAQ,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CAAC;QACpC,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;QAC9D,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}

View File

@@ -77,7 +77,6 @@ const util = __importStar(require("./util"));
requiredInputStub.withArgs("upload-database").returns("false");
requiredInputStub.withArgs("output").returns("out");
const optionalInputStub = sinon.stub(actionsUtil, "getOptionalInput");
optionalInputStub.withArgs("cleanup-level").returns("none");
optionalInputStub.withArgs("expect-error").returns("false");
sinon.stub(api, "getGitHubVersion").resolves(gitHubVersion);
sinon.stub(gitUtils, "isAnalyzingDefaultBranch").resolves(true);
@@ -97,8 +96,10 @@ const util = __importStar(require("./util"));
// runFinalize and runQueries are correctly captured by spies, we explicitly
// wait for the action promise to complete before starting verification.
await analyzeAction.runPromise;
t.assert(runFinalizeStub.calledOnce);
t.deepEqual(runFinalizeStub.firstCall.args[1], "--threads=-1");
t.deepEqual(runFinalizeStub.firstCall.args[2], "--ram=3012");
t.assert(runQueriesStub.calledOnce);
t.deepEqual(runQueriesStub.firstCall.args[3], "--threads=-1");
t.deepEqual(runQueriesStub.firstCall.args[1], "--ram=3012");
});

View File

@@ -1 +1 @@
{"version":3,"file":"analyze-action-input.test.js","sourceRoot":"","sources":["../src/analyze-action-input.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAuB;AACvB,6CAA+B;AAE/B,4DAA8C;AAC9C,mDAAqC;AACrC,kDAAoC;AACpC,4DAA8C;AAC9C,sDAAwC;AACxC,8DAAgD;AAChD,mDAIyB;AACzB,6CAA+B;AAE/B,IAAA,0BAAU,EAAC,aAAI,CAAC,CAAC;AAEjB,4EAA4E;AAC5E,4EAA4E;AAC5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,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,MAAM,CAAC;QAEnC,4DAA4D;QAC5D,iBAAiB,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACpD,iBAAiB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAElD,MAAM,eAAe,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QAC3D,MAAM,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;QACzD,iEAAiE;QACjE,MAAM,aAAa,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;QAElD,uEAAuE;QACvE,oEAAoE;QACpE,4EAA4E;QAC5E,wEAAwE;QACxE,MAAM,aAAa,CAAC,UAAU,CAAC;QAE/B,CAAC,CAAC,MAAM,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;QACrC,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;QAC/D,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;QAC7D,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;QACpC,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;QAC9D,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}

37
lib/analyze-action.js generated
View File

@@ -95,8 +95,8 @@ function hasBadExpectErrorInput() {
* indicating whether Go extraction has extracted at least one file.
*/
function doesGoExtractionOutputExist(config) {
const golangDbDirectory = util.getCodeQLDatabasePath(config, languages_1.Language.go);
const trapDirectory = path_1.default.join(golangDbDirectory, "trap", languages_1.Language.go);
const golangDbDirectory = util.getCodeQLDatabasePath(config, languages_1.KnownLanguage.go);
const trapDirectory = path_1.default.join(golangDbDirectory, "trap", languages_1.KnownLanguage.go);
return (fs.existsSync(trapDirectory) &&
fs
.readdirSync(trapDirectory)
@@ -123,7 +123,7 @@ function doesGoExtractionOutputExist(config) {
* whether any extraction output already exists for Go.
*/
async function runAutobuildIfLegacyGoWorkflow(config, logger) {
if (!config.languages.includes(languages_1.Language.go)) {
if (!config.languages.includes(languages_1.KnownLanguage.go)) {
return;
}
if (config.buildMode) {
@@ -134,7 +134,7 @@ async function runAutobuildIfLegacyGoWorkflow(config, logger) {
logger.debug("Won't run Go autobuild since it has already been run.");
return;
}
if ((0, analyze_1.dbIsFinalized)(config, languages_1.Language.go, logger)) {
if ((0, analyze_1.dbIsFinalized)(config, languages_1.KnownLanguage.go, logger)) {
logger.debug("Won't run Go autobuild since there is already a finalized database for Go.");
return;
}
@@ -149,7 +149,7 @@ async function runAutobuildIfLegacyGoWorkflow(config, logger) {
return;
}
logger.debug("Running Go autobuild because extraction output (TRAP files) for Go code has not been found.");
await (0, autobuild_1.runAutobuild)(config, languages_1.Language.go, logger);
await (0, autobuild_1.runAutobuild)(config, languages_1.KnownLanguage.go, logger);
}
async function run() {
const startedAt = new Date();
@@ -186,6 +186,10 @@ async function run() {
if (hasBadExpectErrorInput()) {
throw new util.ConfigurationError("`expect-error` input parameter is for internal use only. It should only be set by codeql-action or a fork.");
}
if (actionsUtil.getOptionalInput("cleanup-level") !== "") {
logger.info("The 'cleanup-level' input is ignored since the CodeQL Action now automatically " +
"manages database cleanup. This input can safely be removed from your workflow.");
}
const apiDetails = (0, api_client_1.getApiDetails)();
const outputDir = actionsUtil.getRequiredInput("output");
core.exportVariable(environment_1.EnvVar.SARIF_RESULTS_OUTPUT_DIR, outputDir);
@@ -202,19 +206,8 @@ async function run() {
await (0, analyze_1.warnIfGoInstalledAfterInit)(config, logger);
await runAutobuildIfLegacyGoWorkflow(config, logger);
dbCreationTimings = await (0, analyze_1.runFinalize)(outputDir, threads, memory, codeql, config, logger);
// An overlay-base database should always use the 'overlay' cleanup level
// to preserve the cached intermediate results.
//
// Note that we may be overriding the 'cleanup-level' input parameter.
const cleanupLevel = config.augmentationProperties.overlayDatabaseMode ===
overlay_database_utils_1.OverlayDatabaseMode.OverlayBase
? "overlay"
: actionsUtil.getOptionalInput("cleanup-level") || "brutal";
if (actionsUtil.getRequiredInput("skip-queries") !== "true") {
runStats = await (0, analyze_1.runQueries)(outputDir, memory, util.getAddSnippetsFlag(actionsUtil.getRequiredInput("add-snippets")), threads, cleanupLevel, diffRangePackDir, actionsUtil.getOptionalInput("category"), config, logger, features);
}
if (cleanupLevel !== "none") {
await (0, analyze_1.runCleanup)(config, cleanupLevel, logger);
runStats = await (0, analyze_1.runQueries)(outputDir, memory, util.getAddSnippetsFlag(actionsUtil.getRequiredInput("add-snippets")), threads, diffRangePackDir, actionsUtil.getOptionalInput("category"), codeql, config, logger, features);
}
const dbLocations = {};
for (const language of config.languages) {
@@ -227,17 +220,19 @@ async function run() {
uploadResult = await uploadLib.uploadFiles(outputDir, actionsUtil.getRequiredInput("checkout_path"), actionsUtil.getOptionalInput("category"), features, logger, uploadLib.CodeScanningTarget);
core.setOutput("sarif-id", uploadResult.sarifID);
if (config.augmentationProperties.qualityQueriesInput !== undefined) {
const qualityUploadResult = await uploadLib.uploadFiles(outputDir, actionsUtil.getRequiredInput("checkout_path"), actionsUtil.getOptionalInput("category"), features, logger, uploadLib.CodeQualityTarget);
const qualityUploadResult = await uploadLib.uploadFiles(outputDir, actionsUtil.getRequiredInput("checkout_path"), actionsUtil.fixCodeQualityCategory(logger, actionsUtil.getOptionalInput("category")), features, logger, uploadLib.CodeQualityTarget);
core.setOutput("quality-sarif-id", qualityUploadResult.sarifID);
}
}
else {
logger.info("Not uploading results");
}
// Possibly upload the database bundles for remote queries
await (0, database_upload_1.uploadDatabases)(repositoryNwo, config, apiDetails, logger);
// Possibly upload the overlay-base database to actions cache
// Possibly upload the overlay-base database to actions cache.
// If databases are to be uploaded, they will first be cleaned up at the overlay level.
await (0, overlay_database_utils_1.uploadOverlayBaseDatabaseToCache)(codeql, config, logger);
// Possibly upload the database bundles for remote queries.
// If databases are to be uploaded, they will first be cleaned up at the clear level.
await (0, database_upload_1.uploadDatabases)(repositoryNwo, codeql, config, apiDetails, logger);
// Possibly upload the TRAP caches for later re-use
const trapCacheUploadStartTime = perf_hooks_1.performance.now();
didUploadTrapCaches = await (0, trap_caching_1.uploadTrapCaches)(codeql, config, logger);

File diff suppressed because one or more lines are too long

48
lib/analyze.js generated
View File

@@ -44,7 +44,6 @@ exports.resolveQuerySuiteAlias = resolveQuerySuiteAlias;
exports.runQueries = runQueries;
exports.runFinalize = runFinalize;
exports.warnIfGoInstalledAfterInit = warnIfGoInstalledAfterInit;
exports.runCleanup = runCleanup;
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
const perf_hooks_1 = require("perf_hooks");
@@ -54,7 +53,6 @@ const yaml = __importStar(require("js-yaml"));
const actions_util_1 = require("./actions-util");
const api_client_1 = require("./api-client");
const autobuild_1 = require("./autobuild");
const codeql_1 = require("./codeql");
const dependency_caching_1 = require("./dependency-caching");
const diagnostics_1 = require("./diagnostics");
const diff_informed_analysis_utils_1 = require("./diff-informed-analysis-utils");
@@ -93,13 +91,13 @@ async function runExtraction(codeql, config, logger) {
logger.debug(`Database for ${language} has already been finalized, skipping extraction.`);
continue;
}
if (shouldExtractLanguage(config, language)) {
if (await shouldExtractLanguage(codeql, config, language)) {
logger.startGroup(`Extracting ${language}`);
if (language === languages_1.Language.python) {
if (language === languages_1.KnownLanguage.python) {
await setupPythonExtractor(logger);
}
if (config.buildMode) {
if (language === languages_1.Language.cpp &&
if (language === languages_1.KnownLanguage.cpp &&
config.buildMode === util_1.BuildMode.Autobuild) {
await (0, autobuild_1.setupCppAutobuild)(codeql, logger);
}
@@ -107,7 +105,8 @@ async function runExtraction(codeql, config, logger) {
// database scratch directory by default. For dependency caching purposes, we want
// a stable path that caches can be restored into and that we can cache at the
// end of the workflow (i.e. that does not get removed when the scratch directory is).
if (language === languages_1.Language.java && config.buildMode === util_1.BuildMode.None) {
if (language === languages_1.KnownLanguage.java &&
config.buildMode === util_1.BuildMode.None) {
process.env["CODEQL_EXTRACTOR_JAVA_OPTION_BUILDLESS_DEPENDENCY_DIR"] =
(0, dependency_caching_1.getJavaTempDependencyDir)();
}
@@ -120,11 +119,11 @@ async function runExtraction(codeql, config, logger) {
}
}
}
function shouldExtractLanguage(config, language) {
async function shouldExtractLanguage(codeql, config, language) {
return (config.buildMode === util_1.BuildMode.None ||
(config.buildMode === util_1.BuildMode.Autobuild &&
process.env[environment_1.EnvVar.AUTOBUILD_DID_COMPLETE_SUCCESSFULLY] !== "true") ||
(!config.buildMode && (0, languages_1.isScannedLanguage)(language)));
(!config.buildMode && (await codeql.isScannedLanguage(language))));
}
function dbIsFinalized(config, language, logger) {
const dbPath = util.getCodeQLDatabasePath(config, language);
@@ -410,11 +409,13 @@ function resolveQuerySuiteAlias(language, maybeSuite) {
return maybeSuite;
}
// Runs queries and creates sarif files in the given folder
async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag, cleanupLevel, diffRangePackDir, automationDetailsId, config, logger, features) {
async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag, diffRangePackDir, automationDetailsId, codeql, config, logger, features) {
const statusReport = {};
const queryFlags = [memoryFlag, threadsFlag];
const incrementalMode = [];
if (cleanupLevel !== "overlay") {
// Preserve cached intermediate results for overlay-base databases.
if (config.augmentationProperties.overlayDatabaseMode !==
overlay_database_utils_1.OverlayDatabaseMode.OverlayBase) {
queryFlags.push("--expect-discarded-cache");
}
statusReport.analysis_is_diff_informed = diffRangePackDir !== undefined;
@@ -436,7 +437,6 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
const sarifRunPropertyFlag = incrementalMode.length > 0
? `--sarif-run-property=incrementalMode=${incrementalMode.join(",")}`
: undefined;
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
for (const language of config.languages) {
try {
const sarifFile = path.join(sarifFolder, `${language}.sarif`);
@@ -463,19 +463,22 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
new Date().getTime() - startTimeRunQueries;
logger.startGroup(`Interpreting results for ${language}`);
const startTimeInterpretResults = new Date();
const analysisSummary = await runInterpretResults(language, undefined, sarifFile, config.debugMode);
const analysisSummary = await runInterpretResults(language, undefined, sarifFile, config.debugMode, automationDetailsId);
let qualityAnalysisSummary;
if (config.augmentationProperties.qualityQueriesInput !== undefined) {
logger.info(`Interpreting quality results for ${language}`);
const qualityCategory = (0, actions_util_1.fixCodeQualityCategory)(logger, automationDetailsId);
const qualitySarifFile = path.join(sarifFolder, `${language}.quality.sarif`);
const qualityAnalysisSummary = await runInterpretResults(language, config.augmentationProperties.qualityQueriesInput.map((i) => resolveQuerySuiteAlias(language, i.uses)), qualitySarifFile, config.debugMode);
// TODO: move
logger.info(qualityAnalysisSummary);
qualityAnalysisSummary = await runInterpretResults(language, config.augmentationProperties.qualityQueriesInput.map((i) => resolveQuerySuiteAlias(language, i.uses)), qualitySarifFile, config.debugMode, qualityCategory);
}
const endTimeInterpretResults = new Date();
statusReport[`interpret_results_${language}_duration_ms`] =
endTimeInterpretResults.getTime() - startTimeInterpretResults.getTime();
logger.endGroup();
logger.info(analysisSummary);
if (qualityAnalysisSummary) {
logger.info(qualityAnalysisSummary);
}
if (await features.getValue(feature_flags_1.Feature.QaTelemetryEnabled)) {
const perQueryAlertCounts = getPerQueryAlertCounts(sarifFile);
const perQueryAlertCountEventReport = {
@@ -500,9 +503,9 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
}
}
return statusReport;
async function runInterpretResults(language, queries, sarifFile, enableDebugLogging) {
async function runInterpretResults(language, queries, sarifFile, enableDebugLogging, category) {
const databasePath = util.getCodeQLDatabasePath(config, language);
return await codeql.databaseInterpretResults(databasePath, queries, sarifFile, addSnippetsFlag, threadsFlag, enableDebugLogging ? "-vv" : "-v", sarifRunPropertyFlag, automationDetailsId, config, features);
return await codeql.databaseInterpretResults(databasePath, queries, sarifFile, addSnippetsFlag, threadsFlag, enableDebugLogging ? "-vv" : "-v", sarifRunPropertyFlag, category, config, features);
}
/** Get an object with all queries and their counts parsed from a SARIF file path. */
function getPerQueryAlertCounts(sarifPath) {
@@ -554,7 +557,7 @@ async function warnIfGoInstalledAfterInit(config, logger) {
const goBinaryPath = await io.which("go", true);
if (goInitPath !== goBinaryPath) {
logger.warning(`Expected \`which go\` to return ${goInitPath}, but got ${goBinaryPath}: please ensure that the correct version of Go is installed before the \`codeql-action/init\` Action is used.`);
(0, diagnostics_1.addDiagnostic)(config, languages_1.Language.go, (0, diagnostics_1.makeDiagnostic)("go/workflow/go-installed-after-codeql-init", "Go was installed after the `codeql-action/init` Action was run", {
(0, diagnostics_1.addDiagnostic)(config, languages_1.KnownLanguage.go, (0, diagnostics_1.makeDiagnostic)("go/workflow/go-installed-after-codeql-init", "Go was installed after the `codeql-action/init` Action was run", {
markdownMessage: "To avoid interfering with the CodeQL analysis, perform all installation steps before calling the `github/codeql-action/init` Action.",
visibility: {
statusPage: true,
@@ -566,15 +569,6 @@ async function warnIfGoInstalledAfterInit(config, logger) {
}
}
}
async function runCleanup(config, cleanupLevel, logger) {
logger.startGroup("Cleaning up databases");
for (const language of config.languages) {
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
const databasePath = util.getCodeQLDatabasePath(config, language);
await codeql.databaseCleanup(databasePath, cleanupLevel);
}
logger.endGroup();
}
exports.exportedForTesting = {
getDiffRanges,
};

File diff suppressed because one or more lines are too long

12
lib/analyze.test.js generated
View File

@@ -63,8 +63,8 @@ const util = __importStar(require("./util"));
const addSnippetsFlag = "";
const threadsFlag = "";
sinon.stub(uploadLib, "validateSarifFileSchema");
for (const language of Object.values(languages_1.Language)) {
(0, codeql_1.setCodeQL)({
for (const language of Object.values(languages_1.KnownLanguage)) {
const codeql = (0, codeql_1.createStubCodeQL)({
databaseRunQueries: async () => { },
packDownload: async () => ({ packs: [] }),
databaseInterpretResults: async (_db, _queriesRun, sarifFile) => {
@@ -114,7 +114,7 @@ const util = __importStar(require("./util"));
fs.mkdirSync(util.getCodeQLDatabasePath(config, language), {
recursive: true,
});
const statusReport = await (0, analyze_1.runQueries)(tmpDir, memoryFlag, addSnippetsFlag, threadsFlag, "brutal", undefined, undefined, config, (0, logging_1.getRunnerLogger)(true), (0, testing_utils_1.createFeatures)([feature_flags_1.Feature.QaTelemetryEnabled]));
const statusReport = await (0, analyze_1.runQueries)(tmpDir, memoryFlag, addSnippetsFlag, threadsFlag, undefined, undefined, codeql, config, (0, logging_1.getRunnerLogger)(true), (0, testing_utils_1.createFeatures)([feature_flags_1.Feature.QaTelemetryEnabled]));
t.deepEqual(Object.keys(statusReport).sort(), [
"analysis_builds_overlay_base_database",
"analysis_is_diff_informed",
@@ -318,14 +318,14 @@ function runGetDiffRanges(changes, patch) {
(0, ava_1.default)("resolveQuerySuiteAlias", (t) => {
// default query suite names should resolve to something language-specific ending in `.qls`.
for (const suite of analyze_1.defaultSuites) {
const resolved = (0, analyze_1.resolveQuerySuiteAlias)(languages_1.Language.go, suite);
const resolved = (0, analyze_1.resolveQuerySuiteAlias)(languages_1.KnownLanguage.go, suite);
t.assert(resolved.endsWith(".qls"), "Resolved default suite doesn't end in .qls");
t.assert(resolved.indexOf(languages_1.Language.go) >= 0, "Resolved default suite doesn't contain language name");
t.assert(resolved.indexOf(languages_1.KnownLanguage.go) >= 0, "Resolved default suite doesn't contain language name");
}
// other inputs should be returned unchanged
const names = ["foo", "bar", "codeql/go-queries@1.0"];
for (const name of names) {
t.deepEqual((0, analyze_1.resolveQuerySuiteAlias)(languages_1.Language.go, name), name);
t.deepEqual((0, analyze_1.resolveQuerySuiteAlias)(languages_1.KnownLanguage.go, name), name);
}
});
//# sourceMappingURL=analyze.test.js.map

File diff suppressed because one or more lines are too long

14
lib/autobuild.js generated
View File

@@ -46,7 +46,7 @@ const feature_flags_1 = require("./feature-flags");
const languages_1 = require("./languages");
const repository_1 = require("./repository");
const util_1 = require("./util");
async function determineAutobuildLanguages(_codeql, config, logger) {
async function determineAutobuildLanguages(codeql, config, logger) {
if (config.buildMode === util_1.BuildMode.None ||
config.buildMode === util_1.BuildMode.Manual) {
logger.info(`Using build mode "${config.buildMode}", nothing to autobuild. ` +
@@ -57,8 +57,8 @@ async function determineAutobuildLanguages(_codeql, config, logger) {
// We want pick the dominant language in the repo from the ones we're able to build
// The languages are sorted in order specified by user or by lines of code if we got
// them from the GitHub API, so try to build the first language on the list.
const autobuildLanguages = config.languages.filter((l) => (0, languages_1.isTracedLanguage)(l));
if (!autobuildLanguages) {
const autobuildLanguages = await (0, util_1.asyncFilter)(config.languages, async (language) => await codeql.isTracedLanguage(language));
if (autobuildLanguages.length === 0) {
logger.info("None of the languages in this project require extra build steps");
return undefined;
}
@@ -89,7 +89,7 @@ async function determineAutobuildLanguages(_codeql, config, logger) {
* This special case behavior should be removed as part of the next major
* version of the CodeQL Action.
*/
const autobuildLanguagesWithoutGo = autobuildLanguages.filter((l) => l !== languages_1.Language.go);
const autobuildLanguagesWithoutGo = autobuildLanguages.filter((l) => l !== languages_1.KnownLanguage.go);
const languages = [];
// First run the autobuilder for the first non-Go traced language, if one
// exists.
@@ -99,7 +99,7 @@ async function determineAutobuildLanguages(_codeql, config, logger) {
// If Go is requested, run the Go autobuilder last to ensure it doesn't
// interfere with the other autobuilder.
if (autobuildLanguages.length !== autobuildLanguagesWithoutGo.length) {
languages.push(languages_1.Language.go);
languages.push(languages_1.KnownLanguage.go);
}
logger.debug(`Will autobuild ${languages.join(" and ")}.`);
// In general the autobuilders for other traced languages may conflict with
@@ -145,7 +145,7 @@ async function setupCppAutobuild(codeql, logger) {
async function runAutobuild(config, language, logger) {
logger.startGroup(`Attempting to automatically build ${language} code`);
const codeQL = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
if (language === languages_1.Language.cpp) {
if (language === languages_1.KnownLanguage.cpp) {
await setupCppAutobuild(codeQL, logger);
}
if (config.buildMode) {
@@ -154,7 +154,7 @@ async function runAutobuild(config, language, logger) {
else {
await codeQL.runAutobuild(config, language);
}
if (language === languages_1.Language.go) {
if (language === languages_1.KnownLanguage.go) {
core.exportVariable(environment_1.EnvVar.DID_AUTOBUILD_GOLANG, "true");
}
logger.endGroup();

View File

@@ -1 +1 @@
{"version":3,"file":"autobuild.js","sourceRoot":"","sources":["../src/autobuild.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,kEAiGC;AAED,8CAmCC;AAED,oCAmBC;AAzKD,oDAAsC;AAEtC,iDAA6E;AAC7E,6CAAgD;AAChD,qCAA6C;AAE7C,uCAAmC;AACnC,+CAAuC;AACvC,mDAAmE;AACnE,2CAAyD;AAEzD,6CAAgD;AAChD,iCAAmC;AAE5B,KAAK,UAAU,2BAA2B,CAC/C,OAAe,EACf,MAA0B,EAC1B,MAAc;IAEd,IACE,MAAM,CAAC,SAAS,KAAK,gBAAS,CAAC,IAAI;QACnC,MAAM,CAAC,SAAS,KAAK,gBAAS,CAAC,MAAM,EACrC,CAAC;QACD,MAAM,CAAC,IAAI,CACT,qBAAqB,MAAM,CAAC,SAAS,2BAA2B;YAC9D,OAAO,gBAAM,CAAC,kBAAkB,wBAAwB,CAC3D,CAAC;QACF,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,0CAA0C;IAC1C,mFAAmF;IACnF,oFAAoF;IACpF,4EAA4E;IAC5E,MAAM,kBAAkB,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CACvD,IAAA,4BAAgB,EAAC,CAAC,CAAC,CACpB,CAAC;IA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AC,IAAI,CACT,YAAY,WAAW,yCAAyC,MAAM,yCAAyC,gBAAM,CAAC,oBAAoB,wBAAwB,CACnK,CAAC;YACF,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,IAAI,CAAC,aAAa,WAAW,GAAG,CAAC,CAAC;QACzC,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC;AACH,CAAC;AAEM,KAAK,UAAU,YAAY,CAChC,MAA0B,EAC1B,QAAkB,EAClB,MAAc;IAEd,MAAM,CAAC,UAAU,CAAC,qCAAqC,QAAQ,OAAO,CAAC,CAAC;IACxE,MAAM,MAAM,GAAG,MAAM,IAAA,kBAAS,EAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACjD,IAAI,QAAQ,KAAK,yBAAa,CAAC,GAAG,EAAE,CAAC;QACnC,MAAM,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,CAAC;IACD,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;QACrB,MAAM,MAAM,CAAC,qBAAqB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACvD,CAAC;SAAM,CAAC;QACN,MAAM,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC9C,CAAC;IACD,IAAI,QAAQ,KAAK,yBAAa,CAAC,EAAE,EAAE,CAAC;QAClC,IAAI,CAAC,cAAc,CAAC,oBAAM,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC;IAC3D,CAAC;IACD,MAAM,CAAC,QAAQ,EAAE,CAAC;AACpB,CAAC"}

37
lib/cli-errors.js generated
View File

@@ -1,11 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.cliErrorsConfig = exports.CliConfigErrorCategory = exports.CliError = void 0;
exports.getCliConfigCategoryIfExists = getCliConfigCategoryIfExists;
exports.wrapCliConfigurationError = wrapCliConfigurationError;
const actions_util_1 = require("./actions-util");
const doc_url_1 = require("./doc-url");
const util_1 = require("./util");
const SUPPORTED_PLATFORMS = [
["linux", "x64"],
["win32", "x64"],
["darwin", "x64"],
["darwin", "arm64"],
];
/**
* An error from a CodeQL CLI invocation, with associated exit code, stderr, etc.
*/
@@ -124,6 +129,7 @@ var CliConfigErrorCategory;
CliConfigErrorCategory["NoSourceCodeSeen"] = "NoSourceCodeSeen";
CliConfigErrorCategory["NoSupportedBuildCommandSucceeded"] = "NoSupportedBuildCommandSucceeded";
CliConfigErrorCategory["NoSupportedBuildSystemDetected"] = "NoSupportedBuildSystemDetected";
CliConfigErrorCategory["NotFoundInRegistry"] = "NotFoundInRegistry";
CliConfigErrorCategory["OutOfMemoryOrDisk"] = "OutOfMemoryOrDisk";
CliConfigErrorCategory["PackCannotBeFound"] = "PackCannotBeFound";
CliConfigErrorCategory["PackMissingAuth"] = "PackMissingAuth";
@@ -150,7 +156,7 @@ exports.cliErrorsConfig = {
},
[CliConfigErrorCategory.GradleBuildFailed]: {
cliErrorMessageCandidates: [
new RegExp("[autobuild] FAILURE: Build failed with an exception."),
new RegExp("\\[autobuild\\] FAILURE: Build failed with an exception."),
],
},
// Version of CodeQL CLI is incompatible with this version of the CodeQL Action
@@ -243,6 +249,11 @@ exports.cliErrorsConfig = {
new RegExp("does not support the .* build mode. Please try using one of the following build modes instead"),
],
},
[CliConfigErrorCategory.NotFoundInRegistry]: {
cliErrorMessageCandidates: [
new RegExp("'.*' not found in the registry '.*'"),
],
},
};
/**
* Check if the given CLI error or exit code, if applicable, apply to any known
@@ -266,11 +277,29 @@ function getCliConfigCategoryIfExists(cliError) {
return undefined;
}
/**
* Changes an error received from the CLI to a ConfigurationError with optionally an extra
* error message appended, if it exists in a known set of configuration errors. Otherwise,
* Check if we are running on an unsupported platform/architecture combination.
*/
function isUnsupportedPlatform() {
return !SUPPORTED_PLATFORMS.some(([platform, arch]) => platform === process.platform && arch === process.arch);
}
/**
* Transform a CLI error into a ConfigurationError for an unsupported platform.
*/
function getUnsupportedPlatformError(cliError) {
return new util_1.ConfigurationError("The CodeQL CLI does not support the platform/architecture combination of " +
`${process.platform}/${process.arch} ` +
`(see ${doc_url_1.DocUrl.SYSTEM_REQUIREMENTS}). ` +
`The underlying error was: ${cliError.message}`);
}
/**
* Changes an error received from the CLI to a ConfigurationError with the message
* optionally being transformed, if it is a known configuration error. Otherwise,
* simply returns the original error.
*/
function wrapCliConfigurationError(cliError) {
if (isUnsupportedPlatform()) {
return getUnsupportedPlatformError(cliError);
}
const cliConfigErrorCategory = getCliConfigCategoryIfExists(cliError);
if (cliConfigErrorCategory === undefined) {
return cliError;

File diff suppressed because one or more lines are too long

220
lib/cli-errors.test.js generated Normal file
View File

@@ -0,0 +1,220 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (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 () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__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 sinon = __importStar(require("sinon"));
const actions_util_1 = require("./actions-util");
const cli_errors_1 = require("./cli-errors");
const testing_utils_1 = require("./testing-utils");
const util_1 = require("./util");
(0, testing_utils_1.setupTests)(ava_1.default);
(0, ava_1.default)("CliError constructor with fatal errors", (t) => {
const commandError = new actions_util_1.CommandInvocationError("codeql", ["database", "finalize"], 32, "Running TRAP import for CodeQL database...\nA fatal error occurred: Evaluator heap must be at least 384.00 MiB\nA fatal error occurred: Dataset import failed with code 2");
const cliError = new cli_errors_1.CliError(commandError);
t.is(cliError.exitCode, 32);
t.is(cliError.stderr, "Running TRAP import for CodeQL database...\nA fatal error occurred: Evaluator heap must be at least 384.00 MiB\nA fatal error occurred: Dataset import failed with code 2");
t.true(cliError.message.includes("A fatal error occurred: Dataset import failed with code 2."));
t.true(cliError.message.includes("Context: A fatal error occurred: Evaluator heap must be at least 384.00 MiB."));
});
(0, ava_1.default)("CliError constructor with single fatal error", (t) => {
const commandError = new actions_util_1.CommandInvocationError("codeql", ["database", "create"], 1, "A fatal error occurred: Out of memory");
const cliError = new cli_errors_1.CliError(commandError);
t.is(cliError.exitCode, 1);
t.true(cliError.message.includes("A fatal error occurred: Out of memory"));
t.false(cliError.message.includes("Context:"));
});
(0, ava_1.default)("CliError constructor with autobuild errors", (t) => {
const commandError = new actions_util_1.CommandInvocationError("codeql", ["database", "create"], 1, "[autobuild] [ERROR] Build failed\n[autobuild] [ERROR] Compilation error");
const cliError = new cli_errors_1.CliError(commandError);
t.is(cliError.exitCode, 1);
t.true(cliError.message.includes("We were unable to automatically build your code"));
t.true(cliError.message.includes("Build failed\nCompilation error"));
});
(0, ava_1.default)("CliError constructor with truncated autobuild errors", (t) => {
const stderr = Array.from({ length: 12 }, (_, i) => `[autobuild] [ERROR] Error ${i + 1}`).join("\n");
const commandError = new actions_util_1.CommandInvocationError("codeql", ["database", "create"], 1, stderr);
const cliError = new cli_errors_1.CliError(commandError);
t.true(cliError.message.includes("(truncated)"));
// Should only include first 10 errors plus truncation message
const errorLines = cliError.message
.split("Encountered the following error: ")[1]
.split("\n");
t.is(errorLines.length, 11); // 10 errors + "(truncated)"
});
(0, ava_1.default)("CliError constructor with generic error", (t) => {
const commandError = new actions_util_1.CommandInvocationError("codeql", ["version"], 1, "Some generic error message\nLast line of error");
const cliError = new cli_errors_1.CliError(commandError);
t.is(cliError.exitCode, 1);
t.true(cliError.message.includes('Encountered a fatal error while running "codeql version"'));
t.true(cliError.message.includes("Exit code was 1 and last log line was: Last line of error."));
});
(0, ava_1.default)("CliError constructor with empty stderr", (t) => {
const commandError = new actions_util_1.CommandInvocationError("codeql", ["version"], 1, "");
const cliError = new cli_errors_1.CliError(commandError);
t.true(cliError.message.includes("last log line was: n/a"));
});
for (const [platform, arch] of [
["weird_plat", "x64"],
["linux", "arm64"],
["win32", "arm64"],
]) {
(0, ava_1.default)(`wrapCliConfigurationError - ${platform}/${arch} unsupported`, (t) => {
sinon.stub(process, "platform").value(platform);
sinon.stub(process, "arch").value(arch);
const commandError = new actions_util_1.CommandInvocationError("codeql", ["version"], 1, "Some error");
const cliError = new cli_errors_1.CliError(commandError);
const wrappedError = (0, cli_errors_1.wrapCliConfigurationError)(cliError);
t.true(wrappedError instanceof util_1.ConfigurationError);
t.true(wrappedError.message.includes("CodeQL CLI does not support the platform/architecture combination"));
t.true(wrappedError.message.includes(`${platform}/${arch}`));
});
}
(0, ava_1.default)("wrapCliConfigurationError - supported platform", (t) => {
const commandError = new actions_util_1.CommandInvocationError("codeql", ["version"], 1, "Some error");
const cliError = new cli_errors_1.CliError(commandError);
const wrappedError = (0, cli_errors_1.wrapCliConfigurationError)(cliError);
// Should return the original error since platform is supported
t.is(wrappedError, cliError);
});
(0, ava_1.default)("wrapCliConfigurationError - autobuild error", (t) => {
const commandError = new actions_util_1.CommandInvocationError("codeql", ["database", "create"], 1, "We were unable to automatically build your code");
const cliError = new cli_errors_1.CliError(commandError);
const wrappedError = (0, cli_errors_1.wrapCliConfigurationError)(cliError);
t.true(wrappedError instanceof util_1.ConfigurationError);
t.true(wrappedError.message.includes("We were unable to automatically build your code"));
});
(0, ava_1.default)("wrapCliConfigurationError - init called twice", (t) => {
const commandError = new actions_util_1.CommandInvocationError("codeql", ["database", "create"], 1, "Refusing to create databases /some/path but could not process any of it");
const cliError = new cli_errors_1.CliError(commandError);
const wrappedError = (0, cli_errors_1.wrapCliConfigurationError)(cliError);
t.true(wrappedError instanceof util_1.ConfigurationError);
t.true(wrappedError.message.includes('Is the "init" action called twice in the same job?'));
});
(0, ava_1.default)("wrapCliConfigurationError - no source code seen by exit code", (t) => {
const commandError = new actions_util_1.CommandInvocationError("codeql", ["database", "finalize"], 32, "Some other error message");
const cliError = new cli_errors_1.CliError(commandError);
const wrappedError = (0, cli_errors_1.wrapCliConfigurationError)(cliError);
t.true(wrappedError instanceof util_1.ConfigurationError);
});
(0, ava_1.default)("wrapCliConfigurationError - no source code seen by message", (t) => {
const commandError = new actions_util_1.CommandInvocationError("codeql", ["database", "finalize"], 1, "CodeQL detected code written in JavaScript but could not process any of it");
const cliError = new cli_errors_1.CliError(commandError);
const wrappedError = (0, cli_errors_1.wrapCliConfigurationError)(cliError);
t.true(wrappedError instanceof util_1.ConfigurationError);
});
(0, ava_1.default)("wrapCliConfigurationError - out of memory error with additional message", (t) => {
const commandError = new actions_util_1.CommandInvocationError("codeql", ["database", "analyze"], 1, "CodeQL is out of memory.");
const cliError = new cli_errors_1.CliError(commandError);
const wrappedError = (0, cli_errors_1.wrapCliConfigurationError)(cliError);
t.true(wrappedError instanceof util_1.ConfigurationError);
t.true(wrappedError.message.includes("For more information, see https://gh.io/troubleshooting-code-scanning/out-of-disk-or-memory"));
});
(0, ava_1.default)("wrapCliConfigurationError - gradle build failed", (t) => {
const commandError = new actions_util_1.CommandInvocationError("codeql", ["database", "create"], 1, "[autobuild] FAILURE: Build failed with an exception.");
const cliError = new cli_errors_1.CliError(commandError);
const wrappedError = (0, cli_errors_1.wrapCliConfigurationError)(cliError);
t.true(wrappedError instanceof util_1.ConfigurationError);
});
(0, ava_1.default)("wrapCliConfigurationError - maven build failed", (t) => {
const commandError = new actions_util_1.CommandInvocationError("codeql", ["database", "create"], 1, "[autobuild] [ERROR] Failed to execute goal");
const cliError = new cli_errors_1.CliError(commandError);
const wrappedError = (0, cli_errors_1.wrapCliConfigurationError)(cliError);
t.true(wrappedError instanceof util_1.ConfigurationError);
});
(0, ava_1.default)("wrapCliConfigurationError - swift build failed", (t) => {
const commandError = new actions_util_1.CommandInvocationError("codeql", ["database", "create"], 1, "[autobuilder/build] [build-command-failed] `autobuild` failed to run the build command");
const cliError = new cli_errors_1.CliError(commandError);
const wrappedError = (0, cli_errors_1.wrapCliConfigurationError)(cliError);
t.true(wrappedError instanceof util_1.ConfigurationError);
});
(0, ava_1.default)("wrapCliConfigurationError - pack cannot be found", (t) => {
const commandError = new actions_util_1.CommandInvocationError("codeql", ["pack", "install"], 1, "Query pack my-pack cannot be found. Check the spelling of the pack.");
const cliError = new cli_errors_1.CliError(commandError);
const wrappedError = (0, cli_errors_1.wrapCliConfigurationError)(cliError);
t.true(wrappedError instanceof util_1.ConfigurationError);
});
(0, ava_1.default)("wrapCliConfigurationError - pack missing auth", (t) => {
const commandError = new actions_util_1.CommandInvocationError("codeql", ["pack", "download"], 1, "GitHub Container registry returned 403 Forbidden");
const cliError = new cli_errors_1.CliError(commandError);
const wrappedError = (0, cli_errors_1.wrapCliConfigurationError)(cliError);
t.true(wrappedError instanceof util_1.ConfigurationError);
});
(0, ava_1.default)("wrapCliConfigurationError - invalid config file", (t) => {
const commandError = new actions_util_1.CommandInvocationError("codeql", ["database", "create"], 1, "Config file .codeql/config.yml is not valid");
const cliError = new cli_errors_1.CliError(commandError);
const wrappedError = (0, cli_errors_1.wrapCliConfigurationError)(cliError);
t.true(wrappedError instanceof util_1.ConfigurationError);
});
(0, ava_1.default)("wrapCliConfigurationError - incompatible CLI version", (t) => {
const commandError = new actions_util_1.CommandInvocationError("codeql", ["version"], 1, "is not compatible with this CodeQL CLI");
const cliError = new cli_errors_1.CliError(commandError);
const wrappedError = (0, cli_errors_1.wrapCliConfigurationError)(cliError);
t.true(wrappedError instanceof util_1.ConfigurationError);
});
(0, ava_1.default)("wrapCliConfigurationError - unknown error remains unchanged", (t) => {
const commandError = new actions_util_1.CommandInvocationError("codeql", ["version"], 1, "Some unknown error that doesn't match any patterns");
const cliError = new cli_errors_1.CliError(commandError);
const wrappedError = (0, cli_errors_1.wrapCliConfigurationError)(cliError);
// Should return the original CliError since it doesn't match any known patterns
t.is(wrappedError, cliError);
t.true(wrappedError instanceof cli_errors_1.CliError);
t.false(wrappedError instanceof util_1.ConfigurationError);
});
// Test all error categories to ensure they're properly configured
(0, ava_1.default)("all CLI config error categories have valid configurations", (t) => {
const allCategories = Object.values(cli_errors_1.CliConfigErrorCategory);
for (const category of allCategories) {
// Each category should be a string
t.is(typeof category, "string");
// Create a test error that matches this category
let testError;
switch (category) {
case cli_errors_1.CliConfigErrorCategory.NoSourceCodeSeen:
// This category matches by exit code
testError = new cli_errors_1.CliError(new actions_util_1.CommandInvocationError("codeql", [], 32, "some error"));
break;
default:
// For other categories, we'll test with a generic message that should not match
testError = new cli_errors_1.CliError(new actions_util_1.CommandInvocationError("codeql", [], 1, "generic error"));
break;
}
// The test should not throw an error when processing
t.notThrows(() => (0, cli_errors_1.wrapCliConfigurationError)(testError));
}
});
//# sourceMappingURL=cli-errors.test.js.map

File diff suppressed because one or more lines are too long

68
lib/codeql.js generated
View File

@@ -36,7 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.setupCodeQL = setupCodeQL;
exports.getCodeQL = getCodeQL;
exports.setCodeQL = setCodeQL;
exports.getCachedCodeQL = getCachedCodeQL;
exports.createStubCodeQL = createStubCodeQL;
exports.getCodeQLForTesting = getCodeQLForTesting;
exports.getCodeQLForCmd = getCodeQLForCmd;
exports.getExtraOptions = getExtraOptions;
@@ -63,7 +63,6 @@ const util = __importStar(require("./util"));
const util_1 = require("./util");
/**
* Stores the CodeQL object, and is populated by `setupCodeQL` or `getCodeQL`.
* Can be overridden in tests using `setCodeQL`.
*/
let cachedCodeQL = undefined;
/**
@@ -150,6 +149,16 @@ async function getCodeQL(cmd) {
}
return cachedCodeQL;
}
/**
* Overrides the CodeQL object. Only for use in tests that cannot override
* CodeQL via dependency injection.
*
* Accepts a partial object. Any undefined methods will be implemented
* to immediately throw an exception indicating which method is missing.
*/
function setCodeQL(codeql) {
cachedCodeQL = createStubCodeQL(codeql);
}
function resolveFunction(partialCodeql, methodName, defaultImplementation) {
if (typeof partialCodeql[methodName] !== "function") {
if (defaultImplementation !== undefined) {
@@ -163,13 +172,13 @@ function resolveFunction(partialCodeql, methodName, defaultImplementation) {
return partialCodeql[methodName];
}
/**
* Set the functionality for CodeQL methods. Only for use in tests.
* Creates a stub CodeQL object. Only for use in tests.
*
* Accepts a partial object and any undefined methods will be implemented
* Accepts a partial object. Any undefined methods will be implemented
* to immediately throw an exception indicating which method is missing.
*/
function setCodeQL(partialCodeql) {
cachedCodeQL = {
function createStubCodeQL(partialCodeql) {
return {
getPath: resolveFunction(partialCodeql, "getPath", () => "/tmp/dummy-path"),
getVersion: resolveFunction(partialCodeql, "getVersion", async () => ({
version: "1.0.0",
@@ -177,6 +186,8 @@ function setCodeQL(partialCodeql) {
printVersion: resolveFunction(partialCodeql, "printVersion"),
supportsFeature: resolveFunction(partialCodeql, "supportsFeature", async (feature) => !!partialCodeql.getVersion &&
(0, tools_features_1.isSupportedToolsFeature)(await partialCodeql.getVersion(), feature)),
isTracedLanguage: resolveFunction(partialCodeql, "isTracedLanguage"),
isScannedLanguage: resolveFunction(partialCodeql, "isScannedLanguage"),
databaseInitCluster: resolveFunction(partialCodeql, "databaseInitCluster"),
runAutobuild: resolveFunction(partialCodeql, "runAutobuild"),
extractScannedLanguage: resolveFunction(partialCodeql, "extractScannedLanguage"),
@@ -187,7 +198,7 @@ function setCodeQL(partialCodeql) {
resolveQueries: resolveFunction(partialCodeql, "resolveQueries"),
resolveBuildEnvironment: resolveFunction(partialCodeql, "resolveBuildEnvironment"),
packDownload: resolveFunction(partialCodeql, "packDownload"),
databaseCleanup: resolveFunction(partialCodeql, "databaseCleanup"),
databaseCleanupCluster: resolveFunction(partialCodeql, "databaseCleanupCluster"),
databaseBundle: resolveFunction(partialCodeql, "databaseBundle"),
databaseRunQueries: resolveFunction(partialCodeql, "databaseRunQueries"),
databaseInterpretResults: resolveFunction(partialCodeql, "databaseInterpretResults"),
@@ -197,20 +208,6 @@ function setCodeQL(partialCodeql) {
resolveExtractor: resolveFunction(partialCodeql, "resolveExtractor"),
mergeResults: resolveFunction(partialCodeql, "mergeResults"),
};
return cachedCodeQL;
}
/**
* Get the cached CodeQL object. Should only be used from tests.
*
* TODO: Work out a good way for tests to get this from the test context
* instead of having to have this method.
*/
function getCachedCodeQL() {
if (cachedCodeQL === undefined) {
// Should never happen as setCodeQL is called by testing-utils.setupTests
throw new Error("cachedCodeQL undefined");
}
return cachedCodeQL;
}
/**
* Get a real, newly created CodeQL instance for testing. The instance refers to
@@ -255,6 +252,14 @@ async function getCodeQLForCmd(cmd, checkVersion) {
async supportsFeature(feature) {
return (0, tools_features_1.isSupportedToolsFeature)(await this.getVersion(), feature);
},
async isTracedLanguage(language) {
const extractorPath = await this.resolveExtractor(language);
const tracingConfigPath = path.join(extractorPath, "tools", "tracing-config.lua");
return fs.existsSync(tracingConfigPath);
},
async isScannedLanguage(language) {
return !(await this.isTracedLanguage(language));
},
async databaseInitCluster(config, sourceRoot, processName, qlconfigFile, logger) {
const extraArgs = config.languages.map((language) => `--language=${language}`);
if (await (0, tracer_config_1.shouldEnableIndirectTracing)(codeql, config)) {
@@ -566,18 +571,21 @@ async function getCodeQLForCmd(cmd, checkVersion) {
throw new Error(`Attempted to download specified packs but got an error:\n${output}\n${e}`);
}
},
async databaseCleanup(databasePath, cleanupLevel) {
async databaseCleanupCluster(config, cleanupLevel) {
const cacheCleanupFlag = (await util.codeQlVersionAtLeast(this, CODEQL_VERSION_CACHE_CLEANUP))
? "--cache-cleanup"
: "--mode";
const codeqlArgs = [
"database",
"cleanup",
databasePath,
`${cacheCleanupFlag}=${cleanupLevel}`,
...getExtraOptionsFromEnv(["database", "cleanup"]),
];
await runCli(cmd, codeqlArgs);
for (const language of config.languages) {
const databasePath = util.getCodeQLDatabasePath(config, language);
const codeqlArgs = [
"database",
"cleanup",
databasePath,
`${cacheCleanupFlag}=${cleanupLevel}`,
...getExtraOptionsFromEnv(["database", "cleanup"]),
];
await runCli(cmd, codeqlArgs);
}
},
async databaseBundle(databasePath, outputFilePath, databaseName) {
const args = [

File diff suppressed because one or more lines are too long

36
lib/codeql.test.js generated
View File

@@ -65,7 +65,7 @@ const NO_FEATURES = (0, testing_utils_1.createFeatures)([]);
ava_1.default.beforeEach(() => {
(0, util_1.initializeEnvironment)("1.2.3");
stubConfig = (0, testing_utils_1.createTestConfig)({
languages: [languages_1.Language.cpp],
languages: [languages_1.KnownLanguage.cpp],
});
});
async function installIntoToolcache({ apiDetails = testing_utils_1.SAMPLE_DOTCOM_API_DETAILS, cliVersion, isPinned, tagName, tmpDir, }) {
@@ -96,6 +96,15 @@ function mockApiDetails(apiDetails) {
process.env["GITHUB_SERVER_URL"] = apiDetails.url;
process.env["GITHUB_API_URL"] = apiDetails.apiURL || "";
}
async function stubCodeql() {
const codeqlObject = await codeql.getCodeQLForTesting();
sinon.stub(codeqlObject, "getVersion").resolves((0, testing_utils_1.makeVersionInfo)("2.17.6"));
sinon
.stub(codeqlObject, "isTracedLanguage")
.withArgs(languages_1.KnownLanguage.cpp)
.resolves(true);
return codeqlObject;
}
(0, ava_1.default)("downloads and caches explicitly requested bundles that aren't in the toolcache", async (t) => {
await util.withTmpDir(async (tmpDir) => {
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
@@ -328,8 +337,7 @@ const injectedConfigMacro = ava_1.default.macro({
exec: async (t, augmentationProperties, configOverride, expectedConfig) => {
await util.withTmpDir(async (tempDir) => {
const runnerConstructorStub = stubToolRunnerConstructor();
const codeqlObject = await codeql.getCodeQLForTesting();
sinon.stub(codeqlObject, "getVersion").resolves((0, testing_utils_1.makeVersionInfo)("1.0.0"));
const codeqlObject = await stubCodeql();
const thisStubConfig = {
...stubConfig,
...configOverride,
@@ -467,8 +475,7 @@ const injectedConfigMacro = ava_1.default.macro({
(0, ava_1.default)("passes a code scanning config AND qlconfig to the CLI", async (t) => {
await util.withTmpDir(async (tempDir) => {
const runnerConstructorStub = stubToolRunnerConstructor();
const codeqlObject = await codeql.getCodeQLForTesting();
sinon.stub(codeqlObject, "getVersion").resolves((0, testing_utils_1.makeVersionInfo)("2.17.6"));
const codeqlObject = await stubCodeql();
await codeqlObject.databaseInitCluster({ ...stubConfig, tempDir }, "", undefined, "/path/to/qlconfig.yml", (0, logging_1.getRunnerLogger)(true));
const args = runnerConstructorStub.firstCall.args[1];
// should have used a config file
@@ -482,8 +489,7 @@ const injectedConfigMacro = ava_1.default.macro({
(0, ava_1.default)("does not pass a qlconfig to the CLI when it is undefined", async (t) => {
await util.withTmpDir(async (tempDir) => {
const runnerConstructorStub = stubToolRunnerConstructor();
const codeqlObject = await codeql.getCodeQLForTesting();
sinon.stub(codeqlObject, "getVersion").resolves((0, testing_utils_1.makeVersionInfo)("2.17.6"));
const codeqlObject = await stubCodeql();
await codeqlObject.databaseInitCluster({ ...stubConfig, tempDir }, "", undefined, undefined, // undefined qlconfigFile
(0, logging_1.getRunnerLogger)(true));
const args = runnerConstructorStub.firstCall.args[1];
@@ -543,8 +549,7 @@ for (const { codeqlVersion, flagPassed, githubVersion, negativeFlagPassed, } of
const cliStderr = `Running TRAP import for CodeQL database at /home/runner/work/_temp/codeql_databases/javascript...\n` +
`${heapError}\n${datasetImportError}.`;
stubToolRunnerConstructor(32, cliStderr);
const codeqlObject = await codeql.getCodeQLForTesting();
sinon.stub(codeqlObject, "getVersion").resolves((0, testing_utils_1.makeVersionInfo)("2.17.6"));
const codeqlObject = await stubCodeql();
// io throws because of the test CodeQL object.
sinon.stub(io, "which").resolves("");
await t.throwsAsync(async () => await codeqlObject.finalizeDatabase("db", "--threads=2", "--ram=2048", false), {
@@ -570,7 +575,7 @@ for (const { codeqlVersion, flagPassed, githubVersion, negativeFlagPassed, } of
sinon.stub(codeqlObject, "resolveExtractor").resolves("/path/to/extractor");
// io throws because of the test CodeQL object.
sinon.stub(io, "which").resolves("");
await t.throwsAsync(async () => await codeqlObject.runAutobuild(stubConfig, languages_1.Language.java), {
await t.throwsAsync(async () => await codeqlObject.runAutobuild(stubConfig, languages_1.KnownLanguage.java), {
instanceOf: util.ConfigurationError,
message: "We were unable to automatically build your code. Please provide manual build steps. " +
`See ${doc_url_1.DocUrl.AUTOMATIC_BUILD_FAILED} for more information. ` +
@@ -583,12 +588,11 @@ for (const { codeqlVersion, flagPassed, githubVersion, negativeFlagPassed, } of
(0, ava_1.default)("runTool truncates long autobuilder errors", async (t) => {
const stderr = Array.from({ length: 20 }, (_, i) => `[2019-09-18 12:00:00] [autobuild] [ERROR] line${i + 1}`).join("\n");
stubToolRunnerConstructor(1, stderr);
const codeqlObject = await codeql.getCodeQLForTesting();
sinon.stub(codeqlObject, "getVersion").resolves((0, testing_utils_1.makeVersionInfo)("2.17.6"));
const codeqlObject = await stubCodeql();
sinon.stub(codeqlObject, "resolveExtractor").resolves("/path/to/extractor");
// io throws because of the test CodeQL object.
sinon.stub(io, "which").resolves("");
await t.throwsAsync(async () => await codeqlObject.runAutobuild(stubConfig, languages_1.Language.java), {
await t.throwsAsync(async () => await codeqlObject.runAutobuild(stubConfig, languages_1.KnownLanguage.java), {
instanceOf: util.ConfigurationError,
message: "We were unable to automatically build your code. Please provide manual build steps. " +
`See ${doc_url_1.DocUrl.AUTOMATIC_BUILD_FAILED} for more information. ` +
@@ -618,8 +622,7 @@ for (const { codeqlVersion, flagPassed, githubVersion, negativeFlagPassed, } of
(0, ava_1.default)("runTool outputs last line of stderr if fatal error could not be found", async (t) => {
const cliStderr = "line1\nline2\nline3\nline4\nline5";
stubToolRunnerConstructor(32, cliStderr);
const codeqlObject = await codeql.getCodeQLForTesting();
sinon.stub(codeqlObject, "getVersion").resolves((0, testing_utils_1.makeVersionInfo)("2.17.6"));
const codeqlObject = await stubCodeql();
// io throws because of the test CodeQL object.
sinon.stub(io, "which").resolves("");
await t.throwsAsync(async () => await codeqlObject.finalizeDatabase("db", "--threads=2", "--ram=2048", false), {
@@ -630,8 +633,7 @@ for (const { codeqlVersion, flagPassed, githubVersion, negativeFlagPassed, } of
});
(0, ava_1.default)("Avoids duplicating --overwrite flag if specified in CODEQL_ACTION_EXTRA_OPTIONS", async (t) => {
const runnerConstructorStub = stubToolRunnerConstructor();
const codeqlObject = await codeql.getCodeQLForTesting();
sinon.stub(codeqlObject, "getVersion").resolves((0, testing_utils_1.makeVersionInfo)("2.17.6"));
const codeqlObject = await stubCodeql();
// io throws because of the test CodeQL object.
sinon.stub(io, "which").resolves("");
process.env["CODEQL_ACTION_EXTRA_OPTIONS"] =

File diff suppressed because one or more lines are too long

165
lib/config-utils.js generated
View File

@@ -42,8 +42,11 @@ exports.getConfigFileFormatInvalidMessage = getConfigFileFormatInvalidMessage;
exports.getConfigFileDirectoryGivenMessage = getConfigFileDirectoryGivenMessage;
exports.getNoLanguagesError = getNoLanguagesError;
exports.getUnknownLanguagesError = getUnknownLanguagesError;
exports.getLanguagesInRepo = getLanguagesInRepo;
exports.getSupportedLanguageMap = getSupportedLanguageMap;
exports.hasActionsWorkflows = hasActionsWorkflows;
exports.getRawLanguagesInRepo = getRawLanguagesInRepo;
exports.getLanguages = getLanguages;
exports.getRawLanguagesNoAutodetect = getRawLanguagesNoAutodetect;
exports.getRawLanguages = getRawLanguages;
exports.getDefaultConfig = getDefaultConfig;
exports.calculateAugmentation = calculateAugmentation;
@@ -127,29 +130,63 @@ function getNoLanguagesError() {
function getUnknownLanguagesError(languages) {
return `Did not recognize the following languages: ${languages.join(", ")}`;
}
async function getSupportedLanguageMap(codeql) {
const resolveResult = await codeql.betterResolveLanguages();
const supportedLanguages = {};
// Populate canonical language names
for (const extractor of Object.keys(resolveResult.extractors)) {
// Require the language to be a known language.
// This is a temporary workaround since we have extractors that are not
// supported languages, such as `csv`, `html`, `properties`, `xml`, and
// `yaml`. We should replace this with a more robust solution in the future.
if (languages_1.KnownLanguage[extractor] !== undefined) {
supportedLanguages[extractor] = extractor;
}
}
// Populate language aliases
if (resolveResult.aliases) {
for (const [alias, extractor] of Object.entries(resolveResult.aliases)) {
supportedLanguages[alias] = extractor;
}
}
return supportedLanguages;
}
const baseWorkflowsPath = ".github/workflows";
/**
* Gets the set of languages in the current repository that are
* scannable by CodeQL.
* Determines if there exists a `.github/workflows` directory with at least
* one file in it, which we use as an indicator that there are Actions
* workflows in the workspace. This doesn't perfectly detect whether there
* are actually workflows, but should be a good approximation.
*
* Alternatively, we could check specifically for yaml files, or call the
* API to check if it knows about workflows.
*
* @returns True if the non-empty directory exists, false if not.
*/
async function getLanguagesInRepo(repository, logger) {
logger.debug(`GitHub repo ${repository.owner} ${repository.repo}`);
function hasActionsWorkflows(sourceRoot) {
const workflowsPath = path.resolve(sourceRoot, baseWorkflowsPath);
const stats = fs.lstatSync(workflowsPath);
return (stats !== undefined &&
stats.isDirectory() &&
fs.readdirSync(workflowsPath).length > 0);
}
/**
* Gets the set of languages in the current repository.
*/
async function getRawLanguagesInRepo(repository, sourceRoot, logger) {
logger.debug(`Automatically detecting languages (${repository.owner}/${repository.repo})`);
const response = await api.getApiClient().rest.repos.listLanguages({
owner: repository.owner,
repo: repository.repo,
});
logger.debug(`Languages API response: ${JSON.stringify(response)}`);
// The GitHub API is going to return languages in order of popularity,
// When we pick a language to autobuild we want to pick the most popular traced language
// Since sets in javascript maintain insertion order, using a set here and then splatting it
// into an array gives us an array of languages ordered by popularity
const languages = new Set();
for (const lang of Object.keys(response.data)) {
const parsedLang = (0, languages_1.parseLanguage)(lang);
if (parsedLang !== undefined) {
languages.add(parsedLang);
}
const result = Object.keys(response.data).map((language) => language.trim().toLowerCase());
if (hasActionsWorkflows(sourceRoot)) {
logger.debug(`Found a .github/workflows directory`);
result.push("actions");
}
return [...languages];
logger.debug(`Raw languages in repository: ${result.join(", ")}`);
return result;
}
/**
* Get the languages to analyse.
@@ -161,48 +198,44 @@ async function getLanguagesInRepo(repository, logger) {
* If no languages could be detected from either the workflow or the repository
* then throw an error.
*/
async function getLanguages(codeQL, languagesInput, repository, logger) {
async function getLanguages(codeql, languagesInput, repository, sourceRoot, logger) {
// Obtain languages without filtering them.
const { rawLanguages, autodetected } = await getRawLanguages(languagesInput, repository, logger);
let languages = rawLanguages;
if (autodetected) {
const supportedLanguages = Object.keys(await codeQL.resolveLanguages());
languages = languages
.map(languages_1.parseLanguage)
.filter((value) => value && supportedLanguages.includes(value))
.map((value) => value);
logger.info(`Automatically detected languages: ${languages.join(", ")}`);
}
else {
const aliases = (await codeQL.betterResolveLanguages()).aliases;
if (aliases) {
languages = languages.map((lang) => aliases[lang] || lang);
const { rawLanguages, autodetected } = await getRawLanguages(languagesInput, repository, sourceRoot, logger);
const languageMap = await getSupportedLanguageMap(codeql);
const languagesSet = new Set();
const unknownLanguages = [];
// Make sure they are supported
for (const language of rawLanguages) {
const extractorName = languageMap[language];
if (extractorName === undefined) {
unknownLanguages.push(language);
}
logger.info(`Languages from configuration: ${languages.join(", ")}`);
else {
languagesSet.add(extractorName);
}
}
const languages = Array.from(languagesSet);
if (!autodetected && unknownLanguages.length > 0) {
throw new util_1.ConfigurationError(getUnknownLanguagesError(unknownLanguages));
}
// If the languages parameter was not given and no languages were
// detected then fail here as this is a workflow configuration error.
if (languages.length === 0) {
throw new util_1.ConfigurationError(getNoLanguagesError());
}
// Make sure they are supported
const parsedLanguages = [];
const unknownLanguages = [];
for (const language of languages) {
const parsedLanguage = (0, languages_1.parseLanguage)(language);
if (parsedLanguage === undefined) {
unknownLanguages.push(language);
}
else if (!parsedLanguages.includes(parsedLanguage)) {
parsedLanguages.push(parsedLanguage);
}
if (autodetected) {
logger.info(`Autodetected languages: ${languages.join(", ")}`);
}
// Any unknown languages here would have come directly from the input
// since we filter unknown languages coming from the GitHub API.
if (unknownLanguages.length > 0) {
throw new util_1.ConfigurationError(getUnknownLanguagesError(unknownLanguages));
else {
logger.info(`Languages from configuration: ${languages.join(", ")}`);
}
return parsedLanguages;
return languages;
}
function getRawLanguagesNoAutodetect(languagesInput) {
return (languagesInput || "")
.split(",")
.map((x) => x.trim().toLowerCase())
.filter((x) => x.length > 0);
}
/**
* Gets the set of languages in the current repository without checking to
@@ -214,28 +247,23 @@ async function getLanguages(codeQL, languagesInput, repository, logger) {
* @returns A tuple containing a list of languages in this repository that might be
* analyzable and whether or not this list was determined automatically.
*/
async function getRawLanguages(languagesInput, repository, logger) {
// Obtain from action input 'languages' if set
let rawLanguages = (languagesInput || "")
.split(",")
.map((x) => x.trim().toLowerCase())
.filter((x) => x.length > 0);
let autodetected;
if (rawLanguages.length) {
autodetected = false;
async function getRawLanguages(languagesInput, repository, sourceRoot, logger) {
// If the user has specified languages, use those.
const languagesFromInput = getRawLanguagesNoAutodetect(languagesInput);
if (languagesFromInput.length > 0) {
return { rawLanguages: languagesFromInput, autodetected: false };
}
else {
autodetected = true;
// Obtain all languages in the repo that can be analysed
rawLanguages = (await getLanguagesInRepo(repository, logger));
}
return { rawLanguages, autodetected };
// Otherwise, autodetect languages in the repository.
return {
rawLanguages: await getRawLanguagesInRepo(repository, sourceRoot, logger),
autodetected: true,
};
}
/**
* Get the default config, populated without user configuration file.
*/
async function getDefaultConfig({ languagesInput, queriesInput, qualityQueriesInput, packsInput, buildModeInput, dbLocation, trapCachingEnabled, dependencyCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeql, githubVersion, features, logger, }) {
const languages = await getLanguages(codeql, languagesInput, repository, logger);
async function getDefaultConfig({ languagesInput, queriesInput, qualityQueriesInput, packsInput, buildModeInput, dbLocation, trapCachingEnabled, dependencyCachingEnabled, debugMode, debugArtifactName, debugDatabaseName, repository, tempDir, codeql, sourceRoot, githubVersion, features, logger, }) {
const languages = await getLanguages(codeql, languagesInput, repository, sourceRoot, logger);
const buildMode = await parseBuildModeInput(buildModeInput, languages, features, logger);
const augmentationProperties = await calculateAugmentation(packsInput, queriesInput, qualityQueriesInput, languages);
const { trapCaches, trapCacheDownloadTime } = await downloadCacheWithTime(trapCachingEnabled, codeql, languages, logger);
@@ -443,7 +471,8 @@ async function getOverlayDatabaseMode(codeql, repository, features, languages, s
if (overlayDatabaseMode === overlay_database_utils_1.OverlayDatabaseMode.None) {
return nonOverlayAnalysis;
}
if (buildMode !== util_1.BuildMode.None && languages.some(languages_1.isTracedLanguage)) {
if (buildMode !== util_1.BuildMode.None &&
(await Promise.all(languages.map(async (l) => await codeql.isTracedLanguage(l)))).some(Boolean)) {
logger.warning(`Cannot build an ${overlayDatabaseMode} database because ` +
`build-mode is set to "${buildMode}" instead of "none". ` +
"Falling back to creating a normal full database instead.");
@@ -827,12 +856,12 @@ async function parseBuildModeInput(input, languages, features, logger) {
if (!Object.values(util_1.BuildMode).includes(input)) {
throw new util_1.ConfigurationError(`Invalid build mode: '${input}'. Supported build modes are: ${Object.values(util_1.BuildMode).join(", ")}.`);
}
if (languages.includes(languages_1.Language.csharp) &&
if (languages.includes(languages_1.KnownLanguage.csharp) &&
(await features.getValue(feature_flags_1.Feature.DisableCsharpBuildless))) {
logger.warning("Scanning C# code without a build is temporarily unavailable. Falling back to 'autobuild' build mode.");
return util_1.BuildMode.Autobuild;
}
if (languages.includes(languages_1.Language.java) &&
if (languages.includes(languages_1.KnownLanguage.java) &&
(await features.getValue(feature_flags_1.Feature.DisableJavaBuildlessEnabled))) {
logger.warning("Scanning Java code without a build is temporarily unavailable. Falling back to 'autobuild' build mode.");
return util_1.BuildMode.Autobuild;

File diff suppressed because one or more lines are too long

223
lib/config-utils.test.js generated
View File

@@ -74,7 +74,16 @@ function createTestInitConfigInputs(overrides) {
debugDatabaseName: "",
repository: { owner: "github", repo: "example" },
tempDir: "",
codeql: {},
codeql: (0, codeql_1.createStubCodeQL)({
async betterResolveLanguages() {
return {
extractors: {
html: [{ extractor_root: "" }],
javascript: [{ extractor_root: "" }],
},
};
},
}),
workspacePath: "",
sourceRoot: "",
githubVersion,
@@ -126,7 +135,15 @@ function mockListLanguages(languages) {
return await (0, util_1.withTmpDir)(async (tempDir) => {
const logger = (0, logging_1.getRunnerLogger)(true);
const languages = "javascript,python";
const codeql = (0, codeql_1.setCodeQL)({
const codeql = (0, codeql_1.createStubCodeQL)({
async betterResolveLanguages() {
return {
extractors: {
javascript: [{ extractor_root: "" }],
python: [{ extractor_root: "" }],
},
};
},
async resolveQueries() {
return {
byLanguage: {
@@ -159,7 +176,15 @@ function mockListLanguages(languages) {
(0, ava_1.default)("loading config saves config", async (t) => {
return await (0, util_1.withTmpDir)(async (tempDir) => {
const logger = (0, logging_1.getRunnerLogger)(true);
const codeql = (0, codeql_1.setCodeQL)({
const codeql = (0, codeql_1.createStubCodeQL)({
async betterResolveLanguages() {
return {
extractors: {
javascript: [{ extractor_root: "" }],
python: [{ extractor_root: "" }],
},
};
},
async resolveQueries() {
return {
byLanguage: {
@@ -203,7 +228,6 @@ function mockListLanguages(languages) {
await configUtils.initConfig(createTestInitConfigInputs({
configFile: "../input",
tempDir,
codeql: (0, codeql_1.getCachedCodeQL)(),
workspacePath: tempDir,
}));
throw new Error("initConfig did not throw error");
@@ -221,7 +245,6 @@ function mockListLanguages(languages) {
await configUtils.initConfig(createTestInitConfigInputs({
configFile,
tempDir,
codeql: (0, codeql_1.getCachedCodeQL)(),
workspacePath: tempDir,
}));
throw new Error("initConfig did not throw error");
@@ -241,7 +264,6 @@ function mockListLanguages(languages) {
languagesInput,
configFile,
tempDir,
codeql: (0, codeql_1.getCachedCodeQL)(),
workspacePath: tempDir,
}));
throw new Error("initConfig did not throw error");
@@ -253,7 +275,14 @@ function mockListLanguages(languages) {
});
(0, ava_1.default)("load non-empty input", async (t) => {
return await (0, util_1.withTmpDir)(async (tempDir) => {
const codeql = (0, codeql_1.setCodeQL)({
const codeql = (0, codeql_1.createStubCodeQL)({
async betterResolveLanguages() {
return {
extractors: {
javascript: [{ extractor_root: "" }],
},
};
},
async resolveQueries() {
return {
byLanguage: {
@@ -284,7 +313,7 @@ function mockListLanguages(languages) {
fs.mkdirSync(path.join(tempDir, "foo"));
// And the config we expect it to parse to
const expectedConfig = {
languages: [languages_1.Language.javascript],
languages: [languages_1.KnownLanguage.javascript],
buildMode: util_1.BuildMode.None,
originalUserInput: {
name: "my config",
@@ -360,7 +389,15 @@ function queriesToResolvedQueryForm(queries) {
`;
fs.mkdirSync(path.join(tempDir, "foo"));
const resolveQueriesArgs = [];
const codeql = (0, codeql_1.setCodeQL)({
const codeql = (0, codeql_1.createStubCodeQL)({
async betterResolveLanguages() {
return {
extractors: {
javascript: [{ extractor_root: "" }],
python: [{ extractor_root: "" }],
},
};
},
async resolveQueries(queries, extraSearchPath) {
resolveQueriesArgs.push({ queries, extraSearchPath });
return queriesToResolvedQueryForm(queries);
@@ -384,7 +421,14 @@ function queriesToResolvedQueryForm(queries) {
});
(0, ava_1.default)("API client used when reading remote config", async (t) => {
return await (0, util_1.withTmpDir)(async (tempDir) => {
const codeql = (0, codeql_1.setCodeQL)({
const codeql = (0, codeql_1.createStubCodeQL)({
async betterResolveLanguages() {
return {
extractors: {
javascript: [{ extractor_root: "" }],
},
};
},
async resolveQueries() {
return {
byLanguage: {
@@ -439,7 +483,6 @@ function queriesToResolvedQueryForm(queries) {
await configUtils.initConfig(createTestInitConfigInputs({
configFile: repoReference,
tempDir,
codeql: (0, codeql_1.getCachedCodeQL)(),
workspacePath: tempDir,
}));
throw new Error("initConfig did not throw error");
@@ -460,7 +503,6 @@ function queriesToResolvedQueryForm(queries) {
await configUtils.initConfig(createTestInitConfigInputs({
configFile: repoReference,
tempDir,
codeql: (0, codeql_1.getCachedCodeQL)(),
workspacePath: tempDir,
}));
throw new Error("initConfig did not throw error");
@@ -473,7 +515,7 @@ function queriesToResolvedQueryForm(queries) {
(0, ava_1.default)("No detected languages", async (t) => {
return await (0, util_1.withTmpDir)(async (tempDir) => {
mockListLanguages([]);
const codeql = (0, codeql_1.setCodeQL)({
const codeql = (0, codeql_1.createStubCodeQL)({
async resolveLanguages() {
return {};
},
@@ -501,7 +543,6 @@ function queriesToResolvedQueryForm(queries) {
await configUtils.initConfig(createTestInitConfigInputs({
languagesInput,
tempDir,
codeql: (0, codeql_1.getCachedCodeQL)(),
workspacePath: tempDir,
}));
throw new Error("initConfig did not throw error");
@@ -531,17 +572,17 @@ const parsePacksErrorMacro = ava_1.default.macro({
* Test macro for testing when the packs block is invalid
*/
const invalidPackNameMacro = ava_1.default.macro({
exec: (t, name) => parsePacksErrorMacro.exec(t, name, [languages_1.Language.cpp], new RegExp(`^"${name}" is not a valid pack$`)),
exec: (t, name) => parsePacksErrorMacro.exec(t, name, [languages_1.KnownLanguage.cpp], new RegExp(`^"${name}" is not a valid pack$`)),
title: (_providedTitle, arg) => `Invalid pack string: ${arg}`,
});
(0, ava_1.default)("no packs", parsePacksMacro, "", [], undefined);
(0, ava_1.default)("two packs", parsePacksMacro, "a/b,c/d@1.2.3", [languages_1.Language.cpp], {
[languages_1.Language.cpp]: ["a/b", "c/d@1.2.3"],
(0, ava_1.default)("two packs", parsePacksMacro, "a/b,c/d@1.2.3", [languages_1.KnownLanguage.cpp], {
[languages_1.KnownLanguage.cpp]: ["a/b", "c/d@1.2.3"],
});
(0, ava_1.default)("two packs with spaces", parsePacksMacro, " a/b , c/d@1.2.3 ", [languages_1.Language.cpp], {
[languages_1.Language.cpp]: ["a/b", "c/d@1.2.3"],
(0, ava_1.default)("two packs with spaces", parsePacksMacro, " a/b , c/d@1.2.3 ", [languages_1.KnownLanguage.cpp], {
[languages_1.KnownLanguage.cpp]: ["a/b", "c/d@1.2.3"],
});
(0, ava_1.default)("two packs with language", parsePacksErrorMacro, "a/b,c/d@1.2.3", [languages_1.Language.cpp, languages_1.Language.java], new RegExp("Cannot specify a 'packs' input in a multi-language analysis. " +
(0, ava_1.default)("two packs with language", parsePacksErrorMacro, "a/b,c/d@1.2.3", [languages_1.KnownLanguage.cpp, languages_1.KnownLanguage.java], new RegExp("Cannot specify a 'packs' input in a multi-language analysis. " +
"Use a codeql-config.yml file instead and specify packs by language."));
(0, ava_1.default)("packs with other valid names", parsePacksMacro, [
// ranges are ok
@@ -560,8 +601,8 @@ const invalidPackNameMacro = ava_1.default.macro({
// this is valid, too. It will fail if it doesn't match a path
// (globbing is not done)
"c/d@1.2.3:+*)_(",
].join(","), [languages_1.Language.cpp], {
[languages_1.Language.cpp]: [
].join(","), [languages_1.KnownLanguage.cpp], {
[languages_1.KnownLanguage.cpp]: [
"c/d@1.0",
"c/d@~1.0.0",
"c/d@~1.0.0:a/b",
@@ -634,19 +675,19 @@ const calculateAugmentationMacro = ava_1.default.macro({
},
title: (_, title) => `Calculate Augmentation: ${title}`,
});
(0, ava_1.default)(calculateAugmentationMacro, "All empty", undefined, undefined, undefined, [languages_1.Language.javascript], {
(0, ava_1.default)(calculateAugmentationMacro, "All empty", undefined, undefined, undefined, [languages_1.KnownLanguage.javascript], {
...configUtils.defaultAugmentationProperties,
});
(0, ava_1.default)(calculateAugmentationMacro, "With queries", undefined, " a, b , c, d", undefined, [languages_1.Language.javascript], {
(0, ava_1.default)(calculateAugmentationMacro, "With queries", undefined, " a, b , c, d", undefined, [languages_1.KnownLanguage.javascript], {
...configUtils.defaultAugmentationProperties,
queriesInput: [{ uses: "a" }, { uses: "b" }, { uses: "c" }, { uses: "d" }],
});
(0, ava_1.default)(calculateAugmentationMacro, "With queries combining", undefined, " + a, b , c, d ", undefined, [languages_1.Language.javascript], {
(0, ava_1.default)(calculateAugmentationMacro, "With queries combining", undefined, " + a, b , c, d ", undefined, [languages_1.KnownLanguage.javascript], {
...configUtils.defaultAugmentationProperties,
queriesInputCombines: true,
queriesInput: [{ uses: "a" }, { uses: "b" }, { uses: "c" }, { uses: "d" }],
});
(0, ava_1.default)(calculateAugmentationMacro, "With quality queries", undefined, undefined, " a, b , c, d", [languages_1.Language.javascript], {
(0, ava_1.default)(calculateAugmentationMacro, "With quality queries", undefined, undefined, " a, b , c, d", [languages_1.KnownLanguage.javascript], {
...configUtils.defaultAugmentationProperties,
qualityQueriesInput: [
{ uses: "a" },
@@ -655,7 +696,7 @@ const calculateAugmentationMacro = ava_1.default.macro({
{ uses: "d" },
],
});
(0, ava_1.default)(calculateAugmentationMacro, "With security and quality queries", undefined, " a, b , c, d", "e, f , g,h", [languages_1.Language.javascript], {
(0, ava_1.default)(calculateAugmentationMacro, "With security and quality queries", undefined, " a, b , c, d", "e, f , g,h", [languages_1.KnownLanguage.javascript], {
...configUtils.defaultAugmentationProperties,
queriesInput: [{ uses: "a" }, { uses: "b" }, { uses: "c" }, { uses: "d" }],
qualityQueriesInput: [
@@ -665,11 +706,11 @@ const calculateAugmentationMacro = ava_1.default.macro({
{ uses: "h" },
],
});
(0, ava_1.default)(calculateAugmentationMacro, "With packs", " codeql/a , codeql/b , codeql/c , codeql/d ", undefined, undefined, [languages_1.Language.javascript], {
(0, ava_1.default)(calculateAugmentationMacro, "With packs", " codeql/a , codeql/b , codeql/c , codeql/d ", undefined, undefined, [languages_1.KnownLanguage.javascript], {
...configUtils.defaultAugmentationProperties,
packsInput: ["codeql/a", "codeql/b", "codeql/c", "codeql/d"],
});
(0, ava_1.default)(calculateAugmentationMacro, "With packs combining", " + codeql/a, codeql/b, codeql/c, codeql/d", undefined, undefined, [languages_1.Language.javascript], {
(0, ava_1.default)(calculateAugmentationMacro, "With packs combining", " + codeql/a, codeql/b, codeql/c, codeql/d", undefined, undefined, [languages_1.KnownLanguage.javascript], {
...configUtils.defaultAugmentationProperties,
packsInputCombines: true,
packsInput: ["codeql/a", "codeql/b", "codeql/c", "codeql/d"],
@@ -680,11 +721,11 @@ const calculateAugmentationErrorMacro = ava_1.default.macro({
},
title: (_, title) => `Calculate Augmentation Error: ${title}`,
});
(0, ava_1.default)(calculateAugmentationErrorMacro, "Plus (+) with nothing else (queries)", undefined, " + ", undefined, [languages_1.Language.javascript], /The workflow property "queries" is invalid/);
(0, ava_1.default)(calculateAugmentationErrorMacro, "Plus (+) with nothing else (packs)", " + ", undefined, undefined, [languages_1.Language.javascript], /The workflow property "packs" is invalid/);
(0, ava_1.default)(calculateAugmentationErrorMacro, "Packs input with multiple languages", " + a/b, c/d ", undefined, undefined, [languages_1.Language.javascript, languages_1.Language.java], /Cannot specify a 'packs' input in a multi-language analysis/);
(0, ava_1.default)(calculateAugmentationErrorMacro, "Plus (+) with nothing else (queries)", undefined, " + ", undefined, [languages_1.KnownLanguage.javascript], /The workflow property "queries" is invalid/);
(0, ava_1.default)(calculateAugmentationErrorMacro, "Plus (+) with nothing else (packs)", " + ", undefined, undefined, [languages_1.KnownLanguage.javascript], /The workflow property "packs" is invalid/);
(0, ava_1.default)(calculateAugmentationErrorMacro, "Packs input with multiple languages", " + a/b, c/d ", undefined, undefined, [languages_1.KnownLanguage.javascript, languages_1.KnownLanguage.java], /Cannot specify a 'packs' input in a multi-language analysis/);
(0, ava_1.default)(calculateAugmentationErrorMacro, "Packs input with no languages", " + a/b, c/d ", undefined, undefined, [], /No languages specified/);
(0, ava_1.default)(calculateAugmentationErrorMacro, "Invalid packs", " a-pack-without-a-scope ", undefined, undefined, [languages_1.Language.javascript], /"a-pack-without-a-scope" is not a valid pack/);
(0, ava_1.default)(calculateAugmentationErrorMacro, "Invalid packs", " a-pack-without-a-scope ", undefined, undefined, [languages_1.KnownLanguage.javascript], /"a-pack-without-a-scope" is not a valid pack/);
(0, ava_1.default)("no generateRegistries when registries is undefined", async (t) => {
return await (0, util_1.withTmpDir)(async (tmpDir) => {
const registriesInput = undefined;
@@ -716,7 +757,6 @@ const mockRepositoryNwo = (0, repository_1.parseRepositoryNwo)("owner/repo");
[
{
name: "languages from input",
codeqlResolvedLanguages: ["javascript", "java", "python"],
languagesInput: "jAvAscript, \n jaVa",
languagesInRepository: ["SwiFt", "other"],
expectedLanguages: ["javascript", "java"],
@@ -724,7 +764,6 @@ const mockRepositoryNwo = (0, repository_1.parseRepositoryNwo)("owner/repo");
},
{
name: "languages from github api",
codeqlResolvedLanguages: ["javascript", "java", "python"],
languagesInput: "",
languagesInRepository: [" jAvAscript\n \t", " jaVa", "SwiFt", "other"],
expectedLanguages: ["javascript", "java"],
@@ -732,7 +771,6 @@ const mockRepositoryNwo = (0, repository_1.parseRepositoryNwo)("owner/repo");
},
{
name: "aliases from input",
codeqlResolvedLanguages: ["javascript", "csharp", "cpp", "java", "python"],
languagesInput: " typEscript\n \t, C#, c , KoTlin",
languagesInRepository: ["SwiFt", "other"],
expectedLanguages: ["javascript", "csharp", "cpp", "java"],
@@ -740,7 +778,6 @@ const mockRepositoryNwo = (0, repository_1.parseRepositoryNwo)("owner/repo");
},
{
name: "duplicate languages from input",
codeqlResolvedLanguages: ["javascript", "java", "python"],
languagesInput: "jAvAscript, \n jaVa, kotlin, typescript",
languagesInRepository: ["SwiFt", "other"],
expectedLanguages: ["javascript", "java"],
@@ -748,7 +785,6 @@ const mockRepositoryNwo = (0, repository_1.parseRepositoryNwo)("owner/repo");
},
{
name: "aliases from github api",
codeqlResolvedLanguages: ["javascript", "csharp", "cpp", "java", "python"],
languagesInput: "",
languagesInRepository: [" typEscript\n \t", " C#", "c", "other"],
expectedLanguages: ["javascript", "csharp", "cpp"],
@@ -756,7 +792,6 @@ const mockRepositoryNwo = (0, repository_1.parseRepositoryNwo)("owner/repo");
},
{
name: "no languages",
codeqlResolvedLanguages: ["javascript", "java", "python"],
languagesInput: "",
languagesInRepository: [],
expectedApiCall: true,
@@ -764,30 +799,56 @@ const mockRepositoryNwo = (0, repository_1.parseRepositoryNwo)("owner/repo");
},
{
name: "unrecognized languages from input",
codeqlResolvedLanguages: ["javascript", "java", "python"],
languagesInput: "a, b, c, javascript",
languagesInRepository: [],
expectedApiCall: false,
expectedError: configUtils.getUnknownLanguagesError(["a", "b"]),
},
{
name: "extractors that aren't languages aren't included (specified)",
languagesInput: "html",
languagesInRepository: [],
expectedApiCall: false,
expectedError: configUtils.getUnknownLanguagesError(["html"]),
},
{
name: "extractors that aren't languages aren't included (autodetected)",
languagesInput: "",
languagesInRepository: ["html", "javascript"],
expectedApiCall: true,
expectedLanguages: ["javascript"],
},
].forEach((args) => {
(0, ava_1.default)(`getLanguages: ${args.name}`, async (t) => {
const mockRequest = (0, testing_utils_1.mockLanguagesInRepo)(args.languagesInRepository);
const languages = args.codeqlResolvedLanguages.reduce((acc, lang) => ({
...acc,
[lang]: true,
}), {});
const codeQL = (0, codeql_1.setCodeQL)({
resolveLanguages: () => Promise.resolve(languages),
const stubExtractorEntry = {
extractor_root: "",
};
const codeQL = (0, codeql_1.createStubCodeQL)({
betterResolveLanguages: () => Promise.resolve({
aliases: {
"c#": languages_1.KnownLanguage.csharp,
c: languages_1.KnownLanguage.cpp,
kotlin: languages_1.KnownLanguage.java,
typescript: languages_1.KnownLanguage.javascript,
},
extractors: {
cpp: [stubExtractorEntry],
csharp: [stubExtractorEntry],
java: [stubExtractorEntry],
javascript: [stubExtractorEntry],
python: [stubExtractorEntry],
},
}),
});
if (args.expectedLanguages) {
// happy path
const actualLanguages = await configUtils.getLanguages(codeQL, args.languagesInput, mockRepositoryNwo, mockLogger);
const actualLanguages = await configUtils.getLanguages(codeQL, args.languagesInput, mockRepositoryNwo, ".", mockLogger);
t.deepEqual(actualLanguages.sort(), args.expectedLanguages.sort());
}
else {
// there is an error
await t.throwsAsync(async () => await configUtils.getLanguages(codeQL, args.languagesInput, mockRepositoryNwo, mockLogger), { message: args.expectedError });
await t.throwsAsync(async () => await configUtils.getLanguages(codeQL, args.languagesInput, mockRepositoryNwo, ".", mockLogger), { message: args.expectedError });
}
t.deepEqual(mockRequest.called, args.expectedApiCall);
});
@@ -795,12 +856,12 @@ const mockRepositoryNwo = (0, repository_1.parseRepositoryNwo)("owner/repo");
for (const { displayName, language, feature } of [
{
displayName: "Java",
language: languages_1.Language.java,
language: languages_1.KnownLanguage.java,
feature: feature_flags_1.Feature.DisableJavaBuildlessEnabled,
},
{
displayName: "C#",
language: languages_1.Language.csharp,
language: languages_1.KnownLanguage.csharp,
feature: feature_flags_1.Feature.DisableCsharpBuildless,
},
]) {
@@ -812,7 +873,7 @@ for (const { displayName, language, feature } of [
});
(0, ava_1.default)(`Build mode not overridden for other languages when disable ${displayName} buildless feature flag enabled`, async (t) => {
const messages = [];
const buildMode = await configUtils.parseBuildModeInput("none", [languages_1.Language.python], (0, testing_utils_1.createFeatures)([feature]), (0, testing_utils_1.getRecordingLogger)(messages));
const buildMode = await configUtils.parseBuildModeInput("none", [languages_1.KnownLanguage.python], (0, testing_utils_1.createFeatures)([feature]), (0, testing_utils_1.getRecordingLogger)(messages));
t.is(buildMode, util_1.BuildMode.None);
t.deepEqual(messages, []);
});
@@ -835,7 +896,7 @@ const defaultOverlayDatabaseModeTestSetup = {
isDefaultBranch: false,
repositoryOwner: "github",
buildMode: util_1.BuildMode.None,
languages: [languages_1.Language.javascript],
languages: [languages_1.KnownLanguage.javascript],
codeqlVersion: "2.21.0",
gitRoot: "/some/git/root",
codeScanningConfig: {},
@@ -871,6 +932,12 @@ const getOverlayDatabaseModeMacro = ava_1.default.macro({
};
// Set up CodeQL mock
const codeql = (0, testing_utils_1.mockCodeQLVersion)(setup.codeqlVersion);
// Mock traced languages
sinon
.stub(codeql, "isTracedLanguage")
.callsFake(async (lang) => {
return [languages_1.KnownLanguage.java].includes(lang);
});
// Mock git root detection
if (setup.gitRoot !== undefined) {
sinon.stub(gitUtils, "getGitRoot").resolves(setup.gitRoot);
@@ -916,14 +983,14 @@ const getOverlayDatabaseModeMacro = ava_1.default.macro({
useOverlayDatabaseCaching: false,
});
(0, ava_1.default)(getOverlayDatabaseModeMacro, "Ignore feature flag when analyzing non-default branch", {
languages: [languages_1.Language.javascript],
languages: [languages_1.KnownLanguage.javascript],
features: [feature_flags_1.Feature.OverlayAnalysis, feature_flags_1.Feature.OverlayAnalysisJavascript],
}, {
overlayDatabaseMode: overlay_database_utils_1.OverlayDatabaseMode.None,
useOverlayDatabaseCaching: false,
});
(0, ava_1.default)(getOverlayDatabaseModeMacro, "Overlay-base database on default branch when feature enabled", {
languages: [languages_1.Language.javascript],
languages: [languages_1.KnownLanguage.javascript],
features: [feature_flags_1.Feature.OverlayAnalysis, feature_flags_1.Feature.OverlayAnalysisJavascript],
isDefaultBranch: true,
}, {
@@ -931,7 +998,7 @@ const getOverlayDatabaseModeMacro = ava_1.default.macro({
useOverlayDatabaseCaching: true,
});
(0, ava_1.default)(getOverlayDatabaseModeMacro, "Overlay-base database on default branch when feature enabled with custom analysis", {
languages: [languages_1.Language.javascript],
languages: [languages_1.KnownLanguage.javascript],
features: [feature_flags_1.Feature.OverlayAnalysis, feature_flags_1.Feature.OverlayAnalysisJavascript],
codeScanningConfig: {
packs: ["some-custom-pack@1.0.0"],
@@ -942,7 +1009,7 @@ const getOverlayDatabaseModeMacro = ava_1.default.macro({
useOverlayDatabaseCaching: true,
});
(0, ava_1.default)(getOverlayDatabaseModeMacro, "Overlay-base database on default branch when code-scanning feature enabled", {
languages: [languages_1.Language.javascript],
languages: [languages_1.KnownLanguage.javascript],
features: [
feature_flags_1.Feature.OverlayAnalysis,
feature_flags_1.Feature.OverlayAnalysisCodeScanningJavascript,
@@ -953,7 +1020,7 @@ const getOverlayDatabaseModeMacro = ava_1.default.macro({
useOverlayDatabaseCaching: true,
});
(0, ava_1.default)(getOverlayDatabaseModeMacro, "No overlay-base database on default branch when code-scanning feature enabled with disable-default-queries", {
languages: [languages_1.Language.javascript],
languages: [languages_1.KnownLanguage.javascript],
features: [
feature_flags_1.Feature.OverlayAnalysis,
feature_flags_1.Feature.OverlayAnalysisCodeScanningJavascript,
@@ -967,7 +1034,7 @@ const getOverlayDatabaseModeMacro = ava_1.default.macro({
useOverlayDatabaseCaching: false,
});
(0, ava_1.default)(getOverlayDatabaseModeMacro, "No overlay-base database on default branch when code-scanning feature enabled with packs", {
languages: [languages_1.Language.javascript],
languages: [languages_1.KnownLanguage.javascript],
features: [
feature_flags_1.Feature.OverlayAnalysis,
feature_flags_1.Feature.OverlayAnalysisCodeScanningJavascript,
@@ -981,7 +1048,7 @@ const getOverlayDatabaseModeMacro = ava_1.default.macro({
useOverlayDatabaseCaching: false,
});
(0, ava_1.default)(getOverlayDatabaseModeMacro, "No overlay-base database on default branch when code-scanning feature enabled with queries", {
languages: [languages_1.Language.javascript],
languages: [languages_1.KnownLanguage.javascript],
features: [
feature_flags_1.Feature.OverlayAnalysis,
feature_flags_1.Feature.OverlayAnalysisCodeScanningJavascript,
@@ -995,7 +1062,7 @@ const getOverlayDatabaseModeMacro = ava_1.default.macro({
useOverlayDatabaseCaching: false,
});
(0, ava_1.default)(getOverlayDatabaseModeMacro, "No overlay-base database on default branch when code-scanning feature enabled with query-filters", {
languages: [languages_1.Language.javascript],
languages: [languages_1.KnownLanguage.javascript],
features: [
feature_flags_1.Feature.OverlayAnalysis,
feature_flags_1.Feature.OverlayAnalysisCodeScanningJavascript,
@@ -1009,7 +1076,7 @@ const getOverlayDatabaseModeMacro = ava_1.default.macro({
useOverlayDatabaseCaching: false,
});
(0, ava_1.default)(getOverlayDatabaseModeMacro, "No overlay-base database on default branch when only language-specific feature enabled", {
languages: [languages_1.Language.javascript],
languages: [languages_1.KnownLanguage.javascript],
features: [feature_flags_1.Feature.OverlayAnalysisJavascript],
isDefaultBranch: true,
}, {
@@ -1017,7 +1084,7 @@ const getOverlayDatabaseModeMacro = ava_1.default.macro({
useOverlayDatabaseCaching: false,
});
(0, ava_1.default)(getOverlayDatabaseModeMacro, "No overlay-base database on default branch when only code-scanning feature enabled", {
languages: [languages_1.Language.javascript],
languages: [languages_1.KnownLanguage.javascript],
features: [feature_flags_1.Feature.OverlayAnalysisCodeScanningJavascript],
isDefaultBranch: true,
}, {
@@ -1025,7 +1092,7 @@ const getOverlayDatabaseModeMacro = ava_1.default.macro({
useOverlayDatabaseCaching: false,
});
(0, ava_1.default)(getOverlayDatabaseModeMacro, "No overlay-base database on default branch when language-specific feature disabled", {
languages: [languages_1.Language.javascript],
languages: [languages_1.KnownLanguage.javascript],
features: [feature_flags_1.Feature.OverlayAnalysis],
isDefaultBranch: true,
}, {
@@ -1033,7 +1100,7 @@ const getOverlayDatabaseModeMacro = ava_1.default.macro({
useOverlayDatabaseCaching: false,
});
(0, ava_1.default)(getOverlayDatabaseModeMacro, "Overlay analysis on PR when feature enabled", {
languages: [languages_1.Language.javascript],
languages: [languages_1.KnownLanguage.javascript],
features: [feature_flags_1.Feature.OverlayAnalysis, feature_flags_1.Feature.OverlayAnalysisJavascript],
isPullRequest: true,
}, {
@@ -1041,7 +1108,7 @@ const getOverlayDatabaseModeMacro = ava_1.default.macro({
useOverlayDatabaseCaching: true,
});
(0, ava_1.default)(getOverlayDatabaseModeMacro, "Overlay analysis on PR when feature enabled with custom analysis", {
languages: [languages_1.Language.javascript],
languages: [languages_1.KnownLanguage.javascript],
features: [feature_flags_1.Feature.OverlayAnalysis, feature_flags_1.Feature.OverlayAnalysisJavascript],
codeScanningConfig: {
packs: ["some-custom-pack@1.0.0"],
@@ -1052,7 +1119,7 @@ const getOverlayDatabaseModeMacro = ava_1.default.macro({
useOverlayDatabaseCaching: true,
});
(0, ava_1.default)(getOverlayDatabaseModeMacro, "Overlay analysis on PR when code-scanning feature enabled", {
languages: [languages_1.Language.javascript],
languages: [languages_1.KnownLanguage.javascript],
features: [
feature_flags_1.Feature.OverlayAnalysis,
feature_flags_1.Feature.OverlayAnalysisCodeScanningJavascript,
@@ -1063,7 +1130,7 @@ const getOverlayDatabaseModeMacro = ava_1.default.macro({
useOverlayDatabaseCaching: true,
});
(0, ava_1.default)(getOverlayDatabaseModeMacro, "No overlay analysis on PR when code-scanning feature enabled with disable-default-queries", {
languages: [languages_1.Language.javascript],
languages: [languages_1.KnownLanguage.javascript],
features: [
feature_flags_1.Feature.OverlayAnalysis,
feature_flags_1.Feature.OverlayAnalysisCodeScanningJavascript,
@@ -1077,7 +1144,7 @@ const getOverlayDatabaseModeMacro = ava_1.default.macro({
useOverlayDatabaseCaching: false,
});
(0, ava_1.default)(getOverlayDatabaseModeMacro, "No overlay analysis on PR when code-scanning feature enabled with packs", {
languages: [languages_1.Language.javascript],
languages: [languages_1.KnownLanguage.javascript],
features: [
feature_flags_1.Feature.OverlayAnalysis,
feature_flags_1.Feature.OverlayAnalysisCodeScanningJavascript,
@@ -1091,7 +1158,7 @@ const getOverlayDatabaseModeMacro = ava_1.default.macro({
useOverlayDatabaseCaching: false,
});
(0, ava_1.default)(getOverlayDatabaseModeMacro, "No overlay analysis on PR when code-scanning feature enabled with queries", {
languages: [languages_1.Language.javascript],
languages: [languages_1.KnownLanguage.javascript],
features: [
feature_flags_1.Feature.OverlayAnalysis,
feature_flags_1.Feature.OverlayAnalysisCodeScanningJavascript,
@@ -1105,7 +1172,7 @@ const getOverlayDatabaseModeMacro = ava_1.default.macro({
useOverlayDatabaseCaching: false,
});
(0, ava_1.default)(getOverlayDatabaseModeMacro, "No overlay analysis on PR when code-scanning feature enabled with query-filters", {
languages: [languages_1.Language.javascript],
languages: [languages_1.KnownLanguage.javascript],
features: [
feature_flags_1.Feature.OverlayAnalysis,
feature_flags_1.Feature.OverlayAnalysisCodeScanningJavascript,
@@ -1119,7 +1186,7 @@ const getOverlayDatabaseModeMacro = ava_1.default.macro({
useOverlayDatabaseCaching: false,
});
(0, ava_1.default)(getOverlayDatabaseModeMacro, "No overlay analysis on PR when only language-specific feature enabled", {
languages: [languages_1.Language.javascript],
languages: [languages_1.KnownLanguage.javascript],
features: [feature_flags_1.Feature.OverlayAnalysisJavascript],
isPullRequest: true,
}, {
@@ -1127,7 +1194,7 @@ const getOverlayDatabaseModeMacro = ava_1.default.macro({
useOverlayDatabaseCaching: false,
});
(0, ava_1.default)(getOverlayDatabaseModeMacro, "No overlay analysis on PR when only code-scanning feature enabled", {
languages: [languages_1.Language.javascript],
languages: [languages_1.KnownLanguage.javascript],
features: [feature_flags_1.Feature.OverlayAnalysisCodeScanningJavascript],
isPullRequest: true,
}, {
@@ -1135,7 +1202,7 @@ const getOverlayDatabaseModeMacro = ava_1.default.macro({
useOverlayDatabaseCaching: false,
});
(0, ava_1.default)(getOverlayDatabaseModeMacro, "No overlay analysis on PR when language-specific feature disabled", {
languages: [languages_1.Language.javascript],
languages: [languages_1.KnownLanguage.javascript],
features: [feature_flags_1.Feature.OverlayAnalysis],
isPullRequest: true,
}, {
@@ -1157,7 +1224,7 @@ const getOverlayDatabaseModeMacro = ava_1.default.macro({
useOverlayDatabaseCaching: false,
});
(0, ava_1.default)(getOverlayDatabaseModeMacro, "Overlay PR analysis by feature flag for dsp-testing", {
languages: [languages_1.Language.javascript],
languages: [languages_1.KnownLanguage.javascript],
features: [feature_flags_1.Feature.OverlayAnalysis, feature_flags_1.Feature.OverlayAnalysisJavascript],
isPullRequest: true,
repositoryOwner: "dsp-testing",
@@ -1166,7 +1233,7 @@ const getOverlayDatabaseModeMacro = ava_1.default.macro({
useOverlayDatabaseCaching: true,
});
(0, ava_1.default)(getOverlayDatabaseModeMacro, "No overlay PR analysis by feature flag for other-org", {
languages: [languages_1.Language.javascript],
languages: [languages_1.KnownLanguage.javascript],
features: [feature_flags_1.Feature.OverlayAnalysis, feature_flags_1.Feature.OverlayAnalysisJavascript],
isPullRequest: true,
repositoryOwner: "other-org",
@@ -1177,7 +1244,7 @@ const getOverlayDatabaseModeMacro = ava_1.default.macro({
(0, ava_1.default)(getOverlayDatabaseModeMacro, "Fallback due to autobuild with traced language", {
overlayDatabaseEnvVar: "overlay",
buildMode: util_1.BuildMode.Autobuild,
languages: [languages_1.Language.java],
languages: [languages_1.KnownLanguage.java],
}, {
overlayDatabaseMode: overlay_database_utils_1.OverlayDatabaseMode.None,
useOverlayDatabaseCaching: false,
@@ -1185,7 +1252,7 @@ const getOverlayDatabaseModeMacro = ava_1.default.macro({
(0, ava_1.default)(getOverlayDatabaseModeMacro, "Fallback due to no build mode with traced language", {
overlayDatabaseEnvVar: "overlay",
buildMode: undefined,
languages: [languages_1.Language.java],
languages: [languages_1.KnownLanguage.java],
}, {
overlayDatabaseMode: overlay_database_utils_1.OverlayDatabaseMode.None,
useOverlayDatabaseCaching: false,
@@ -1205,7 +1272,7 @@ const getOverlayDatabaseModeMacro = ava_1.default.macro({
useOverlayDatabaseCaching: false,
});
// Exercise language-specific overlay analysis features code paths
for (const language in languages_1.Language) {
for (const language in languages_1.KnownLanguage) {
(0, ava_1.default)(getOverlayDatabaseModeMacro, `Check default overlay analysis feature for ${language}`, {
languages: [language],
features: [feature_flags_1.Feature.OverlayAnalysis],

File diff suppressed because one or more lines are too long

10
lib/database-upload.js generated
View File

@@ -37,11 +37,11 @@ exports.uploadDatabases = uploadDatabases;
const fs = __importStar(require("fs"));
const actionsUtil = __importStar(require("./actions-util"));
const api_client_1 = require("./api-client");
const codeql_1 = require("./codeql");
const gitUtils = __importStar(require("./git-utils"));
const logging_1 = require("./logging");
const util = __importStar(require("./util"));
const util_1 = require("./util");
async function uploadDatabases(repositoryNwo, config, apiDetails, logger) {
async function uploadDatabases(repositoryNwo, codeql, config, apiDetails, logger) {
if (actionsUtil.getRequiredInput("upload-database") !== "true") {
logger.debug("Database upload disabled in workflow. Skipping upload.");
return;
@@ -61,8 +61,12 @@ async function uploadDatabases(repositoryNwo, config, apiDetails, logger) {
logger.debug("Not analyzing default branch. Skipping upload.");
return;
}
// Clean up the database, since intermediate results may still be written to the
// database if there is high RAM pressure.
await (0, logging_1.withGroupAsync)("Cleaning up databases", async () => {
await codeql.databaseCleanupCluster(config, "clear");
});
const client = (0, api_client_1.getApiClient)();
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
const uploadsUrl = new URL((0, util_1.parseGitHubUrl)(apiDetails.url));
uploadsUrl.hostname = `uploads.${uploadsUrl.hostname}`;
// Octokit expects the baseUrl to not have a trailing slash,

View File

@@ -1 +1 @@
{"version":3,"file":"database-upload.js","sourceRoot":"","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ClB,qGAAqG,EACrG;oBACE,OAAO,EAAE,cAAc;oBACvB,KAAK,EAAE,aAAa,CAAC,KAAK;oBAC1B,IAAI,EAAE,aAAa,CAAC,IAAI;oBACxB,QAAQ;oBACR,IAAI,EAAE,GAAG,QAAQ,WAAW;oBAC5B,UAAU,EAAE,SAAS;oBACrB,IAAI,EAAE,mBAAmB;oBACzB,OAAO,EAAE;wBACP,aAAa,EAAE,SAAS,UAAU,CAAC,IAAI,EAAE;wBACzC,cAAc,EAAE,iBAAiB;wBACjC,gBAAgB,EAAE,aAAa;qBAChC;iBACF,CACF,CAAC;gBACF,MAAM,CAAC,KAAK,CAAC,sCAAsC,QAAQ,EAAE,CAAC,CAAC;YACjE,CAAC;oBAAS,CAAC;gBACT,mBAAmB,CAAC,KAAK,EAAE,CAAC;YAC9B,CAAC;QACH,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,4CAA4C;YAC5C,MAAM,CAAC,OAAO,CAAC,iCAAiC,QAAQ,KAAK,CAAC,EAAE,CAAC,CAAC;QACpE,CAAC;IACH,CAAC;AACH,CAAC"}

View File

@@ -60,7 +60,7 @@ const testApiDetails = {
};
function getTestConfig(tmpDir) {
return (0, testing_utils_1.createTestConfig)({
languages: [languages_1.Language.javascript],
languages: [languages_1.KnownLanguage.javascript],
dbLocation: tmpDir,
});
}
@@ -79,6 +79,16 @@ async function mockHttpRequests(databaseUploadStatusCode) {
sinon.stub(apiClient, "getApiClient").value(() => client);
return databaseUploadSpy;
}
function getCodeQL() {
return (0, codeql_1.createStubCodeQL)({
async databaseBundle(_, outputFilePath) {
fs.writeFileSync(outputFilePath, "");
},
async databaseCleanupCluster() {
// Do nothing, as we are not testing cleanup here.
},
});
}
(0, ava_1.default)("Abort database upload if 'upload-database' input set to false", async (t) => {
await (0, util_1.withTmpDir)(async (tmpDir) => {
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
@@ -88,7 +98,7 @@ async function mockHttpRequests(databaseUploadStatusCode) {
.returns("false");
sinon.stub(gitUtils, "isAnalyzingDefaultBranch").resolves(true);
const loggedMessages = [];
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), testApiDetails, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
await (0, database_upload_1.uploadDatabases)(testRepoName, getCodeQL(), getTestConfig(tmpDir), testApiDetails, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
t.assert(loggedMessages.find((v) => v.type === "debug" &&
v.message ===
"Database upload disabled in workflow. Skipping upload.") !== undefined);
@@ -105,7 +115,7 @@ async function mockHttpRequests(databaseUploadStatusCode) {
const config = getTestConfig(tmpDir);
config.gitHubVersion = { type: util_1.GitHubVariant.GHES, version: "3.0" };
const loggedMessages = [];
await (0, database_upload_1.uploadDatabases)(testRepoName, config, testApiDetails, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
await (0, database_upload_1.uploadDatabases)(testRepoName, getCodeQL(), config, testApiDetails, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
t.assert(loggedMessages.find((v) => v.type === "debug" &&
v.message ===
"Not running against github.com or GHEC-DR. Skipping upload.") !== undefined);
@@ -120,7 +130,7 @@ async function mockHttpRequests(databaseUploadStatusCode) {
.returns("true");
sinon.stub(gitUtils, "isAnalyzingDefaultBranch").resolves(false);
const loggedMessages = [];
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), testApiDetails, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
await (0, database_upload_1.uploadDatabases)(testRepoName, getCodeQL(), getTestConfig(tmpDir), testApiDetails, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
t.assert(loggedMessages.find((v) => v.type === "debug" &&
v.message === "Not analyzing default branch. Skipping upload.") !== undefined);
});
@@ -134,13 +144,8 @@ async function mockHttpRequests(databaseUploadStatusCode) {
.returns("true");
sinon.stub(gitUtils, "isAnalyzingDefaultBranch").resolves(true);
await mockHttpRequests(500);
(0, codeql_1.setCodeQL)({
async databaseBundle(_, outputFilePath) {
fs.writeFileSync(outputFilePath, "");
},
});
const loggedMessages = [];
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), testApiDetails, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
await (0, database_upload_1.uploadDatabases)(testRepoName, getCodeQL(), getTestConfig(tmpDir), testApiDetails, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
t.assert(loggedMessages.find((v) => v.type === "warning" &&
v.message ===
"Failed to upload database for javascript: Error: some error message") !== undefined);
@@ -155,13 +160,8 @@ async function mockHttpRequests(databaseUploadStatusCode) {
.returns("true");
sinon.stub(gitUtils, "isAnalyzingDefaultBranch").resolves(true);
await mockHttpRequests(201);
(0, codeql_1.setCodeQL)({
async databaseBundle(_, outputFilePath) {
fs.writeFileSync(outputFilePath, "");
},
});
const loggedMessages = [];
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), testApiDetails, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
await (0, database_upload_1.uploadDatabases)(testRepoName, getCodeQL(), getTestConfig(tmpDir), testApiDetails, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
t.assert(loggedMessages.find((v) => v.type === "debug" &&
v.message === "Successfully uploaded database for javascript") !== undefined);
});
@@ -175,13 +175,8 @@ async function mockHttpRequests(databaseUploadStatusCode) {
.returns("true");
sinon.stub(gitUtils, "isAnalyzingDefaultBranch").resolves(true);
const databaseUploadSpy = await mockHttpRequests(201);
(0, codeql_1.setCodeQL)({
async databaseBundle(_, outputFilePath) {
fs.writeFileSync(outputFilePath, "");
},
});
const loggedMessages = [];
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), {
await (0, database_upload_1.uploadDatabases)(testRepoName, getCodeQL(), getTestConfig(tmpDir), {
auth: "1234",
url: "https://tenant.ghe.com",
apiURL: undefined,

File diff suppressed because one or more lines are too long

13
lib/debug-artifacts.js generated
View File

@@ -50,7 +50,6 @@ const archiver_1 = __importDefault(require("archiver"));
const del_1 = __importDefault(require("del"));
const actions_util_1 = require("./actions-util");
const analyze_1 = require("./analyze");
const codeql_1 = require("./codeql");
const environment_1 = require("./environment");
const logging_1 = require("./logging");
const tools_features_1 = require("./tools-features");
@@ -120,11 +119,11 @@ function tryPrepareSarifDebugArtifact(config, language, logger) {
*
* @return The path to the database bundle, or undefined if an error occurs.
*/
async function tryBundleDatabase(config, language, logger) {
async function tryBundleDatabase(codeql, config, language, logger) {
try {
if ((0, analyze_1.dbIsFinalized)(config, language, logger)) {
try {
return await createDatabaseBundleCli(config, language);
return await createDatabaseBundleCli(codeql, config, language);
}
catch (e) {
logger.warning(`Failed to bundle database for ${language} using the CLI. ` +
@@ -143,7 +142,7 @@ async function tryBundleDatabase(config, language, logger) {
*
* Logs and suppresses any errors that occur.
*/
async function tryUploadAllAvailableDebugArtifacts(config, logger, codeQlVersion) {
async function tryUploadAllAvailableDebugArtifacts(codeql, config, logger, codeQlVersion) {
const filesToUpload = [];
try {
for (const language of config.languages) {
@@ -170,7 +169,7 @@ async function tryUploadAllAvailableDebugArtifacts(config, logger, codeQlVersion
}
// Add database bundle
logger.info("Preparing database bundle debug artifact...");
const databaseBundle = await tryBundleDatabase(config, language, logger);
const databaseBundle = await tryBundleDatabase(codeql, config, language, logger);
if (databaseBundle) {
filesToUpload.push(databaseBundle);
logger.info("Database bundle debug artifact ready for upload.");
@@ -269,8 +268,8 @@ async function createPartialDatabaseBundle(config, language) {
/**
* Runs `codeql database bundle` command and returns the path.
*/
async function createDatabaseBundleCli(config, language) {
const databaseBundlePath = await (0, util_1.bundleDb)(config, language, await (0, codeql_1.getCodeQL)(config.codeQLCmd), `${config.debugDatabaseName}-${language}`);
async function createDatabaseBundleCli(codeql, config, language) {
const databaseBundlePath = await (0, util_1.bundleDb)(config, language, codeql, `${config.debugDatabaseName}-${language}`);
return databaseBundlePath;
}
//# sourceMappingURL=debug-artifacts.js.map

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,6 @@
{
"bundleVersion": "codeql-bundle-v2.22.2",
"cliVersion": "2.22.2",
"priorBundleVersion": "codeql-bundle-v2.22.1",
"priorCliVersion": "2.22.1"
"bundleVersion": "codeql-bundle-v2.22.3",
"cliVersion": "2.22.3",
"priorBundleVersion": "codeql-bundle-v2.22.2",
"priorCliVersion": "2.22.2"
}

1
lib/doc-url.js generated
View File

@@ -13,5 +13,6 @@ var DocUrl;
DocUrl["SPECIFY_BUILD_STEPS_MANUALLY"] = "https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages#about-specifying-build-steps-manually";
DocUrl["TRACK_CODE_SCANNING_ALERTS_ACROSS_RUNS"] = "https://docs.github.com/en/enterprise-cloud@latest/code-security/code-scanning/integrating-with-code-scanning/sarif-support-for-code-scanning#providing-data-to-track-code-scanning-alerts-across-runs";
DocUrl["CODEQL_BUILD_MODES"] = "https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages#codeql-build-modes";
DocUrl["SYSTEM_REQUIREMENTS"] = "https://codeql.github.com/docs/codeql-overview/system-requirements/";
})(DocUrl || (exports.DocUrl = DocUrl = {}));
//# sourceMappingURL=doc-url.js.map

View File

@@ -1 +1 @@
{"version":3,"file":"doc-url.js","sourceRoot":"","sources":["../src/doc-url.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,IAAY,MAQX;AARD,WAAY,MAAM;IAChB,uHAA6G,CAAA;IAC7G,gJAAsI,CAAA;IACtI,yJAA+I,CAAA;IAC/I,qMAA2L,CAAA;IAC3L,gOAAsN,CAAA;IACtN,2PAAiP,CAAA;IACjP,mMAAyL,CAAA;AAC3L,CAAC,EARW,MAAM,sBAAN,MAAM,QAQjB"}
{"version":3,"file":"doc-url.js","sourceRoot":"","sources":["../src/doc-url.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,IAAY,MASX;AATD,WAAY,MAAM;IAChB,uHAA6G,CAAA;IAC7G,gJAAsI,CAAA;IACtI,yJAA+I,CAAA;IAC/I,qMAA2L,CAAA;IAC3L,gOAAsN,CAAA;IACtN,2PAAiP,CAAA;IACjP,mMAAyL,CAAA;IACzL,qGAA2F,CAAA;AAC7F,CAAC,EATW,MAAM,sBAAN,MAAM,QASjB"}

View File

@@ -116,7 +116,7 @@ async function tryUploadSarifIfRunFailed(config, repositoryNwo, features, logger
};
}
}
async function run(uploadAllAvailableDebugArtifacts, printDebugLogs, config, repositoryNwo, features, logger) {
async function run(uploadAllAvailableDebugArtifacts, printDebugLogs, codeql, config, repositoryNwo, features, logger) {
const uploadFailedSarifResult = await tryUploadSarifIfRunFailed(config, repositoryNwo, features, logger);
if (uploadFailedSarifResult.upload_failed_run_skipped_because) {
logger.debug("Won't upload a failed SARIF file for this CodeQL code scanning run because: " +
@@ -142,9 +142,8 @@ async function run(uploadAllAvailableDebugArtifacts, printDebugLogs, config, rep
// Upload appropriate Actions artifacts for debugging
if (config.debugMode) {
logger.info("Debug mode is on. Uploading available database bundles and logs as Actions debugging artifacts...");
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
const version = await codeql.getVersion();
await uploadAllAvailableDebugArtifacts(config, logger, version.version);
await uploadAllAvailableDebugArtifacts(codeql, config, logger, version.version);
await printDebugLogs(config);
}
if (actionsUtil.isSelfHostedRunner()) {

File diff suppressed because one or more lines are too long

View File

@@ -65,7 +65,7 @@ const workflow = __importStar(require("./workflow"));
});
const uploadAllAvailableDebugArtifactsSpy = sinon.spy();
const printDebugLogsSpy = sinon.spy();
await initActionPostHelper.run(uploadAllAvailableDebugArtifactsSpy, printDebugLogsSpy, (0, testing_utils_1.createTestConfig)({ debugMode: false }), (0, repository_1.parseRepositoryNwo)("github/codeql-action"), (0, testing_utils_1.createFeatures)([]), (0, logging_1.getRunnerLogger)(true));
await initActionPostHelper.run(uploadAllAvailableDebugArtifactsSpy, printDebugLogsSpy, codeql.createStubCodeQL({}), (0, testing_utils_1.createTestConfig)({ debugMode: false }), (0, repository_1.parseRepositoryNwo)("github/codeql-action"), (0, testing_utils_1.createFeatures)([]), (0, logging_1.getRunnerLogger)(true));
t.assert(uploadAllAvailableDebugArtifactsSpy.notCalled);
t.assert(printDebugLogsSpy.notCalled);
});
@@ -76,7 +76,7 @@ const workflow = __importStar(require("./workflow"));
process.env["RUNNER_TEMP"] = tmpDir;
const uploadAllAvailableDebugArtifactsSpy = sinon.spy();
const printDebugLogsSpy = sinon.spy();
await initActionPostHelper.run(uploadAllAvailableDebugArtifactsSpy, printDebugLogsSpy, (0, testing_utils_1.createTestConfig)({ debugMode: true }), (0, repository_1.parseRepositoryNwo)("github/codeql-action"), (0, testing_utils_1.createFeatures)([]), (0, logging_1.getRunnerLogger)(true));
await initActionPostHelper.run(uploadAllAvailableDebugArtifactsSpy, printDebugLogsSpy, codeql.createStubCodeQL({}), (0, testing_utils_1.createTestConfig)({ debugMode: true }), (0, repository_1.parseRepositoryNwo)("github/codeql-action"), (0, testing_utils_1.createFeatures)([]), (0, logging_1.getRunnerLogger)(true));
t.assert(uploadAllAvailableDebugArtifactsSpy.called);
t.assert(printDebugLogsSpy.called);
});

File diff suppressed because one or more lines are too long

View File

@@ -41,6 +41,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(require("@actions/core"));
const actions_util_1 = require("./actions-util");
const api_client_1 = require("./api-client");
const codeql_1 = require("./codeql");
const config_utils_1 = require("./config-utils");
const debugArtifacts = __importStar(require("./debug-artifacts"));
const feature_flags_1 = require("./feature-flags");
@@ -66,7 +67,8 @@ async function runWrapper() {
logger.warning("Debugging artifacts are unavailable since the 'init' Action failed before it could produce any.");
}
else {
uploadFailedSarifResult = await initActionPostHelper.run(debugArtifacts.tryUploadAllAvailableDebugArtifacts, actions_util_1.printDebugLogs, config, repositoryNwo, features, logger);
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
uploadFailedSarifResult = await initActionPostHelper.run(debugArtifacts.tryUploadAllAvailableDebugArtifacts, actions_util_1.printDebugLogs, codeql, config, repositoryNwo, features, logger);
}
}
catch (unwrappedError) {

View File

@@ -1 +1 @@
{"version":3,"file":"init-action-post.js","sourceRoot":"","sources":["../src/init-action-post.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,oDAAsC;AAEtC,iDAIwB;AACxB,6CAAgD;AAChD,iDAAmD;AACnD,kEAAoD;AACpD,mDAA2C;AAC3C,gFAAkE;AAClE,uCAA6C;AAC7C,6CAAgD;AAChD,mDAOyB;AACzB,iCAA8E;AAO9E,KAAK,UAAU,UAAU;IACvB,MAAM,MAAM,GAAG,IAAA,0BAAgB,GAAE,CAAC;IAClC,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;IAC7B,IAAI,MAA0B,CAAC;IAC/B,IAAI,uBAES,CAAC;IACd,IAAI,CAAC;QACH,qCAAqC;QACrC,IAAA,4BAAa,GAAE,CAAC;QAEhB,MAAM,aAAa,GAAG,MAAM,IAAA,6BAAgB,GAAE,CAAC;QAC/C,IAAA,gCAAyB,EAAC,aAAa,EAAE,MAAM,CAAC,CAAC;QAEjD,MAAM,aAAa,GAAG,IAAA,6BAAgB,GAAE,CAAC;QACzC,MAAM,QAAQ,GAAG,IAAI,wBAAQ,CAC3B,aAAa,EACb,aAAa,EACb,IAAA,oCAAqB,GAAE,EACvB,MAAM,CACP,CAAC;QAEF,MAAM,GAAG,MAAM,IAAA,wBAAS,EAAC,IAAA,oCAAqB,GAAE,EAAE,MAAM,CAAC,CAAC;QAC1D,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,MAAM,CAAC,OAAO,CACZ,iGAAiG,CAClG,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,uBAAuB,GAAG,MAAM,oBAAoB,CAAC,GAAG,CACtD,cAAc,CAAC,mCAAmC,EAClD,6BAAc,EACd,MAAM,EACN,aAAa,EACb,QAAQ,EACR,MAAM,CACP,CAAC;QACJ,CAAC;IACH,CAAC;IAA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C;AAED,KAAK,UAAU,EAAE,CAAC"}

39
lib/init-action.js generated
View File

@@ -195,6 +195,33 @@ async function run() {
logger.warning(`Unable to validate code scanning workflow: ${validateWorkflowResult}`);
}
core.endGroup();
// Set CODEQL_ENABLE_EXPERIMENTAL_FEATURES for Rust. We need to set this environment
// variable before initializing the config, otherwise Rust analysis will not be
// enabled.
if (
// Only enable Rust analysis if the user has explicitly requested it - don't
// enable it via language autodetection.
configUtils
.getRawLanguagesNoAutodetect((0, actions_util_1.getOptionalInput)("languages"))
.includes(languages_1.KnownLanguage.rust)) {
const feat = feature_flags_1.Feature.RustAnalysis;
const minVer = feature_flags_1.featureConfig[feat].minimumVersion;
const envVar = "CODEQL_ENABLE_EXPERIMENTAL_FEATURES";
// if in default setup, it means the feature flag was on when rust was enabled
// if the feature flag gets turned off, let's not have rust analysis throwing a configuration error
// in that case rust analysis will be disabled only when default setup is refreshed
if ((0, actions_util_1.isDefaultSetup)() || (await features.getValue(feat, codeql))) {
core.exportVariable(envVar, "true");
}
if (process.env[envVar] !== "true") {
throw new util_1.ConfigurationError(`Experimental and not officially supported Rust analysis requires setting ${envVar}=true in the environment`);
}
const actualVer = (await codeql.getVersion()).version;
if (semver.lt(actualVer, minVer)) {
throw new util_1.ConfigurationError(`Experimental rust analysis is supported by CodeQL CLI version ${minVer} or higher, but found version ${actualVer}`);
}
logger.info("Experimental rust analysis enabled");
}
config = await (0, init_1.initConfig)({
languagesInput: (0, actions_util_1.getOptionalInput)("languages"),
queriesInput: (0, actions_util_1.getOptionalInput)("queries"),
@@ -285,11 +312,11 @@ async function run() {
core.exportVariable("GOFLAGS", goFlags);
core.warning("Passing the GOFLAGS env parameter to the init action is deprecated. Please move this to the analyze action.");
}
if (config.languages.includes(languages_1.Language.swift) &&
if (config.languages.includes(languages_1.KnownLanguage.swift) &&
process.platform === "linux") {
logger.warning(`Swift analysis on Ubuntu runner images is no longer supported. Please migrate to a macOS runner if this affects you.`);
}
if (config.languages.includes(languages_1.Language.go) &&
if (config.languages.includes(languages_1.KnownLanguage.go) &&
process.platform === "linux") {
try {
const goBinaryPath = await io.which("go", true);
@@ -327,7 +354,7 @@ async function run() {
catch (e) {
logger.warning(`Failed to determine the location of the Go binary: ${e}`);
if (e instanceof actions_util_1.FileCmdNotFoundError) {
(0, diagnostics_1.addDiagnostic)(config, languages_1.Language.go, (0, diagnostics_1.makeDiagnostic)("go/workflow/file-program-unavailable", "The `file` program is required on Linux, but does not appear to be installed", {
(0, diagnostics_1.addDiagnostic)(config, languages_1.KnownLanguage.go, (0, diagnostics_1.makeDiagnostic)("go/workflow/file-program-unavailable", "The `file` program is required on Linux, but does not appear to be installed", {
markdownMessage: "CodeQL was unable to find the `file` program on this system. Ensure that the `file` program is installed on Linux runners and accessible.",
visibility: {
statusPage: true,
@@ -357,7 +384,7 @@ async function run() {
!(await (0, util_1.codeQlVersionAtLeast)(codeql, "2.20.4"))) {
core.exportVariable(kotlinLimitVar, "2.1.20");
}
if (config.languages.includes(languages_1.Language.cpp)) {
if (config.languages.includes(languages_1.KnownLanguage.cpp)) {
const envVar = "CODEQL_EXTRACTOR_CPP_TRAP_CACHING";
if (process.env[envVar]) {
logger.info(`Environment variable ${envVar} already set. Not en/disabling CodeQL C++ TRAP caching support`);
@@ -373,7 +400,7 @@ async function run() {
}
}
// Set CODEQL_EXTRACTOR_CPP_BUILD_MODE_NONE
if (config.languages.includes(languages_1.Language.cpp)) {
if (config.languages.includes(languages_1.KnownLanguage.cpp)) {
const bmnVar = "CODEQL_EXTRACTOR_CPP_BUILD_MODE_NONE";
const value = process.env[bmnVar] ||
(await features.getValue(feature_flags_1.Feature.CppBuildModeNone, codeql));
@@ -381,7 +408,7 @@ async function run() {
core.exportVariable(bmnVar, value);
}
// For rust: set CODEQL_ENABLE_EXPERIMENTAL_FEATURES, unless codeql already supports rust without it
if (config.languages.includes(languages_1.Language.rust) &&
if (config.languages.includes(languages_1.KnownLanguage.rust) &&
!(await codeql.resolveLanguages()).rust) {
const feat = feature_flags_1.Feature.RustAnalysis;
const minVer = feature_flags_1.featureConfig[feat].minimumVersion;

File diff suppressed because one or more lines are too long

4
lib/init.js generated
View File

@@ -83,7 +83,7 @@ async function runInit(codeql, config, sourceRoot, processName, registriesInput,
* This check happens in a powershell script.
*/
async function checkInstallPython311(languages, codeql) {
if (languages.includes(languages_1.Language.python) &&
if (languages.includes(languages_1.KnownLanguage.python) &&
process.platform === "win32" &&
!(await codeql.getVersion()).features?.supportsPython312) {
const script = path.resolve(__dirname, "../python-setup", "check_python12.ps1");
@@ -98,7 +98,7 @@ function cleanupDatabaseClusterDirectory(config, logger,
rmSync = fs.rmSync) {
if (fs.existsSync(config.dbLocation) &&
(fs.statSync(config.dbLocation).isFile() ||
fs.readdirSync(config.dbLocation).length)) {
fs.readdirSync(config.dbLocation).length > 0)) {
logger.warning(`The database cluster directory ${config.dbLocation} must be empty. Attempting to clean it up.`);
try {
rmSync(config.dbLocation, {

View File

@@ -1 +1 @@
{"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,gCAyCC;AAED,gCAMC;AAED,0BAkCC;AAMD,sDAkBC;AAED,0EAkDC;AApLD,uCAAyB;AACzB,2CAA6B;AAE7B,yEAA2D;AAC3D,gDAAkC;AAElC,iDAAsE;AAEtE,qCAA+C;AAC/C,4DAA8C;AAE9C,2CAAuC;AACvC,uCAAmD;AAInD,mDAAwE;AACxE,6CAA+B;AAExB,KAAK,UAAU,UAAU,CAC9B,UAA8B,EAC9B,UAA4B,EAC5B,OAAe,EACf,OAA2B,EAC3B,iBAA2C,EAC3C,QAA2B,EAC3B,MAAc;IAQd,MAAM,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC;IACxC,MAAM,EACJ,MAAM,EACN,yBAAyB,EACzB,WAAW,EACX,YAAY,EACZ,gBAAgB,GACjB,GAAG,MAAM,IAAA,oBAAW,EACnB,UAAU,EACV,UAAU,EACV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AE,EAAE,CAAC;gBACzB,MAAM,IAAI,IAAI,CAAC,kBAAkB,CAC/B,GAAG,KAAK,4GAA4G;oBAClH,sEAAsE,IAAI,CAAC,eAAe,CACxF,CAAC,CACF,EAAE,CACN,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,KAAK,CACb,GAAG,KAAK,sDAAsD;oBAC5D,+EAA+E;oBAC/E,yCAAyC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,CACrE,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC"}

77
lib/languages.js generated
View File

@@ -1,66 +1,23 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LANGUAGE_ALIASES = exports.Language = void 0;
exports.parseLanguage = parseLanguage;
exports.isTracedLanguage = isTracedLanguage;
exports.isScannedLanguage = isScannedLanguage;
// All the languages supported by CodeQL
var Language;
(function (Language) {
Language["actions"] = "actions";
Language["csharp"] = "csharp";
Language["cpp"] = "cpp";
Language["go"] = "go";
Language["java"] = "java";
Language["javascript"] = "javascript";
Language["python"] = "python";
Language["ruby"] = "ruby";
Language["rust"] = "rust";
Language["swift"] = "swift";
})(Language || (exports.Language = Language = {}));
// Additional names for languages
exports.LANGUAGE_ALIASES = {
c: Language.cpp,
"c++": Language.cpp,
"c#": Language.csharp,
kotlin: Language.java,
typescript: Language.javascript,
"javascript-typescript": Language.javascript,
"java-kotlin": Language.java,
};
exports.KnownLanguage = void 0;
/**
* Translate from user input or GitHub's API names for languages to CodeQL's
* names for languages.
* A language supported by CodeQL that is treated specially by the Action.
*
* @param language The language to translate.
* @returns A language supported by CodeQL, an alias for a language, or
* `undefined` if the input language cannot be parsed into a language supported
* by CodeQL.
* This is not an exhaustive list of languages supported by CodeQL and new
* languages do not need to be added here.
*/
function parseLanguage(language) {
// Normalise to lower case
language = language.trim().toLowerCase();
// See if it's an exact match
if (language in Language) {
return language;
}
// Check language aliases, but return the original language name,
// the alias will be resolved later.
if (language in exports.LANGUAGE_ALIASES) {
return exports.LANGUAGE_ALIASES[language];
}
return undefined;
}
function isTracedLanguage(language) {
return [
Language.cpp,
Language.csharp,
Language.go,
Language.java,
Language.swift,
].includes(language);
}
function isScannedLanguage(language) {
return !isTracedLanguage(language);
}
var KnownLanguage;
(function (KnownLanguage) {
KnownLanguage["actions"] = "actions";
KnownLanguage["cpp"] = "cpp";
KnownLanguage["csharp"] = "csharp";
KnownLanguage["go"] = "go";
KnownLanguage["java"] = "java";
KnownLanguage["javascript"] = "javascript";
KnownLanguage["python"] = "python";
KnownLanguage["ruby"] = "ruby";
KnownLanguage["rust"] = "rust";
KnownLanguage["swift"] = "swift";
})(KnownLanguage || (exports.KnownLanguage = KnownLanguage = {}));
//# sourceMappingURL=languages.js.map

View File

@@ -1 +1 @@
{"version":3,"file":"languages.js","sourceRoot":"","sources":["../src/languages.ts"],"names":[],"mappings":";;;AAkCA,sCAgBC;AAED,4CAQC;AAED,8CAEC;AAhED,wCAAwC;AACxC,IAAY,QAWX;AAXD,WAAY,QAAQ;IAClB,+BAAmB,CAAA;IACnB,6BAAiB,CAAA;IACjB,uBAAW,CAAA;IACX,qBAAS,CAAA;IACT,yBAAa,CAAA;IACb,qCAAyB,CAAA;IACzB,6BAAiB,CAAA;IACjB,yBAAa,CAAA;IACb,yBAAa,CAAA;IACb,2BAAe,CAAA;AACjB,CAAC,EAXW,QAAQ,wBAAR,QAAQ,QAWnB;AAED,iCAAiC;AACpB,QAAA,gBAAgB,GAAiC;IAC5D,CAAC,EAAE,QAAQ,CAAC,GAAG;IACf,KAAK,EAAE,QAAQ,CAAC,GAAG;IACnB,IAAI,EAAE,QAAQ,CAAC,MAAM;IACrB,MAAM,EAAE,QAAQ,CAAC,IAAI;IACrB,UAAU,EAAE,QAAQ,CAAC,UAAU;IAC/B,uBAAuB,EAAE,QAAQ,CAAC,UAAU;IAC5C,aAAa,EAAE,QAAQ,CAAC,IAAI;CAC7B,CAAC;AAEF;;;;;;;;GAQG;AACH,SAAgB,aAAa,CAAC,QAAgB;IAC5C,0BAA0B;IAC1B,QAAQ,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAEzC,6BAA6B;IAC7B,IAAI,QAAQ,IAAI,QAAQ,EAAE,CAAC;QACzB,OAAO,QAAoB,CAAC;IAC9B,CAAC;IAED,iEAAiE;IACjE,oCAAoC;IACpC,IAAI,QAAQ,IAAI,wBAAgB,EAAE,CAAC;QACjC,OAAO,wBAAgB,CAAC,QAAQ,CAAC,CAAC;IACpC,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAgB,gBAAgB,CAAC,QAAkB;IACjD,OAAO;QACL,QAAQ,CAAC,GAAG;QACZ,QAAQ,CAAC,MAAM;QACf,QAAQ,CAAC,EAAE;QACX,QAAQ,CAAC,IAAI;QACb,QAAQ,CAAC,KAAK;KACf,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACvB,CAAC;AAED,SAAgB,iBAAiB,CAAC,QAAkB;IAClD,OAAO,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;AACrC,CAAC"}
{"version":3,"file":"languages.js","sourceRoot":"","sources":["../src/languages.ts"],"names":[],"mappings":";;;AAGA;;;;;GAKG;AACH,IAAY,aAWX;AAXD,WAAY,aAAa;IACvB,oCAAmB,CAAA;IACnB,4BAAW,CAAA;IACX,kCAAiB,CAAA;IACjB,0BAAS,CAAA;IACT,8BAAa,CAAA;IACb,0CAAyB,CAAA;IACzB,kCAAiB,CAAA;IACjB,8BAAa,CAAA;IACb,8BAAa,CAAA;IACb,gCAAe,CAAA;AACjB,CAAC,EAXW,aAAa,6BAAb,aAAa,QAWxB"}

55
lib/languages.test.js generated
View File

@@ -1,55 +0,0 @@
"use strict";
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 languages_1 = require("./languages");
const testing_utils_1 = require("./testing-utils");
(0, testing_utils_1.setupTests)(ava_1.default);
(0, ava_1.default)("parseLanguage", async (t) => {
// Exact matches
t.deepEqual((0, languages_1.parseLanguage)("csharp"), languages_1.Language.csharp);
t.deepEqual((0, languages_1.parseLanguage)("cpp"), languages_1.Language.cpp);
t.deepEqual((0, languages_1.parseLanguage)("go"), languages_1.Language.go);
t.deepEqual((0, languages_1.parseLanguage)("java"), languages_1.Language.java);
t.deepEqual((0, languages_1.parseLanguage)("javascript"), languages_1.Language.javascript);
t.deepEqual((0, languages_1.parseLanguage)("python"), languages_1.Language.python);
t.deepEqual((0, languages_1.parseLanguage)("rust"), languages_1.Language.rust);
// Aliases
t.deepEqual((0, languages_1.parseLanguage)("c"), languages_1.Language.cpp);
t.deepEqual((0, languages_1.parseLanguage)("c++"), languages_1.Language.cpp);
t.deepEqual((0, languages_1.parseLanguage)("c#"), languages_1.Language.csharp);
t.deepEqual((0, languages_1.parseLanguage)("kotlin"), languages_1.Language.java);
t.deepEqual((0, languages_1.parseLanguage)("typescript"), languages_1.Language.javascript);
// spaces and case-insensitivity
t.deepEqual((0, languages_1.parseLanguage)(" \t\nCsHaRp\t\t"), languages_1.Language.csharp);
t.deepEqual((0, languages_1.parseLanguage)(" \t\nkOtLin\t\t"), languages_1.Language.java);
// Not matches
t.deepEqual((0, languages_1.parseLanguage)("foo"), undefined);
t.deepEqual((0, languages_1.parseLanguage)(" "), undefined);
t.deepEqual((0, languages_1.parseLanguage)(""), undefined);
});
(0, ava_1.default)("isTracedLanguage", async (t) => {
t.true((0, languages_1.isTracedLanguage)(languages_1.Language.cpp));
t.true((0, languages_1.isTracedLanguage)(languages_1.Language.csharp));
t.true((0, languages_1.isTracedLanguage)(languages_1.Language.go));
t.true((0, languages_1.isTracedLanguage)(languages_1.Language.java));
t.true((0, languages_1.isTracedLanguage)(languages_1.Language.swift));
t.false((0, languages_1.isTracedLanguage)(languages_1.Language.javascript));
t.false((0, languages_1.isTracedLanguage)(languages_1.Language.python));
t.false((0, languages_1.isTracedLanguage)(languages_1.Language.ruby));
t.false((0, languages_1.isTracedLanguage)(languages_1.Language.rust));
});
(0, ava_1.default)("isScannedLanguage", async (t) => {
t.false((0, languages_1.isScannedLanguage)(languages_1.Language.cpp));
t.false((0, languages_1.isScannedLanguage)(languages_1.Language.csharp));
t.false((0, languages_1.isScannedLanguage)(languages_1.Language.go));
t.false((0, languages_1.isScannedLanguage)(languages_1.Language.java));
t.false((0, languages_1.isScannedLanguage)(languages_1.Language.swift));
t.true((0, languages_1.isScannedLanguage)(languages_1.Language.javascript));
t.true((0, languages_1.isScannedLanguage)(languages_1.Language.python));
t.true((0, languages_1.isScannedLanguage)(languages_1.Language.ruby));
t.true((0, languages_1.isScannedLanguage)(languages_1.Language.rust));
});
//# sourceMappingURL=languages.test.js.map

View File

@@ -1 +0,0 @@
{"version":3,"file":"languages.test.js","sourceRoot":"","sources":["../src/languages.test.ts"],"names":[],"mappings":";;;;;AAAA,8CAAuB;AAEvB,2CAKqB;AACrB,mDAA6C;AAE7C,IAAA,0BAAU,EAAC,aAAI,CAAC,CAAC;AAEjB,IAAA,aAAI,EAAC,eAAe,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAChC,gBAAgB;IAChB,CAAC,CAAC,SAAS,CAAC,IAAA,yBAAa,EAAC,QAAQ,CAAC,EAAE,oBAAQ,CAAC,MAAM,CAAC,CAAC;IACtD,CAAC,CAAC,SAAS,CAAC,IAAA,yBAAa,EAAC,KAAK,CAAC,EAAE,oBAAQ,CAAC,GAAG,CAAC,CAAC;IAChD,CAAC,CAAC,SAAS,CAAC,IAAA,yBAAa,EAAC,IAAI,CAAC,EAAE,oBAAQ,CAAC,EAAE,CAAC,CAAC;IAC9C,CAAC,CAAC,SAAS,CAAC,IAAA,yBAAa,EAAC,MAAM,CAAC,EAAE,oBAAQ,CAAC,IAAI,CAAC,CAAC;IAClD,CAAC,CAAC,SAAS,CAAC,IAAA,yBAAa,EAAC,YAAY,CAA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EAAC,oBAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;IACxC,CAAC,CAAC,KAAK,CAAC,IAAA,6BAAiB,EAAC,oBAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1C,CAAC,CAAC,KAAK,CAAC,IAAA,6BAAiB,EAAC,oBAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;IAE3C,CAAC,CAAC,IAAI,CAAC,IAAA,6BAAiB,EAAC,oBAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;IAC/C,CAAC,CAAC,IAAI,CAAC,IAAA,6BAAiB,EAAC,oBAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IAC3C,CAAC,CAAC,IAAI,CAAC,IAAA,6BAAiB,EAAC,oBAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;IACzC,CAAC,CAAC,IAAI,CAAC,IAAA,6BAAiB,EAAC,oBAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;AAC3C,CAAC,CAAC,CAAC"}

View File

@@ -44,6 +44,7 @@ const path = __importStar(require("path"));
const actionsCache = __importStar(require("@actions/cache"));
const actions_util_1 = require("./actions-util");
const git_utils_1 = require("./git-utils");
const logging_1 = require("./logging");
const util_1 = require("./util");
var OverlayDatabaseMode;
(function (OverlayDatabaseMode) {
@@ -186,6 +187,10 @@ async function uploadOverlayBaseDatabaseToCache(codeql, config, logger) {
if (!databaseIsValid) {
return false;
}
// Clean up the database using the overlay cleanup level.
await (0, logging_1.withGroupAsync)("Cleaning up databases", async () => {
await codeql.databaseCleanupCluster(config, "overlay");
});
const dbLocation = config.dbLocation;
const codeQlVersion = (await codeql.getVersion()).version;
const checkoutPath = (0, actions_util_1.getRequiredInput)("checkout_path");

File diff suppressed because one or more lines are too long

2
lib/setup-codeql.js generated
View File

@@ -160,7 +160,7 @@ function tryGetBundleVersionFromTagName(tagName, logger) {
}
function tryGetTagNameFromUrl(url, logger) {
const matches = [...url.matchAll(/\/(codeql-bundle-[^/]*)\//g)];
if (!matches.length) {
if (matches.length === 0) {
logger.debug(`Could not determine tag name for URL ${url}.`);
return undefined;
}

File diff suppressed because one or more lines are too long

44
lib/start-proxy.js generated
View File

@@ -33,10 +33,48 @@ var __importStar = (this && this.__importStar) || (function () {
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseLanguage = parseLanguage;
exports.getCredentials = getCredentials;
const core = __importStar(require("@actions/core"));
const languages_1 = require("./languages");
const util_1 = require("./util");
/*
* Language aliases supported by the start-proxy Action.
*
* In general, the CodeQL CLI is the source of truth for language aliases, and to
* allow us to more easily support new languages, we want to avoid hardcoding these
* aliases in the Action itself. However this is difficult to do in the start-proxy
* Action since this Action does not use CodeQL, so we're accepting some hardcoding
* for this Action.
*/
const LANGUAGE_ALIASES = {
c: languages_1.KnownLanguage.cpp,
"c++": languages_1.KnownLanguage.cpp,
"c#": languages_1.KnownLanguage.csharp,
kotlin: languages_1.KnownLanguage.java,
typescript: languages_1.KnownLanguage.javascript,
"javascript-typescript": languages_1.KnownLanguage.javascript,
"java-kotlin": languages_1.KnownLanguage.java,
};
/**
* Parse the start-proxy language input into its canonical CodeQL language name.
*
* Exported for testing. Do not use this outside of the start-proxy Action
* to avoid complicating the process of adding new CodeQL languages.
*/
function parseLanguage(language) {
// Normalize to lower case
language = language.trim().toLowerCase();
// See if it's an exact match
if (language in languages_1.KnownLanguage) {
return language;
}
// Check language aliases
if (language in LANGUAGE_ALIASES) {
return LANGUAGE_ALIASES[language];
}
return undefined;
}
const LANGUAGE_TO_REGISTRY_TYPE = {
java: "maven_repository",
csharp: "nuget_feed",
@@ -45,10 +83,6 @@ const LANGUAGE_TO_REGISTRY_TYPE = {
ruby: "rubygems_server",
rust: "cargo_registry",
go: "goproxy_server",
// We do not have an established proxy type for these languages, thus leaving empty.
actions: "",
cpp: "",
swift: "",
};
/**
* Checks that `value` is neither `undefined` nor `null`.
@@ -62,7 +96,7 @@ function isDefined(value) {
// It prefers `registries_credentials` over `registry_secrets`.
// If neither is set, it returns an empty array.
function getCredentials(logger, registrySecrets, registriesCredentials, languageString) {
const language = languageString ? (0, languages_1.parseLanguage)(languageString) : undefined;
const language = languageString ? parseLanguage(languageString) : undefined;
const registryTypeForLanguage = language
? LANGUAGE_TO_REGISTRY_TYPE[language]
: undefined;

View File

@@ -1 +1 @@
{"version":3,"file":"start-proxy.js","sourceRoot":"","sources":["../src/start-proxy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,wCA8FC;AAvID,oDAAsC;AAEtC,2CAAsD;AAEtD,iCAA4C;AAW5C,MAAM,yBAAyB,GAA6B;IAC1D,IAAI,EAAE,kBAAkB;IACxB,MAAM,EAAE,YAAY;IACpB,UAAU,EAAE,cAAc;IAC1B,MAAM,EAAE,cAAc;IACtB,IAAI,EAAE,iBAAiB;IACvB,IAAI,EAAE,gBAAgB;IACtB,EAAE,EAAE,gBAAgB;IACpB,oFAAoF;IACpF,OAAO,EAAE,EAAE;IACX,GAAG,EAAE,EAAE;IACP,KAAK,EAAE,EAAE;CACD,CAAC;AAEX;;;;GAIG;AACH,SAAS,SAAS,CAAI,KAA2B;IAC/C,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC;AAC/C,CAAC;AAED,kEAAkE;AAClE,+DAA+D;AAC/D,gDAAgD;AAChD,SAAgB,cAAc,CAC5B,MAAc,EACd,eAAmC,EACnC,qBAAyC,EACzC,cAAkC;IAElC,MAAM,QAAQ,GAAG,cAAc,CAAC,CAAC,CAAC,IAAA,yBAAa,EAAC,cAAc,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5E,MAAM,uBAAuB,GAAG,QAAQ;QACtC,CAAC,CAAC,yBAAyB,CAAC,QAAQ,CAAC;QACrC,CAAC,CAAC,SAAS,CAAC;IAEd,IAAI,cAAsB,CAAC;IAC3B,IAAI,qBAAqB,KAAK,SAAS,EAAE,CAAC;QACxC,MAAM,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC;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AAC,CAAC,CAAC,KAAK,CAAC,EACrB,CAAC;YACD,MAAM,IAAI,yBAAkB,CAC1B,qEAAqE,CACtE,CAAC;QACJ,CAAC;QAED,GAAG,CAAC,IAAI,CAAC;YACP,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,GAAG,EAAE,CAAC,CAAC,GAAG;YACV,QAAQ,EAAE,CAAC,CAAC,QAAQ;YACpB,QAAQ,EAAE,CAAC,CAAC,QAAQ;YACpB,KAAK,EAAE,CAAC,CAAC,KAAK;SACf,CAAC,CAAC;IACL,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}

View File

@@ -37,8 +37,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
};
Object.defineProperty(exports, "__esModule", { value: true });
const ava_1 = __importDefault(require("ava"));
const languages_1 = require("./languages");
const logging_1 = require("./logging");
const startProxyExports = __importStar(require("./start-proxy"));
const start_proxy_1 = require("./start-proxy");
const testing_utils_1 = require("./testing-utils");
(0, testing_utils_1.setupTests)(ava_1.default);
const toEncodedJSON = (data) => Buffer.from(JSON.stringify(data)).toString("base64");
@@ -119,4 +121,27 @@ const toEncodedJSON = (data) => Buffer.from(JSON.stringify(data)).toString("base
});
}
});
(0, ava_1.default)("parseLanguage", async (t) => {
// Exact matches
t.deepEqual((0, start_proxy_1.parseLanguage)("csharp"), languages_1.KnownLanguage.csharp);
t.deepEqual((0, start_proxy_1.parseLanguage)("cpp"), languages_1.KnownLanguage.cpp);
t.deepEqual((0, start_proxy_1.parseLanguage)("go"), languages_1.KnownLanguage.go);
t.deepEqual((0, start_proxy_1.parseLanguage)("java"), languages_1.KnownLanguage.java);
t.deepEqual((0, start_proxy_1.parseLanguage)("javascript"), languages_1.KnownLanguage.javascript);
t.deepEqual((0, start_proxy_1.parseLanguage)("python"), languages_1.KnownLanguage.python);
t.deepEqual((0, start_proxy_1.parseLanguage)("rust"), languages_1.KnownLanguage.rust);
// Aliases
t.deepEqual((0, start_proxy_1.parseLanguage)("c"), languages_1.KnownLanguage.cpp);
t.deepEqual((0, start_proxy_1.parseLanguage)("c++"), languages_1.KnownLanguage.cpp);
t.deepEqual((0, start_proxy_1.parseLanguage)("c#"), languages_1.KnownLanguage.csharp);
t.deepEqual((0, start_proxy_1.parseLanguage)("kotlin"), languages_1.KnownLanguage.java);
t.deepEqual((0, start_proxy_1.parseLanguage)("typescript"), languages_1.KnownLanguage.javascript);
// spaces and case-insensitivity
t.deepEqual((0, start_proxy_1.parseLanguage)(" \t\nCsHaRp\t\t"), languages_1.KnownLanguage.csharp);
t.deepEqual((0, start_proxy_1.parseLanguage)(" \t\nkOtLin\t\t"), languages_1.KnownLanguage.java);
// Not matches
t.deepEqual((0, start_proxy_1.parseLanguage)("foo"), undefined);
t.deepEqual((0, start_proxy_1.parseLanguage)(" "), undefined);
t.deepEqual((0, start_proxy_1.parseLanguage)(""), undefined);
});
//# sourceMappingURL=start-proxy.test.js.map

File diff suppressed because one or more lines are too long

View File

@@ -66,7 +66,7 @@ function setupEnvironmentAndStub(tmpDir) {
setupEnvironmentAndStub(tmpDir);
const statusReport = await (0, status_report_1.createStatusReportBase)(status_report_1.ActionName.Init, "failure", new Date("May 19, 2023 05:19:00"), (0, testing_utils_1.createTestConfig)({
buildMode: util_1.BuildMode.None,
languages: [languages_1.Language.java, languages_1.Language.swift],
languages: [languages_1.KnownLanguage.java, languages_1.KnownLanguage.swift],
}), { numAvailableBytes: 100, numTotalBytes: 500 }, (0, logging_1.getRunnerLogger)(false), "failure cause", "exception stack trace");
t.truthy(statusReport);
if (statusReport !== undefined) {

File diff suppressed because one or more lines are too long

2
lib/testing-utils.js generated
View File

@@ -233,7 +233,7 @@ const makeVersionInfo = (version, features) => ({
});
exports.makeVersionInfo = makeVersionInfo;
function mockCodeQLVersion(version, features) {
return codeql.setCodeQL({
return codeql.createStubCodeQL({
async getVersion() {
return (0, exports.makeVersionInfo)(version, features);
},

File diff suppressed because one or more lines are too long

5
lib/tracer-config.js generated
View File

@@ -39,9 +39,8 @@ exports.getTracerConfigForCluster = getTracerConfigForCluster;
exports.getCombinedTracerConfig = getCombinedTracerConfig;
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
const languages_1 = require("./languages");
const util_1 = require("./util");
async function shouldEnableIndirectTracing(_codeql, config) {
async function shouldEnableIndirectTracing(codeql, config) {
// We don't need to trace build mode none, or languages which unconditionally don't need tracing.
if (config.buildMode === util_1.BuildMode.None) {
return false;
@@ -52,7 +51,7 @@ async function shouldEnableIndirectTracing(_codeql, config) {
return false;
}
// Otherwise, use direct tracing if any of the languages need to be traced.
return config.languages.some((l) => (0, languages_1.isTracedLanguage)(l));
return (0, util_1.asyncSome)(config.languages, (l) => codeql.isTracedLanguage(l));
}
/**
* Delete variables as specified by the end-tracing script

View File

@@ -1 +1 @@
{"version":3,"file":"tracer-config.js","sourceRoot":"","sources":["../src/tracer-config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,kEAiBC;AAWD,oDAoCC;AAED,8DAeC;AAED,0DASC;AAzGD,uCAAyB;AACzB,2CAA6B;AAI7B,2CAA+C;AAE/C,iCAAmC;AAM5B,KAAK,UAAU,2BAA2B,CAC/C,OAAe,EACf,MAAc;IAEd,iGAAiG;IACjG,IAAI,MAAM,CAAC,SAAS,KAAK,gBAAS,CAAC,IAAI,EAAE,CAAC;QACxC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,iGAAiG;IACjG,oBAAoB;IACpB,IAAI,MAAM,CAAC,SAAS,KAAK,gBAAS,CAAC,SAAS,EAAE,CAAC;QAC7C,OAAO,KAAK,CAAC;IACf,CAAC;IAED,2EAA2E;IAC3E,OAAO,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,4BAAgB,EAAC,CAAC,CAAC,CAAC,CAAC;AAC3D,CAAC;AAED;;;;;;;;GAQG;AACI,KAAK,UAAU,oBAAoB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Property(exports, "__esModule", { value: true });
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
const ava_1 = __importDefault(require("ava"));
const sinon = __importStar(require("sinon"));
const codeql_1 = require("./codeql");
const languages_1 = require("./languages");
const testing_utils_1 = require("./testing-utils");
const tracer_config_1 = require("./tracer-config");
@@ -46,17 +48,28 @@ const util = __importStar(require("./util"));
(0, testing_utils_1.setupTests)(ava_1.default);
function getTestConfig(tempDir) {
return (0, testing_utils_1.createTestConfig)({
languages: [languages_1.Language.java],
languages: [languages_1.KnownLanguage.java],
tempDir,
dbLocation: path.resolve(tempDir, "codeql_databases"),
});
}
async function stubCodeql(enabledFeatures = []) {
const codeqlObject = await (0, codeql_1.getCodeQLForTesting)();
sinon
.stub(codeqlObject, "getVersion")
.resolves((0, testing_utils_1.makeVersionInfo)("1.0.0", Object.fromEntries(enabledFeatures.map((f) => [f, true]))));
sinon
.stub(codeqlObject, "isTracedLanguage")
.withArgs(languages_1.KnownLanguage.java)
.resolves(true);
return codeqlObject;
}
(0, ava_1.default)("getCombinedTracerConfig - return undefined when no languages are traced languages", async (t) => {
await util.withTmpDir(async (tmpDir) => {
const config = getTestConfig(tmpDir);
// No traced languages
config.languages = [languages_1.Language.javascript, languages_1.Language.python];
t.deepEqual(await (0, tracer_config_1.getCombinedTracerConfig)((0, testing_utils_1.mockCodeQLVersion)("1.0.0"), config), undefined);
config.languages = [languages_1.KnownLanguage.javascript, languages_1.KnownLanguage.python];
t.deepEqual(await (0, tracer_config_1.getCombinedTracerConfig)(await stubCodeql(), config), undefined);
});
});
(0, ava_1.default)("getCombinedTracerConfig", async (t) => {
@@ -77,7 +90,7 @@ function getTestConfig(tempDir) {
fs.mkdirSync(tracingEnvironmentDir, { recursive: true });
const startTracingJson = path.join(tracingEnvironmentDir, "start-tracing.json");
fs.writeFileSync(startTracingJson, JSON.stringify(startTracingEnv));
const result = await (0, tracer_config_1.getCombinedTracerConfig)((0, testing_utils_1.mockCodeQLVersion)("1.0.0"), config);
const result = await (0, tracer_config_1.getCombinedTracerConfig)(await stubCodeql(), config);
t.notDeepEqual(result, undefined);
t.false(Object.prototype.hasOwnProperty.call(result?.env, "CODEQL_RUNNER"));
});

View File

@@ -1 +1 @@
{"version":3,"file":"tracer-config.test.js","sourceRoot":"","sources":["../src/tracer-config.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,8CAAuB;AAGvB,2CAAuC;AACvC,mDAIyB;AACzB,mDAA0D;AAC1D,6CAA+B;AAE/B,IAAA,0BAAU,EAAC,aAAI,CAAC,CAAC;AAEjB,SAAS,aAAa,CAAC,OAAe;IACpC,OAAO,IAAA,gCAAgB,EAAC;QACtB,SAAS,EAAE,CAAC,oBAAQ,CAAC,IAAI,CAAC;QAC1B,OAAO;QACP,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,kBAAkB,CAAC;KACtD,CAAC,CAAC;AACL,CAAC;AAED,IAAA,aAAI,EAAC,mFAAmF,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IACpG,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;QACrC,sBAAsB;QACtB,MAAM,CAAC,SAAS,GAAG,CAAC,oBAAQ,CAAC,UAAU,EAAE,oBAAQ,CAAC,MAAM,CAAC,CAAC;QAC1D,CAAC,CAAC,SAAS,CACT,MAAM,IAAA,uCAAuB,EAAC,IAAA,iCAAiB,EAAC,OAAO,CAAC,EAAE,MAAM,CAAC,EACjE,SAAS,CACV,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,IAAA,aAAI,EAAC,yBAAyB,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAC1C,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,EAA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EAAE,SAAS,CAAC,CAAC;QAElC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,eAAe,CAAC,CAAC,CAAC;IAC9E,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}

File diff suppressed because one or more lines are too long

View File

@@ -52,14 +52,14 @@ const testing_utils_1 = require("./testing-utils");
const trap_caching_1 = require("./trap-caching");
const util = __importStar(require("./util"));
(0, testing_utils_1.setupTests)(ava_1.default);
const stubCodeql = (0, codeql_1.setCodeQL)({
const stubCodeql = (0, codeql_1.createStubCodeQL)({
async getVersion() {
return (0, testing_utils_1.makeVersionInfo)("2.10.3");
},
async betterResolveLanguages() {
return {
extractors: {
[languages_1.Language.javascript]: [
[languages_1.KnownLanguage.javascript]: [
{
extractor_root: "some_root",
extractor_options: {
@@ -83,7 +83,7 @@ const stubCodeql = (0, codeql_1.setCodeQL)({
},
},
],
[languages_1.Language.cpp]: [
[languages_1.KnownLanguage.cpp]: [
{
extractor_root: "other_root",
},
@@ -93,14 +93,14 @@ const stubCodeql = (0, codeql_1.setCodeQL)({
},
});
const testConfigWithoutTmpDir = (0, testing_utils_1.createTestConfig)({
languages: [languages_1.Language.javascript, languages_1.Language.cpp],
languages: [languages_1.KnownLanguage.javascript, languages_1.KnownLanguage.cpp],
trapCaches: {
javascript: "/some/cache/dir",
},
});
function getTestConfigWithTempDir(tempDir) {
return (0, testing_utils_1.createTestConfig)({
languages: [languages_1.Language.javascript, languages_1.Language.ruby],
languages: [languages_1.KnownLanguage.javascript, languages_1.KnownLanguage.ruby],
tempDir,
dbLocation: path.resolve(tempDir, "codeql_databases"),
trapCaches: {
@@ -113,7 +113,7 @@ function getTestConfigWithTempDir(tempDir) {
await util.withTmpDir(async (tmpDir) => {
const config = getTestConfigWithTempDir(tmpDir);
sinon.stub(gitUtils, "isAnalyzingDefaultBranch").resolves(true);
const result = await (0, codeql_1.getTrapCachingExtractorConfigArgsForLang)(config, languages_1.Language.javascript);
const result = await (0, codeql_1.getTrapCachingExtractorConfigArgsForLang)(config, languages_1.KnownLanguage.javascript);
t.deepEqual(result, [
`-O=javascript.trap.cache.dir=${path.resolve(tmpDir, "jsCache")}`,
"-O=javascript.trap.cache.bound=1024",
@@ -139,8 +139,8 @@ function getTestConfigWithTempDir(tempDir) {
(0, ava_1.default)("get languages that support TRAP caching", async (t) => {
const loggedMessages = [];
const logger = (0, testing_utils_1.getRecordingLogger)(loggedMessages);
const languagesSupportingCaching = await (0, trap_caching_1.getLanguagesSupportingCaching)(stubCodeql, [languages_1.Language.javascript, languages_1.Language.cpp], logger);
t.deepEqual(languagesSupportingCaching, [languages_1.Language.javascript]);
const languagesSupportingCaching = await (0, trap_caching_1.getLanguagesSupportingCaching)(stubCodeql, [languages_1.KnownLanguage.javascript, languages_1.KnownLanguage.cpp], logger);
t.deepEqual(languagesSupportingCaching, [languages_1.KnownLanguage.javascript]);
});
(0, ava_1.default)("upload cache key contains right fields", async (t) => {
const loggedMessages = [];
@@ -172,7 +172,7 @@ function getTestConfigWithTempDir(tempDir) {
},
},
}));
await (0, trap_caching_1.downloadTrapCaches)(stubCodeql, [languages_1.Language.javascript, languages_1.Language.cpp], logger);
await (0, trap_caching_1.downloadTrapCaches)(stubCodeql, [languages_1.KnownLanguage.javascript, languages_1.KnownLanguage.cpp], logger);
t.assert(stubRestore.calledOnceWith(sinon.match.array.contains([
path.resolve(tmpDir, "trapCaches", "javascript"),
]), sinon

File diff suppressed because one or more lines are too long

2
lib/upload-lib.js generated
View File

@@ -387,7 +387,7 @@ function validateSarifFileSchema(sarif, sarifFilePath, logger) {
for (const warning of warnings) {
logger.info(`Warning: '${warning.instance}' is not a valid URI in '${warning.property}'.`);
}
if (errors.length) {
if (errors.length > 0) {
// Output the more verbose error messages in groups as these may be very large.
for (const error of errors) {
logger.startGroup(`Error details: ${error.stack}`);

File diff suppressed because one or more lines are too long

View File

@@ -80,7 +80,7 @@ async function run() {
if (fs.lstatSync(sarifPath).isDirectory()) {
const qualitySarifFiles = upload_lib.findSarifFilesInDir(sarifPath, upload_lib.CodeQualityTarget.sarifPredicate);
if (qualitySarifFiles.length !== 0) {
await upload_lib.uploadSpecifiedFiles(qualitySarifFiles, checkoutPath, category, features, logger, upload_lib.CodeQualityTarget);
await upload_lib.uploadSpecifiedFiles(qualitySarifFiles, checkoutPath, actionsUtil.fixCodeQualityCategory(logger, category), features, logger, upload_lib.CodeQualityTarget);
}
}
// We don't upload results in test mode, so don't wait for processing

View File

@@ -1 +1 @@
{"version":3,"file":"upload-sarif-action.js","sourceRoot":"","sources":["../src/upload-sarif-action.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AAEzB,oDAAsC;AAEtC,4DAA8C;AAC9C,iDAAyE;AACzE,6CAAgD;AAChD,mDAA2C;AAC3C,uCAAqD;AACrD,6CAAgD;AAChD,mDAOyB;AACzB,yDAA2C;AAC3C,iCAQgB;AAMhB,KAAK,UAAU,uBAAuB,CACpC,SAAe,EACf,WAA0C,EAC1C,MAAc;IAEd,MAAM,gBAAgB,GAAG,MAAM,IAAA,sCAAsB,EACnD,0BAAU,CAAC,WAAW,EACtB,SAAS,EACT,SAAS,EACT,SAAS,EACT,MAAM,IAAA,qBAAc,EAAC,MAAM,CAAC,EAC5B,MAAM,CACP,CAAC;IACF,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;QACnC,MAAM,YAAY,GAA4B;YAC5C,GAAG,gBAAgB;YACnB,GAAG,WAAW;SACf,CAAC;QACF,MAAM,IAAA,gCAAgB,EAAC,YAAY,CAAC,CAAC;IACvC,CAAC;AACH,CAAC;AAED,KAAK,UAAU,GAAG;IAChB,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;IAC7B,MAAM,MAAM,GAAG,IAAA,0BAAgB,GAAE,CAAC;IAClC,IAAA,4BAAqB,EAAC,IAAA,+BAAgB,GAAE,CA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,IAAA,qBAAc,EAAC,MAAM,CAAC,EAC5B,MAAM,EACN,OAAO,EACP,KAAK,CAAC,KAAK,CACZ,CAAC;QACF,IAAI,qBAAqB,KAAK,SAAS,EAAE,CAAC;YACxC,MAAM,IAAA,gCAAgB,EAAC,qBAAqB,CAAC,CAAC;QAChD,CAAC;QACD,OAAO;IACT,CAAC;AACH,CAAC;AAED,KAAK,UAAU,UAAU;IACvB,IAAI,CAAC;QACH,MAAM,GAAG,EAAE,CAAC;IACd,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,SAAS,CACZ,sCAAsC,IAAA,sBAAe,EAAC,KAAK,CAAC,EAAE,CAC/D,CAAC;IACJ,CAAC;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"}
{"version":3,"file":"upload-sarif-action.js","sourceRoot":"","sources":["../src/upload-sarif-action.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AAEzB,oDAAsC;AAEtC,4DAA8C;AAC9C,iDAAyE;AACzE,6CAAgD;AAChD,mDAA2C;AAC3C,uCAAqD;AACrD,6CAAgD;AAChD,mDAOyB;AACzB,yDAA2C;AAC3C,iCAQgB;AAMhB,KAAK,UAAU,uBAAuB,CACpC,SAAe,EACf,WAA0C,EAC1C,MAAc;IAEd,MAAM,gBAAgB,GAAG,MAAM,IAAA,sCAAsB,EACnD,0BAAU,CAAC,WAAW,EACtB,SAAS,EACT,SAAS,EACT,SAAS,EACT,MAAM,IAAA,qBAAc,EAAC,MAAM,CAAC,EAC5B,MAAM,CACP,CAAC;IACF,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;QACnC,MAAM,YAAY,GAA4B;YAC5C,GAAG,gBAAgB;YACnB,GAAG,WAAW;SACf,CAAC;QACF,MAAM,IAAA,gCAAgB,EAAC,YAAY,CAAC,CAAC;IACvC,CAAC;AACH,CAAC;AAED,KAAK,UAAU,GAAG;IAChB,MAAM,SAAS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AAC,SAAS,CAAC,OAAO,CAAC,CAAC;QAExB,MAAM,qBAAqB,GAAG,MAAM,IAAA,sCAAsB,EACxD,0BAAU,CAAC,WAAW,EACtB,IAAA,gCAAgB,EAAC,KAAK,CAAC,EACvB,SAAS,EACT,SAAS,EACT,MAAM,IAAA,qBAAc,EAAC,MAAM,CAAC,EAC5B,MAAM,EACN,OAAO,EACP,KAAK,CAAC,KAAK,CACZ,CAAC;QACF,IAAI,qBAAqB,KAAK,SAAS,EAAE,CAAC;YACxC,MAAM,IAAA,gCAAgB,EAAC,qBAAqB,CAAC,CAAC;QAChD,CAAC;QACD,OAAO;IACT,CAAC;AACH,CAAC;AAED,KAAK,UAAU,UAAU;IACvB,IAAI,CAAC;QACH,MAAM,GAAG,EAAE,CAAC;IACd,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,SAAS,CACZ,sCAAsC,IAAA,sBAAe,EAAC,KAAK,CAAC,EAAE,CAC/D,CAAC;IACJ,CAAC;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"}

20
lib/util.js generated
View File

@@ -82,6 +82,8 @@ exports.cloneObject = cloneObject;
exports.checkSipEnablement = checkSipEnablement;
exports.cleanUpGlob = cleanUpGlob;
exports.isBinaryAccessible = isBinaryAccessible;
exports.asyncFilter = asyncFilter;
exports.asyncSome = asyncSome;
const fs = __importStar(require("fs"));
const os = __importStar(require("os"));
const path = __importStar(require("path"));
@@ -496,11 +498,11 @@ function assertNever(value) {
* knowing what version of CodeQL we're running.
*/
function initializeEnvironment(version) {
core.exportVariable(String(environment_1.EnvVar.FEATURE_MULTI_LANGUAGE), "false");
core.exportVariable(String(environment_1.EnvVar.FEATURE_SANDWICH), "false");
core.exportVariable(String(environment_1.EnvVar.FEATURE_SARIF_COMBINE), "true");
core.exportVariable(String(environment_1.EnvVar.FEATURE_WILL_UPLOAD), "true");
core.exportVariable(String(environment_1.EnvVar.VERSION), version);
core.exportVariable(environment_1.EnvVar.FEATURE_MULTI_LANGUAGE, "false");
core.exportVariable(environment_1.EnvVar.FEATURE_SANDWICH, "false");
core.exportVariable(environment_1.EnvVar.FEATURE_SARIF_COMBINE, "true");
core.exportVariable(environment_1.EnvVar.FEATURE_WILL_UPLOAD, "true");
core.exportVariable(environment_1.EnvVar.VERSION, version);
}
/**
* Get an environment parameter, but throw an error if it is not set.
@@ -981,4 +983,12 @@ async function isBinaryAccessible(binary, logger) {
return false;
}
}
async function asyncFilter(array, predicate) {
const results = await Promise.all(array.map(predicate));
return array.filter((_, index) => results[index]);
}
async function asyncSome(array, predicate) {
const results = await Promise.all(array.map(predicate));
return results.some((result) => result);
}
//# sourceMappingURL=util.js.map

File diff suppressed because one or more lines are too long

268
node_modules/.package-lock.json generated vendored
View File

@@ -1,6 +1,6 @@
{
"name": "codeql",
"version": "3.29.6",
"version": "3.29.8",
"lockfileVersion": 3,
"requires": true,
"packages": {
@@ -1015,9 +1015,9 @@
}
},
"node_modules/@mswjs/interceptors": {
"version": "0.39.3",
"resolved": "https://registry.npmjs.org/@mswjs/interceptors/-/interceptors-0.39.3.tgz",
"integrity": "sha512-9bw/wBL7pblsnOCIqvn1788S9o4h+cC5HWXg0Xhh0dOzsZ53IyfmBM+FYqpDDPbm0xjCqEqvCITloF3Dm4TXRQ==",
"version": "0.39.5",
"resolved": "https://registry.npmjs.org/@mswjs/interceptors/-/interceptors-0.39.5.tgz",
"integrity": "sha512-B9nHSJYtsv79uo7QdkZ/b/WoKm20IkVSmTc/WCKarmDtFwM0dRx2ouEniqwNkzCSLn3fydzKmnMzjtfdOWt3VQ==",
"dev": true,
"license": "MIT",
"dependencies": {
@@ -1943,10 +1943,12 @@
"license": "MIT"
},
"node_modules/@types/node": {
"version": "20.9.0",
"version": "20.19.9",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.19.9.tgz",
"integrity": "sha512-cuVNgarYWZqxRJDQHEB58GEONhOK79QVR/qYx4S7kcUObQvUwvFnYxJuuHUKm2aieN9X3yZB4LZsuYNU1Qphsw==",
"license": "MIT",
"dependencies": {
"undici-types": "~5.26.4"
"undici-types": "~6.21.0"
}
},
"node_modules/@types/node-forge": {
@@ -1994,17 +1996,17 @@
"license": "MIT"
},
"node_modules/@typescript-eslint/eslint-plugin": {
"version": "8.38.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.38.0.tgz",
"integrity": "sha512-CPoznzpuAnIOl4nhj4tRr4gIPj5AfKgkiJmGQDaq+fQnRJTYlcBjbX3wbciGmpoPf8DREufuPRe1tNMZnGdanA==",
"version": "8.39.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.39.0.tgz",
"integrity": "sha512-bhEz6OZeUR+O/6yx9Jk6ohX6H9JSFTaiY0v9/PuKT3oGK0rn0jNplLmyFUGV+a9gfYnVNwGDwS/UkLIuXNb2Rw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@eslint-community/regexpp": "^4.10.0",
"@typescript-eslint/scope-manager": "8.38.0",
"@typescript-eslint/type-utils": "8.38.0",
"@typescript-eslint/utils": "8.38.0",
"@typescript-eslint/visitor-keys": "8.38.0",
"@typescript-eslint/scope-manager": "8.39.0",
"@typescript-eslint/type-utils": "8.39.0",
"@typescript-eslint/utils": "8.39.0",
"@typescript-eslint/visitor-keys": "8.39.0",
"graphemer": "^1.4.0",
"ignore": "^7.0.0",
"natural-compare": "^1.4.0",
@@ -2018,20 +2020,20 @@
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"@typescript-eslint/parser": "^8.38.0",
"@typescript-eslint/parser": "^8.39.0",
"eslint": "^8.57.0 || ^9.0.0",
"typescript": ">=4.8.4 <5.9.0"
"typescript": ">=4.8.4 <6.0.0"
}
},
"node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/scope-manager": {
"version": "8.38.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.38.0.tgz",
"integrity": "sha512-WJw3AVlFFcdT9Ri1xs/lg8LwDqgekWXWhH3iAF+1ZM+QPd7oxQ6jvtW/JPwzAScxitILUIFs0/AnQ/UWHzbATQ==",
"version": "8.39.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.39.0.tgz",
"integrity": "sha512-8QOzff9UKxOh6npZQ/4FQu4mjdOCGSdO3p44ww0hk8Vu+IGbg0tB/H1LcTARRDzGCC8pDGbh2rissBuuoPgH8A==",
"dev": true,
"license": "MIT",
"dependencies": {
"@typescript-eslint/types": "8.38.0",
"@typescript-eslint/visitor-keys": "8.38.0"
"@typescript-eslint/types": "8.39.0",
"@typescript-eslint/visitor-keys": "8.39.0"
},
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
@@ -2042,9 +2044,9 @@
}
},
"node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/types": {
"version": "8.38.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.38.0.tgz",
"integrity": "sha512-wzkUfX3plUqij4YwWaJyqhiPE5UCRVlFpKn1oCRn2O1bJ592XxWJj8ROQ3JD5MYXLORW84063z3tZTb/cs4Tyw==",
"version": "8.39.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.39.0.tgz",
"integrity": "sha512-ArDdaOllnCj3yn/lzKn9s0pBQYmmyme/v1HbGIGB0GB/knFI3fWMHloC+oYTJW46tVbYnGKTMDK4ah1sC2v0Kg==",
"dev": true,
"license": "MIT",
"engines": {
@@ -2056,16 +2058,16 @@
}
},
"node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/typescript-estree": {
"version": "8.38.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.38.0.tgz",
"integrity": "sha512-fooELKcAKzxux6fA6pxOflpNS0jc+nOQEEOipXFNjSlBS6fqrJOVY/whSn70SScHrcJ2LDsxWrneFoWYSVfqhQ==",
"version": "8.39.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.39.0.tgz",
"integrity": "sha512-ndWdiflRMvfIgQRpckQQLiB5qAKQ7w++V4LlCHwp62eym1HLB/kw7D9f2e8ytONls/jt89TEasgvb+VwnRprsw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@typescript-eslint/project-service": "8.38.0",
"@typescript-eslint/tsconfig-utils": "8.38.0",
"@typescript-eslint/types": "8.38.0",
"@typescript-eslint/visitor-keys": "8.38.0",
"@typescript-eslint/project-service": "8.39.0",
"@typescript-eslint/tsconfig-utils": "8.39.0",
"@typescript-eslint/types": "8.39.0",
"@typescript-eslint/visitor-keys": "8.39.0",
"debug": "^4.3.4",
"fast-glob": "^3.3.2",
"is-glob": "^4.0.3",
@@ -2081,20 +2083,20 @@
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"typescript": ">=4.8.4 <5.9.0"
"typescript": ">=4.8.4 <6.0.0"
}
},
"node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/utils": {
"version": "8.38.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.38.0.tgz",
"integrity": "sha512-hHcMA86Hgt+ijJlrD8fX0j1j8w4C92zue/8LOPAFioIno+W0+L7KqE8QZKCcPGc/92Vs9x36w/4MPTJhqXdyvg==",
"version": "8.39.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.39.0.tgz",
"integrity": "sha512-4GVSvNA0Vx1Ktwvf4sFE+exxJ3QGUorQG1/A5mRfRNZtkBT2xrA/BCO2H0eALx/PnvCS6/vmYwRdDA41EoffkQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"@eslint-community/eslint-utils": "^4.7.0",
"@typescript-eslint/scope-manager": "8.38.0",
"@typescript-eslint/types": "8.38.0",
"@typescript-eslint/typescript-estree": "8.38.0"
"@typescript-eslint/scope-manager": "8.39.0",
"@typescript-eslint/types": "8.39.0",
"@typescript-eslint/typescript-estree": "8.39.0"
},
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
@@ -2105,17 +2107,17 @@
},
"peerDependencies": {
"eslint": "^8.57.0 || ^9.0.0",
"typescript": ">=4.8.4 <5.9.0"
"typescript": ">=4.8.4 <6.0.0"
}
},
"node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/visitor-keys": {
"version": "8.38.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.38.0.tgz",
"integrity": "sha512-pWrTcoFNWuwHlA9CvlfSsGWs14JxfN1TH25zM5L7o0pRLhsoZkDnTsXfQRJBEWJoV5DL0jf+Z+sxiud+K0mq1g==",
"version": "8.39.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.39.0.tgz",
"integrity": "sha512-ldgiJ+VAhQCfIjeOgu8Kj5nSxds0ktPOSO9p4+0VDH2R2pLvQraaM5Oen2d7NxzMCm+Sn/vJT+mv2H5u6b/3fA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@typescript-eslint/types": "8.38.0",
"@typescript-eslint/types": "8.39.0",
"eslint-visitor-keys": "^4.2.1"
},
"engines": {
@@ -2188,16 +2190,16 @@
}
},
"node_modules/@typescript-eslint/parser": {
"version": "8.38.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.38.0.tgz",
"integrity": "sha512-Zhy8HCvBUEfBECzIl1PKqF4p11+d0aUJS1GeUiuqK9WmOug8YCmC4h4bjyBvMyAMI9sbRczmrYL5lKg/YMbrcQ==",
"version": "8.39.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.39.0.tgz",
"integrity": "sha512-g3WpVQHngx0aLXn6kfIYCZxM6rRJlWzEkVpqEFLT3SgEDsp9cpCbxxgwnE504q4H+ruSDh/VGS6nqZIDynP+vg==",
"dev": true,
"license": "MIT",
"dependencies": {
"@typescript-eslint/scope-manager": "8.38.0",
"@typescript-eslint/types": "8.38.0",
"@typescript-eslint/typescript-estree": "8.38.0",
"@typescript-eslint/visitor-keys": "8.38.0",
"@typescript-eslint/scope-manager": "8.39.0",
"@typescript-eslint/types": "8.39.0",
"@typescript-eslint/typescript-estree": "8.39.0",
"@typescript-eslint/visitor-keys": "8.39.0",
"debug": "^4.3.4"
},
"engines": {
@@ -2209,18 +2211,18 @@
},
"peerDependencies": {
"eslint": "^8.57.0 || ^9.0.0",
"typescript": ">=4.8.4 <5.9.0"
"typescript": ">=4.8.4 <6.0.0"
}
},
"node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/scope-manager": {
"version": "8.38.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.38.0.tgz",
"integrity": "sha512-WJw3AVlFFcdT9Ri1xs/lg8LwDqgekWXWhH3iAF+1ZM+QPd7oxQ6jvtW/JPwzAScxitILUIFs0/AnQ/UWHzbATQ==",
"version": "8.39.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.39.0.tgz",
"integrity": "sha512-8QOzff9UKxOh6npZQ/4FQu4mjdOCGSdO3p44ww0hk8Vu+IGbg0tB/H1LcTARRDzGCC8pDGbh2rissBuuoPgH8A==",
"dev": true,
"license": "MIT",
"dependencies": {
"@typescript-eslint/types": "8.38.0",
"@typescript-eslint/visitor-keys": "8.38.0"
"@typescript-eslint/types": "8.39.0",
"@typescript-eslint/visitor-keys": "8.39.0"
},
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
@@ -2231,9 +2233,9 @@
}
},
"node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/types": {
"version": "8.38.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.38.0.tgz",
"integrity": "sha512-wzkUfX3plUqij4YwWaJyqhiPE5UCRVlFpKn1oCRn2O1bJ592XxWJj8ROQ3JD5MYXLORW84063z3tZTb/cs4Tyw==",
"version": "8.39.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.39.0.tgz",
"integrity": "sha512-ArDdaOllnCj3yn/lzKn9s0pBQYmmyme/v1HbGIGB0GB/knFI3fWMHloC+oYTJW46tVbYnGKTMDK4ah1sC2v0Kg==",
"dev": true,
"license": "MIT",
"engines": {
@@ -2245,16 +2247,16 @@
}
},
"node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/typescript-estree": {
"version": "8.38.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.38.0.tgz",
"integrity": "sha512-fooELKcAKzxux6fA6pxOflpNS0jc+nOQEEOipXFNjSlBS6fqrJOVY/whSn70SScHrcJ2LDsxWrneFoWYSVfqhQ==",
"version": "8.39.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.39.0.tgz",
"integrity": "sha512-ndWdiflRMvfIgQRpckQQLiB5qAKQ7w++V4LlCHwp62eym1HLB/kw7D9f2e8ytONls/jt89TEasgvb+VwnRprsw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@typescript-eslint/project-service": "8.38.0",
"@typescript-eslint/tsconfig-utils": "8.38.0",
"@typescript-eslint/types": "8.38.0",
"@typescript-eslint/visitor-keys": "8.38.0",
"@typescript-eslint/project-service": "8.39.0",
"@typescript-eslint/tsconfig-utils": "8.39.0",
"@typescript-eslint/types": "8.39.0",
"@typescript-eslint/visitor-keys": "8.39.0",
"debug": "^4.3.4",
"fast-glob": "^3.3.2",
"is-glob": "^4.0.3",
@@ -2270,17 +2272,17 @@
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"typescript": ">=4.8.4 <5.9.0"
"typescript": ">=4.8.4 <6.0.0"
}
},
"node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/visitor-keys": {
"version": "8.38.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.38.0.tgz",
"integrity": "sha512-pWrTcoFNWuwHlA9CvlfSsGWs14JxfN1TH25zM5L7o0pRLhsoZkDnTsXfQRJBEWJoV5DL0jf+Z+sxiud+K0mq1g==",
"version": "8.39.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.39.0.tgz",
"integrity": "sha512-ldgiJ+VAhQCfIjeOgu8Kj5nSxds0ktPOSO9p4+0VDH2R2pLvQraaM5Oen2d7NxzMCm+Sn/vJT+mv2H5u6b/3fA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@typescript-eslint/types": "8.38.0",
"@typescript-eslint/types": "8.39.0",
"eslint-visitor-keys": "^4.2.1"
},
"engines": {
@@ -2344,14 +2346,14 @@
}
},
"node_modules/@typescript-eslint/project-service": {
"version": "8.38.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.38.0.tgz",
"integrity": "sha512-dbK7Jvqcb8c9QfH01YB6pORpqX1mn5gDZc9n63Ak/+jD67oWXn3Gs0M6vddAN+eDXBCS5EmNWzbSxsn9SzFWWg==",
"version": "8.39.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.39.0.tgz",
"integrity": "sha512-CTzJqaSq30V/Z2Og9jogzZt8lJRR5TKlAdXmWgdu4hgcC9Kww5flQ+xFvMxIBWVNdxJO7OifgdOK4PokMIWPew==",
"dev": true,
"license": "MIT",
"dependencies": {
"@typescript-eslint/tsconfig-utils": "^8.38.0",
"@typescript-eslint/types": "^8.38.0",
"@typescript-eslint/tsconfig-utils": "^8.39.0",
"@typescript-eslint/types": "^8.39.0",
"debug": "^4.3.4"
},
"engines": {
@@ -2362,13 +2364,13 @@
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"typescript": ">=4.8.4 <5.9.0"
"typescript": ">=4.8.4 <6.0.0"
}
},
"node_modules/@typescript-eslint/project-service/node_modules/@typescript-eslint/types": {
"version": "8.38.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.38.0.tgz",
"integrity": "sha512-wzkUfX3plUqij4YwWaJyqhiPE5UCRVlFpKn1oCRn2O1bJ592XxWJj8ROQ3JD5MYXLORW84063z3tZTb/cs4Tyw==",
"version": "8.39.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.39.0.tgz",
"integrity": "sha512-ArDdaOllnCj3yn/lzKn9s0pBQYmmyme/v1HbGIGB0GB/knFI3fWMHloC+oYTJW46tVbYnGKTMDK4ah1sC2v0Kg==",
"dev": true,
"license": "MIT",
"engines": {
@@ -2398,9 +2400,9 @@
}
},
"node_modules/@typescript-eslint/tsconfig-utils": {
"version": "8.38.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.38.0.tgz",
"integrity": "sha512-Lum9RtSE3EroKk/bYns+sPOodqb2Fv50XOl/gMviMKNvanETUuUcC9ObRbzrJ4VSd2JalPqgSAavwrPiPvnAiQ==",
"version": "8.39.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.39.0.tgz",
"integrity": "sha512-Fd3/QjmFV2sKmvv3Mrj8r6N8CryYiCS8Wdb/6/rgOXAWGcFuc+VkQuG28uk/4kVNVZBQuuDHEDUpo/pQ32zsIQ==",
"dev": true,
"license": "MIT",
"engines": {
@@ -2411,19 +2413,19 @@
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"typescript": ">=4.8.4 <5.9.0"
"typescript": ">=4.8.4 <6.0.0"
}
},
"node_modules/@typescript-eslint/type-utils": {
"version": "8.38.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.38.0.tgz",
"integrity": "sha512-c7jAvGEZVf0ao2z+nnz8BUaHZD09Agbh+DY7qvBQqLiz8uJzRgVPj5YvOh8I8uEiH8oIUGIfHzMwUcGVco/SJg==",
"version": "8.39.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.39.0.tgz",
"integrity": "sha512-6B3z0c1DXVT2vYA9+z9axjtc09rqKUPRmijD5m9iv8iQpHBRYRMBcgxSiKTZKm6FwWw1/cI4v6em35OsKCiN5Q==",
"dev": true,
"license": "MIT",
"dependencies": {
"@typescript-eslint/types": "8.38.0",
"@typescript-eslint/typescript-estree": "8.38.0",
"@typescript-eslint/utils": "8.38.0",
"@typescript-eslint/types": "8.39.0",
"@typescript-eslint/typescript-estree": "8.39.0",
"@typescript-eslint/utils": "8.39.0",
"debug": "^4.3.4",
"ts-api-utils": "^2.1.0"
},
@@ -2436,18 +2438,18 @@
},
"peerDependencies": {
"eslint": "^8.57.0 || ^9.0.0",
"typescript": ">=4.8.4 <5.9.0"
"typescript": ">=4.8.4 <6.0.0"
}
},
"node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/scope-manager": {
"version": "8.38.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.38.0.tgz",
"integrity": "sha512-WJw3AVlFFcdT9Ri1xs/lg8LwDqgekWXWhH3iAF+1ZM+QPd7oxQ6jvtW/JPwzAScxitILUIFs0/AnQ/UWHzbATQ==",
"version": "8.39.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.39.0.tgz",
"integrity": "sha512-8QOzff9UKxOh6npZQ/4FQu4mjdOCGSdO3p44ww0hk8Vu+IGbg0tB/H1LcTARRDzGCC8pDGbh2rissBuuoPgH8A==",
"dev": true,
"license": "MIT",
"dependencies": {
"@typescript-eslint/types": "8.38.0",
"@typescript-eslint/visitor-keys": "8.38.0"
"@typescript-eslint/types": "8.39.0",
"@typescript-eslint/visitor-keys": "8.39.0"
},
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
@@ -2458,9 +2460,9 @@
}
},
"node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/types": {
"version": "8.38.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.38.0.tgz",
"integrity": "sha512-wzkUfX3plUqij4YwWaJyqhiPE5UCRVlFpKn1oCRn2O1bJ592XxWJj8ROQ3JD5MYXLORW84063z3tZTb/cs4Tyw==",
"version": "8.39.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.39.0.tgz",
"integrity": "sha512-ArDdaOllnCj3yn/lzKn9s0pBQYmmyme/v1HbGIGB0GB/knFI3fWMHloC+oYTJW46tVbYnGKTMDK4ah1sC2v0Kg==",
"dev": true,
"license": "MIT",
"engines": {
@@ -2472,16 +2474,16 @@
}
},
"node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/typescript-estree": {
"version": "8.38.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.38.0.tgz",
"integrity": "sha512-fooELKcAKzxux6fA6pxOflpNS0jc+nOQEEOipXFNjSlBS6fqrJOVY/whSn70SScHrcJ2LDsxWrneFoWYSVfqhQ==",
"version": "8.39.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.39.0.tgz",
"integrity": "sha512-ndWdiflRMvfIgQRpckQQLiB5qAKQ7w++V4LlCHwp62eym1HLB/kw7D9f2e8ytONls/jt89TEasgvb+VwnRprsw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@typescript-eslint/project-service": "8.38.0",
"@typescript-eslint/tsconfig-utils": "8.38.0",
"@typescript-eslint/types": "8.38.0",
"@typescript-eslint/visitor-keys": "8.38.0",
"@typescript-eslint/project-service": "8.39.0",
"@typescript-eslint/tsconfig-utils": "8.39.0",
"@typescript-eslint/types": "8.39.0",
"@typescript-eslint/visitor-keys": "8.39.0",
"debug": "^4.3.4",
"fast-glob": "^3.3.2",
"is-glob": "^4.0.3",
@@ -2497,20 +2499,20 @@
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"typescript": ">=4.8.4 <5.9.0"
"typescript": ">=4.8.4 <6.0.0"
}
},
"node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/utils": {
"version": "8.38.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.38.0.tgz",
"integrity": "sha512-hHcMA86Hgt+ijJlrD8fX0j1j8w4C92zue/8LOPAFioIno+W0+L7KqE8QZKCcPGc/92Vs9x36w/4MPTJhqXdyvg==",
"version": "8.39.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.39.0.tgz",
"integrity": "sha512-4GVSvNA0Vx1Ktwvf4sFE+exxJ3QGUorQG1/A5mRfRNZtkBT2xrA/BCO2H0eALx/PnvCS6/vmYwRdDA41EoffkQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"@eslint-community/eslint-utils": "^4.7.0",
"@typescript-eslint/scope-manager": "8.38.0",
"@typescript-eslint/types": "8.38.0",
"@typescript-eslint/typescript-estree": "8.38.0"
"@typescript-eslint/scope-manager": "8.39.0",
"@typescript-eslint/types": "8.39.0",
"@typescript-eslint/typescript-estree": "8.39.0"
},
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
@@ -2521,17 +2523,17 @@
},
"peerDependencies": {
"eslint": "^8.57.0 || ^9.0.0",
"typescript": ">=4.8.4 <5.9.0"
"typescript": ">=4.8.4 <6.0.0"
}
},
"node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/visitor-keys": {
"version": "8.38.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.38.0.tgz",
"integrity": "sha512-pWrTcoFNWuwHlA9CvlfSsGWs14JxfN1TH25zM5L7o0pRLhsoZkDnTsXfQRJBEWJoV5DL0jf+Z+sxiud+K0mq1g==",
"version": "8.39.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.39.0.tgz",
"integrity": "sha512-ldgiJ+VAhQCfIjeOgu8Kj5nSxds0ktPOSO9p4+0VDH2R2pLvQraaM5Oen2d7NxzMCm+Sn/vJT+mv2H5u6b/3fA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@typescript-eslint/types": "8.38.0",
"@typescript-eslint/types": "8.39.0",
"eslint-visitor-keys": "^4.2.1"
},
"engines": {
@@ -5213,9 +5215,9 @@
"license": "ISC"
},
"node_modules/follow-redirects": {
"version": "1.15.9",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz",
"integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==",
"version": "1.15.11",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.11.tgz",
"integrity": "sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ==",
"funding": [
{
"type": "individual",
@@ -6502,13 +6504,13 @@
"license": "MIT"
},
"node_modules/nock": {
"version": "14.0.7",
"resolved": "https://registry.npmjs.org/nock/-/nock-14.0.7.tgz",
"integrity": "sha512-ubwvvhSzNPqc7Nm3a/iYolwqb7lo1zfllDKO1ODsYu3KnarmQEya5yV70ZUwhVxYIl1ePuX3W+lHw2un+pUfpQ==",
"version": "14.0.8",
"resolved": "https://registry.npmjs.org/nock/-/nock-14.0.8.tgz",
"integrity": "sha512-5DCGrkwK1f8kxUvqvzLWb97XuDUY4/t5M3ZcogPfLGvC2wO8wjRQsIDSXj2L6e1J0Dv8xscf9wWSvGnS3OL29Q==",
"dev": true,
"license": "MIT",
"dependencies": {
"@mswjs/interceptors": "^0.39.3",
"@mswjs/interceptors": "^0.39.5",
"json-stringify-safe": "^5.0.1",
"propagate": "^2.0.0"
},
@@ -8025,9 +8027,10 @@
}
},
"node_modules/tmp": {
"version": "0.2.3",
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.3.tgz",
"integrity": "sha512-nZD7m9iCPC5g0pYmcaxogYKggSfLsdxl8of3Q/oIbqCqLLIO9IAF0GWjX1z9NZRHPiXv8Wex4yDCaZsgEw0Y8w==",
"version": "0.2.4",
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.4.tgz",
"integrity": "sha512-UdiSoX6ypifLmrfQ/XfiawN6hkjSBpCjhKxxZcWlUUmoXLaCKQU0bx4HF/tdDK2uzRuchf1txGvrWBzYREssoQ==",
"license": "MIT",
"engines": {
"node": ">=14.14"
}
@@ -8209,10 +8212,11 @@
}
},
"node_modules/typescript": {
"version": "5.8.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz",
"integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==",
"version": "5.9.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.2.tgz",
"integrity": "sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A==",
"dev": true,
"license": "Apache-2.0",
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
@@ -8362,7 +8366,9 @@
}
},
"node_modules/undici-types": {
"version": "5.26.5",
"version": "6.21.0",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",
"integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",
"license": "MIT"
},
"node_modules/unicorn-magic": {

View File

@@ -3,7 +3,7 @@
var _chunkR6JVCM7Xjs = require('./chunk-R6JVCM7X.js');
var _chunkF6CVST3Sjs = require('./chunk-F6CVST3S.js');
var _chunkATZKM2BZjs = require('./chunk-ATZKM2BZ.js');
require('./chunk-4YBV77DG.js');
@@ -30,7 +30,7 @@ var RemoteHttpInterceptor = class extends _chunkR6JVCM7Xjs.BatchInterceptor {
super({
name: "remote-interceptor",
interceptors: [
new (0, _chunkF6CVST3Sjs.ClientRequestInterceptor)(),
new (0, _chunkATZKM2BZjs.ClientRequestInterceptor)(),
new (0, _chunk4WG2AM2Tjs.XMLHttpRequestInterceptor)(),
new (0, _chunkYAIEISARjs.FetchInterceptor)()
]

View File

@@ -3,7 +3,7 @@ import {
} from "./chunk-RC2XPCC4.mjs";
import {
ClientRequestInterceptor
} from "./chunk-HGTNS5VM.mjs";
} from "./chunk-WA2XMLKW.mjs";
import "./chunk-TJDMZZXE.mjs";
import {
XMLHttpRequestInterceptor

View File

@@ -305,6 +305,7 @@ var MockHttpSocket = class extends MockSocket {
}
});
this.requestRawHeadersBuffer = [];
this.responseRawHeadersBuffer = [];
this.writeBuffer = [];
this.socketState = "unknown";
/**
@@ -367,8 +368,22 @@ var MockHttpSocket = class extends MockSocket {
socket: this
});
};
/**
* This callback might be called when the response is "slow":
* - Response headers were fragmented across multiple TCP packages;
* - Response headers were too large to be processed in a single run
* (e.g. more than 30 response headers).
* @note This is called before response start.
*/
this.onResponseHeaders = (rawHeaders) => {
this.responseRawHeadersBuffer.push(...rawHeaders);
};
this.onResponseStart = (versionMajor, versionMinor, rawHeaders, method, url, status, statusText) => {
const headers = _chunkA7U44ARPjs.FetchResponse.parseRawHeaders(rawHeaders);
const headers = _chunkA7U44ARPjs.FetchResponse.parseRawHeaders([
...this.responseRawHeadersBuffer,
...rawHeaders || []
]);
this.responseRawHeadersBuffer.length = 0;
const response = new (0, _chunkA7U44ARPjs.FetchResponse)(
/**
* @note The Fetch API response instance exposed to the consumer
@@ -417,6 +432,7 @@ var MockHttpSocket = class extends MockSocket {
this.requestParser[__http_common.HTTPParser.kOnMessageComplete] = this.onRequestEnd.bind(this);
this.responseParser = new (0, __http_common.HTTPParser)();
this.responseParser.initialize(__http_common.HTTPParser.RESPONSE, {});
this.responseParser[__http_common.HTTPParser.kOnHeaders] = this.onResponseHeaders.bind(this);
this.responseParser[__http_common.HTTPParser.kOnHeadersComplete] = this.onResponseStart.bind(this);
this.responseParser[__http_common.HTTPParser.kOnBody] = this.onResponseBody.bind(this);
this.responseParser[__http_common.HTTPParser.kOnMessageComplete] = this.onResponseEnd.bind(this);
@@ -687,8 +703,8 @@ var MockHttpsAgent = class extends _https2.default.Agent {
this.onResponse = options.onResponse;
}
createConnection(options, callback) {
const createConnection = this.customAgent instanceof _https2.default.Agent ? this.customAgent.createConnection : super.createConnection;
const createConnectionOptions = this.customAgent instanceof _https2.default.Agent ? {
const createConnection = this.customAgent instanceof _http2.default.Agent ? this.customAgent.createConnection : super.createConnection;
const createConnectionOptions = this.customAgent instanceof _http2.default.Agent ? {
...options,
...this.customAgent.options
} : options;
@@ -1096,4 +1112,4 @@ ClientRequestInterceptor.symbol = Symbol("client-request-interceptor");
exports.ClientRequestInterceptor = ClientRequestInterceptor;
//# sourceMappingURL=chunk-F6CVST3S.js.map
//# sourceMappingURL=chunk-ATZKM2BZ.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -305,6 +305,7 @@ var MockHttpSocket = class extends MockSocket {
}
});
this.requestRawHeadersBuffer = [];
this.responseRawHeadersBuffer = [];
this.writeBuffer = [];
this.socketState = "unknown";
/**
@@ -367,8 +368,22 @@ var MockHttpSocket = class extends MockSocket {
socket: this
});
};
/**
* This callback might be called when the response is "slow":
* - Response headers were fragmented across multiple TCP packages;
* - Response headers were too large to be processed in a single run
* (e.g. more than 30 response headers).
* @note This is called before response start.
*/
this.onResponseHeaders = (rawHeaders) => {
this.responseRawHeadersBuffer.push(...rawHeaders);
};
this.onResponseStart = (versionMajor, versionMinor, rawHeaders, method, url, status, statusText) => {
const headers = FetchResponse.parseRawHeaders(rawHeaders);
const headers = FetchResponse.parseRawHeaders([
...this.responseRawHeadersBuffer,
...rawHeaders || []
]);
this.responseRawHeadersBuffer.length = 0;
const response = new FetchResponse(
/**
* @note The Fetch API response instance exposed to the consumer
@@ -417,6 +432,7 @@ var MockHttpSocket = class extends MockSocket {
this.requestParser[HTTPParser.kOnMessageComplete] = this.onRequestEnd.bind(this);
this.responseParser = new HTTPParser();
this.responseParser.initialize(HTTPParser.RESPONSE, {});
this.responseParser[HTTPParser.kOnHeaders] = this.onResponseHeaders.bind(this);
this.responseParser[HTTPParser.kOnHeadersComplete] = this.onResponseStart.bind(this);
this.responseParser[HTTPParser.kOnBody] = this.onResponseBody.bind(this);
this.responseParser[HTTPParser.kOnMessageComplete] = this.onResponseEnd.bind(this);
@@ -687,8 +703,8 @@ var MockHttpsAgent = class extends https.Agent {
this.onResponse = options.onResponse;
}
createConnection(options, callback) {
const createConnection = this.customAgent instanceof https.Agent ? this.customAgent.createConnection : super.createConnection;
const createConnectionOptions = this.customAgent instanceof https.Agent ? {
const createConnection = this.customAgent instanceof http.Agent ? this.customAgent.createConnection : super.createConnection;
const createConnectionOptions = this.customAgent instanceof http.Agent ? {
...options,
...this.customAgent.options
} : options;
@@ -1096,4 +1112,4 @@ ClientRequestInterceptor.symbol = Symbol("client-request-interceptor");
export {
ClientRequestInterceptor
};
//# sourceMappingURL=chunk-HGTNS5VM.mjs.map
//# sourceMappingURL=chunk-WA2XMLKW.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -47,6 +47,7 @@ declare class MockHttpSocket extends MockSocket {
private onResponse;
private responseListenersPromise?;
private requestRawHeadersBuffer;
private responseRawHeadersBuffer;
private writeBuffer;
private request?;
private requestParser;
@@ -86,6 +87,14 @@ declare class MockHttpSocket extends MockSocket {
private onRequestStart;
private onRequestBody;
private onRequestEnd;
/**
* This callback might be called when the response is "slow":
* - Response headers were fragmented across multiple TCP packages;
* - Response headers were too large to be processed in a single run
* (e.g. more than 30 response headers).
* @note This is called before response start.
*/
private onResponseHeaders;
private onResponseStart;
private onResponseBody;
private onResponseEnd;

View File

@@ -1,11 +1,11 @@
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
var _chunkF6CVST3Sjs = require('../../chunk-F6CVST3S.js');
var _chunkATZKM2BZjs = require('../../chunk-ATZKM2BZ.js');
require('../../chunk-4YBV77DG.js');
require('../../chunk-C2JSMMHY.js');
require('../../chunk-A7U44ARP.js');
require('../../chunk-SMXZPJEA.js');
exports.ClientRequestInterceptor = _chunkF6CVST3Sjs.ClientRequestInterceptor;
exports.ClientRequestInterceptor = _chunkATZKM2BZjs.ClientRequestInterceptor;
//# sourceMappingURL=index.js.map

View File

@@ -1,6 +1,6 @@
import {
ClientRequestInterceptor
} from "../../chunk-HGTNS5VM.mjs";
} from "../../chunk-WA2XMLKW.mjs";
import "../../chunk-TJDMZZXE.mjs";
import "../../chunk-LGXJ3UUF.mjs";
import "../../chunk-IHJSPMYM.mjs";

View File

@@ -1,6 +1,6 @@
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
var _chunkF6CVST3Sjs = require('../chunk-F6CVST3S.js');
var _chunkATZKM2BZjs = require('../chunk-ATZKM2BZ.js');
require('../chunk-4YBV77DG.js');
@@ -17,7 +17,7 @@ require('../chunk-SMXZPJEA.js');
// src/presets/node.ts
var node_default = [
new (0, _chunkF6CVST3Sjs.ClientRequestInterceptor)(),
new (0, _chunkATZKM2BZjs.ClientRequestInterceptor)(),
new (0, _chunk4WG2AM2Tjs.XMLHttpRequestInterceptor)(),
new (0, _chunkYAIEISARjs.FetchInterceptor)()
];

View File

@@ -1,6 +1,6 @@
import {
ClientRequestInterceptor
} from "../chunk-HGTNS5VM.mjs";
} from "../chunk-WA2XMLKW.mjs";
import "../chunk-TJDMZZXE.mjs";
import {
XMLHttpRequestInterceptor

View File

@@ -1,7 +1,7 @@
{
"name": "@mswjs/interceptors",
"description": "Low-level HTTP/HTTPS/XHR/fetch request interception library.",
"version": "0.39.3",
"version": "0.39.5",
"main": "./lib/node/index.js",
"module": "./lib/node/index.mjs",
"types": "./lib/node/index.d.ts",

View File

@@ -1,7 +1,7 @@
import net from 'node:net'
import {
type HeadersCallback,
HTTPParser,
RequestHeadersCallback,
type RequestHeadersCompleteCallback,
type ResponseHeadersCompleteCallback,
} from '_http_common'
@@ -55,6 +55,7 @@ export class MockHttpSocket extends MockSocket {
private responseListenersPromise?: Promise<void>
private requestRawHeadersBuffer: Array<string> = []
private responseRawHeadersBuffer: Array<string> = []
private writeBuffer: Array<NormalizedSocketWriteArgs> = []
private request?: Request
private requestParser: HTTPParser<0>
@@ -125,6 +126,8 @@ export class MockHttpSocket extends MockSocket {
// Response parser.
this.responseParser = new HTTPParser()
this.responseParser.initialize(HTTPParser.RESPONSE, {})
this.responseParser[HTTPParser.kOnHeaders] =
this.onResponseHeaders.bind(this)
this.responseParser[HTTPParser.kOnHeadersComplete] =
this.onResponseStart.bind(this)
this.responseParser[HTTPParser.kOnBody] = this.onResponseBody.bind(this)
@@ -482,7 +485,7 @@ export class MockHttpSocket extends MockSocket {
* (e.g. more than 30 request headers).
* @note This is called before request start.
*/
private onRequestHeaders: RequestHeadersCallback = (rawHeaders) => {
private onRequestHeaders: HeadersCallback = (rawHeaders) => {
this.requestRawHeadersBuffer.push(...rawHeaders)
}
@@ -597,6 +600,17 @@ export class MockHttpSocket extends MockSocket {
}
}
/**
* This callback might be called when the response is "slow":
* - Response headers were fragmented across multiple TCP packages;
* - Response headers were too large to be processed in a single run
* (e.g. more than 30 response headers).
* @note This is called before response start.
*/
private onResponseHeaders: HeadersCallback = (rawHeaders) => {
this.responseRawHeadersBuffer.push(...rawHeaders)
}
private onResponseStart: ResponseHeadersCompleteCallback = (
versionMajor,
versionMinor,
@@ -606,7 +620,11 @@ export class MockHttpSocket extends MockSocket {
status,
statusText
) => {
const headers = FetchResponse.parseRawHeaders(rawHeaders)
const headers = FetchResponse.parseRawHeaders([
...this.responseRawHeadersBuffer,
...(rawHeaders || []),
])
this.responseRawHeadersBuffer.length = 0
const response = new FetchResponse(
/**

View File

@@ -75,12 +75,12 @@ export class MockHttpsAgent extends https.Agent {
public createConnection(options: any, callback: any): net.Socket {
const createConnection =
this.customAgent instanceof https.Agent
this.customAgent instanceof http.Agent
? this.customAgent.createConnection
: super.createConnection
const createConnectionOptions =
this.customAgent instanceof https.Agent
this.customAgent instanceof http.Agent
? {
...options,
...this.customAgent.options,

6
node_modules/@types/node/README.md generated vendored
View File

@@ -5,11 +5,11 @@
This package contains type definitions for node (https://nodejs.org/).
# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node/v20.
### Additional Details
* Last updated: Tue, 07 Nov 2023 20:08:00 GMT
* Last updated: Sat, 19 Jul 2025 00:47:11 GMT
* Dependencies: [undici-types](https://npmjs.com/package/undici-types)
# Credits
These definitions were written by [Microsoft TypeScript](https://github.com/Microsoft), [Alberto Schiabel](https://github.com/jkomyno), [Alvis HT Tang](https://github.com/alvis), [Andrew Makarov](https://github.com/r3nya), [Benjamin Toueg](https://github.com/btoueg), [Chigozirim C.](https://github.com/smac89), [David Junger](https://github.com/touffy), [Deividas Bakanas](https://github.com/DeividasBakanas), [Eugene Y. Q. Shen](https://github.com/eyqs), [Hannes Magnusson](https://github.com/Hannes-Magnusson-CK), [Huw](https://github.com/hoo29), [Kelvin Jin](https://github.com/kjin), [Klaus Meinhardt](https://github.com/ajafff), [Lishude](https://github.com/islishude), [Mariusz Wiktorczyk](https://github.com/mwiktorczyk), [Mohsen Azimi](https://github.com/mohsen1), [Nicolas Even](https://github.com/n-e), [Nikita Galkin](https://github.com/galkin), [Parambir Singh](https://github.com/parambirs), [Sebastian Silbermann](https://github.com/eps1lon), [Thomas den Hollander](https://github.com/ThomasdenH), [Wilco Bakker](https://github.com/WilcoBakker), [wwwy3y3](https://github.com/wwwy3y3), [Samuel Ainsworth](https://github.com/samuela), [Kyle Uehlein](https://github.com/kuehlein), [Thanik Bhongbhibhat](https://github.com/bhongy), [Marcin Kopacz](https://github.com/chyzwar), [Trivikram Kamat](https://github.com/trivikr), [Junxiao Shi](https://github.com/yoursunny), [Ilia Baryshnikov](https://github.com/qwelias), [ExE Boss](https://github.com/ExE-Boss), [Piotr Błażejewicz](https://github.com/peterblazejewicz), [Anna Henningsen](https://github.com/addaleax), [Victor Perin](https://github.com/victorperin), [Yongsheng Zhang](https://github.com/ZYSzys), [NodeJS Contributors](https://github.com/NodeJS), [Linus Unnebäck](https://github.com/LinusU), [wafuwafu13](https://github.com/wafuwafu13), [Matteo Collina](https://github.com/mcollina), and [Dmitry Semigradsky](https://github.com/Semigradsky).
These definitions were written by [Microsoft TypeScript](https://github.com/Microsoft), [Alberto Schiabel](https://github.com/jkomyno), [Andrew Makarov](https://github.com/r3nya), [Benjamin Toueg](https://github.com/btoueg), [David Junger](https://github.com/touffy), [Mohsen Azimi](https://github.com/mohsen1), [Nikita Galkin](https://github.com/galkin), [Sebastian Silbermann](https://github.com/eps1lon), [Wilco Bakker](https://github.com/WilcoBakker), [Marcin Kopacz](https://github.com/chyzwar), [Trivikram Kamat](https://github.com/trivikr), [Junxiao Shi](https://github.com/yoursunny), [Ilia Baryshnikov](https://github.com/qwelias), [ExE Boss](https://github.com/ExE-Boss), [Piotr Błażejewicz](https://github.com/peterblazejewicz), [Anna Henningsen](https://github.com/addaleax), [Victor Perin](https://github.com/victorperin), [NodeJS Contributors](https://github.com/NodeJS), [Linus Unnebäck](https://github.com/LinusU), [wafuwafu13](https://github.com/wafuwafu13), [Matteo Collina](https://github.com/mcollina), and [Dmitry Semigradsky](https://github.com/Semigradsky).

142
node_modules/@types/node/assert.d.ts generated vendored
View File

@@ -1,7 +1,7 @@
/**
* The `node:assert` module provides a set of assertion functions for verifying
* invariants.
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/assert.js)
* @see [source](https://github.com/nodejs/node/blob/v20.13.1/lib/assert.js)
*/
declare module "assert" {
/**
@@ -12,7 +12,7 @@ declare module "assert" {
function assert(value: unknown, message?: string | Error): asserts value;
namespace assert {
/**
* Indicates the failure of an assertion. All errors thrown by the `node:assert`module will be instances of the `AssertionError` class.
* Indicates the failure of an assertion. All errors thrown by the `node:assert` module will be instances of the `AssertionError` class.
*/
class AssertionError extends Error {
/**
@@ -45,7 +45,7 @@ declare module "assert" {
/** The `operator` property on the error instance. */
operator?: string | undefined;
/** If provided, the generated stack trace omits frames before this function. */
// tslint:disable-next-line:ban-types
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
stackStartFn?: Function | undefined;
});
}
@@ -76,10 +76,12 @@ declare module "assert" {
* @since v14.2.0, v12.19.0
* @param [fn='A no-op function']
* @param [exact=1]
* @return that wraps `fn`.
* @return A function that wraps `fn`.
*/
calls(exact?: number): () => void;
calls<Func extends (...args: any[]) => any>(fn?: Func, exact?: number): Func;
calls(fn: undefined, exact?: number): () => void;
calls<Func extends (...args: any[]) => any>(fn: Func, exact?: number): Func;
calls<Func extends (...args: any[]) => any>(fn?: Func, exact?: number): Func | (() => void);
/**
* Example:
*
@@ -96,8 +98,7 @@ declare module "assert" {
* [{ thisArg: undefined, arguments: [1, 2, 3] }]);
* ```
* @since v18.8.0, v16.18.0
* @param fn
* @return An Array with all the calls to a tracked function.
* @return An array with all the calls to a tracked function.
*/
getCalls(fn: Function): CallTrackerCall[];
/**
@@ -130,12 +131,11 @@ declare module "assert" {
* // ]
* ```
* @since v14.2.0, v12.19.0
* @return An Array of objects containing information about the wrapper functions returned by `calls`.
* @return An array of objects containing information about the wrapper functions returned by {@link tracker.calls()}.
*/
report(): CallTrackerReportInformation[];
/**
* Reset calls of the call tracker.
* If a tracked function is passed as an argument, the calls will be reset for it.
* Reset calls of the call tracker. If a tracked function is passed as an argument, the calls will be reset for it.
* If no arguments are passed, all tracked functions will be reset.
*
* ```js
@@ -158,7 +158,7 @@ declare module "assert" {
*/
reset(fn?: Function): void;
/**
* Iterates through the list of functions passed to `tracker.calls()` and will throw an error for functions that
* Iterates through the list of functions passed to {@link tracker.calls()} and will throw an error for functions that
* have not been called the expected number of times.
*
* ```js
@@ -228,14 +228,14 @@ declare module "assert" {
expected: unknown,
message?: string | Error,
operator?: string,
// tslint:disable-next-line:ban-types
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
stackStartFn?: Function,
): never;
/**
* Tests if `value` is truthy. It is equivalent to`assert.equal(!!value, true, message)`.
* Tests if `value` is truthy. It is equivalent to `assert.equal(!!value, true, message)`.
*
* If `value` is not truthy, an `AssertionError` is thrown with a `message`property set equal to the value of the `message` parameter. If the `message`parameter is `undefined`, a default
* error message is assigned. If the `message`parameter is an instance of an `Error` then it will be thrown instead of the`AssertionError`.
* If `value` is not truthy, an `AssertionError` is thrown with a `message` property set equal to the value of the `message` parameter. If the `message` parameter is `undefined`, a default
* error message is assigned. If the `message` parameter is an instance of an `Error` then it will be thrown instead of the `AssertionError`.
* If no arguments are passed in at all `message` will be set to the string:`` 'No value argument passed to `assert.ok()`' ``.
*
* Be aware that in the `repl` the error message will be different to the one
@@ -317,8 +317,8 @@ declare module "assert" {
* // AssertionError: { a: { b: 1 } } == { a: { b: 1 } }
* ```
*
* If the values are not equal, an `AssertionError` is thrown with a `message`property set equal to the value of the `message` parameter. If the `message`parameter is undefined, a default
* error message is assigned. If the `message`parameter is an instance of an `Error` then it will be thrown instead of the`AssertionError`.
* If the values are not equal, an `AssertionError` is thrown with a `message` property set equal to the value of the `message` parameter. If the `message` parameter is undefined, a default
* error message is assigned. If the `message` parameter is an instance of an `Error` then it will be thrown instead of the `AssertionError`.
* @since v0.1.21
*/
function equal(actual: unknown, expected: unknown, message?: string | Error): void;
@@ -347,8 +347,8 @@ declare module "assert" {
* // AssertionError: 1 != '1'
* ```
*
* If the values are equal, an `AssertionError` is thrown with a `message`property set equal to the value of the `message` parameter. If the `message`parameter is undefined, a default error
* message is assigned. If the `message`parameter is an instance of an `Error` then it will be thrown instead of the`AssertionError`.
* If the values are equal, an `AssertionError` is thrown with a `message` property set equal to the value of the `message` parameter. If the `message` parameter is undefined, a default error
* message is assigned. If the `message` parameter is an instance of an `Error` then it will be thrown instead of the `AssertionError`.
* @since v0.1.21
*/
function notEqual(actual: unknown, expected: unknown, message?: string | Error): void;
@@ -414,8 +414,8 @@ declare module "assert" {
* // OK
* ```
*
* If the values are deeply equal, an `AssertionError` is thrown with a`message` property set equal to the value of the `message` parameter. If the`message` parameter is undefined, a default
* error message is assigned. If the`message` parameter is an instance of an `Error` then it will be thrown
* If the values are deeply equal, an `AssertionError` is thrown with a `message` property set equal to the value of the `message` parameter. If the `message` parameter is undefined, a default
* error message is assigned. If the `message` parameter is an instance of an `Error` then it will be thrown
* instead of the `AssertionError`.
* @since v0.1.21
*/
@@ -452,8 +452,8 @@ declare module "assert" {
* // TypeError: Inputs are not identical
* ```
*
* If the values are not strictly equal, an `AssertionError` is thrown with a`message` property set equal to the value of the `message` parameter. If the`message` parameter is undefined, a
* default error message is assigned. If the`message` parameter is an instance of an `Error` then it will be thrown
* If the values are not strictly equal, an `AssertionError` is thrown with a `message` property set equal to the value of the `message` parameter. If the `message` parameter is undefined, a
* default error message is assigned. If the `message` parameter is an instance of an `Error` then it will be thrown
* instead of the `AssertionError`.
* @since v0.1.21
*/
@@ -477,8 +477,8 @@ declare module "assert" {
* // OK
* ```
*
* If the values are strictly equal, an `AssertionError` is thrown with a`message` property set equal to the value of the `message` parameter. If the`message` parameter is undefined, a
* default error message is assigned. If the`message` parameter is an instance of an `Error` then it will be thrown
* If the values are strictly equal, an `AssertionError` is thrown with a `message` property set equal to the value of the `message` parameter. If the `message` parameter is undefined, a
* default error message is assigned. If the `message` parameter is an instance of an `Error` then it will be thrown
* instead of the `AssertionError`.
* @since v0.1.21
*/
@@ -519,7 +519,7 @@ declare module "assert" {
* using an object, it is also possible to use a regular expression, when
* validating against a string property. See below for examples.
*
* If specified, `message` will be appended to the message provided by the`AssertionError` if the `fn` call fails to throw or in case the error validation
* If specified, `message` will be appended to the message provided by the `AssertionError` if the `fn` call fails to throw or in case the error validation
* fails.
*
* Custom validation object/error instance:
@@ -649,8 +649,8 @@ declare module "assert" {
* ```
*
* `error` cannot be a string. If a string is provided as the second
* argument, then `error` is assumed to be omitted and the string will be used for`message` instead. This can lead to easy-to-miss mistakes. Using the same
* message as the thrown error message is going to result in an`ERR_AMBIGUOUS_ARGUMENT` error. Please read the example below carefully if using
* argument, then `error` is assumed to be omitted and the string will be used for `message` instead. This can lead to easy-to-miss mistakes. Using the same
* message as the thrown error message is going to result in an `ERR_AMBIGUOUS_ARGUMENT` error. Please read the example below carefully if using
* a string as the second argument gets considered:
*
* ```js
@@ -703,9 +703,9 @@ declare module "assert" {
* adding a comment next to the specific code path that should not throw and keep
* error messages as expressive as possible.
*
* When `assert.doesNotThrow()` is called, it will immediately call the `fn`function.
* When `assert.doesNotThrow()` is called, it will immediately call the `fn` function.
*
* If an error is thrown and it is the same type as that specified by the `error`parameter, then an `AssertionError` is thrown. If the error is of a
* If an error is thrown and it is the same type as that specified by the `error` parameter, then an `AssertionError` is thrown. If the error is of a
* different type, or if the `error` parameter is undefined, the error is
* propagated back to the caller.
*
@@ -741,7 +741,7 @@ declare module "assert" {
* );
* ```
*
* If an `AssertionError` is thrown and a value is provided for the `message`parameter, the value of `message` will be appended to the `AssertionError` message:
* If an `AssertionError` is thrown and a value is provided for the `message` parameter, the value of `message` will be appended to the `AssertionError` message:
*
* ```js
* import assert from 'node:assert/strict';
@@ -762,7 +762,7 @@ declare module "assert" {
/**
* Throws `value` if `value` is not `undefined` or `null`. This is useful when
* testing the `error` argument in callbacks. The stack trace contains all frames
* from the error passed to `ifError()` including the potential new frames for`ifError()` itself.
* from the error passed to `ifError()` including the potential new frames for `ifError()` itself.
*
* ```js
* import assert from 'node:assert/strict';
@@ -797,18 +797,18 @@ declare module "assert" {
* calls the function and awaits the returned promise to complete. It will then
* check that the promise is rejected.
*
* If `asyncFn` is a function and it throws an error synchronously,`assert.rejects()` will return a rejected `Promise` with that error. If the
* function does not return a promise, `assert.rejects()` will return a rejected`Promise` with an `ERR_INVALID_RETURN_VALUE` error. In both cases the error
* handler is skipped.
* If `asyncFn` is a function and it throws an error synchronously, `assert.rejects()` will return a rejected `Promise` with that error. If the
* function does not return a promise, `assert.rejects()` will return a rejected `Promise` with an [ERR_INVALID_RETURN_VALUE](https://nodejs.org/docs/latest-v20.x/api/errors.html#err_invalid_return_value)
* error. In both cases the error handler is skipped.
*
* Besides the async nature to await the completion behaves identically to {@link throws}.
*
* If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes),
* [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), a validation function,
* an object where each property will be tested for, or an instance of error where
* each property will be tested for including the non-enumerable `message` and`name` properties.
* each property will be tested for including the non-enumerable `message` and `name` properties.
*
* If specified, `message` will be the message provided by the `AssertionError` if the `asyncFn` fails to reject.
* If specified, `message` will be the message provided by the `{@link AssertionError}` if the `asyncFn` fails to reject.
*
* ```js
* import assert from 'node:assert/strict';
@@ -850,10 +850,9 @@ declare module "assert" {
* });
* ```
*
* `error` cannot be a string. If a string is provided as the second
* argument, then `error` is assumed to be omitted and the string will be used for`message` instead. This can lead to easy-to-miss mistakes. Please read the
* example in {@link throws} carefully if using a string as the second
* argument gets considered.
* `error` cannot be a string. If a string is provided as the second argument, then `error` is assumed to
* be omitted and the string will be used for `message` instead. This can lead to easy-to-miss mistakes. Please read the
* example in {@link throws} carefully if using a string as the second argument gets considered.
* @since v10.0.0
*/
function rejects(block: (() => Promise<unknown>) | Promise<unknown>, message?: string | Error): Promise<void>;
@@ -867,9 +866,9 @@ declare module "assert" {
* calls the function and awaits the returned promise to complete. It will then
* check that the promise is not rejected.
*
* If `asyncFn` is a function and it throws an error synchronously,`assert.doesNotReject()` will return a rejected `Promise` with that error. If
* If `asyncFn` is a function and it throws an error synchronously, `assert.doesNotReject()` will return a rejected `Promise` with that error. If
* the function does not return a promise, `assert.doesNotReject()` will return a
* rejected `Promise` with an `ERR_INVALID_RETURN_VALUE` error. In both cases
* rejected `Promise` with an [ERR_INVALID_RETURN_VALUE](https://nodejs.org/docs/latest-v20.x/api/errors.html#err_invalid_return_value) error. In both cases
* the error handler is skipped.
*
* Using `assert.doesNotReject()` is actually not useful because there is little
@@ -929,10 +928,10 @@ declare module "assert" {
* // OK
* ```
*
* If the values do not match, or if the `string` argument is of another type than`string`, an `AssertionError` is thrown with a `message` property set equal
* If the values do not match, or if the `string` argument is of another type than `string`, an `{@link AssertionError}` is thrown with a `message` property set equal
* to the value of the `message` parameter. If the `message` parameter is
* undefined, a default error message is assigned. If the `message` parameter is an
* instance of an `Error` then it will be thrown instead of the `AssertionError`.
* instance of an [Error](https://nodejs.org/docs/latest-v20.x/api/errors.html#class-error) then it will be thrown instead of the `{@link AssertionError}`.
* @since v13.6.0, v12.16.0
*/
function match(value: string, regExp: RegExp, message?: string | Error): void;
@@ -952,13 +951,60 @@ declare module "assert" {
* // OK
* ```
*
* If the values do match, or if the `string` argument is of another type than`string`, an `AssertionError` is thrown with a `message` property set equal
* If the values do match, or if the `string` argument is of another type than `string`, an `{@link AssertionError}` is thrown with a `message` property set equal
* to the value of the `message` parameter. If the `message` parameter is
* undefined, a default error message is assigned. If the `message` parameter is an
* instance of an `Error` then it will be thrown instead of the `AssertionError`.
* instance of an [Error](https://nodejs.org/docs/latest-v20.x/api/errors.html#class-error) then it will be thrown instead of the `{@link AssertionError}`.
* @since v13.6.0, v12.16.0
*/
function doesNotMatch(value: string, regExp: RegExp, message?: string | Error): void;
/**
* In strict assertion mode, non-strict methods behave like their corresponding strict methods. For example,
* {@link deepEqual} will behave like {@link deepStrictEqual}.
*
* In strict assertion mode, error messages for objects display a diff. In legacy assertion mode, error
* messages for objects display the objects, often truncated.
*
* To use strict assertion mode:
*
* ```js
* import { strict as assert } from 'node:assert';COPY
* import assert from 'node:assert/strict';
* ```
*
* Example error diff:
*
* ```js
* import { strict as assert } from 'node:assert';
*
* assert.deepEqual([[[1, 2, 3]], 4, 5], [[[1, 2, '3']], 4, 5]);
* // AssertionError: Expected inputs to be strictly deep-equal:
* // + actual - expected ... Lines skipped
* //
* // [
* // [
* // ...
* // 2,
* // + 3
* // - '3'
* // ],
* // ...
* // 5
* // ]
* ```
*
* To deactivate the colors, use the `NO_COLOR` or `NODE_DISABLE_COLORS` environment variables. This will also
* deactivate the colors in the REPL. For more on color support in terminal environments, read the tty
* `getColorDepth()` documentation.
*
* @since v15.0.0, v13.9.0, v12.16.2, v9.9.0
*/
namespace strict {
type AssertionError = assert.AssertionError;
type AssertPredicate = assert.AssertPredicate;
type CallTrackerCall = assert.CallTrackerCall;
type CallTrackerReportInformation = assert.CallTrackerReportInformation;
}
const strict:
& Omit<
typeof assert,
@@ -971,6 +1017,7 @@ declare module "assert" {
| "deepStrictEqual"
| "ifError"
| "strict"
| "AssertionError"
>
& {
(value: unknown, message?: string | Error): asserts value;
@@ -986,6 +1033,7 @@ declare module "assert" {
deepStrictEqual: typeof deepStrictEqual;
ifError: typeof ifError;
strict: typeof strict;
AssertionError: typeof AssertionError;
};
}
export = assert;

Some files were not shown because too many files have changed in this diff Show More