mirror of
https://github.com/github/codeql-action.git
synced 2026-08-05 04:57:19 -05:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c55c1eedf6 |
@@ -28,6 +28,7 @@ runs:
|
|||||||
echo "::set-output name=tools-url::https://github.com/dsp-testing/codeql-cli-nightlies/releases/download/codeql-bundle-$VERSION-manual/codeql-bundle.tar.gz"
|
echo "::set-output name=tools-url::https://github.com/dsp-testing/codeql-cli-nightlies/releases/download/codeql-bundle-$VERSION-manual/codeql-bundle.tar.gz"
|
||||||
elif [[ ${{ inputs.version }} == *"stable"* ]]; then
|
elif [[ ${{ inputs.version }} == *"stable"* ]]; then
|
||||||
export VERSION=`echo ${{ inputs.version }} | sed -e 's/^.*\-//'`
|
export VERSION=`echo ${{ inputs.version }} | sed -e 's/^.*\-//'`
|
||||||
|
echo "Hello $VERSION"
|
||||||
echo "::set-output name=tools-url::https://github.com/github/codeql-action/releases/download/codeql-bundle-$VERSION/codeql-bundle.tar.gz"
|
echo "::set-output name=tools-url::https://github.com/github/codeql-action/releases/download/codeql-bundle-$VERSION/codeql-bundle.tar.gz"
|
||||||
elif [[ ${{ inputs.version }} == "latest" ]]; then
|
elif [[ ${{ inputs.version }} == "latest" ]]; then
|
||||||
echo "::set-output name=tools-url::latest"
|
echo "::set-output name=tools-url::latest"
|
||||||
|
|||||||
Generated
-75
@@ -1,75 +0,0 @@
|
|||||||
# Warning: This file is generated automatically, and should not be modified.
|
|
||||||
# Instead, please modify the template in the pr-checks directory and run:
|
|
||||||
# pip install ruamel.yaml && python3 sync.py
|
|
||||||
# to regenerate this file.
|
|
||||||
|
|
||||||
name: PR Check - Debug artifact upload
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
GO111MODULE: auto
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- v1
|
|
||||||
pull_request:
|
|
||||||
types:
|
|
||||||
- opened
|
|
||||||
- synchronize
|
|
||||||
- reopened
|
|
||||||
- ready_for_review
|
|
||||||
workflow_dispatch: {}
|
|
||||||
jobs:
|
|
||||||
debug-artifacts:
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
version:
|
|
||||||
- stable-20201028
|
|
||||||
- stable-20210319
|
|
||||||
- stable-20210809
|
|
||||||
- cached
|
|
||||||
- latest
|
|
||||||
- nightly-latest
|
|
||||||
os: [ubuntu-latest, macos-latest]
|
|
||||||
name: Debug artifact upload
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
steps:
|
|
||||||
- name: Check out repository
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Prepare test
|
|
||||||
id: prepare-test
|
|
||||||
uses: ./.github/prepare-test
|
|
||||||
with:
|
|
||||||
version: ${{ matrix.version }}
|
|
||||||
- uses: ./../action/init
|
|
||||||
with:
|
|
||||||
tools: ${{ steps.prepare-test.outputs.tools-url }}
|
|
||||||
debug: true
|
|
||||||
- name: Build code
|
|
||||||
shell: bash
|
|
||||||
run: ./build.sh
|
|
||||||
- uses: ./../action/analyze
|
|
||||||
id: analysis
|
|
||||||
- uses: actions/download-artifact@v2
|
|
||||||
with:
|
|
||||||
name: debug-artifacts-${{ matrix.os }}-${{ matrix.version }}
|
|
||||||
- shell: bash
|
|
||||||
run: |
|
|
||||||
LANGUAGES="cpp csharp go java javascript python"
|
|
||||||
for language in $LANGUAGES; do
|
|
||||||
echo "Checking $language"
|
|
||||||
if [[ ! -f "$language.sarif" ]] ; then
|
|
||||||
echo "Missing a SARIF file for $language"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [[ ! -f "$language.zip" ]] ; then
|
|
||||||
echo "Missing a database bundle for $language"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [[ ! -d "$language/log" ]] ; then
|
|
||||||
echo "Missing logs for $language"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
env:
|
|
||||||
INTERNAL_CODEQL_ACTION_DEBUG_LOC: true
|
|
||||||
-63
@@ -1,63 +0,0 @@
|
|||||||
# Warning: This file is generated automatically, and should not be modified.
|
|
||||||
# Instead, please modify the template in the pr-checks directory and run:
|
|
||||||
# pip install ruamel.yaml && python3 sync.py
|
|
||||||
# to regenerate this file.
|
|
||||||
|
|
||||||
name: PR Check - Extractor ram and threads options test
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
GO111MODULE: auto
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- v1
|
|
||||||
pull_request:
|
|
||||||
types:
|
|
||||||
- opened
|
|
||||||
- synchronize
|
|
||||||
- reopened
|
|
||||||
- ready_for_review
|
|
||||||
workflow_dispatch: {}
|
|
||||||
jobs:
|
|
||||||
extractor-ram-threads:
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
version: [latest]
|
|
||||||
os: [ubuntu-latest]
|
|
||||||
name: Extractor ram and threads options test
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
steps:
|
|
||||||
- name: Check out repository
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Prepare test
|
|
||||||
id: prepare-test
|
|
||||||
uses: ./.github/prepare-test
|
|
||||||
with:
|
|
||||||
version: ${{ matrix.version }}
|
|
||||||
- uses: ./../action/init
|
|
||||||
with:
|
|
||||||
languages: java
|
|
||||||
ram: 230
|
|
||||||
threads: 1
|
|
||||||
- name: Assert Results
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
if [ "${CODEQL_RAM}" != "230" ]; then
|
|
||||||
echo "CODEQL_RAM is '${CODEQL_RAM}' instead of 230"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ "${CODEQL_EXTRACTOR_JAVA_RAM}" != "230" ]; then
|
|
||||||
echo "CODEQL_EXTRACTOR_JAVA_RAM is '${CODEQL_EXTRACTOR_JAVA_RAM}' instead of 230"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ "${CODEQL_THREADS}" != "1" ]; then
|
|
||||||
echo "CODEQL_THREADS is '${CODEQL_THREADS}' instead of 1"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ "${CODEQL_EXTRACTOR_JAVA_THREADS}" != "1" ]; then
|
|
||||||
echo "CODEQL_EXTRACTOR_JAVA_THREADS is '${CODEQL_EXTRACTOR_JAVA_THREADS}' instead of 1"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
env:
|
|
||||||
INTERNAL_CODEQL_ACTION_DEBUG_LOC: true
|
|
||||||
Generated
-1
@@ -60,7 +60,6 @@ jobs:
|
|||||||
- uses: ./../action/analyze
|
- uses: ./../action/analyze
|
||||||
with:
|
with:
|
||||||
output: ${{ runner.temp }}/results
|
output: ${{ runner.temp }}/results
|
||||||
upload-database: false
|
|
||||||
env:
|
env:
|
||||||
TEST_MODE: true
|
TEST_MODE: true
|
||||||
- name: Assert Results
|
- name: Assert Results
|
||||||
|
|||||||
-88
@@ -1,88 +0,0 @@
|
|||||||
# Warning: This file is generated automatically, and should not be modified.
|
|
||||||
# Instead, please modify the template in the pr-checks directory and run:
|
|
||||||
# pip install ruamel.yaml && python3 sync.py
|
|
||||||
# to regenerate this file.
|
|
||||||
|
|
||||||
name: PR Check - Test unsetting environment variables
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
GO111MODULE: auto
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- v1
|
|
||||||
pull_request:
|
|
||||||
types:
|
|
||||||
- opened
|
|
||||||
- synchronize
|
|
||||||
- reopened
|
|
||||||
- ready_for_review
|
|
||||||
workflow_dispatch: {}
|
|
||||||
jobs:
|
|
||||||
unset-environment:
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
version:
|
|
||||||
- stable-20201028
|
|
||||||
- stable-20210319
|
|
||||||
- stable-20210809
|
|
||||||
- cached
|
|
||||||
- latest
|
|
||||||
- nightly-latest
|
|
||||||
os: [ubuntu-latest]
|
|
||||||
name: Test unsetting environment variables
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
steps:
|
|
||||||
- name: Check out repository
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Prepare test
|
|
||||||
id: prepare-test
|
|
||||||
uses: ./.github/prepare-test
|
|
||||||
with:
|
|
||||||
version: ${{ matrix.version }}
|
|
||||||
- uses: ./../action/init
|
|
||||||
with:
|
|
||||||
db-location: ${{ runner.temp }}/customDbLocation
|
|
||||||
tools: ${{ steps.prepare-test.outputs.tools-url }}
|
|
||||||
- name: Build code
|
|
||||||
shell: bash
|
|
||||||
run: env -i PATH="$PATH" HOME="$HOME" ./build.sh
|
|
||||||
- uses: ./../action/analyze
|
|
||||||
id: analysis
|
|
||||||
env:
|
|
||||||
TEST_MODE: true
|
|
||||||
- shell: bash
|
|
||||||
run: |
|
|
||||||
CPP_DB=${{ fromJson(steps.analysis.outputs.db-locations).cpp }}
|
|
||||||
if [[ ! -d $CPP_DB ]] || [[ ! $CPP_DB == ${{ runner.temp }}/customDbLocation/* ]]; then
|
|
||||||
echo "Did not create a database for CPP, or created it in the wrong location."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
CSHARP_DB=${{ fromJson(steps.analysis.outputs.db-locations).csharp }}
|
|
||||||
if [[ ! -d $CSHARP_DB ]] || [[ ! $CSHARP_DB == ${{ runner.temp }}/customDbLocation/* ]]; then
|
|
||||||
echo "Did not create a database for C Sharp, or created it in the wrong location."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
GO_DB=${{ fromJson(steps.analysis.outputs.db-locations).go }}
|
|
||||||
if [[ ! -d $GO_DB ]] || [[ ! $GO_DB == ${{ runner.temp }}/customDbLocation/* ]]; then
|
|
||||||
echo "Did not create a database for Go, or created it in the wrong location."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
JAVA_DB=${{ fromJson(steps.analysis.outputs.db-locations).java }}
|
|
||||||
if [[ ! -d $JAVA_DB ]] || [[ ! $JAVA_DB == ${{ runner.temp }}/customDbLocation/* ]]; then
|
|
||||||
echo "Did not create a database for Java, or created it in the wrong location."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
JAVASCRIPT_DB=${{ fromJson(steps.analysis.outputs.db-locations).javascript }}
|
|
||||||
if [[ ! -d $JAVASCRIPT_DB ]] || [[ ! $JAVASCRIPT_DB == ${{ runner.temp }}/customDbLocation/* ]]; then
|
|
||||||
echo "Did not create a database for Javascript, or created it in the wrong location."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
PYTHON_DB=${{ fromJson(steps.analysis.outputs.db-locations).python }}
|
|
||||||
if [[ ! -d $PYTHON_DB ]] || [[ ! $PYTHON_DB == ${{ runner.temp }}/customDbLocation/* ]]; then
|
|
||||||
echo "Did not create a database for Python, or created it in the wrong location."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
env:
|
|
||||||
INTERNAL_CODEQL_ACTION_DEBUG_LOC: true
|
|
||||||
@@ -393,42 +393,3 @@ jobs:
|
|||||||
# Deliberately don't use TEST_MODE here. This is specifically testing
|
# Deliberately don't use TEST_MODE here. This is specifically testing
|
||||||
# the compatibility with the API.
|
# the compatibility with the API.
|
||||||
runner/dist/codeql-runner-linux upload --sarif-file src/testdata/empty-sarif.sarif --repository $GITHUB_REPOSITORY --commit $GITHUB_SHA --ref $GITHUB_REF --github-url $GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
runner/dist/codeql-runner-linux upload --sarif-file src/testdata/empty-sarif.sarif --repository $GITHUB_REPOSITORY --commit $GITHUB_SHA --ref $GITHUB_REF --github-url $GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
||||||
|
|
||||||
runner-extractor-ram-threads-options:
|
|
||||||
name: Runner ubuntu extractor RAM and threads options
|
|
||||||
needs: [check-js, check-node-modules]
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Build runner
|
|
||||||
run: |
|
|
||||||
cd runner
|
|
||||||
npm install
|
|
||||||
npm run build-runner
|
|
||||||
|
|
||||||
- name: Run init
|
|
||||||
run: |
|
|
||||||
runner/dist/codeql-runner-linux init --ram=230 --threads=1 --repository $GITHUB_REPOSITORY --languages java --github-url $GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
|
||||||
|
|
||||||
- name: Assert Results
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
. ./codeql-runner/codeql-env.sh
|
|
||||||
if [ "${CODEQL_RAM}" != "230" ]; then
|
|
||||||
echo "CODEQL_RAM is '${CODEQL_RAM}' instead of 230"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ "${CODEQL_EXTRACTOR_JAVA_RAM}" != "230" ]; then
|
|
||||||
echo "CODEQL_EXTRACTOR_JAVA_RAM is '${CODEQL_EXTRACTOR_JAVA_RAM}' instead of 230"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ "${CODEQL_THREADS}" != "1" ]; then
|
|
||||||
echo "CODEQL_THREADS is '${CODEQL_THREADS}' instead of 1"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ "${CODEQL_EXTRACTOR_JAVA_THREADS}" != "1" ]; then
|
|
||||||
echo "CODEQL_EXTRACTOR_JAVA_THREADS is '${CODEQL_EXTRACTOR_JAVA_THREADS}' instead of 1"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|||||||
@@ -1,13 +1,17 @@
|
|||||||
name: Update dependencies
|
name: Update dependencies
|
||||||
on:
|
on:
|
||||||
pull_request_target:
|
pull_request:
|
||||||
types: [opened, synchronize, reopened, ready_for_review, labeled]
|
types: [opened, synchronize, reopened, ready_for_review, labeled]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
issues: write
|
||||||
|
contents: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
update:
|
update:
|
||||||
name: Update dependencies
|
name: Update dependencies
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
if: contains(github.event.pull_request.labels.*.name, 'Update dependencies') && (github.event.pull_request.head.repo.full_name == 'github/codeql-action')
|
if: contains(github.event.pull_request.labels.*.name, 'Update dependencies')
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
@@ -24,8 +28,8 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
BRANCH: '${{ github.head_ref }}'
|
BRANCH: '${{ github.head_ref }}'
|
||||||
run: |
|
run: |
|
||||||
git fetch origin "$BRANCH" --depth=1
|
git fetch
|
||||||
git checkout "origin/$BRANCH"
|
git checkout $BRANCH
|
||||||
sudo npm install --force -g npm@latest
|
sudo npm install --force -g npm@latest
|
||||||
npm install
|
npm install
|
||||||
npm ci
|
npm ci
|
||||||
@@ -35,5 +39,5 @@ jobs:
|
|||||||
git config --global user.name "github-actions[bot]"
|
git config --global user.name "github-actions[bot]"
|
||||||
git add node_modules
|
git add node_modules
|
||||||
git commit -am "Update checked-in dependencies"
|
git commit -am "Update checked-in dependencies"
|
||||||
git push origin "HEAD:$BRANCH"
|
git push origin "$BRANCH"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
name: Update release branch
|
name: Update release branch
|
||||||
on:
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: 0 9 * * 1
|
||||||
repository_dispatch:
|
repository_dispatch:
|
||||||
# Example of how to trigger this:
|
# Example of how to trigger this:
|
||||||
# curl -H "Authorization: Bearer <token>" -X POST https://api.github.com/repos/github/codeql-action/dispatches -d '{"event_type":"update-release-branch"}'
|
# curl -H "Authorization: Bearer <token>" -X POST https://api.github.com/repos/github/codeql-action/dispatches -d '{"event_type":"update-release-branch"}'
|
||||||
|
|||||||
@@ -2,37 +2,6 @@
|
|||||||
|
|
||||||
## [UNRELEASED]
|
## [UNRELEASED]
|
||||||
|
|
||||||
- The `analyze` and `upload-sarif` actions will now wait up to 2 minutes for processing to complete after they have uploaded the results so they can report any processing errors that occurred. This behavior can be disabled by setting the `wait-for-processing` action input to `"false"`.
|
|
||||||
|
|
||||||
|
|
||||||
## 1.0.26 - 10 Dec 2021
|
|
||||||
|
|
||||||
- Update default CodeQL bundle version to 2.7.3. [#842](https://github.com/github/codeql-action/pull/842)
|
|
||||||
|
|
||||||
## 1.0.25 - 06 Dec 2021
|
|
||||||
|
|
||||||
No user facing changes.
|
|
||||||
|
|
||||||
## 1.0.24 - 23 Nov 2021
|
|
||||||
|
|
||||||
- Update default CodeQL bundle version to 2.7.2. [#827](https://github.com/github/codeql-action/pull/827)
|
|
||||||
|
|
||||||
## 1.0.23 - 16 Nov 2021
|
|
||||||
|
|
||||||
- The `upload-sarif` action now allows multiple uploads in a single job, as long as they have different categories. [#801](https://github.com/github/codeql-action/pull/801)
|
|
||||||
- Update default CodeQL bundle version to 2.7.1. [#816](https://github.com/github/codeql-action/pull/816)
|
|
||||||
|
|
||||||
## 1.0.22 - 04 Nov 2021
|
|
||||||
|
|
||||||
- The `init` step of the Action now supports `ram` and `threads` inputs to limit resource use of CodeQL extractors. These inputs also serve as defaults to the subsequent `analyze` step, which finalizes the database and executes queries. [#738](https://github.com/github/codeql-action/pull/738)
|
|
||||||
- When used with CodeQL 2.7.1 or above, the Action now includes custom query help in the analysis results uploaded to GitHub code scanning, if available. To add help text for a custom query, create a Markdown file next to the `.ql` file containing the query, using the same base name but the file extension `.md`. [#804](https://github.com/github/codeql-action/pull/804)
|
|
||||||
|
|
||||||
## 1.0.21 - 28 Oct 2021
|
|
||||||
|
|
||||||
- Update default CodeQL bundle version to 2.7.0. [#795](https://github.com/github/codeql-action/pull/795)
|
|
||||||
|
|
||||||
## 1.0.20 - 25 Oct 2021
|
|
||||||
|
|
||||||
No user facing changes.
|
No user facing changes.
|
||||||
|
|
||||||
## 1.0.19 - 18 Oct 2021
|
## 1.0.19 - 18 Oct 2021
|
||||||
|
|||||||
+9
-23
@@ -1,6 +1,6 @@
|
|||||||
name: "CodeQL: Finish"
|
name: 'CodeQL: Finish'
|
||||||
description: "Finalize CodeQL database"
|
description: 'Finalize CodeQL database'
|
||||||
author: "GitHub"
|
author: 'GitHub'
|
||||||
inputs:
|
inputs:
|
||||||
check_name:
|
check_name:
|
||||||
description: The name of the check run to add text to.
|
description: The name of the check run to add text to.
|
||||||
@@ -8,9 +8,9 @@ inputs:
|
|||||||
output:
|
output:
|
||||||
description: The path of the directory in which to save the SARIF results
|
description: The path of the directory in which to save the SARIF results
|
||||||
required: false
|
required: false
|
||||||
default: "../results"
|
default: '../results'
|
||||||
upload:
|
upload:
|
||||||
description: Upload the SARIF file to Code Scanning
|
description: Upload the SARIF file
|
||||||
required: false
|
required: false
|
||||||
default: "true"
|
default: "true"
|
||||||
cleanup-level:
|
cleanup-level:
|
||||||
@@ -18,12 +18,7 @@ inputs:
|
|||||||
required: false
|
required: false
|
||||||
default: "brutal"
|
default: "brutal"
|
||||||
ram:
|
ram:
|
||||||
description: >-
|
description: Override the amount of memory in MB to be used by CodeQL. By default, almost all the memory of the machine is used.
|
||||||
The amount of memory in MB that can be used by CodeQL for database finalization and query execution.
|
|
||||||
By default, this action will use the same amount of memory as previously set in the "init" action.
|
|
||||||
If the "init" action also does not have an explicit "ram" input, this action will use most of the
|
|
||||||
memory available in the system (which for GitHub-hosted runners is 6GB for Linux, 5.5GB for Windows,
|
|
||||||
and 13GB for macOS).
|
|
||||||
required: false
|
required: false
|
||||||
add-snippets:
|
add-snippets:
|
||||||
description: Specify whether or not to add code snippets to the output sarif file.
|
description: Specify whether or not to add code snippets to the output sarif file.
|
||||||
@@ -34,12 +29,7 @@ inputs:
|
|||||||
required: false
|
required: false
|
||||||
default: "false"
|
default: "false"
|
||||||
threads:
|
threads:
|
||||||
description: >-
|
description: The number of threads to be used by CodeQL.
|
||||||
The number of threads that can be used by CodeQL for database finalization and query execution.
|
|
||||||
By default, this action will use the same number of threads as previously set in the "init" action.
|
|
||||||
If the "init" action also does not have an explicit "threads" input, this action will use all the
|
|
||||||
hardware threads available in the system (which for GitHub-hosted runners is 2 for Linux and Windows
|
|
||||||
and 3 for macOS).
|
|
||||||
required: false
|
required: false
|
||||||
checkout_path:
|
checkout_path:
|
||||||
description: "The path at which the analyzed repository was checked out. Used to relativize any absolute paths in the uploaded SARIF file."
|
description: "The path at which the analyzed repository was checked out. Used to relativize any absolute paths in the uploaded SARIF file."
|
||||||
@@ -52,10 +42,6 @@ inputs:
|
|||||||
description: Whether to upload the resulting CodeQL database
|
description: Whether to upload the resulting CodeQL database
|
||||||
required: false
|
required: false
|
||||||
default: "true"
|
default: "true"
|
||||||
wait-for-processing:
|
|
||||||
description: If true, the Action will wait for the uploaded SARIF to be processed before completing.
|
|
||||||
required: true
|
|
||||||
default: "true"
|
|
||||||
token:
|
token:
|
||||||
default: ${{ github.token }}
|
default: ${{ github.token }}
|
||||||
matrix:
|
matrix:
|
||||||
@@ -64,5 +50,5 @@ outputs:
|
|||||||
db-locations:
|
db-locations:
|
||||||
description: A map from language to absolute path for each database created by CodeQL.
|
description: A map from language to absolute path for each database created by CodeQL.
|
||||||
runs:
|
runs:
|
||||||
using: "node12"
|
using: 'node12'
|
||||||
main: "../lib/analyze-action.js"
|
main: '../lib/analyze-action.js'
|
||||||
|
|||||||
@@ -41,24 +41,6 @@ inputs:
|
|||||||
source-root:
|
source-root:
|
||||||
description: Path of the root source code directory, relative to $GITHUB_WORKSPACE.
|
description: Path of the root source code directory, relative to $GITHUB_WORKSPACE.
|
||||||
required: false
|
required: false
|
||||||
ram:
|
|
||||||
description: >-
|
|
||||||
The amount of memory in MB that can be used by CodeQL extractors.
|
|
||||||
By default, CodeQL extractors will use most of the memory available in the system
|
|
||||||
(which for GitHub-hosted runners is 6GB for Linux, 5.5GB for Windows, and 13GB for macOS).
|
|
||||||
This input also sets the amount of memory that can later be used by the "analyze" action.
|
|
||||||
required: false
|
|
||||||
threads:
|
|
||||||
description: >-
|
|
||||||
The number of threads that can be used by CodeQL extractors.
|
|
||||||
By default, CodeQL extractors will use all the hardware threads available in the system
|
|
||||||
(which for GitHub-hosted runners is 2 for Linux and Windows and 3 for macOS).
|
|
||||||
This input also sets the number of threads that can later be used by the "analyze" action.
|
|
||||||
required: false
|
|
||||||
debug:
|
|
||||||
description: Enable debugging mode. This will result in more output being produced which may be useful when debugging certain issues.
|
|
||||||
required: false
|
|
||||||
default: 'false'
|
|
||||||
outputs:
|
outputs:
|
||||||
codeql-path:
|
codeql-path:
|
||||||
description: The path of the CodeQL binary used for analysis
|
description: The path of the CodeQL binary used for analysis
|
||||||
|
|||||||
Generated
+1
-6
@@ -19,7 +19,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.sanitizeArifactName = exports.isAnalyzingDefaultBranch = exports.getRelativeScriptPath = exports.isRunningLocalAction = exports.sendStatusReport = exports.createStatusReportBase = exports.getRef = exports.computeAutomationID = exports.getAutomationID = exports.getAnalysisKey = exports.getWorkflowRunID = exports.getWorkflow = exports.formatWorkflowCause = exports.formatWorkflowErrors = exports.validateWorkflow = exports.getWorkflowErrors = exports.WorkflowErrors = exports.patternIsSuperset = exports.getCommitOid = exports.getToolCacheDirectory = exports.getTemporaryDirectory = exports.getOptionalInput = exports.getRequiredInput = void 0;
|
exports.isAnalyzingDefaultBranch = exports.getRelativeScriptPath = exports.isRunningLocalAction = exports.sendStatusReport = exports.createStatusReportBase = exports.getRef = exports.computeAutomationID = exports.getAutomationID = exports.getAnalysisKey = exports.getWorkflowRunID = exports.getWorkflow = exports.formatWorkflowCause = exports.formatWorkflowErrors = exports.validateWorkflow = exports.getWorkflowErrors = exports.WorkflowErrors = exports.patternIsSuperset = exports.getCommitOid = exports.getToolCacheDirectory = exports.getTemporaryDirectory = exports.getOptionalInput = exports.getRequiredInput = void 0;
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const core = __importStar(require("@actions/core"));
|
const core = __importStar(require("@actions/core"));
|
||||||
@@ -98,7 +98,6 @@ const getCommitOid = async function (ref = "HEAD") {
|
|||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
core.info(`Failed to call git to get current commit. Continuing with data from environment: ${e}`);
|
core.info(`Failed to call git to get current commit. Continuing with data from environment: ${e}`);
|
||||||
core.info(e.stack || "NO STACK");
|
|
||||||
return (0, util_1.getRequiredEnvParam)("GITHUB_SHA");
|
return (0, util_1.getRequiredEnvParam)("GITHUB_SHA");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -575,8 +574,4 @@ async function isAnalyzingDefaultBranch() {
|
|||||||
return currentRef === defaultBranch;
|
return currentRef === defaultBranch;
|
||||||
}
|
}
|
||||||
exports.isAnalyzingDefaultBranch = isAnalyzingDefaultBranch;
|
exports.isAnalyzingDefaultBranch = isAnalyzingDefaultBranch;
|
||||||
function sanitizeArifactName(name) {
|
|
||||||
return name.replace(/[^a-zA-Z0-9_\\-]+/g, "");
|
|
||||||
}
|
|
||||||
exports.sanitizeArifactName = sanitizeArifactName;
|
|
||||||
//# sourceMappingURL=actions-util.js.map
|
//# sourceMappingURL=actions-util.js.map
|
||||||
File diff suppressed because one or more lines are too long
Generated
-6
@@ -440,10 +440,4 @@ on: ["push"]
|
|||||||
t.deepEqual(await actionsutil.isAnalyzingDefaultBranch(), false);
|
t.deepEqual(await actionsutil.isAnalyzingDefaultBranch(), false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("sanitizeArifactName", (t) => {
|
|
||||||
t.deepEqual(actionsutil.sanitizeArifactName("hello-world_"), "hello-world_");
|
|
||||||
t.deepEqual(actionsutil.sanitizeArifactName("hello`world`"), "helloworld");
|
|
||||||
t.deepEqual(actionsutil.sanitizeArifactName("hello===123"), "hello123");
|
|
||||||
t.deepEqual(actionsutil.sanitizeArifactName("*m)a&n^y%i££n+v!a:l[i]d"), "manyinvalid");
|
|
||||||
});
|
|
||||||
//# sourceMappingURL=actions-util.test.js.map
|
//# sourceMappingURL=actions-util.test.js.map
|
||||||
File diff suppressed because one or more lines are too long
Generated
-3
@@ -42,7 +42,6 @@ const util = __importStar(require("./util"));
|
|||||||
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
||||||
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
||||||
packs: {},
|
packs: {},
|
||||||
debugMode: false,
|
|
||||||
};
|
};
|
||||||
analysisPaths.includeAndExcludeAnalysisPaths(config);
|
analysisPaths.includeAndExcludeAnalysisPaths(config);
|
||||||
t.is(process.env["LGTM_INDEX_INCLUDE"], undefined);
|
t.is(process.env["LGTM_INDEX_INCLUDE"], undefined);
|
||||||
@@ -64,7 +63,6 @@ const util = __importStar(require("./util"));
|
|||||||
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
||||||
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
||||||
packs: {},
|
packs: {},
|
||||||
debugMode: false,
|
|
||||||
};
|
};
|
||||||
analysisPaths.includeAndExcludeAnalysisPaths(config);
|
analysisPaths.includeAndExcludeAnalysisPaths(config);
|
||||||
t.is(process.env["LGTM_INDEX_INCLUDE"], "path1\npath2");
|
t.is(process.env["LGTM_INDEX_INCLUDE"], "path1\npath2");
|
||||||
@@ -87,7 +85,6 @@ const util = __importStar(require("./util"));
|
|||||||
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
||||||
dbLocation: path.resolve(tempDir, "codeql_databases"),
|
dbLocation: path.resolve(tempDir, "codeql_databases"),
|
||||||
packs: {},
|
packs: {},
|
||||||
debugMode: false,
|
|
||||||
};
|
};
|
||||||
analysisPaths.includeAndExcludeAnalysisPaths(config);
|
analysisPaths.includeAndExcludeAnalysisPaths(config);
|
||||||
t.is(process.env["LGTM_INDEX_INCLUDE"], undefined);
|
t.is(process.env["LGTM_INDEX_INCLUDE"], undefined);
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"analysis-paths.test.js","sourceRoot":"","sources":["../src/analysis-paths.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAE7B,8CAAuB;AAEvB,gEAAkD;AAClD,mDAA6C;AAC7C,6CAA+B;AAE/B,IAAA,0BAAU,EAAC,aAAI,CAAC,CAAC;AAEjB,IAAA,aAAI,EAAC,YAAY,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAC7B,OAAO,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QAC5C,MAAM,MAAM,GAAG;YACb,SAAS,EAAE,EAAE;YACb,OAAO,EAAE,EAAE;YACX,WAAW,EAAE,EAAE;YACf,KAAK,EAAE,EAAE;YACT,iBAAiB,EAAE,EAAE;YACrB,OAAO,EAAE,MAAM;YACf,YAAY,EAAE,MAAM;YACpB,SAAS,EAAE,EAAE;YACb,aAAa,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,MAAM,EAAwB;YACxE,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,kBAAkB,CAAC;YACpD,KAAK,EAAE,EAAE;YACT,SAAS,EAAE,KAAK;SACjB,CAAC;QACF,aAAa,CAAC,8BAA8B,CAAC,MAAM,CAAC,CAAC;QACrD,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,oBAA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O,EAAE,kBAAkB,CAAC;YACrD,KAAK,EAAE,EAAE;SACV,CAAC;QACF,aAAa,CAAC,8BAA8B,CAAC,MAAM,CAAC,CAAC;QACrD,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,SAAS,CAAC,CAAC;QACnD,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,oBAAoB,CAAC,CAAC;QAC9D,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,SAAS,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
||||||
Generated
-77
@@ -1,77 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
||||||
__setModuleDefault(result, mod);
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const ava_1 = __importDefault(require("ava"));
|
|
||||||
const sinon = __importStar(require("sinon"));
|
|
||||||
const actionsUtil = __importStar(require("./actions-util"));
|
|
||||||
const analyze = __importStar(require("./analyze"));
|
|
||||||
const configUtils = __importStar(require("./config-utils"));
|
|
||||||
const testing_utils_1 = require("./testing-utils");
|
|
||||||
const util = __importStar(require("./util"));
|
|
||||||
(0, testing_utils_1.setupTests)(ava_1.default);
|
|
||||||
// This test needs to be in its own file so that ava would run it in its own
|
|
||||||
// nodejs process. The code being tested is in analyze-action.ts, which runs
|
|
||||||
// immediately on load. So the file needs to be loaded during part of the test,
|
|
||||||
// and that can happen only once per nodejs process. If multiple such tests are
|
|
||||||
// in the same test file, ava would run them in the same nodejs process, and all
|
|
||||||
// but the first test would fail.
|
|
||||||
(0, ava_1.default)("analyze action with RAM & threads from environment variables", async (t) => {
|
|
||||||
await util.withTmpDir(async (tmpDir) => {
|
|
||||||
process.env["GITHUB_SERVER_URL"] = "fake-server-url";
|
|
||||||
process.env["GITHUB_REPOSITORY"] = "fake/repository";
|
|
||||||
sinon
|
|
||||||
.stub(actionsUtil, "createStatusReportBase")
|
|
||||||
.resolves({});
|
|
||||||
sinon.stub(actionsUtil, "sendStatusReport").resolves(true);
|
|
||||||
sinon.stub(configUtils, "getConfig").resolves({
|
|
||||||
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
|
||||||
languages: [],
|
|
||||||
});
|
|
||||||
const requiredInputStub = sinon.stub(actionsUtil, "getRequiredInput");
|
|
||||||
requiredInputStub.withArgs("token").returns("fake-token");
|
|
||||||
requiredInputStub.withArgs("upload-database").returns("false");
|
|
||||||
const optionalInputStub = sinon.stub(actionsUtil, "getOptionalInput");
|
|
||||||
optionalInputStub.withArgs("cleanup-level").returns("none");
|
|
||||||
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
|
||||||
(0, testing_utils_1.mockFeatureFlagApiEndpoint)(200, {});
|
|
||||||
// When there are no action inputs for RAM and threads, the action uses
|
|
||||||
// environment variables (passed down from the init action) to set RAM and
|
|
||||||
// threads usage.
|
|
||||||
process.env["CODEQL_THREADS"] = "-1";
|
|
||||||
process.env["CODEQL_RAM"] = "4992";
|
|
||||||
const runFinalizeStub = sinon.stub(analyze, "runFinalize");
|
|
||||||
const runQueriesStub = sinon.stub(analyze, "runQueries");
|
|
||||||
const analyzeAction = require("./analyze-action");
|
|
||||||
// When analyze-action.ts loads, it runs an async function from the top
|
|
||||||
// level but does not wait for it to finish. To ensure that calls to
|
|
||||||
// runFinalize and runQueries are correctly captured by spies, we explicitly
|
|
||||||
// wait for the action promise to complete before starting verification.
|
|
||||||
await analyzeAction.runPromise;
|
|
||||||
t.deepEqual(runFinalizeStub.firstCall.args[1], "--threads=-1");
|
|
||||||
t.deepEqual(runFinalizeStub.firstCall.args[2], "--ram=4992");
|
|
||||||
t.deepEqual(runQueriesStub.firstCall.args[3], "--threads=-1");
|
|
||||||
t.deepEqual(runQueriesStub.firstCall.args[1], "--ram=4992");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
//# sourceMappingURL=analyze-action-env.test.js.map
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"analyze-action-env.test.js","sourceRoot":"","sources":["../src/analyze-action-env.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAuB;AACvB,6CAA+B;AAE/B,4DAA8C;AAC9C,mDAAqC;AACrC,4DAA8C;AAC9C,mDAIyB;AACzB,6CAA+B;AAE/B,IAAA,0BAAU,EAAC,aAAI,CAAC,CAAC;AAEjB,4EAA4E;AAC5E,4EAA4E;AAC5E,+EAA+E;AAC/E,+EAA+E;AAC/E,gFAAgF;AAChF,iCAAiC;AAEjC,IAAA,aAAI,EAAC,8DAA8D,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAC/E,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QACrC,OAAO,CAAC,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,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QAC3D,MAAM,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;QACzD,MAAM,aAAa,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;QAElD,uEAAuE;QACvE,oEAAoE;QACpE,4EAA4E;QAC5E,wEAAwE;QACxE,MAAM,aAAa,CAAC,UAAU,CAAC;QAE/B,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;QAC/D,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;QAC7D,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;QAC9D,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
||||||
Generated
-77
@@ -1,77 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
||||||
__setModuleDefault(result, mod);
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const ava_1 = __importDefault(require("ava"));
|
|
||||||
const sinon = __importStar(require("sinon"));
|
|
||||||
const actionsUtil = __importStar(require("./actions-util"));
|
|
||||||
const analyze = __importStar(require("./analyze"));
|
|
||||||
const configUtils = __importStar(require("./config-utils"));
|
|
||||||
const testing_utils_1 = require("./testing-utils");
|
|
||||||
const util = __importStar(require("./util"));
|
|
||||||
(0, testing_utils_1.setupTests)(ava_1.default);
|
|
||||||
// This test needs to be in its own file so that ava would run it in its own
|
|
||||||
// nodejs process. The code being tested is in analyze-action.ts, which runs
|
|
||||||
// immediately on load. So the file needs to be loaded during part of the test,
|
|
||||||
// and that can happen only once per nodejs process. If multiple such tests are
|
|
||||||
// in the same test file, ava would run them in the same nodejs process, and all
|
|
||||||
// but the first test would fail.
|
|
||||||
(0, ava_1.default)("analyze action with RAM & threads from action inputs", async (t) => {
|
|
||||||
await util.withTmpDir(async (tmpDir) => {
|
|
||||||
process.env["GITHUB_SERVER_URL"] = "fake-server-url";
|
|
||||||
process.env["GITHUB_REPOSITORY"] = "fake/repository";
|
|
||||||
sinon
|
|
||||||
.stub(actionsUtil, "createStatusReportBase")
|
|
||||||
.resolves({});
|
|
||||||
sinon.stub(actionsUtil, "sendStatusReport").resolves(true);
|
|
||||||
sinon.stub(configUtils, "getConfig").resolves({
|
|
||||||
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
|
||||||
languages: [],
|
|
||||||
});
|
|
||||||
const requiredInputStub = sinon.stub(actionsUtil, "getRequiredInput");
|
|
||||||
requiredInputStub.withArgs("token").returns("fake-token");
|
|
||||||
requiredInputStub.withArgs("upload-database").returns("false");
|
|
||||||
const optionalInputStub = sinon.stub(actionsUtil, "getOptionalInput");
|
|
||||||
optionalInputStub.withArgs("cleanup-level").returns("none");
|
|
||||||
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
|
||||||
(0, testing_utils_1.mockFeatureFlagApiEndpoint)(200, {});
|
|
||||||
process.env["CODEQL_THREADS"] = "1";
|
|
||||||
process.env["CODEQL_RAM"] = "4992";
|
|
||||||
// Action inputs have precedence over environment variables.
|
|
||||||
optionalInputStub.withArgs("threads").returns("-1");
|
|
||||||
optionalInputStub.withArgs("ram").returns("3012");
|
|
||||||
const runFinalizeStub = sinon.stub(analyze, "runFinalize");
|
|
||||||
const runQueriesStub = sinon.stub(analyze, "runQueries");
|
|
||||||
const analyzeAction = require("./analyze-action");
|
|
||||||
// When analyze-action.ts loads, it runs an async function from the top
|
|
||||||
// level but does not wait for it to finish. To ensure that calls to
|
|
||||||
// runFinalize and runQueries are correctly captured by spies, we explicitly
|
|
||||||
// wait for the action promise to complete before starting verification.
|
|
||||||
await analyzeAction.runPromise;
|
|
||||||
t.deepEqual(runFinalizeStub.firstCall.args[1], "--threads=-1");
|
|
||||||
t.deepEqual(runFinalizeStub.firstCall.args[2], "--ram=3012");
|
|
||||||
t.deepEqual(runQueriesStub.firstCall.args[3], "--threads=-1");
|
|
||||||
t.deepEqual(runQueriesStub.firstCall.args[1], "--ram=3012");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
//# sourceMappingURL=analyze-action-input.test.js.map
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"analyze-action-input.test.js","sourceRoot":"","sources":["../src/analyze-action-input.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAuB;AACvB,6CAA+B;AAE/B,4DAA8C;AAC9C,mDAAqC;AACrC,4DAA8C;AAC9C,mDA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__importStar) || function (mod) {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.runPromise = exports.sendStatusReport = void 0;
|
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const artifact = __importStar(require("@actions/artifact"));
|
|
||||||
const core = __importStar(require("@actions/core"));
|
const core = __importStar(require("@actions/core"));
|
||||||
const actionsUtil = __importStar(require("./actions-util"));
|
const actionsUtil = __importStar(require("./actions-util"));
|
||||||
const analyze_1 = require("./analyze");
|
const analyze_1 = require("./analyze");
|
||||||
const codeql_1 = require("./codeql");
|
const codeql_1 = require("./codeql");
|
||||||
const config_utils_1 = require("./config-utils");
|
const config_utils_1 = require("./config-utils");
|
||||||
const database_upload_1 = require("./database-upload");
|
const database_upload_1 = require("./database-upload");
|
||||||
const feature_flags_1 = require("./feature-flags");
|
|
||||||
const logging_1 = require("./logging");
|
const logging_1 = require("./logging");
|
||||||
const repository_1 = require("./repository");
|
const repository_1 = require("./repository");
|
||||||
const upload_lib = __importStar(require("./upload-lib"));
|
const upload_lib = __importStar(require("./upload-lib"));
|
||||||
const util = __importStar(require("./util"));
|
const util = __importStar(require("./util"));
|
||||||
const util_1 = require("./util");
|
|
||||||
// eslint-disable-next-line import/no-commonjs
|
// eslint-disable-next-line import/no-commonjs
|
||||||
const pkg = require("../package.json");
|
const pkg = require("../package.json");
|
||||||
async function sendStatusReport(startedAt, stats, error) {
|
async function sendStatusReport(startedAt, stats, error) {
|
||||||
@@ -48,10 +44,9 @@ async function sendStatusReport(startedAt, stats, error) {
|
|||||||
};
|
};
|
||||||
await actionsUtil.sendStatusReport(statusReport);
|
await actionsUtil.sendStatusReport(statusReport);
|
||||||
}
|
}
|
||||||
exports.sendStatusReport = sendStatusReport;
|
|
||||||
async function run() {
|
async function run() {
|
||||||
const startedAt = new Date();
|
const startedAt = new Date();
|
||||||
let uploadResult = undefined;
|
let uploadStats = undefined;
|
||||||
let runStats = undefined;
|
let runStats = undefined;
|
||||||
let config = undefined;
|
let config = undefined;
|
||||||
util.initializeEnvironment(util.Mode.actions, pkg.version);
|
util.initializeEnvironment(util.Mode.actions, pkg.version);
|
||||||
@@ -70,35 +65,11 @@ async function run() {
|
|||||||
url: util.getRequiredEnvParam("GITHUB_SERVER_URL"),
|
url: util.getRequiredEnvParam("GITHUB_SERVER_URL"),
|
||||||
};
|
};
|
||||||
const outputDir = actionsUtil.getRequiredInput("output");
|
const outputDir = actionsUtil.getRequiredInput("output");
|
||||||
const threads = util.getThreadsFlag(actionsUtil.getOptionalInput("threads") || process.env["CODEQL_THREADS"], logger);
|
const threads = util.getThreadsFlag(actionsUtil.getOptionalInput("threads"), logger);
|
||||||
const memory = util.getMemoryFlag(actionsUtil.getOptionalInput("ram") || process.env["CODEQL_RAM"]);
|
const memory = util.getMemoryFlag(actionsUtil.getOptionalInput("ram"));
|
||||||
const repositoryNwo = (0, repository_1.parseRepositoryNwo)(util.getRequiredEnvParam("GITHUB_REPOSITORY"));
|
|
||||||
const featureFlags = new feature_flags_1.GitHubFeatureFlags(config.gitHubVersion, apiDetails, repositoryNwo, logger);
|
|
||||||
void featureFlags.preloadFeatureFlags();
|
|
||||||
await (0, analyze_1.runFinalize)(outputDir, threads, memory, config, logger);
|
await (0, analyze_1.runFinalize)(outputDir, threads, memory, config, logger);
|
||||||
if (actionsUtil.getRequiredInput("skip-queries") !== "true") {
|
if (actionsUtil.getRequiredInput("skip-queries") !== "true") {
|
||||||
runStats = await (0, analyze_1.runQueries)(outputDir, memory, util.getAddSnippetsFlag(actionsUtil.getRequiredInput("add-snippets")), threads, actionsUtil.getOptionalInput("category"), config, logger);
|
runStats = await (0, analyze_1.runQueries)(outputDir, memory, util.getAddSnippetsFlag(actionsUtil.getRequiredInput("add-snippets")), threads, actionsUtil.getOptionalInput("category"), config, logger);
|
||||||
if (config.debugMode) {
|
|
||||||
// Upload the SARIF files as an Actions artifact for debugging
|
|
||||||
await uploadDebugArtifacts(config.languages.map((lang) => path.resolve(outputDir, `${lang}.sarif`)), outputDir);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
|
||||||
if (config.debugMode) {
|
|
||||||
// Upload the logs as an Actions artifact for debugging
|
|
||||||
const toUpload = [];
|
|
||||||
for (const language of config.languages) {
|
|
||||||
toUpload.push(...listFolder(path.resolve(util.getCodeQLDatabasePath(config, language), "log")));
|
|
||||||
}
|
|
||||||
if (await (0, util_1.codeQlVersionAbove)(codeql, codeql_1.CODEQL_VERSION_NEW_TRACING)) {
|
|
||||||
// Multilanguage tracing: there are additional logs in the root of the cluster
|
|
||||||
toUpload.push(...listFolder(path.resolve(config.dbLocation, "log")));
|
|
||||||
}
|
|
||||||
await uploadDebugArtifacts(toUpload, config.dbLocation);
|
|
||||||
if (!(await (0, util_1.codeQlVersionAbove)(codeql, codeql_1.CODEQL_VERSION_NEW_TRACING))) {
|
|
||||||
// Before multi-language tracing, we wrote a compound-build-tracer.log in the temp dir
|
|
||||||
await uploadDebugArtifacts([path.resolve(config.tempDir, "compound-build-tracer.log")], config.tempDir);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (actionsUtil.getOptionalInput("cleanup-level") !== "none") {
|
if (actionsUtil.getOptionalInput("cleanup-level") !== "none") {
|
||||||
await (0, analyze_1.runCleanup)(config, actionsUtil.getOptionalInput("cleanup-level") || "brutal", logger);
|
await (0, analyze_1.runCleanup)(config, actionsUtil.getOptionalInput("cleanup-level") || "brutal", logger);
|
||||||
@@ -109,17 +80,13 @@ async function run() {
|
|||||||
}
|
}
|
||||||
core.setOutput("db-locations", dbLocations);
|
core.setOutput("db-locations", dbLocations);
|
||||||
if (runStats && actionsUtil.getRequiredInput("upload") === "true") {
|
if (runStats && actionsUtil.getRequiredInput("upload") === "true") {
|
||||||
uploadResult = await upload_lib.uploadFromActions(outputDir, config.gitHubVersion, apiDetails, logger);
|
uploadStats = await upload_lib.uploadFromActions(outputDir, config.gitHubVersion, apiDetails, logger);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
logger.info("Not uploading results");
|
logger.info("Not uploading results");
|
||||||
}
|
}
|
||||||
// Possibly upload the database bundles for remote queries
|
const repositoryNwo = (0, repository_1.parseRepositoryNwo)(util.getRequiredEnvParam("GITHUB_REPOSITORY"));
|
||||||
await (0, database_upload_1.uploadDatabases)(repositoryNwo, config, featureFlags, apiDetails, logger);
|
await (0, database_upload_1.uploadDatabases)(repositoryNwo, config, apiDetails, logger);
|
||||||
if (uploadResult !== undefined &&
|
|
||||||
actionsUtil.getRequiredInput("wait-for-processing") === "true") {
|
|
||||||
await upload_lib.waitForProcessing((0, repository_1.parseRepositoryNwo)(util.getRequiredEnvParam("GITHUB_REPOSITORY")), uploadResult.sarifID, apiDetails, (0, logging_1.getActionsLogger)());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (origError) {
|
catch (origError) {
|
||||||
const error = origError instanceof Error ? origError : new Error(String(origError));
|
const error = origError instanceof Error ? origError : new Error(String(origError));
|
||||||
@@ -135,19 +102,6 @@ async function run() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if (config !== undefined && config.debugMode) {
|
|
||||||
try {
|
|
||||||
// Upload the database bundles as an Actions artifact for debugging
|
|
||||||
const toUpload = [];
|
|
||||||
for (const language of config.languages) {
|
|
||||||
toUpload.push(await (0, util_1.bundleDb)(config, language, await (0, codeql_1.getCodeQL)(config.codeQLCmd)));
|
|
||||||
}
|
|
||||||
await uploadDebugArtifacts(toUpload, config.dbLocation);
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
console.log(`Failed to upload database debug bundles: ${error}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (core.isDebug() && config !== undefined) {
|
if (core.isDebug() && config !== undefined) {
|
||||||
core.info("Debug mode is on. Printing CodeQL debug logs...");
|
core.info("Debug mode is on. Printing CodeQL debug logs...");
|
||||||
for (const language of config.languages) {
|
for (const language of config.languages) {
|
||||||
@@ -170,11 +124,8 @@ async function run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (runStats && uploadResult) {
|
if (runStats && uploadStats) {
|
||||||
await sendStatusReport(startedAt, {
|
await sendStatusReport(startedAt, { ...runStats, ...uploadStats });
|
||||||
...runStats,
|
|
||||||
...uploadResult.statusReport,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
else if (runStats) {
|
else if (runStats) {
|
||||||
await sendStatusReport(startedAt, { ...runStats });
|
await sendStatusReport(startedAt, { ...runStats });
|
||||||
@@ -183,32 +134,9 @@ async function run() {
|
|||||||
await sendStatusReport(startedAt, undefined);
|
await sendStatusReport(startedAt, undefined);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async function uploadDebugArtifacts(toUpload, rootDir) {
|
|
||||||
let suffix = "";
|
|
||||||
const matrix = actionsUtil.getRequiredInput("matrix");
|
|
||||||
if (matrix !== undefined && matrix !== "null") {
|
|
||||||
for (const entry of Object.entries(JSON.parse(matrix)).sort())
|
|
||||||
suffix += `-${entry[1]}`;
|
|
||||||
}
|
|
||||||
await artifact.create().uploadArtifact(actionsUtil.sanitizeArifactName(`${util_1.DEBUG_ARTIFACT_NAME}${suffix}`), toUpload.map((file) => path.normalize(file)), path.normalize(rootDir));
|
|
||||||
}
|
|
||||||
function listFolder(dir) {
|
|
||||||
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
||||||
const files = [];
|
|
||||||
for (const entry of entries) {
|
|
||||||
if (entry.isFile()) {
|
|
||||||
files.push(path.resolve(dir, entry.name));
|
|
||||||
}
|
|
||||||
else if (entry.isDirectory()) {
|
|
||||||
files.push(...listFolder(path.resolve(dir, entry.name)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return files;
|
|
||||||
}
|
|
||||||
exports.runPromise = run();
|
|
||||||
async function runWrapper() {
|
async function runWrapper() {
|
||||||
try {
|
try {
|
||||||
await exports.runPromise;
|
await run();
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
core.setFailed(`analyze action failed: ${error}`);
|
core.setFailed(`analyze action failed: ${error}`);
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Generated
-1
@@ -125,7 +125,6 @@ const util = __importStar(require("./util"));
|
|||||||
},
|
},
|
||||||
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
||||||
packs,
|
packs,
|
||||||
debugMode: false,
|
|
||||||
};
|
};
|
||||||
fs.mkdirSync(util.getCodeQLDatabasePath(config, language), {
|
fs.mkdirSync(util.getCodeQLDatabasePath(config, language), {
|
||||||
recursive: true,
|
recursive: true,
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
|
|||||||
{ "maximumVersion": "3.4", "minimumVersion": "3.0" }
|
{ "maximumVersion": "3.3", "minimumVersion": "3.0" }
|
||||||
|
|||||||
Generated
+15
-22
@@ -22,7 +22,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.getExtraOptions = exports.getCodeQLForTesting = exports.getCachedCodeQL = exports.setCodeQL = exports.getCodeQL = exports.convertToSemVer = exports.getCodeQLURLVersion = exports.setupCodeQL = exports.getCodeQLActionRepository = exports.CODEQL_VERSION_NEW_TRACING = exports.CODEQL_VERSION_COUNTS_LINES = exports.CommandInvocationError = void 0;
|
exports.getExtraOptions = exports.getCachedCodeQL = exports.setCodeQL = exports.getCodeQL = exports.convertToSemVer = exports.getCodeQLURLVersion = exports.setupCodeQL = exports.getCodeQLActionRepository = exports.CODEQL_VERSION_NEW_TRACING = exports.CODEQL_VERSION_COUNTS_LINES = exports.CommandInvocationError = void 0;
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
|
const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
|
||||||
@@ -37,7 +37,6 @@ const languages_1 = require("./languages");
|
|||||||
const toolcache = __importStar(require("./toolcache"));
|
const toolcache = __importStar(require("./toolcache"));
|
||||||
const toolrunner_error_catcher_1 = require("./toolrunner-error-catcher");
|
const toolrunner_error_catcher_1 = require("./toolrunner-error-catcher");
|
||||||
const util = __importStar(require("./util"));
|
const util = __importStar(require("./util"));
|
||||||
const util_1 = require("./util");
|
|
||||||
class CommandInvocationError extends Error {
|
class CommandInvocationError extends Error {
|
||||||
constructor(cmd, args, exitCode, error) {
|
constructor(cmd, args, exitCode, error) {
|
||||||
super(`Failure invoking ${cmd} with arguments ${args}.\n
|
super(`Failure invoking ${cmd} with arguments ${args}.\n
|
||||||
@@ -73,17 +72,22 @@ const CODEQL_VERSION_METRICS = "2.5.5";
|
|||||||
const CODEQL_VERSION_GROUP_RULES = "2.5.5";
|
const CODEQL_VERSION_GROUP_RULES = "2.5.5";
|
||||||
const CODEQL_VERSION_SARIF_GROUP = "2.5.3";
|
const CODEQL_VERSION_SARIF_GROUP = "2.5.3";
|
||||||
exports.CODEQL_VERSION_COUNTS_LINES = "2.6.2";
|
exports.CODEQL_VERSION_COUNTS_LINES = "2.6.2";
|
||||||
const CODEQL_VERSION_CUSTOM_QUERY_HELP = "2.7.1";
|
|
||||||
/**
|
/**
|
||||||
* This variable controls using the new style of tracing from the CodeQL
|
* Version above which we use the CLI's indirect build tracing and
|
||||||
* CLI. In particular, with versions above this we will use both indirect
|
* multi-language tracing features.
|
||||||
* tracing, and multi-language tracing together with database clusters.
|
|
||||||
*
|
*
|
||||||
* Note that there were bugs in both of these features that were fixed in
|
* There are currently three blockers on the CLI's side to enabling this:
|
||||||
* release 2.7.0 of the CodeQL CLI, therefore this flag is only enabled for
|
* (1) The logs directory should be created for a DB cluster, as some
|
||||||
* versions above that.
|
* autobuilders expect it to be present.
|
||||||
|
* (2) The SEMMLE_PRELOAD_libtrace{32,64}? env variables need to be set.
|
||||||
|
* (3) The .environment and .win32env files need to be created next to
|
||||||
|
* the DB spec.
|
||||||
|
*
|
||||||
|
* Once _all_ of these are fixed, we can enable this by setting the
|
||||||
|
* version flag below to the earliest version of the CLI that resolved
|
||||||
|
* the above issues.
|
||||||
*/
|
*/
|
||||||
exports.CODEQL_VERSION_NEW_TRACING = "2.7.0";
|
exports.CODEQL_VERSION_NEW_TRACING = "99.99.99";
|
||||||
function getCodeQLBundleName() {
|
function getCodeQLBundleName() {
|
||||||
let platform;
|
let platform;
|
||||||
if (process.platform === "win32") {
|
if (process.platform === "win32") {
|
||||||
@@ -216,7 +220,7 @@ async function setupCodeQL(codeqlURL, apiDetails, tempDir, toolCacheDir, variant
|
|||||||
// specified explicitly (in which case we always honor it).
|
// specified explicitly (in which case we always honor it).
|
||||||
if (!codeqlFolder && !codeqlURL && !forceLatest) {
|
if (!codeqlFolder && !codeqlURL && !forceLatest) {
|
||||||
const codeqlVersions = toolcache.findAllVersions("CodeQL", toolCacheDir, logger);
|
const codeqlVersions = toolcache.findAllVersions("CodeQL", toolCacheDir, logger);
|
||||||
if (codeqlVersions.length === 1 && (0, util_1.isGoodVersion)(codeqlVersions[0])) {
|
if (codeqlVersions.length === 1) {
|
||||||
const tmpCodeqlFolder = toolcache.find("CodeQL", codeqlVersions[0], toolCacheDir, logger);
|
const tmpCodeqlFolder = toolcache.find("CodeQL", codeqlVersions[0], toolCacheDir, logger);
|
||||||
if (fs.existsSync(path.join(tmpCodeqlFolder, "pinned-version"))) {
|
if (fs.existsSync(path.join(tmpCodeqlFolder, "pinned-version"))) {
|
||||||
logger.debug(`CodeQL in cache overriding the default ${CODEQL_BUNDLE_VERSION}`);
|
logger.debug(`CodeQL in cache overriding the default ${CODEQL_BUNDLE_VERSION}`);
|
||||||
@@ -354,15 +358,6 @@ function getCachedCodeQL() {
|
|||||||
return cachedCodeQL;
|
return cachedCodeQL;
|
||||||
}
|
}
|
||||||
exports.getCachedCodeQL = getCachedCodeQL;
|
exports.getCachedCodeQL = getCachedCodeQL;
|
||||||
/**
|
|
||||||
* Get a real, newly created CodeQL instance for testing. The instance refers to
|
|
||||||
* a non-existent placeholder codeql command, so tests that use this function
|
|
||||||
* should also stub the toolrunner.ToolRunner constructor.
|
|
||||||
*/
|
|
||||||
async function getCodeQLForTesting() {
|
|
||||||
return getCodeQLForCmd("codeql-for-testing", false);
|
|
||||||
}
|
|
||||||
exports.getCodeQLForTesting = getCodeQLForTesting;
|
|
||||||
async function getCodeQLForCmd(cmd, checkVersion) {
|
async function getCodeQLForCmd(cmd, checkVersion) {
|
||||||
let cachedVersion = undefined;
|
let cachedVersion = undefined;
|
||||||
const codeql = {
|
const codeql = {
|
||||||
@@ -573,8 +568,6 @@ async function getCodeQLForCmd(cmd, checkVersion) {
|
|||||||
codeqlArgs.push("--print-metrics-summary");
|
codeqlArgs.push("--print-metrics-summary");
|
||||||
if (await util.codeQlVersionAbove(this, CODEQL_VERSION_GROUP_RULES))
|
if (await util.codeQlVersionAbove(this, CODEQL_VERSION_GROUP_RULES))
|
||||||
codeqlArgs.push("--sarif-group-rules-by-pack");
|
codeqlArgs.push("--sarif-group-rules-by-pack");
|
||||||
if (await util.codeQlVersionAbove(this, CODEQL_VERSION_CUSTOM_QUERY_HELP))
|
|
||||||
codeqlArgs.push("--sarif-add-query-help");
|
|
||||||
if (automationDetailsId !== undefined &&
|
if (automationDetailsId !== undefined &&
|
||||||
(await util.codeQlVersionAbove(this, CODEQL_VERSION_SARIF_GROUP))) {
|
(await util.codeQlVersionAbove(this, CODEQL_VERSION_SARIF_GROUP))) {
|
||||||
codeqlArgs.push("--sarif-category", automationDetailsId);
|
codeqlArgs.push("--sarif-category", automationDetailsId);
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
Generated
-23
@@ -23,11 +23,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
|
|
||||||
const toolcache = __importStar(require("@actions/tool-cache"));
|
const toolcache = __importStar(require("@actions/tool-cache"));
|
||||||
const ava_1 = __importDefault(require("ava"));
|
const ava_1 = __importDefault(require("ava"));
|
||||||
const nock_1 = __importDefault(require("nock"));
|
const nock_1 = __importDefault(require("nock"));
|
||||||
const sinon = __importStar(require("sinon"));
|
|
||||||
const codeql = __importStar(require("./codeql"));
|
const codeql = __importStar(require("./codeql"));
|
||||||
const defaults = __importStar(require("./defaults.json"));
|
const defaults = __importStar(require("./defaults.json"));
|
||||||
const logging_1 = require("./logging");
|
const logging_1 = require("./logging");
|
||||||
@@ -219,25 +217,4 @@ ava_1.default.beforeEach(() => {
|
|||||||
const repoEnv = codeql.getCodeQLActionRepository(logger);
|
const repoEnv = codeql.getCodeQLActionRepository(logger);
|
||||||
t.deepEqual(repoEnv, "xxx/yyy");
|
t.deepEqual(repoEnv, "xxx/yyy");
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("databaseInterpretResults() does not set --sarif-add-query-help for 2.7.0", async (t) => {
|
|
||||||
const runnerConstructorStub = stubToolRunnerConstructor();
|
|
||||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
|
||||||
sinon.stub(codeqlObject, "getVersion").resolves("2.7.0");
|
|
||||||
await codeqlObject.databaseInterpretResults("", [], "", "", "", "");
|
|
||||||
t.false(runnerConstructorStub.firstCall.args[1].includes("--sarif-add-query-help"), "--sarif-add-query-help should be absent, but it is present");
|
|
||||||
});
|
|
||||||
(0, ava_1.default)("databaseInterpretResults() sets --sarif-add-query-help for 2.7.1", async (t) => {
|
|
||||||
const runnerConstructorStub = stubToolRunnerConstructor();
|
|
||||||
const codeqlObject = await codeql.getCodeQLForTesting();
|
|
||||||
sinon.stub(codeqlObject, "getVersion").resolves("2.7.1");
|
|
||||||
await codeqlObject.databaseInterpretResults("", [], "", "", "", "");
|
|
||||||
t.true(runnerConstructorStub.firstCall.args[1].includes("--sarif-add-query-help"), "--sarif-add-query-help should be present, but it is absent");
|
|
||||||
});
|
|
||||||
function stubToolRunnerConstructor() {
|
|
||||||
const runnerObjectStub = sinon.createStubInstance(toolrunner.ToolRunner);
|
|
||||||
runnerObjectStub.exec.resolves(0);
|
|
||||||
const runnerConstructorStub = sinon.stub(toolrunner, "ToolRunner");
|
|
||||||
runnerConstructorStub.returns(runnerObjectStub);
|
|
||||||
return runnerConstructorStub;
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=codeql.test.js.map
|
//# sourceMappingURL=codeql.test.js.map
|
||||||
File diff suppressed because one or more lines are too long
Generated
+5
-7
@@ -425,7 +425,7 @@ function shouldAddConfigFileQueries(queriesInput) {
|
|||||||
/**
|
/**
|
||||||
* Get the default config for when the user has not supplied one.
|
* Get the default config for when the user has not supplied one.
|
||||||
*/
|
*/
|
||||||
async function getDefaultConfig(languagesInput, queriesInput, packsInput, dbLocation, debugMode, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, logger) {
|
async function getDefaultConfig(languagesInput, queriesInput, packsInput, dbLocation, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, logger) {
|
||||||
var _a;
|
var _a;
|
||||||
const languages = await getLanguages(codeQL, languagesInput, repository, apiDetails, logger);
|
const languages = await getLanguages(codeQL, languagesInput, repository, apiDetails, logger);
|
||||||
const queries = {};
|
const queries = {};
|
||||||
@@ -452,14 +452,13 @@ async function getDefaultConfig(languagesInput, queriesInput, packsInput, dbLoca
|
|||||||
codeQLCmd: codeQL.getPath(),
|
codeQLCmd: codeQL.getPath(),
|
||||||
gitHubVersion,
|
gitHubVersion,
|
||||||
dbLocation: dbLocationOrDefault(dbLocation, tempDir),
|
dbLocation: dbLocationOrDefault(dbLocation, tempDir),
|
||||||
debugMode,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
exports.getDefaultConfig = getDefaultConfig;
|
exports.getDefaultConfig = getDefaultConfig;
|
||||||
/**
|
/**
|
||||||
* Load the config from the given file.
|
* Load the config from the given file.
|
||||||
*/
|
*/
|
||||||
async function loadConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, debugMode, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, logger) {
|
async function loadConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, logger) {
|
||||||
var _a;
|
var _a;
|
||||||
let parsedYAML;
|
let parsedYAML;
|
||||||
if (isLocal(configFile)) {
|
if (isLocal(configFile)) {
|
||||||
@@ -556,7 +555,6 @@ async function loadConfig(languagesInput, queriesInput, packsInput, configFile,
|
|||||||
codeQLCmd: codeQL.getPath(),
|
codeQLCmd: codeQL.getPath(),
|
||||||
gitHubVersion,
|
gitHubVersion,
|
||||||
dbLocation: dbLocationOrDefault(dbLocation, tempDir),
|
dbLocation: dbLocationOrDefault(dbLocation, tempDir),
|
||||||
debugMode,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -682,16 +680,16 @@ function dbLocationOrDefault(dbLocation, tempDir) {
|
|||||||
* This will parse the config from the user input if present, or generate
|
* This will parse the config from the user input if present, or generate
|
||||||
* a default config. The parsed config is then stored to a known location.
|
* a default config. The parsed config is then stored to a known location.
|
||||||
*/
|
*/
|
||||||
async function initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, debugMode, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, logger) {
|
async function initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, logger) {
|
||||||
var _a, _b, _c;
|
var _a, _b, _c;
|
||||||
let config;
|
let config;
|
||||||
// If no config file was provided create an empty one
|
// If no config file was provided create an empty one
|
||||||
if (!configFile) {
|
if (!configFile) {
|
||||||
logger.debug("No configuration file was provided");
|
logger.debug("No configuration file was provided");
|
||||||
config = await getDefaultConfig(languagesInput, queriesInput, packsInput, dbLocation, debugMode, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, logger);
|
config = await getDefaultConfig(languagesInput, queriesInput, packsInput, dbLocation, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, logger);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
config = await loadConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, debugMode, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, logger);
|
config = await loadConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, logger);
|
||||||
}
|
}
|
||||||
// The list of queries should not be empty for any language. If it is then
|
// The list of queries should not be empty for any language. If it is then
|
||||||
// it is a user configuration error.
|
// it is a user configuration error.
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Generated
+22
-23
@@ -88,8 +88,8 @@ function mockListLanguages(languages) {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const config = await configUtils.initConfig(languages, undefined, undefined, undefined, undefined, false, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logger);
|
const config = await configUtils.initConfig(languages, undefined, undefined, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logger);
|
||||||
t.deepEqual(config, await configUtils.getDefaultConfig(languages, undefined, undefined, undefined, false, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logger));
|
t.deepEqual(config, await configUtils.getDefaultConfig(languages, undefined, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logger));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("loading config saves config", async (t) => {
|
(0, ava_1.default)("loading config saves config", async (t) => {
|
||||||
@@ -111,7 +111,7 @@ function mockListLanguages(languages) {
|
|||||||
t.false(fs.existsSync(configUtils.getPathToParsedConfigFile(tmpDir)));
|
t.false(fs.existsSync(configUtils.getPathToParsedConfigFile(tmpDir)));
|
||||||
// Sanity check that getConfig returns undefined before we have called initConfig
|
// Sanity check that getConfig returns undefined before we have called initConfig
|
||||||
t.deepEqual(await configUtils.getConfig(tmpDir, logger), undefined);
|
t.deepEqual(await configUtils.getConfig(tmpDir, logger), undefined);
|
||||||
const config1 = await configUtils.initConfig("javascript,python", undefined, undefined, undefined, undefined, false, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logger);
|
const config1 = await configUtils.initConfig("javascript,python", undefined, undefined, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logger);
|
||||||
// The saved config file should now exist
|
// The saved config file should now exist
|
||||||
t.true(fs.existsSync(configUtils.getPathToParsedConfigFile(tmpDir)));
|
t.true(fs.existsSync(configUtils.getPathToParsedConfigFile(tmpDir)));
|
||||||
// And that same newly-initialised config should now be returned by getConfig
|
// And that same newly-initialised config should now be returned by getConfig
|
||||||
@@ -122,7 +122,7 @@ function mockListLanguages(languages) {
|
|||||||
(0, ava_1.default)("load input outside of workspace", async (t) => {
|
(0, ava_1.default)("load input outside of workspace", async (t) => {
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(undefined, undefined, undefined, "../input", undefined, false, { owner: "github", repo: "example " }, tmpDir, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
await configUtils.initConfig(undefined, undefined, undefined, "../input", undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -135,7 +135,7 @@ function mockListLanguages(languages) {
|
|||||||
// no filename given, just a repo
|
// no filename given, just a repo
|
||||||
const configFile = "octo-org/codeql-config@main";
|
const configFile = "octo-org/codeql-config@main";
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(undefined, undefined, undefined, configFile, undefined, false, { owner: "github", repo: "example " }, tmpDir, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
await configUtils.initConfig(undefined, undefined, undefined, configFile, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -149,7 +149,7 @@ function mockListLanguages(languages) {
|
|||||||
const configFile = "input";
|
const configFile = "input";
|
||||||
t.false(fs.existsSync(path.join(tmpDir, configFile)));
|
t.false(fs.existsSync(path.join(tmpDir, configFile)));
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, false, { owner: "github", repo: "example " }, tmpDir, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -214,11 +214,10 @@ function mockListLanguages(languages) {
|
|||||||
gitHubVersion,
|
gitHubVersion,
|
||||||
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
||||||
packs: {},
|
packs: {},
|
||||||
debugMode: false,
|
|
||||||
};
|
};
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const configFilePath = createConfigFile(inputFileContents, tmpDir);
|
const configFilePath = createConfigFile(inputFileContents, tmpDir);
|
||||||
const actualConfig = await configUtils.initConfig(languages, undefined, undefined, configFilePath, undefined, false, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
const actualConfig = await configUtils.initConfig(languages, undefined, undefined, configFilePath, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
||||||
// Should exactly equal the object we constructed earlier
|
// Should exactly equal the object we constructed earlier
|
||||||
t.deepEqual(actualConfig, expectedConfig);
|
t.deepEqual(actualConfig, expectedConfig);
|
||||||
});
|
});
|
||||||
@@ -254,7 +253,7 @@ function mockListLanguages(languages) {
|
|||||||
fs.mkdirSync(path.join(tmpDir, "foo"));
|
fs.mkdirSync(path.join(tmpDir, "foo"));
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const configFilePath = createConfigFile(inputFileContents, tmpDir);
|
const configFilePath = createConfigFile(inputFileContents, tmpDir);
|
||||||
await configUtils.initConfig(languages, undefined, undefined, configFilePath, undefined, false, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
await configUtils.initConfig(languages, undefined, undefined, configFilePath, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
||||||
// Check resolve queries was called correctly
|
// Check resolve queries was called correctly
|
||||||
t.deepEqual(resolveQueriesArgs.length, 1);
|
t.deepEqual(resolveQueriesArgs.length, 1);
|
||||||
t.deepEqual(resolveQueriesArgs[0].queries, [
|
t.deepEqual(resolveQueriesArgs[0].queries, [
|
||||||
@@ -297,7 +296,7 @@ function queriesToResolvedQueryForm(queries) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const config = await configUtils.initConfig(languages, undefined, undefined, configFilePath, undefined, false, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
const config = await configUtils.initConfig(languages, undefined, undefined, configFilePath, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
||||||
// Check resolveQueries was called correctly
|
// Check resolveQueries was called correctly
|
||||||
// It'll be called once for the default queries
|
// It'll be called once for the default queries
|
||||||
// and once for `./foo` from the config file.
|
// and once for `./foo` from the config file.
|
||||||
@@ -330,7 +329,7 @@ function queriesToResolvedQueryForm(queries) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const config = await configUtils.initConfig(languages, testQueries, undefined, configFilePath, undefined, false, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
const config = await configUtils.initConfig(languages, testQueries, undefined, configFilePath, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
||||||
// Check resolveQueries was called correctly
|
// Check resolveQueries was called correctly
|
||||||
// It'll be called once for the default queries and once for `./override`,
|
// It'll be called once for the default queries and once for `./override`,
|
||||||
// but won't be called for './foo' from the config file.
|
// but won't be called for './foo' from the config file.
|
||||||
@@ -362,7 +361,7 @@ function queriesToResolvedQueryForm(queries) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const config = await configUtils.initConfig(languages, testQueries, undefined, configFilePath, undefined, false, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
const config = await configUtils.initConfig(languages, testQueries, undefined, configFilePath, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
||||||
// Check resolveQueries was called correctly
|
// Check resolveQueries was called correctly
|
||||||
// It'll be called once for `./workflow-query`,
|
// It'll be called once for `./workflow-query`,
|
||||||
// but won't be called for the default one since that was disabled
|
// but won't be called for the default one since that was disabled
|
||||||
@@ -388,7 +387,7 @@ function queriesToResolvedQueryForm(queries) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const config = await configUtils.initConfig(languages, testQueries, undefined, undefined, undefined, false, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
const config = await configUtils.initConfig(languages, testQueries, undefined, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
||||||
// Check resolveQueries was called correctly:
|
// Check resolveQueries was called correctly:
|
||||||
// It'll be called once for the default queries,
|
// It'll be called once for the default queries,
|
||||||
// and then once for each of the two queries from the workflow
|
// and then once for each of the two queries from the workflow
|
||||||
@@ -427,7 +426,7 @@ function queriesToResolvedQueryForm(queries) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const config = await configUtils.initConfig(languages, testQueries, undefined, configFilePath, undefined, false, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
const config = await configUtils.initConfig(languages, testQueries, undefined, configFilePath, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
||||||
// Check resolveQueries was called correctly
|
// Check resolveQueries was called correctly
|
||||||
// It'll be called once for the default queries,
|
// It'll be called once for the default queries,
|
||||||
// once for each of additional1 and additional2,
|
// once for each of additional1 and additional2,
|
||||||
@@ -466,7 +465,7 @@ function queriesToResolvedQueryForm(queries) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(languages, queries, undefined, undefined, undefined, false, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
await configUtils.initConfig(languages, queries, undefined, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
||||||
t.fail("initConfig did not throw error");
|
t.fail("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -509,7 +508,7 @@ function queriesToResolvedQueryForm(queries) {
|
|||||||
fs.mkdirSync(path.join(tmpDir, "foo/bar/dev"), { recursive: true });
|
fs.mkdirSync(path.join(tmpDir, "foo/bar/dev"), { recursive: true });
|
||||||
const configFile = "octo-org/codeql-config/config.yaml@main";
|
const configFile = "octo-org/codeql-config/config.yaml@main";
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, false, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
||||||
t.assert(spyGetContents.called);
|
t.assert(spyGetContents.called);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -519,7 +518,7 @@ function queriesToResolvedQueryForm(queries) {
|
|||||||
mockGetContents(dummyResponse);
|
mockGetContents(dummyResponse);
|
||||||
const repoReference = "octo-org/codeql-config/config.yaml@main";
|
const repoReference = "octo-org/codeql-config/config.yaml@main";
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(undefined, undefined, undefined, repoReference, undefined, false, { owner: "github", repo: "example " }, tmpDir, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
await configUtils.initConfig(undefined, undefined, undefined, repoReference, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -535,7 +534,7 @@ function queriesToResolvedQueryForm(queries) {
|
|||||||
mockGetContents(dummyResponse);
|
mockGetContents(dummyResponse);
|
||||||
const repoReference = "octo-org/codeql-config/config.yaml@main";
|
const repoReference = "octo-org/codeql-config/config.yaml@main";
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(undefined, undefined, undefined, repoReference, undefined, false, { owner: "github", repo: "example " }, tmpDir, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
await configUtils.initConfig(undefined, undefined, undefined, repoReference, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -552,7 +551,7 @@ function queriesToResolvedQueryForm(queries) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(undefined, undefined, undefined, undefined, undefined, false, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
await configUtils.initConfig(undefined, undefined, undefined, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -564,7 +563,7 @@ function queriesToResolvedQueryForm(queries) {
|
|||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
const languages = "rubbish,english";
|
const languages = "rubbish,english";
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(languages, undefined, undefined, undefined, undefined, false, { owner: "github", repo: "example " }, tmpDir, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
await configUtils.initConfig(languages, undefined, undefined, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, (0, codeql_1.getCachedCodeQL)(), tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -592,7 +591,7 @@ function queriesToResolvedQueryForm(queries) {
|
|||||||
const configFile = path.join(tmpDir, "codeql-config.yaml");
|
const configFile = path.join(tmpDir, "codeql-config.yaml");
|
||||||
fs.writeFileSync(configFile, inputFileContents);
|
fs.writeFileSync(configFile, inputFileContents);
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const { packs } = await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, false, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
const { packs } = await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
||||||
t.deepEqual(packs, {
|
t.deepEqual(packs, {
|
||||||
[languages_1.Language.javascript]: [
|
[languages_1.Language.javascript]: [
|
||||||
{
|
{
|
||||||
@@ -631,7 +630,7 @@ function queriesToResolvedQueryForm(queries) {
|
|||||||
fs.writeFileSync(configFile, inputFileContents);
|
fs.writeFileSync(configFile, inputFileContents);
|
||||||
fs.mkdirSync(path.join(tmpDir, "foo"));
|
fs.mkdirSync(path.join(tmpDir, "foo"));
|
||||||
const languages = "javascript,python,cpp";
|
const languages = "javascript,python,cpp";
|
||||||
const { packs, queries } = await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, false, { owner: "github", repo: "example" }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
const { packs, queries } = await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, { owner: "github", repo: "example" }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
||||||
t.deepEqual(packs, {
|
t.deepEqual(packs, {
|
||||||
[languages_1.Language.javascript]: [
|
[languages_1.Language.javascript]: [
|
||||||
{
|
{
|
||||||
@@ -684,7 +683,7 @@ function doInvalidInputTest(testName, inputFileContents, expectedErrorMessageGen
|
|||||||
const inputFile = path.join(tmpDir, configFile);
|
const inputFile = path.join(tmpDir, configFile);
|
||||||
fs.writeFileSync(inputFile, inputFileContents, "utf8");
|
fs.writeFileSync(inputFile, inputFileContents, "utf8");
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, false, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, (0, logging_1.getRunnerLogger)(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Generated
+28
-32
@@ -24,10 +24,8 @@ const fs = __importStar(require("fs"));
|
|||||||
const actionsUtil = __importStar(require("./actions-util"));
|
const actionsUtil = __importStar(require("./actions-util"));
|
||||||
const api_client_1 = require("./api-client");
|
const api_client_1 = require("./api-client");
|
||||||
const codeql_1 = require("./codeql");
|
const codeql_1 = require("./codeql");
|
||||||
const feature_flags_1 = require("./feature-flags");
|
|
||||||
const util = __importStar(require("./util"));
|
const util = __importStar(require("./util"));
|
||||||
const util_1 = require("./util");
|
async function uploadDatabases(repositoryNwo, config, apiDetails, logger) {
|
||||||
async function uploadDatabases(repositoryNwo, config, featureFlags, apiDetails, logger) {
|
|
||||||
if (actionsUtil.getRequiredInput("upload-database") !== "true") {
|
if (actionsUtil.getRequiredInput("upload-database") !== "true") {
|
||||||
logger.debug("Database upload disabled in workflow. Skipping upload.");
|
logger.debug("Database upload disabled in workflow. Skipping upload.");
|
||||||
return;
|
return;
|
||||||
@@ -42,40 +40,38 @@ async function uploadDatabases(repositoryNwo, config, featureFlags, apiDetails,
|
|||||||
logger.debug("Not analyzing default branch. Skipping upload.");
|
logger.debug("Not analyzing default branch. Skipping upload.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!(await featureFlags.getValue(feature_flags_1.FeatureFlag.DatabaseUploadsEnabled))) {
|
const client = (0, api_client_1.getApiClient)(apiDetails);
|
||||||
logger.debug("Repository is not opted in to database uploads. Skipping upload.");
|
try {
|
||||||
|
await client.request("GET /repos/:owner/:repo/code-scanning/codeql/databases", {
|
||||||
|
owner: repositoryNwo.owner,
|
||||||
|
repo: repositoryNwo.repo,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
if (util.isHTTPError(e) && e.status === 404) {
|
||||||
|
logger.debug("Repository is not opted in to database uploads. Skipping upload.");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.log(e);
|
||||||
|
logger.info(`Skipping database upload due to unknown error: ${e}`);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const client = (0, api_client_1.getApiClient)(apiDetails);
|
|
||||||
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
const codeql = await (0, codeql_1.getCodeQL)(config.codeQLCmd);
|
||||||
const useUploadDomain = await featureFlags.getValue(feature_flags_1.FeatureFlag.UploadsDomainEnabled);
|
|
||||||
for (const language of config.languages) {
|
for (const language of config.languages) {
|
||||||
// Upload the database bundle.
|
// Bundle the database up into a single zip file
|
||||||
// Although we are uploading arbitrary file contents to the API, it's worth
|
const databasePath = util.getCodeQLDatabasePath(config, language);
|
||||||
// noting that it's the API's job to validate that the contents is acceptable.
|
const databaseBundlePath = `${databasePath}.zip`;
|
||||||
// This API method is available to anyone with write access to the repo.
|
await codeql.databaseBundle(databasePath, databaseBundlePath);
|
||||||
const payload = fs.readFileSync(await (0, util_1.bundleDb)(config, language, codeql));
|
// Upload the database bundle
|
||||||
|
const payload = fs.readFileSync(databaseBundlePath);
|
||||||
try {
|
try {
|
||||||
if (useUploadDomain) {
|
await client.request(`PUT /repos/:owner/:repo/code-scanning/codeql/databases/:language`, {
|
||||||
await client.request(`POST https://uploads.github.com/repos/:owner/:repo/code-scanning/codeql/databases/:language?name=:name`, {
|
owner: repositoryNwo.owner,
|
||||||
owner: repositoryNwo.owner,
|
repo: repositoryNwo.repo,
|
||||||
repo: repositoryNwo.repo,
|
language,
|
||||||
language,
|
data: payload,
|
||||||
name: `${language}-database`,
|
});
|
||||||
data: payload,
|
|
||||||
headers: {
|
|
||||||
authorization: `token ${apiDetails.auth}`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
await client.request(`PUT /repos/:owner/:repo/code-scanning/codeql/databases/:language`, {
|
|
||||||
owner: repositoryNwo.owner,
|
|
||||||
repo: repositoryNwo.repo,
|
|
||||||
language,
|
|
||||||
data: payload,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
logger.debug(`Successfully uploaded database for ${language}`);
|
logger.debug(`Successfully uploaded database for ${language}`);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"database-upload.js","sourceRoot":"","sources":["../src/database-upload.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AAEzB,4DAA8C;AAC9C,6CAA8D;AAC9D,qCAAqC;AAErC,mDAA4D;AAG5D,6CAA+B;AAC/B,iCAAkC;AAE3B,KAAK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,aAAa,CAAC,KAAK;gBAC1B,IAAI,EAAE,aAAa,CAAC,IAAI;gBACxB,QAAQ;gBACR,IAAI,EAAE,OAAO;aACd,CACF,CAAC;YACF,MAAM,CAAC,KAAK,CAAC,sCAAsC,QAAQ,EAAE,CAAC,CAAC;SAChE;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACf,4CAA4C;YAC5C,MAAM,CAAC,OAAO,CAAC,iCAAiC,QAAQ,KAAK,CAAC,EAAE,CAAC,CAAC;SACnE;KACF;AACH,CAAC;AAtED,0CAsEC"}
|
||||||
Generated
+70
-48
@@ -30,7 +30,6 @@ const actionsUtil = __importStar(require("./actions-util"));
|
|||||||
const apiClient = __importStar(require("./api-client"));
|
const apiClient = __importStar(require("./api-client"));
|
||||||
const codeql_1 = require("./codeql");
|
const codeql_1 = require("./codeql");
|
||||||
const database_upload_1 = require("./database-upload");
|
const database_upload_1 = require("./database-upload");
|
||||||
const feature_flags_1 = require("./feature-flags");
|
|
||||||
const languages_1 = require("./languages");
|
const languages_1 = require("./languages");
|
||||||
const testing_utils_1 = require("./testing-utils");
|
const testing_utils_1 = require("./testing-utils");
|
||||||
const util_1 = require("./util");
|
const util_1 = require("./util");
|
||||||
@@ -38,10 +37,6 @@ const util_1 = require("./util");
|
|||||||
ava_1.default.beforeEach(() => {
|
ava_1.default.beforeEach(() => {
|
||||||
(0, util_1.initializeEnvironment)(util_1.Mode.actions, "1.2.3");
|
(0, util_1.initializeEnvironment)(util_1.Mode.actions, "1.2.3");
|
||||||
});
|
});
|
||||||
const uploadToUploadsDomainFlags = (0, feature_flags_1.createFeatureFlags)([
|
|
||||||
feature_flags_1.FeatureFlag.DatabaseUploadsEnabled,
|
|
||||||
feature_flags_1.FeatureFlag.UploadsDomainEnabled,
|
|
||||||
]);
|
|
||||||
const testRepoName = { owner: "github", repo: "example" };
|
const testRepoName = { owner: "github", repo: "example" };
|
||||||
const testApiDetails = {
|
const testApiDetails = {
|
||||||
auth: "1234",
|
auth: "1234",
|
||||||
@@ -60,22 +55,50 @@ function getTestConfig(tmpDir) {
|
|||||||
gitHubVersion: { type: util_1.GitHubVariant.DOTCOM },
|
gitHubVersion: { type: util_1.GitHubVariant.DOTCOM },
|
||||||
dbLocation: tmpDir,
|
dbLocation: tmpDir,
|
||||||
packs: {},
|
packs: {},
|
||||||
debugMode: false,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
async function mockHttpRequests(featureFlags, databaseUploadStatusCode) {
|
function getRecordingLogger(messages) {
|
||||||
|
return {
|
||||||
|
debug: (message) => {
|
||||||
|
messages.push({ type: "debug", message });
|
||||||
|
console.debug(message);
|
||||||
|
},
|
||||||
|
info: (message) => {
|
||||||
|
messages.push({ type: "info", message });
|
||||||
|
console.info(message);
|
||||||
|
},
|
||||||
|
warning: (message) => {
|
||||||
|
messages.push({ type: "warning", message });
|
||||||
|
console.warn(message);
|
||||||
|
},
|
||||||
|
error: (message) => {
|
||||||
|
messages.push({ type: "error", message });
|
||||||
|
console.error(message);
|
||||||
|
},
|
||||||
|
isDebug: () => true,
|
||||||
|
startGroup: () => undefined,
|
||||||
|
endGroup: () => undefined,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
function mockHttpRequests(optInStatusCode, databaseUploadStatusCode) {
|
||||||
// Passing an auth token is required, so we just use a dummy value
|
// Passing an auth token is required, so we just use a dummy value
|
||||||
const client = github.getOctokit("123");
|
const client = github.getOctokit("123");
|
||||||
const requestSpy = sinon.stub(client, "request");
|
const requestSpy = sinon.stub(client, "request");
|
||||||
const url = (await featureFlags.getValue(feature_flags_1.FeatureFlag.UploadsDomainEnabled))
|
const optInSpy = requestSpy.withArgs("GET /repos/:owner/:repo/code-scanning/codeql/databases");
|
||||||
? "POST https://uploads.github.com/repos/:owner/:repo/code-scanning/codeql/databases/:language?name=:name"
|
if (optInStatusCode < 300) {
|
||||||
: "PUT /repos/:owner/:repo/code-scanning/codeql/databases/:language";
|
optInSpy.resolves(undefined);
|
||||||
const databaseUploadSpy = requestSpy.withArgs(url);
|
|
||||||
if (databaseUploadStatusCode < 300) {
|
|
||||||
databaseUploadSpy.resolves(undefined);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
databaseUploadSpy.throws(new util_1.HTTPError("some error message", databaseUploadStatusCode));
|
optInSpy.throws(new util_1.HTTPError("some error message", optInStatusCode));
|
||||||
|
}
|
||||||
|
if (databaseUploadStatusCode !== undefined) {
|
||||||
|
const databaseUploadSpy = requestSpy.withArgs("PUT /repos/:owner/:repo/code-scanning/codeql/databases/:language");
|
||||||
|
if (databaseUploadStatusCode < 300) {
|
||||||
|
databaseUploadSpy.resolves(undefined);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
databaseUploadSpy.throws(new util_1.HTTPError("some error message", databaseUploadStatusCode));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sinon.stub(apiClient, "getApiClient").value(() => client);
|
sinon.stub(apiClient, "getApiClient").value(() => client);
|
||||||
}
|
}
|
||||||
@@ -88,7 +111,7 @@ async function mockHttpRequests(featureFlags, databaseUploadStatusCode) {
|
|||||||
.returns("false");
|
.returns("false");
|
||||||
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
||||||
const loggedMessages = [];
|
const loggedMessages = [];
|
||||||
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), uploadToUploadsDomainFlags, testApiDetails, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
|
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), testApiDetails, getRecordingLogger(loggedMessages));
|
||||||
t.assert(loggedMessages.find((v) => v.type === "debug" &&
|
t.assert(loggedMessages.find((v) => v.type === "debug" &&
|
||||||
v.message === "Database upload disabled in workflow. Skipping upload.") !== undefined);
|
v.message === "Database upload disabled in workflow. Skipping upload.") !== undefined);
|
||||||
});
|
});
|
||||||
@@ -104,7 +127,7 @@ async function mockHttpRequests(featureFlags, databaseUploadStatusCode) {
|
|||||||
const config = getTestConfig(tmpDir);
|
const config = getTestConfig(tmpDir);
|
||||||
config.gitHubVersion = { type: util_1.GitHubVariant.GHES, version: "3.0" };
|
config.gitHubVersion = { type: util_1.GitHubVariant.GHES, version: "3.0" };
|
||||||
const loggedMessages = [];
|
const loggedMessages = [];
|
||||||
await (0, database_upload_1.uploadDatabases)(testRepoName, config, (0, feature_flags_1.createFeatureFlags)([]), testApiDetails, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
|
await (0, database_upload_1.uploadDatabases)(testRepoName, config, testApiDetails, getRecordingLogger(loggedMessages));
|
||||||
t.assert(loggedMessages.find((v) => v.type === "debug" &&
|
t.assert(loggedMessages.find((v) => v.type === "debug" &&
|
||||||
v.message === "Not running against github.com. Skipping upload.") !== undefined);
|
v.message === "Not running against github.com. Skipping upload.") !== undefined);
|
||||||
});
|
});
|
||||||
@@ -120,7 +143,7 @@ async function mockHttpRequests(featureFlags, databaseUploadStatusCode) {
|
|||||||
const config = getTestConfig(tmpDir);
|
const config = getTestConfig(tmpDir);
|
||||||
config.gitHubVersion = { type: util_1.GitHubVariant.GHAE };
|
config.gitHubVersion = { type: util_1.GitHubVariant.GHAE };
|
||||||
const loggedMessages = [];
|
const loggedMessages = [];
|
||||||
await (0, database_upload_1.uploadDatabases)(testRepoName, config, (0, feature_flags_1.createFeatureFlags)([]), testApiDetails, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
|
await (0, database_upload_1.uploadDatabases)(testRepoName, config, testApiDetails, getRecordingLogger(loggedMessages));
|
||||||
t.assert(loggedMessages.find((v) => v.type === "debug" &&
|
t.assert(loggedMessages.find((v) => v.type === "debug" &&
|
||||||
v.message === "Not running against github.com. Skipping upload.") !== undefined);
|
v.message === "Not running against github.com. Skipping upload.") !== undefined);
|
||||||
});
|
});
|
||||||
@@ -134,12 +157,12 @@ async function mockHttpRequests(featureFlags, databaseUploadStatusCode) {
|
|||||||
.returns("true");
|
.returns("true");
|
||||||
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(false);
|
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(false);
|
||||||
const loggedMessages = [];
|
const loggedMessages = [];
|
||||||
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), uploadToUploadsDomainFlags, testApiDetails, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
|
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), testApiDetails, getRecordingLogger(loggedMessages));
|
||||||
t.assert(loggedMessages.find((v) => v.type === "debug" &&
|
t.assert(loggedMessages.find((v) => v.type === "debug" &&
|
||||||
v.message === "Not analyzing default branch. Skipping upload.") !== undefined);
|
v.message === "Not analyzing default branch. Skipping upload.") !== undefined);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("Abort database upload if feature flag is disabled", async (t) => {
|
(0, ava_1.default)("Abort database upload if opt-in request returns 404", async (t) => {
|
||||||
await (0, util_1.withTmpDir)(async (tmpDir) => {
|
await (0, util_1.withTmpDir)(async (tmpDir) => {
|
||||||
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
sinon
|
sinon
|
||||||
@@ -147,18 +170,40 @@ async function mockHttpRequests(featureFlags, databaseUploadStatusCode) {
|
|||||||
.withArgs("upload-database")
|
.withArgs("upload-database")
|
||||||
.returns("true");
|
.returns("true");
|
||||||
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
||||||
|
mockHttpRequests(404);
|
||||||
(0, codeql_1.setCodeQL)({
|
(0, codeql_1.setCodeQL)({
|
||||||
async databaseBundle() {
|
async databaseBundle() {
|
||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const loggedMessages = [];
|
const loggedMessages = [];
|
||||||
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), (0, feature_flags_1.createFeatureFlags)([feature_flags_1.FeatureFlag.UploadsDomainEnabled]), testApiDetails, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
|
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), testApiDetails, getRecordingLogger(loggedMessages));
|
||||||
t.assert(loggedMessages.find((v) => v.type === "debug" &&
|
t.assert(loggedMessages.find((v) => v.type === "debug" &&
|
||||||
v.message ===
|
v.message ===
|
||||||
"Repository is not opted in to database uploads. Skipping upload.") !== undefined);
|
"Repository is not opted in to database uploads. Skipping upload.") !== undefined);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
(0, ava_1.default)("Abort database upload if opt-in request fails with something other than 404", async (t) => {
|
||||||
|
await (0, util_1.withTmpDir)(async (tmpDir) => {
|
||||||
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
|
sinon
|
||||||
|
.stub(actionsUtil, "getRequiredInput")
|
||||||
|
.withArgs("upload-database")
|
||||||
|
.returns("true");
|
||||||
|
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
||||||
|
mockHttpRequests(500);
|
||||||
|
(0, codeql_1.setCodeQL)({
|
||||||
|
async databaseBundle() {
|
||||||
|
return;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const loggedMessages = [];
|
||||||
|
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), testApiDetails, getRecordingLogger(loggedMessages));
|
||||||
|
t.assert(loggedMessages.find((v) => v.type === "info" &&
|
||||||
|
v.message ===
|
||||||
|
"Skipping database upload due to unknown error: Error: some error message") !== undefined);
|
||||||
|
});
|
||||||
|
});
|
||||||
(0, ava_1.default)("Don't crash if uploading a database fails", async (t) => {
|
(0, ava_1.default)("Don't crash if uploading a database fails", async (t) => {
|
||||||
await (0, util_1.withTmpDir)(async (tmpDir) => {
|
await (0, util_1.withTmpDir)(async (tmpDir) => {
|
||||||
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
@@ -167,23 +212,20 @@ async function mockHttpRequests(featureFlags, databaseUploadStatusCode) {
|
|||||||
.withArgs("upload-database")
|
.withArgs("upload-database")
|
||||||
.returns("true");
|
.returns("true");
|
||||||
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
||||||
const featureFlags = (0, feature_flags_1.createFeatureFlags)([
|
mockHttpRequests(204, 500);
|
||||||
feature_flags_1.FeatureFlag.DatabaseUploadsEnabled,
|
|
||||||
]);
|
|
||||||
await mockHttpRequests(featureFlags, 500);
|
|
||||||
(0, codeql_1.setCodeQL)({
|
(0, codeql_1.setCodeQL)({
|
||||||
async databaseBundle(_, outputFilePath) {
|
async databaseBundle(_, outputFilePath) {
|
||||||
fs.writeFileSync(outputFilePath, "");
|
fs.writeFileSync(outputFilePath, "");
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const loggedMessages = [];
|
const loggedMessages = [];
|
||||||
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), featureFlags, testApiDetails, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
|
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), testApiDetails, getRecordingLogger(loggedMessages));
|
||||||
t.assert(loggedMessages.find((v) => v.type === "warning" &&
|
t.assert(loggedMessages.find((v) => v.type === "warning" &&
|
||||||
v.message ===
|
v.message ===
|
||||||
"Failed to upload database for javascript: Error: some error message") !== undefined);
|
"Failed to upload database for javascript: Error: some error message") !== undefined);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("Successfully uploading a database to api.github.com", async (t) => {
|
(0, ava_1.default)("Successfully uploading a database", async (t) => {
|
||||||
await (0, util_1.withTmpDir)(async (tmpDir) => {
|
await (0, util_1.withTmpDir)(async (tmpDir) => {
|
||||||
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
||||||
sinon
|
sinon
|
||||||
@@ -191,34 +233,14 @@ async function mockHttpRequests(featureFlags, databaseUploadStatusCode) {
|
|||||||
.withArgs("upload-database")
|
.withArgs("upload-database")
|
||||||
.returns("true");
|
.returns("true");
|
||||||
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
||||||
await mockHttpRequests(uploadToUploadsDomainFlags, 201);
|
mockHttpRequests(204, 201);
|
||||||
(0, codeql_1.setCodeQL)({
|
(0, codeql_1.setCodeQL)({
|
||||||
async databaseBundle(_, outputFilePath) {
|
async databaseBundle(_, outputFilePath) {
|
||||||
fs.writeFileSync(outputFilePath, "");
|
fs.writeFileSync(outputFilePath, "");
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const loggedMessages = [];
|
const loggedMessages = [];
|
||||||
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), uploadToUploadsDomainFlags, testApiDetails, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
|
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), testApiDetails, getRecordingLogger(loggedMessages));
|
||||||
t.assert(loggedMessages.find((v) => v.type === "debug" &&
|
|
||||||
v.message === "Successfully uploaded database for javascript") !== undefined);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
(0, ava_1.default)("Successfully uploading a database to uploads.github.com", async (t) => {
|
|
||||||
await (0, util_1.withTmpDir)(async (tmpDir) => {
|
|
||||||
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
|
||||||
sinon
|
|
||||||
.stub(actionsUtil, "getRequiredInput")
|
|
||||||
.withArgs("upload-database")
|
|
||||||
.returns("true");
|
|
||||||
sinon.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
|
||||||
await mockHttpRequests(uploadToUploadsDomainFlags, 201);
|
|
||||||
(0, codeql_1.setCodeQL)({
|
|
||||||
async databaseBundle(_, outputFilePath) {
|
|
||||||
fs.writeFileSync(outputFilePath, "");
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const loggedMessages = [];
|
|
||||||
await (0, database_upload_1.uploadDatabases)(testRepoName, getTestConfig(tmpDir), uploadToUploadsDomainFlags, testApiDetails, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
|
|
||||||
t.assert(loggedMessages.find((v) => v.type === "debug" &&
|
t.assert(loggedMessages.find((v) => v.type === "debug" &&
|
||||||
v.message === "Successfully uploaded database for javascript") !== undefined);
|
v.message === "Successfully uploaded database for javascript") !== undefined);
|
||||||
});
|
});
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"bundleVersion": "codeql-bundle-20211208"
|
"bundleVersion": "codeql-bundle-20211013"
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
-91
@@ -1,91 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
||||||
__setModuleDefault(result, mod);
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.createFeatureFlags = exports.GitHubFeatureFlags = exports.FeatureFlag = void 0;
|
|
||||||
const api_client_1 = require("./api-client");
|
|
||||||
const util = __importStar(require("./util"));
|
|
||||||
var FeatureFlag;
|
|
||||||
(function (FeatureFlag) {
|
|
||||||
FeatureFlag["DatabaseUploadsEnabled"] = "database_uploads_enabled";
|
|
||||||
FeatureFlag["MlPoweredQueriesEnabled"] = "ml_powered_queries_enabled";
|
|
||||||
FeatureFlag["UploadsDomainEnabled"] = "uploads_domain_enabled";
|
|
||||||
})(FeatureFlag = exports.FeatureFlag || (exports.FeatureFlag = {}));
|
|
||||||
class GitHubFeatureFlags {
|
|
||||||
constructor(gitHubVersion, apiDetails, repositoryNwo, logger) {
|
|
||||||
this.gitHubVersion = gitHubVersion;
|
|
||||||
this.apiDetails = apiDetails;
|
|
||||||
this.repositoryNwo = repositoryNwo;
|
|
||||||
this.logger = logger;
|
|
||||||
}
|
|
||||||
async getValue(flag) {
|
|
||||||
const response = (await this.getApiResponse())[flag];
|
|
||||||
if (response === undefined) {
|
|
||||||
this.logger.debug(`Feature flag '${flag}' undefined in API response, considering it disabled.`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
async preloadFeatureFlags() {
|
|
||||||
await this.getApiResponse();
|
|
||||||
}
|
|
||||||
async getApiResponse() {
|
|
||||||
const loadApiResponse = async () => {
|
|
||||||
// Do nothing when not running against github.com
|
|
||||||
if (this.gitHubVersion.type !== util.GitHubVariant.DOTCOM) {
|
|
||||||
this.logger.debug("Not running against github.com. Disabling all feature flags.");
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
const client = (0, api_client_1.getApiClient)(this.apiDetails);
|
|
||||||
try {
|
|
||||||
const response = await client.request("GET /repos/:owner/:repo/code-scanning/codeql-action/features", {
|
|
||||||
owner: this.repositoryNwo.owner,
|
|
||||||
repo: this.repositoryNwo.repo,
|
|
||||||
});
|
|
||||||
return response.data;
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
// Some feature flags, such as `ml_powered_queries_enabled` affect the produced alerts.
|
|
||||||
// Considering these feature flags disabled in the event of a transient error could
|
|
||||||
// therefore lead to alert churn. As a result, we crash if we cannot determine the value of
|
|
||||||
// the feature flags.
|
|
||||||
throw new Error(`Encountered an error while trying to load feature flags: ${e}`);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const apiResponse = this.cachedApiResponse || (await loadApiResponse());
|
|
||||||
this.cachedApiResponse = apiResponse;
|
|
||||||
return apiResponse;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.GitHubFeatureFlags = GitHubFeatureFlags;
|
|
||||||
/**
|
|
||||||
* Create a feature flags instance with the specified set of enabled flags.
|
|
||||||
*
|
|
||||||
* This should be only used within tests.
|
|
||||||
*/
|
|
||||||
function createFeatureFlags(enabledFlags) {
|
|
||||||
return {
|
|
||||||
getValue: async (flag) => {
|
|
||||||
return enabledFlags.includes(flag);
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
exports.createFeatureFlags = createFeatureFlags;
|
|
||||||
//# sourceMappingURL=feature-flags.js.map
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"feature-flags.js","sourceRoot":"","sources":["../src/feature-flags.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA8D;AAG9D,6CAA+B;AAM/B,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,kEAAmD,CAAA;IACnD,qEAAsD,CAAA;IACtD,8DAA+C,CAAA;AACjD,CAAC,EAJW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAItB;AAUD,MAAa,kBAAkB;IAG7B,YACU,aAAiC,EACjC,UAA4B,EAC5B,a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I,KAAK,CACb,4DAA4D,CAAC,EAAE,CAChE,CAAC;aACH;QACH,CAAC,CAAC;QAEF,MAAM,WAAW,GAAG,IAAI,CAAC,iBAAiB,IAAI,CAAC,MAAM,eAAe,EAAE,CAAC,CAAC;QACxE,IAAI,CAAC,iBAAiB,GAAG,WAAW,CAAC;QACrC,OAAO,WAAW,CAAC;IACrB,CAAC;CACF;AA3DD,gDA2DC;AAED;;;;GAIG;AACH,SAAgB,kBAAkB,CAAC,YAA2B;IAC5D,OAAO;QACL,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;YACvB,OAAO,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACrC,CAAC;KACF,CAAC;AACJ,CAAC;AAND,gDAMC"}
|
|
||||||
Generated
-98
@@ -1,98 +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 feature_flags_1 = require("./feature-flags");
|
|
||||||
const logging_1 = require("./logging");
|
|
||||||
const repository_1 = require("./repository");
|
|
||||||
const testing_utils_1 = require("./testing-utils");
|
|
||||||
const util_1 = require("./util");
|
|
||||||
(0, testing_utils_1.setupTests)(ava_1.default);
|
|
||||||
ava_1.default.beforeEach(() => {
|
|
||||||
(0, util_1.initializeEnvironment)(util_1.Mode.actions, "1.2.3");
|
|
||||||
});
|
|
||||||
const testApiDetails = {
|
|
||||||
auth: "1234",
|
|
||||||
url: "https://github.com",
|
|
||||||
};
|
|
||||||
const testRepositoryNwo = (0, repository_1.parseRepositoryNwo)("github/example");
|
|
||||||
const ALL_FEATURE_FLAGS_DISABLED_VARIANTS = [
|
|
||||||
{
|
|
||||||
description: "GHES",
|
|
||||||
gitHubVersion: { type: util_1.GitHubVariant.GHES, version: "3.0.0" },
|
|
||||||
},
|
|
||||||
{ description: "GHAE", gitHubVersion: { type: util_1.GitHubVariant.GHAE } },
|
|
||||||
];
|
|
||||||
for (const variant of ALL_FEATURE_FLAGS_DISABLED_VARIANTS) {
|
|
||||||
(0, ava_1.default)(`All feature flags are disabled if running against ${variant.description}`, async (t) => {
|
|
||||||
await (0, util_1.withTmpDir)(async (tmpDir) => {
|
|
||||||
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
|
||||||
const loggedMessages = [];
|
|
||||||
const featureFlags = new feature_flags_1.GitHubFeatureFlags(variant.gitHubVersion, testApiDetails, testRepositoryNwo, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
|
|
||||||
for (const flag of Object.values(feature_flags_1.FeatureFlag)) {
|
|
||||||
t.assert((await featureFlags.getValue(flag)) === false);
|
|
||||||
}
|
|
||||||
t.assert(loggedMessages.find((v) => v.type === "debug" &&
|
|
||||||
v.message ===
|
|
||||||
"Not running against github.com. Disabling all feature flags.") !== undefined);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
(0, ava_1.default)("Feature flags are disabled if they're not returned in API response", async (t) => {
|
|
||||||
await (0, util_1.withTmpDir)(async (tmpDir) => {
|
|
||||||
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
|
||||||
const loggedMessages = [];
|
|
||||||
const featureFlags = new feature_flags_1.GitHubFeatureFlags({ type: util_1.GitHubVariant.DOTCOM }, testApiDetails, testRepositoryNwo, (0, testing_utils_1.getRecordingLogger)(loggedMessages));
|
|
||||||
(0, testing_utils_1.mockFeatureFlagApiEndpoint)(200, {});
|
|
||||||
for (const flag of Object.values(feature_flags_1.FeatureFlag)) {
|
|
||||||
t.assert((await featureFlags.getValue(flag)) === false);
|
|
||||||
}
|
|
||||||
for (const featureFlag of [
|
|
||||||
"database_uploads_enabled",
|
|
||||||
"ml_powered_queries_enabled",
|
|
||||||
"uploads_domain_enabled",
|
|
||||||
]) {
|
|
||||||
t.assert(loggedMessages.find((v) => v.type === "debug" &&
|
|
||||||
v.message ===
|
|
||||||
`Feature flag '${featureFlag}' undefined in API response, considering it disabled.`) !== undefined);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
(0, ava_1.default)("Feature flags exception is propagated if the API request errors", async (t) => {
|
|
||||||
await (0, util_1.withTmpDir)(async (tmpDir) => {
|
|
||||||
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
|
||||||
const featureFlags = new feature_flags_1.GitHubFeatureFlags({ type: util_1.GitHubVariant.DOTCOM }, testApiDetails, testRepositoryNwo, (0, logging_1.getRunnerLogger)(true));
|
|
||||||
(0, testing_utils_1.mockFeatureFlagApiEndpoint)(500, {});
|
|
||||||
await t.throwsAsync(async () => featureFlags.preloadFeatureFlags(), {
|
|
||||||
message: "Encountered an error while trying to load feature flags: Error: some error message",
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
const FEATURE_FLAGS = [
|
|
||||||
"database_uploads_enabled",
|
|
||||||
"ml_powered_queries_enabled",
|
|
||||||
"uploads_domain_enabled",
|
|
||||||
];
|
|
||||||
for (const featureFlag of FEATURE_FLAGS) {
|
|
||||||
(0, ava_1.default)(`Feature flag '${featureFlag}' is enabled if enabled in the API response`, async (t) => {
|
|
||||||
await (0, util_1.withTmpDir)(async (tmpDir) => {
|
|
||||||
(0, testing_utils_1.setupActionsVars)(tmpDir, tmpDir);
|
|
||||||
const featureFlags = new feature_flags_1.GitHubFeatureFlags({ type: util_1.GitHubVariant.DOTCOM }, testApiDetails, testRepositoryNwo, (0, logging_1.getRunnerLogger)(true));
|
|
||||||
const expectedFeatureFlags = {};
|
|
||||||
for (const f of FEATURE_FLAGS) {
|
|
||||||
expectedFeatureFlags[f] = false;
|
|
||||||
}
|
|
||||||
expectedFeatureFlags[featureFlag] = true;
|
|
||||||
(0, testing_utils_1.mockFeatureFlagApiEndpoint)(200, expectedFeatureFlags);
|
|
||||||
const actualFeatureFlags = {
|
|
||||||
database_uploads_enabled: await featureFlags.getValue(feature_flags_1.FeatureFlag.DatabaseUploadsEnabled),
|
|
||||||
ml_powered_queries_enabled: await featureFlags.getValue(feature_flags_1.FeatureFlag.MlPoweredQueriesEnabled),
|
|
||||||
uploads_domain_enabled: await featureFlags.getValue(feature_flags_1.FeatureFlag.UploadsDomainEnabled),
|
|
||||||
};
|
|
||||||
t.deepEqual(actualFeatureFlags, expectedFeatureFlags);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=feature-flags.test.js.map
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"feature-flags.test.js","sourceRoot":"","sources":["../src/feature-flags.test.ts"],"names":[],"mappings":";;;;;AAAA,8CAAuB;AAGvB,mDAAkE;AAClE,uCAA4C;AAC5C,6CAAkD;AAClD,mDAMyB;AAEzB,iCAAgF;AAEhF,IAAA,0BAAU,EAAC,aAAI,CAAC,CAAC;AAEjB,aAAI,CAAC,UAAU,CAAC,GAAG,EAAE;IACnB,IAAA,4BAAqB,EAAC,WAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC/C,CAAC,CAAC,CAAC;AAEH,MAAM,cAAc,GAAqB;IACvC,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,oBAAoB;CAC1B,CAAC;AAEF,MAAM,iBAAiB,GAAG,IAAA,+BAAkB,EAAC,gBAAgB,CAAC,CAAC;AAE/D,MAAM,mCAAmC,GAGpC;IACH;QACE,WAAW,EAAE,MAAM;QACnB,aAAa,EAAE,EAAE,IAAI,EAAE,oBAAa,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE;KAC9D;IACD,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE,IAAI,EAAE,oBAAa,CAAC,IAAI,EAAE,EAAE;CACrE,CAAC;AAEF,KAAK,MAAM,OAAO,IAAI,mCAAmC,EAAE;IACzD,IAAA,aAAI,EAAC,qDAAqD,OAAO,CAAC,WAAW,EA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I,EAAC,iBAAiB,WAAW,6CAA6C,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;QAC1F,MAAM,IAAA,iBAAU,EAAC,KAAK,EAAE,MAAM,EAAE,EAAE;YAChC,IAAA,gCAAgB,EAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAEjC,MAAM,YAAY,GAAG,IAAI,kCAAkB,CACzC,EAAE,IAAI,EAAE,oBAAa,CAAC,MAAM,EAAE,EAC9B,cAAc,EACd,iBAAiB,EACjB,IAAA,yBAAe,EAAC,IAAI,CAAC,CACtB,CAAC;YAEF,MAAM,oBAAoB,GAAG,EAAE,CAAC;YAChC,KAAK,MAAM,CAAC,IAAI,aAAa,EAAE;gBAC7B,oBAAoB,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;aACjC;YACD,oBAAoB,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC;YACzC,IAAA,0CAA0B,EAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC;YAEtD,MAAM,kBAAkB,GAAG;gBACzB,wBAAwB,EAAE,MAAM,YAAY,CAAC,QAAQ,CACnD,2BAAW,CAAC,sBAAsB,CACnC;gBACD,0BAA0B,EAAE,MAAM,YAAY,CAAC,QAAQ,CACrD,2BAAW,CAAC,uBAAuB,CACpC;gBACD,sBAAsB,EAAE,MAAM,YAAY,CAAC,QAAQ,CACjD,2BAAW,CAAC,oBAAoB,CACjC;aACF,CAAC;YAEF,CAAC,CAAC,SAAS,CAAC,kBAAkB,EAAE,oBAAoB,CAAC,CAAC;QACxD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;CACJ"}
|
|
||||||
Generated
+4
-9
@@ -87,7 +87,7 @@ async function run() {
|
|||||||
codeql = initCodeQLResult.codeql;
|
codeql = initCodeQLResult.codeql;
|
||||||
toolsVersion = initCodeQLResult.toolsVersion;
|
toolsVersion = initCodeQLResult.toolsVersion;
|
||||||
await (0, util_1.enrichEnvironment)(util_1.Mode.actions, codeql);
|
await (0, util_1.enrichEnvironment)(util_1.Mode.actions, codeql);
|
||||||
config = await (0, init_1.initConfig)((0, actions_util_1.getOptionalInput)("languages"), (0, actions_util_1.getOptionalInput)("queries"), (0, actions_util_1.getOptionalInput)("packs"), (0, actions_util_1.getOptionalInput)("config-file"), (0, actions_util_1.getOptionalInput)("db-location"), (0, actions_util_1.getOptionalInput)("debug") === "true", (0, repository_1.parseRepositoryNwo)((0, util_1.getRequiredEnvParam)("GITHUB_REPOSITORY")), (0, actions_util_1.getTemporaryDirectory)(), (0, util_1.getRequiredEnvParam)("RUNNER_TOOL_CACHE"), codeql, (0, util_1.getRequiredEnvParam)("GITHUB_WORKSPACE"), gitHubVersion, apiDetails, logger);
|
config = await (0, init_1.initConfig)((0, actions_util_1.getOptionalInput)("languages"), (0, actions_util_1.getOptionalInput)("queries"), (0, actions_util_1.getOptionalInput)("packs"), (0, actions_util_1.getOptionalInput)("config-file"), (0, actions_util_1.getOptionalInput)("db-location"), (0, repository_1.parseRepositoryNwo)((0, util_1.getRequiredEnvParam)("GITHUB_REPOSITORY")), (0, actions_util_1.getTemporaryDirectory)(), (0, util_1.getRequiredEnvParam)("RUNNER_TOOL_CACHE"), codeql, (0, util_1.getRequiredEnvParam)("GITHUB_WORKSPACE"), gitHubVersion, apiDetails, logger);
|
||||||
if (config.languages.includes(languages_1.Language.python) &&
|
if (config.languages.includes(languages_1.Language.python) &&
|
||||||
(0, actions_util_1.getRequiredInput)("setup-python-dependencies") === "true") {
|
(0, actions_util_1.getRequiredInput)("setup-python-dependencies") === "true") {
|
||||||
try {
|
try {
|
||||||
@@ -113,14 +113,9 @@ async function run() {
|
|||||||
core.exportVariable("GOFLAGS", goFlags);
|
core.exportVariable("GOFLAGS", goFlags);
|
||||||
core.warning("Passing the GOFLAGS env parameter to the init action is deprecated. Please move this to the analyze action.");
|
core.warning("Passing the GOFLAGS env parameter to the init action is deprecated. Please move this to the analyze action.");
|
||||||
}
|
}
|
||||||
// Limit RAM and threads for extractors. When running extractors, the CodeQL CLI obeys the
|
// Setup CODEQL_RAM flag (todo improve this https://github.com/github/dsp-code-scanning/issues/935)
|
||||||
// CODEQL_RAM and CODEQL_THREADS environment variables to decide how much RAM and how many
|
const codeqlRam = process.env["CODEQL_RAM"] || "6500";
|
||||||
// threads it would ask extractors to use. See help text for the "--ram" and "--threads"
|
core.exportVariable("CODEQL_RAM", codeqlRam);
|
||||||
// options at https://codeql.github.com/docs/codeql-cli/manual/database-trace-command/
|
|
||||||
// for details.
|
|
||||||
core.exportVariable("CODEQL_RAM", process.env["CODEQL_RAM"] ||
|
|
||||||
(0, util_1.getMemoryFlagValue)((0, actions_util_1.getOptionalInput)("ram")).toString());
|
|
||||||
core.exportVariable("CODEQL_THREADS", (0, util_1.getThreadsFlagValue)((0, actions_util_1.getOptionalInput)("threads"), logger).toString());
|
|
||||||
const sourceRoot = path.resolve((0, util_1.getRequiredEnvParam)("GITHUB_WORKSPACE"), (0, actions_util_1.getOptionalInput)("source-root") || "");
|
const sourceRoot = path.resolve((0, util_1.getRequiredEnvParam)("GITHUB_WORKSPACE"), (0, actions_util_1.getOptionalInput)("source-root") || "");
|
||||||
const tracerConfig = await (0, init_1.runInit)(codeql, config, sourceRoot, "Runner.Worker.exe", undefined);
|
const tracerConfig = await (0, init_1.runInit)(codeql, config, sourceRoot, "Runner.Worker.exe", undefined);
|
||||||
if (tracerConfig !== undefined) {
|
if (tracerConfig !== undefined) {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Generated
+2
-2
@@ -38,9 +38,9 @@ async function initCodeQL(codeqlURL, apiDetails, tempDir, toolCacheDir, variant,
|
|||||||
return { codeql, toolsVersion };
|
return { codeql, toolsVersion };
|
||||||
}
|
}
|
||||||
exports.initCodeQL = initCodeQL;
|
exports.initCodeQL = initCodeQL;
|
||||||
async function initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, debugMode, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, logger) {
|
async function initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, logger) {
|
||||||
logger.startGroup("Load language configuration");
|
logger.startGroup("Load language configuration");
|
||||||
const config = await configUtils.initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, debugMode, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, logger);
|
const config = await configUtils.initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, logger);
|
||||||
analysisPaths.printPathFiltersWarning(config, logger);
|
analysisPaths.printPathFiltersWarning(config, logger);
|
||||||
logger.endGroup();
|
logger.endGroup();
|
||||||
return config;
|
return config;
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,yEAA2D;AAC3D,kEAAoD;AAEpD,gEAAkD;AAElD,qCAA2E;AAC3E,4DAA8C;AAG9C,mDAAwE;AACxE,6CAA+B;AAC/B,iCAA4C;AAErC,KAAK,UAAU,UAAU,CAC9B,SAA6B,EAC7B,UAA4B,EAC5B,OAAe,EACf,YAAoB,EACpB,OAA2B,EAC3B,MAAc;IAEd,MAAM,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC;IACxC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,IAAA,oBAAW,EAChD,SAAS,EACT,UAAU,EACV,OAAO,EACP,YAAY,EACZ,OAAO,EACP,MAAM,EACN,IAAI,CACL,CAAC;IACF,MAAM,MAAM,CAAC,YAAY,EAAE,CAAC;IAC5B,MAAM,CAAC,QAAQ,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC;AAClC,CAAC;AArBD,gCAqBC;AAEM,KAAK,UAAU,UAAU,C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AAC,UAAU,CAC7B,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAC7C,CAAC,IAAI,EAAE,CAAC;SACV;QACD,MAAM,MAAM,GAAG,0BAA0B,CAAC;QAC1C,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE;YAChC,MAAM,IAAI,UAAU,CAAC,UAAU,CAAC,MAAM,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE;gBAC/D,IAAI;gBACJ,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC;gBAChC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;aAC/B,CAAC,CAAC,IAAI,EAAE,CAAC;SACX;aAAM;YACL,MAAM,IAAI,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC,EAAE;gBAChE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;aAC/B,CAAC,CAAC,IAAI,EAAE,CAAC;SACX;KACF;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,CAAC,QAAQ,EAAE,CAAC;QAClB,MAAM,CAAC,OAAO,CACZ,gFAAgF,CAAC,IAAI;YACnF,qGAAqG;YACrG,oGAAoG;YACpG,iDAAiD,CACpD,CAAC;QACF,OAAO;KACR;IACD,MAAM,CAAC,QAAQ,EAAE,CAAC;AACpB,CAAC;AAtCD,8CAsCC"}
|
||||||
Generated
+9
-41
@@ -18,15 +18,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
__setModuleDefault(result, mod);
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const os = __importStar(require("os"));
|
const os = __importStar(require("os"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const commander_1 = require("commander");
|
const commander_1 = require("commander");
|
||||||
const del_1 = __importDefault(require("del"));
|
|
||||||
const analyze_1 = require("./analyze");
|
const analyze_1 = require("./analyze");
|
||||||
const autobuild_1 = require("./autobuild");
|
const autobuild_1 = require("./autobuild");
|
||||||
const codeql_1 = require("./codeql");
|
const codeql_1 = require("./codeql");
|
||||||
@@ -58,14 +54,11 @@ function getToolsDir(userInput) {
|
|||||||
return toolsDir;
|
return toolsDir;
|
||||||
}
|
}
|
||||||
const codeqlEnvJsonFilename = "codeql-env.json";
|
const codeqlEnvJsonFilename = "codeql-env.json";
|
||||||
function loadTracerEnvironment(config) {
|
|
||||||
const jsonEnvFile = path.join(config.tempDir, codeqlEnvJsonFilename);
|
|
||||||
return JSON.parse(fs.readFileSync(jsonEnvFile).toString("utf-8"));
|
|
||||||
}
|
|
||||||
// Imports the environment from codeqlEnvJsonFilename if not already present
|
// Imports the environment from codeqlEnvJsonFilename if not already present
|
||||||
function importTracerEnvironment(config) {
|
function importTracerEnvironment(config) {
|
||||||
if (!("ODASA_TRACER_CONFIGURATION" in process.env)) {
|
if (!("ODASA_TRACER_CONFIGURATION" in process.env)) {
|
||||||
const env = loadTracerEnvironment(config);
|
const jsonEnvFile = path.join(config.tempDir, codeqlEnvJsonFilename);
|
||||||
|
const env = JSON.parse(fs.readFileSync(jsonEnvFile).toString("utf-8"));
|
||||||
for (const key of Object.keys(env)) {
|
for (const key of Object.keys(env)) {
|
||||||
process.env[key] = env[key];
|
process.env[key] = env[key];
|
||||||
}
|
}
|
||||||
@@ -123,12 +116,6 @@ program
|
|||||||
.option("--debug", "Print more verbose output", false)
|
.option("--debug", "Print more verbose output", false)
|
||||||
.option("--trace-process-name <string>", "(Advanced, windows-only) Inject a windows tracer of this process into a process with the given process name.")
|
.option("--trace-process-name <string>", "(Advanced, windows-only) Inject a windows tracer of this process into a process with the given process name.")
|
||||||
.option("--trace-process-level <number>", "(Advanced, windows-only) Inject a windows tracer of this process into a parent process <number> levels up.")
|
.option("--trace-process-level <number>", "(Advanced, windows-only) Inject a windows tracer of this process into a parent process <number> levels up.")
|
||||||
.option("--ram <number>", "The amount of memory in MB that can be used by CodeQL extractors. " +
|
|
||||||
"By default, CodeQL extractors will use most of the memory available in the system. " +
|
|
||||||
'This input also sets the amount of memory that can later be used by the "analyze" command.')
|
|
||||||
.option("--threads <number>", "The number of threads that can be used by CodeQL extractors. " +
|
|
||||||
"By default, CodeQL extractors will use all the hardware threads available in the system. " +
|
|
||||||
'This input also sets the number of threads that can later be used by the "analyze" command.')
|
|
||||||
.action(async (cmd) => {
|
.action(async (cmd) => {
|
||||||
const logger = (0, logging_1.getRunnerLogger)(cmd.debug);
|
const logger = (0, logging_1.getRunnerLogger)(cmd.debug);
|
||||||
try {
|
try {
|
||||||
@@ -137,7 +124,7 @@ program
|
|||||||
const checkoutPath = cmd.checkoutPath || process.cwd();
|
const checkoutPath = cmd.checkoutPath || process.cwd();
|
||||||
// Wipe the temp dir
|
// Wipe the temp dir
|
||||||
logger.info(`Cleaning temp directory ${tempDir}`);
|
logger.info(`Cleaning temp directory ${tempDir}`);
|
||||||
await (0, del_1.default)(tempDir, { force: true });
|
fs.rmSync(tempDir, { recursive: true, force: true });
|
||||||
fs.mkdirSync(tempDir, { recursive: true });
|
fs.mkdirSync(tempDir, { recursive: true });
|
||||||
const auth = await (0, util_1.getGitHubAuth)(logger, cmd.githubAuth, cmd.githubAuthStdin);
|
const auth = await (0, util_1.getGitHubAuth)(logger, cmd.githubAuth, cmd.githubAuthStdin);
|
||||||
const apiDetails = {
|
const apiDetails = {
|
||||||
@@ -147,13 +134,6 @@ program
|
|||||||
};
|
};
|
||||||
const gitHubVersion = await (0, util_1.getGitHubVersion)(apiDetails);
|
const gitHubVersion = await (0, util_1.getGitHubVersion)(apiDetails);
|
||||||
(0, util_1.checkGitHubVersionInRange)(gitHubVersion, logger, util_1.Mode.runner);
|
(0, util_1.checkGitHubVersionInRange)(gitHubVersion, logger, util_1.Mode.runner);
|
||||||
// Limit RAM and threads for extractors. When running extractors, the CodeQL CLI obeys the
|
|
||||||
// CODEQL_RAM and CODEQL_THREADS environment variables to decide how much RAM and how many
|
|
||||||
// threads it would ask extractors to use. See help text for the "--ram" and "--threads"
|
|
||||||
// options at https://codeql.github.com/docs/codeql-cli/manual/database-trace-command/
|
|
||||||
// for details.
|
|
||||||
process.env["CODEQL_RAM"] = (0, util_1.getMemoryFlagValue)(cmd.ram).toString();
|
|
||||||
process.env["CODEQL_THREADS"] = (0, util_1.getThreadsFlagValue)(cmd.threads, logger).toString();
|
|
||||||
let codeql;
|
let codeql;
|
||||||
if (cmd.codeqlPath !== undefined) {
|
if (cmd.codeqlPath !== undefined) {
|
||||||
codeql = await (0, codeql_1.getCodeQL)(cmd.codeqlPath);
|
codeql = await (0, codeql_1.getCodeQL)(cmd.codeqlPath);
|
||||||
@@ -163,7 +143,7 @@ program
|
|||||||
}
|
}
|
||||||
await (0, util_1.enrichEnvironment)(util_1.Mode.runner, codeql);
|
await (0, util_1.enrichEnvironment)(util_1.Mode.runner, codeql);
|
||||||
const workspacePath = checkoutPath;
|
const workspacePath = checkoutPath;
|
||||||
const config = await (0, init_1.initConfig)(cmd.languages, cmd.queries, cmd.packs, cmd.configFile, undefined, false, (0, repository_1.parseRepositoryNwo)(cmd.repository), tempDir, toolsDir, codeql, workspacePath, gitHubVersion, apiDetails, logger);
|
const config = await (0, init_1.initConfig)(cmd.languages, cmd.queries, cmd.packs, cmd.configFile, undefined, (0, repository_1.parseRepositoryNwo)(cmd.repository), tempDir, toolsDir, codeql, workspacePath, gitHubVersion, apiDetails, logger);
|
||||||
const sourceRoot = checkoutPath;
|
const sourceRoot = checkoutPath;
|
||||||
const tracerConfig = await (0, init_1.runInit)(codeql, config, sourceRoot, parseTraceProcessName(), parseTraceProcessLevel());
|
const tracerConfig = await (0, init_1.runInit)(codeql, config, sourceRoot, parseTraceProcessName(), parseTraceProcessLevel());
|
||||||
if (tracerConfig === undefined) {
|
if (tracerConfig === undefined) {
|
||||||
@@ -260,15 +240,10 @@ program
|
|||||||
.option("--checkout-path <path>", "Checkout path. Default is the current working directory.")
|
.option("--checkout-path <path>", "Checkout path. Default is the current working directory.")
|
||||||
.option("--no-upload", "Do not upload results after analysis.")
|
.option("--no-upload", "Do not upload results after analysis.")
|
||||||
.option("--output-dir <dir>", "Directory to output SARIF files to. Default is in the temp directory.")
|
.option("--output-dir <dir>", "Directory to output SARIF files to. Default is in the temp directory.")
|
||||||
.option("--ram <ram>", "The amount of memory in MB that can be used by CodeQL for database finalization and query execution. " +
|
.option("--ram <ram>", "Amount of memory to use when running queries. Default is to use all available memory.")
|
||||||
'By default, this command will use the same amount of memory as previously set in the "init" command. ' +
|
|
||||||
'If the "init" command also does not have an explicit "ram" flag, this command will use most of the ' +
|
|
||||||
"memory available in the system.")
|
|
||||||
.option("--no-add-snippets", "Specify whether to include code snippets in the sarif output.")
|
.option("--no-add-snippets", "Specify whether to include code snippets in the sarif output.")
|
||||||
.option("--threads <threads>", "The number of threads that can be used by CodeQL for database finalization and query execution. " +
|
.option("--threads <threads>", "Number of threads to use when running queries. " +
|
||||||
'By default, this command will use the same number of threads as previously set in the "init" command. ' +
|
"Default is to use all available cores.")
|
||||||
'If the "init" command also does not have an explicit "threads" flag, this command will use all the ' +
|
|
||||||
"hardware threads available in the system.")
|
|
||||||
.option("--temp-dir <dir>", 'Directory to use for temporary files. Default is "./codeql-runner".')
|
.option("--temp-dir <dir>", 'Directory to use for temporary files. Default is "./codeql-runner".')
|
||||||
.option("--category <category>", "String used by Code Scanning for matching the analyses.")
|
.option("--category <category>", "String used by Code Scanning for matching the analyses.")
|
||||||
.option("--debug", "Print more verbose output", false)
|
.option("--debug", "Print more verbose output", false)
|
||||||
@@ -287,15 +262,8 @@ program
|
|||||||
url: (0, util_1.parseGitHubUrl)(cmd.githubUrl),
|
url: (0, util_1.parseGitHubUrl)(cmd.githubUrl),
|
||||||
};
|
};
|
||||||
const outputDir = cmd.outputDir || path.join(config.tempDir, "codeql-sarif");
|
const outputDir = cmd.outputDir || path.join(config.tempDir, "codeql-sarif");
|
||||||
let initEnv = {};
|
const threads = (0, util_1.getThreadsFlag)(cmd.threads, logger);
|
||||||
try {
|
const memory = (0, util_1.getMemoryFlag)(cmd.ram);
|
||||||
initEnv = loadTracerEnvironment(config);
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
// The init command did not generate a tracer environment file
|
|
||||||
}
|
|
||||||
const threads = (0, util_1.getThreadsFlag)(cmd.threads || initEnv["CODEQL_THREADS"], logger);
|
|
||||||
const memory = (0, util_1.getMemoryFlag)(cmd.ram || initEnv["CODEQL_RAM"]);
|
|
||||||
await (0, analyze_1.runFinalize)(outputDir, threads, memory, config, logger);
|
await (0, analyze_1.runFinalize)(outputDir, threads, memory, config, logger);
|
||||||
await (0, analyze_1.runQueries)(outputDir, memory, (0, util_1.getAddSnippetsFlag)(cmd.addSnippets), threads, cmd.category, config, logger);
|
await (0, analyze_1.runQueries)(outputDir, memory, (0, util_1.getAddSnippetsFlag)(cmd.addSnippets), threads, cmd.category, config, logger);
|
||||||
if (!cmd.upload) {
|
if (!cmd.upload) {
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
Generated
+1
-48
@@ -19,12 +19,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.mockFeatureFlagApiEndpoint = exports.getRecordingLogger = exports.setupActionsVars = exports.setupTests = void 0;
|
exports.setupActionsVars = exports.setupTests = void 0;
|
||||||
const github = __importStar(require("@actions/github"));
|
|
||||||
const sinon = __importStar(require("sinon"));
|
const sinon = __importStar(require("sinon"));
|
||||||
const apiClient = __importStar(require("./api-client"));
|
|
||||||
const CodeQL = __importStar(require("./codeql"));
|
const CodeQL = __importStar(require("./codeql"));
|
||||||
const util_1 = require("./util");
|
|
||||||
function wrapOutput(context) {
|
function wrapOutput(context) {
|
||||||
// Function signature taken from Socket.write.
|
// Function signature taken from Socket.write.
|
||||||
// Note there are two overloads:
|
// Note there are two overloads:
|
||||||
@@ -92,48 +89,4 @@ function setupActionsVars(tempDir, toolsDir) {
|
|||||||
process.env["RUNNER_TOOL_CACHE"] = toolsDir;
|
process.env["RUNNER_TOOL_CACHE"] = toolsDir;
|
||||||
}
|
}
|
||||||
exports.setupActionsVars = setupActionsVars;
|
exports.setupActionsVars = setupActionsVars;
|
||||||
function getRecordingLogger(messages) {
|
|
||||||
return {
|
|
||||||
debug: (message) => {
|
|
||||||
messages.push({ type: "debug", message });
|
|
||||||
console.debug(message);
|
|
||||||
},
|
|
||||||
info: (message) => {
|
|
||||||
messages.push({ type: "info", message });
|
|
||||||
console.info(message);
|
|
||||||
},
|
|
||||||
warning: (message) => {
|
|
||||||
messages.push({ type: "warning", message });
|
|
||||||
console.warn(message);
|
|
||||||
},
|
|
||||||
error: (message) => {
|
|
||||||
messages.push({ type: "error", message });
|
|
||||||
console.error(message);
|
|
||||||
},
|
|
||||||
isDebug: () => true,
|
|
||||||
startGroup: () => undefined,
|
|
||||||
endGroup: () => undefined,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
exports.getRecordingLogger = getRecordingLogger;
|
|
||||||
/** Mock the HTTP request to the feature flags enablement API endpoint. */
|
|
||||||
function mockFeatureFlagApiEndpoint(responseStatusCode, response) {
|
|
||||||
// Passing an auth token is required, so we just use a dummy value
|
|
||||||
const client = github.getOctokit("123");
|
|
||||||
const requestSpy = sinon.stub(client, "request");
|
|
||||||
const optInSpy = requestSpy.withArgs("GET /repos/:owner/:repo/code-scanning/codeql-action/features");
|
|
||||||
if (responseStatusCode < 300) {
|
|
||||||
optInSpy.resolves({
|
|
||||||
status: responseStatusCode,
|
|
||||||
data: response,
|
|
||||||
headers: {},
|
|
||||||
url: "GET /repos/:owner/:repo/code-scanning/codeql-action/features",
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
optInSpy.throws(new util_1.HTTPError("some error message", responseStatusCode));
|
|
||||||
}
|
|
||||||
sinon.stub(apiClient, "getApiClient").value(() => client);
|
|
||||||
}
|
|
||||||
exports.mockFeatureFlagApiEndpoint = mockFeatureFlagApiEndpoint;
|
|
||||||
//# sourceMappingURL=testing-utils.js.map
|
//# sourceMappingURL=testing-utils.js.map
|
||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"testing-utils.js","sourceRoot":"","sources":["../src/testing-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,wDAA0C;AAE1C,6CAA+B;AAE/B,wDAA0C;AAC1C,iDAAmC;AAEnC,iCAAmC;AASnC,SAAS,UAAU,CAAC,OAAoB;IACtC,8CAA8C;IAC9C,gCAAgC;IAChC,2EAA2E;IAC3E,2FAA2F;IAC3F,OAAO,CACL,KAA0B,EAC1B,QAAiB,EACjB,EAA0B,EACjB,EAAE;QACX,2CAA2C;QAC3C,IAAI,EAAE,KAAK,SAAS,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE;YACtD,EAAE,GAAG,QAAQ,CAAC;YACd,QAAQ,GAAG,SAAS,CAAC;SACtB;QAED,oBAAoB;QACpB,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,OAAO,CAAC,UAAU,IAAI,KAAK,CAAC;SAC7B;aAAM;YACL,OAAO,CAAC,UAAU,IAAI,IAAI,WAAW,CAAC,QAAQ,IAAI,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;SAC1E;QAED,iDAAiD;QACjD,IAAI,EAAE,KAAK,SAAS,IAAI,OAAO,EAAE,KAAK,UAAU,EAAE;YAChD,EAAE,EAAE,CAAC;SACN;QAED,OAAO,IAAI,CAAC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 var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
__setModuleDefault(result, mod);
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.downloadTool = exports.findAllVersions = exports.find = exports.cacheDir = exports.extractTar = void 0;
|
exports.downloadTool = exports.findAllVersions = exports.find = exports.cacheDir = exports.extractTar = void 0;
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
@@ -30,7 +27,6 @@ const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
|
|||||||
const io = __importStar(require("@actions/io"));
|
const io = __importStar(require("@actions/io"));
|
||||||
const actionsToolcache = __importStar(require("@actions/tool-cache"));
|
const actionsToolcache = __importStar(require("@actions/tool-cache"));
|
||||||
const safeWhich = __importStar(require("@chrisgavin/safe-which"));
|
const safeWhich = __importStar(require("@chrisgavin/safe-which"));
|
||||||
const del_1 = __importDefault(require("del"));
|
|
||||||
const semver = __importStar(require("semver"));
|
const semver = __importStar(require("semver"));
|
||||||
const uuid_1 = require("uuid");
|
const uuid_1 = require("uuid");
|
||||||
const util_1 = require("./util");
|
const util_1 = require("./util");
|
||||||
@@ -127,7 +123,7 @@ async function cacheDir(sourceDir, tool, version, toolCacheDir, logger) {
|
|||||||
throw new Error("sourceDir is not a directory");
|
throw new Error("sourceDir is not a directory");
|
||||||
}
|
}
|
||||||
// Create the tool dir
|
// Create the tool dir
|
||||||
const destPath = await createToolPath(tool, version, arch, toolCacheDir, logger);
|
const destPath = createToolPath(tool, version, arch, toolCacheDir, logger);
|
||||||
// copy each child item. do not move. move can fail on Windows
|
// copy each child item. do not move. move can fail on Windows
|
||||||
// due to anti-virus software having an open handle on a file.
|
// due to anti-virus software having an open handle on a file.
|
||||||
for (const itemName of fs.readdirSync(sourceDir)) {
|
for (const itemName of fs.readdirSync(sourceDir)) {
|
||||||
@@ -236,12 +232,12 @@ function createExtractFolder(tempDir) {
|
|||||||
}
|
}
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
async function createToolPath(tool, version, arch, toolCacheDir, logger) {
|
function createToolPath(tool, version, arch, toolCacheDir, logger) {
|
||||||
const folderPath = path.join(toolCacheDir, tool, semver.clean(version) || version, arch || "");
|
const folderPath = path.join(toolCacheDir, tool, semver.clean(version) || version, arch || "");
|
||||||
logger.debug(`destination ${folderPath}`);
|
logger.debug(`destination ${folderPath}`);
|
||||||
const markerPath = `${folderPath}.complete`;
|
const markerPath = `${folderPath}.complete`;
|
||||||
await (0, del_1.default)(folderPath, { force: true });
|
fs.rmSync(folderPath, { recursive: true, force: true });
|
||||||
await (0, del_1.default)(markerPath, { force: true });
|
fs.rmSync(markerPath, { recursive: true, force: true });
|
||||||
fs.mkdirSync(folderPath, { recursive: true });
|
fs.mkdirSync(folderPath, { recursive: true });
|
||||||
return folderPath;
|
return folderPath;
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Generated
+8
@@ -44,6 +44,10 @@ async function toolrunnerErrorCatcher(commandLine, args, matchers, options) {
|
|||||||
if (((_a = options === null || options === void 0 ? void 0 : options.listeners) === null || _a === void 0 ? void 0 : _a.stdout) !== undefined) {
|
if (((_a = options === null || options === void 0 ? void 0 : options.listeners) === null || _a === void 0 ? void 0 : _a.stdout) !== undefined) {
|
||||||
options.listeners.stdout(data);
|
options.listeners.stdout(data);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// if no stdout listener was originally defined then we match default behavior of Toolrunner
|
||||||
|
process.stdout.write(data);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
stderr: (data) => {
|
stderr: (data) => {
|
||||||
var _a;
|
var _a;
|
||||||
@@ -51,6 +55,10 @@ async function toolrunnerErrorCatcher(commandLine, args, matchers, options) {
|
|||||||
if (((_a = options === null || options === void 0 ? void 0 : options.listeners) === null || _a === void 0 ? void 0 : _a.stderr) !== undefined) {
|
if (((_a = options === null || options === void 0 ? void 0 : options.listeners) === null || _a === void 0 ? void 0 : _a.stderr) !== undefined) {
|
||||||
options.listeners.stderr(data);
|
options.listeners.stderr(data);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// if no stderr listener was originally defined then we match default behavior of Toolrunner
|
||||||
|
process.stderr.write(data);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
// we capture the original return code or error so that if no match is found we can duplicate the behavior
|
// we capture the original return code or error so that if no match is found we can duplicate the behavior
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"toolrunner-error-catcher.js","sourceRoot":"","sources":["../src/toolrunner-error-catcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA,yEAA2D;AAC3D,kEAAoD;AAIpD;;;;;;;;;;GAUG;AACI,KAAK,UAAU,sBAAsB,CAC1C,WAAmB,EACnB,IAAe,EACf,QAAyB,EACzB,OAAwB;;IAExB,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,MAAM,GAAG,EAAE,CAAC;IAEhB,MAAM,SAAS,GAAG;QAChB,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE;;YACvB,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC1B,IAAI,CAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,0CAAE,MAAM,MAAK,SAAS,EAAE;gBAC5C,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;aAChC;QACH,CAAC;QACD,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE;;YACvB,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC1B,IAAI,CAAA,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,0CA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AAC,WAAW,CAAC,EACtC,IAAI,EACJ;YACE,GAAG,OAAO;YACV,SAAS;YACT,gBAAgB,EAAE,IAAI,EAAE,wDAAwD;SACjF,CACF,CAAC,IAAI,EAAE,CAAC;KACV;IAAC,OAAO,CAAC,EAAE;QACV,WAAW,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;KAC7D;IAED,mEAAmE;IACnE,IAAI,WAAW,KAAK,CAAC;QAAE,OAAO,WAAW,CAAC;IAE1C,IAAI,QAAQ,EAAE;QACZ,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;YAC9B,IACE,OAAO,CAAC,QAAQ,KAAK,WAAW;iBAChC,MAAA,OAAO,CAAC,WAAW,0CAAE,IAAI,CAAC,MAAM,CAAC,CAAA;iBACjC,MAAA,OAAO,CAAC,WAAW,0CAAE,IAAI,CAAC,MAAM,CAAC,CAAA,EACjC;gBACA,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;aAClC;SACF;KACF;IAED,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE;QACnC,qFAAqF;QACrF,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,gBAAgB,EAAE;YAC7B,OAAO,WAAW,CAAC;SACpB;aAAM;YACL,MAAM,IAAI,KAAK,CACb,gBAAgB,WAAW,2BAA2B,WAAW,EAAE,CACpE,CAAC;SACH;KACF;SAAM;QACL,MAAM,WAAW,CAAC;KACnB;AACH,CAAC;AAzED,wDAyEC"}
|
||||||
Generated
+9
-9
@@ -182,15 +182,15 @@ async function getCombinedTracerConfig(config, codeql) {
|
|||||||
tracedLanguageConfigs[language] = await getTracerConfigForLanguage(codeql, config, language);
|
tracedLanguageConfigs[language] = await getTracerConfigForLanguage(codeql, config, language);
|
||||||
}
|
}
|
||||||
mainTracerConfig = concatTracerConfigs(tracedLanguageConfigs, config);
|
mainTracerConfig = concatTracerConfigs(tracedLanguageConfigs, config);
|
||||||
// Add a couple more variables
|
}
|
||||||
mainTracerConfig.env["ODASA_TRACER_CONFIGURATION"] = mainTracerConfig.spec;
|
// Add a couple more variables
|
||||||
const codeQLDir = path.dirname(codeql.getPath());
|
mainTracerConfig.env["ODASA_TRACER_CONFIGURATION"] = mainTracerConfig.spec;
|
||||||
if (process.platform === "darwin") {
|
const codeQLDir = path.dirname(codeql.getPath());
|
||||||
mainTracerConfig.env["DYLD_INSERT_LIBRARIES"] = path.join(codeQLDir, "tools", "osx64", "libtrace.dylib");
|
if (process.platform === "darwin") {
|
||||||
}
|
mainTracerConfig.env["DYLD_INSERT_LIBRARIES"] = path.join(codeQLDir, "tools", "osx64", "libtrace.dylib");
|
||||||
else if (process.platform !== "win32") {
|
}
|
||||||
mainTracerConfig.env["LD_PRELOAD"] = path.join(codeQLDir, "tools", "linux64", "${LIB}trace.so");
|
else if (process.platform !== "win32") {
|
||||||
}
|
mainTracerConfig.env["LD_PRELOAD"] = path.join(codeQLDir, "tools", "linux64", "${LIB}trace.so");
|
||||||
}
|
}
|
||||||
// On macos it's necessary to prefix the build command with the runner executable
|
// On macos it's necessary to prefix the build command with the runner executable
|
||||||
// on order to trace when System Integrity Protection is enabled.
|
// on order to trace when System Integrity Protection is enabled.
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Generated
-1
@@ -44,7 +44,6 @@ function getTestConfig(tmpDir) {
|
|||||||
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
||||||
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
||||||
packs: {},
|
packs: {},
|
||||||
debugMode: false,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// A very minimal setup
|
// A very minimal setup
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Generated
+13
-85
@@ -22,7 +22,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.validateUniqueCategory = exports.waitForProcessing = exports.buildPayload = exports.validateSarifFileSchema = exports.countResultsInSarif = exports.uploadFromRunner = exports.uploadFromActions = exports.findSarifFilesInDir = exports.populateRunAutomationDetails = exports.combineSarifFiles = void 0;
|
exports.buildPayload = exports.validateSarifFileSchema = exports.countResultsInSarif = exports.uploadFromRunner = exports.uploadFromActions = exports.findSarifFilesInDir = exports.populateRunAutomationDetails = exports.combineSarifFiles = void 0;
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const zlib_1 = __importDefault(require("zlib"));
|
const zlib_1 = __importDefault(require("zlib"));
|
||||||
@@ -105,7 +105,6 @@ async function uploadPayload(payload, repositoryNwo, apiDetails, logger) {
|
|||||||
});
|
});
|
||||||
logger.debug(`response status: ${response.status}`);
|
logger.debug(`response status: ${response.status}`);
|
||||||
logger.info("Successfully uploaded results");
|
logger.info("Successfully uploaded results");
|
||||||
return response.data.id;
|
|
||||||
}
|
}
|
||||||
// Recursively walks a directory and returns all SARIF files it finds.
|
// Recursively walks a directory and returns all SARIF files it finds.
|
||||||
// Does not follow symlinks.
|
// Does not follow symlinks.
|
||||||
@@ -244,7 +243,14 @@ exports.buildPayload = buildPayload;
|
|||||||
async function uploadFiles(sarifFiles, repositoryNwo, commitOid, ref, analysisKey, category, analysisName, workflowRunID, sourceRoot, environment, gitHubVersion, apiDetails, logger) {
|
async function uploadFiles(sarifFiles, repositoryNwo, commitOid, ref, analysisKey, category, analysisName, workflowRunID, sourceRoot, environment, gitHubVersion, apiDetails, logger) {
|
||||||
logger.startGroup("Uploading results");
|
logger.startGroup("Uploading results");
|
||||||
logger.info(`Processing sarif files: ${JSON.stringify(sarifFiles)}`);
|
logger.info(`Processing sarif files: ${JSON.stringify(sarifFiles)}`);
|
||||||
validateUniqueCategory(category);
|
if (util.isActions()) {
|
||||||
|
// This check only works on actions as env vars don't persist between calls to the runner
|
||||||
|
const sentinelEnvVar = "CODEQL_UPLOAD_SARIF";
|
||||||
|
if (process.env[sentinelEnvVar]) {
|
||||||
|
throw new Error("Aborting upload: only one run of the codeql/analyze or codeql/upload-sarif actions is allowed per job");
|
||||||
|
}
|
||||||
|
core.exportVariable(sentinelEnvVar, sentinelEnvVar);
|
||||||
|
}
|
||||||
// Validate that the files we were asked to upload are all valid SARIF files
|
// Validate that the files we were asked to upload are all valid SARIF files
|
||||||
for (const file of sarifFiles) {
|
for (const file of sarifFiles) {
|
||||||
validateSarifFileSchema(file, logger);
|
validateSarifFileSchema(file, logger);
|
||||||
@@ -264,90 +270,12 @@ async function uploadFiles(sarifFiles, repositoryNwo, commitOid, ref, analysisKe
|
|||||||
const numResultInSarif = countResultsInSarif(sarifPayload);
|
const numResultInSarif = countResultsInSarif(sarifPayload);
|
||||||
logger.debug(`Number of results in upload: ${numResultInSarif}`);
|
logger.debug(`Number of results in upload: ${numResultInSarif}`);
|
||||||
// Make the upload
|
// Make the upload
|
||||||
const sarifID = await uploadPayload(payload, repositoryNwo, apiDetails, logger);
|
await uploadPayload(payload, repositoryNwo, apiDetails, logger);
|
||||||
logger.endGroup();
|
logger.endGroup();
|
||||||
return {
|
return {
|
||||||
statusReport: {
|
raw_upload_size_bytes: rawUploadSizeBytes,
|
||||||
raw_upload_size_bytes: rawUploadSizeBytes,
|
zipped_upload_size_bytes: zippedUploadSizeBytes,
|
||||||
zipped_upload_size_bytes: zippedUploadSizeBytes,
|
num_results_in_sarif: numResultInSarif,
|
||||||
num_results_in_sarif: numResultInSarif,
|
|
||||||
},
|
|
||||||
sarifID,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const STATUS_CHECK_FREQUENCY_MILLISECONDS = 5 * 1000;
|
|
||||||
const STATUS_CHECK_TIMEOUT_MILLISECONDS = 2 * 60 * 1000;
|
|
||||||
// Waits until either the analysis is successfully processed, a processing error is reported, or STATUS_CHECK_TIMEOUT_MILLISECONDS elapses.
|
|
||||||
async function waitForProcessing(repositoryNwo, sarifID, apiDetails, logger) {
|
|
||||||
logger.startGroup("Waiting for processing to finish");
|
|
||||||
const client = api.getApiClient(apiDetails);
|
|
||||||
const statusCheckingStarted = Date.now();
|
|
||||||
// eslint-disable-next-line no-constant-condition
|
|
||||||
while (true) {
|
|
||||||
if (Date.now() >
|
|
||||||
statusCheckingStarted + STATUS_CHECK_TIMEOUT_MILLISECONDS) {
|
|
||||||
// If the analysis hasn't finished processing in the allotted time, we continue anyway rather than failing.
|
|
||||||
// It's possible the analysis will eventually finish processing, but it's not worth spending more Actions time waiting.
|
|
||||||
logger.warning("Timed out waiting for analysis to finish processing. Continuing.");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const response = await client.request("GET /repos/:owner/:repo/code-scanning/sarifs/:sarif_id", {
|
|
||||||
owner: repositoryNwo.owner,
|
|
||||||
repo: repositoryNwo.repo,
|
|
||||||
sarif_id: sarifID,
|
|
||||||
});
|
|
||||||
const status = response.data.processing_status;
|
|
||||||
logger.info(`Analysis upload status is ${status}.`);
|
|
||||||
if (status === "complete") {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (status === "failed") {
|
|
||||||
throw new Error(`Code Scanning could not process the submitted SARIF file:\n${response.data.errors}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
if (util.isHTTPError(e)) {
|
|
||||||
switch (e.status) {
|
|
||||||
case 404:
|
|
||||||
logger.debug("Analysis is not found yet...");
|
|
||||||
break; // Note this breaks from the case statement, not the outer loop.
|
|
||||||
default:
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
await util.delay(STATUS_CHECK_FREQUENCY_MILLISECONDS);
|
|
||||||
}
|
|
||||||
logger.endGroup();
|
|
||||||
}
|
|
||||||
exports.waitForProcessing = waitForProcessing;
|
|
||||||
function validateUniqueCategory(category) {
|
|
||||||
if (util.isActions()) {
|
|
||||||
// This check only works on actions as env vars don't persist between calls to the runner
|
|
||||||
const sentinelEnvVar = `CODEQL_UPLOAD_SARIF${category ? `_${sanitize(category)}` : ""}`;
|
|
||||||
if (process.env[sentinelEnvVar]) {
|
|
||||||
throw new Error("Aborting upload: only one run of the codeql/analyze or codeql/upload-sarif actions is allowed per job per category. " +
|
|
||||||
"Please specify a unique `category` to call this action multiple times. " +
|
|
||||||
`Category: ${category ? category : "(none)"}`);
|
|
||||||
}
|
|
||||||
core.exportVariable(sentinelEnvVar, sentinelEnvVar);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.validateUniqueCategory = validateUniqueCategory;
|
|
||||||
/**
|
|
||||||
* Santizes a string to be used as an environment variable name.
|
|
||||||
* This will replace all non-alphanumeric characters with underscores.
|
|
||||||
* There could still be some false category clashes if two uploads
|
|
||||||
* occur that differ only in their non-alphanumeric characters. This is
|
|
||||||
* unlikely.
|
|
||||||
*
|
|
||||||
* @param str the initial value to sanitize
|
|
||||||
*/
|
|
||||||
function sanitize(str) {
|
|
||||||
return str.replace(/[^a-zA-Z0-9_]/g, "_");
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=upload-lib.js.map
|
//# sourceMappingURL=upload-lib.js.map
|
||||||
File diff suppressed because one or more lines are too long
Generated
-16
@@ -113,20 +113,4 @@ ava_1.default.beforeEach(() => {
|
|||||||
modifiedSarif = uploadLib.populateRunAutomationDetails(sarif, undefined, analysisKey, '{"os": "linux", "language": "javascript"}');
|
modifiedSarif = uploadLib.populateRunAutomationDetails(sarif, undefined, analysisKey, '{"os": "linux", "language": "javascript"}');
|
||||||
t.deepEqual(modifiedSarif, expectedSarif);
|
t.deepEqual(modifiedSarif, expectedSarif);
|
||||||
});
|
});
|
||||||
(0, ava_1.default)("validateUniqueCategory", (t) => {
|
|
||||||
t.notThrows(() => uploadLib.validateUniqueCategory(undefined));
|
|
||||||
t.throws(() => uploadLib.validateUniqueCategory(undefined));
|
|
||||||
t.notThrows(() => uploadLib.validateUniqueCategory("abc"));
|
|
||||||
t.throws(() => uploadLib.validateUniqueCategory("abc"));
|
|
||||||
t.notThrows(() => uploadLib.validateUniqueCategory("def"));
|
|
||||||
t.throws(() => uploadLib.validateUniqueCategory("def"));
|
|
||||||
// Our category sanitization is not perfect. Here are some examples
|
|
||||||
// of where we see false clashes
|
|
||||||
t.notThrows(() => uploadLib.validateUniqueCategory("abc/def"));
|
|
||||||
t.throws(() => uploadLib.validateUniqueCategory("abc@def"));
|
|
||||||
t.throws(() => uploadLib.validateUniqueCategory("abc_def"));
|
|
||||||
t.throws(() => uploadLib.validateUniqueCategory("abc def"));
|
|
||||||
// this one is fine
|
|
||||||
t.notThrows(() => uploadLib.validateUniqueCategory("abc_ def"));
|
|
||||||
});
|
|
||||||
//# sourceMappingURL=upload-lib.test.js.map
|
//# sourceMappingURL=upload-lib.test.js.map
|
||||||
File diff suppressed because one or more lines are too long
Generated
+2
-6
@@ -22,7 +22,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||||||
const core = __importStar(require("@actions/core"));
|
const core = __importStar(require("@actions/core"));
|
||||||
const actionsUtil = __importStar(require("./actions-util"));
|
const actionsUtil = __importStar(require("./actions-util"));
|
||||||
const logging_1 = require("./logging");
|
const logging_1 = require("./logging");
|
||||||
const repository_1 = require("./repository");
|
|
||||||
const upload_lib = __importStar(require("./upload-lib"));
|
const upload_lib = __importStar(require("./upload-lib"));
|
||||||
const util_1 = require("./util");
|
const util_1 = require("./util");
|
||||||
// eslint-disable-next-line import/no-commonjs
|
// eslint-disable-next-line import/no-commonjs
|
||||||
@@ -47,11 +46,8 @@ async function run() {
|
|||||||
url: (0, util_1.getRequiredEnvParam)("GITHUB_SERVER_URL"),
|
url: (0, util_1.getRequiredEnvParam)("GITHUB_SERVER_URL"),
|
||||||
};
|
};
|
||||||
const gitHubVersion = await (0, util_1.getGitHubVersion)(apiDetails);
|
const gitHubVersion = await (0, util_1.getGitHubVersion)(apiDetails);
|
||||||
const uploadResult = await upload_lib.uploadFromActions(actionsUtil.getRequiredInput("sarif_file"), gitHubVersion, apiDetails, (0, logging_1.getActionsLogger)());
|
const uploadStats = await upload_lib.uploadFromActions(actionsUtil.getRequiredInput("sarif_file"), gitHubVersion, apiDetails, (0, logging_1.getActionsLogger)());
|
||||||
if (actionsUtil.getRequiredInput("wait-for-processing") === "true") {
|
await sendSuccessStatusReport(startedAt, uploadStats);
|
||||||
await upload_lib.waitForProcessing((0, repository_1.parseRepositoryNwo)((0, util_1.getRequiredEnvParam)("GITHUB_REPOSITORY")), uploadResult.sarifID, apiDetails, (0, logging_1.getActionsLogger)());
|
|
||||||
}
|
|
||||||
await sendSuccessStatusReport(startedAt, uploadResult.statusReport);
|
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
const message = error instanceof Error ? error.message : String(error);
|
const message = error instanceof Error ? error.message : String(error);
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"upload-sarif-action.js","sourceRoot":"","sources":["../src/upload-sarif-action.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsC;AAEtC,4DAA8C;AAC9C,uCAA6C;AAC7C,6CAAkD;AAClD,yDAA2C;AAC3C,iCAKgB;AAEhB,8CAA8C;AAC9C,MAAM,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAMvC,KAAK,UAAU,uBAAuB,CACpC,SAAe,EACf,WAA0C;IAE1C,MAAM,gBAAgB,GAAG,MAAM,WAAW,CAAC,sBAAsB,CAC/D,cAAc,EACd,SAAS,EACT,SAAS,CACV,CAAC;IACF,MAAM,YAAY,GAA4B;QAC5C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N,CACF,CAAC;QACF,OAAO;KACR;AACH,CAAC;AAED,KAAK,UAAU,UAAU;IACvB,IAAI;QACF,MAAM,GAAG,EAAE,CAAC;KACb;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,SAAS,CAAC,sCAAsC,KAAK,EAAE,CAAC,CAAC;QAC9D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;KACpB;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"}
|
||||||
Generated
+13
-73
@@ -18,33 +18,20 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
__setModuleDefault(result, mod);
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.isGoodVersion = exports.delay = exports.bundleDb = exports.codeQlVersionAbove = exports.isHTTPError = exports.HTTPError = exports.getRequiredEnvParam = exports.isActions = exports.getMode = exports.enrichEnvironment = exports.initializeEnvironment = exports.Mode = exports.assertNever = exports.getGitHubAuth = exports.apiVersionInRange = exports.DisallowedAPIVersionReason = exports.checkGitHubVersionInRange = exports.getGitHubVersion = exports.GitHubVariant = exports.parseGitHubUrl = exports.getCodeQLDatabasePath = exports.getThreadsFlag = exports.getThreadsFlagValue = exports.getAddSnippetsFlag = exports.getMemoryFlag = exports.getMemoryFlagValue = exports.withTmpDir = exports.getToolNames = exports.getExtraOptionsEnvParam = exports.DEBUG_ARTIFACT_NAME = exports.GITHUB_DOTCOM_URL = void 0;
|
exports.codeQlVersionAbove = exports.isHTTPError = exports.HTTPError = exports.getRequiredEnvParam = exports.isActions = exports.getMode = exports.enrichEnvironment = exports.initializeEnvironment = exports.Mode = exports.assertNever = exports.getGitHubAuth = exports.apiVersionInRange = exports.DisallowedAPIVersionReason = exports.checkGitHubVersionInRange = exports.getGitHubVersion = exports.GitHubVariant = exports.parseGitHubUrl = exports.getCodeQLDatabasePath = exports.getThreadsFlag = exports.getAddSnippetsFlag = exports.getMemoryFlag = exports.withTmpDir = exports.getToolNames = exports.getExtraOptionsEnvParam = exports.GITHUB_DOTCOM_URL = void 0;
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const os = __importStar(require("os"));
|
const os = __importStar(require("os"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const core = __importStar(require("@actions/core"));
|
const core = __importStar(require("@actions/core"));
|
||||||
const del_1 = __importDefault(require("del"));
|
|
||||||
const semver = __importStar(require("semver"));
|
const semver = __importStar(require("semver"));
|
||||||
const api_client_1 = require("./api-client");
|
const api_client_1 = require("./api-client");
|
||||||
const apiCompatibility = __importStar(require("./api-compatibility.json"));
|
const apiCompatibility = __importStar(require("./api-compatibility.json"));
|
||||||
const codeql_1 = require("./codeql");
|
const codeql_1 = require("./codeql");
|
||||||
/**
|
|
||||||
* Specifies bundle versions that are known to be broken
|
|
||||||
* and will not be used if found in the toolcache.
|
|
||||||
*/
|
|
||||||
const BROKEN_VERSIONS = ["0.0.0-20211207"];
|
|
||||||
/**
|
/**
|
||||||
* The URL for github.com.
|
* The URL for github.com.
|
||||||
*/
|
*/
|
||||||
exports.GITHUB_DOTCOM_URL = "https://github.com";
|
exports.GITHUB_DOTCOM_URL = "https://github.com";
|
||||||
/**
|
|
||||||
* Name of the debugging artifact.
|
|
||||||
*/
|
|
||||||
exports.DEBUG_ARTIFACT_NAME = "debug-artifacts";
|
|
||||||
/**
|
/**
|
||||||
* Get the extra options for the codeql commands.
|
* Get the extra options for the codeql commands.
|
||||||
*/
|
*/
|
||||||
@@ -90,7 +77,7 @@ async function withTmpDir(body) {
|
|||||||
const symlinkSubdir = path.join(tmpDir, "symlink");
|
const symlinkSubdir = path.join(tmpDir, "symlink");
|
||||||
fs.symlinkSync(realSubdir, symlinkSubdir, "dir");
|
fs.symlinkSync(realSubdir, symlinkSubdir, "dir");
|
||||||
const result = await body(symlinkSubdir);
|
const result = await body(symlinkSubdir);
|
||||||
await (0, del_1.default)(tmpDir, { force: true });
|
fs.rmSync(tmpDir, { recursive: true, force: true });
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
exports.withTmpDir = withTmpDir;
|
exports.withTmpDir = withTmpDir;
|
||||||
@@ -106,13 +93,13 @@ function getSystemReservedMemoryMegaBytes() {
|
|||||||
return 1024 * (process.platform === "win32" ? 1.5 : 1);
|
return 1024 * (process.platform === "win32" ? 1.5 : 1);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Get the value of the codeql `--ram` flag as configured by the `ram` input.
|
* Get the codeql `--ram` flag as configured by the `ram` input. If no value was
|
||||||
* If no value was specified, the total available memory will be used minus a
|
* specified, the total available memory will be used minus a threshold
|
||||||
* threshold reserved for the OS.
|
* reserved for the OS.
|
||||||
*
|
*
|
||||||
* @returns {number} the amount of RAM to use, in megabytes
|
* @returns string
|
||||||
*/
|
*/
|
||||||
function getMemoryFlagValue(userInput) {
|
function getMemoryFlag(userInput) {
|
||||||
let memoryToUseMegaBytes;
|
let memoryToUseMegaBytes;
|
||||||
if (userInput) {
|
if (userInput) {
|
||||||
memoryToUseMegaBytes = Number(userInput);
|
memoryToUseMegaBytes = Number(userInput);
|
||||||
@@ -126,18 +113,7 @@ function getMemoryFlagValue(userInput) {
|
|||||||
const reservedMemoryMegaBytes = getSystemReservedMemoryMegaBytes();
|
const reservedMemoryMegaBytes = getSystemReservedMemoryMegaBytes();
|
||||||
memoryToUseMegaBytes = totalMemoryMegaBytes - reservedMemoryMegaBytes;
|
memoryToUseMegaBytes = totalMemoryMegaBytes - reservedMemoryMegaBytes;
|
||||||
}
|
}
|
||||||
return Math.floor(memoryToUseMegaBytes);
|
return `--ram=${Math.floor(memoryToUseMegaBytes)}`;
|
||||||
}
|
|
||||||
exports.getMemoryFlagValue = getMemoryFlagValue;
|
|
||||||
/**
|
|
||||||
* Get the codeql `--ram` flag as configured by the `ram` input. If no value was
|
|
||||||
* specified, the total available memory will be used minus a threshold
|
|
||||||
* reserved for the OS.
|
|
||||||
*
|
|
||||||
* @returns string
|
|
||||||
*/
|
|
||||||
function getMemoryFlag(userInput) {
|
|
||||||
return `--ram=${getMemoryFlagValue(userInput)}`;
|
|
||||||
}
|
}
|
||||||
exports.getMemoryFlag = getMemoryFlag;
|
exports.getMemoryFlag = getMemoryFlag;
|
||||||
/**
|
/**
|
||||||
@@ -154,14 +130,14 @@ function getAddSnippetsFlag(userInput) {
|
|||||||
}
|
}
|
||||||
exports.getAddSnippetsFlag = getAddSnippetsFlag;
|
exports.getAddSnippetsFlag = getAddSnippetsFlag;
|
||||||
/**
|
/**
|
||||||
* Get the value of the codeql `--threads` flag specified for the `threads`
|
* Get the codeql `--threads` value specified for the `threads` input.
|
||||||
* input. If no value was specified, all available threads will be used.
|
* If no value was specified, all available threads will be used.
|
||||||
*
|
*
|
||||||
* The value will be capped to the number of available CPUs.
|
* The value will be capped to the number of available CPUs.
|
||||||
*
|
*
|
||||||
* @returns {number}
|
* @returns string
|
||||||
*/
|
*/
|
||||||
function getThreadsFlagValue(userInput, logger) {
|
function getThreadsFlag(userInput, logger) {
|
||||||
let numThreads;
|
let numThreads;
|
||||||
const maxThreads = os.cpus().length;
|
const maxThreads = os.cpus().length;
|
||||||
if (userInput) {
|
if (userInput) {
|
||||||
@@ -183,19 +159,7 @@ function getThreadsFlagValue(userInput, logger) {
|
|||||||
// Default to using all threads
|
// Default to using all threads
|
||||||
numThreads = maxThreads;
|
numThreads = maxThreads;
|
||||||
}
|
}
|
||||||
return numThreads;
|
return `--threads=${numThreads}`;
|
||||||
}
|
|
||||||
exports.getThreadsFlagValue = getThreadsFlagValue;
|
|
||||||
/**
|
|
||||||
* Get the codeql `--threads` flag specified for the `threads` input.
|
|
||||||
* If no value was specified, all available threads will be used.
|
|
||||||
*
|
|
||||||
* The value will be capped to the number of available CPUs.
|
|
||||||
*
|
|
||||||
* @returns string
|
|
||||||
*/
|
|
||||||
function getThreadsFlag(userInput, logger) {
|
|
||||||
return `--threads=${getThreadsFlagValue(userInput, logger)}`;
|
|
||||||
}
|
}
|
||||||
exports.getThreadsFlag = getThreadsFlag;
|
exports.getThreadsFlag = getThreadsFlag;
|
||||||
/**
|
/**
|
||||||
@@ -491,28 +455,4 @@ async function codeQlVersionAbove(codeql, requiredVersion) {
|
|||||||
return semver.gte(await codeql.getVersion(), requiredVersion);
|
return semver.gte(await codeql.getVersion(), requiredVersion);
|
||||||
}
|
}
|
||||||
exports.codeQlVersionAbove = codeQlVersionAbove;
|
exports.codeQlVersionAbove = codeQlVersionAbove;
|
||||||
// Create a bundle for the given DB, if it doesn't already exist
|
|
||||||
async function bundleDb(config, language, codeql) {
|
|
||||||
const databasePath = getCodeQLDatabasePath(config, language);
|
|
||||||
const databaseBundlePath = path.resolve(config.dbLocation, `${databasePath}.zip`);
|
|
||||||
// For a tiny bit of added safety, delete the file if it exists.
|
|
||||||
// The file is probably from an earlier call to this function, either
|
|
||||||
// as part of this action step or a previous one, but it could also be
|
|
||||||
// from somewhere else or someone trying to make the action upload a
|
|
||||||
// non-database file.
|
|
||||||
if (fs.existsSync(databaseBundlePath)) {
|
|
||||||
await (0, del_1.default)(databaseBundlePath, { force: true });
|
|
||||||
}
|
|
||||||
await codeql.databaseBundle(databasePath, databaseBundlePath);
|
|
||||||
return databaseBundlePath;
|
|
||||||
}
|
|
||||||
exports.bundleDb = bundleDb;
|
|
||||||
async function delay(milliseconds) {
|
|
||||||
return new Promise((resolve) => setTimeout(resolve, milliseconds));
|
|
||||||
}
|
|
||||||
exports.delay = delay;
|
|
||||||
function isGoodVersion(versionSpec) {
|
|
||||||
return !BROKEN_VERSIONS.includes(versionSpec);
|
|
||||||
}
|
|
||||||
exports.isGoodVersion = isGoodVersion;
|
|
||||||
//# sourceMappingURL=util.js.map
|
//# sourceMappingURL=util.js.map
|
||||||
+1
-1
File diff suppressed because one or more lines are too long
+890
-1128
File diff suppressed because it is too large
Load Diff
node_modules/base64-js/LICENSE → node_modules/@octokit/endpoint/node_modules/is-plain-object/LICENSE
Generated
Vendored
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) 2014 Jameson Little
|
Copyright (c) 2014-2017, Jon Schlinkert.
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
+125
@@ -0,0 +1,125 @@
|
|||||||
|
# is-plain-object [](https://www.npmjs.com/package/is-plain-object) [](https://npmjs.org/package/is-plain-object) [](https://npmjs.org/package/is-plain-object) [](https://travis-ci.org/jonschlinkert/is-plain-object)
|
||||||
|
|
||||||
|
> Returns true if an object was created by the `Object` constructor, or Object.create(null).
|
||||||
|
|
||||||
|
Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
Install with [npm](https://www.npmjs.com/):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm install --save is-plain-object
|
||||||
|
```
|
||||||
|
|
||||||
|
Use [isobject](https://github.com/jonschlinkert/isobject) if you only want to check if the value is an object and not an array or null.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
with es modules
|
||||||
|
```js
|
||||||
|
import { isPlainObject } from 'is-plain-object';
|
||||||
|
```
|
||||||
|
|
||||||
|
or with commonjs
|
||||||
|
```js
|
||||||
|
const { isPlainObject } = require('is-plain-object');
|
||||||
|
```
|
||||||
|
|
||||||
|
**true** when created by the `Object` constructor, or Object.create(null).
|
||||||
|
|
||||||
|
```js
|
||||||
|
isPlainObject(Object.create({}));
|
||||||
|
//=> true
|
||||||
|
isPlainObject(Object.create(Object.prototype));
|
||||||
|
//=> true
|
||||||
|
isPlainObject({foo: 'bar'});
|
||||||
|
//=> true
|
||||||
|
isPlainObject({});
|
||||||
|
//=> true
|
||||||
|
isPlainObject(null);
|
||||||
|
//=> true
|
||||||
|
```
|
||||||
|
|
||||||
|
**false** when not created by the `Object` constructor.
|
||||||
|
|
||||||
|
```js
|
||||||
|
isPlainObject(1);
|
||||||
|
//=> false
|
||||||
|
isPlainObject(['foo', 'bar']);
|
||||||
|
//=> false
|
||||||
|
isPlainObject([]);
|
||||||
|
//=> false
|
||||||
|
isPlainObject(new Foo);
|
||||||
|
//=> false
|
||||||
|
isPlainObject(Object.create(null));
|
||||||
|
//=> false
|
||||||
|
```
|
||||||
|
|
||||||
|
## About
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary><strong>Contributing</strong></summary>
|
||||||
|
|
||||||
|
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary><strong>Running Tests</strong></summary>
|
||||||
|
|
||||||
|
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm install && npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary><strong>Building docs</strong></summary>
|
||||||
|
|
||||||
|
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
|
||||||
|
|
||||||
|
To generate the readme, run the following command:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm install -g verbose/verb#dev verb-generate-readme && verb
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
### Related projects
|
||||||
|
|
||||||
|
You might also be interested in these projects:
|
||||||
|
|
||||||
|
* [is-number](https://www.npmjs.com/package/is-number): Returns true if a number or string value is a finite number. Useful for regex… [more](https://github.com/jonschlinkert/is-number) | [homepage](https://github.com/jonschlinkert/is-number "Returns true if a number or string value is a finite number. Useful for regex matches, parsing, user input, etc.")
|
||||||
|
* [isobject](https://www.npmjs.com/package/isobject): Returns true if the value is an object and not an array or null. | [homepage](https://github.com/jonschlinkert/isobject "Returns true if the value is an object and not an array or null.")
|
||||||
|
* [kind-of](https://www.npmjs.com/package/kind-of): Get the native type of a value. | [homepage](https://github.com/jonschlinkert/kind-of "Get the native type of a value.")
|
||||||
|
|
||||||
|
### Contributors
|
||||||
|
|
||||||
|
| **Commits** | **Contributor** |
|
||||||
|
| --- | --- |
|
||||||
|
| 19 | [jonschlinkert](https://github.com/jonschlinkert) |
|
||||||
|
| 6 | [TrySound](https://github.com/TrySound) |
|
||||||
|
| 6 | [stevenvachon](https://github.com/stevenvachon) |
|
||||||
|
| 3 | [onokumus](https://github.com/onokumus) |
|
||||||
|
| 1 | [wtgtybhertgeghgtwtg](https://github.com/wtgtybhertgeghgtwtg) |
|
||||||
|
|
||||||
|
### Author
|
||||||
|
|
||||||
|
**Jon Schlinkert**
|
||||||
|
|
||||||
|
* [GitHub Profile](https://github.com/jonschlinkert)
|
||||||
|
* [Twitter Profile](https://twitter.com/jonschlinkert)
|
||||||
|
* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)
|
||||||
|
|
||||||
|
### License
|
||||||
|
|
||||||
|
Copyright © 2019, [Jon Schlinkert](https://github.com/jonschlinkert).
|
||||||
|
Released under the [MIT License](LICENSE).
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on April 28, 2019._
|
||||||
Generated
Vendored
Generated
Vendored
Generated
Vendored
+85
@@ -0,0 +1,85 @@
|
|||||||
|
{
|
||||||
|
"name": "is-plain-object",
|
||||||
|
"description": "Returns true if an object was created by the `Object` constructor, or Object.create(null).",
|
||||||
|
"version": "5.0.0",
|
||||||
|
"homepage": "https://github.com/jonschlinkert/is-plain-object",
|
||||||
|
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
||||||
|
"contributors": [
|
||||||
|
"Jon Schlinkert (http://twitter.com/jonschlinkert)",
|
||||||
|
"Osman Nuri Okumuş (http://onokumus.com)",
|
||||||
|
"Steven Vachon (https://svachon.com)",
|
||||||
|
"(https://github.com/wtgtybhertgeghgtwtg)",
|
||||||
|
"Bogdan Chadkin (https://github.com/TrySound)"
|
||||||
|
],
|
||||||
|
"repository": "jonschlinkert/is-plain-object",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/jonschlinkert/is-plain-object/issues"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"main": "dist/is-plain-object.js",
|
||||||
|
"module": "dist/is-plain-object.mjs",
|
||||||
|
"types": "is-plain-object.d.ts",
|
||||||
|
"files": [
|
||||||
|
"is-plain-object.d.ts",
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"import": "./dist/is-plain-object.mjs",
|
||||||
|
"require": "./dist/is-plain-object.js"
|
||||||
|
},
|
||||||
|
"./package.json": "./package.json"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10.0"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"build": "rollup -c",
|
||||||
|
"test_browser": "mocha-headless-chrome --args=disable-web-security -f test/browser.html",
|
||||||
|
"test_node": "mocha -r esm",
|
||||||
|
"test": "npm run test_node && npm run build && npm run test_browser",
|
||||||
|
"prepare": "rollup -c"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"chai": "^4.2.0",
|
||||||
|
"esm": "^3.2.22",
|
||||||
|
"gulp-format-md": "^1.0.0",
|
||||||
|
"mocha": "^6.1.4",
|
||||||
|
"mocha-headless-chrome": "^3.1.0",
|
||||||
|
"rollup": "^2.22.1"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"check",
|
||||||
|
"is",
|
||||||
|
"is-object",
|
||||||
|
"isobject",
|
||||||
|
"javascript",
|
||||||
|
"kind",
|
||||||
|
"kind-of",
|
||||||
|
"object",
|
||||||
|
"plain",
|
||||||
|
"type",
|
||||||
|
"typeof",
|
||||||
|
"value"
|
||||||
|
],
|
||||||
|
"verb": {
|
||||||
|
"toc": false,
|
||||||
|
"layout": "default",
|
||||||
|
"tasks": [
|
||||||
|
"readme"
|
||||||
|
],
|
||||||
|
"plugins": [
|
||||||
|
"gulp-format-md"
|
||||||
|
],
|
||||||
|
"related": {
|
||||||
|
"list": [
|
||||||
|
"is-number",
|
||||||
|
"isobject",
|
||||||
|
"kind-of"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"lint": {
|
||||||
|
"reflinks": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Generated
Vendored
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) Feross Aboukhadijeh, and other contributors.
|
Copyright (c) 2014-2017, Jon Schlinkert.
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
+125
@@ -0,0 +1,125 @@
|
|||||||
|
# is-plain-object [](https://www.npmjs.com/package/is-plain-object) [](https://npmjs.org/package/is-plain-object) [](https://npmjs.org/package/is-plain-object) [](https://travis-ci.org/jonschlinkert/is-plain-object)
|
||||||
|
|
||||||
|
> Returns true if an object was created by the `Object` constructor, or Object.create(null).
|
||||||
|
|
||||||
|
Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
Install with [npm](https://www.npmjs.com/):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm install --save is-plain-object
|
||||||
|
```
|
||||||
|
|
||||||
|
Use [isobject](https://github.com/jonschlinkert/isobject) if you only want to check if the value is an object and not an array or null.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
with es modules
|
||||||
|
```js
|
||||||
|
import { isPlainObject } from 'is-plain-object';
|
||||||
|
```
|
||||||
|
|
||||||
|
or with commonjs
|
||||||
|
```js
|
||||||
|
const { isPlainObject } = require('is-plain-object');
|
||||||
|
```
|
||||||
|
|
||||||
|
**true** when created by the `Object` constructor, or Object.create(null).
|
||||||
|
|
||||||
|
```js
|
||||||
|
isPlainObject(Object.create({}));
|
||||||
|
//=> true
|
||||||
|
isPlainObject(Object.create(Object.prototype));
|
||||||
|
//=> true
|
||||||
|
isPlainObject({foo: 'bar'});
|
||||||
|
//=> true
|
||||||
|
isPlainObject({});
|
||||||
|
//=> true
|
||||||
|
isPlainObject(null);
|
||||||
|
//=> true
|
||||||
|
```
|
||||||
|
|
||||||
|
**false** when not created by the `Object` constructor.
|
||||||
|
|
||||||
|
```js
|
||||||
|
isPlainObject(1);
|
||||||
|
//=> false
|
||||||
|
isPlainObject(['foo', 'bar']);
|
||||||
|
//=> false
|
||||||
|
isPlainObject([]);
|
||||||
|
//=> false
|
||||||
|
isPlainObject(new Foo);
|
||||||
|
//=> false
|
||||||
|
isPlainObject(Object.create(null));
|
||||||
|
//=> false
|
||||||
|
```
|
||||||
|
|
||||||
|
## About
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary><strong>Contributing</strong></summary>
|
||||||
|
|
||||||
|
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary><strong>Running Tests</strong></summary>
|
||||||
|
|
||||||
|
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm install && npm test
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary><strong>Building docs</strong></summary>
|
||||||
|
|
||||||
|
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
|
||||||
|
|
||||||
|
To generate the readme, run the following command:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm install -g verbose/verb#dev verb-generate-readme && verb
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
### Related projects
|
||||||
|
|
||||||
|
You might also be interested in these projects:
|
||||||
|
|
||||||
|
* [is-number](https://www.npmjs.com/package/is-number): Returns true if a number or string value is a finite number. Useful for regex… [more](https://github.com/jonschlinkert/is-number) | [homepage](https://github.com/jonschlinkert/is-number "Returns true if a number or string value is a finite number. Useful for regex matches, parsing, user input, etc.")
|
||||||
|
* [isobject](https://www.npmjs.com/package/isobject): Returns true if the value is an object and not an array or null. | [homepage](https://github.com/jonschlinkert/isobject "Returns true if the value is an object and not an array or null.")
|
||||||
|
* [kind-of](https://www.npmjs.com/package/kind-of): Get the native type of a value. | [homepage](https://github.com/jonschlinkert/kind-of "Get the native type of a value.")
|
||||||
|
|
||||||
|
### Contributors
|
||||||
|
|
||||||
|
| **Commits** | **Contributor** |
|
||||||
|
| --- | --- |
|
||||||
|
| 19 | [jonschlinkert](https://github.com/jonschlinkert) |
|
||||||
|
| 6 | [TrySound](https://github.com/TrySound) |
|
||||||
|
| 6 | [stevenvachon](https://github.com/stevenvachon) |
|
||||||
|
| 3 | [onokumus](https://github.com/onokumus) |
|
||||||
|
| 1 | [wtgtybhertgeghgtwtg](https://github.com/wtgtybhertgeghgtwtg) |
|
||||||
|
|
||||||
|
### Author
|
||||||
|
|
||||||
|
**Jon Schlinkert**
|
||||||
|
|
||||||
|
* [GitHub Profile](https://github.com/jonschlinkert)
|
||||||
|
* [Twitter Profile](https://twitter.com/jonschlinkert)
|
||||||
|
* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)
|
||||||
|
|
||||||
|
### License
|
||||||
|
|
||||||
|
Copyright © 2019, [Jon Schlinkert](https://github.com/jonschlinkert).
|
||||||
|
Released under the [MIT License](LICENSE).
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on April 28, 2019._
|
||||||
Generated
Vendored
+38
@@ -0,0 +1,38 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
Object.defineProperty(exports, '__esModule', { value: true });
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014-2017, Jon Schlinkert.
|
||||||
|
* Released under the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function isObject(o) {
|
||||||
|
return Object.prototype.toString.call(o) === '[object Object]';
|
||||||
|
}
|
||||||
|
|
||||||
|
function isPlainObject(o) {
|
||||||
|
var ctor,prot;
|
||||||
|
|
||||||
|
if (isObject(o) === false) return false;
|
||||||
|
|
||||||
|
// If has modified constructor
|
||||||
|
ctor = o.constructor;
|
||||||
|
if (ctor === undefined) return true;
|
||||||
|
|
||||||
|
// If has modified prototype
|
||||||
|
prot = ctor.prototype;
|
||||||
|
if (isObject(prot) === false) return false;
|
||||||
|
|
||||||
|
// If constructor does not have an Object-specific method
|
||||||
|
if (prot.hasOwnProperty('isPrototypeOf') === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Most likely a plain Object
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.isPlainObject = isPlainObject;
|
||||||
Generated
Vendored
+34
@@ -0,0 +1,34 @@
|
|||||||
|
/*!
|
||||||
|
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014-2017, Jon Schlinkert.
|
||||||
|
* Released under the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function isObject(o) {
|
||||||
|
return Object.prototype.toString.call(o) === '[object Object]';
|
||||||
|
}
|
||||||
|
|
||||||
|
function isPlainObject(o) {
|
||||||
|
var ctor,prot;
|
||||||
|
|
||||||
|
if (isObject(o) === false) return false;
|
||||||
|
|
||||||
|
// If has modified constructor
|
||||||
|
ctor = o.constructor;
|
||||||
|
if (ctor === undefined) return true;
|
||||||
|
|
||||||
|
// If has modified prototype
|
||||||
|
prot = ctor.prototype;
|
||||||
|
if (isObject(prot) === false) return false;
|
||||||
|
|
||||||
|
// If constructor does not have an Object-specific method
|
||||||
|
if (prot.hasOwnProperty('isPrototypeOf') === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Most likely a plain Object
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
export { isPlainObject };
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
export function isPlainObject(o: any): boolean;
|
||||||
+85
@@ -0,0 +1,85 @@
|
|||||||
|
{
|
||||||
|
"name": "is-plain-object",
|
||||||
|
"description": "Returns true if an object was created by the `Object` constructor, or Object.create(null).",
|
||||||
|
"version": "5.0.0",
|
||||||
|
"homepage": "https://github.com/jonschlinkert/is-plain-object",
|
||||||
|
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
||||||
|
"contributors": [
|
||||||
|
"Jon Schlinkert (http://twitter.com/jonschlinkert)",
|
||||||
|
"Osman Nuri Okumuş (http://onokumus.com)",
|
||||||
|
"Steven Vachon (https://svachon.com)",
|
||||||
|
"(https://github.com/wtgtybhertgeghgtwtg)",
|
||||||
|
"Bogdan Chadkin (https://github.com/TrySound)"
|
||||||
|
],
|
||||||
|
"repository": "jonschlinkert/is-plain-object",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/jonschlinkert/is-plain-object/issues"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"main": "dist/is-plain-object.js",
|
||||||
|
"module": "dist/is-plain-object.mjs",
|
||||||
|
"types": "is-plain-object.d.ts",
|
||||||
|
"files": [
|
||||||
|
"is-plain-object.d.ts",
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"import": "./dist/is-plain-object.mjs",
|
||||||
|
"require": "./dist/is-plain-object.js"
|
||||||
|
},
|
||||||
|
"./package.json": "./package.json"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10.0"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"build": "rollup -c",
|
||||||
|
"test_browser": "mocha-headless-chrome --args=disable-web-security -f test/browser.html",
|
||||||
|
"test_node": "mocha -r esm",
|
||||||
|
"test": "npm run test_node && npm run build && npm run test_browser",
|
||||||
|
"prepare": "rollup -c"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"chai": "^4.2.0",
|
||||||
|
"esm": "^3.2.22",
|
||||||
|
"gulp-format-md": "^1.0.0",
|
||||||
|
"mocha": "^6.1.4",
|
||||||
|
"mocha-headless-chrome": "^3.1.0",
|
||||||
|
"rollup": "^2.22.1"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"check",
|
||||||
|
"is",
|
||||||
|
"is-object",
|
||||||
|
"isobject",
|
||||||
|
"javascript",
|
||||||
|
"kind",
|
||||||
|
"kind-of",
|
||||||
|
"object",
|
||||||
|
"plain",
|
||||||
|
"type",
|
||||||
|
"typeof",
|
||||||
|
"value"
|
||||||
|
],
|
||||||
|
"verb": {
|
||||||
|
"toc": false,
|
||||||
|
"layout": "default",
|
||||||
|
"tasks": [
|
||||||
|
"readme"
|
||||||
|
],
|
||||||
|
"plugins": [
|
||||||
|
"gulp-format-md"
|
||||||
|
],
|
||||||
|
"related": {
|
||||||
|
"list": [
|
||||||
|
"is-number",
|
||||||
|
"isobject",
|
||||||
|
"kind-of"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"lint": {
|
||||||
|
"reflinks": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
-3
@@ -1,3 +0,0 @@
|
|||||||
This is a stub types definition for del (https://github.com/sindresorhus/del).
|
|
||||||
|
|
||||||
del provides its own type definitions, so you don't need @types/del installed!
|
|
||||||
-14
@@ -1,14 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@types/del",
|
|
||||||
"version": "4.0.0",
|
|
||||||
"typings": null,
|
|
||||||
"description": "Stub TypeScript definitions entry for del, which provides its own types definitions",
|
|
||||||
"main": "",
|
|
||||||
"scripts": {},
|
|
||||||
"author": "",
|
|
||||||
"repository": "https://github.com/sindresorhus/del",
|
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
|
||||||
"del": "*"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
# Installation
|
||||||
|
> `npm install --save @types/events`
|
||||||
|
|
||||||
|
# Summary
|
||||||
|
This package contains type definitions for events (https://github.com/Gozala/events).
|
||||||
|
|
||||||
|
# Details
|
||||||
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/events
|
||||||
|
|
||||||
|
Additional Details
|
||||||
|
* Last updated: Thu, 24 Jan 2019 03:19:08 GMT
|
||||||
|
* Dependencies: none
|
||||||
|
* Global values: none
|
||||||
|
|
||||||
|
# Credits
|
||||||
|
These definitions were written by Yasunori Ohoka <https://github.com/yasupeke>, Shenwei Wang <https://github.com/weareoutman>.
|
||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
// Type definitions for events 3.0
|
||||||
|
// Project: https://github.com/Gozala/events
|
||||||
|
// Definitions by: Yasunori Ohoka <https://github.com/yasupeke>
|
||||||
|
// Shenwei Wang <https://github.com/weareoutman>
|
||||||
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||||
|
|
||||||
|
export type Listener = (...args: any[]) => void;
|
||||||
|
|
||||||
|
export class EventEmitter {
|
||||||
|
static listenerCount(emitter: EventEmitter, type: string | number): number;
|
||||||
|
static defaultMaxListeners: number;
|
||||||
|
|
||||||
|
eventNames(): Array<string | number>;
|
||||||
|
setMaxListeners(n: number): this;
|
||||||
|
getMaxListeners(): number;
|
||||||
|
emit(type: string | number, ...args: any[]): boolean;
|
||||||
|
addListener(type: string | number, listener: Listener): this;
|
||||||
|
on(type: string | number, listener: Listener): this;
|
||||||
|
once(type: string | number, listener: Listener): this;
|
||||||
|
prependListener(type: string | number, listener: Listener): this;
|
||||||
|
prependOnceListener(type: string | number, listener: Listener): this;
|
||||||
|
removeListener(type: string | number, listener: Listener): this;
|
||||||
|
off(type: string | number, listener: Listener): this;
|
||||||
|
removeAllListeners(type?: string | number): this;
|
||||||
|
listeners(type: string | number): Listener[];
|
||||||
|
listenerCount(type: string | number): number;
|
||||||
|
rawListeners(type: string | number): Listener[];
|
||||||
|
}
|
||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"name": "@types/events",
|
||||||
|
"version": "3.0.0",
|
||||||
|
"description": "TypeScript definitions for events",
|
||||||
|
"license": "MIT",
|
||||||
|
"contributors": [
|
||||||
|
{
|
||||||
|
"name": "Yasunori Ohoka",
|
||||||
|
"url": "https://github.com/yasupeke",
|
||||||
|
"githubUsername": "yasupeke"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Shenwei Wang",
|
||||||
|
"url": "https://github.com/weareoutman",
|
||||||
|
"githubUsername": "weareoutman"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"main": "",
|
||||||
|
"types": "index",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git"
|
||||||
|
},
|
||||||
|
"scripts": {},
|
||||||
|
"dependencies": {},
|
||||||
|
"typesPublisherContentHash": "ae078136220837864b64cc7c1c5267ca1ceb809166fb74569e637bc7de9f2e12",
|
||||||
|
"typeScriptVersion": "2.0"
|
||||||
|
}
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
# Installation
|
||||||
|
> `npm install --save @types/glob`
|
||||||
|
|
||||||
|
# Summary
|
||||||
|
This package contains type definitions for Glob (https://github.com/isaacs/node-glob).
|
||||||
|
|
||||||
|
# Details
|
||||||
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/glob
|
||||||
|
|
||||||
|
Additional Details
|
||||||
|
* Last updated: Thu, 27 Sep 2018 12:34:19 GMT
|
||||||
|
* Dependencies: events, minimatch, node
|
||||||
|
* Global values: none
|
||||||
|
|
||||||
|
# Credits
|
||||||
|
These definitions were written by vvakame <https://github.com/vvakame>, voy <https://github.com/voy>, Klaus Meinhardt <https://github.com/ajafff>.
|
||||||
+87
@@ -0,0 +1,87 @@
|
|||||||
|
// Type definitions for Glob 7.1
|
||||||
|
// Project: https://github.com/isaacs/node-glob
|
||||||
|
// Definitions by: vvakame <https://github.com/vvakame>
|
||||||
|
// voy <https://github.com/voy>
|
||||||
|
// Klaus Meinhardt <https://github.com/ajafff>
|
||||||
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||||
|
|
||||||
|
/// <reference types="node" />
|
||||||
|
|
||||||
|
import events = require("events");
|
||||||
|
import minimatch = require("minimatch");
|
||||||
|
|
||||||
|
declare function G(pattern: string, cb: (err: Error | null, matches: string[]) => void): void;
|
||||||
|
declare function G(pattern: string, options: G.IOptions, cb: (err: Error | null, matches: string[]) => void): void;
|
||||||
|
|
||||||
|
declare namespace G {
|
||||||
|
function __promisify__(pattern: string, options?: IOptions): Promise<string[]>;
|
||||||
|
|
||||||
|
function sync(pattern: string, options?: IOptions): string[];
|
||||||
|
|
||||||
|
function hasMagic(pattern: string, options?: IOptions): boolean;
|
||||||
|
|
||||||
|
let Glob: IGlobStatic;
|
||||||
|
let GlobSync: IGlobSyncStatic;
|
||||||
|
|
||||||
|
interface IOptions extends minimatch.IOptions {
|
||||||
|
cwd?: string;
|
||||||
|
root?: string;
|
||||||
|
dot?: boolean;
|
||||||
|
nomount?: boolean;
|
||||||
|
mark?: boolean;
|
||||||
|
nosort?: boolean;
|
||||||
|
stat?: boolean;
|
||||||
|
silent?: boolean;
|
||||||
|
strict?: boolean;
|
||||||
|
cache?: { [path: string]: boolean | 'DIR' | 'FILE' | ReadonlyArray<string> };
|
||||||
|
statCache?: { [path: string]: false | { isDirectory(): boolean} | undefined };
|
||||||
|
symlinks?: { [path: string]: boolean | undefined };
|
||||||
|
realpathCache?: { [path: string]: string };
|
||||||
|
sync?: boolean;
|
||||||
|
nounique?: boolean;
|
||||||
|
nonull?: boolean;
|
||||||
|
debug?: boolean;
|
||||||
|
nobrace?: boolean;
|
||||||
|
noglobstar?: boolean;
|
||||||
|
noext?: boolean;
|
||||||
|
nocase?: boolean;
|
||||||
|
matchBase?: any;
|
||||||
|
nodir?: boolean;
|
||||||
|
ignore?: string | ReadonlyArray<string>;
|
||||||
|
follow?: boolean;
|
||||||
|
realpath?: boolean;
|
||||||
|
nonegate?: boolean;
|
||||||
|
nocomment?: boolean;
|
||||||
|
absolute?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IGlobStatic extends events.EventEmitter {
|
||||||
|
new (pattern: string, cb?: (err: Error | null, matches: string[]) => void): IGlob;
|
||||||
|
new (pattern: string, options: IOptions, cb?: (err: Error | null, matches: string[]) => void): IGlob;
|
||||||
|
prototype: IGlob;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IGlobSyncStatic {
|
||||||
|
new (pattern: string, options?: IOptions): IGlobBase;
|
||||||
|
prototype: IGlobBase;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IGlobBase {
|
||||||
|
minimatch: minimatch.IMinimatch;
|
||||||
|
options: IOptions;
|
||||||
|
aborted: boolean;
|
||||||
|
cache: { [path: string]: boolean | 'DIR' | 'FILE' | ReadonlyArray<string> };
|
||||||
|
statCache: { [path: string]: false | { isDirectory(): boolean; } | undefined };
|
||||||
|
symlinks: { [path: string]: boolean | undefined };
|
||||||
|
realpathCache: { [path: string]: string };
|
||||||
|
found: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IGlob extends IGlobBase, events.EventEmitter {
|
||||||
|
pause(): void;
|
||||||
|
resume(): void;
|
||||||
|
abort(): void;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export = G;
|
||||||
+36
@@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"name": "@types/glob",
|
||||||
|
"version": "7.1.1",
|
||||||
|
"description": "TypeScript definitions for Glob",
|
||||||
|
"license": "MIT",
|
||||||
|
"contributors": [
|
||||||
|
{
|
||||||
|
"name": "vvakame",
|
||||||
|
"url": "https://github.com/vvakame",
|
||||||
|
"githubUsername": "vvakame"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "voy",
|
||||||
|
"url": "https://github.com/voy",
|
||||||
|
"githubUsername": "voy"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Klaus Meinhardt",
|
||||||
|
"url": "https://github.com/ajafff",
|
||||||
|
"githubUsername": "ajafff"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"main": "",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git"
|
||||||
|
},
|
||||||
|
"scripts": {},
|
||||||
|
"dependencies": {
|
||||||
|
"@types/events": "*",
|
||||||
|
"@types/minimatch": "*",
|
||||||
|
"@types/node": "*"
|
||||||
|
},
|
||||||
|
"typesPublisherContentHash": "43019f2af91c7a4ca3453c4b806a01c521ca3008ffe1bfefd37c5f9d6135660e",
|
||||||
|
"typeScriptVersion": "2.0"
|
||||||
|
}
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE
|
||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
# Installation
|
||||||
|
> `npm install --save @types/minimatch`
|
||||||
|
|
||||||
|
# Summary
|
||||||
|
This package contains type definitions for Minimatch (https://github.com/isaacs/minimatch).
|
||||||
|
|
||||||
|
# Details
|
||||||
|
Files were exported from https://www.github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/minimatch
|
||||||
|
|
||||||
|
Additional Details
|
||||||
|
* Last updated: Thu, 04 Jan 2018 23:26:01 GMT
|
||||||
|
* Dependencies: none
|
||||||
|
* Global values: none
|
||||||
|
|
||||||
|
# Credits
|
||||||
|
These definitions were written by vvakame <https://github.com/vvakame>, Shant Marouti <https://github.com/shantmarouti>.
|
||||||
+214
@@ -0,0 +1,214 @@
|
|||||||
|
// Type definitions for Minimatch 3.0
|
||||||
|
// Project: https://github.com/isaacs/minimatch
|
||||||
|
// Definitions by: vvakame <https://github.com/vvakame>
|
||||||
|
// Shant Marouti <https://github.com/shantmarouti>
|
||||||
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests a path against the pattern using the options.
|
||||||
|
*/
|
||||||
|
declare function M(target: string, pattern: string, options?: M.IOptions): boolean;
|
||||||
|
|
||||||
|
declare namespace M {
|
||||||
|
/**
|
||||||
|
* Match against the list of files, in the style of fnmatch or glob.
|
||||||
|
* If nothing is matched, and options.nonull is set,
|
||||||
|
* then return a list containing the pattern itself.
|
||||||
|
*/
|
||||||
|
function match(list: ReadonlyArray<string>, pattern: string, options?: IOptions): string[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a function that tests its supplied argument, suitable for use with Array.filter
|
||||||
|
*/
|
||||||
|
function filter(pattern: string, options?: IOptions): (element: string, indexed: number, array: ReadonlyArray<string>) => boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make a regular expression object from the pattern.
|
||||||
|
*/
|
||||||
|
function makeRe(pattern: string, options?: IOptions): RegExp;
|
||||||
|
|
||||||
|
let Minimatch: IMinimatchStatic;
|
||||||
|
|
||||||
|
interface IOptions {
|
||||||
|
/**
|
||||||
|
* Dump a ton of stuff to stderr.
|
||||||
|
*
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
debug?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do not expand {a,b} and {1..3} brace sets.
|
||||||
|
*
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
nobrace?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable ** matching against multiple folder names.
|
||||||
|
*
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
noglobstar?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allow patterns to match filenames starting with a period,
|
||||||
|
* even if the pattern does not explicitly have a period in that spot.
|
||||||
|
*
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
dot?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable "extglob" style patterns like +(a|b).
|
||||||
|
*
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
noext?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform a case-insensitive match.
|
||||||
|
*
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
nocase?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When a match is not found by minimatch.match,
|
||||||
|
* return a list containing the pattern itself if this option is set.
|
||||||
|
* Otherwise, an empty list is returned if there are no matches.
|
||||||
|
*
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
nonull?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If set, then patterns without slashes will be matched against
|
||||||
|
* the basename of the path if it contains slashes.
|
||||||
|
*
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
matchBase?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Suppress the behavior of treating #
|
||||||
|
* at the start of a pattern as a comment.
|
||||||
|
*
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
nocomment?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Suppress the behavior of treating a leading ! character as negation.
|
||||||
|
*
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
nonegate?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns from negate expressions the same as if they were not negated.
|
||||||
|
* (Ie, true on a hit, false on a miss.)
|
||||||
|
*
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
flipNegate?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IMinimatchStatic {
|
||||||
|
new(pattern: string, options?: IOptions): IMinimatch;
|
||||||
|
prototype: IMinimatch;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface IMinimatch {
|
||||||
|
/**
|
||||||
|
* The original pattern the minimatch object represents.
|
||||||
|
*/
|
||||||
|
pattern: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The options supplied to the constructor.
|
||||||
|
*/
|
||||||
|
options: IOptions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A 2-dimensional array of regexp or string expressions.
|
||||||
|
*/
|
||||||
|
set: any[][]; // (RegExp | string)[][]
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A single regular expression expressing the entire pattern.
|
||||||
|
* Created by the makeRe method.
|
||||||
|
*/
|
||||||
|
regexp: RegExp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* True if the pattern is negated.
|
||||||
|
*/
|
||||||
|
negate: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* True if the pattern is a comment.
|
||||||
|
*/
|
||||||
|
comment: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* True if the pattern is ""
|
||||||
|
*/
|
||||||
|
empty: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate the regexp member if necessary, and return it.
|
||||||
|
* Will return false if the pattern is invalid.
|
||||||
|
*/
|
||||||
|
makeRe(): RegExp; // regexp or boolean
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true if the filename matches the pattern, or false otherwise.
|
||||||
|
*/
|
||||||
|
match(fname: string): boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Take a /-split filename, and match it against a single row in the regExpSet.
|
||||||
|
* This method is mainly for internal use, but is exposed so that it can be used
|
||||||
|
* by a glob-walker that needs to avoid excessive filesystem calls.
|
||||||
|
*/
|
||||||
|
matchOne(files: string[], pattern: string[], partial: boolean): boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated. For internal use.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
debug(): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated. For internal use.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
make(): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated. For internal use.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
parseNegate(): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated. For internal use.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
braceExpand(pattern: string, options: IOptions): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated. For internal use.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
parse(pattern: string, isSub?: boolean): void;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export = M;
|
||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"name": "@types/minimatch",
|
||||||
|
"version": "3.0.3",
|
||||||
|
"description": "TypeScript definitions for Minimatch",
|
||||||
|
"license": "MIT",
|
||||||
|
"contributors": [
|
||||||
|
{
|
||||||
|
"name": "vvakame",
|
||||||
|
"url": "https://github.com/vvakame",
|
||||||
|
"githubUsername": "vvakame"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Shant Marouti",
|
||||||
|
"url": "https://github.com/shantmarouti",
|
||||||
|
"githubUsername": "shantmarouti"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"main": "",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://www.github.com/DefinitelyTyped/DefinitelyTyped.git"
|
||||||
|
},
|
||||||
|
"scripts": {},
|
||||||
|
"dependencies": {},
|
||||||
|
"typesPublisherContentHash": "e768e36348874adcc93ac67e9c3c7b5fcbd39079c0610ec16e410b8f851308d1",
|
||||||
|
"typeScriptVersion": "2.0"
|
||||||
|
}
|
||||||
+4
-4
@@ -5,12 +5,12 @@
|
|||||||
This package contains type definitions for Node.js (http://nodejs.org/).
|
This package contains type definitions for Node.js (http://nodejs.org/).
|
||||||
|
|
||||||
# Details
|
# Details
|
||||||
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node/v12.
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
|
||||||
|
|
||||||
### Additional Details
|
### Additional Details
|
||||||
* Last updated: Wed, 21 Oct 2020 17:47:46 GMT
|
* Last updated: Wed, 28 Jul 2021 19:31:18 GMT
|
||||||
* Dependencies: none
|
* Dependencies: none
|
||||||
* Global values: `Buffer`, `NodeJS`, `__dirname`, `__filename`, `clearImmediate`, `clearInterval`, `clearTimeout`, `console`, `exports`, `global`, `module`, `process`, `queueMicrotask`, `require`, `setImmediate`, `setInterval`, `setTimeout`
|
* Global values: `AbortController`, `AbortSignal`, `__dirname`, `__filename`, `console`, `exports`, `gc`, `global`, `module`, `process`, `require`
|
||||||
|
|
||||||
# Credits
|
# Credits
|
||||||
These definitions were written by [Microsoft TypeScript](https://github.com/Microsoft), [DefinitelyTyped](https://github.com/DefinitelyTyped), [Alberto Schiabel](https://github.com/jkomyno), [Alexander T.](https://github.com/a-tarasyuk), [Alvis HT Tang](https://github.com/alvis), [Andrew Makarov](https://github.com/r3nya), [Benjamin Toueg](https://github.com/btoueg), [Bruno Scheufler](https://github.com/brunoscheufler), [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), [Flarna](https://github.com/Flarna), [Hannes Magnusson](https://github.com/Hannes-Magnusson-CK), [Hoàng Văn Khải](https://github.com/KSXGitHub), [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), [Simon Schick](https://github.com/SimonSchick), [Thomas den Hollander](https://github.com/ThomasdenH), [Wilco Bakker](https://github.com/WilcoBakker), [wwwy3y3](https://github.com/wwwy3y3), [Zane Hannan AU](https://github.com/ZaneHannanAU), [Samuel Ainsworth](https://github.com/samuela), [Kyle Uehlein](https://github.com/kuehlein), [Jordi Oliveras Rovira](https://github.com/j-oliveras), [Thanik Bhongbhibhat](https://github.com/bhongy), [Marcin Kopacz](https://github.com/chyzwar), [Trivikram Kamat](https://github.com/trivikr), [Minh Son Nguyen](https://github.com/nguymin4), [Junxiao Shi](https://github.com/yoursunny), [Ilia Baryshnikov](https://github.com/qwelias), [ExE Boss](https://github.com/ExE-Boss), and [Jason Kwok](https://github.com/JasonHK).
|
These definitions were written by [Microsoft TypeScript](https://github.com/Microsoft), [DefinitelyTyped](https://github.com/DefinitelyTyped), [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), [Hoàng Văn Khải](https://github.com/KSXGitHub), [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), [Simon Schick](https://github.com/SimonSchick), [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), [Minh Son Nguyen](https://github.com/nguymin4), [Junxiao Shi](https://github.com/yoursunny), [Ilia Baryshnikov](https://github.com/qwelias), [ExE Boss](https://github.com/ExE-Boss), [Surasak Chaisurin](https://github.com/Ryan-Willpower), [Piotr Błażejewicz](https://github.com/peterblazejewicz), [Anna Henningsen](https://github.com/addaleax), [Jason Kwok](https://github.com/JasonHK), [Victor Perin](https://github.com/victorperin), [Yongsheng Zhang](https://github.com/ZYSzys), and [NodeJS Contributors](https://github.com/NodeJS).
|
||||||
|
|||||||
+1421
-71
File diff suppressed because it is too large
Load Diff
+8
@@ -0,0 +1,8 @@
|
|||||||
|
declare module 'assert/strict' {
|
||||||
|
import { strict } from 'node:assert';
|
||||||
|
export = strict;
|
||||||
|
}
|
||||||
|
declare module 'node:assert/strict' {
|
||||||
|
import { strict } from 'node:assert';
|
||||||
|
export = strict;
|
||||||
|
}
|
||||||
+374
-124
@@ -1,16 +1,47 @@
|
|||||||
/**
|
/**
|
||||||
* Async Hooks module: https://nodejs.org/api/async_hooks.html
|
* The `async_hooks` module provides an API to track asynchronous resources. It
|
||||||
|
* can be accessed using:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const async_hooks = require('async_hooks');
|
||||||
|
* ```
|
||||||
|
* @experimental
|
||||||
|
* @see [source](https://github.com/nodejs/node/blob/v16.4.2/lib/async_hooks.js)
|
||||||
*/
|
*/
|
||||||
declare module "async_hooks" {
|
declare module 'async_hooks' {
|
||||||
/**
|
/**
|
||||||
* Returns the asyncId of the current execution context.
|
* ```js
|
||||||
|
* const async_hooks = require('async_hooks');
|
||||||
|
*
|
||||||
|
* console.log(async_hooks.executionAsyncId()); // 1 - bootstrap
|
||||||
|
* fs.open(path, 'r', (err, fd) => {
|
||||||
|
* console.log(async_hooks.executionAsyncId()); // 6 - open()
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* The ID returned from `executionAsyncId()` is related to execution timing, not
|
||||||
|
* causality (which is covered by `triggerAsyncId()`):
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const server = net.createServer((conn) => {
|
||||||
|
* // Returns the ID of the server, not of the new connection, because the
|
||||||
|
* // callback runs in the execution scope of the server's MakeCallback().
|
||||||
|
* async_hooks.executionAsyncId();
|
||||||
|
*
|
||||||
|
* }).listen(port, () => {
|
||||||
|
* // Returns the ID of a TickObject (process.nextTick()) because all
|
||||||
|
* // callbacks passed to .listen() are wrapped in a nextTick().
|
||||||
|
* async_hooks.executionAsyncId();
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Promise contexts may not get precise `executionAsyncIds` by default.
|
||||||
|
* See the section on `promise execution tracking`.
|
||||||
|
* @since v8.1.0
|
||||||
|
* @return The `asyncId` of the current execution context. Useful to track when something calls.
|
||||||
*/
|
*/
|
||||||
function executionAsyncId(): number;
|
function executionAsyncId(): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The resource representing the current execution.
|
|
||||||
* Useful to store data within the resource.
|
|
||||||
*
|
|
||||||
* Resource objects returned by `executionAsyncResource()` are most often internal
|
* Resource objects returned by `executionAsyncResource()` are most often internal
|
||||||
* Node.js handle objects with undocumented APIs. Using any functions or properties
|
* Node.js handle objects with undocumented APIs. Using any functions or properties
|
||||||
* on the object is likely to crash your application and should be avoided.
|
* on the object is likely to crash your application and should be avoided.
|
||||||
@@ -18,14 +49,70 @@ declare module "async_hooks" {
|
|||||||
* Using `executionAsyncResource()` in the top-level execution context will
|
* Using `executionAsyncResource()` in the top-level execution context will
|
||||||
* return an empty object as there is no handle or request object to use,
|
* return an empty object as there is no handle or request object to use,
|
||||||
* but having an object representing the top-level can be helpful.
|
* but having an object representing the top-level can be helpful.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const { open } = require('fs');
|
||||||
|
* const { executionAsyncId, executionAsyncResource } = require('async_hooks');
|
||||||
|
*
|
||||||
|
* console.log(executionAsyncId(), executionAsyncResource()); // 1 {}
|
||||||
|
* open(__filename, 'r', (err, fd) => {
|
||||||
|
* console.log(executionAsyncId(), executionAsyncResource()); // 7 FSReqWrap
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* This can be used to implement continuation local storage without the
|
||||||
|
* use of a tracking `Map` to store the metadata:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const { createServer } = require('http');
|
||||||
|
* const {
|
||||||
|
* executionAsyncId,
|
||||||
|
* executionAsyncResource,
|
||||||
|
* createHook
|
||||||
|
* } = require('async_hooks');
|
||||||
|
* const sym = Symbol('state'); // Private symbol to avoid pollution
|
||||||
|
*
|
||||||
|
* createHook({
|
||||||
|
* init(asyncId, type, triggerAsyncId, resource) {
|
||||||
|
* const cr = executionAsyncResource();
|
||||||
|
* if (cr) {
|
||||||
|
* resource[sym] = cr[sym];
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* }).enable();
|
||||||
|
*
|
||||||
|
* const server = createServer((req, res) => {
|
||||||
|
* executionAsyncResource()[sym] = { state: req.url };
|
||||||
|
* setTimeout(function() {
|
||||||
|
* res.end(JSON.stringify(executionAsyncResource()[sym]));
|
||||||
|
* }, 100);
|
||||||
|
* }).listen(3000);
|
||||||
|
* ```
|
||||||
|
* @since v13.9.0, v12.17.0
|
||||||
|
* @return The resource representing the current execution. Useful to store data within the resource.
|
||||||
*/
|
*/
|
||||||
function executionAsyncResource(): object;
|
function executionAsyncResource(): object;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the ID of the resource responsible for calling the callback that is currently being executed.
|
* ```js
|
||||||
|
* const server = net.createServer((conn) => {
|
||||||
|
* // The resource that caused (or triggered) this callback to be called
|
||||||
|
* // was that of the new connection. Thus the return value of triggerAsyncId()
|
||||||
|
* // is the asyncId of "conn".
|
||||||
|
* async_hooks.triggerAsyncId();
|
||||||
|
*
|
||||||
|
* }).listen(port, () => {
|
||||||
|
* // Even though all callbacks passed to .listen() are wrapped in a nextTick()
|
||||||
|
* // the callback itself exists because the call to the server's .listen()
|
||||||
|
* // was made. So the return value would be the ID of the server.
|
||||||
|
* async_hooks.triggerAsyncId();
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Promise contexts may not get valid `triggerAsyncId`s by default. See
|
||||||
|
* the section on `promise execution tracking`.
|
||||||
|
* @return The ID of the resource responsible for calling the callback that is currently being executed.
|
||||||
*/
|
*/
|
||||||
function triggerAsyncId(): number;
|
function triggerAsyncId(): number;
|
||||||
|
|
||||||
interface HookCallbacks {
|
interface HookCallbacks {
|
||||||
/**
|
/**
|
||||||
* Called when a class is constructed that has the possibility to emit an asynchronous event.
|
* Called when a class is constructed that has the possibility to emit an asynchronous event.
|
||||||
@@ -35,73 +122,133 @@ declare module "async_hooks" {
|
|||||||
* @param resource reference to the resource representing the async operation, needs to be released during destroy
|
* @param resource reference to the resource representing the async operation, needs to be released during destroy
|
||||||
*/
|
*/
|
||||||
init?(asyncId: number, type: string, triggerAsyncId: number, resource: object): void;
|
init?(asyncId: number, type: string, triggerAsyncId: number, resource: object): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When an asynchronous operation is initiated or completes a callback is called to notify the user.
|
* When an asynchronous operation is initiated or completes a callback is called to notify the user.
|
||||||
* The before callback is called just before said callback is executed.
|
* The before callback is called just before said callback is executed.
|
||||||
* @param asyncId the unique identifier assigned to the resource about to execute the callback.
|
* @param asyncId the unique identifier assigned to the resource about to execute the callback.
|
||||||
*/
|
*/
|
||||||
before?(asyncId: number): void;
|
before?(asyncId: number): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called immediately after the callback specified in before is completed.
|
* Called immediately after the callback specified in before is completed.
|
||||||
* @param asyncId the unique identifier assigned to the resource which has executed the callback.
|
* @param asyncId the unique identifier assigned to the resource which has executed the callback.
|
||||||
*/
|
*/
|
||||||
after?(asyncId: number): void;
|
after?(asyncId: number): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a promise has resolve() called. This may not be in the same execution id
|
* Called when a promise has resolve() called. This may not be in the same execution id
|
||||||
* as the promise itself.
|
* as the promise itself.
|
||||||
* @param asyncId the unique id for the promise that was resolve()d.
|
* @param asyncId the unique id for the promise that was resolve()d.
|
||||||
*/
|
*/
|
||||||
promiseResolve?(asyncId: number): void;
|
promiseResolve?(asyncId: number): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called after the resource corresponding to asyncId is destroyed
|
* Called after the resource corresponding to asyncId is destroyed
|
||||||
* @param asyncId a unique ID for the async resource
|
* @param asyncId a unique ID for the async resource
|
||||||
*/
|
*/
|
||||||
destroy?(asyncId: number): void;
|
destroy?(asyncId: number): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface AsyncHook {
|
interface AsyncHook {
|
||||||
/**
|
/**
|
||||||
* Enable the callbacks for a given AsyncHook instance. If no callbacks are provided enabling is a noop.
|
* Enable the callbacks for a given AsyncHook instance. If no callbacks are provided enabling is a noop.
|
||||||
*/
|
*/
|
||||||
enable(): this;
|
enable(): this;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disable the callbacks for a given AsyncHook instance from the global pool of AsyncHook callbacks to be executed. Once a hook has been disabled it will not be called again until enabled.
|
* Disable the callbacks for a given AsyncHook instance from the global pool of AsyncHook callbacks to be executed. Once a hook has been disabled it will not be called again until enabled.
|
||||||
*/
|
*/
|
||||||
disable(): this;
|
disable(): this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers functions to be called for different lifetime events of each async operation.
|
* Registers functions to be called for different lifetime events of each async
|
||||||
* @param options the callbacks to register
|
* operation.
|
||||||
* @return an AsyncHooks instance used for disabling and enabling hooks
|
*
|
||||||
|
* The callbacks `init()`/`before()`/`after()`/`destroy()` are called for the
|
||||||
|
* respective asynchronous event during a resource's lifetime.
|
||||||
|
*
|
||||||
|
* All callbacks are optional. For example, if only resource cleanup needs to
|
||||||
|
* be tracked, then only the `destroy` callback needs to be passed. The
|
||||||
|
* specifics of all functions that can be passed to `callbacks` is in the `Hook Callbacks` section.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const async_hooks = require('async_hooks');
|
||||||
|
*
|
||||||
|
* const asyncHook = async_hooks.createHook({
|
||||||
|
* init(asyncId, type, triggerAsyncId, resource) { },
|
||||||
|
* destroy(asyncId) { }
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* The callbacks will be inherited via the prototype chain:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* class MyAsyncCallbacks {
|
||||||
|
* init(asyncId, type, triggerAsyncId, resource) { }
|
||||||
|
* destroy(asyncId) {}
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* class MyAddedCallbacks extends MyAsyncCallbacks {
|
||||||
|
* before(asyncId) { }
|
||||||
|
* after(asyncId) { }
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* const asyncHook = async_hooks.createHook(new MyAddedCallbacks());
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Because promises are asynchronous resources whose lifecycle is tracked
|
||||||
|
* via the async hooks mechanism, the `init()`, `before()`, `after()`, and`destroy()` callbacks _must not_ be async functions that return promises.
|
||||||
|
* @since v8.1.0
|
||||||
|
* @param callbacks The `Hook Callbacks` to register
|
||||||
|
* @return Instance used for disabling and enabling hooks
|
||||||
*/
|
*/
|
||||||
function createHook(options: HookCallbacks): AsyncHook;
|
function createHook(callbacks: HookCallbacks): AsyncHook;
|
||||||
|
|
||||||
interface AsyncResourceOptions {
|
interface AsyncResourceOptions {
|
||||||
/**
|
/**
|
||||||
* The ID of the execution context that created this async event.
|
* The ID of the execution context that created this async event.
|
||||||
* Default: `executionAsyncId()`
|
* @default executionAsyncId()
|
||||||
*/
|
*/
|
||||||
triggerAsyncId?: number;
|
triggerAsyncId?: number | undefined;
|
||||||
|
/**
|
||||||
/**
|
* Disables automatic `emitDestroy` when the object is garbage collected.
|
||||||
* Disables automatic `emitDestroy` when the object is garbage collected.
|
* This usually does not need to be set (even if `emitDestroy` is called
|
||||||
* This usually does not need to be set (even if `emitDestroy` is called
|
* manually), unless the resource's `asyncId` is retrieved and the
|
||||||
* manually), unless the resource's `asyncId` is retrieved and the
|
* sensitive API's `emitDestroy` is called with it.
|
||||||
* sensitive API's `emitDestroy` is called with it.
|
* @default false
|
||||||
* Default: `false`
|
*/
|
||||||
*/
|
requireManualDestroy?: boolean | undefined;
|
||||||
requireManualDestroy?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The class AsyncResource was designed to be extended by the embedder's async resources.
|
* The class `AsyncResource` is designed to be extended by the embedder's async
|
||||||
* Using this users can easily trigger the lifetime events of their own resources.
|
* resources. Using this, users can easily trigger the lifetime events of their
|
||||||
|
* own resources.
|
||||||
|
*
|
||||||
|
* The `init` hook will trigger when an `AsyncResource` is instantiated.
|
||||||
|
*
|
||||||
|
* The following is an overview of the `AsyncResource` API.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const { AsyncResource, executionAsyncId } = require('async_hooks');
|
||||||
|
*
|
||||||
|
* // AsyncResource() is meant to be extended. Instantiating a
|
||||||
|
* // new AsyncResource() also triggers init. If triggerAsyncId is omitted then
|
||||||
|
* // async_hook.executionAsyncId() is used.
|
||||||
|
* const asyncResource = new AsyncResource(
|
||||||
|
* type, { triggerAsyncId: executionAsyncId(), requireManualDestroy: false }
|
||||||
|
* );
|
||||||
|
*
|
||||||
|
* // Run a function in the execution context of the resource. This will
|
||||||
|
* // * establish the context of the resource
|
||||||
|
* // * trigger the AsyncHooks before callbacks
|
||||||
|
* // * call the provided function `fn` with the supplied arguments
|
||||||
|
* // * trigger the AsyncHooks after callbacks
|
||||||
|
* // * restore the original execution context
|
||||||
|
* asyncResource.runInAsyncScope(fn, thisArg, ...args);
|
||||||
|
*
|
||||||
|
* // Call AsyncHooks destroy callbacks.
|
||||||
|
* asyncResource.emitDestroy();
|
||||||
|
*
|
||||||
|
* // Return the unique ID assigned to the AsyncResource instance.
|
||||||
|
* asyncResource.asyncId();
|
||||||
|
*
|
||||||
|
* // Return the trigger ID for the AsyncResource instance.
|
||||||
|
* asyncResource.triggerAsyncId();
|
||||||
|
* ```
|
||||||
*/
|
*/
|
||||||
class AsyncResource {
|
class AsyncResource {
|
||||||
/**
|
/**
|
||||||
@@ -113,135 +260,238 @@ declare module "async_hooks" {
|
|||||||
* this async event (default: `executionAsyncId()`), or an
|
* this async event (default: `executionAsyncId()`), or an
|
||||||
* AsyncResourceOptions object (since 9.3)
|
* AsyncResourceOptions object (since 9.3)
|
||||||
*/
|
*/
|
||||||
constructor(type: string, triggerAsyncId?: number|AsyncResourceOptions);
|
constructor(type: string, triggerAsyncId?: number | AsyncResourceOptions);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call the provided function with the provided arguments in the
|
* Binds the given function to the current execution context.
|
||||||
* execution context of the async resource. This will establish the
|
*
|
||||||
* context, trigger the AsyncHooks before callbacks, call the function,
|
* The returned function will have an `asyncResource` property referencing
|
||||||
* trigger the AsyncHooks after callbacks, and then restore the original
|
* the `AsyncResource` to which the function is bound.
|
||||||
* execution context.
|
* @since v14.8.0, v12.19.0
|
||||||
* @param fn The function to call in the execution context of this
|
* @param fn The function to bind to the current execution context.
|
||||||
* async resource.
|
* @param type An optional name to associate with the underlying `AsyncResource`.
|
||||||
|
*/
|
||||||
|
static bind<Func extends (this: ThisArg, ...args: any[]) => any, ThisArg>(
|
||||||
|
fn: Func,
|
||||||
|
type?: string,
|
||||||
|
thisArg?: ThisArg
|
||||||
|
): Func & {
|
||||||
|
asyncResource: AsyncResource;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Binds the given function to execute to this `AsyncResource`'s scope.
|
||||||
|
*
|
||||||
|
* The returned function will have an `asyncResource` property referencing
|
||||||
|
* the `AsyncResource` to which the function is bound.
|
||||||
|
* @since v14.8.0, v12.19.0
|
||||||
|
* @param fn The function to bind to the current `AsyncResource`.
|
||||||
|
*/
|
||||||
|
bind<Func extends (...args: any[]) => any>(
|
||||||
|
fn: Func
|
||||||
|
): Func & {
|
||||||
|
asyncResource: AsyncResource;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Call the provided function with the provided arguments in the execution context
|
||||||
|
* of the async resource. This will establish the context, trigger the AsyncHooks
|
||||||
|
* before callbacks, call the function, trigger the AsyncHooks after callbacks, and
|
||||||
|
* then restore the original execution context.
|
||||||
|
* @since v9.6.0
|
||||||
|
* @param fn The function to call in the execution context of this async resource.
|
||||||
* @param thisArg The receiver to be used for the function call.
|
* @param thisArg The receiver to be used for the function call.
|
||||||
* @param args Optional arguments to pass to the function.
|
* @param args Optional arguments to pass to the function.
|
||||||
*/
|
*/
|
||||||
runInAsyncScope<This, Result>(fn: (this: This, ...args: any[]) => Result, thisArg?: This, ...args: any[]): Result;
|
runInAsyncScope<This, Result>(fn: (this: This, ...args: any[]) => Result, thisArg?: This, ...args: any[]): Result;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call AsyncHooks destroy callbacks.
|
* Call all `destroy` hooks. This should only ever be called once. An error will
|
||||||
|
* be thrown if it is called more than once. This **must** be manually called. If
|
||||||
|
* the resource is left to be collected by the GC then the `destroy` hooks will
|
||||||
|
* never be called.
|
||||||
|
* @return A reference to `asyncResource`.
|
||||||
*/
|
*/
|
||||||
emitDestroy(): void;
|
emitDestroy(): this;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the unique ID assigned to this AsyncResource instance.
|
* @return The unique `asyncId` assigned to the resource.
|
||||||
*/
|
*/
|
||||||
asyncId(): number;
|
asyncId(): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the trigger ID for this AsyncResource instance.
|
*
|
||||||
|
* @return The same `triggerAsyncId` that is passed to the `AsyncResource` constructor.
|
||||||
*/
|
*/
|
||||||
triggerAsyncId(): number;
|
triggerAsyncId(): number;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When having multiple instances of `AsyncLocalStorage`, they are independent
|
* This class creates stores that stay coherent through asynchronous operations.
|
||||||
* from each other. It is safe to instantiate this class multiple times.
|
*
|
||||||
|
* While you can create your own implementation on top of the `async_hooks` module,`AsyncLocalStorage` should be preferred as it is a performant and memory safe
|
||||||
|
* implementation that involves significant optimizations that are non-obvious to
|
||||||
|
* implement.
|
||||||
|
*
|
||||||
|
* The following example uses `AsyncLocalStorage` to build a simple logger
|
||||||
|
* that assigns IDs to incoming HTTP requests and includes them in messages
|
||||||
|
* logged within each request.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const http = require('http');
|
||||||
|
* const { AsyncLocalStorage } = require('async_hooks');
|
||||||
|
*
|
||||||
|
* const asyncLocalStorage = new AsyncLocalStorage();
|
||||||
|
*
|
||||||
|
* function logWithId(msg) {
|
||||||
|
* const id = asyncLocalStorage.getStore();
|
||||||
|
* console.log(`${id !== undefined ? id : '-'}:`, msg);
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* let idSeq = 0;
|
||||||
|
* http.createServer((req, res) => {
|
||||||
|
* asyncLocalStorage.run(idSeq++, () => {
|
||||||
|
* logWithId('start');
|
||||||
|
* // Imagine any chain of async operations here
|
||||||
|
* setImmediate(() => {
|
||||||
|
* logWithId('finish');
|
||||||
|
* res.end();
|
||||||
|
* });
|
||||||
|
* });
|
||||||
|
* }).listen(8080);
|
||||||
|
*
|
||||||
|
* http.get('http://localhost:8080');
|
||||||
|
* http.get('http://localhost:8080');
|
||||||
|
* // Prints:
|
||||||
|
* // 0: start
|
||||||
|
* // 1: start
|
||||||
|
* // 0: finish
|
||||||
|
* // 1: finish
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* Each instance of `AsyncLocalStorage` maintains an independent storage context.
|
||||||
|
* Multiple instances can safely exist simultaneously without risk of interfering
|
||||||
|
* with each other data.
|
||||||
|
* @since v13.10.0, v12.17.0
|
||||||
*/
|
*/
|
||||||
class AsyncLocalStorage<T> {
|
class AsyncLocalStorage<T> {
|
||||||
/**
|
/**
|
||||||
* This method disables the instance of `AsyncLocalStorage`. All subsequent calls
|
* Disables the instance of `AsyncLocalStorage`. All subsequent calls
|
||||||
* to `asyncLocalStorage.getStore()` will return `undefined` until
|
* to `asyncLocalStorage.getStore()` will return `undefined` until`asyncLocalStorage.run()` or `asyncLocalStorage.enterWith()` is called again.
|
||||||
* `asyncLocalStorage.run()` or `asyncLocalStorage.runSyncAndReturn()`
|
|
||||||
* is called again.
|
|
||||||
*
|
*
|
||||||
* When calling `asyncLocalStorage.disable()`, all current contexts linked to the
|
* When calling `asyncLocalStorage.disable()`, all current contexts linked to the
|
||||||
* instance will be exited.
|
* instance will be exited.
|
||||||
*
|
*
|
||||||
* Calling `asyncLocalStorage.disable()` is required before the
|
* Calling `asyncLocalStorage.disable()` is required before the`asyncLocalStorage` can be garbage collected. This does not apply to stores
|
||||||
* `asyncLocalStorage` can be garbage collected. This does not apply to stores
|
|
||||||
* provided by the `asyncLocalStorage`, as those objects are garbage collected
|
* provided by the `asyncLocalStorage`, as those objects are garbage collected
|
||||||
* along with the corresponding async resources.
|
* along with the corresponding async resources.
|
||||||
*
|
*
|
||||||
* This method is to be used when the `asyncLocalStorage` is not in use anymore
|
* Use this method when the `asyncLocalStorage` is not in use anymore
|
||||||
* in the current process.
|
* in the current process.
|
||||||
|
* @since v13.10.0, v12.17.0
|
||||||
|
* @experimental
|
||||||
*/
|
*/
|
||||||
disable(): void;
|
disable(): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method returns the current store.
|
* Returns the current store.
|
||||||
* If this method is called outside of an asynchronous context initialized by
|
* If called outside of an asynchronous context initialized by
|
||||||
* calling `asyncLocalStorage.run` or `asyncLocalStorage.runAndReturn`, it will
|
* calling `asyncLocalStorage.run()` or `asyncLocalStorage.enterWith()`, it
|
||||||
* return `undefined`.
|
* returns `undefined`.
|
||||||
|
* @since v13.10.0, v12.17.0
|
||||||
*/
|
*/
|
||||||
getStore(): T | undefined;
|
getStore(): T | undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calling `asyncLocalStorage.run(callback)` will create a new asynchronous
|
* Runs a function synchronously within a context and returns its
|
||||||
* context.
|
|
||||||
* Within the callback function and the asynchronous operations from the callback,
|
|
||||||
* `asyncLocalStorage.getStore()` will return an instance of `Map` known as
|
|
||||||
* "the store". This store will be persistent through the following
|
|
||||||
* asynchronous calls.
|
|
||||||
*
|
|
||||||
* The callback will be ran asynchronously. Optionally, arguments can be passed
|
|
||||||
* to the function. They will be passed to the callback function.
|
|
||||||
*
|
|
||||||
* If an error is thrown by the callback function, it will not be caught by
|
|
||||||
* a `try/catch` block as the callback is ran in a new asynchronous resource.
|
|
||||||
* Also, the stacktrace will be impacted by the asynchronous call.
|
|
||||||
*/
|
|
||||||
// TODO: Apply generic vararg once available
|
|
||||||
run(store: T, callback: (...args: any[]) => void, ...args: any[]): void;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Calling `asyncLocalStorage.exit(callback)` will create a new asynchronous
|
|
||||||
* context.
|
|
||||||
* Within the callback function and the asynchronous operations from the callback,
|
|
||||||
* `asyncLocalStorage.getStore()` will return `undefined`.
|
|
||||||
*
|
|
||||||
* The callback will be ran asynchronously. Optionally, arguments can be passed
|
|
||||||
* to the function. They will be passed to the callback function.
|
|
||||||
*
|
|
||||||
* If an error is thrown by the callback function, it will not be caught by
|
|
||||||
* a `try/catch` block as the callback is ran in a new asynchronous resource.
|
|
||||||
* Also, the stacktrace will be impacted by the asynchronous call.
|
|
||||||
*/
|
|
||||||
exit(callback: (...args: any[]) => void, ...args: any[]): void;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This methods runs a function synchronously within a context and return its
|
|
||||||
* return value. The store is not accessible outside of the callback function or
|
* return value. The store is not accessible outside of the callback function or
|
||||||
* the asynchronous operations created within the callback.
|
* the asynchronous operations created within the callback.
|
||||||
*
|
*
|
||||||
* Optionally, arguments can be passed to the function. They will be passed to
|
* The optional `args` are passed to the callback function.
|
||||||
* the callback function.
|
|
||||||
*
|
*
|
||||||
* If the callback function throws an error, it will be thrown by
|
* If the callback function throws an error, the error is thrown by `run()` too.
|
||||||
* `runSyncAndReturn` too. The stacktrace will not be impacted by this call and
|
* The stacktrace is not impacted by this call and the context is exited.
|
||||||
* the context will be exited.
|
*
|
||||||
|
* Example:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const store = { id: 2 };
|
||||||
|
* try {
|
||||||
|
* asyncLocalStorage.run(store, () => {
|
||||||
|
* asyncLocalStorage.getStore(); // Returns the store object
|
||||||
|
* throw new Error();
|
||||||
|
* });
|
||||||
|
* } catch (e) {
|
||||||
|
* asyncLocalStorage.getStore(); // Returns undefined
|
||||||
|
* // The error will be caught here
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
* @since v13.10.0, v12.17.0
|
||||||
*/
|
*/
|
||||||
runSyncAndReturn<R>(store: T, callback: (...args: any[]) => R, ...args: any[]): R;
|
run<R, TArgs extends any[]>(store: T, callback: (...args: TArgs) => R, ...args: TArgs): R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This methods runs a function synchronously outside of a context and return its
|
* Runs a function synchronously outside of a context and returns its
|
||||||
* return value. The store is not accessible within the callback function or
|
* return value. The store is not accessible within the callback function or
|
||||||
* the asynchronous operations created within the callback.
|
* the asynchronous operations created within the callback. Any `getStore()`call done within the callback function will always return `undefined`.
|
||||||
*
|
*
|
||||||
* Optionally, arguments can be passed to the function. They will be passed to
|
* The optional `args` are passed to the callback function.
|
||||||
* the callback function.
|
|
||||||
*
|
*
|
||||||
* If the callback function throws an error, it will be thrown by
|
* If the callback function throws an error, the error is thrown by `exit()` too.
|
||||||
* `exitSyncAndReturn` too. The stacktrace will not be impacted by this call and
|
* The stacktrace is not impacted by this call and the context is re-entered.
|
||||||
* the context will be re-entered.
|
*
|
||||||
|
* Example:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* // Within a call to run
|
||||||
|
* try {
|
||||||
|
* asyncLocalStorage.getStore(); // Returns the store object or value
|
||||||
|
* asyncLocalStorage.exit(() => {
|
||||||
|
* asyncLocalStorage.getStore(); // Returns undefined
|
||||||
|
* throw new Error();
|
||||||
|
* });
|
||||||
|
* } catch (e) {
|
||||||
|
* asyncLocalStorage.getStore(); // Returns the same object or value
|
||||||
|
* // The error will be caught here
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
* @since v13.10.0, v12.17.0
|
||||||
|
* @experimental
|
||||||
*/
|
*/
|
||||||
exitSyncAndReturn<R>(callback: (...args: any[]) => R, ...args: any[]): R;
|
exit<R, TArgs extends any[]>(callback: (...args: TArgs) => R, ...args: TArgs): R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calling `asyncLocalStorage.enterWith(store)` will transition into the context
|
* Transitions into the context for the remainder of the current
|
||||||
* for the remainder of the current synchronous execution and will persist
|
* synchronous execution and then persists the store through any following
|
||||||
* through any following asynchronous calls.
|
* asynchronous calls.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const store = { id: 1 };
|
||||||
|
* // Replaces previous store with the given store object
|
||||||
|
* asyncLocalStorage.enterWith(store);
|
||||||
|
* asyncLocalStorage.getStore(); // Returns the store object
|
||||||
|
* someAsyncOperation(() => {
|
||||||
|
* asyncLocalStorage.getStore(); // Returns the same object
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* This transition will continue for the _entire_ synchronous execution.
|
||||||
|
* This means that if, for example, the context is entered within an event
|
||||||
|
* handler subsequent event handlers will also run within that context unless
|
||||||
|
* specifically bound to another context with an `AsyncResource`. That is why`run()` should be preferred over `enterWith()` unless there are strong reasons
|
||||||
|
* to use the latter method.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const store = { id: 1 };
|
||||||
|
*
|
||||||
|
* emitter.on('my-event', () => {
|
||||||
|
* asyncLocalStorage.enterWith(store);
|
||||||
|
* });
|
||||||
|
* emitter.on('my-event', () => {
|
||||||
|
* asyncLocalStorage.getStore(); // Returns the same object
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
* asyncLocalStorage.getStore(); // Returns undefined
|
||||||
|
* emitter.emit('my-event');
|
||||||
|
* asyncLocalStorage.getStore(); // Returns the same object
|
||||||
|
* ```
|
||||||
|
* @since v13.11.0, v12.17.0
|
||||||
|
* @experimental
|
||||||
*/
|
*/
|
||||||
enterWith(store: T): void;
|
enterWith(store: T): void;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
declare module 'node:async_hooks' {
|
||||||
|
export * from 'async_hooks';
|
||||||
|
}
|
||||||
|
|||||||
-1
@@ -13,7 +13,6 @@
|
|||||||
/// <reference lib="esnext.bigint" />
|
/// <reference lib="esnext.bigint" />
|
||||||
|
|
||||||
// Base definitions for all NodeJS modules that are not specific to any version of TypeScript:
|
// Base definitions for all NodeJS modules that are not specific to any version of TypeScript:
|
||||||
// tslint:disable-next-line:no-bad-reference
|
|
||||||
/// <reference path="ts3.6/base.d.ts" />
|
/// <reference path="ts3.6/base.d.ts" />
|
||||||
|
|
||||||
// TypeScript 3.7-specific augmentations:
|
// TypeScript 3.7-specific augmentations:
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user