Merge pull request #1706 from github/update-v2.3.5-d3314cca2

Merge main into releases/v2
This commit is contained in:
Andrew Eisenberg 2023-05-25 12:10:52 -07:00 коммит произвёл GitHub
Родитель f0e3dfb303 15f9b00614
Коммит 0225834cc5
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
60 изменённых файлов: 319 добавлений и 81 удалений

5
.github/workflows/__analyze-ref-input.yml сгенерированный поставляемый
Просмотреть файл

@ -1,6 +1,6 @@
# Warning: This file is generated automatically, and should not be modified.
# Instead, please modify the template in the pr-checks directory and run:
# pip install ruamel.yaml && python3 sync.py
# (cd pr-checks; pip install ruamel.yaml && python3 sync.py)
# to regenerate this file.
name: "PR Check - Analyze: 'ref' and 'sha' from inputs"
@ -68,6 +68,9 @@ jobs:
- os: windows-latest
version: nightly-latest
name: "Analyze: 'ref' and 'sha' from inputs"
permissions:
contents: read
security-events: write
timeout-minutes: 45
runs-on: ${{ matrix.os }}
steps:

5
.github/workflows/__autobuild-action.yml сгенерированный поставляемый
Просмотреть файл

@ -1,6 +1,6 @@
# Warning: This file is generated automatically, and should not be modified.
# Instead, please modify the template in the pr-checks directory and run:
# pip install ruamel.yaml && python3 sync.py
# (cd pr-checks; pip install ruamel.yaml && python3 sync.py)
# to regenerate this file.
name: PR Check - autobuild-action
@ -32,6 +32,9 @@ jobs:
- os: windows-latest
version: latest
name: autobuild-action
permissions:
contents: read
security-events: write
timeout-minutes: 45
runs-on: ${{ matrix.os }}
steps:

5
.github/workflows/__config-export.yml сгенерированный поставляемый
Просмотреть файл

@ -1,6 +1,6 @@
# Warning: This file is generated automatically, and should not be modified.
# Instead, please modify the template in the pr-checks directory and run:
# pip install ruamel.yaml && python3 sync.py
# (cd pr-checks; pip install ruamel.yaml && python3 sync.py)
# to regenerate this file.
name: PR Check - Config export
@ -38,6 +38,9 @@ jobs:
- os: windows-latest
version: nightly-latest
name: Config export
permissions:
contents: read
security-events: write
timeout-minutes: 45
runs-on: ${{ matrix.os }}
steps:

5
.github/workflows/__diagnostics-export.yml сгенерированный поставляемый
Просмотреть файл

@ -1,6 +1,6 @@
# Warning: This file is generated automatically, and should not be modified.
# Instead, please modify the template in the pr-checks directory and run:
# pip install ruamel.yaml && python3 sync.py
# (cd pr-checks; pip install ruamel.yaml && python3 sync.py)
# to regenerate this file.
name: PR Check - Diagnostic export
@ -44,6 +44,9 @@ jobs:
- os: windows-latest
version: nightly-latest
name: Diagnostic export
permissions:
contents: read
security-events: write
timeout-minutes: 45
runs-on: ${{ matrix.os }}
steps:

5
.github/workflows/__export-file-baseline-information.yml сгенерированный поставляемый
Просмотреть файл

@ -1,6 +1,6 @@
# Warning: This file is generated automatically, and should not be modified.
# Instead, please modify the template in the pr-checks directory and run:
# pip install ruamel.yaml && python3 sync.py
# (cd pr-checks; pip install ruamel.yaml && python3 sync.py)
# to regenerate this file.
name: PR Check - Export file baseline information
@ -32,6 +32,9 @@ jobs:
- os: windows-latest
version: nightly-latest
name: Export file baseline information
permissions:
contents: read
security-events: write
timeout-minutes: 45
runs-on: ${{ matrix.os }}
steps:

5
.github/workflows/__extractor-ram-threads.yml сгенерированный поставляемый
Просмотреть файл

@ -1,6 +1,6 @@
# Warning: This file is generated automatically, and should not be modified.
# Instead, please modify the template in the pr-checks directory and run:
# pip install ruamel.yaml && python3 sync.py
# (cd pr-checks; pip install ruamel.yaml && python3 sync.py)
# to regenerate this file.
name: PR Check - Extractor ram and threads options test
@ -28,6 +28,9 @@ jobs:
- os: ubuntu-latest
version: latest
name: Extractor ram and threads options test
permissions:
contents: read
security-events: write
timeout-minutes: 45
runs-on: ${{ matrix.os }}
steps:

5
.github/workflows/__go-custom-queries.yml сгенерированный поставляемый
Просмотреть файл

@ -1,6 +1,6 @@
# Warning: This file is generated automatically, and should not be modified.
# Instead, please modify the template in the pr-checks directory and run:
# pip install ruamel.yaml && python3 sync.py
# (cd pr-checks; pip install ruamel.yaml && python3 sync.py)
# to regenerate this file.
name: 'PR Check - Go: Custom queries'
@ -68,6 +68,9 @@ jobs:
- os: windows-latest
version: nightly-latest
name: 'Go: Custom queries'
permissions:
contents: read
security-events: write
timeout-minutes: 45
runs-on: ${{ matrix.os }}
steps:

5
.github/workflows/__go-tracing-autobuilder.yml сгенерированный поставляемый
Просмотреть файл

@ -1,6 +1,6 @@
# Warning: This file is generated automatically, and should not be modified.
# Instead, please modify the template in the pr-checks directory and run:
# pip install ruamel.yaml && python3 sync.py
# (cd pr-checks; pip install ruamel.yaml && python3 sync.py)
# to regenerate this file.
name: 'PR Check - Go: tracing with autobuilder step'
@ -54,6 +54,9 @@ jobs:
- os: macos-latest
version: nightly-latest
name: 'Go: tracing with autobuilder step'
permissions:
contents: read
security-events: write
timeout-minutes: 45
runs-on: ${{ matrix.os }}
steps:

5
.github/workflows/__go-tracing-custom-build-steps.yml сгенерированный поставляемый
Просмотреть файл

@ -1,6 +1,6 @@
# Warning: This file is generated automatically, and should not be modified.
# Instead, please modify the template in the pr-checks directory and run:
# pip install ruamel.yaml && python3 sync.py
# (cd pr-checks; pip install ruamel.yaml && python3 sync.py)
# to regenerate this file.
name: 'PR Check - Go: tracing with custom build steps'
@ -54,6 +54,9 @@ jobs:
- os: macos-latest
version: nightly-latest
name: 'Go: tracing with custom build steps'
permissions:
contents: read
security-events: write
timeout-minutes: 45
runs-on: ${{ matrix.os }}
steps:

5
.github/workflows/__go-tracing-legacy-workflow.yml сгенерированный поставляемый
Просмотреть файл

@ -1,6 +1,6 @@
# Warning: This file is generated automatically, and should not be modified.
# Instead, please modify the template in the pr-checks directory and run:
# pip install ruamel.yaml && python3 sync.py
# (cd pr-checks; pip install ruamel.yaml && python3 sync.py)
# to regenerate this file.
name: 'PR Check - Go: tracing with legacy workflow'
@ -54,6 +54,9 @@ jobs:
- os: macos-latest
version: nightly-latest
name: 'Go: tracing with legacy workflow'
permissions:
contents: read
security-events: write
timeout-minutes: 45
runs-on: ${{ matrix.os }}
steps:

10
.github/workflows/__init-with-registries.yml сгенерированный поставляемый
Просмотреть файл

@ -1,6 +1,6 @@
# Warning: This file is generated automatically, and should not be modified.
# Instead, please modify the template in the pr-checks directory and run:
# pip install ruamel.yaml && python3 sync.py
# (cd pr-checks; pip install ruamel.yaml && python3 sync.py)
# to regenerate this file.
name: 'PR Check - Packaging: Download using registries'
@ -44,6 +44,10 @@ jobs:
- os: windows-latest
version: nightly-latest
name: 'Packaging: Download using registries'
permissions:
contents: read
packages: read
timeout-minutes: 45
runs-on: ${{ matrix.os }}
steps:
@ -127,9 +131,5 @@ jobs:
cat $QLCONFIG_PATH
exit 1
fi
permissions:
contents: read
packages: read
env:
CODEQL_ACTION_TEST_MODE: true

5
.github/workflows/__javascript-source-root.yml сгенерированный поставляемый
Просмотреть файл

@ -1,6 +1,6 @@
# Warning: This file is generated automatically, and should not be modified.
# Instead, please modify the template in the pr-checks directory and run:
# pip install ruamel.yaml && python3 sync.py
# (cd pr-checks; pip install ruamel.yaml && python3 sync.py)
# to regenerate this file.
name: PR Check - Custom source root
@ -32,6 +32,9 @@ jobs:
- os: ubuntu-latest
version: nightly-latest
name: Custom source root
permissions:
contents: read
security-events: write
timeout-minutes: 45
runs-on: ${{ matrix.os }}
steps:

5
.github/workflows/__ml-powered-queries.yml сгенерированный поставляемый
Просмотреть файл

@ -1,6 +1,6 @@
# Warning: This file is generated automatically, and should not be modified.
# Instead, please modify the template in the pr-checks directory and run:
# pip install ruamel.yaml && python3 sync.py
# (cd pr-checks; pip install ruamel.yaml && python3 sync.py)
# to regenerate this file.
name: PR Check - ML-powered queries
@ -68,6 +68,9 @@ jobs:
- os: windows-latest
version: nightly-latest
name: ML-powered queries
permissions:
contents: read
security-events: write
timeout-minutes: 45
runs-on: ${{ matrix.os }}
steps:

5
.github/workflows/__multi-language-autodetect.yml сгенерированный поставляемый
Просмотреть файл

@ -1,6 +1,6 @@
# Warning: This file is generated automatically, and should not be modified.
# Instead, please modify the template in the pr-checks directory and run:
# pip install ruamel.yaml && python3 sync.py
# (cd pr-checks; pip install ruamel.yaml && python3 sync.py)
# to regenerate this file.
name: PR Check - Multi-language repository
@ -54,6 +54,9 @@ jobs:
- os: macos-latest
version: nightly-latest
name: Multi-language repository
permissions:
contents: read
security-events: write
timeout-minutes: 45
runs-on: ${{ matrix.os }}
steps:

5
.github/workflows/__packaging-codescanning-config-inputs-js.yml сгенерированный поставляемый
Просмотреть файл

@ -1,6 +1,6 @@
# Warning: This file is generated automatically, and should not be modified.
# Instead, please modify the template in the pr-checks directory and run:
# pip install ruamel.yaml && python3 sync.py
# (cd pr-checks; pip install ruamel.yaml && python3 sync.py)
# to regenerate this file.
name: 'PR Check - Packaging: Config and input passed to the CLI'
@ -44,6 +44,9 @@ jobs:
- os: windows-latest
version: nightly-latest
name: 'Packaging: Config and input passed to the CLI'
permissions:
contents: read
security-events: write
timeout-minutes: 45
runs-on: ${{ matrix.os }}
steps:

5
.github/workflows/__packaging-config-inputs-js.yml сгенерированный поставляемый
Просмотреть файл

@ -1,6 +1,6 @@
# Warning: This file is generated automatically, and should not be modified.
# Instead, please modify the template in the pr-checks directory and run:
# pip install ruamel.yaml && python3 sync.py
# (cd pr-checks; pip install ruamel.yaml && python3 sync.py)
# to regenerate this file.
name: 'PR Check - Packaging: Config and input'
@ -44,6 +44,9 @@ jobs:
- os: windows-latest
version: nightly-latest
name: 'Packaging: Config and input'
permissions:
contents: read
security-events: write
timeout-minutes: 45
runs-on: ${{ matrix.os }}
steps:

5
.github/workflows/__packaging-config-js.yml сгенерированный поставляемый
Просмотреть файл

@ -1,6 +1,6 @@
# Warning: This file is generated automatically, and should not be modified.
# Instead, please modify the template in the pr-checks directory and run:
# pip install ruamel.yaml && python3 sync.py
# (cd pr-checks; pip install ruamel.yaml && python3 sync.py)
# to regenerate this file.
name: 'PR Check - Packaging: Config file'
@ -44,6 +44,9 @@ jobs:
- os: windows-latest
version: nightly-latest
name: 'Packaging: Config file'
permissions:
contents: read
security-events: write
timeout-minutes: 45
runs-on: ${{ matrix.os }}
steps:

5
.github/workflows/__packaging-inputs-js.yml сгенерированный поставляемый
Просмотреть файл

@ -1,6 +1,6 @@
# Warning: This file is generated automatically, and should not be modified.
# Instead, please modify the template in the pr-checks directory and run:
# pip install ruamel.yaml && python3 sync.py
# (cd pr-checks; pip install ruamel.yaml && python3 sync.py)
# to regenerate this file.
name: 'PR Check - Packaging: Action input'
@ -44,6 +44,9 @@ jobs:
- os: windows-latest
version: nightly-latest
name: 'Packaging: Action input'
permissions:
contents: read
security-events: write
timeout-minutes: 45
runs-on: ${{ matrix.os }}
steps:

5
.github/workflows/__remote-config.yml сгенерированный поставляемый
Просмотреть файл

@ -1,6 +1,6 @@
# Warning: This file is generated automatically, and should not be modified.
# Instead, please modify the template in the pr-checks directory and run:
# pip install ruamel.yaml && python3 sync.py
# (cd pr-checks; pip install ruamel.yaml && python3 sync.py)
# to regenerate this file.
name: PR Check - Remote config file
@ -68,6 +68,9 @@ jobs:
- os: windows-latest
version: nightly-latest
name: Remote config file
permissions:
contents: read
security-events: write
timeout-minutes: 45
runs-on: ${{ matrix.os }}
steps:

5
.github/workflows/__rubocop-multi-language.yml сгенерированный поставляемый
Просмотреть файл

@ -1,6 +1,6 @@
# Warning: This file is generated automatically, and should not be modified.
# Instead, please modify the template in the pr-checks directory and run:
# pip install ruamel.yaml && python3 sync.py
# (cd pr-checks; pip install ruamel.yaml && python3 sync.py)
# to regenerate this file.
name: PR Check - RuboCop multi-language
@ -28,6 +28,9 @@ jobs:
- os: ubuntu-latest
version: cached
name: RuboCop multi-language
permissions:
contents: read
security-events: write
timeout-minutes: 45
runs-on: ${{ matrix.os }}
steps:

5
.github/workflows/__ruby.yml сгенерированный поставляемый
Просмотреть файл

@ -1,6 +1,6 @@
# Warning: This file is generated automatically, and should not be modified.
# Instead, please modify the template in the pr-checks directory and run:
# pip install ruamel.yaml && python3 sync.py
# (cd pr-checks; pip install ruamel.yaml && python3 sync.py)
# to regenerate this file.
name: PR Check - Ruby analysis
@ -38,6 +38,9 @@ jobs:
- os: macos-latest
version: nightly-latest
name: Ruby analysis
permissions:
contents: read
security-events: write
timeout-minutes: 45
runs-on: ${{ matrix.os }}
steps:

5
.github/workflows/__split-workflow.yml сгенерированный поставляемый
Просмотреть файл

@ -1,6 +1,6 @@
# Warning: This file is generated automatically, and should not be modified.
# Instead, please modify the template in the pr-checks directory and run:
# pip install ruamel.yaml && python3 sync.py
# (cd pr-checks; pip install ruamel.yaml && python3 sync.py)
# to regenerate this file.
name: PR Check - Split workflow
@ -38,6 +38,9 @@ jobs:
- os: macos-latest
version: nightly-latest
name: Split workflow
permissions:
contents: read
security-events: write
timeout-minutes: 45
runs-on: ${{ matrix.os }}
steps:

5
.github/workflows/__submit-sarif-failure.yml сгенерированный поставляемый
Просмотреть файл

@ -1,6 +1,6 @@
# Warning: This file is generated automatically, and should not be modified.
# Instead, please modify the template in the pr-checks directory and run:
# pip install ruamel.yaml && python3 sync.py
# (cd pr-checks; pip install ruamel.yaml && python3 sync.py)
# to regenerate this file.
name: PR Check - Submit SARIF after failure
@ -32,6 +32,9 @@ jobs:
- os: ubuntu-latest
version: nightly-latest
name: Submit SARIF after failure
permissions:
contents: read
security-events: write
timeout-minutes: 45
runs-on: ${{ matrix.os }}
steps:

5
.github/workflows/__swift-custom-build.yml сгенерированный поставляемый
Просмотреть файл

@ -1,6 +1,6 @@
# Warning: This file is generated automatically, and should not be modified.
# Instead, please modify the template in the pr-checks directory and run:
# pip install ruamel.yaml && python3 sync.py
# (cd pr-checks; pip install ruamel.yaml && python3 sync.py)
# to regenerate this file.
name: PR Check - Swift analysis using a custom build command
@ -38,6 +38,9 @@ jobs:
- os: macos-latest
version: nightly-latest
name: Swift analysis using a custom build command
permissions:
contents: read
security-events: write
timeout-minutes: 45
runs-on: ${{ matrix.os }}
steps:

5
.github/workflows/__test-autobuild-working-dir.yml сгенерированный поставляемый
Просмотреть файл

@ -1,6 +1,6 @@
# Warning: This file is generated automatically, and should not be modified.
# Instead, please modify the template in the pr-checks directory and run:
# pip install ruamel.yaml && python3 sync.py
# (cd pr-checks; pip install ruamel.yaml && python3 sync.py)
# to regenerate this file.
name: PR Check - Autobuild working directory
@ -28,6 +28,9 @@ jobs:
- os: ubuntu-latest
version: latest
name: Autobuild working directory
permissions:
contents: read
security-events: write
timeout-minutes: 45
runs-on: ${{ matrix.os }}
steps:

5
.github/workflows/__test-local-codeql.yml сгенерированный поставляемый
Просмотреть файл

@ -1,6 +1,6 @@
# Warning: This file is generated automatically, and should not be modified.
# Instead, please modify the template in the pr-checks directory and run:
# pip install ruamel.yaml && python3 sync.py
# (cd pr-checks; pip install ruamel.yaml && python3 sync.py)
# to regenerate this file.
name: PR Check - Local CodeQL bundle
@ -28,6 +28,9 @@ jobs:
- os: ubuntu-latest
version: nightly-latest
name: Local CodeQL bundle
permissions:
contents: read
security-events: write
timeout-minutes: 45
runs-on: ${{ matrix.os }}
steps:

5
.github/workflows/__test-proxy.yml сгенерированный поставляемый
Просмотреть файл

@ -1,6 +1,6 @@
# Warning: This file is generated automatically, and should not be modified.
# Instead, please modify the template in the pr-checks directory and run:
# pip install ruamel.yaml && python3 sync.py
# (cd pr-checks; pip install ruamel.yaml && python3 sync.py)
# to regenerate this file.
name: PR Check - Proxy test
@ -28,6 +28,9 @@ jobs:
- os: ubuntu-latest
version: latest
name: Proxy test
permissions:
contents: read
security-events: write
timeout-minutes: 45
runs-on: ${{ matrix.os }}
steps:

5
.github/workflows/__unset-environment.yml сгенерированный поставляемый
Просмотреть файл

@ -1,6 +1,6 @@
# Warning: This file is generated automatically, and should not be modified.
# Instead, please modify the template in the pr-checks directory and run:
# pip install ruamel.yaml && python3 sync.py
# (cd pr-checks; pip install ruamel.yaml && python3 sync.py)
# to regenerate this file.
name: PR Check - Test unsetting environment variables
@ -40,6 +40,9 @@ jobs:
- os: ubuntu-latest
version: nightly-latest
name: Test unsetting environment variables
permissions:
contents: read
security-events: write
timeout-minutes: 45
runs-on: ${{ matrix.os }}
steps:

5
.github/workflows/__upload-ref-sha-input.yml сгенерированный поставляемый
Просмотреть файл

@ -1,6 +1,6 @@
# Warning: This file is generated automatically, and should not be modified.
# Instead, please modify the template in the pr-checks directory and run:
# pip install ruamel.yaml && python3 sync.py
# (cd pr-checks; pip install ruamel.yaml && python3 sync.py)
# to regenerate this file.
name: "PR Check - Upload-sarif: 'ref' and 'sha' from inputs"
@ -68,6 +68,9 @@ jobs:
- os: windows-latest
version: nightly-latest
name: "Upload-sarif: 'ref' and 'sha' from inputs"
permissions:
contents: read
security-events: write
timeout-minutes: 45
runs-on: ${{ matrix.os }}
steps:

5
.github/workflows/__with-checkout-path.yml сгенерированный поставляемый
Просмотреть файл

@ -1,6 +1,6 @@
# Warning: This file is generated automatically, and should not be modified.
# Instead, please modify the template in the pr-checks directory and run:
# pip install ruamel.yaml && python3 sync.py
# (cd pr-checks; pip install ruamel.yaml && python3 sync.py)
# to regenerate this file.
name: PR Check - Use a custom `checkout_path`
@ -68,6 +68,9 @@ jobs:
- os: windows-latest
version: nightly-latest
name: Use a custom `checkout_path`
permissions:
contents: read
security-events: write
timeout-minutes: 45
runs-on: ${{ matrix.os }}
steps:

Просмотреть файл

@ -40,7 +40,7 @@ jobs:
- name: Update git config
run: |
git config --global user.email "github-actions@github.com"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Get version and new branch

2
.github/workflows/update-bundle.yml поставляемый
Просмотреть файл

@ -30,7 +30,7 @@ jobs:
- name: Update git config
run: |
git config --global user.email "github-actions@github.com"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Update bundle

2
.github/workflows/update-dependencies.yml поставляемый
Просмотреть файл

@ -29,7 +29,7 @@ jobs:
git checkout "origin/$BRANCH"
.github/workflows/script/update-node-modules.sh update
if [ ! -z "$(git status --porcelain)" ]; then
git config --global user.email "github-actions@github.com"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git add node_modules
git commit -am "Update checked-in dependencies"

2
.github/workflows/update-release-branch.yml поставляемый
Просмотреть файл

@ -35,7 +35,7 @@ jobs:
- name: Update git config
run: |
git config --global user.email "github-actions@github.com"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Update release branch

Просмотреть файл

@ -1,5 +1,10 @@
# CodeQL Action Changelog
## 2.3.5 - 25 May 2023
- Allow invalid URIs to be used as values to `artifactLocation.uri` properties. This reverses a change from [#1668](https://github.com/github/codeql-action/pull/1668) that inadvertently led to stricter validation of some URI values. [#1705](https://github.com/github/codeql-action/pull/1705)
- Gracefully handle invalid URIs when fingerprinting. [#1694](https://github.com/github/codeql-action/pull/1694)
## 2.3.4 - 24 May 2023
- Updated the SARIF 2.1.0 JSON schema file to the latest from [oasis-tcs/sarif-spec](https://github.com/oasis-tcs/sarif-spec/blob/123e95847b13fbdd4cbe2120fa5e33355d4a042b/Schemata/sarif-schema-2.1.0.json). [#1668](https://github.com/github/codeql-action/pull/1668)

Просмотреть файл

@ -12,7 +12,7 @@ Please note that this project is released with a [Contributor Code of Conduct][c
## Development and Testing
Before you start, ensure that you have a recent version of node (14 or higher) installed, along with a recent version of npm (7 or higher). You can see which version of node is used by the action in `init/action.yml`.
Before you start, ensure that you have a recent version of node (16 or higher) installed, along with a recent version of npm (9.2 or higher). You can see which version of node is used by the action in `init/action.yml`.
### Common tasks

Просмотреть файл

@ -170,3 +170,7 @@ You can use Actions or environment variables to share configuration across multi
## Troubleshooting
Read about [troubleshooting code scanning](https://help.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/troubleshooting-code-scanning).
## Contributing
This project welcomes contributions. See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to build, install, and contribute.

9
lib/fingerprints.js сгенерированный
Просмотреть файл

@ -194,7 +194,14 @@ function resolveUriToFile(location, artifacts, sourceRoot, logger) {
logger.debug(`Ignoring location as URI "${location.uri}" is invalid`);
return undefined;
}
let uri = decodeURIComponent(location.uri);
let uri;
try {
uri = decodeURIComponent(location.uri);
}
catch (e) {
logger.debug(`Ignoring location as URI "${location.uri}" is invalid`);
return undefined;
}
// Remove a file scheme, and abort if the scheme is anything else
const fileUriPrefix = "file://";
if (uri.startsWith(fileUriPrefix)) {

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

3
lib/init-action-post-helper.js сгенерированный
Просмотреть файл

@ -110,8 +110,9 @@ async function run(uploadDatabaseBundleDebugArtifact, uploadLogsDebugArtifact, p
// but we didn't upload anything.
if (process.env["CODEQL_ACTION_EXPECT_UPLOAD_FAILED_SARIF"] === "true" &&
!uploadFailedSarifResult.raw_upload_size_bytes) {
const error = JSON.stringify(uploadFailedSarifResult);
throw new Error("Expected to upload a failed SARIF file for this CodeQL code scanning run, " +
`but the result was instead ${uploadFailedSarifResult}.`);
`but the result was instead ${error}.`);
}
// Upload appropriate Actions artifacts for debugging
if (config.debugMode) {

Просмотреть файл

@ -1 +1 @@
{"version":3,"file":"init-action-post-helper.js","sourceRoot":"","sources":["../src/init-action-post-helper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsC;AAEtC,4DAA8C;AAC9C,qCAAqC;AACrC,iDAAmD;AACnD,mDAA6D;AAG7D,6DAAuF;AACvF,wDAA0C;AAC1C,iCAKgB;AAChB,yCAKoB;AAWpB,SAAS,mCAAmC,CAC1C,KAAc;IAEd,MAAM,YAAY,GAAG,IAAA,gBAAS,EAAC,KAAK,CAAC,CAAC;IACtC,OAAO;QACL,uBAAuB,EAAE,YAAY,CAAC,OAAO;QAC7C,6BAA6B,EAAE,YAAY,CAAC,KAAK;KAClD,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,KAAK,UAAU,sBAAsB,CACnC,MAAc,EACd,aAA4B,EAC5B,QAA2B,EAC3B,MAAc;IAEd,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE;QACrB,OAAO,EAAE,iCAAiC,EAAE,0BAA0B,EAAE,CAAC;KAC1E;IACD,MAAM,MAAM,GAAG,MA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E;QACxB,MAAM,CAAC,OAAO,CACZ,iGAAiG,CAClG,CAAC;QACF,OAAO;KACR;IAED,MAAM,uBAAuB,GAAG,MAAM,yBAAyB,CAC7D,MAAM,EACN,aAAa,EACb,QAAQ,EACR,MAAM,CACP,CAAC;IAEF,IAAI,uBAAuB,CAAC,iCAAiC,EAAE;QAC7D,MAAM,CAAC,KAAK,CACV,8EAA8E;YAC5E,GAAG,uBAAuB,CAAC,iCAAiC,GAAG,CAClE,CAAC;KACH;IACD,8FAA8F;IAC9F,iCAAiC;IACjC,IACE,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,KAAK,MAAM;QAClE,CAAC,uBAAuB,CAAC,qBAAqB,EAC9C;QACA,MAAM,IAAI,KAAK,CACb,4EAA4E;YAC1E,8BAA8B,uBAAuB,GAAG,CAC3D,CAAC;KACH;IAED,qDAAqD;IACrD,IAAI,MAAM,CAAC,SAAS,EAAE;QACpB,IAAI,CAAC,IAAI,CACP,mGAAmG,CACpG,CAAC;QACF,MAAM,iCAAiC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACxD,MAAM,uBAAuB,CAAC,MAAM,CAAC,CAAC;QAEtC,MAAM,cAAc,CAAC,MAAM,CAAC,CAAC;KAC9B;IAED,OAAO,uBAAuB,CAAC;AACjC,CAAC;AArDD,kBAqDC"}
{"version":3,"file":"init-action-post-helper.js","sourceRoot":"","sources":["../src/init-action-post-helper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsC;AAEtC,4DAA8C;AAC9C,qCAAqC;AACrC,iDAAmD;AACnD,mDAA6D;AAG7D,6DAAuF;AACvF,wDAA0C;AAC1C,iCAKgB;AAChB,yCAKoB;AAWpB,SAAS,mCAAmC,CAC1C,KAAc;IAEd,MAAM,YAAY,GAAG,IAAA,gBAAS,EAAC,KAAK,CAAC,CAAC;IACtC,OAAO;QACL,uBAAuB,EAAE,YAAY,CAAC,OAAO;QAC7C,6BAA6B,EAAE,YA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A1BD,8DA0BC;AAEM,KAAK,UAAU,GAAG,CACvB,iCAA2C,EAC3C,uBAAiC,EACjC,cAAwB,EACxB,aAA4B,EAC5B,QAA2B,EAC3B,MAAc;IAEd,MAAM,MAAM,GAAG,MAAM,IAAA,wBAAS,EAAC,WAAW,CAAC,qBAAqB,EAAE,EAAE,MAAM,CAAC,CAAC;IAC5E,IAAI,MAAM,KAAK,SAAS,EAAE;QACxB,MAAM,CAAC,OAAO,CACZ,iGAAiG,CAClG,CAAC;QACF,OAAO;KACR;IAED,MAAM,uBAAuB,GAAG,MAAM,yBAAyB,CAC7D,MAAM,EACN,aAAa,EACb,QAAQ,EACR,MAAM,CACP,CAAC;IAEF,IAAI,uBAAuB,CAAC,iCAAiC,EAAE;QAC7D,MAAM,CAAC,KAAK,CACV,8EAA8E;YAC5E,GAAG,uBAAuB,CAAC,iCAAiC,GAAG,CAClE,CAAC;KACH;IACD,8FAA8F;IAC9F,iCAAiC;IACjC,IACE,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,KAAK,MAAM;QAClE,CAAC,uBAAuB,CAAC,qBAAqB,EAC9C;QACA,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,uBAAuB,CAAC,CAAC;QACtD,MAAM,IAAI,KAAK,CACb,4EAA4E;YAC1E,8BAA8B,KAAK,GAAG,CACzC,CAAC;KACH;IAED,qDAAqD;IACrD,IAAI,MAAM,CAAC,SAAS,EAAE;QACpB,IAAI,CAAC,IAAI,CACP,mGAAmG,CACpG,CAAC;QACF,MAAM,iCAAiC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACxD,MAAM,uBAAuB,CAAC,MAAM,CAAC,CAAC;QAEtC,MAAM,cAAc,CAAC,MAAM,CAAC,CAAC;KAC9B;IAED,OAAO,uBAAuB,CAAC;AACjC,CAAC;AAtDD,kBAsDC"}

13
lib/upload-lib.js сгенерированный
Просмотреть файл

@ -181,16 +181,23 @@ function validateSarifFileSchema(sarifFilePath, logger) {
const sarif = JSON.parse(fs.readFileSync(sarifFilePath, "utf8"));
const schema = require("../src/sarif-schema-2.1.0.json");
const result = new jsonschema.Validator().validate(sarif, schema);
if (!result.valid) {
// Filter errors related to invalid URIs in the artifactLocation field as this
// is a breaking change. See https://github.com/github/codeql-action/issues/1703
const errors = (result.errors || []).filter((err) => err.argument !== "uri-reference");
const warnings = (result.errors || []).filter((err) => err.argument === "uri-reference");
for (const warning of warnings) {
logger.info(`Warning: '${warning.instance}' is not a valid URI in '${warning.property}'.`);
}
if (errors.length) {
// Output the more verbose error messages in groups as these may be very large.
for (const error of result.errors) {
for (const error of errors) {
logger.startGroup(`Error details: ${error.stack}`);
logger.info(JSON.stringify(error, null, 2));
logger.endGroup();
}
// Set the main error message to the stacks of all the errors.
// This should be of a manageable size and may even give enough to fix the error.
const sarifErrors = result.errors.map((e) => `- ${e.stack}`);
const sarifErrors = errors.map((e) => `- ${e.stack}`);
throw new Error(`Unable to upload "${sarifFilePath}" as it is not valid SARIF:\n${sarifErrors.join("\n")}`);
}
}

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

12
lib/upload-lib.test.js сгенерированный
Просмотреть файл

@ -233,6 +233,18 @@ ava_1.default.beforeEach(() => {
t.deepEqual(loggedMessages.length, 1);
t.assert(loggedMessages[0].includes("Pruned 2 results"));
});
(0, ava_1.default)("accept results with invalid artifactLocation.uri value", (t) => {
const loggedMessages = [];
const mockLogger = {
info: (message) => {
loggedMessages.push(message);
},
};
const sarifFile = `${__dirname}/../src/testdata/with-invalid-uri.sarif`;
uploadLib.validateSarifFileSchema(sarifFile, mockLogger);
t.deepEqual(loggedMessages.length, 1);
t.deepEqual(loggedMessages[0], "Warning: 'not a valid URI' is not a valid URI in 'instance.runs[0].results[0].locations[0].physicalLocation.artifactLocation.uri'.");
});
const affectedCodeQLVersion = {
driver: {
name: "CodeQL",

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

28
lib/util.js сгенерированный
Просмотреть файл

@ -673,11 +673,6 @@ function removeDuplicateLocations(locations) {
});
}
function fixInvalidNotifications(sarif, logger) {
if (process.env[shared_environment_1.CODEQL_ACTION_DISABLE_DUPLICATE_LOCATION_FIX] === "true") {
logger.info("SARIF notification object duplicate location fix disabled by the " +
`${shared_environment_1.CODEQL_ACTION_DISABLE_DUPLICATE_LOCATION_FIX} environment variable.`);
return sarif;
}
if (!Array.isArray(sarif.runs)) {
return sarif;
}
@ -727,10 +722,27 @@ function fixInvalidNotifications(sarif, logger) {
return newSarif;
}
exports.fixInvalidNotifications = fixInvalidNotifications;
/**
* Removes duplicates from the sarif file.
*
* When `CODEQL_ACTION_DISABLE_DUPLICATE_LOCATION_FIX` is set to true, this will
* simply rename the input file to the output file. Otherwise, it will parse the
* input file as JSON, remove duplicate locations from the SARIF notification
* objects, and write the result to the output file.
*
* For context, see documentation of:
* `CODEQL_ACTION_DISABLE_DUPLICATE_LOCATION_FIX`. */
function fixInvalidNotificationsInFile(inputPath, outputPath, logger) {
let sarif = JSON.parse(fs.readFileSync(inputPath, "utf8"));
sarif = fixInvalidNotifications(sarif, logger);
fs.writeFileSync(outputPath, JSON.stringify(sarif));
if (process.env[shared_environment_1.CODEQL_ACTION_DISABLE_DUPLICATE_LOCATION_FIX] === "true") {
logger.info("SARIF notification object duplicate location fix disabled by the " +
`${shared_environment_1.CODEQL_ACTION_DISABLE_DUPLICATE_LOCATION_FIX} environment variable.`);
fs.renameSync(inputPath, outputPath);
}
else {
let sarif = JSON.parse(fs.readFileSync(inputPath, "utf8"));
sarif = fixInvalidNotifications(sarif, logger);
fs.writeFileSync(outputPath, JSON.stringify(sarif));
}
}
exports.fixInvalidNotificationsInFile = fixInvalidNotificationsInFile;
function wrapError(error) {

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

4
lib/workflow.js сгенерированный
Просмотреть файл

@ -298,7 +298,9 @@ function getInputOrThrow(workflow, jobName, actionName, inputName, matrixVars) {
* This allows us to test workflow parsing functionality as a CodeQL Action PR check.
*/
function getAnalyzeActionName() {
if ((0, util_1.getRequiredEnvParam)("GITHUB_REPOSITORY") === "github/codeql-action") {
if ((0, util_1.isInTestMode)() ||
process.env["CODEQL_ACTION_TESTING_ENVIRONMENT"] ===
"codeql-action-pr-checks") {
return "./analyze";
}
else {

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

2
node_modules/.package-lock.json сгенерированный поставляемый
Просмотреть файл

@ -1,6 +1,6 @@
{
"name": "codeql",
"version": "2.3.4",
"version": "2.3.5",
"lockfileVersion": 3,
"requires": true,
"packages": {

4
package-lock.json сгенерированный
Просмотреть файл

@ -1,12 +1,12 @@
{
"name": "codeql",
"version": "2.3.4",
"version": "2.3.5",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "codeql",
"version": "2.3.4",
"version": "2.3.5",
"license": "MIT",
"dependencies": {
"@actions/artifact": "^1.1.0",

Просмотреть файл

@ -1,6 +1,6 @@
{
"name": "codeql",
"version": "2.3.4",
"version": "2.3.5",
"private": true,
"description": "CodeQL action",
"scripts": {

Просмотреть файл

@ -24,7 +24,7 @@ defaultTestVersions = [
header = """# Warning: This file is generated automatically, and should not be modified.
# Instead, please modify the template in the pr-checks directory and run:
# pip install ruamel.yaml && python3 sync.py
# (cd pr-checks; pip install ruamel.yaml && python3 sync.py)
# to regenerate this file.
"""
@ -100,6 +100,10 @@ for file in os.listdir('checks'):
}
},
'name': checkSpecification['name'],
'permissions': {
'contents': 'read',
'security-events': 'write'
},
'timeout-minutes': 45,
'runs-on': '${{ matrix.os }}',
'steps': steps,

Просмотреть файл

@ -201,7 +201,14 @@ export function resolveUriToFile(
logger.debug(`Ignoring location as URI "${location.uri}" is invalid`);
return undefined;
}
let uri = decodeURIComponent(location.uri as string);
let uri: string;
try {
uri = decodeURIComponent(location.uri as string);
} catch (e: any) {
logger.debug(`Ignoring location as URI "${location.uri}" is invalid`);
return undefined;
}
// Remove a file scheme, and abort if the scheme is anything else
const fileUriPrefix = "file://";

Просмотреть файл

@ -171,9 +171,10 @@ export async function run(
process.env["CODEQL_ACTION_EXPECT_UPLOAD_FAILED_SARIF"] === "true" &&
!uploadFailedSarifResult.raw_upload_size_bytes
) {
const error = JSON.stringify(uploadFailedSarifResult);
throw new Error(
"Expected to upload a failed SARIF file for this CodeQL code scanning run, " +
`but the result was instead ${uploadFailedSarifResult}.`
`but the result was instead ${error}.`
);
}

42
src/testdata/with-invalid-uri.sarif поставляемый Normal file
Просмотреть файл

@ -0,0 +1,42 @@
{
"$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
"version": "2.1.0",
"runs": [
{
"tool": {
"driver": {
"name": "LGTM.com",
"organization": "Semmle",
"version": "1.24.0-SNAPSHOT",
"rules": []
}
},
"results" : [ {
"ruleId" : "js/unused-local-variable",
"ruleIndex" : 0,
"message" : {
"text" : "Unused variable foo."
},
"locations" : [ {
"physicalLocation" : {
"artifactLocation" : {
"uri" : "not a valid URI",
"uriBaseId" : "%SRCROOT%",
"index" : 0
},
"region" : {
"startLine" : 2,
"startColumn" : 7,
"endColumn" : 10
}
}
} ]
} ],
"columnKind": "utf16CodeUnits",
"properties": {
"semmle.formatSpecifier": "2.1.0",
"semmle.sourceLanguage": "java"
}
}
]
}

Просмотреть файл

@ -360,6 +360,23 @@ test("pruneInvalidResults", (t) => {
t.assert(loggedMessages[0].includes("Pruned 2 results"));
});
test("accept results with invalid artifactLocation.uri value", (t) => {
const loggedMessages: string[] = [];
const mockLogger = {
info: (message: string) => {
loggedMessages.push(message);
},
} as Logger;
const sarifFile = `${__dirname}/../src/testdata/with-invalid-uri.sarif`;
uploadLib.validateSarifFileSchema(sarifFile, mockLogger);
t.deepEqual(loggedMessages.length, 1);
t.deepEqual(
loggedMessages[0],
"Warning: 'not a valid URI' is not a valid URI in 'instance.runs[0].results[0].locations[0].physicalLocation.artifactLocation.uri'."
);
});
const affectedCodeQLVersion = {
driver: {
name: "CodeQL",

Просмотреть файл

@ -228,9 +228,24 @@ export function validateSarifFileSchema(sarifFilePath: string, logger: Logger) {
const schema = require("../src/sarif-schema-2.1.0.json") as jsonschema.Schema;
const result = new jsonschema.Validator().validate(sarif, schema);
if (!result.valid) {
// Filter errors related to invalid URIs in the artifactLocation field as this
// is a breaking change. See https://github.com/github/codeql-action/issues/1703
const errors = (result.errors || []).filter(
(err) => err.argument !== "uri-reference"
);
const warnings = (result.errors || []).filter(
(err) => err.argument === "uri-reference"
);
for (const warning of warnings) {
logger.info(
`Warning: '${warning.instance}' is not a valid URI in '${warning.property}'.`
);
}
if (errors.length) {
// Output the more verbose error messages in groups as these may be very large.
for (const error of result.errors) {
for (const error of errors) {
logger.startGroup(`Error details: ${error.stack}`);
logger.info(JSON.stringify(error, null, 2));
logger.endGroup();
@ -238,7 +253,7 @@ export function validateSarifFileSchema(sarifFilePath: string, logger: Logger) {
// Set the main error message to the stacks of all the errors.
// This should be of a manageable size and may even give enough to fix the error.
const sarifErrors = result.errors.map((e) => `- ${e.stack}`);
const sarifErrors = errors.map((e) => `- ${e.stack}`);
throw new Error(
`Unable to upload "${sarifFilePath}" as it is not valid SARIF:\n${sarifErrors.join(
"\n"

Просмотреть файл

@ -818,13 +818,6 @@ export function fixInvalidNotifications(
sarif: SarifFile,
logger: Logger
): SarifFile {
if (process.env[CODEQL_ACTION_DISABLE_DUPLICATE_LOCATION_FIX] === "true") {
logger.info(
"SARIF notification object duplicate location fix disabled by the " +
`${CODEQL_ACTION_DISABLE_DUPLICATE_LOCATION_FIX} environment variable.`
);
return sarif;
}
if (!Array.isArray(sarif.runs)) {
return sarif;
}
@ -883,14 +876,32 @@ export function fixInvalidNotifications(
return newSarif;
}
/**
* Removes duplicates from the sarif file.
*
* When `CODEQL_ACTION_DISABLE_DUPLICATE_LOCATION_FIX` is set to true, this will
* simply rename the input file to the output file. Otherwise, it will parse the
* input file as JSON, remove duplicate locations from the SARIF notification
* objects, and write the result to the output file.
*
* For context, see documentation of:
* `CODEQL_ACTION_DISABLE_DUPLICATE_LOCATION_FIX`. */
export function fixInvalidNotificationsInFile(
inputPath: string,
outputPath: string,
logger: Logger
): void {
let sarif = JSON.parse(fs.readFileSync(inputPath, "utf8")) as SarifFile;
sarif = fixInvalidNotifications(sarif, logger);
fs.writeFileSync(outputPath, JSON.stringify(sarif));
if (process.env[CODEQL_ACTION_DISABLE_DUPLICATE_LOCATION_FIX] === "true") {
logger.info(
"SARIF notification object duplicate location fix disabled by the " +
`${CODEQL_ACTION_DISABLE_DUPLICATE_LOCATION_FIX} environment variable.`
);
fs.renameSync(inputPath, outputPath);
} else {
let sarif = JSON.parse(fs.readFileSync(inputPath, "utf8")) as SarifFile;
sarif = fixInvalidNotifications(sarif, logger);
fs.writeFileSync(outputPath, JSON.stringify(sarif));
}
}
export function wrapError(error: unknown): Error {

Просмотреть файл

@ -7,7 +7,7 @@ import * as yaml from "js-yaml";
import * as api from "./api-client";
import { Logger } from "./logging";
import { getRequiredEnvParam } from "./util";
import { getRequiredEnvParam, isInTestMode } from "./util";
export interface WorkflowJobStep {
name?: string;
@ -389,7 +389,11 @@ function getInputOrThrow(
* This allows us to test workflow parsing functionality as a CodeQL Action PR check.
*/
function getAnalyzeActionName() {
if (getRequiredEnvParam("GITHUB_REPOSITORY") === "github/codeql-action") {
if (
isInTestMode() ||
process.env["CODEQL_ACTION_TESTING_ENVIRONMENT"] ===
"codeql-action-pr-checks"
) {
return "./analyze";
} else {
return "github/codeql-action/analyze";