mirror of
https://github.com/github/codeql-action.git
synced 2025-12-13 11:09:35 +08:00
Compare commits
2 Commits
codeql-bun
...
daverlo/te
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
068ef74bd6 | ||
|
|
afde6a46b1 |
@@ -18,20 +18,15 @@
|
|||||||
"import/no-amd": "error",
|
"import/no-amd": "error",
|
||||||
"import/no-commonjs": "error",
|
"import/no-commonjs": "error",
|
||||||
"import/no-dynamic-require": "error",
|
"import/no-dynamic-require": "error",
|
||||||
"import/no-extraneous-dependencies": ["error"],
|
"import/no-extraneous-dependencies": ["error", {"devDependencies": false}],
|
||||||
"import/no-namespace": "off",
|
"import/no-namespace": "off",
|
||||||
"import/no-unresolved": "error",
|
"import/no-unresolved": "error",
|
||||||
"import/no-webpack-loader-syntax": "error",
|
"import/no-webpack-loader-syntax": "error",
|
||||||
"import/order": ["error", {
|
|
||||||
"alphabetize": {"order": "asc"},
|
|
||||||
"newlines-between": "always"
|
|
||||||
}],
|
|
||||||
"no-async-foreach/no-async-foreach": "error",
|
"no-async-foreach/no-async-foreach": "error",
|
||||||
"no-console": "off",
|
"no-console": "off",
|
||||||
"no-sequences": "error",
|
"no-sequences": "error",
|
||||||
"no-shadow": "off",
|
"one-var": ["error", "never"],
|
||||||
"@typescript-eslint/no-shadow": ["error"],
|
"sort-imports": ["error", { "allowSeparatedGroups": true }]
|
||||||
"one-var": ["error", "never"]
|
|
||||||
},
|
},
|
||||||
"overrides": [{
|
"overrides": [{
|
||||||
// "temporarily downgraded during transition to eslint
|
// "temporarily downgraded during transition to eslint
|
||||||
@@ -44,11 +39,20 @@
|
|||||||
"@typescript-eslint/no-unsafe-call": "off",
|
"@typescript-eslint/no-unsafe-call": "off",
|
||||||
"@typescript-eslint/no-unsafe-member-access": "off",
|
"@typescript-eslint/no-unsafe-member-access": "off",
|
||||||
"@typescript-eslint/no-unsafe-return": "off",
|
"@typescript-eslint/no-unsafe-return": "off",
|
||||||
|
"@typescript-eslint/no-unused-vars": "off",
|
||||||
"@typescript-eslint/no-var-requires": "off",
|
"@typescript-eslint/no-var-requires": "off",
|
||||||
"@typescript-eslint/prefer-regexp-exec": "off",
|
"@typescript-eslint/prefer-regexp-exec": "off",
|
||||||
"@typescript-eslint/require-await": "off",
|
"@typescript-eslint/require-await": "off",
|
||||||
"@typescript-eslint/restrict-template-expressions": "off",
|
"@typescript-eslint/restrict-template-expressions": "off",
|
||||||
"func-style": "off"
|
"eslint-comments/no-use": "off",
|
||||||
|
"func-style": "off",
|
||||||
|
"github/no-then": "off",
|
||||||
|
"import/no-extraneous-dependencies": "off",
|
||||||
|
"no-shadow": "off",
|
||||||
|
"no-sparse-arrays": "off",
|
||||||
|
"no-throw-literal": "off",
|
||||||
|
"no-useless-escape": "off",
|
||||||
|
"sort-imports": "off"
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
|
|||||||
4
.github/ISSUE_TEMPLATE/config.yml
vendored
4
.github/ISSUE_TEMPLATE/config.yml
vendored
@@ -1,5 +1,5 @@
|
|||||||
blank_issues_enabled: true
|
blank_issues_enabled: true
|
||||||
contact_links:
|
contact_links:
|
||||||
- name: Contact GitHub Support
|
- name: Contact GitHub Support
|
||||||
url: https://support.github.com/request
|
url: https://support.github.com/contact?subject=Code+Scanning+Beta+Support&tags=code-scanning-support
|
||||||
about: Contact Support
|
about: Contact Support about code scanning
|
||||||
|
|||||||
18
.github/update-release-branch.py
vendored
18
.github/update-release-branch.py
vendored
@@ -35,7 +35,7 @@ def open_pr(repo, all_commits, short_main_sha, branch_name):
|
|||||||
commits_without_pull_requests = []
|
commits_without_pull_requests = []
|
||||||
for commit in all_commits:
|
for commit in all_commits:
|
||||||
pr = get_pr_for_commit(repo, commit)
|
pr = get_pr_for_commit(repo, commit)
|
||||||
|
|
||||||
if pr is None:
|
if pr is None:
|
||||||
commits_without_pull_requests.append(commit)
|
commits_without_pull_requests.append(commit)
|
||||||
elif not any(p for p in pull_requests if p.number == pr.number):
|
elif not any(p for p in pull_requests if p.number == pr.number):
|
||||||
@@ -47,7 +47,7 @@ def open_pr(repo, all_commits, short_main_sha, branch_name):
|
|||||||
# Sort PRs and commits by age
|
# Sort PRs and commits by age
|
||||||
pull_requests = sorted(pull_requests, key=lambda pr: pr.number)
|
pull_requests = sorted(pull_requests, key=lambda pr: pr.number)
|
||||||
commits_without_pull_requests = sorted(commits_without_pull_requests, key=lambda c: c.commit.author.date)
|
commits_without_pull_requests = sorted(commits_without_pull_requests, key=lambda c: c.commit.author.date)
|
||||||
|
|
||||||
# Start constructing the body text
|
# Start constructing the body text
|
||||||
body = 'Merging ' + short_main_sha + ' into ' + LATEST_RELEASE_BRANCH
|
body = 'Merging ' + short_main_sha + ' into ' + LATEST_RELEASE_BRANCH
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ def open_pr(repo, all_commits, short_main_sha, branch_name):
|
|||||||
body += '\n- #' + str(pr.number)
|
body += '\n- #' + str(pr.number)
|
||||||
body += ' - ' + pr.title
|
body += ' - ' + pr.title
|
||||||
body += ' (@' + merger + ')'
|
body += ' (@' + merger + ')'
|
||||||
|
|
||||||
# List all commits not part of a PR
|
# List all commits not part of a PR
|
||||||
if len(commits_without_pull_requests) > 0:
|
if len(commits_without_pull_requests) > 0:
|
||||||
body += '\n\nContains the following commits not from a pull request:'
|
body += '\n\nContains the following commits not from a pull request:'
|
||||||
@@ -86,7 +86,7 @@ def get_conductor(repo, pull_requests, other_commits):
|
|||||||
# If there are any PRs then use whoever merged the last one
|
# If there are any PRs then use whoever merged the last one
|
||||||
if len(pull_requests) > 0:
|
if len(pull_requests) > 0:
|
||||||
return get_merger_of_pr(repo, pull_requests[-1])
|
return get_merger_of_pr(repo, pull_requests[-1])
|
||||||
|
|
||||||
# Otherwise take the author of the latest commit
|
# Otherwise take the author of the latest commit
|
||||||
return other_commits[-1].author.login
|
return other_commits[-1].author.login
|
||||||
|
|
||||||
@@ -95,7 +95,7 @@ def get_conductor(repo, pull_requests, other_commits):
|
|||||||
# This will not include any commits that exist on the release branch
|
# This will not include any commits that exist on the release branch
|
||||||
# that aren't on main.
|
# that aren't on main.
|
||||||
def get_commit_difference(repo):
|
def get_commit_difference(repo):
|
||||||
commits = run_git('log', '--pretty=format:%H', ORIGIN + '/' + LATEST_RELEASE_BRANCH + '..' + MAIN_BRANCH).strip().split('\n')
|
commits = run_git('log', '--pretty=format:%H', ORIGIN + '/' + LATEST_RELEASE_BRANCH + '...' + MAIN_BRANCH).strip().split('\n')
|
||||||
|
|
||||||
# Convert to full-fledged commit objects
|
# Convert to full-fledged commit objects
|
||||||
commits = [repo.get_commit(c) for c in commits]
|
commits = [repo.get_commit(c) for c in commits]
|
||||||
@@ -119,12 +119,12 @@ def get_truncated_commit_message(commit):
|
|||||||
# Returns the PR object, or None if no PR could be found.
|
# Returns the PR object, or None if no PR could be found.
|
||||||
def get_pr_for_commit(repo, commit):
|
def get_pr_for_commit(repo, commit):
|
||||||
prs = commit.get_pulls()
|
prs = commit.get_pulls()
|
||||||
|
|
||||||
if prs.totalCount > 0:
|
if prs.totalCount > 0:
|
||||||
# In the case that there are multiple PRs, return the earliest one
|
# In the case that there are multiple PRs, return the earliest one
|
||||||
prs = list(prs)
|
prs = list(prs)
|
||||||
sorted_prs = sorted(prs, key=lambda pr: int(pr.number))
|
sorted(prs, key=lambda pr: int(pr.number))
|
||||||
return sorted_prs[0]
|
return prs[0]
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@@ -165,7 +165,7 @@ def main():
|
|||||||
if branch_exists_on_remote(new_branch_name):
|
if branch_exists_on_remote(new_branch_name):
|
||||||
print('Branch ' + new_branch_name + ' already exists. Nothing to do.')
|
print('Branch ' + new_branch_name + ' already exists. Nothing to do.')
|
||||||
return
|
return
|
||||||
|
|
||||||
# Create the new branch and push it to the remote
|
# Create the new branch and push it to the remote
|
||||||
print('Creating branch ' + new_branch_name)
|
print('Creating branch ' + new_branch_name)
|
||||||
run_git('checkout', '-b', new_branch_name, MAIN_BRANCH)
|
run_git('checkout', '-b', new_branch_name, MAIN_BRANCH)
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
name: Check Expected Release Files
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
paths:
|
|
||||||
- .github/workflows/check-expected-release-files.yml
|
|
||||||
- src/defaults.json
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
check-expected-release-files:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout CodeQL Action
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Check Expected Release Files
|
|
||||||
run: |
|
|
||||||
bundle_version="$(cat "./src/defaults.json" | jq -r ".bundleVersion")"
|
|
||||||
set -x
|
|
||||||
for expected_file in "codeql-bundle.tar.gz" "codeql-bundle-linux64.tar.gz" "codeql-bundle-osx64.tar.gz" "codeql-bundle-win64.tar.gz" "codeql-runner-linux" "codeql-runner-macos" "codeql-runner-win.exe"; do
|
|
||||||
curl --location --fail --head --request GET "https://github.com/github/codeql-action/releases/download/$bundle_version/$expected_file" > /dev/null
|
|
||||||
done
|
|
||||||
72
.github/workflows/codeql.yml
vendored
72
.github/workflows/codeql.yml
vendored
@@ -4,80 +4,28 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches: [main, v1]
|
branches: [main, v1]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [main, v1]
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# Identify the CodeQL tool versions to use in the analysis job.
|
|
||||||
check-codeql-versions:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
outputs:
|
|
||||||
versions: ${{ steps.compare.outputs.versions }}
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
actions: read
|
|
||||||
contents: read
|
|
||||||
security-events: write
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Init with default CodeQL bundle from the VM image
|
|
||||||
id: init-default
|
|
||||||
uses: ./init
|
|
||||||
with:
|
|
||||||
languages: javascript
|
|
||||||
- name: Remove empty database
|
|
||||||
# allows us to run init a second time
|
|
||||||
run: |
|
|
||||||
rm -rf "$RUNNER_TEMP/codeql_databases"
|
|
||||||
- name: Init with latest CodeQL bundle
|
|
||||||
id: init-latest
|
|
||||||
uses: ./init
|
|
||||||
with:
|
|
||||||
tools: latest
|
|
||||||
languages: javascript
|
|
||||||
- name: Compare default and latest CodeQL bundle versions
|
|
||||||
id: compare
|
|
||||||
env:
|
|
||||||
CODEQL_DEFAULT: ${{ steps.init-default.outputs.codeql-path }}
|
|
||||||
CODEQL_LATEST: ${{ steps.init-latest.outputs.codeql-path }}
|
|
||||||
run: |
|
|
||||||
CODEQL_VERSION_DEFAULT="$("$CODEQL_DEFAULT" version --format terse)"
|
|
||||||
CODEQL_VERSION_LATEST="$("$CODEQL_LATEST" version --format terse)"
|
|
||||||
echo "Default CodeQL bundle version is $CODEQL_VERSION_DEFAULT"
|
|
||||||
echo "Latest CodeQL bundle version is $CODEQL_VERSION_LATEST"
|
|
||||||
if [[ "$CODEQL_VERSION_DEFAULT" == "$CODEQL_VERSION_LATEST" ]]; then
|
|
||||||
# Just use `tools: null` to avoid duplication in the analysis job.
|
|
||||||
VERSIONS_JSON='[null]'
|
|
||||||
else
|
|
||||||
# Use both `tools: null` and `tools: latest` in the analysis job.
|
|
||||||
VERSIONS_JSON='[null, "latest"]'
|
|
||||||
fi
|
|
||||||
# Output a JSON-encoded list with the distinct versions to test against.
|
|
||||||
echo "Suggested matrix config for analysis job: $VERSIONS_JSON"
|
|
||||||
echo "::set-output name=versions::${VERSIONS_JSON}"
|
|
||||||
|
|
||||||
build:
|
build:
|
||||||
needs: [check-codeql-versions]
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest,windows-latest,macos-latest]
|
os: [ubuntu-latest,windows-latest,macos-latest]
|
||||||
tools: ${{ fromJson(needs.check-codeql-versions.outputs.versions) }}
|
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
permissions:
|
|
||||||
actions: read
|
|
||||||
contents: read
|
|
||||||
security-events: write
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
# Must fetch at least the immediate parents so that if this is
|
||||||
|
# a pull request then we can checkout the head of the pull request.
|
||||||
|
fetch-depth: 2
|
||||||
|
|
||||||
|
# If this run was triggered by a pull request event then checkout
|
||||||
|
# the head of the pull request instead of the merge commit.
|
||||||
|
- run: git checkout HEAD^2
|
||||||
|
if: ${{ github.event_name == 'pull_request' }}
|
||||||
|
|
||||||
- uses: ./init
|
- uses: ./init
|
||||||
id: init
|
|
||||||
with:
|
with:
|
||||||
languages: javascript
|
languages: javascript
|
||||||
config-file: ./.github/codeql/codeql-config.yml
|
config-file: ./.github/codeql/codeql-config.yml
|
||||||
tools: ${{ matrix.tools }}
|
|
||||||
# confirm steps.init.outputs.codeql-path points to the codeql binary
|
|
||||||
- name: Print CodeQL Version
|
|
||||||
run: ${{steps.init.outputs.codeql-path}} version --format=json
|
|
||||||
- uses: ./analyze
|
- uses: ./analyze
|
||||||
|
|||||||
449
.github/workflows/integration-testing.yml
vendored
Normal file
449
.github/workflows/integration-testing.yml
vendored
Normal file
@@ -0,0 +1,449 @@
|
|||||||
|
name: "Integration Testing"
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main, v1]
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
multi-language-repo_test-autodetect-languages:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Move codeql-action
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
mkdir ../action
|
||||||
|
mv * .github ../action/
|
||||||
|
mv ../action/tests/multi-language-repo/{*,.github} .
|
||||||
|
- uses: ./../action/init
|
||||||
|
- name: Build code
|
||||||
|
shell: bash
|
||||||
|
run: ./build.sh
|
||||||
|
- uses: ./../action/analyze
|
||||||
|
env:
|
||||||
|
TEST_MODE: true
|
||||||
|
- run: |
|
||||||
|
cd "$RUNNER_TEMP/codeql_databases"
|
||||||
|
# List all directories as there will be precisely one directory per database
|
||||||
|
# but there may be other files in this directory such as query suites.
|
||||||
|
if [ "$(ls -d */ | wc -l)" != 6 ] || \
|
||||||
|
[[ ! -d cpp ]] || \
|
||||||
|
[[ ! -d csharp ]] || \
|
||||||
|
[[ ! -d go ]] || \
|
||||||
|
[[ ! -d java ]] || \
|
||||||
|
[[ ! -d javascript ]] || \
|
||||||
|
[[ ! -d python ]]; then
|
||||||
|
echo "Did not find expected number of databases. Database dir contains: $(ls)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
multi-language-repo_test-custom-queries-and-remote-config:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Move codeql-action
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
mkdir ../action
|
||||||
|
mv * .github ../action/
|
||||||
|
mv ../action/tests/multi-language-repo/{*,.github} .
|
||||||
|
- uses: ./../action/init
|
||||||
|
with:
|
||||||
|
languages: cpp,csharp,java,javascript,python
|
||||||
|
config-file: github/codeql-action/tests/multi-language-repo/.github/codeql/custom-queries.yml@${{ github.sha }}
|
||||||
|
- name: Build code
|
||||||
|
shell: bash
|
||||||
|
run: ./build.sh
|
||||||
|
- uses: ./../action/analyze
|
||||||
|
env:
|
||||||
|
TEST_MODE: true
|
||||||
|
|
||||||
|
# Currently is not possible to analyze Go in conjunction with other languages in macos
|
||||||
|
multi-language-repo_test-go-custom-queries:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/setup-go@v2
|
||||||
|
if: ${{ matrix.os == 'macos-latest' }}
|
||||||
|
with:
|
||||||
|
go-version: '^1.13.1'
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Move codeql-action
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
mkdir ../action
|
||||||
|
mv * .github ../action/
|
||||||
|
mv ../action/tests/multi-language-repo/{*,.github} .
|
||||||
|
- uses: ./../action/init
|
||||||
|
with:
|
||||||
|
languages: go
|
||||||
|
config-file: ./.github/codeql/custom-queries.yml
|
||||||
|
- name: Build code
|
||||||
|
shell: bash
|
||||||
|
run: ./build.sh
|
||||||
|
- uses: ./../action/analyze
|
||||||
|
env:
|
||||||
|
TEST_MODE: true
|
||||||
|
|
||||||
|
multi-language-repo_rubocop:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Move codeql-action
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
mkdir ../action
|
||||||
|
mv * .github ../action/
|
||||||
|
mv ../action/tests/multi-language-repo/{*,.github} .
|
||||||
|
- name: Set up Ruby
|
||||||
|
uses: ruby/setup-ruby@v1
|
||||||
|
with:
|
||||||
|
ruby-version: 2.6
|
||||||
|
- name: Install Code Scanning integration
|
||||||
|
run: bundle add code-scanning-rubocop --version 0.3.0 --skip-install
|
||||||
|
- name: Install dependencies
|
||||||
|
run: bundle install
|
||||||
|
- name: Rubocop run
|
||||||
|
run: |
|
||||||
|
bash -c "
|
||||||
|
bundle exec rubocop --require code_scanning --format CodeScanning::SarifFormatter -o rubocop.sarif
|
||||||
|
[[ $? -ne 2 ]]
|
||||||
|
"
|
||||||
|
- uses: ./../action/upload-sarif
|
||||||
|
with:
|
||||||
|
sarif_file: rubocop.sarif
|
||||||
|
env:
|
||||||
|
TEST_MODE: true
|
||||||
|
|
||||||
|
test-proxy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ubuntu:18.04
|
||||||
|
options: --dns 127.0.0.1
|
||||||
|
services:
|
||||||
|
squid-proxy:
|
||||||
|
image: datadog/squid:latest
|
||||||
|
ports:
|
||||||
|
- 3128:3128
|
||||||
|
env:
|
||||||
|
https_proxy: http://squid-proxy:3128
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Move codeql-action
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
mkdir ../action
|
||||||
|
mv * .github ../action/
|
||||||
|
mv ../action/tests/multi-language-repo/{*,.github} .
|
||||||
|
- uses: ./../action/init
|
||||||
|
with:
|
||||||
|
languages: javascript
|
||||||
|
- uses: ./../action/analyze
|
||||||
|
env:
|
||||||
|
TEST_MODE: true
|
||||||
|
|
||||||
|
runner-analyze-javascript-ubuntu:
|
||||||
|
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: |
|
||||||
|
# Pass --config-file here, but not for other jobs in this workflow.
|
||||||
|
# This means we're testing the config file parsing in the runner
|
||||||
|
# but not slowing down all jobs unnecessarily as it doesn't add much
|
||||||
|
# testing the parsing on different operating systems and languages.
|
||||||
|
runner/dist/codeql-runner-linux init --repository $GITHUB_REPOSITORY --languages javascript --config-file ./.github/codeql/codeql-config.yml --github-url $GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
||||||
|
|
||||||
|
- name: Run analyze
|
||||||
|
run: |
|
||||||
|
runner/dist/codeql-runner-linux analyze --repository $GITHUB_REPOSITORY --commit $GITHUB_SHA --ref $GITHUB_REF --github-url $GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
||||||
|
env:
|
||||||
|
TEST_MODE: true
|
||||||
|
|
||||||
|
runner-analyze-javascript-windows:
|
||||||
|
runs-on: windows-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-win.exe init --repository $Env:GITHUB_REPOSITORY --languages javascript --github-url $Env:GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
||||||
|
|
||||||
|
- name: Run analyze
|
||||||
|
run: |
|
||||||
|
runner/dist/codeql-runner-win.exe analyze --repository $Env:GITHUB_REPOSITORY --commit $Env:GITHUB_SHA --ref $Env:GITHUB_REF --github-url $Env:GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
||||||
|
env:
|
||||||
|
TEST_MODE: true
|
||||||
|
|
||||||
|
runner-analyze-javascript-macos:
|
||||||
|
runs-on: macos-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-macos init --repository $GITHUB_REPOSITORY --languages javascript --config-file ./.github/codeql/codeql-config.yml --github-url $GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
||||||
|
|
||||||
|
- name: Run analyze
|
||||||
|
run: |
|
||||||
|
runner/dist/codeql-runner-macos analyze --repository $GITHUB_REPOSITORY --commit $GITHUB_SHA --ref $GITHUB_REF --github-url $GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
||||||
|
env:
|
||||||
|
TEST_MODE: true
|
||||||
|
|
||||||
|
runner-analyze-csharp-ubuntu:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Move codeql-action
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
mkdir ../action
|
||||||
|
mv * .github ../action/
|
||||||
|
mv ../action/tests/multi-language-repo/{*,.github} .
|
||||||
|
|
||||||
|
- name: Build runner
|
||||||
|
run: |
|
||||||
|
cd ../action/runner
|
||||||
|
npm install
|
||||||
|
npm run build-runner
|
||||||
|
|
||||||
|
- name: Run init
|
||||||
|
run: |
|
||||||
|
../action/runner/dist/codeql-runner-linux init --repository $GITHUB_REPOSITORY --languages csharp --github-url $GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
||||||
|
|
||||||
|
- name: Build code
|
||||||
|
run: |
|
||||||
|
. ./codeql-runner/codeql-env.sh
|
||||||
|
dotnet build
|
||||||
|
|
||||||
|
- name: Run analyze
|
||||||
|
run: |
|
||||||
|
../action/runner/dist/codeql-runner-linux analyze --repository $GITHUB_REPOSITORY --commit $GITHUB_SHA --ref $GITHUB_REF --github-url $GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
||||||
|
env:
|
||||||
|
TEST_MODE: true
|
||||||
|
|
||||||
|
runner-analyze-csharp-windows:
|
||||||
|
runs-on: windows-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Move codeql-action
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
mkdir ../action
|
||||||
|
mv * .github ../action/
|
||||||
|
mv ../action/tests/multi-language-repo/{*,.github} .
|
||||||
|
|
||||||
|
- name: Build runner
|
||||||
|
run: |
|
||||||
|
cd ../action/runner
|
||||||
|
npm install
|
||||||
|
npm run build-runner
|
||||||
|
|
||||||
|
- name: Run init
|
||||||
|
run: |
|
||||||
|
../action/runner/dist/codeql-runner-win.exe init --repository $Env:GITHUB_REPOSITORY --languages csharp --github-url $Env:GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
||||||
|
|
||||||
|
- name: Build code
|
||||||
|
shell: powershell
|
||||||
|
run: |
|
||||||
|
cat ./codeql-runner/codeql-env.sh | Invoke-Expression
|
||||||
|
dotnet build
|
||||||
|
|
||||||
|
- name: Run analyze
|
||||||
|
run: |
|
||||||
|
../action/runner/dist/codeql-runner-win.exe analyze --repository $Env:GITHUB_REPOSITORY --commit $Env:GITHUB_SHA --ref $Env:GITHUB_REF --github-url $Env:GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
||||||
|
env:
|
||||||
|
TEST_MODE: true
|
||||||
|
|
||||||
|
runner-analyze-csharp-macos:
|
||||||
|
runs-on: macos-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Move codeql-action
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
mkdir ../action
|
||||||
|
mv * .github ../action/
|
||||||
|
mv ../action/tests/multi-language-repo/{*,.github} .
|
||||||
|
|
||||||
|
- name: Build runner
|
||||||
|
run: |
|
||||||
|
cd ../action/runner
|
||||||
|
npm install
|
||||||
|
npm run build-runner
|
||||||
|
|
||||||
|
- name: Run init
|
||||||
|
run: |
|
||||||
|
../action/runner/dist/codeql-runner-macos init --repository $GITHUB_REPOSITORY --languages csharp --github-url $GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
||||||
|
|
||||||
|
- name: Build code
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
. ./codeql-runner/codeql-env.sh
|
||||||
|
dotnet build
|
||||||
|
|
||||||
|
- name: Run analyze
|
||||||
|
run: |
|
||||||
|
../action/runner/dist/codeql-runner-macos analyze --repository $GITHUB_REPOSITORY --commit $GITHUB_SHA --ref $GITHUB_REF --github-url $GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
||||||
|
env:
|
||||||
|
TEST_MODE: true
|
||||||
|
|
||||||
|
|
||||||
|
runner-analyze-csharp-autobuild-ubuntu:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Move codeql-action
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
mkdir ../action
|
||||||
|
mv * .github ../action/
|
||||||
|
mv ../action/tests/multi-language-repo/{*,.github} .
|
||||||
|
|
||||||
|
- name: Build runner
|
||||||
|
run: |
|
||||||
|
cd ../action/runner
|
||||||
|
npm install
|
||||||
|
npm run build-runner
|
||||||
|
|
||||||
|
- name: Run init
|
||||||
|
run: |
|
||||||
|
../action/runner/dist/codeql-runner-linux init --repository $GITHUB_REPOSITORY --languages csharp --github-url $GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
||||||
|
|
||||||
|
- name: Build code
|
||||||
|
run: |
|
||||||
|
../action/runner/dist/codeql-runner-linux autobuild
|
||||||
|
|
||||||
|
- name: Run analyze
|
||||||
|
run: |
|
||||||
|
../action/runner/dist/codeql-runner-linux analyze --repository $GITHUB_REPOSITORY --commit $GITHUB_SHA --ref $GITHUB_REF --github-url $GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
||||||
|
env:
|
||||||
|
TEST_MODE: true
|
||||||
|
|
||||||
|
runner-analyze-csharp-autobuild-windows:
|
||||||
|
runs-on: windows-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Move codeql-action
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
mkdir ../action
|
||||||
|
mv * .github ../action/
|
||||||
|
mv ../action/tests/multi-language-repo/{*,.github} .
|
||||||
|
|
||||||
|
- name: Build runner
|
||||||
|
run: |
|
||||||
|
cd ../action/runner
|
||||||
|
npm install
|
||||||
|
npm run build-runner
|
||||||
|
|
||||||
|
- name: Run init
|
||||||
|
run: |
|
||||||
|
../action/runner/dist/codeql-runner-win.exe init --repository $Env:GITHUB_REPOSITORY --languages csharp --github-url $Env:GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
||||||
|
|
||||||
|
- name: Build code
|
||||||
|
shell: powershell
|
||||||
|
run: |
|
||||||
|
../action/runner/dist/codeql-runner-win.exe autobuild
|
||||||
|
|
||||||
|
- name: Run analyze
|
||||||
|
run: |
|
||||||
|
../action/runner/dist/codeql-runner-win.exe analyze --repository $Env:GITHUB_REPOSITORY --commit $Env:GITHUB_SHA --ref $Env:GITHUB_REF --github-url $Env:GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
||||||
|
env:
|
||||||
|
TEST_MODE: true
|
||||||
|
|
||||||
|
runner-analyze-csharp-autobuild-macos:
|
||||||
|
runs-on: macos-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Move codeql-action
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
mkdir ../action
|
||||||
|
mv * .github ../action/
|
||||||
|
mv ../action/tests/multi-language-repo/{*,.github} .
|
||||||
|
|
||||||
|
- name: Build runner
|
||||||
|
run: |
|
||||||
|
cd ../action/runner
|
||||||
|
npm install
|
||||||
|
npm run build-runner
|
||||||
|
|
||||||
|
- name: Run init
|
||||||
|
run: |
|
||||||
|
../action/runner/dist/codeql-runner-macos init --repository $GITHUB_REPOSITORY --languages csharp --github-url $GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
||||||
|
|
||||||
|
- name: Build code
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
../action/runner/dist/codeql-runner-macos autobuild
|
||||||
|
|
||||||
|
- name: Run analyze
|
||||||
|
run: |
|
||||||
|
../action/runner/dist/codeql-runner-macos analyze --repository $GITHUB_REPOSITORY --commit $GITHUB_SHA --ref $GITHUB_REF --github-url $GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
||||||
|
env:
|
||||||
|
TEST_MODE: true
|
||||||
|
|
||||||
|
runner-upload-sarif:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Build runner
|
||||||
|
run: |
|
||||||
|
cd runner
|
||||||
|
npm install
|
||||||
|
npm run build-runner
|
||||||
|
|
||||||
|
- name: Upload with runner
|
||||||
|
run: |
|
||||||
|
# Deliberately don't use TEST_MODE here. This is specifically testing
|
||||||
|
# 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 }}
|
||||||
642
.github/workflows/pr-checks.yml
vendored
642
.github/workflows/pr-checks.yml
vendored
@@ -1,8 +1,5 @@
|
|||||||
name: "PR checks"
|
name: "PR checks"
|
||||||
|
|
||||||
env:
|
|
||||||
GO111MODULE: auto
|
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main, v1]
|
branches: [main, v1]
|
||||||
@@ -23,7 +20,25 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Check generated JavaScript
|
- name: Check generated JavaScript
|
||||||
run: .github/workflows/script/check-js.sh
|
run: |
|
||||||
|
# Sanity check that repo is clean to start with
|
||||||
|
if [ ! -z "$(git status --porcelain)" ]; then
|
||||||
|
# If we get a fail here then this workflow needs attention...
|
||||||
|
>&2 echo "Failed: Repo should be clean before testing!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
# Wipe the lib directory incase there are extra unnecessary files in there
|
||||||
|
rm -rf lib
|
||||||
|
# Generate the JavaScript files
|
||||||
|
npm run-script build
|
||||||
|
# Check that repo is still clean
|
||||||
|
if [ ! -z "$(git status --porcelain)" ]; then
|
||||||
|
# If we get a fail here then the PR needs attention
|
||||||
|
>&2 echo "Failed: JavaScript files are not up to date. Run 'npm run-script build' to update"
|
||||||
|
git status
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Success: JavaScript files are up to date"
|
||||||
|
|
||||||
check-node-modules:
|
check-node-modules:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -31,10 +46,27 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Check node modules up to date
|
- name: Check node modules up to date
|
||||||
run: .github/workflows/script/check-node-modules.sh
|
run: |
|
||||||
|
# Sanity check that repo is clean to start with
|
||||||
|
if [ ! -z "$(git status --porcelain)" ]; then
|
||||||
|
# If we get a fail here then this workflow needs attention...
|
||||||
|
>&2 echo "Failed: Repo should be clean before testing!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
# Reinstall modules and then clean to remove absolute paths
|
||||||
|
# Use 'npm ci' instead of 'npm install' as this is intended to be reproducible
|
||||||
|
npm ci
|
||||||
|
npm run removeNPMAbsolutePaths
|
||||||
|
# Check that repo is still clean
|
||||||
|
if [ ! -z "$(git status --porcelain)" ]; then
|
||||||
|
# If we get a fail here then the PR needs attention
|
||||||
|
>&2 echo "Failed: node_modules are not up to date. Run 'npm ci' and 'npm run removeNPMAbsolutePaths' to update"
|
||||||
|
git status
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Success: node_modules are up to date"
|
||||||
|
|
||||||
npm-test:
|
npm-test:
|
||||||
needs: [check-js, check-node-modules]
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest,macos-latest]
|
os: [ubuntu-latest,macos-latest]
|
||||||
@@ -44,601 +76,3 @@ jobs:
|
|||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: npm run-script test
|
- name: npm run-script test
|
||||||
run: npm run-script test
|
run: npm run-script test
|
||||||
|
|
||||||
multi-language-repo_test-autodetect-languages:
|
|
||||||
needs: [check-js, check-node-modules]
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Move codeql-action
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
mkdir ../action
|
|
||||||
mv * .github ../action/
|
|
||||||
mv ../action/tests/multi-language-repo/{*,.github} .
|
|
||||||
mv ../action/.github/workflows .github
|
|
||||||
- uses: ./../action/init
|
|
||||||
- name: Build code
|
|
||||||
shell: bash
|
|
||||||
run: ./build.sh
|
|
||||||
- uses: ./../action/analyze
|
|
||||||
env:
|
|
||||||
TEST_MODE: true
|
|
||||||
- run: |
|
|
||||||
cd "$RUNNER_TEMP/codeql_databases"
|
|
||||||
# List all directories as there will be precisely one directory per database
|
|
||||||
# but there may be other files in this directory such as query suites.
|
|
||||||
if [ "$(ls -d */ | wc -l)" != 6 ] || \
|
|
||||||
[[ ! -d cpp ]] || \
|
|
||||||
[[ ! -d csharp ]] || \
|
|
||||||
[[ ! -d go ]] || \
|
|
||||||
[[ ! -d java ]] || \
|
|
||||||
[[ ! -d javascript ]] || \
|
|
||||||
[[ ! -d python ]]; then
|
|
||||||
echo "Did not find expected number of databases. Database dir contains: $(ls)"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Identify the CodeQL tool versions to integration test against.
|
|
||||||
check-codeql-versions:
|
|
||||||
needs: [check-js, check-node-modules]
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
outputs:
|
|
||||||
versions: ${{ steps.compare.outputs.versions }}
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Move codeql-action
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
mkdir ../action
|
|
||||||
mv * .github ../action/
|
|
||||||
mv ../action/tests/multi-language-repo/{*,.github} .
|
|
||||||
mv ../action/.github/workflows .github
|
|
||||||
- name: Init with default CodeQL bundle from the VM image
|
|
||||||
id: init-default
|
|
||||||
uses: ./../action/init
|
|
||||||
with:
|
|
||||||
languages: javascript
|
|
||||||
- name: Remove empty database
|
|
||||||
# allows us to run init a second time
|
|
||||||
run: |
|
|
||||||
rm -rf "$RUNNER_TEMP/codeql_databases"
|
|
||||||
- name: Init with latest CodeQL bundle
|
|
||||||
id: init-latest
|
|
||||||
uses: ./../action/init
|
|
||||||
with:
|
|
||||||
tools: latest
|
|
||||||
languages: javascript
|
|
||||||
- name: Compare default and latest CodeQL bundle versions
|
|
||||||
id: compare
|
|
||||||
env:
|
|
||||||
CODEQL_DEFAULT: ${{ steps.init-default.outputs.codeql-path }}
|
|
||||||
CODEQL_LATEST: ${{ steps.init-latest.outputs.codeql-path }}
|
|
||||||
run: |
|
|
||||||
CODEQL_VERSION_DEFAULT="$("$CODEQL_DEFAULT" version --format terse)"
|
|
||||||
CODEQL_VERSION_LATEST="$("$CODEQL_LATEST" version --format terse)"
|
|
||||||
echo "Default CodeQL bundle version is $CODEQL_VERSION_DEFAULT"
|
|
||||||
echo "Latest CodeQL bundle version is $CODEQL_VERSION_LATEST"
|
|
||||||
if [[ "$CODEQL_VERSION_DEFAULT" == "$CODEQL_VERSION_LATEST" ]]; then
|
|
||||||
# Just use `tools: null` to avoid duplication in the integration tests.
|
|
||||||
VERSIONS_JSON='[null]'
|
|
||||||
else
|
|
||||||
# Use both `tools: null` and `tools: latest` in the integration tests.
|
|
||||||
VERSIONS_JSON='[null, "latest"]'
|
|
||||||
fi
|
|
||||||
# Output a JSON-encoded list with the distinct versions to test against.
|
|
||||||
echo "Suggested matrix config for integration tests: $VERSIONS_JSON"
|
|
||||||
echo "::set-output name=versions::${VERSIONS_JSON}"
|
|
||||||
|
|
||||||
multi-language-repo_test-custom-queries-and-remote-config:
|
|
||||||
needs: [check-js, check-node-modules, check-codeql-versions]
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
||||||
tools: ${{ fromJson(needs.check-codeql-versions.outputs.versions) }}
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Move codeql-action
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
mkdir ../action
|
|
||||||
mv * .github ../action/
|
|
||||||
mv ../action/tests/multi-language-repo/{*,.github} .
|
|
||||||
mv ../action/.github/workflows .github
|
|
||||||
- uses: ./../action/init
|
|
||||||
with:
|
|
||||||
tools: ${{ matrix.tools }}
|
|
||||||
languages: cpp,csharp,java,javascript,python
|
|
||||||
config-file: github/codeql-action/tests/multi-language-repo/.github/codeql/custom-queries.yml@${{ github.sha }}
|
|
||||||
- name: Build code
|
|
||||||
shell: bash
|
|
||||||
run: ./build.sh
|
|
||||||
- uses: ./../action/analyze
|
|
||||||
env:
|
|
||||||
TEST_MODE: true
|
|
||||||
|
|
||||||
# Currently is not possible to analyze Go in conjunction with other languages in macos
|
|
||||||
multi-language-repo_test-go-custom-queries:
|
|
||||||
needs: [check-js, check-node-modules, check-codeql-versions]
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
||||||
tools: ${{ fromJson(needs.check-codeql-versions.outputs.versions) }}
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/setup-go@v2
|
|
||||||
if: ${{ matrix.os == 'macos-latest' }}
|
|
||||||
with:
|
|
||||||
go-version: '^1.13.1'
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Move codeql-action
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
mkdir ../action
|
|
||||||
mv * .github ../action/
|
|
||||||
mv ../action/tests/multi-language-repo/{*,.github} .
|
|
||||||
mv ../action/.github/workflows .github
|
|
||||||
- uses: ./../action/init
|
|
||||||
with:
|
|
||||||
languages: go
|
|
||||||
config-file: ./.github/codeql/custom-queries.yml
|
|
||||||
tools: ${{ matrix.tools }}
|
|
||||||
- name: Build code
|
|
||||||
shell: bash
|
|
||||||
run: ./build.sh
|
|
||||||
- uses: ./../action/analyze
|
|
||||||
env:
|
|
||||||
TEST_MODE: true
|
|
||||||
|
|
||||||
go-custom-tracing:
|
|
||||||
needs: [check-js, check-node-modules, check-codeql-versions]
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
||||||
tools: ${{ fromJson(needs.check-codeql-versions.outputs.versions) }}
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
env:
|
|
||||||
CODEQL_EXTRACTOR_GO_BUILD_TRACING: "on"
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/setup-go@v2
|
|
||||||
if: ${{ matrix.os == 'macos-latest' }}
|
|
||||||
with:
|
|
||||||
go-version: '^1.13.1'
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Move codeql-action
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
mkdir ../action
|
|
||||||
mv * .github ../action/
|
|
||||||
mv ../action/tests/multi-language-repo/{*,.github} .
|
|
||||||
mv ../action/.github/workflows .github
|
|
||||||
- uses: ./../action/init
|
|
||||||
with:
|
|
||||||
languages: go
|
|
||||||
tools: ${{ matrix.tools }}
|
|
||||||
- name: Build code
|
|
||||||
shell: bash
|
|
||||||
run: go build main.go
|
|
||||||
- uses: ./../action/analyze
|
|
||||||
env:
|
|
||||||
TEST_MODE: true
|
|
||||||
|
|
||||||
go-custom-tracing-autobuild:
|
|
||||||
needs: [check-js, check-node-modules, check-codeql-versions]
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
tools: ${{ fromJson(needs.check-codeql-versions.outputs.versions) }}
|
|
||||||
# No need to test Go autobuild on multiple OSes since
|
|
||||||
# we're testing Go custom tracing with a manual build on all OSes.
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
env:
|
|
||||||
CODEQL_EXTRACTOR_GO_BUILD_TRACING: "on"
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Move codeql-action
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
mkdir ../action
|
|
||||||
mv * .github ../action/
|
|
||||||
mv ../action/tests/multi-language-repo/{*,.github} .
|
|
||||||
mv ../action/.github/workflows .github
|
|
||||||
- uses: ./../action/init
|
|
||||||
with:
|
|
||||||
languages: go
|
|
||||||
tools: ${{ matrix.tools }}
|
|
||||||
- uses: ./../action/autobuild
|
|
||||||
- uses: ./../action/analyze
|
|
||||||
env:
|
|
||||||
TEST_MODE: true
|
|
||||||
|
|
||||||
multi-language-repo_rubocop:
|
|
||||||
needs: [check-js, check-node-modules]
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Move codeql-action
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
mkdir ../action
|
|
||||||
mv * .github ../action/
|
|
||||||
mv ../action/tests/multi-language-repo/{*,.github} .
|
|
||||||
mv ../action/.github/workflows .github
|
|
||||||
- name: Set up Ruby
|
|
||||||
uses: ruby/setup-ruby@v1
|
|
||||||
with:
|
|
||||||
ruby-version: 2.6
|
|
||||||
- name: Install Code Scanning integration
|
|
||||||
run: bundle add code-scanning-rubocop --version 0.3.0 --skip-install
|
|
||||||
- name: Install dependencies
|
|
||||||
run: bundle install
|
|
||||||
- name: Rubocop run
|
|
||||||
run: |
|
|
||||||
bash -c "
|
|
||||||
bundle exec rubocop --require code_scanning --format CodeScanning::SarifFormatter -o rubocop.sarif
|
|
||||||
[[ $? -ne 2 ]]
|
|
||||||
"
|
|
||||||
- uses: ./../action/upload-sarif
|
|
||||||
with:
|
|
||||||
sarif_file: rubocop.sarif
|
|
||||||
env:
|
|
||||||
TEST_MODE: true
|
|
||||||
|
|
||||||
test-proxy:
|
|
||||||
needs: [check-js, check-node-modules, check-codeql-versions]
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
tools: ${{ fromJson(needs.check-codeql-versions.outputs.versions) }}
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
container:
|
|
||||||
image: ubuntu:18.04
|
|
||||||
options: --dns 127.0.0.1
|
|
||||||
services:
|
|
||||||
squid-proxy:
|
|
||||||
image: datadog/squid:latest
|
|
||||||
ports:
|
|
||||||
- 3128:3128
|
|
||||||
env:
|
|
||||||
https_proxy: http://squid-proxy:3128
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Move codeql-action
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
mkdir ../action
|
|
||||||
mv * .github ../action/
|
|
||||||
mv ../action/tests/multi-language-repo/{*,.github} .
|
|
||||||
mv ../action/.github/workflows .github
|
|
||||||
- uses: ./../action/init
|
|
||||||
with:
|
|
||||||
languages: javascript
|
|
||||||
tools: ${{ matrix.tools }}
|
|
||||||
- uses: ./../action/analyze
|
|
||||||
env:
|
|
||||||
TEST_MODE: true
|
|
||||||
|
|
||||||
runner-analyze-javascript-ubuntu:
|
|
||||||
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: |
|
|
||||||
# Pass --config-file here, but not for other jobs in this workflow.
|
|
||||||
# This means we're testing the config file parsing in the runner
|
|
||||||
# but not slowing down all jobs unnecessarily as it doesn't add much
|
|
||||||
# testing the parsing on different operating systems and languages.
|
|
||||||
runner/dist/codeql-runner-linux init --repository $GITHUB_REPOSITORY --languages javascript --config-file ./.github/codeql/codeql-config.yml --github-url $GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
|
||||||
|
|
||||||
- name: Run analyze
|
|
||||||
run: |
|
|
||||||
runner/dist/codeql-runner-linux analyze --repository $GITHUB_REPOSITORY --commit $GITHUB_SHA --ref $GITHUB_REF --github-url $GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
|
||||||
env:
|
|
||||||
TEST_MODE: true
|
|
||||||
|
|
||||||
runner-analyze-javascript-windows:
|
|
||||||
needs: [check-js, check-node-modules]
|
|
||||||
runs-on: windows-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-win.exe init --repository $Env:GITHUB_REPOSITORY --languages javascript --github-url $Env:GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
|
||||||
|
|
||||||
- name: Run analyze
|
|
||||||
run: |
|
|
||||||
runner/dist/codeql-runner-win.exe analyze --repository $Env:GITHUB_REPOSITORY --commit $Env:GITHUB_SHA --ref $Env:GITHUB_REF --github-url $Env:GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
|
||||||
env:
|
|
||||||
TEST_MODE: true
|
|
||||||
|
|
||||||
runner-analyze-javascript-macos:
|
|
||||||
needs: [check-js, check-node-modules]
|
|
||||||
runs-on: macos-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-macos init --repository $GITHUB_REPOSITORY --languages javascript --config-file ./.github/codeql/codeql-config.yml --github-url $GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
|
||||||
|
|
||||||
- name: Run analyze
|
|
||||||
run: |
|
|
||||||
runner/dist/codeql-runner-macos analyze --repository $GITHUB_REPOSITORY --commit $GITHUB_SHA --ref $GITHUB_REF --github-url $GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
|
||||||
env:
|
|
||||||
TEST_MODE: true
|
|
||||||
|
|
||||||
runner-analyze-csharp-ubuntu:
|
|
||||||
needs: [check-js, check-node-modules]
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Move codeql-action
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
mkdir ../action
|
|
||||||
mv * .github ../action/
|
|
||||||
mv ../action/tests/multi-language-repo/{*,.github} .
|
|
||||||
mv ../action/.github/workflows .github
|
|
||||||
|
|
||||||
- name: Build runner
|
|
||||||
run: |
|
|
||||||
cd ../action/runner
|
|
||||||
npm install
|
|
||||||
npm run build-runner
|
|
||||||
|
|
||||||
- name: Run init
|
|
||||||
run: |
|
|
||||||
../action/runner/dist/codeql-runner-linux init --repository $GITHUB_REPOSITORY --languages csharp --github-url $GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
|
||||||
|
|
||||||
- name: Build code
|
|
||||||
run: |
|
|
||||||
. ./codeql-runner/codeql-env.sh
|
|
||||||
$CODEQL_RUNNER dotnet build
|
|
||||||
|
|
||||||
- name: Run analyze
|
|
||||||
run: |
|
|
||||||
../action/runner/dist/codeql-runner-linux analyze --repository $GITHUB_REPOSITORY --commit $GITHUB_SHA --ref $GITHUB_REF --github-url $GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
|
||||||
env:
|
|
||||||
TEST_MODE: true
|
|
||||||
|
|
||||||
runner-analyze-csharp-windows:
|
|
||||||
needs: [check-js, check-node-modules]
|
|
||||||
runs-on: windows-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Move codeql-action
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
mkdir ../action
|
|
||||||
mv * .github ../action/
|
|
||||||
mv ../action/tests/multi-language-repo/{*,.github} .
|
|
||||||
mv ../action/.github/workflows .github
|
|
||||||
|
|
||||||
- name: Build runner
|
|
||||||
run: |
|
|
||||||
cd ../action/runner
|
|
||||||
npm install
|
|
||||||
npm run build-runner
|
|
||||||
|
|
||||||
- name: Run init
|
|
||||||
run: |
|
|
||||||
../action/runner/dist/codeql-runner-win.exe init --repository $Env:GITHUB_REPOSITORY --languages csharp --github-url $Env:GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
|
||||||
|
|
||||||
- name: Build code
|
|
||||||
shell: powershell
|
|
||||||
# Note we want to make sure that the .win32env file is read correctly, so we unset the CODEQL_EXTRACTOR_CSHARP_ROOT from the .sh file.
|
|
||||||
run: |
|
|
||||||
cat ./codeql-runner/codeql-env.sh | Invoke-Expression
|
|
||||||
$Env:CODEQL_EXTRACTOR_CSHARP_ROOT = ""
|
|
||||||
& $Env:CODEQL_RUNNER dotnet build
|
|
||||||
|
|
||||||
- name: Run analyze
|
|
||||||
run: |
|
|
||||||
../action/runner/dist/codeql-runner-win.exe analyze --repository $Env:GITHUB_REPOSITORY --commit $Env:GITHUB_SHA --ref $Env:GITHUB_REF --github-url $Env:GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
|
||||||
env:
|
|
||||||
TEST_MODE: true
|
|
||||||
|
|
||||||
runner-analyze-csharp-macos:
|
|
||||||
needs: [check-js, check-node-modules]
|
|
||||||
runs-on: macos-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Move codeql-action
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
mkdir ../action
|
|
||||||
mv * .github ../action/
|
|
||||||
mv ../action/tests/multi-language-repo/{*,.github} .
|
|
||||||
mv ../action/.github/workflows .github
|
|
||||||
|
|
||||||
- name: Build runner
|
|
||||||
run: |
|
|
||||||
cd ../action/runner
|
|
||||||
npm install
|
|
||||||
npm run build-runner
|
|
||||||
|
|
||||||
- name: Run init
|
|
||||||
run: |
|
|
||||||
../action/runner/dist/codeql-runner-macos init --repository $GITHUB_REPOSITORY --languages csharp --github-url $GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
|
||||||
|
|
||||||
- name: Build code
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
. ./codeql-runner/codeql-env.sh
|
|
||||||
$CODEQL_RUNNER dotnet build
|
|
||||||
|
|
||||||
- name: Run analyze
|
|
||||||
run: |
|
|
||||||
../action/runner/dist/codeql-runner-macos analyze --repository $GITHUB_REPOSITORY --commit $GITHUB_SHA --ref $GITHUB_REF --github-url $GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
|
||||||
env:
|
|
||||||
TEST_MODE: true
|
|
||||||
|
|
||||||
|
|
||||||
runner-analyze-csharp-autobuild-ubuntu:
|
|
||||||
needs: [check-js, check-node-modules]
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Move codeql-action
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
mkdir ../action
|
|
||||||
mv * .github ../action/
|
|
||||||
mv ../action/tests/multi-language-repo/{*,.github} .
|
|
||||||
mv ../action/.github/workflows .github
|
|
||||||
|
|
||||||
- name: Build runner
|
|
||||||
run: |
|
|
||||||
cd ../action/runner
|
|
||||||
npm install
|
|
||||||
npm run build-runner
|
|
||||||
|
|
||||||
- name: Run init
|
|
||||||
run: |
|
|
||||||
../action/runner/dist/codeql-runner-linux init --repository $GITHUB_REPOSITORY --languages csharp --github-url $GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
|
||||||
|
|
||||||
- name: Build code
|
|
||||||
run: |
|
|
||||||
../action/runner/dist/codeql-runner-linux autobuild
|
|
||||||
|
|
||||||
- name: Run analyze
|
|
||||||
run: |
|
|
||||||
../action/runner/dist/codeql-runner-linux analyze --repository $GITHUB_REPOSITORY --commit $GITHUB_SHA --ref $GITHUB_REF --github-url $GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
|
||||||
env:
|
|
||||||
TEST_MODE: true
|
|
||||||
|
|
||||||
runner-analyze-csharp-autobuild-windows:
|
|
||||||
needs: [check-js, check-node-modules]
|
|
||||||
runs-on: windows-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Move codeql-action
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
mkdir ../action
|
|
||||||
mv * .github ../action/
|
|
||||||
mv ../action/tests/multi-language-repo/{*,.github} .
|
|
||||||
mv ../action/.github/workflows .github
|
|
||||||
|
|
||||||
- name: Build runner
|
|
||||||
run: |
|
|
||||||
cd ../action/runner
|
|
||||||
npm install
|
|
||||||
npm run build-runner
|
|
||||||
|
|
||||||
- name: Run init
|
|
||||||
run: |
|
|
||||||
../action/runner/dist/codeql-runner-win.exe init --repository $Env:GITHUB_REPOSITORY --languages csharp --github-url $Env:GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
|
||||||
|
|
||||||
- name: Build code
|
|
||||||
shell: powershell
|
|
||||||
run: |
|
|
||||||
../action/runner/dist/codeql-runner-win.exe autobuild
|
|
||||||
|
|
||||||
- name: Run analyze
|
|
||||||
run: |
|
|
||||||
../action/runner/dist/codeql-runner-win.exe analyze --repository $Env:GITHUB_REPOSITORY --commit $Env:GITHUB_SHA --ref $Env:GITHUB_REF --github-url $Env:GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
|
||||||
env:
|
|
||||||
TEST_MODE: true
|
|
||||||
|
|
||||||
runner-analyze-csharp-autobuild-macos:
|
|
||||||
needs: [check-js, check-node-modules]
|
|
||||||
runs-on: macos-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Move codeql-action
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
mkdir ../action
|
|
||||||
mv * .github ../action/
|
|
||||||
mv ../action/tests/multi-language-repo/{*,.github} .
|
|
||||||
mv ../action/.github/workflows .github
|
|
||||||
|
|
||||||
- name: Build runner
|
|
||||||
run: |
|
|
||||||
cd ../action/runner
|
|
||||||
npm install
|
|
||||||
npm run build-runner
|
|
||||||
|
|
||||||
- name: Run init
|
|
||||||
run: |
|
|
||||||
../action/runner/dist/codeql-runner-macos init --repository $GITHUB_REPOSITORY --languages csharp --github-url $GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
|
||||||
|
|
||||||
- name: Build code
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
../action/runner/dist/codeql-runner-macos autobuild
|
|
||||||
|
|
||||||
- name: Run analyze
|
|
||||||
run: |
|
|
||||||
../action/runner/dist/codeql-runner-macos analyze --repository $GITHUB_REPOSITORY --commit $GITHUB_SHA --ref $GITHUB_REF --github-url $GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
|
||||||
env:
|
|
||||||
TEST_MODE: true
|
|
||||||
|
|
||||||
runner-upload-sarif:
|
|
||||||
needs: [check-js, check-node-modules]
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id }}
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Build runner
|
|
||||||
run: |
|
|
||||||
cd runner
|
|
||||||
npm install
|
|
||||||
npm run build-runner
|
|
||||||
|
|
||||||
- name: Upload with runner
|
|
||||||
run: |
|
|
||||||
# Deliberately don't use TEST_MODE here. This is specifically testing
|
|
||||||
# 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 }}
|
|
||||||
|
|||||||
152
.github/workflows/python-deps.yml
vendored
152
.github/workflows/python-deps.yml
vendored
@@ -1,150 +1,64 @@
|
|||||||
name: Test Python Package Installation on Linux and Mac
|
name: Test Python Package Installation
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main, v1]
|
|
||||||
pull_request:
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
test-setup-python-scripts:
|
test-setup-python-scripts:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, macos-latest]
|
os: [ubuntu-latest,windows-latest,macos-latest]
|
||||||
python_deps_type: [pipenv, poetry, requirements, setup_py]
|
include:
|
||||||
python_version: [2, 3]
|
- test_dir: python-setup/tests/pipenv/requests-2
|
||||||
|
test_script: $GITHUB_WORKSPACE/python-setup/tests/check_requests_123.sh 2
|
||||||
|
- test_dir: python-setup/tests/pipenv/requests-3
|
||||||
|
test_script: $GITHUB_WORKSPACE/python-setup/tests/check_requests_123.sh 3
|
||||||
|
|
||||||
env:
|
- test_dir: python-setup/tests/poetry/requests-2
|
||||||
PYTHON_DEPS_TYPE: ${{ matrix.python_deps_type }}
|
test_script: $GITHUB_WORKSPACE/python-setup/tests/check_requests_123.sh 2
|
||||||
PYTHON_VERSION: ${{ matrix.python_version }}
|
- test_dir: python-setup/tests/poetry/requests-3
|
||||||
|
test_script: $GITHUB_WORKSPACE/python-setup/tests/check_requests_123.sh 3
|
||||||
|
|
||||||
|
- test_dir: python-setup/tests/requirements/requests-2
|
||||||
|
test_script: $GITHUB_WORKSPACE/python-setup/tests/check_requests_123.sh 2
|
||||||
|
- test_dir: python-setup/tests/requirements/requests-3
|
||||||
|
test_script: $GITHUB_WORKSPACE/python-setup/tests/check_requests_123.sh 3
|
||||||
|
|
||||||
|
- test_dir: python-setup/tests/setup_py/requests-2
|
||||||
|
test_script: $GITHUB_WORKSPACE/python-setup/tests/check_requests_123.sh 2
|
||||||
|
- test_dir: python-setup/tests/setup_py/requests-3
|
||||||
|
test_script: $GITHUB_WORKSPACE/python-setup/tests/check_requests_123.sh 3
|
||||||
|
|
||||||
|
# This one shouldn't fail, but also won't install packages
|
||||||
|
- test_dir: python-setup/tests/requirements/non-standard-location
|
||||||
|
test_script: test -z $LGTM_INDEX_IMPORT_PATH
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Initialize CodeQL
|
- name: Initialize CodeQL
|
||||||
uses: ./init
|
uses: github/codeql-action/init@v1
|
||||||
id: init
|
|
||||||
with:
|
with:
|
||||||
tools: latest
|
|
||||||
languages: python
|
languages: python
|
||||||
setup-python-dependencies: false
|
|
||||||
|
|
||||||
- name: Test Auto Package Installation
|
- name: Test Auto Package Installation
|
||||||
run: |
|
run: |
|
||||||
set -x
|
set -x
|
||||||
$GITHUB_WORKSPACE/python-setup/install_tools.sh
|
$GITHUB_WORKSPACE/python-setup/install_tools.sh
|
||||||
|
echo -e '\n\n\n\n\n' && sleep 0.5
|
||||||
cd $GITHUB_WORKSPACE/python-setup/tests/${PYTHON_DEPS_TYPE}/requests-${PYTHON_VERSION}
|
cd $GITHUB_WORKSPACE/${{ matrix.test_dir }}
|
||||||
|
$GITHUB_WORKSPACE/python-setup/auto_install_packages.py /opt/hostedtoolcache/CodeQL/0.0.0-20200826/x64/codeql/
|
||||||
case ${{ matrix.os }} in
|
/bin/true
|
||||||
ubuntu-latest*) basePath="/opt";;
|
|
||||||
macos-latest*) basePath="/Users/runner";;
|
|
||||||
esac
|
|
||||||
echo ${basePath}
|
|
||||||
|
|
||||||
$GITHUB_WORKSPACE/python-setup/auto_install_packages.py "$(dirname ${{steps.init.outputs.codeql-path}})"
|
|
||||||
- name: Setup for extractor
|
- name: Setup for extractor
|
||||||
run: |
|
run: |
|
||||||
echo $CODEQL_PYTHON
|
echo $CODEQL_PYTHON
|
||||||
# only run if $CODEQL_PYTHON is set
|
# only run if $CODEQL_PYTHON is set
|
||||||
if [ ! -z $CODEQL_PYTHON ]; then
|
test ! -z $CODEQL_PYTHON && $GITHUB_WORKSPACE/python-setup/tests/from_python_exe.py $CODEQL_PYTHON || /bin/true
|
||||||
$GITHUB_WORKSPACE/python-setup/tests/from_python_exe.py $CODEQL_PYTHON;
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Verify packages installed
|
- name: Verify packages installed
|
||||||
run: |
|
run: |
|
||||||
$GITHUB_WORKSPACE/python-setup/tests/check_requests_123.sh ${PYTHON_VERSION}
|
${{ matrix.test_script }}
|
||||||
|
|
||||||
# This one shouldn't fail, but also won't install packages
|
|
||||||
test-setup-python-scripts-non-standard-location:
|
|
||||||
runs-on: ${{ matrix.os }}
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
os: [ubuntu-latest, macos-latest]
|
|
||||||
|
|
||||||
steps:
|
|
||||||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Initialize CodeQL
|
|
||||||
uses: ./init
|
|
||||||
id: init
|
|
||||||
with:
|
|
||||||
tools: latest
|
|
||||||
languages: python
|
|
||||||
setup-python-dependencies: false
|
|
||||||
|
|
||||||
- name: Test Auto Package Installation
|
|
||||||
run: |
|
|
||||||
set -x
|
|
||||||
$GITHUB_WORKSPACE/python-setup/install_tools.sh
|
|
||||||
|
|
||||||
cd $GITHUB_WORKSPACE/python-setup/tests/requirements/non-standard-location
|
|
||||||
|
|
||||||
case ${{ matrix.os }} in
|
|
||||||
ubuntu-latest*) basePath="/opt";;
|
|
||||||
macos-latest*) basePath="/Users/runner";;
|
|
||||||
esac
|
|
||||||
echo ${basePath}
|
|
||||||
|
|
||||||
$GITHUB_WORKSPACE/python-setup/auto_install_packages.py "$(dirname ${{steps.init.outputs.codeql-path}})"
|
|
||||||
|
|
||||||
- name: Setup for extractor
|
|
||||||
run: |
|
|
||||||
echo $CODEQL_PYTHON
|
|
||||||
# only run if $CODEQL_PYTHON is set
|
|
||||||
if [ ! -z $CODEQL_PYTHON ]; then
|
|
||||||
$GITHUB_WORKSPACE/python-setup/tests/from_python_exe.py $CODEQL_PYTHON;
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Verify packages installed
|
|
||||||
run: |
|
|
||||||
test -z $LGTM_INDEX_IMPORT_PATH
|
|
||||||
|
|
||||||
test-setup-python-scripts-windows:
|
|
||||||
runs-on: windows-latest
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
python_deps_type: [pipenv, poetry, requirements, setup_py]
|
|
||||||
python_version: [2, 3]
|
|
||||||
|
|
||||||
env:
|
|
||||||
PYTHON_DEPS_TYPE: ${{ matrix.python_deps_type }}
|
|
||||||
PYTHON_VERSION: ${{ matrix.python_version }}
|
|
||||||
|
|
||||||
steps:
|
|
||||||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Initialize CodeQL
|
|
||||||
uses: ./init
|
|
||||||
with:
|
|
||||||
tools: latest
|
|
||||||
languages: python
|
|
||||||
setup-python-dependencies: false
|
|
||||||
|
|
||||||
- name: Test Auto Package Installation
|
|
||||||
run: |
|
|
||||||
$cmd = $Env:GITHUB_WORKSPACE + "\\python-setup\\install_tools.ps1"
|
|
||||||
powershell -File $cmd
|
|
||||||
|
|
||||||
cd $Env:GITHUB_WORKSPACE\\python-setup/tests/$Env:PYTHON_DEPS_TYPE/requests-$Env:PYTHON_VERSION
|
|
||||||
$DefaultsPath = Join-Path (Join-Path $Env:GITHUB_WORKSPACE "src") "defaults.json"
|
|
||||||
$CodeQLBundleName = (Get-Content -Raw -Path $DefaultsPath | ConvertFrom-Json).bundleVersion
|
|
||||||
$CodeQLVersion = "0.0.0-" + $CodeQLBundleName.split("-")[-1]
|
|
||||||
py -3 $Env:GITHUB_WORKSPACE\\python-setup\\auto_install_packages.py C:\\hostedtoolcache\\windows\\CodeQL\\$CodeQLVersion\\x64\\codeql
|
|
||||||
|
|
||||||
- name: Setup for extractor
|
|
||||||
run: |
|
|
||||||
echo $Env:CODEQL_PYTHON
|
|
||||||
|
|
||||||
py -3 $Env:GITHUB_WORKSPACE\\python-setup\\tests\\from_python_exe.py $Env:CODEQL_PYTHON
|
|
||||||
|
|
||||||
- name: Verify packages installed
|
|
||||||
run: |
|
|
||||||
$cmd = $Env:GITHUB_WORKSPACE + "\\python-setup\\tests\\check_requests_123.ps1"
|
|
||||||
powershell -File $cmd $Env:PYTHON_VERSION
|
|
||||||
54
.github/workflows/release-runner.yml
vendored
54
.github/workflows/release-runner.yml
vendored
@@ -1,54 +0,0 @@
|
|||||||
name: Release runner
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
bundle-tag:
|
|
||||||
description: 'Tag of the bundle release (e.g., "codeql-bundle-20200826")'
|
|
||||||
required: false
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
release-runner:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
env:
|
|
||||||
RELEASE_TAG: "${{ github.event.inputs.bundle-tag }}"
|
|
||||||
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
extension: ["linux", "macos", "win.exe"]
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Build runner
|
|
||||||
run: |
|
|
||||||
cd runner
|
|
||||||
npm install
|
|
||||||
npm run build-runner
|
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v2
|
|
||||||
with:
|
|
||||||
name: codeql-runner-${{matrix.extension}}
|
|
||||||
path: runner/dist/codeql-runner-${{matrix.extension}}
|
|
||||||
|
|
||||||
- name: Resolve Upload URL for the release
|
|
||||||
if: ${{ github.event.inputs.bundle-tag != null }}
|
|
||||||
id: save_url
|
|
||||||
run: |
|
|
||||||
UPLOAD_URL=$(curl -sS \
|
|
||||||
"https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/tags/${RELEASE_TAG}" \
|
|
||||||
-H "Accept: application/json" \
|
|
||||||
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" | jq .upload_url | sed s/\"//g)
|
|
||||||
echo ${UPLOAD_URL}
|
|
||||||
echo "::set-output name=upload_url::${UPLOAD_URL}"
|
|
||||||
|
|
||||||
- name: Upload Platform Package
|
|
||||||
if: ${{ github.event.inputs.bundle-tag != null }}
|
|
||||||
uses: actions/upload-release-asset@v1
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
|
||||||
upload_url: ${{ steps.save_url.outputs.upload_url }}
|
|
||||||
asset_path: runner/dist/codeql-runner-${{matrix.extension}}
|
|
||||||
asset_name: codeql-runner-${{matrix.extension}}
|
|
||||||
asset_content_type: application/octet-stream
|
|
||||||
21
.github/workflows/script/check-js.sh
vendored
21
.github/workflows/script/check-js.sh
vendored
@@ -1,21 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -eu
|
|
||||||
|
|
||||||
# Sanity check that repo is clean to start with
|
|
||||||
if [ ! -z "$(git status --porcelain)" ]; then
|
|
||||||
# If we get a fail here then this workflow needs attention...
|
|
||||||
>&2 echo "Failed: Repo should be clean before testing!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
# Wipe the lib directory incase there are extra unnecessary files in there
|
|
||||||
rm -rf lib
|
|
||||||
# Generate the JavaScript files
|
|
||||||
npm run-script build
|
|
||||||
# Check that repo is still clean
|
|
||||||
if [ ! -z "$(git status --porcelain)" ]; then
|
|
||||||
# If we get a fail here then the PR needs attention
|
|
||||||
>&2 echo "Failed: JavaScript files are not up to date. Run 'npm run-script build' to update"
|
|
||||||
git status
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo "Success: JavaScript files are up to date"
|
|
||||||
21
.github/workflows/script/check-node-modules.sh
vendored
21
.github/workflows/script/check-node-modules.sh
vendored
@@ -1,21 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -eu
|
|
||||||
|
|
||||||
# Sanity check that repo is clean to start with
|
|
||||||
if [ ! -z "$(git status --porcelain)" ]; then
|
|
||||||
# If we get a fail here then this workflow needs attention...
|
|
||||||
>&2 echo "Failed: Repo should be clean before testing!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
# Reinstall modules and then clean to remove absolute paths
|
|
||||||
# Use 'npm ci' instead of 'npm install' as this is intended to be reproducible
|
|
||||||
npm ci
|
|
||||||
npm run removeNPMAbsolutePaths
|
|
||||||
# Check that repo is still clean
|
|
||||||
if [ ! -z "$(git status --porcelain)" ]; then
|
|
||||||
# If we get a fail here then the PR needs attention
|
|
||||||
>&2 echo "Failed: node_modules are not up to date. Run 'npm ci' and 'npm run removeNPMAbsolutePaths' to update"
|
|
||||||
git status
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo "Success: node_modules are up to date"
|
|
||||||
1
.github/workflows/update-release-branch.yml
vendored
1
.github/workflows/update-release-branch.yml
vendored
@@ -12,7 +12,6 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
update:
|
update:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: ${{ github.repository == 'github/codeql-action' }}
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
name: Update Supported Enterprise Server Versions
|
|
||||||
|
|
||||||
on:
|
|
||||||
schedule:
|
|
||||||
- cron: "0 0 * * *"
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
update-supported-enterprise-server-versions:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Setup Python
|
|
||||||
uses: actions/setup-python@v2
|
|
||||||
with:
|
|
||||||
python-version: "3.7"
|
|
||||||
- name: Checkout CodeQL Action
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
- name: Checkout Enterprise Releases
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
repository: github/enterprise-releases
|
|
||||||
ssh-key: ${{ secrets.ENTERPRISE_RELEASES_SSH_KEY }}
|
|
||||||
path: ${{ github.workspace }}/enterprise-releases/
|
|
||||||
- name: Update Supported Enterprise Server Versions
|
|
||||||
run: |
|
|
||||||
cd ./.github/workflows/update-supported-enterprise-server-versions/
|
|
||||||
python3 -m pip install pipenv
|
|
||||||
pipenv install
|
|
||||||
pipenv run ./update.py
|
|
||||||
rm --recursive "$ENTERPRISE_RELEASES_PATH"
|
|
||||||
npm run build
|
|
||||||
env:
|
|
||||||
ENTERPRISE_RELEASES_PATH: ${{ github.workspace }}/enterprise-releases/
|
|
||||||
- name: Commit Changes
|
|
||||||
uses: peter-evans/create-pull-request@c7f493a8000b8aeb17a1332e326ba76b57cb83eb # v3.4.1
|
|
||||||
with:
|
|
||||||
commit-message: Update supported GitHub Enterprise Server versions.
|
|
||||||
title: Update supported GitHub Enterprise Server versions.
|
|
||||||
body: ""
|
|
||||||
author: GitHub <noreply@github.com>
|
|
||||||
branch: update-supported-enterprise-server-versions
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
import datetime
|
|
||||||
import json
|
|
||||||
import os
|
|
||||||
import pathlib
|
|
||||||
|
|
||||||
import semver
|
|
||||||
|
|
||||||
_API_COMPATIBILITY_PATH = pathlib.Path(__file__).absolute().parents[3] / "src" / "api-compatibility.json"
|
|
||||||
_ENTERPRISE_RELEASES_PATH = pathlib.Path(os.environ["ENTERPRISE_RELEASES_PATH"])
|
|
||||||
_RELEASE_FILE_PATH = _ENTERPRISE_RELEASES_PATH / "releases.json"
|
|
||||||
_FIRST_SUPPORTED_RELEASE = semver.VersionInfo.parse("2.22.0") # Versions older than this did not include Code Scanning.
|
|
||||||
|
|
||||||
def main():
|
|
||||||
api_compatibility_data = json.loads(_API_COMPATIBILITY_PATH.read_text())
|
|
||||||
|
|
||||||
releases = json.loads(_RELEASE_FILE_PATH.read_text())
|
|
||||||
oldest_supported_release = None
|
|
||||||
newest_supported_release = semver.VersionInfo.parse(api_compatibility_data["maximumVersion"] + ".0")
|
|
||||||
|
|
||||||
for release_version_string, release_data in releases.items():
|
|
||||||
release_version = semver.VersionInfo.parse(release_version_string + ".0")
|
|
||||||
if release_version < _FIRST_SUPPORTED_RELEASE:
|
|
||||||
continue
|
|
||||||
|
|
||||||
if release_version > newest_supported_release:
|
|
||||||
feature_freeze_date = datetime.date.fromisoformat(release_data["feature_freeze"])
|
|
||||||
if feature_freeze_date < datetime.date.today() + datetime.timedelta(weeks=2):
|
|
||||||
newest_supported_release = release_version
|
|
||||||
|
|
||||||
if oldest_supported_release is None or release_version < oldest_supported_release:
|
|
||||||
end_of_life_date = datetime.date.fromisoformat(release_data["end"])
|
|
||||||
if end_of_life_date > datetime.date.today():
|
|
||||||
oldest_supported_release = release_version
|
|
||||||
|
|
||||||
api_compatibility_data = {
|
|
||||||
"minimumVersion": f"{oldest_supported_release.major}.{oldest_supported_release.minor}",
|
|
||||||
"maximumVersion": f"{newest_supported_release.major}.{newest_supported_release.minor}",
|
|
||||||
}
|
|
||||||
_API_COMPATIBILITY_PATH.write_text(json.dumps(api_compatibility_data, sort_keys=True) + "\n")
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
15
.vscode/tasks.json
vendored
15
.vscode/tasks.json
vendored
@@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"version": "2.0.0",
|
|
||||||
"tasks": [
|
|
||||||
{
|
|
||||||
"type": "typescript",
|
|
||||||
"tsconfig": "tsconfig.json",
|
|
||||||
"option": "watch",
|
|
||||||
"problemMatcher": [
|
|
||||||
"$tsc-watch"
|
|
||||||
],
|
|
||||||
"group": "build",
|
|
||||||
"label": "tsc: watch - tsconfig.json"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -22,14 +22,6 @@ Before you start, ensure that you have a recent version of node installed. You c
|
|||||||
|
|
||||||
This project also includes configuration to run tests from VSCode (with support for breakpoints) - open the test file you wish to run and choose "Debug AVA test file" from the Run menu in the Run panel.
|
This project also includes configuration to run tests from VSCode (with support for breakpoints) - open the test file you wish to run and choose "Debug AVA test file" from the Run menu in the Run panel.
|
||||||
|
|
||||||
You may want to run `tsc --watch` from the command line or inside of vscode in order to ensure build artifacts are up to date as you are working.
|
|
||||||
|
|
||||||
### Checking in compiled artifacts and `node_modules`
|
|
||||||
|
|
||||||
Because CodeQL Action users consume the code directly from this repository, and there can be no build step during an GitHub Actions run, this repository contains all compiled artifacts and node modules. There is a PR check that will fail if any of the compiled artifacts are not up to date. Compiled artifacts are stored in the `lib/` directory. For all day-to-day development purposes, this folder can be ignored.
|
|
||||||
|
|
||||||
Only run `npm install` if you are explicitly changing the set of dependencies in `package.json`. The `node_modules` directory should be up to date when you check out, but if for some reason, there is an inconsistency use `npm ci && npm run removeNPMAbsolutePaths` to ensure the directory is in a state consistent with the `package-lock.json`. There is a PR check to ensure the consistency of the `node_modules` directory.
|
|
||||||
|
|
||||||
### Running the action
|
### Running the action
|
||||||
|
|
||||||
To see the effect of your changes and to test them, push your changes in a branch and then look at the [Actions output](https://github.com/github/codeql-action/actions) for that branch. You can also exercise the code locally by running the automated tests.
|
To see the effect of your changes and to test them, push your changes in a branch and then look at the [Actions output](https://github.com/github/codeql-action/actions) for that branch. You can also exercise the code locally by running the automated tests.
|
||||||
@@ -44,7 +36,6 @@ It is possible to run this action locally via [act](https://github.com/nektos/ac
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
CODEQL_LOCAL_RUN=true
|
CODEQL_LOCAL_RUN=true
|
||||||
GITHUB_SERVER_URL=https://github.com
|
|
||||||
|
|
||||||
# Optional, for better logging
|
# Optional, for better logging
|
||||||
GITHUB_JOB=<ANY_JOB_NAME>
|
GITHUB_JOB=<ANY_JOB_NAME>
|
||||||
|
|||||||
33
README.md
33
README.md
@@ -22,16 +22,7 @@ on:
|
|||||||
push:
|
push:
|
||||||
pull_request:
|
pull_request:
|
||||||
schedule:
|
schedule:
|
||||||
# ┌───────────── minute (0 - 59)
|
- cron: '0 0 * * 0'
|
||||||
# │ ┌───────────── hour (0 - 23)
|
|
||||||
# │ │ ┌───────────── day of the month (1 - 31)
|
|
||||||
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
|
|
||||||
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
|
|
||||||
# │ │ │ │ │
|
|
||||||
# │ │ │ │ │
|
|
||||||
# │ │ │ │ │
|
|
||||||
# * * * * *
|
|
||||||
- cron: '30 1 * * 0'
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
CodeQL-Build:
|
CodeQL-Build:
|
||||||
@@ -41,6 +32,17 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
# Must fetch at least the immediate parents so that if this is
|
||||||
|
# a pull request then we can checkout the head of the pull request.
|
||||||
|
# Only include this option if you are running this workflow on pull requests.
|
||||||
|
fetch-depth: 2
|
||||||
|
|
||||||
|
# If this run was triggered by a pull request event then checkout
|
||||||
|
# the head of the pull request instead of the merge commit.
|
||||||
|
# Only include this step if you are running this workflow on pull requests.
|
||||||
|
- run: git checkout HEAD^2
|
||||||
|
if: ${{ github.event_name == 'pull_request' }}
|
||||||
|
|
||||||
# Initializes the CodeQL tools for scanning.
|
# Initializes the CodeQL tools for scanning.
|
||||||
- name: Initialize CodeQL
|
- name: Initialize CodeQL
|
||||||
@@ -96,16 +98,7 @@ Use the `config-file` parameter of the `init` action to enable the configuration
|
|||||||
config-file: ./.github/codeql/codeql-config.yml
|
config-file: ./.github/codeql/codeql-config.yml
|
||||||
```
|
```
|
||||||
|
|
||||||
The configuration file can be located in a different repository. This is useful if you want to share the same configuration across multiple repositories. If the configuration file is in a private repository you can also specify an `external-repository-token` option. This should be a personal access token that has read access to any repositories containing referenced config files and queries.
|
The configuration file must be located within the local repository. For information on how to write a configuration file, see "[Using a custom configuration file](https://help.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#using-a-custom-configuration-file)."
|
||||||
|
|
||||||
```yaml
|
|
||||||
- uses: github/codeql-action/init@v1
|
|
||||||
with:
|
|
||||||
config-file: owner/repo/codeql-config.yml@branch
|
|
||||||
external-repository-token: ${{ secrets.EXTERNAL_REPOSITORY_TOKEN }}
|
|
||||||
```
|
|
||||||
|
|
||||||
For information on how to write a configuration file, see "[Using a custom configuration file](https://help.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#using-a-custom-configuration-file)."
|
|
||||||
|
|
||||||
If you only want to customise the queries used, you can specify them in your workflow instead of creating a config file, using the `queries` property of the `init` action:
|
If you only want to customise the queries used, you can specify them in your workflow instead of creating a config file, using the `queries` property of the `init` action:
|
||||||
|
|
||||||
|
|||||||
@@ -24,12 +24,9 @@ inputs:
|
|||||||
description: The number of threads to be used by CodeQL.
|
description: The number of threads to be used by CodeQL.
|
||||||
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 relativeize any absolute paths in the uploaded SARIF file."
|
||||||
required: false
|
required: false
|
||||||
default: ${{ github.workspace }}
|
default: ${{ github.workspace }}
|
||||||
category:
|
|
||||||
description: String used by Code Scanning for matching the analyses
|
|
||||||
required: false
|
|
||||||
token:
|
token:
|
||||||
default: ${{ github.token }}
|
default: ${{ github.token }}
|
||||||
matrix:
|
matrix:
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
name: 'CodeQL: Init'
|
name: 'CodeQL: Init'
|
||||||
description: 'Set up CodeQL'
|
description: 'Setup the CodeQL tracer'
|
||||||
author: 'GitHub'
|
author: 'GitHub'
|
||||||
inputs:
|
inputs:
|
||||||
tools:
|
tools:
|
||||||
@@ -19,16 +19,10 @@ inputs:
|
|||||||
queries:
|
queries:
|
||||||
description: Comma-separated list of additional queries to run. By default, this overrides the same setting in a configuration file; prefix with "+" to use both sets of queries.
|
description: Comma-separated list of additional queries to run. By default, this overrides the same setting in a configuration file; prefix with "+" to use both sets of queries.
|
||||||
required: false
|
required: false
|
||||||
external-repository-token:
|
|
||||||
description: A token for fetching external config files and queries if they reside in a private repository.
|
|
||||||
required: false
|
|
||||||
setup-python-dependencies:
|
setup-python-dependencies:
|
||||||
description: Try to auto-install your python dependencies
|
description: Try to auto-install your python dependencies
|
||||||
required: true
|
required: true
|
||||||
default: 'true'
|
default: 'true'
|
||||||
outputs:
|
|
||||||
codeql-path:
|
|
||||||
description: The path of the CodeQL binary used for analysis
|
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: 'node12'
|
||||||
main: '../lib/init-action.js'
|
main: '../lib/init-action.js'
|
||||||
|
|||||||
384
lib/actions-util.js
generated
384
lib/actions-util.js
generated
@@ -7,12 +7,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const fs = __importStar(require("fs"));
|
|
||||||
const path = __importStar(require("path"));
|
|
||||||
const core = __importStar(require("@actions/core"));
|
const core = __importStar(require("@actions/core"));
|
||||||
const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
|
const toolrunnner = __importStar(require("@actions/exec/lib/toolrunner"));
|
||||||
const safeWhich = __importStar(require("@chrisgavin/safe-which"));
|
|
||||||
const yaml = __importStar(require("js-yaml"));
|
|
||||||
const api = __importStar(require("./api-client"));
|
const api = __importStar(require("./api-client"));
|
||||||
const sharedEnv = __importStar(require("./shared-environment"));
|
const sharedEnv = __importStar(require("./shared-environment"));
|
||||||
const util_1 = require("./util");
|
const util_1 = require("./util");
|
||||||
@@ -51,20 +47,6 @@ function getRequiredEnvParam(paramName) {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
exports.getRequiredEnvParam = getRequiredEnvParam;
|
exports.getRequiredEnvParam = getRequiredEnvParam;
|
||||||
function getTemporaryDirectory() {
|
|
||||||
const value = process.env["CODEQL_ACTION_TEMP"];
|
|
||||||
return value !== undefined && value !== ""
|
|
||||||
? value
|
|
||||||
: getRequiredEnvParam("RUNNER_TEMP");
|
|
||||||
}
|
|
||||||
exports.getTemporaryDirectory = getTemporaryDirectory;
|
|
||||||
function getToolCacheDirectory() {
|
|
||||||
const value = process.env["CODEQL_ACTION_TOOL_CACHE"];
|
|
||||||
return value !== undefined && value !== ""
|
|
||||||
? value
|
|
||||||
: getRequiredEnvParam("RUNNER_TOOL_CACHE");
|
|
||||||
}
|
|
||||||
exports.getToolCacheDirectory = getToolCacheDirectory;
|
|
||||||
/**
|
/**
|
||||||
* Ensures all required environment variables are set in the context of a local run.
|
* Ensures all required environment variables are set in the context of a local run.
|
||||||
*/
|
*/
|
||||||
@@ -76,15 +58,12 @@ function prepareLocalRunEnvironment() {
|
|||||||
if (!process.env.GITHUB_JOB) {
|
if (!process.env.GITHUB_JOB) {
|
||||||
core.exportVariable("GITHUB_JOB", "UNKNOWN-JOB");
|
core.exportVariable("GITHUB_JOB", "UNKNOWN-JOB");
|
||||||
}
|
}
|
||||||
if (!process.env.CODEQL_ACTION_ANALYSIS_KEY) {
|
|
||||||
core.exportVariable("CODEQL_ACTION_ANALYSIS_KEY", `LOCAL-RUN:${process.env.GITHUB_JOB}`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
exports.prepareLocalRunEnvironment = prepareLocalRunEnvironment;
|
exports.prepareLocalRunEnvironment = prepareLocalRunEnvironment;
|
||||||
/**
|
/**
|
||||||
* Gets the SHA of the commit that is currently checked out.
|
* Gets the SHA of the commit that is currently checked out.
|
||||||
*/
|
*/
|
||||||
exports.getCommitOid = async function (ref = "HEAD") {
|
async function getCommitOid() {
|
||||||
// Try to use git to get the current commit SHA. If that fails then
|
// Try to use git to get the current commit SHA. If that fails then
|
||||||
// log but otherwise silently fall back to using the SHA from the environment.
|
// log but otherwise silently fall back to using the SHA from the environment.
|
||||||
// The only time these two values will differ is during analysis of a PR when
|
// The only time these two values will differ is during analysis of a PR when
|
||||||
@@ -94,7 +73,7 @@ exports.getCommitOid = async function (ref = "HEAD") {
|
|||||||
// reported on the merge commit.
|
// reported on the merge commit.
|
||||||
try {
|
try {
|
||||||
let commitOid = "";
|
let commitOid = "";
|
||||||
await new toolrunner.ToolRunner(await safeWhich.safeWhich("git"), ["rev-parse", ref], {
|
await new toolrunnner.ToolRunner("git", ["rev-parse", "HEAD"], {
|
||||||
silent: true,
|
silent: true,
|
||||||
listeners: {
|
listeners: {
|
||||||
stdout: (data) => {
|
stdout: (data) => {
|
||||||
@@ -111,204 +90,12 @@ exports.getCommitOid = async function (ref = "HEAD") {
|
|||||||
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}`);
|
||||||
return getRequiredEnvParam("GITHUB_SHA");
|
return getRequiredEnvParam("GITHUB_SHA");
|
||||||
}
|
}
|
||||||
};
|
|
||||||
function isObject(o) {
|
|
||||||
return o !== null && typeof o === "object";
|
|
||||||
}
|
}
|
||||||
const GLOB_PATTERN = new RegExp("(\\*\\*?)");
|
exports.getCommitOid = getCommitOid;
|
||||||
function escapeRegExp(string) {
|
|
||||||
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string
|
|
||||||
}
|
|
||||||
function patternToRegExp(value) {
|
|
||||||
return new RegExp(`^${value
|
|
||||||
.toString()
|
|
||||||
.split(GLOB_PATTERN)
|
|
||||||
.reduce(function (arr, cur) {
|
|
||||||
if (cur === "**") {
|
|
||||||
arr.push(".*?");
|
|
||||||
}
|
|
||||||
else if (cur === "*") {
|
|
||||||
arr.push("[^/]*?");
|
|
||||||
}
|
|
||||||
else if (cur) {
|
|
||||||
arr.push(escapeRegExp(cur));
|
|
||||||
}
|
|
||||||
return arr;
|
|
||||||
}, [])
|
|
||||||
.join("")}$`);
|
|
||||||
}
|
|
||||||
// this function should return true if patternA is a superset of patternB
|
|
||||||
// e.g: * is a superset of main-* but main-* is not a superset of *.
|
|
||||||
function patternIsSuperset(patternA, patternB) {
|
|
||||||
return patternToRegExp(patternA).test(patternB);
|
|
||||||
}
|
|
||||||
exports.patternIsSuperset = patternIsSuperset;
|
|
||||||
function branchesToArray(branches) {
|
|
||||||
if (typeof branches === "string") {
|
|
||||||
return [branches];
|
|
||||||
}
|
|
||||||
if (Array.isArray(branches)) {
|
|
||||||
if (branches.length === 0) {
|
|
||||||
return "**";
|
|
||||||
}
|
|
||||||
return branches;
|
|
||||||
}
|
|
||||||
return "**";
|
|
||||||
}
|
|
||||||
function toCodedErrors(errors) {
|
|
||||||
return Object.entries(errors).reduce((acc, [key, value]) => {
|
|
||||||
acc[key] = { message: value, code: key };
|
|
||||||
return acc;
|
|
||||||
}, {});
|
|
||||||
}
|
|
||||||
// code to send back via status report
|
|
||||||
// message to add as a warning annotation to the run
|
|
||||||
exports.WorkflowErrors = toCodedErrors({
|
|
||||||
MismatchedBranches: `Please make sure that every branch in on.pull_request is also in on.push so that Code Scanning can compare pull requests against the state of the base branch.`,
|
|
||||||
MissingPushHook: `Please specify an on.push hook so that Code Scanning can compare pull requests against the state of the base branch.`,
|
|
||||||
PathsSpecified: `Using on.push.paths can prevent Code Scanning annotating new alerts in your pull requests.`,
|
|
||||||
PathsIgnoreSpecified: `Using on.push.paths-ignore can prevent Code Scanning annotating new alerts in your pull requests.`,
|
|
||||||
CheckoutWrongHead: `git checkout HEAD^2 is no longer necessary. Please remove this step as Code Scanning recommends analyzing the merge commit for best results.`,
|
|
||||||
});
|
|
||||||
function getWorkflowErrors(doc) {
|
|
||||||
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
||||||
const errors = [];
|
|
||||||
const jobName = process.env.GITHUB_JOB;
|
|
||||||
if (jobName) {
|
|
||||||
const job = (_b = (_a = doc) === null || _a === void 0 ? void 0 : _a.jobs) === null || _b === void 0 ? void 0 : _b[jobName];
|
|
||||||
const steps = (_c = job) === null || _c === void 0 ? void 0 : _c.steps;
|
|
||||||
if (Array.isArray(steps)) {
|
|
||||||
for (const step of steps) {
|
|
||||||
// this was advice that we used to give in the README
|
|
||||||
// we actually want to run the analysis on the merge commit
|
|
||||||
// to produce results that are more inline with expectations
|
|
||||||
// (i.e: this is what will happen if you merge this PR)
|
|
||||||
// and avoid some race conditions
|
|
||||||
if (((_d = step) === null || _d === void 0 ? void 0 : _d.run) === "git checkout HEAD^2") {
|
|
||||||
errors.push(exports.WorkflowErrors.CheckoutWrongHead);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let missingPush = false;
|
|
||||||
if (doc.on === undefined) {
|
|
||||||
// this is not a valid config
|
|
||||||
}
|
|
||||||
else if (typeof doc.on === "string") {
|
|
||||||
if (doc.on === "pull_request") {
|
|
||||||
missingPush = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (Array.isArray(doc.on)) {
|
|
||||||
const hasPush = doc.on.includes("push");
|
|
||||||
const hasPullRequest = doc.on.includes("pull_request");
|
|
||||||
if (hasPullRequest && !hasPush) {
|
|
||||||
missingPush = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (isObject(doc.on)) {
|
|
||||||
const hasPush = Object.prototype.hasOwnProperty.call(doc.on, "push");
|
|
||||||
const hasPullRequest = Object.prototype.hasOwnProperty.call(doc.on, "pull_request");
|
|
||||||
if (!hasPush && hasPullRequest) {
|
|
||||||
missingPush = true;
|
|
||||||
}
|
|
||||||
if (hasPush && hasPullRequest) {
|
|
||||||
const paths = (_e = doc.on.push) === null || _e === void 0 ? void 0 : _e.paths;
|
|
||||||
// if you specify paths or paths-ignore you can end up with commits that have no baseline
|
|
||||||
// if they didn't change any files
|
|
||||||
// currently we cannot go back through the history and find the most recent baseline
|
|
||||||
if (Array.isArray(paths) && paths.length > 0) {
|
|
||||||
errors.push(exports.WorkflowErrors.PathsSpecified);
|
|
||||||
}
|
|
||||||
const pathsIgnore = (_f = doc.on.push) === null || _f === void 0 ? void 0 : _f["paths-ignore"];
|
|
||||||
if (Array.isArray(pathsIgnore) && pathsIgnore.length > 0) {
|
|
||||||
errors.push(exports.WorkflowErrors.PathsIgnoreSpecified);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// if doc.on.pull_request is null that means 'all branches'
|
|
||||||
// if doc.on.pull_request is undefined that means 'off'
|
|
||||||
// we only want to check for mismatched branches if pull_request is on.
|
|
||||||
if (doc.on.pull_request !== undefined) {
|
|
||||||
const push = branchesToArray((_g = doc.on.push) === null || _g === void 0 ? void 0 : _g.branches);
|
|
||||||
if (push !== "**") {
|
|
||||||
const pull_request = branchesToArray((_h = doc.on.pull_request) === null || _h === void 0 ? void 0 : _h.branches);
|
|
||||||
if (pull_request !== "**") {
|
|
||||||
const difference = pull_request.filter((value) => !push.some((o) => patternIsSuperset(o, value)));
|
|
||||||
if (difference.length > 0) {
|
|
||||||
// there are branches in pull_request that may not have a baseline
|
|
||||||
// because we are not building them on push
|
|
||||||
errors.push(exports.WorkflowErrors.MismatchedBranches);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (push.length > 0) {
|
|
||||||
// push is set up to run on a subset of branches
|
|
||||||
// and you could open a PR against a branch with no baseline
|
|
||||||
errors.push(exports.WorkflowErrors.MismatchedBranches);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (missingPush) {
|
|
||||||
errors.push(exports.WorkflowErrors.MissingPushHook);
|
|
||||||
}
|
|
||||||
return errors;
|
|
||||||
}
|
|
||||||
exports.getWorkflowErrors = getWorkflowErrors;
|
|
||||||
async function validateWorkflow() {
|
|
||||||
let workflow;
|
|
||||||
try {
|
|
||||||
workflow = await getWorkflow();
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
return `error: getWorkflow() failed: ${e.toString()}`;
|
|
||||||
}
|
|
||||||
let workflowErrors;
|
|
||||||
try {
|
|
||||||
workflowErrors = getWorkflowErrors(workflow);
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
return `error: getWorkflowErrors() failed: ${e.toString()}`;
|
|
||||||
}
|
|
||||||
if (workflowErrors.length > 0) {
|
|
||||||
let message;
|
|
||||||
try {
|
|
||||||
message = formatWorkflowErrors(workflowErrors);
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
return `error: formatWorkflowErrors() failed: ${e.toString()}`;
|
|
||||||
}
|
|
||||||
core.warning(message);
|
|
||||||
}
|
|
||||||
return formatWorkflowCause(workflowErrors);
|
|
||||||
}
|
|
||||||
exports.validateWorkflow = validateWorkflow;
|
|
||||||
function formatWorkflowErrors(errors) {
|
|
||||||
const issuesWere = errors.length === 1 ? "issue was" : "issues were";
|
|
||||||
const errorsList = errors.map((e) => e.message).join(" ");
|
|
||||||
return `${errors.length} ${issuesWere} detected with this workflow: ${errorsList}`;
|
|
||||||
}
|
|
||||||
exports.formatWorkflowErrors = formatWorkflowErrors;
|
|
||||||
function formatWorkflowCause(errors) {
|
|
||||||
if (errors.length === 0) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return errors.map((e) => e.code).join(",");
|
|
||||||
}
|
|
||||||
exports.formatWorkflowCause = formatWorkflowCause;
|
|
||||||
async function getWorkflow() {
|
|
||||||
const relativePath = await getWorkflowPath();
|
|
||||||
const absolutePath = path.join(getRequiredEnvParam("GITHUB_WORKSPACE"), relativePath);
|
|
||||||
return yaml.safeLoad(fs.readFileSync(absolutePath, "utf-8"));
|
|
||||||
}
|
|
||||||
exports.getWorkflow = getWorkflow;
|
|
||||||
/**
|
/**
|
||||||
* Get the path of the currently executing workflow.
|
* Get the path of the currently executing workflow.
|
||||||
*/
|
*/
|
||||||
async function getWorkflowPath() {
|
async function getWorkflowPath() {
|
||||||
if (util_1.isLocalRun()) {
|
|
||||||
return getRequiredEnvParam("WORKFLOW_PATH");
|
|
||||||
}
|
|
||||||
const repo_nwo = getRequiredEnvParam("GITHUB_REPOSITORY").split("/");
|
const repo_nwo = getRequiredEnvParam("GITHUB_REPOSITORY").split("/");
|
||||||
const owner = repo_nwo[0];
|
const owner = repo_nwo[0];
|
||||||
const repo = repo_nwo[1];
|
const repo = repo_nwo[1];
|
||||||
@@ -335,7 +122,7 @@ function getWorkflowRunID() {
|
|||||||
}
|
}
|
||||||
exports.getWorkflowRunID = getWorkflowRunID;
|
exports.getWorkflowRunID = getWorkflowRunID;
|
||||||
/**
|
/**
|
||||||
* Get the analysis key parameter for the current job.
|
* Get the analysis key paramter for the current job.
|
||||||
*
|
*
|
||||||
* This will combine the workflow path and current job name.
|
* This will combine the workflow path and current job name.
|
||||||
* Computing this the first time requires making requests to
|
* Computing this the first time requires making requests to
|
||||||
@@ -354,60 +141,20 @@ async function getAnalysisKey() {
|
|||||||
return analysisKey;
|
return analysisKey;
|
||||||
}
|
}
|
||||||
exports.getAnalysisKey = getAnalysisKey;
|
exports.getAnalysisKey = getAnalysisKey;
|
||||||
async function getAutomationID() {
|
|
||||||
const analysis_key = await getAnalysisKey();
|
|
||||||
const environment = getRequiredInput("matrix");
|
|
||||||
return computeAutomationID(analysis_key, environment);
|
|
||||||
}
|
|
||||||
exports.getAutomationID = getAutomationID;
|
|
||||||
function computeAutomationID(analysis_key, environment) {
|
|
||||||
let automationID = `${analysis_key}/`;
|
|
||||||
// the id has to be deterministic so we sort the fields
|
|
||||||
if (environment !== undefined && environment !== "null") {
|
|
||||||
const environmentObject = JSON.parse(environment);
|
|
||||||
for (const entry of Object.entries(environmentObject).sort()) {
|
|
||||||
if (typeof entry[1] === "string") {
|
|
||||||
automationID += `${entry[0]}:${entry[1]}/`;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// In code scanning we just handle the string values,
|
|
||||||
// the rest get converted to the empty string
|
|
||||||
automationID += `${entry[0]}:/`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return automationID;
|
|
||||||
}
|
|
||||||
exports.computeAutomationID = computeAutomationID;
|
|
||||||
/**
|
/**
|
||||||
* Get the ref currently being analyzed.
|
* Get the ref currently being analyzed.
|
||||||
*/
|
*/
|
||||||
async function getRef() {
|
function getRef() {
|
||||||
// Will be in the form "refs/heads/master" on a push event
|
// Will be in the form "refs/heads/master" on a push event
|
||||||
// or in the form "refs/pull/N/merge" on a pull_request event
|
// or in the form "refs/pull/N/merge" on a pull_request event
|
||||||
const ref = getRequiredEnvParam("GITHUB_REF");
|
const ref = getRequiredEnvParam("GITHUB_REF");
|
||||||
const sha = getRequiredEnvParam("GITHUB_SHA");
|
// For pull request refs we want to convert from the 'merge' ref
|
||||||
// For pull request refs we want to detect whether the workflow
|
// to the 'head' ref, as that is what we want to analyse.
|
||||||
// has run `git checkout HEAD^2` to analyze the 'head' ref rather
|
// There should have been some code earlier in the workflow to do
|
||||||
// than the 'merge' ref. If so, we want to convert the ref that
|
// the checkout, but we have no way of verifying that here.
|
||||||
// we report back.
|
|
||||||
const pull_ref_regex = /refs\/pull\/(\d+)\/merge/;
|
const pull_ref_regex = /refs\/pull\/(\d+)\/merge/;
|
||||||
if (!pull_ref_regex.test(ref)) {
|
if (pull_ref_regex.test(ref)) {
|
||||||
return ref;
|
return ref.replace(pull_ref_regex, "refs/pull/$1/head");
|
||||||
}
|
|
||||||
const head = await exports.getCommitOid("HEAD");
|
|
||||||
// in actions/checkout@v2 we can check if git rev-parse HEAD == GITHUB_SHA
|
|
||||||
// in actions/checkout@v1 this may not be true as it checks out the repository
|
|
||||||
// using GITHUB_REF. There is a subtle race condition where
|
|
||||||
// git rev-parse GITHUB_REF != GITHUB_SHA, so we must check
|
|
||||||
// git git-parse GITHUB_REF == git rev-parse HEAD instead.
|
|
||||||
const hasChangedRef = sha !== head &&
|
|
||||||
(await exports.getCommitOid(ref.replace(/^refs\/pull\//, "refs/remotes/pull/"))) !==
|
|
||||||
head;
|
|
||||||
if (hasChangedRef) {
|
|
||||||
const newRef = ref.replace(pull_ref_regex, "refs/pull/$1/head");
|
|
||||||
core.debug(`No longer on merge commit, rewriting ref from ${ref} to ${newRef}.`);
|
|
||||||
return newRef;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return ref;
|
return ref;
|
||||||
@@ -425,7 +172,7 @@ exports.getRef = getRef;
|
|||||||
*/
|
*/
|
||||||
async function createStatusReportBase(actionName, status, actionStartedAt, cause, exception) {
|
async function createStatusReportBase(actionName, status, actionStartedAt, cause, exception) {
|
||||||
const commitOid = process.env["GITHUB_SHA"] || "";
|
const commitOid = process.env["GITHUB_SHA"] || "";
|
||||||
const ref = await getRef();
|
const ref = getRef();
|
||||||
const workflowRunIDStr = process.env["GITHUB_RUN_ID"];
|
const workflowRunIDStr = process.env["GITHUB_RUN_ID"];
|
||||||
let workflowRunID = -1;
|
let workflowRunID = -1;
|
||||||
if (workflowRunIDStr) {
|
if (workflowRunIDStr) {
|
||||||
@@ -439,11 +186,6 @@ async function createStatusReportBase(actionName, status, actionStartedAt, cause
|
|||||||
workflowStartedAt = actionStartedAt.toISOString();
|
workflowStartedAt = actionStartedAt.toISOString();
|
||||||
core.exportVariable(sharedEnv.CODEQL_WORKFLOW_STARTED_AT, workflowStartedAt);
|
core.exportVariable(sharedEnv.CODEQL_WORKFLOW_STARTED_AT, workflowStartedAt);
|
||||||
}
|
}
|
||||||
// If running locally then the GITHUB_ACTION_REF cannot be trusted as it may be for the previous action
|
|
||||||
// See https://github.com/actions/runner/issues/803
|
|
||||||
const actionRef = isRunningLocalAction()
|
|
||||||
? undefined
|
|
||||||
: process.env["GITHUB_ACTION_REF"];
|
|
||||||
const statusReport = {
|
const statusReport = {
|
||||||
workflow_run_id: workflowRunID,
|
workflow_run_id: workflowRunID,
|
||||||
workflow_name: workflowName,
|
workflow_name: workflowName,
|
||||||
@@ -452,7 +194,6 @@ async function createStatusReportBase(actionName, status, actionStartedAt, cause
|
|||||||
commit_oid: commitOid,
|
commit_oid: commitOid,
|
||||||
ref,
|
ref,
|
||||||
action_name: actionName,
|
action_name: actionName,
|
||||||
action_ref: actionRef,
|
|
||||||
action_oid: "unknown",
|
action_oid: "unknown",
|
||||||
started_at: workflowStartedAt,
|
started_at: workflowStartedAt,
|
||||||
action_started_at: actionStartedAt.toISOString(),
|
action_started_at: actionStartedAt.toISOString(),
|
||||||
@@ -475,14 +216,6 @@ async function createStatusReportBase(actionName, status, actionStartedAt, cause
|
|||||||
return statusReport;
|
return statusReport;
|
||||||
}
|
}
|
||||||
exports.createStatusReportBase = createStatusReportBase;
|
exports.createStatusReportBase = createStatusReportBase;
|
||||||
function isHTTPError(arg) {
|
|
||||||
var _a;
|
|
||||||
return ((_a = arg) === null || _a === void 0 ? void 0 : _a.status) !== undefined && Number.isInteger(arg.status);
|
|
||||||
}
|
|
||||||
const GENERIC_403_MSG = "The repo on which this action is running is not opted-in to CodeQL code scanning.";
|
|
||||||
const GENERIC_404_MSG = "Not authorized to used the CodeQL code scanning feature on this repo.";
|
|
||||||
const OUT_OF_DATE_MSG = "CodeQL Action is out-of-date. Please upgrade to the latest version of codeql-action.";
|
|
||||||
const INCOMPATIBLE_MSG = "CodeQL Action version is incompatible with the code scanning endpoint. Please update to a compatible version of codeql-action.";
|
|
||||||
/**
|
/**
|
||||||
* Send a status report to the code_scanning/analysis/status endpoint.
|
* Send a status report to the code_scanning/analysis/status endpoint.
|
||||||
*
|
*
|
||||||
@@ -492,7 +225,11 @@ const INCOMPATIBLE_MSG = "CodeQL Action version is incompatible with the code sc
|
|||||||
*
|
*
|
||||||
* Returns whether sending the status report was successful of not.
|
* Returns whether sending the status report was successful of not.
|
||||||
*/
|
*/
|
||||||
async function sendStatusReport(statusReport) {
|
async function sendStatusReport(statusReport, ignoreFailures) {
|
||||||
|
if (getRequiredEnvParam("GITHUB_SERVER_URL") !== util_1.GITHUB_DOTCOM_URL) {
|
||||||
|
core.debug("Not sending status report to GitHub Enterprise");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (util_1.isLocalRun()) {
|
if (util_1.isLocalRun()) {
|
||||||
core.debug("Not sending status report because this is a local run");
|
core.debug("Not sending status report because this is a local run");
|
||||||
return true;
|
return true;
|
||||||
@@ -502,73 +239,28 @@ async function sendStatusReport(statusReport) {
|
|||||||
const nwo = getRequiredEnvParam("GITHUB_REPOSITORY");
|
const nwo = getRequiredEnvParam("GITHUB_REPOSITORY");
|
||||||
const [owner, repo] = nwo.split("/");
|
const [owner, repo] = nwo.split("/");
|
||||||
const client = api.getActionsApiClient();
|
const client = api.getActionsApiClient();
|
||||||
try {
|
const statusResponse = await client.request("PUT /repos/:owner/:repo/code-scanning/analysis/status", {
|
||||||
await client.request("PUT /repos/:owner/:repo/code-scanning/analysis/status", {
|
owner,
|
||||||
owner,
|
repo,
|
||||||
repo,
|
data: statusReportJSON,
|
||||||
data: statusReportJSON,
|
});
|
||||||
});
|
if (!ignoreFailures) {
|
||||||
return true;
|
// If the status report request fails with a 403 or a 404, then this is a deliberate
|
||||||
}
|
// message from the endpoint that the SARIF upload can be expected to fail too,
|
||||||
catch (e) {
|
// so the action should fail to avoid wasting actions minutes.
|
||||||
console.log(e);
|
//
|
||||||
if (isHTTPError(e)) {
|
// Other failure responses (or lack thereof) could be transitory and should not
|
||||||
switch (e.status) {
|
// cause the action to fail.
|
||||||
case 403:
|
if (statusResponse.status === 403) {
|
||||||
if (workflowIsTriggeredByPushEvent() && isDependabotActor()) {
|
core.setFailed("The repo on which this action is running is not opted-in to CodeQL code scanning.");
|
||||||
core.setFailed('Workflows triggered by Dependabot on the "push" event run with read-only access. ' +
|
return false;
|
||||||
"Uploading Code Scanning results requires write access. " +
|
}
|
||||||
'To use Code Scanning with Dependabot, please ensure you are using the "pull_request" event for this workflow and avoid triggering on the "push" event for Dependabot branches. ' +
|
if (statusResponse.status === 404) {
|
||||||
"See https://docs.github.com/en/code-security/secure-coding/configuring-code-scanning#scanning-on-push for more information on how to configure these events.");
|
core.setFailed("Not authorized to used the CodeQL code scanning feature on this repo.");
|
||||||
}
|
return false;
|
||||||
else {
|
|
||||||
core.setFailed(e.message || GENERIC_403_MSG);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
case 404:
|
|
||||||
core.setFailed(GENERIC_404_MSG);
|
|
||||||
return false;
|
|
||||||
case 422:
|
|
||||||
// schema incompatibility when reporting status
|
|
||||||
// this means that this action version is no longer compatible with the API
|
|
||||||
// we still want to continue as it is likely the analysis endpoint will work
|
|
||||||
if (getRequiredEnvParam("GITHUB_SERVER_URL") !== util_1.GITHUB_DOTCOM_URL) {
|
|
||||||
core.debug(INCOMPATIBLE_MSG);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
core.debug(OUT_OF_DATE_MSG);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// something else has gone wrong and the request/response will be logged by octokit
|
|
||||||
// it's possible this is a transient error and we should continue scanning
|
|
||||||
core.error("An unexpected error occurred when sending code scanning status report.");
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
exports.sendStatusReport = sendStatusReport;
|
exports.sendStatusReport = sendStatusReport;
|
||||||
// Was the workflow run triggered by a `push` event, for example as opposed to a `pull_request` event.
|
|
||||||
function workflowIsTriggeredByPushEvent() {
|
|
||||||
return process.env["GITHUB_EVENT_NAME"] === "push";
|
|
||||||
}
|
|
||||||
// Is dependabot the actor that triggered the current workflow run.
|
|
||||||
function isDependabotActor() {
|
|
||||||
return process.env["GITHUB_ACTOR"] === "dependabot[bot]";
|
|
||||||
}
|
|
||||||
// Is the current action executing a local copy (i.e. we're running a workflow on the codeql-action repo itself)
|
|
||||||
// as opposed to running a remote action (i.e. when another repo references us)
|
|
||||||
function isRunningLocalAction() {
|
|
||||||
const relativeScriptPath = getRelativeScriptPath();
|
|
||||||
return (relativeScriptPath.startsWith("..") || path.isAbsolute(relativeScriptPath));
|
|
||||||
}
|
|
||||||
exports.isRunningLocalAction = isRunningLocalAction;
|
|
||||||
// Get the location where the action is running from.
|
|
||||||
// This can be used to get the actions name or tell if we're running a local action.
|
|
||||||
function getRelativeScriptPath() {
|
|
||||||
const runnerTemp = getRequiredEnvParam("RUNNER_TEMP");
|
|
||||||
const actionsDirectory = path.join(path.dirname(runnerTemp), "_actions");
|
|
||||||
return path.relative(actionsDirectory, __filename);
|
|
||||||
}
|
|
||||||
exports.getRelativeScriptPath = getRelativeScriptPath;
|
|
||||||
//# sourceMappingURL=actions-util.js.map
|
//# sourceMappingURL=actions-util.js.map
|
||||||
File diff suppressed because one or more lines are too long
420
lib/actions-util.test.js
generated
420
lib/actions-util.test.js
generated
@@ -2,434 +2,30 @@
|
|||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
||||||
result["default"] = mod;
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const ava_1 = __importDefault(require("ava"));
|
const ava_1 = __importDefault(require("ava"));
|
||||||
const yaml = __importStar(require("js-yaml"));
|
const actions_util_1 = require("./actions-util");
|
||||||
const sinon_1 = __importDefault(require("sinon"));
|
|
||||||
const actionsutil = __importStar(require("./actions-util"));
|
|
||||||
const testing_utils_1 = require("./testing-utils");
|
const testing_utils_1 = require("./testing-utils");
|
||||||
function errorCodes(actual, expected) {
|
|
||||||
return [actual.map(({ code }) => code), expected.map(({ code }) => code)];
|
|
||||||
}
|
|
||||||
testing_utils_1.setupTests(ava_1.default);
|
testing_utils_1.setupTests(ava_1.default);
|
||||||
ava_1.default("getRef() throws on the empty string", async (t) => {
|
ava_1.default("getRef() throws on the empty string", (t) => {
|
||||||
process.env["GITHUB_REF"] = "";
|
process.env["GITHUB_REF"] = "";
|
||||||
await t.throwsAsync(actionsutil.getRef);
|
t.throws(actions_util_1.getRef);
|
||||||
});
|
|
||||||
ava_1.default("getRef() returns merge PR ref if GITHUB_SHA still checked out", async (t) => {
|
|
||||||
const expectedRef = "refs/pull/1/merge";
|
|
||||||
const currentSha = "a".repeat(40);
|
|
||||||
process.env["GITHUB_REF"] = expectedRef;
|
|
||||||
process.env["GITHUB_SHA"] = currentSha;
|
|
||||||
const callback = sinon_1.default.stub(actionsutil, "getCommitOid");
|
|
||||||
callback.withArgs("HEAD").resolves(currentSha);
|
|
||||||
const actualRef = await actionsutil.getRef();
|
|
||||||
t.deepEqual(actualRef, expectedRef);
|
|
||||||
callback.restore();
|
|
||||||
});
|
|
||||||
ava_1.default("getRef() returns merge PR ref if GITHUB_REF still checked out but sha has changed (actions checkout@v1)", async (t) => {
|
|
||||||
const expectedRef = "refs/pull/1/merge";
|
|
||||||
process.env["GITHUB_REF"] = expectedRef;
|
|
||||||
process.env["GITHUB_SHA"] = "b".repeat(40);
|
|
||||||
const sha = "a".repeat(40);
|
|
||||||
const callback = sinon_1.default.stub(actionsutil, "getCommitOid");
|
|
||||||
callback.withArgs("refs/remotes/pull/1/merge").resolves(sha);
|
|
||||||
callback.withArgs("HEAD").resolves(sha);
|
|
||||||
const actualRef = await actionsutil.getRef();
|
|
||||||
t.deepEqual(actualRef, expectedRef);
|
|
||||||
callback.restore();
|
|
||||||
});
|
|
||||||
ava_1.default("getRef() returns head PR ref if GITHUB_REF no longer checked out", async (t) => {
|
|
||||||
process.env["GITHUB_REF"] = "refs/pull/1/merge";
|
|
||||||
process.env["GITHUB_SHA"] = "a".repeat(40);
|
|
||||||
const callback = sinon_1.default.stub(actionsutil, "getCommitOid");
|
|
||||||
callback.withArgs("refs/pull/1/merge").resolves("a".repeat(40));
|
|
||||||
callback.withArgs("HEAD").resolves("b".repeat(40));
|
|
||||||
const actualRef = await actionsutil.getRef();
|
|
||||||
t.deepEqual(actualRef, "refs/pull/1/head");
|
|
||||||
callback.restore();
|
|
||||||
});
|
|
||||||
ava_1.default("getAnalysisKey() when a local run", async (t) => {
|
|
||||||
process.env.CODEQL_LOCAL_RUN = "true";
|
|
||||||
process.env.CODEQL_ACTION_ANALYSIS_KEY = "";
|
|
||||||
process.env.GITHUB_JOB = "";
|
|
||||||
actionsutil.prepareLocalRunEnvironment();
|
|
||||||
const actualAnalysisKey = await actionsutil.getAnalysisKey();
|
|
||||||
t.deepEqual(actualAnalysisKey, "LOCAL-RUN:UNKNOWN-JOB");
|
|
||||||
});
|
|
||||||
ava_1.default("computeAutomationID()", async (t) => {
|
|
||||||
let actualAutomationID = actionsutil.computeAutomationID(".github/workflows/codeql-analysis.yml:analyze", '{"language": "javascript", "os": "linux"}');
|
|
||||||
t.deepEqual(actualAutomationID, ".github/workflows/codeql-analysis.yml:analyze/language:javascript/os:linux/");
|
|
||||||
// check the environment sorting
|
|
||||||
actualAutomationID = actionsutil.computeAutomationID(".github/workflows/codeql-analysis.yml:analyze", '{"os": "linux", "language": "javascript"}');
|
|
||||||
t.deepEqual(actualAutomationID, ".github/workflows/codeql-analysis.yml:analyze/language:javascript/os:linux/");
|
|
||||||
// check that an empty environment produces the right results
|
|
||||||
actualAutomationID = actionsutil.computeAutomationID(".github/workflows/codeql-analysis.yml:analyze", "{}");
|
|
||||||
t.deepEqual(actualAutomationID, ".github/workflows/codeql-analysis.yml:analyze/");
|
|
||||||
// check non string environment values
|
|
||||||
actualAutomationID = actionsutil.computeAutomationID(".github/workflows/codeql-analysis.yml:analyze", '{"number": 1, "object": {"language": "javascript"}}');
|
|
||||||
t.deepEqual(actualAutomationID, ".github/workflows/codeql-analysis.yml:analyze/number:/object:/");
|
|
||||||
// check undefined environment
|
|
||||||
actualAutomationID = actionsutil.computeAutomationID(".github/workflows/codeql-analysis.yml:analyze", undefined);
|
|
||||||
t.deepEqual(actualAutomationID, ".github/workflows/codeql-analysis.yml:analyze/");
|
|
||||||
});
|
});
|
||||||
ava_1.default("prepareEnvironment() when a local run", (t) => {
|
ava_1.default("prepareEnvironment() when a local run", (t) => {
|
||||||
|
const origLocalRun = process.env.CODEQL_LOCAL_RUN;
|
||||||
process.env.CODEQL_LOCAL_RUN = "false";
|
process.env.CODEQL_LOCAL_RUN = "false";
|
||||||
process.env.GITHUB_JOB = "YYY";
|
process.env.GITHUB_JOB = "YYY";
|
||||||
process.env.CODEQL_ACTION_ANALYSIS_KEY = "TEST";
|
actions_util_1.prepareLocalRunEnvironment();
|
||||||
actionsutil.prepareLocalRunEnvironment();
|
|
||||||
// unchanged
|
// unchanged
|
||||||
t.deepEqual(process.env.GITHUB_JOB, "YYY");
|
t.deepEqual(process.env.GITHUB_JOB, "YYY");
|
||||||
t.deepEqual(process.env.CODEQL_ACTION_ANALYSIS_KEY, "TEST");
|
|
||||||
process.env.CODEQL_LOCAL_RUN = "true";
|
process.env.CODEQL_LOCAL_RUN = "true";
|
||||||
actionsutil.prepareLocalRunEnvironment();
|
actions_util_1.prepareLocalRunEnvironment();
|
||||||
// unchanged
|
// unchanged
|
||||||
t.deepEqual(process.env.GITHUB_JOB, "YYY");
|
t.deepEqual(process.env.GITHUB_JOB, "YYY");
|
||||||
t.deepEqual(process.env.CODEQL_ACTION_ANALYSIS_KEY, "TEST");
|
|
||||||
process.env.CODEQL_ACTION_ANALYSIS_KEY = "";
|
|
||||||
actionsutil.prepareLocalRunEnvironment();
|
|
||||||
// updated
|
|
||||||
t.deepEqual(process.env.GITHUB_JOB, "YYY");
|
|
||||||
t.deepEqual(process.env.CODEQL_ACTION_ANALYSIS_KEY, "LOCAL-RUN:YYY");
|
|
||||||
process.env.GITHUB_JOB = "";
|
process.env.GITHUB_JOB = "";
|
||||||
process.env.CODEQL_ACTION_ANALYSIS_KEY = "";
|
actions_util_1.prepareLocalRunEnvironment();
|
||||||
actionsutil.prepareLocalRunEnvironment();
|
|
||||||
// updated
|
// updated
|
||||||
t.deepEqual(process.env.GITHUB_JOB, "UNKNOWN-JOB");
|
t.deepEqual(process.env.GITHUB_JOB, "UNKNOWN-JOB");
|
||||||
t.deepEqual(process.env.CODEQL_ACTION_ANALYSIS_KEY, "LOCAL-RUN:UNKNOWN-JOB");
|
process.env.CODEQL_LOCAL_RUN = origLocalRun;
|
||||||
});
|
|
||||||
ava_1.default("getWorkflowErrors() when on is empty", (t) => {
|
|
||||||
const errors = actionsutil.getWorkflowErrors({ on: {} });
|
|
||||||
t.deepEqual(...errorCodes(errors, []));
|
|
||||||
});
|
|
||||||
ava_1.default("getWorkflowErrors() when on.push is an array missing pull_request", (t) => {
|
|
||||||
const errors = actionsutil.getWorkflowErrors({ on: ["push"] });
|
|
||||||
t.deepEqual(...errorCodes(errors, []));
|
|
||||||
});
|
|
||||||
ava_1.default("getWorkflowErrors() when on.push is an array missing push", (t) => {
|
|
||||||
const errors = actionsutil.getWorkflowErrors({ on: ["pull_request"] });
|
|
||||||
t.deepEqual(...errorCodes(errors, [actionsutil.WorkflowErrors.MissingPushHook]));
|
|
||||||
});
|
|
||||||
ava_1.default("getWorkflowErrors() when on.push is valid", (t) => {
|
|
||||||
const errors = actionsutil.getWorkflowErrors({
|
|
||||||
on: ["push", "pull_request"],
|
|
||||||
});
|
|
||||||
t.deepEqual(...errorCodes(errors, []));
|
|
||||||
});
|
|
||||||
ava_1.default("getWorkflowErrors() when on.push is a valid superset", (t) => {
|
|
||||||
const errors = actionsutil.getWorkflowErrors({
|
|
||||||
on: ["push", "pull_request", "schedule"],
|
|
||||||
});
|
|
||||||
t.deepEqual(...errorCodes(errors, []));
|
|
||||||
});
|
|
||||||
ava_1.default("getWorkflowErrors() when on.push should not have a path", (t) => {
|
|
||||||
const errors = actionsutil.getWorkflowErrors({
|
|
||||||
on: {
|
|
||||||
push: { branches: ["main"], paths: ["test/*"] },
|
|
||||||
pull_request: { branches: ["main"] },
|
|
||||||
},
|
|
||||||
});
|
|
||||||
t.deepEqual(...errorCodes(errors, [actionsutil.WorkflowErrors.PathsSpecified]));
|
|
||||||
});
|
|
||||||
ava_1.default("getWorkflowErrors() when on.push is a correct object", (t) => {
|
|
||||||
const errors = actionsutil.getWorkflowErrors({
|
|
||||||
on: { push: { branches: ["main"] }, pull_request: { branches: ["main"] } },
|
|
||||||
});
|
|
||||||
t.deepEqual(...errorCodes(errors, []));
|
|
||||||
});
|
|
||||||
ava_1.default("getWorkflowErrors() when on.pull_requests is a string", (t) => {
|
|
||||||
const errors = actionsutil.getWorkflowErrors({
|
|
||||||
on: { push: { branches: ["main"] }, pull_request: { branches: "*" } },
|
|
||||||
});
|
|
||||||
t.deepEqual(...errorCodes(errors, [actionsutil.WorkflowErrors.MismatchedBranches]));
|
|
||||||
});
|
|
||||||
ava_1.default("getWorkflowErrors() when on.pull_requests is a string and correct", (t) => {
|
|
||||||
const errors = actionsutil.getWorkflowErrors({
|
|
||||||
on: { push: { branches: "*" }, pull_request: { branches: "*" } },
|
|
||||||
});
|
|
||||||
t.deepEqual(...errorCodes(errors, []));
|
|
||||||
});
|
|
||||||
ava_1.default("getWorkflowErrors() when on.push is correct with empty objects", (t) => {
|
|
||||||
const errors = actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
pull_request:
|
|
||||||
`));
|
|
||||||
t.deepEqual(...errorCodes(errors, []));
|
|
||||||
});
|
|
||||||
ava_1.default("getWorkflowErrors() when on.push is mismatched", (t) => {
|
|
||||||
const errors = actionsutil.getWorkflowErrors({
|
|
||||||
on: {
|
|
||||||
push: { branches: ["main"] },
|
|
||||||
pull_request: { branches: ["feature"] },
|
|
||||||
},
|
|
||||||
});
|
|
||||||
t.deepEqual(...errorCodes(errors, [actionsutil.WorkflowErrors.MismatchedBranches]));
|
|
||||||
});
|
|
||||||
ava_1.default("getWorkflowErrors() when on.push is not mismatched", (t) => {
|
|
||||||
const errors = actionsutil.getWorkflowErrors({
|
|
||||||
on: {
|
|
||||||
push: { branches: ["main", "feature"] },
|
|
||||||
pull_request: { branches: ["main"] },
|
|
||||||
},
|
|
||||||
});
|
|
||||||
t.deepEqual(...errorCodes(errors, []));
|
|
||||||
});
|
|
||||||
ava_1.default("getWorkflowErrors() when on.push is mismatched for pull_request", (t) => {
|
|
||||||
const errors = actionsutil.getWorkflowErrors({
|
|
||||||
on: {
|
|
||||||
push: { branches: ["main"] },
|
|
||||||
pull_request: { branches: ["main", "feature"] },
|
|
||||||
},
|
|
||||||
});
|
|
||||||
t.deepEqual(...errorCodes(errors, [actionsutil.WorkflowErrors.MismatchedBranches]));
|
|
||||||
});
|
|
||||||
ava_1.default("getWorkflowErrors() for a range of malformed workflows", (t) => {
|
|
||||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors({
|
|
||||||
on: {
|
|
||||||
push: 1,
|
|
||||||
pull_request: 1,
|
|
||||||
},
|
|
||||||
}), []));
|
|
||||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors({
|
|
||||||
on: 1,
|
|
||||||
}), []));
|
|
||||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors({
|
|
||||||
on: 1,
|
|
||||||
jobs: 1,
|
|
||||||
}), []));
|
|
||||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors({
|
|
||||||
on: 1,
|
|
||||||
jobs: [1],
|
|
||||||
}), []));
|
|
||||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors({
|
|
||||||
on: 1,
|
|
||||||
jobs: { 1: 1 },
|
|
||||||
}), []));
|
|
||||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors({
|
|
||||||
on: 1,
|
|
||||||
jobs: { test: 1 },
|
|
||||||
}), []));
|
|
||||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors({
|
|
||||||
on: 1,
|
|
||||||
jobs: { test: [1] },
|
|
||||||
}), []));
|
|
||||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors({
|
|
||||||
on: 1,
|
|
||||||
jobs: { test: { steps: 1 } },
|
|
||||||
}), []));
|
|
||||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors({
|
|
||||||
on: 1,
|
|
||||||
jobs: { test: { steps: [{ notrun: "git checkout HEAD^2" }] } },
|
|
||||||
}), []));
|
|
||||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors({
|
|
||||||
on: 1,
|
|
||||||
jobs: { test: [undefined] },
|
|
||||||
}), []));
|
|
||||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(1), []));
|
|
||||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors({
|
|
||||||
on: {
|
|
||||||
push: {
|
|
||||||
branches: 1,
|
|
||||||
},
|
|
||||||
pull_request: {
|
|
||||||
branches: 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}), []));
|
|
||||||
});
|
|
||||||
ava_1.default("getWorkflowErrors() when on.pull_request for every branch but push specifies branches", (t) => {
|
|
||||||
const errors = actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
|
||||||
name: "CodeQL"
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: ["main"]
|
|
||||||
pull_request:
|
|
||||||
`));
|
|
||||||
t.deepEqual(...errorCodes(errors, [actionsutil.WorkflowErrors.MismatchedBranches]));
|
|
||||||
});
|
|
||||||
ava_1.default("getWorkflowErrors() when on.pull_request for wildcard branches", (t) => {
|
|
||||||
const errors = actionsutil.getWorkflowErrors({
|
|
||||||
on: {
|
|
||||||
push: { branches: ["feature/*"] },
|
|
||||||
pull_request: { branches: "feature/moose" },
|
|
||||||
},
|
|
||||||
});
|
|
||||||
t.deepEqual(...errorCodes(errors, []));
|
|
||||||
});
|
|
||||||
ava_1.default("getWorkflowErrors() when on.pull_request for mismatched wildcard branches", (t) => {
|
|
||||||
const errors = actionsutil.getWorkflowErrors({
|
|
||||||
on: {
|
|
||||||
push: { branches: ["feature/moose"] },
|
|
||||||
pull_request: { branches: "feature/*" },
|
|
||||||
},
|
|
||||||
});
|
|
||||||
t.deepEqual(...errorCodes(errors, [actionsutil.WorkflowErrors.MismatchedBranches]));
|
|
||||||
});
|
|
||||||
ava_1.default("getWorkflowErrors() when HEAD^2 is checked out", (t) => {
|
|
||||||
process.env.GITHUB_JOB = "test";
|
|
||||||
const errors = actionsutil.getWorkflowErrors({
|
|
||||||
on: ["push", "pull_request"],
|
|
||||||
jobs: { test: { steps: [{ run: "git checkout HEAD^2" }] } },
|
|
||||||
});
|
|
||||||
t.deepEqual(...errorCodes(errors, [actionsutil.WorkflowErrors.CheckoutWrongHead]));
|
|
||||||
});
|
|
||||||
ava_1.default("formatWorkflowErrors() when there is one error", (t) => {
|
|
||||||
const message = actionsutil.formatWorkflowErrors([
|
|
||||||
actionsutil.WorkflowErrors.CheckoutWrongHead,
|
|
||||||
]);
|
|
||||||
t.true(message.startsWith("1 issue was detected with this workflow:"));
|
|
||||||
});
|
|
||||||
ava_1.default("formatWorkflowErrors() when there are multiple errors", (t) => {
|
|
||||||
const message = actionsutil.formatWorkflowErrors([
|
|
||||||
actionsutil.WorkflowErrors.CheckoutWrongHead,
|
|
||||||
actionsutil.WorkflowErrors.PathsSpecified,
|
|
||||||
]);
|
|
||||||
t.true(message.startsWith("2 issues were detected with this workflow:"));
|
|
||||||
});
|
|
||||||
ava_1.default("formatWorkflowCause() with no errors", (t) => {
|
|
||||||
const message = actionsutil.formatWorkflowCause([]);
|
|
||||||
t.deepEqual(message, undefined);
|
|
||||||
});
|
|
||||||
ava_1.default("formatWorkflowCause()", (t) => {
|
|
||||||
const message = actionsutil.formatWorkflowCause([
|
|
||||||
actionsutil.WorkflowErrors.CheckoutWrongHead,
|
|
||||||
actionsutil.WorkflowErrors.PathsSpecified,
|
|
||||||
]);
|
|
||||||
t.deepEqual(message, "CheckoutWrongHead,PathsSpecified");
|
|
||||||
t.deepEqual(actionsutil.formatWorkflowCause([]), undefined);
|
|
||||||
});
|
|
||||||
ava_1.default("patternIsSuperset()", (t) => {
|
|
||||||
t.false(actionsutil.patternIsSuperset("main-*", "main"));
|
|
||||||
t.true(actionsutil.patternIsSuperset("*", "*"));
|
|
||||||
t.true(actionsutil.patternIsSuperset("*", "main-*"));
|
|
||||||
t.false(actionsutil.patternIsSuperset("main-*", "*"));
|
|
||||||
t.false(actionsutil.patternIsSuperset("main-*", "main"));
|
|
||||||
t.true(actionsutil.patternIsSuperset("main", "main"));
|
|
||||||
t.false(actionsutil.patternIsSuperset("*", "feature/*"));
|
|
||||||
t.true(actionsutil.patternIsSuperset("**", "feature/*"));
|
|
||||||
t.false(actionsutil.patternIsSuperset("feature-*", "**"));
|
|
||||||
t.false(actionsutil.patternIsSuperset("a/**/c", "a/**/d"));
|
|
||||||
t.false(actionsutil.patternIsSuperset("a/**/c", "a/**"));
|
|
||||||
t.true(actionsutil.patternIsSuperset("a/**", "a/**/c"));
|
|
||||||
t.true(actionsutil.patternIsSuperset("a/**/c", "a/main-**/c"));
|
|
||||||
t.false(actionsutil.patternIsSuperset("a/**/b/**/c", "a/**/d/**/c"));
|
|
||||||
t.true(actionsutil.patternIsSuperset("a/**/b/**/c", "a/**/b/c/**/c"));
|
|
||||||
t.true(actionsutil.patternIsSuperset("a/**/b/**/c", "a/**/b/d/**/c"));
|
|
||||||
t.false(actionsutil.patternIsSuperset("a/**/c/d/**/c", "a/**/b/**/c"));
|
|
||||||
t.false(actionsutil.patternIsSuperset("a/main-**/c", "a/**/c"));
|
|
||||||
t.true(actionsutil.patternIsSuperset("/robin/*/release/*", "/robin/moose/release/goose"));
|
|
||||||
t.false(actionsutil.patternIsSuperset("/robin/moose/release/goose", "/robin/*/release/*"));
|
|
||||||
});
|
|
||||||
ava_1.default("getWorkflowErrors() when branches contain dots", (t) => {
|
|
||||||
const errors = actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [4.1, master]
|
|
||||||
pull_request:
|
|
||||||
# The branches below must be a subset of the branches above
|
|
||||||
branches: [4.1, master]
|
|
||||||
`));
|
|
||||||
t.deepEqual(...errorCodes(errors, []));
|
|
||||||
});
|
|
||||||
ava_1.default("getWorkflowErrors() when on.push has a trailing comma", (t) => {
|
|
||||||
const errors = actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
|
||||||
name: "CodeQL"
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [master, ]
|
|
||||||
pull_request:
|
|
||||||
# The branches below must be a subset of the branches above
|
|
||||||
branches: [master]
|
|
||||||
`));
|
|
||||||
t.deepEqual(...errorCodes(errors, []));
|
|
||||||
});
|
|
||||||
ava_1.default("getWorkflowErrors() should only report the current job's CheckoutWrongHead", (t) => {
|
|
||||||
process.env.GITHUB_JOB = "test";
|
|
||||||
const errors = actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
|
||||||
name: "CodeQL"
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [master]
|
|
||||||
pull_request:
|
|
||||||
# The branches below must be a subset of the branches above
|
|
||||||
branches: [master]
|
|
||||||
jobs:
|
|
||||||
test:
|
|
||||||
steps:
|
|
||||||
- run: "git checkout HEAD^2"
|
|
||||||
|
|
||||||
test2:
|
|
||||||
steps:
|
|
||||||
- run: "git checkout HEAD^2"
|
|
||||||
|
|
||||||
test3:
|
|
||||||
steps: []
|
|
||||||
`));
|
|
||||||
t.deepEqual(...errorCodes(errors, [actionsutil.WorkflowErrors.CheckoutWrongHead]));
|
|
||||||
});
|
|
||||||
ava_1.default("getWorkflowErrors() should not report a different job's CheckoutWrongHead", (t) => {
|
|
||||||
process.env.GITHUB_JOB = "test3";
|
|
||||||
const errors = actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
|
||||||
name: "CodeQL"
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [master]
|
|
||||||
pull_request:
|
|
||||||
# The branches below must be a subset of the branches above
|
|
||||||
branches: [master]
|
|
||||||
jobs:
|
|
||||||
test:
|
|
||||||
steps:
|
|
||||||
- run: "git checkout HEAD^2"
|
|
||||||
|
|
||||||
test2:
|
|
||||||
steps:
|
|
||||||
- run: "git checkout HEAD^2"
|
|
||||||
|
|
||||||
test3:
|
|
||||||
steps: []
|
|
||||||
`));
|
|
||||||
t.deepEqual(...errorCodes(errors, []));
|
|
||||||
});
|
|
||||||
ava_1.default("getWorkflowErrors() when on is missing", (t) => {
|
|
||||||
const errors = actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
|
||||||
name: "CodeQL"
|
|
||||||
`));
|
|
||||||
t.deepEqual(...errorCodes(errors, []));
|
|
||||||
});
|
|
||||||
ava_1.default("getWorkflowErrors() with a different on setup", (t) => {
|
|
||||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
|
||||||
name: "CodeQL"
|
|
||||||
on: "workflow_dispatch"
|
|
||||||
`)), []));
|
|
||||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
|
||||||
name: "CodeQL"
|
|
||||||
on: [workflow_dispatch]
|
|
||||||
`)), []));
|
|
||||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
|
||||||
name: "CodeQL"
|
|
||||||
on:
|
|
||||||
workflow_dispatch: {}
|
|
||||||
`)), []));
|
|
||||||
});
|
|
||||||
ava_1.default("getWorkflowErrors() should not report an error if PRs are totally unconfigured", (t) => {
|
|
||||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
|
||||||
name: "CodeQL"
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [master]
|
|
||||||
`)), []));
|
|
||||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
|
||||||
name: "CodeQL"
|
|
||||||
on: ["push"]
|
|
||||||
`)), []));
|
|
||||||
});
|
});
|
||||||
//# sourceMappingURL=actions-util.test.js.map
|
//# sourceMappingURL=actions-util.test.js.map
|
||||||
File diff suppressed because one or more lines are too long
26
lib/analysis-paths.js
generated
26
lib/analysis-paths.js
generated
@@ -1,18 +1,10 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
||||||
result["default"] = mod;
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const path = __importStar(require("path"));
|
|
||||||
function isInterpretedLanguage(language) {
|
function isInterpretedLanguage(language) {
|
||||||
return language === "javascript" || language === "python";
|
return language === "javascript" || language === "python";
|
||||||
}
|
}
|
||||||
// Matches a string containing only characters that are legal to include in paths on windows.
|
// Matches a string containing only characters that are legal to include in paths on windows.
|
||||||
exports.legalWindowsPathCharactersRegex = /^[^<>:"|?]*$/;
|
exports.legalWindowsPathCharactersRegex = /^[^<>:"\|?]*$/;
|
||||||
// Builds an environment variable suitable for LGTM_INDEX_INCLUDE or LGTM_INDEX_EXCLUDE
|
// Builds an environment variable suitable for LGTM_INDEX_INCLUDE or LGTM_INDEX_EXCLUDE
|
||||||
function buildIncludeExcludeEnvVar(paths) {
|
function buildIncludeExcludeEnvVar(paths) {
|
||||||
// Ignore anything containing a *
|
// Ignore anything containing a *
|
||||||
@@ -28,7 +20,7 @@ function printPathFiltersWarning(config, logger) {
|
|||||||
// If any other languages are detected/configured then show a warning.
|
// If any other languages are detected/configured then show a warning.
|
||||||
if ((config.paths.length !== 0 || config.pathsIgnore.length !== 0) &&
|
if ((config.paths.length !== 0 || config.pathsIgnore.length !== 0) &&
|
||||||
!config.languages.every(isInterpretedLanguage)) {
|
!config.languages.every(isInterpretedLanguage)) {
|
||||||
logger.warning('The "paths"/"paths-ignore" fields of the config only have effect for JavaScript and Python');
|
logger.warning('The "paths"/"paths-ignore" fields of the config only have effect for Javascript and Python');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.printPathFiltersWarning = printPathFiltersWarning;
|
exports.printPathFiltersWarning = printPathFiltersWarning;
|
||||||
@@ -43,18 +35,8 @@ function includeAndExcludeAnalysisPaths(config) {
|
|||||||
if (config.paths.length !== 0) {
|
if (config.paths.length !== 0) {
|
||||||
process.env["LGTM_INDEX_INCLUDE"] = buildIncludeExcludeEnvVar(config.paths);
|
process.env["LGTM_INDEX_INCLUDE"] = buildIncludeExcludeEnvVar(config.paths);
|
||||||
}
|
}
|
||||||
// If the temporary or tools directory is in the working directory ignore that too.
|
if (config.pathsIgnore.length !== 0) {
|
||||||
const tempRelativeToWorking = path.relative(process.cwd(), config.tempDir);
|
process.env["LGTM_INDEX_EXCLUDE"] = buildIncludeExcludeEnvVar(config.pathsIgnore);
|
||||||
const toolsRelativeToWorking = path.relative(process.cwd(), config.toolCacheDir);
|
|
||||||
let pathsIgnore = config.pathsIgnore;
|
|
||||||
if (!tempRelativeToWorking.startsWith("..")) {
|
|
||||||
pathsIgnore = pathsIgnore.concat(tempRelativeToWorking);
|
|
||||||
}
|
|
||||||
if (!toolsRelativeToWorking.startsWith("..")) {
|
|
||||||
pathsIgnore = pathsIgnore.concat(toolsRelativeToWorking);
|
|
||||||
}
|
|
||||||
if (pathsIgnore.length !== 0) {
|
|
||||||
process.env["LGTM_INDEX_EXCLUDE"] = buildIncludeExcludeEnvVar(pathsIgnore);
|
|
||||||
}
|
}
|
||||||
// The 'LGTM_INDEX_FILTERS' environment variable controls which files are
|
// The 'LGTM_INDEX_FILTERS' environment variable controls which files are
|
||||||
// extracted or ignored. It does not control which directories are traversed.
|
// extracted or ignored. It does not control which directories are traversed.
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"analysis-paths.js","sourceRoot":"","sources":["../src/analysis-paths.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA6B;AAK7B,SAAS,qBAAqB,CAAC,QAAQ;IACrC,OAAO,QAAQ,KAAK,YAAY,IAAI,QAAQ,KAAK,QAAQ,CAAC;AAC5D,CAAC;AAED,6FAA6F;AAChF,QAAA,+BAA+B,GAAG,cAAc,CAAC;AAE9D,uFAAuF;AACvF,SAAS,yBAAyB,CAAC,KAAe;IAChD,iCAAiC;IACjC,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAEnD,uDAAuD;IACvD,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE;QAChC,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,uCAA+B,CAAC,CAAC,CAAC;KACvE;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,SAAgB,uBAAuB,CACrC,MAA0B,EAC1B,MAAc;IAEd,oEAAoE;IACpE,sEAAsE;IACtE,IACE,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,CAAC;QAC9D,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
||||||
29
lib/analysis-paths.test.js
generated
29
lib/analysis-paths.test.js
generated
@@ -1,4 +1,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
@@ -6,11 +9,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
result["default"] = mod;
|
result["default"] = 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 path = __importStar(require("path"));
|
|
||||||
const ava_1 = __importDefault(require("ava"));
|
const ava_1 = __importDefault(require("ava"));
|
||||||
const analysisPaths = __importStar(require("./analysis-paths"));
|
const analysisPaths = __importStar(require("./analysis-paths"));
|
||||||
const testing_utils_1 = require("./testing-utils");
|
const testing_utils_1 = require("./testing-utils");
|
||||||
@@ -27,7 +26,6 @@ ava_1.default("emptyPaths", async (t) => {
|
|||||||
tempDir: tmpDir,
|
tempDir: tmpDir,
|
||||||
toolCacheDir: tmpDir,
|
toolCacheDir: tmpDir,
|
||||||
codeQLCmd: "",
|
codeQLCmd: "",
|
||||||
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
|
||||||
};
|
};
|
||||||
analysisPaths.includeAndExcludeAnalysisPaths(config);
|
analysisPaths.includeAndExcludeAnalysisPaths(config);
|
||||||
t.is(process.env["LGTM_INDEX_INCLUDE"], undefined);
|
t.is(process.env["LGTM_INDEX_INCLUDE"], undefined);
|
||||||
@@ -46,7 +44,6 @@ ava_1.default("nonEmptyPaths", async (t) => {
|
|||||||
tempDir: tmpDir,
|
tempDir: tmpDir,
|
||||||
toolCacheDir: tmpDir,
|
toolCacheDir: tmpDir,
|
||||||
codeQLCmd: "",
|
codeQLCmd: "",
|
||||||
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
|
||||||
};
|
};
|
||||||
analysisPaths.includeAndExcludeAnalysisPaths(config);
|
analysisPaths.includeAndExcludeAnalysisPaths(config);
|
||||||
t.is(process.env["LGTM_INDEX_INCLUDE"], "path1\npath2");
|
t.is(process.env["LGTM_INDEX_INCLUDE"], "path1\npath2");
|
||||||
@@ -54,24 +51,4 @@ ava_1.default("nonEmptyPaths", async (t) => {
|
|||||||
t.is(process.env["LGTM_INDEX_FILTERS"], "include:path1\ninclude:path2\ninclude:**/path3\nexclude:path4\nexclude:path5\nexclude:path6/**");
|
t.is(process.env["LGTM_INDEX_FILTERS"], "include:path1\ninclude:path2\ninclude:**/path3\nexclude:path4\nexclude:path5\nexclude:path6/**");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("exclude temp dir", async (t) => {
|
|
||||||
return await util.withTmpDir(async (toolCacheDir) => {
|
|
||||||
const tempDir = path.join(process.cwd(), "codeql-runner-temp");
|
|
||||||
const config = {
|
|
||||||
languages: [],
|
|
||||||
queries: {},
|
|
||||||
pathsIgnore: [],
|
|
||||||
paths: [],
|
|
||||||
originalUserInput: {},
|
|
||||||
tempDir,
|
|
||||||
toolCacheDir,
|
|
||||||
codeQLCmd: "",
|
|
||||||
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
|
||||||
};
|
|
||||||
analysisPaths.includeAndExcludeAnalysisPaths(config);
|
|
||||||
t.is(process.env["LGTM_INDEX_INCLUDE"], undefined);
|
|
||||||
t.is(process.env["LGTM_INDEX_EXCLUDE"], "codeql-runner-temp");
|
|
||||||
t.is(process.env["LGTM_INDEX_FILTERS"], undefined);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
//# sourceMappingURL=analysis-paths.test.js.map
|
//# sourceMappingURL=analysis-paths.test.js.map
|
||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"analysis-paths.test.js","sourceRoot":"","sources":["../src/analysis-paths.test.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA6B;AAE7B,8CAAuB;AAEvB,gEAAkD;AAClD,mDAA6C;AAC7C,6CAA+B;AAE/B,0BAAU,CAAC,aAAI,CAAC,CAAC;AAEjB,aAAI,CAAC,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;SACzE,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,SAAS,CAAC,CAAC;QACnD,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,SAAS,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,aAAI,CAAC,eAAe,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAChC,OAAO,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE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,GAAG,CAAC,oBAAoB,CAAC,EAAE,SAAS,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,aAAI,CAAC,eAAe,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAChC,OAAO,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QAC5C,MAAM,MAAM,GAAG;YACb,SAAS,EAAE,EAAE;YACb,OAAO,EAAE,EAAE;YACX,KAAK,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC;YACrC,WAAW,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC;YAC3C,iBAAiB,EAAE,EAAE;YACrB,OAAO,EAAE,MAAM;YACf,YAAY,EAAE,MAAM;YACpB,SAAS,EAAE,EAAE;SACd,CAAC;QACF,aAAa,CAAC,8BAA8B,CAAC,MAAM,CAAC,CAAC;QACrD,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,cAAc,CAAC,CAAC;QACxD,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,cAAc,CAAC,CAAC;QACxD,CAAC,CAAC,EAAE,CACF,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,EACjC,gGAAgG,CACjG,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
||||||
64
lib/analyze-action.js
generated
64
lib/analyze-action.js
generated
@@ -7,14 +7,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const fs = __importStar(require("fs"));
|
|
||||||
const path = __importStar(require("path"));
|
|
||||||
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 config_utils_1 = require("./config-utils");
|
const config_utils_1 = require("./config-utils");
|
||||||
const logging_1 = require("./logging");
|
const logging_1 = require("./logging");
|
||||||
const upload_lib = __importStar(require("./upload-lib"));
|
const repository_1 = require("./repository");
|
||||||
const util = __importStar(require("./util"));
|
const util = __importStar(require("./util"));
|
||||||
async function sendStatusReport(startedAt, stats, error) {
|
async function sendStatusReport(startedAt, stats, error) {
|
||||||
var _a, _b, _c;
|
var _a, _b, _c;
|
||||||
@@ -31,74 +29,28 @@ async function sendStatusReport(startedAt, stats, error) {
|
|||||||
async function run() {
|
async function run() {
|
||||||
const startedAt = new Date();
|
const startedAt = new Date();
|
||||||
let stats = undefined;
|
let stats = undefined;
|
||||||
let config = undefined;
|
|
||||||
try {
|
try {
|
||||||
actionsUtil.prepareLocalRunEnvironment();
|
actionsUtil.prepareLocalRunEnvironment();
|
||||||
if (!(await actionsUtil.sendStatusReport(await actionsUtil.createStatusReportBase("finish", "starting", startedAt)))) {
|
if (!(await actionsUtil.sendStatusReport(await actionsUtil.createStatusReportBase("finish", "starting", startedAt), true))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const logger = logging_1.getActionsLogger();
|
const logger = logging_1.getActionsLogger();
|
||||||
config = await config_utils_1.getConfig(actionsUtil.getTemporaryDirectory(), logger);
|
const config = await config_utils_1.getConfig(actionsUtil.getRequiredEnvParam("RUNNER_TEMP"), logger);
|
||||||
if (config === undefined) {
|
if (config === undefined) {
|
||||||
throw new Error("Config file could not be found at expected location. Has the 'init' action been called?");
|
throw new Error("Config file could not be found at expected location. Has the 'init' action been called?");
|
||||||
}
|
}
|
||||||
const apiDetails = {
|
stats = await analyze_1.runAnalyze(repository_1.parseRepositoryNwo(actionsUtil.getRequiredEnvParam("GITHUB_REPOSITORY")), await actionsUtil.getCommitOid(), actionsUtil.getRef(), await actionsUtil.getAnalysisKey(), actionsUtil.getRequiredEnvParam("GITHUB_WORKFLOW"), actionsUtil.getWorkflowRunID(), actionsUtil.getRequiredInput("checkout_path"), actionsUtil.getRequiredInput("matrix"), actionsUtil.getRequiredInput("token"), actionsUtil.getRequiredEnvParam("GITHUB_SERVER_URL"), actionsUtil.getRequiredInput("upload") === "true", "actions", actionsUtil.getRequiredInput("output"), util.getMemoryFlag(actionsUtil.getOptionalInput("ram")), util.getAddSnippetsFlag(actionsUtil.getRequiredInput("add-snippets")), util.getThreadsFlag(actionsUtil.getOptionalInput("threads"), logger), config, logger);
|
||||||
auth: actionsUtil.getRequiredInput("token"),
|
|
||||||
url: actionsUtil.getRequiredEnvParam("GITHUB_SERVER_URL"),
|
|
||||||
};
|
|
||||||
const outputDir = actionsUtil.getRequiredInput("output");
|
|
||||||
const queriesStats = await analyze_1.runAnalyze(outputDir, util.getMemoryFlag(actionsUtil.getOptionalInput("ram")), util.getAddSnippetsFlag(actionsUtil.getRequiredInput("add-snippets")), util.getThreadsFlag(actionsUtil.getOptionalInput("threads"), logger), actionsUtil.getOptionalInput("category"), config, logger);
|
|
||||||
if (actionsUtil.getRequiredInput("upload") === "true") {
|
|
||||||
const uploadStats = await upload_lib.uploadFromActions(outputDir, config.gitHubVersion, apiDetails, logger);
|
|
||||||
stats = { ...queriesStats, ...uploadStats };
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
logger.info("Not uploading results");
|
|
||||||
stats = { ...queriesStats };
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
console.log(error);
|
console.log(error);
|
||||||
if (error instanceof analyze_1.CodeQLAnalysisError) {
|
|
||||||
stats = { ...error.queriesStatusReport };
|
|
||||||
}
|
|
||||||
await sendStatusReport(startedAt, stats, error);
|
await sendStatusReport(startedAt, stats, error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
finally {
|
|
||||||
if (core.isDebug() && config !== undefined) {
|
|
||||||
core.info("Debug mode is on. Printing CodeQL debug logs...");
|
|
||||||
for (const language of config.languages) {
|
|
||||||
const databaseDirectory = util.getCodeQLDatabasePath(config.tempDir, language);
|
|
||||||
const logsDirectory = path.join(databaseDirectory, "log");
|
|
||||||
const walkLogFiles = (dir) => {
|
|
||||||
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
||||||
for (const entry of entries) {
|
|
||||||
if (entry.isFile()) {
|
|
||||||
core.startGroup(`CodeQL Debug Logs - ${language} - ${entry.name}`);
|
|
||||||
process.stdout.write(fs.readFileSync(path.resolve(dir, entry.name)));
|
|
||||||
core.endGroup();
|
|
||||||
}
|
|
||||||
else if (entry.isDirectory()) {
|
|
||||||
walkLogFiles(path.resolve(dir, entry.name));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
walkLogFiles(logsDirectory);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
await sendStatusReport(startedAt, stats);
|
await sendStatusReport(startedAt, stats);
|
||||||
}
|
}
|
||||||
async function runWrapper() {
|
run().catch((e) => {
|
||||||
try {
|
core.setFailed(`analyze action failed: ${e}`);
|
||||||
await run();
|
console.log(e);
|
||||||
}
|
});
|
||||||
catch (error) {
|
|
||||||
core.setFailed(`analyze action failed: ${error}`);
|
|
||||||
console.log(error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void runWrapper();
|
|
||||||
//# sourceMappingURL=analyze-action.js.map
|
//# sourceMappingURL=analyze-action.js.map
|
||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"analyze-action.js","sourceRoot":"","sources":["../src/analyze-action.ts"],"names":[],"mappings":";;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,oDAAsC;AAEtC,4DAA8C;AAC9C,uCAImB;AACnB,iDAAmD;AACnD,uCAA6C;AAC7C,yDAA2C;AAC3C,6CAA+B;AAU/B,KAAK,UAAU,gBAAgB,CAC7B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AC3C,CAAC;AAED,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;IAChB,IAAI,CAAC,SAAS,CAAC,0BAA0B,CAAC,EAAE,CAAC,CAAC;IAC9C,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACjB,CAAC,CAAC,CAAC"}
|
||||||
132
lib/analyze.js
generated
132
lib/analyze.js
generated
@@ -7,24 +7,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
const toolrunnner = __importStar(require("@actions/exec/lib/toolrunner"));
|
||||||
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 analysisPaths = __importStar(require("./analysis-paths"));
|
const analysisPaths = __importStar(require("./analysis-paths"));
|
||||||
const codeql_1 = require("./codeql");
|
const codeql_1 = require("./codeql");
|
||||||
const count_loc_1 = require("./count-loc");
|
|
||||||
const languages_1 = require("./languages");
|
const languages_1 = require("./languages");
|
||||||
const sharedEnv = __importStar(require("./shared-environment"));
|
const sharedEnv = __importStar(require("./shared-environment"));
|
||||||
const upload_lib_1 = require("./upload-lib");
|
const upload_lib = __importStar(require("./upload-lib"));
|
||||||
const util = __importStar(require("./util"));
|
const util = __importStar(require("./util"));
|
||||||
class CodeQLAnalysisError extends Error {
|
|
||||||
constructor(queriesStatusReport, message) {
|
|
||||||
super(message);
|
|
||||||
this.name = "CodeQLAnalysisError";
|
|
||||||
this.queriesStatusReport = queriesStatusReport;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.CodeQLAnalysisError = CodeQLAnalysisError;
|
|
||||||
async function setupPythonExtractor(logger) {
|
async function setupPythonExtractor(logger) {
|
||||||
const codeqlPython = process.env["CODEQL_PYTHON"];
|
const codeqlPython = process.env["CODEQL_PYTHON"];
|
||||||
if (codeqlPython === undefined || codeqlPython.length === 0) {
|
if (codeqlPython === undefined || codeqlPython.length === 0) {
|
||||||
@@ -39,14 +30,14 @@ async function setupPythonExtractor(logger) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
await new toolrunner.ToolRunner(codeqlPython, [
|
await new toolrunnner.ToolRunner(codeqlPython, [
|
||||||
"-c",
|
"-c",
|
||||||
"import os; import pip; print(os.path.dirname(os.path.dirname(pip.__file__)))",
|
"import os; import pip; print(os.path.dirname(os.path.dirname(pip.__file__)))",
|
||||||
], options).exec();
|
], options).exec();
|
||||||
logger.info(`Setting LGTM_INDEX_IMPORT_PATH=${output}`);
|
logger.info(`Setting LGTM_INDEX_IMPORT_PATH=${output}`);
|
||||||
process.env["LGTM_INDEX_IMPORT_PATH"] = output;
|
process.env["LGTM_INDEX_IMPORT_PATH"] = output;
|
||||||
output = "";
|
output = "";
|
||||||
await new toolrunner.ToolRunner(codeqlPython, ["-c", "import sys; print(sys.version_info[0])"], options).exec();
|
await new toolrunnner.ToolRunner(codeqlPython, ["-c", "import sys; print(sys.version_info[0])"], options).exec();
|
||||||
logger.info(`Setting LGTM_PYTHON_SETUP_VERSION=${output}`);
|
logger.info(`Setting LGTM_PYTHON_SETUP_VERSION=${output}`);
|
||||||
process.env["LGTM_PYTHON_SETUP_VERSION"] = output;
|
process.env["LGTM_PYTHON_SETUP_VERSION"] = output;
|
||||||
}
|
}
|
||||||
@@ -66,24 +57,18 @@ async function createdDBForScannedLanguages(config, logger) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async function finalizeDatabaseCreation(config, threadsFlag, logger) {
|
async function finalizeDatabaseCreation(config, logger) {
|
||||||
await createdDBForScannedLanguages(config, logger);
|
await createdDBForScannedLanguages(config, logger);
|
||||||
const codeql = codeql_1.getCodeQL(config.codeQLCmd);
|
const codeql = codeql_1.getCodeQL(config.codeQLCmd);
|
||||||
for (const language of config.languages) {
|
for (const language of config.languages) {
|
||||||
logger.startGroup(`Finalizing ${language}`);
|
logger.startGroup(`Finalizing ${language}`);
|
||||||
await codeql.finalizeDatabase(util.getCodeQLDatabasePath(config.tempDir, language), threadsFlag);
|
await codeql.finalizeDatabase(util.getCodeQLDatabasePath(config.tempDir, language));
|
||||||
logger.endGroup();
|
logger.endGroup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Runs queries and creates sarif files in the given folder
|
// Runs queries and creates sarif files in the given folder
|
||||||
async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag, automationDetailsId, config, logger) {
|
async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag, config, logger) {
|
||||||
const statusReport = {};
|
const statusReport = {};
|
||||||
// count the number of lines in the background
|
|
||||||
const locPromise = count_loc_1.countLoc(path.resolve(),
|
|
||||||
// config.paths specifies external directories. the current
|
|
||||||
// directory is included in the analysis by default. Replicate
|
|
||||||
// that here.
|
|
||||||
config.paths, config.pathsIgnore, config.languages, logger);
|
|
||||||
for (const language of config.languages) {
|
for (const language of config.languages) {
|
||||||
logger.startGroup(`Analyzing ${language}`);
|
logger.startGroup(`Analyzing ${language}`);
|
||||||
const queries = config.queries[language];
|
const queries = config.queries[language];
|
||||||
@@ -91,93 +76,54 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
|
|||||||
throw new Error(`Unable to analyse ${language} as no queries were selected for this language`);
|
throw new Error(`Unable to analyse ${language} as no queries were selected for this language`);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (queries["builtin"].length > 0) {
|
for (const type of ["builtin", "custom"]) {
|
||||||
const startTimeBuliltIn = new Date().getTime();
|
if (queries[type].length > 0) {
|
||||||
const sarifFile = await runQueryGroup(language, "builtin", queries["builtin"], sarifFolder, undefined);
|
const startTime = new Date().getTime();
|
||||||
await injectLinesOfCode(sarifFile, language, locPromise);
|
const databasePath = util.getCodeQLDatabasePath(config.tempDir, language);
|
||||||
statusReport[`analyze_builtin_queries_${language}_duration_ms`] =
|
// Pass the queries to codeql using a file instead of using the command
|
||||||
new Date().getTime() - startTimeBuliltIn;
|
// line to avoid command line length restrictions, particularly on windows.
|
||||||
}
|
const querySuitePath = `${databasePath}-queries-${type}.qls`;
|
||||||
const startTimeCustom = new Date().getTime();
|
const querySuiteContents = queries[type]
|
||||||
const temporarySarifDir = config.tempDir;
|
.map((q) => `- query: ${q}`)
|
||||||
const temporarySarifFiles = [];
|
.join("\n");
|
||||||
for (let i = 0; i < queries["custom"].length; ++i) {
|
fs.writeFileSync(querySuitePath, querySuiteContents);
|
||||||
if (queries["custom"][i].queries.length > 0) {
|
logger.debug(`Query suite file for ${language}...\n${querySuiteContents}`);
|
||||||
const sarifFile = await runQueryGroup(language, `custom-${i}`, queries["custom"][i].queries, temporarySarifDir, queries["custom"][i].searchPath);
|
const sarifFile = path.join(sarifFolder, `${language}-${type}.sarif`);
|
||||||
temporarySarifFiles.push(sarifFile);
|
const codeql = codeql_1.getCodeQL(config.codeQLCmd);
|
||||||
|
await codeql.databaseAnalyze(databasePath, sarifFile, querySuitePath, memoryFlag, addSnippetsFlag, threadsFlag);
|
||||||
|
logger.debug(`SARIF results for database ${language} created at "${sarifFile}"`);
|
||||||
|
logger.endGroup();
|
||||||
|
// Record the performance
|
||||||
|
const endTime = new Date().getTime();
|
||||||
|
statusReport[`analyze_${type}_queries_${language}_duration_ms`] =
|
||||||
|
endTime - startTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (temporarySarifFiles.length > 0) {
|
|
||||||
const sarifFile = path.join(sarifFolder, `${language}-custom.sarif`);
|
|
||||||
fs.writeFileSync(sarifFile, upload_lib_1.combineSarifFiles(temporarySarifFiles));
|
|
||||||
await injectLinesOfCode(sarifFile, language, locPromise);
|
|
||||||
statusReport[`analyze_custom_queries_${language}_duration_ms`] =
|
|
||||||
new Date().getTime() - startTimeCustom;
|
|
||||||
}
|
|
||||||
printLinesOfCodeSummary(logger, language, await locPromise);
|
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
|
logger.error(`Error running analysis for ${language}: ${e}`);
|
||||||
logger.info(e);
|
logger.info(e);
|
||||||
statusReport.analyze_failure_language = language;
|
statusReport.analyze_failure_language = language;
|
||||||
throw new CodeQLAnalysisError(statusReport, `Error running analysis for ${language}: ${e}`);
|
return statusReport;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return statusReport;
|
return statusReport;
|
||||||
async function runQueryGroup(language, type, queries, destinationFolder, searchPath) {
|
|
||||||
const databasePath = util.getCodeQLDatabasePath(config.tempDir, language);
|
|
||||||
// Pass the queries to codeql using a file instead of using the command
|
|
||||||
// line to avoid command line length restrictions, particularly on windows.
|
|
||||||
const querySuitePath = `${databasePath}-queries-${type}.qls`;
|
|
||||||
const querySuiteContents = queries
|
|
||||||
.map((q) => `- query: ${q}`)
|
|
||||||
.join("\n");
|
|
||||||
fs.writeFileSync(querySuitePath, querySuiteContents);
|
|
||||||
logger.debug(`Query suite file for ${language}...\n${querySuiteContents}`);
|
|
||||||
const sarifFile = path.join(destinationFolder, `${language}-${type}.sarif`);
|
|
||||||
const codeql = codeql_1.getCodeQL(config.codeQLCmd);
|
|
||||||
await codeql.databaseAnalyze(databasePath, sarifFile, searchPath, querySuitePath, memoryFlag, addSnippetsFlag, threadsFlag, automationDetailsId);
|
|
||||||
logger.debug(`SARIF results for database ${language} created at "${sarifFile}"`);
|
|
||||||
logger.endGroup();
|
|
||||||
return sarifFile;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
exports.runQueries = runQueries;
|
exports.runQueries = runQueries;
|
||||||
async function runAnalyze(outputDir, memoryFlag, addSnippetsFlag, threadsFlag, automationDetailsId, config, logger) {
|
async function runAnalyze(repositoryNwo, commitOid, ref, analysisKey, analysisName, workflowRunID, checkoutPath, environment, githubAuth, githubUrl, doUpload, mode, outputDir, memoryFlag, addSnippetsFlag, threadsFlag, config, logger) {
|
||||||
// Delete the tracer config env var to avoid tracing ourselves
|
// Delete the tracer config env var to avoid tracing ourselves
|
||||||
delete process.env[sharedEnv.ODASA_TRACER_CONFIGURATION];
|
delete process.env[sharedEnv.ODASA_TRACER_CONFIGURATION];
|
||||||
fs.mkdirSync(outputDir, { recursive: true });
|
fs.mkdirSync(outputDir, { recursive: true });
|
||||||
logger.info("Finalizing database creation");
|
logger.info("Finalizing database creation");
|
||||||
await finalizeDatabaseCreation(config, threadsFlag, logger);
|
await finalizeDatabaseCreation(config, logger);
|
||||||
logger.info("Analyzing database");
|
logger.info("Analyzing database");
|
||||||
const queriesStats = await runQueries(outputDir, memoryFlag, addSnippetsFlag, threadsFlag, automationDetailsId, config, logger);
|
const queriesStats = await runQueries(outputDir, memoryFlag, addSnippetsFlag, threadsFlag, config, logger);
|
||||||
return { ...queriesStats };
|
if (!doUpload) {
|
||||||
|
logger.info("Not uploading results");
|
||||||
|
return { ...queriesStats };
|
||||||
|
}
|
||||||
|
const uploadStats = await upload_lib.upload(outputDir, repositoryNwo, commitOid, ref, analysisKey, analysisName, workflowRunID, checkoutPath, environment, githubAuth, githubUrl, mode, logger);
|
||||||
|
return { ...queriesStats, ...uploadStats };
|
||||||
}
|
}
|
||||||
exports.runAnalyze = runAnalyze;
|
exports.runAnalyze = runAnalyze;
|
||||||
async function injectLinesOfCode(sarifFile, language, locPromise) {
|
|
||||||
const lineCounts = await locPromise;
|
|
||||||
const idPrefix = count_loc_1.getIdPrefix(language);
|
|
||||||
if (language in lineCounts) {
|
|
||||||
const sarif = JSON.parse(fs.readFileSync(sarifFile, "utf8"));
|
|
||||||
if (Array.isArray(sarif.runs)) {
|
|
||||||
for (const run of sarif.runs) {
|
|
||||||
const ruleId = `${idPrefix}/summary/lines-of-code`;
|
|
||||||
run.properties = run.properties || {};
|
|
||||||
run.properties.metricResults = run.properties.metricResults || [];
|
|
||||||
const rule = run.properties.metricResults.find(
|
|
||||||
// the rule id can be in either of two places
|
|
||||||
(r) => { var _a; return r.ruleId === ruleId || ((_a = r.rule) === null || _a === void 0 ? void 0 : _a.id) === ruleId; });
|
|
||||||
// only add the baseline value if the rule already exists
|
|
||||||
if (rule) {
|
|
||||||
rule.baseline = lineCounts[language];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fs.writeFileSync(sarifFile, JSON.stringify(sarif));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function printLinesOfCodeSummary(logger, language, lineCounts) {
|
|
||||||
if (language in lineCounts) {
|
|
||||||
logger.info(`Counted ${lineCounts[language]} lines of code for ${language} as a baseline.`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=analyze.js.map
|
//# sourceMappingURL=analyze.js.map
|
||||||
File diff suppressed because one or more lines are too long
112
lib/analyze.test.js
generated
112
lib/analyze.test.js
generated
@@ -1,4 +1,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
@@ -6,75 +9,27 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
result["default"] = mod;
|
result["default"] = 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 path = __importStar(require("path"));
|
|
||||||
const ava_1 = __importDefault(require("ava"));
|
const ava_1 = __importDefault(require("ava"));
|
||||||
const sinon_1 = __importDefault(require("sinon"));
|
const fs = __importStar(require("fs"));
|
||||||
const analyze_1 = require("./analyze");
|
const analyze_1 = require("./analyze");
|
||||||
const codeql_1 = require("./codeql");
|
const codeql_1 = require("./codeql");
|
||||||
const count_loc_1 = require("./count-loc");
|
|
||||||
const count = __importStar(require("./count-loc"));
|
|
||||||
const languages_1 = require("./languages");
|
const languages_1 = require("./languages");
|
||||||
const logging_1 = require("./logging");
|
const logging_1 = require("./logging");
|
||||||
const testing_utils_1 = require("./testing-utils");
|
const testing_utils_1 = require("./testing-utils");
|
||||||
const util = __importStar(require("./util"));
|
const util = __importStar(require("./util"));
|
||||||
testing_utils_1.setupTests(ava_1.default);
|
testing_utils_1.setupTests(ava_1.default);
|
||||||
// Checks that the duration fields are populated for the correct language
|
// Checks that the duration fields are populated for the correct language
|
||||||
// and correct case of builtin or custom. Also checks the correct search
|
// and correct case of builtin or custom.
|
||||||
// paths are set in the database analyze invocation.
|
ava_1.default("status report fields", async (t) => {
|
||||||
ava_1.default("status report fields and search path setting", async (t) => {
|
|
||||||
const mockLinesOfCode = Object.values(languages_1.Language).reduce((obj, lang, i) => {
|
|
||||||
// use a different line count for each language
|
|
||||||
obj[lang] = i + 1;
|
|
||||||
return obj;
|
|
||||||
}, {});
|
|
||||||
sinon_1.default.stub(count, "countLoc").resolves(mockLinesOfCode);
|
|
||||||
let searchPathsUsed = [];
|
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
testing_utils_1.setupActionsVars(tmpDir, tmpDir);
|
codeql_1.setCodeQL({
|
||||||
|
databaseAnalyze: async () => undefined,
|
||||||
|
});
|
||||||
const memoryFlag = "";
|
const memoryFlag = "";
|
||||||
const addSnippetsFlag = "";
|
const addSnippetsFlag = "";
|
||||||
const threadsFlag = "";
|
const threadsFlag = "";
|
||||||
for (const language of Object.values(languages_1.Language)) {
|
for (const language of Object.values(languages_1.Language)) {
|
||||||
codeql_1.setCodeQL({
|
|
||||||
databaseAnalyze: async (_, sarifFile, searchPath) => {
|
|
||||||
fs.writeFileSync(sarifFile, JSON.stringify({
|
|
||||||
runs: [
|
|
||||||
// variant 1 uses ruleId
|
|
||||||
{
|
|
||||||
properties: {
|
|
||||||
metricResults: [
|
|
||||||
{
|
|
||||||
ruleId: `${count_loc_1.getIdPrefix(language)}/summary/lines-of-code`,
|
|
||||||
value: 123,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
// variant 2 uses rule.id
|
|
||||||
{
|
|
||||||
properties: {
|
|
||||||
metricResults: [
|
|
||||||
{
|
|
||||||
rule: {
|
|
||||||
id: `${count_loc_1.getIdPrefix(language)}/summary/lines-of-code`,
|
|
||||||
},
|
|
||||||
value: 123,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{},
|
|
||||||
],
|
|
||||||
}));
|
|
||||||
searchPathsUsed.push(searchPath);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
searchPathsUsed = [];
|
|
||||||
const config = {
|
const config = {
|
||||||
languages: [language],
|
languages: [language],
|
||||||
queries: {},
|
queries: {},
|
||||||
@@ -84,9 +39,6 @@ ava_1.default("status report fields and search path setting", async (t) => {
|
|||||||
tempDir: tmpDir,
|
tempDir: tmpDir,
|
||||||
toolCacheDir: tmpDir,
|
toolCacheDir: tmpDir,
|
||||||
codeQLCmd: "",
|
codeQLCmd: "",
|
||||||
gitHubVersion: {
|
|
||||||
type: util.GitHubVariant.DOTCOM,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
fs.mkdirSync(util.getCodeQLDatabasePath(config.tempDir, language), {
|
fs.mkdirSync(util.getCodeQLDatabasePath(config.tempDir, language), {
|
||||||
recursive: true,
|
recursive: true,
|
||||||
@@ -95,57 +47,17 @@ ava_1.default("status report fields and search path setting", async (t) => {
|
|||||||
builtin: ["foo.ql"],
|
builtin: ["foo.ql"],
|
||||||
custom: [],
|
custom: [],
|
||||||
};
|
};
|
||||||
const builtinStatusReport = await analyze_1.runQueries(tmpDir, memoryFlag, addSnippetsFlag, threadsFlag, undefined, config, logging_1.getRunnerLogger(true));
|
const builtinStatusReport = await analyze_1.runQueries(tmpDir, memoryFlag, addSnippetsFlag, threadsFlag, config, logging_1.getRunnerLogger(true));
|
||||||
t.deepEqual(Object.keys(builtinStatusReport).length, 1);
|
t.deepEqual(Object.keys(builtinStatusReport).length, 1);
|
||||||
t.true(`analyze_builtin_queries_${language}_duration_ms` in builtinStatusReport);
|
t.true(`analyze_builtin_queries_${language}_duration_ms` in builtinStatusReport);
|
||||||
config.queries[language] = {
|
config.queries[language] = {
|
||||||
builtin: [],
|
builtin: [],
|
||||||
custom: [
|
custom: ["foo.ql"],
|
||||||
{
|
|
||||||
queries: ["foo.ql"],
|
|
||||||
searchPath: "/1",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
queries: ["bar.ql"],
|
|
||||||
searchPath: "/2",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
};
|
||||||
const customStatusReport = await analyze_1.runQueries(tmpDir, memoryFlag, addSnippetsFlag, threadsFlag, undefined, config, logging_1.getRunnerLogger(true));
|
const customStatusReport = await analyze_1.runQueries(tmpDir, memoryFlag, addSnippetsFlag, threadsFlag, config, logging_1.getRunnerLogger(true));
|
||||||
t.deepEqual(Object.keys(customStatusReport).length, 1);
|
t.deepEqual(Object.keys(customStatusReport).length, 1);
|
||||||
t.true(`analyze_custom_queries_${language}_duration_ms` in customStatusReport);
|
t.true(`analyze_custom_queries_${language}_duration_ms` in customStatusReport);
|
||||||
t.deepEqual(searchPathsUsed, [undefined, "/1", "/2"]);
|
|
||||||
}
|
}
|
||||||
verifyLineCounts(tmpDir);
|
|
||||||
});
|
});
|
||||||
function verifyLineCounts(tmpDir) {
|
|
||||||
// eslint-disable-next-line github/array-foreach
|
|
||||||
Object.keys(languages_1.Language).forEach((lang, i) => {
|
|
||||||
verifyLineCountForFile(lang, path.join(tmpDir, `${lang}-builtin.sarif`), i + 1);
|
|
||||||
verifyLineCountForFile(lang, path.join(tmpDir, `${lang}-custom.sarif`), i + 1);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
function verifyLineCountForFile(lang, filePath, lineCount) {
|
|
||||||
const idPrefix = count_loc_1.getIdPrefix(lang);
|
|
||||||
const sarif = JSON.parse(fs.readFileSync(filePath, "utf8"));
|
|
||||||
t.deepEqual(sarif.runs[0].properties.metricResults, [
|
|
||||||
{
|
|
||||||
ruleId: `${idPrefix}/summary/lines-of-code`,
|
|
||||||
value: 123,
|
|
||||||
baseline: lineCount,
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
t.deepEqual(sarif.runs[1].properties.metricResults, [
|
|
||||||
{
|
|
||||||
rule: {
|
|
||||||
id: `${idPrefix}/summary/lines-of-code`,
|
|
||||||
},
|
|
||||||
value: 123,
|
|
||||||
baseline: lineCount,
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
// when the rule doesn't exists, it should not be added
|
|
||||||
t.deepEqual(sarif.runs[2].properties.metricResults, []);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
//# sourceMappingURL=analyze.test.js.map
|
//# sourceMappingURL=analyze.test.js.map
|
||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"analyze.test.js","sourceRoot":"","sources":["../src/analyze.test.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,8CAAuB;AACvB,kDAA0B;AAE1B,uCAAuC;AACvC,qCAAqC;AAErC,2CAA0C;AAC1C,mDAAqC;AACrC,2CAAuC;AACvC,uCAA4C;AAC5C,mDAA+D;AAC/D,6CAA+B;AAE/B,0BAAU,CAAC,aAAI,CAAC,CAAC;AAEjB,yEAAyE;AACzE,wEAAwE;AACxE,oDAAoD;AACpD,aAAI,CAAC,8CAA8C,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAC/D,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,oBAA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AC,CAAC,CAAC;YACvD,CAAC,CAAC,IAAI,CACJ,0BAA0B,QAAQ,cAAc,IAAI,kBAAkB,CACvE,CAAC;SACH;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
||||||
26
lib/api-client.js
generated
26
lib/api-client.js
generated
@@ -10,30 +10,26 @@ 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 });
|
||||||
const path = __importStar(require("path"));
|
|
||||||
const githubUtils = __importStar(require("@actions/github/lib/utils"));
|
const githubUtils = __importStar(require("@actions/github/lib/utils"));
|
||||||
|
const retry = __importStar(require("@octokit/plugin-retry"));
|
||||||
const console_log_level_1 = __importDefault(require("console-log-level"));
|
const console_log_level_1 = __importDefault(require("console-log-level"));
|
||||||
|
const path = __importStar(require("path"));
|
||||||
const actions_util_1 = require("./actions-util");
|
const actions_util_1 = require("./actions-util");
|
||||||
const util_1 = require("./util");
|
const util_1 = require("./util");
|
||||||
var DisallowedAPIVersionReason;
|
exports.getApiClient = function (githubAuth, githubUrl, allowLocalRun = false) {
|
||||||
(function (DisallowedAPIVersionReason) {
|
|
||||||
DisallowedAPIVersionReason[DisallowedAPIVersionReason["ACTION_TOO_OLD"] = 0] = "ACTION_TOO_OLD";
|
|
||||||
DisallowedAPIVersionReason[DisallowedAPIVersionReason["ACTION_TOO_NEW"] = 1] = "ACTION_TOO_NEW";
|
|
||||||
})(DisallowedAPIVersionReason = exports.DisallowedAPIVersionReason || (exports.DisallowedAPIVersionReason = {}));
|
|
||||||
exports.getApiClient = function (apiDetails, { allowLocalRun = false, allowExternal = false } = {}) {
|
|
||||||
if (util_1.isLocalRun() && !allowLocalRun) {
|
if (util_1.isLocalRun() && !allowLocalRun) {
|
||||||
throw new Error("Invalid API call in local run");
|
throw new Error("Invalid API call in local run");
|
||||||
}
|
}
|
||||||
const auth = (allowExternal && apiDetails.externalRepoAuth) || apiDetails.auth;
|
const retryingOctokit = githubUtils.GitHub.plugin(retry.retry);
|
||||||
return new githubUtils.GitHub(githubUtils.getOctokitOptions(auth, {
|
return new retryingOctokit(githubUtils.getOctokitOptions(githubAuth, {
|
||||||
baseUrl: getApiUrl(apiDetails.url),
|
baseUrl: getApiUrl(githubUrl),
|
||||||
userAgent: "CodeQL Action",
|
userAgent: "CodeQL Action",
|
||||||
log: console_log_level_1.default({ level: "debug" }),
|
log: console_log_level_1.default({ level: "debug" }),
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
function getApiUrl(githubUrl) {
|
function getApiUrl(githubUrl) {
|
||||||
const url = new URL(githubUrl);
|
const url = new URL(githubUrl);
|
||||||
// If we detect this is trying to connect to github.com
|
// If we detect this is trying to be to github.com
|
||||||
// then return with a fixed canonical URL.
|
// then return with a fixed canonical URL.
|
||||||
if (url.hostname === "github.com" || url.hostname === "api.github.com") {
|
if (url.hostname === "github.com" || url.hostname === "api.github.com") {
|
||||||
return "https://api.github.com";
|
return "https://api.github.com";
|
||||||
@@ -43,14 +39,10 @@ function getApiUrl(githubUrl) {
|
|||||||
return url.toString();
|
return url.toString();
|
||||||
}
|
}
|
||||||
// Temporary function to aid in the transition to running on and off of github actions.
|
// Temporary function to aid in the transition to running on and off of github actions.
|
||||||
// Once all code has been converted this function should be removed or made canonical
|
// Once all code has been coverted this function should be removed or made canonical
|
||||||
// and called only from the action entrypoints.
|
// and called only from the action entrypoints.
|
||||||
function getActionsApiClient(allowLocalRun = false) {
|
function getActionsApiClient(allowLocalRun = false) {
|
||||||
const apiDetails = {
|
return exports.getApiClient(actions_util_1.getRequiredInput("token"), actions_util_1.getRequiredEnvParam("GITHUB_SERVER_URL"), allowLocalRun);
|
||||||
auth: actions_util_1.getRequiredInput("token"),
|
|
||||||
url: actions_util_1.getRequiredEnvParam("GITHUB_SERVER_URL"),
|
|
||||||
};
|
|
||||||
return exports.getApiClient(apiDetails, { allowLocalRun });
|
|
||||||
}
|
}
|
||||||
exports.getActionsApiClient = getActionsApiClient;
|
exports.getActionsApiClient = getActionsApiClient;
|
||||||
//# sourceMappingURL=api-client.js.map
|
//# sourceMappingURL=api-client.js.map
|
||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"api-client.js","sourceRoot":"","sources":["../src/api-client.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA6B;AAE7B,uEAAyD;AACzD,0EAAgD;AAEhD,iDAAuE;AACvE,iCAAoC;AAEpC,IAAY,0BAGX;AAHD,WAAY,0BAA0B;IACpC,+FAAc,CAAA;IACd,+FAAc,CAAA;AAChB,CAAC,EAHW,0BAA0B,GAA1B,kCAA0B,KAA1B,kCAA0B,QAGrC;AAeY,QAAA,YAAY,GAAG,UAC1B,UAAoC,EACpC,EAAE,aAAa,GAAG,KAAK,EAAE,aAAa,GAAG,KAAK,EAAE,GAAG,EAAE;IAErD,IAAI,iBAAU,EAAE,IAAI,CAAC,aAAa,EAAE;QAClC,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;KAClD;IAED,MAAM,IAAI,GACR,CAAC,aAAa,IAAI,UAAU,CAAC,gBAAgB,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC;IACpE,OAAO,IAAI,WAAW,CAAC,MAAM,CAC3B,WAAW,CAAC,iBAAiB,CAAC,IAAI,EAAE;QAClC,OAAO,EAAE,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC;QAClC,SAAS,EAAE,eAAe;QAC1B,GAAG,EAAE,2BAAe,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;KACzC,CAAC,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,SAAS,SAAS,CAAC,SAAiB;IAClC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC;IAE/B,uDAAuD;IACvD,0CAA0C;IAC1C,IAAI,GAA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EAAE,CAAC;KACzC,CAAC,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,SAAS,SAAS,CAAC,SAAiB;IAClC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,CAAC;IAE/B,kDAAkD;IAClD,0CAA0C;IAC1C,IAAI,GAAG,CAAC,QAAQ,KAAK,YAAY,IAAI,GAAG,CAAC,QAAQ,KAAK,gBAAgB,EAAE;QACtE,OAAO,wBAAwB,CAAC;KACjC;IAED,6BAA6B;IAC7B,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IACpD,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;AACxB,CAAC;AAED,uFAAuF;AACvF,oFAAoF;AACpF,+CAA+C;AAC/C,SAAgB,mBAAmB,CAAC,aAAa,GAAG,KAAK;IACvD,OAAO,oBAAY,CACjB,+BAAgB,CAAC,OAAO,CAAC,EACzB,kCAAmB,CAAC,mBAAmB,CAAC,EACxC,aAAa,CACd,CAAC;AACJ,CAAC;AAND,kDAMC"}
|
||||||
72
lib/api-client.test.js
generated
72
lib/api-client.test.js
generated
@@ -1,72 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
||||||
result["default"] = mod;
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const githubUtils = __importStar(require("@actions/github/lib/utils"));
|
|
||||||
const ava_1 = __importDefault(require("ava"));
|
|
||||||
const sinon_1 = __importDefault(require("sinon"));
|
|
||||||
const api_client_1 = require("./api-client");
|
|
||||||
const testing_utils_1 = require("./testing-utils");
|
|
||||||
testing_utils_1.setupTests(ava_1.default);
|
|
||||||
let githubStub;
|
|
||||||
ava_1.default.beforeEach(() => {
|
|
||||||
githubStub = sinon_1.default.stub(githubUtils, "GitHub");
|
|
||||||
});
|
|
||||||
ava_1.default("Get the client API", async (t) => {
|
|
||||||
doTest(t, {
|
|
||||||
auth: "xyz",
|
|
||||||
externalRepoAuth: "abc",
|
|
||||||
url: "http://hucairz",
|
|
||||||
}, undefined, {
|
|
||||||
auth: "token xyz",
|
|
||||||
baseUrl: "http://hucairz/api/v3",
|
|
||||||
userAgent: "CodeQL Action",
|
|
||||||
});
|
|
||||||
});
|
|
||||||
ava_1.default("Get the client API external", async (t) => {
|
|
||||||
doTest(t, {
|
|
||||||
auth: "xyz",
|
|
||||||
externalRepoAuth: "abc",
|
|
||||||
url: "http://hucairz",
|
|
||||||
}, { allowExternal: true }, {
|
|
||||||
auth: "token abc",
|
|
||||||
baseUrl: "http://hucairz/api/v3",
|
|
||||||
userAgent: "CodeQL Action",
|
|
||||||
});
|
|
||||||
});
|
|
||||||
ava_1.default("Get the client API external not present", async (t) => {
|
|
||||||
doTest(t, {
|
|
||||||
auth: "xyz",
|
|
||||||
url: "http://hucairz",
|
|
||||||
}, { allowExternal: true }, {
|
|
||||||
auth: "token xyz",
|
|
||||||
baseUrl: "http://hucairz/api/v3",
|
|
||||||
userAgent: "CodeQL Action",
|
|
||||||
});
|
|
||||||
});
|
|
||||||
ava_1.default("Get the client API with github url", async (t) => {
|
|
||||||
doTest(t, {
|
|
||||||
auth: "xyz",
|
|
||||||
url: "https://github.com/some/invalid/url",
|
|
||||||
}, undefined, {
|
|
||||||
auth: "token xyz",
|
|
||||||
baseUrl: "https://api.github.com",
|
|
||||||
userAgent: "CodeQL Action",
|
|
||||||
});
|
|
||||||
});
|
|
||||||
function doTest(t, clientArgs, clientOptions, expected) {
|
|
||||||
api_client_1.getApiClient(clientArgs, clientOptions);
|
|
||||||
const firstCallArgs = githubStub.args[0];
|
|
||||||
// log is a function, so we don't need to test for equality of it
|
|
||||||
delete firstCallArgs[0].log;
|
|
||||||
t.deepEqual(firstCallArgs, [expected]);
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=api-client.test.js.map
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"api-client.test.js","sourceRoot":"","sources":["../src/api-client.test.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uEAAyD;AACzD,8CAA6C;AAC7C,kDAA0B;AAE1B,6CAA4C;AAC5C,mDAA6C;AAE7C,0BAAU,CAAC,aAAI,CAAC,CAAC;AAEjB,IAAI,UAA2B,CAAC;AAEhC,aAAI,CAAC,UAAU,CAAC,GAAG,EAAE;IACnB,UAAU,GAAG,eAAK,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;AACjD,CAAC,CAAC,CAAC;AAEH,aAAI,CAAC,oBAAoB,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IACrC,MAAM,CACJ,CAAC,EACD;QACE,IAAI,EAAE,KAAK;QACX,gBAAgB,EAAE,KAAK;QACvB,GAAG,EAAE,gBAAgB;KACtB,EACD,SAAS,EACT;QACE,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,uBAAuB;QAChC,SAAS,EAAE,eAAe;KAC3B,CACF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,aAAI,CAAC,6BAA6B,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAC9C,MAAM,CACJ,CAAC,EACD;QACE,IAAI,EAAE,KAAK;QACX,gBAAgB,EAAE,KAAK;QACvB,GAAG,EAAE,gBAAgB;KACtB,EACD,EAAE,aAAa,EAAE,IAAI,EAAE,EACvB;QACE,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,uBAAuB;QAChC,SAAS,EAAE,eAAe;KAC3B,CACF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,aAAI,CAAC,yCAAyC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAC1D,MAAM,CACJ,CAAC,EACD;QACE,IAAI,EAAE,KAAK;QACX,GAAG,EAAE,gBAAgB;KACtB,EACD,EAAE,aAAa,EAAE,IAAI,EAAE,EACvB;QACE,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,uBAAuB;QAChC,SAAS,EAAE,eAAe;KAC3B,CACF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,aAAI,CAAC,oCAAoC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IACrD,MAAM,CACJ,CAAC,EACD;QACE,IAAI,EAAE,KAAK;QACX,GAAG,EAAE,qCAAqC;KAC3C,EACD,SAAS,EACT;QACE,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,wBAAwB;QACjC,SAAS,EAAE,eAAe;KAC3B,CACF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,SAAS,MAAM,CACb,CAA4B,EAC5B,UAAe,EACf,aAAkB,EAClB,QAAa;IAEb,yBAAY,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;IAExC,MAAM,aAAa,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACzC,iEAAiE;IACjE,OAAO,aAAa,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IAC5B,CAAC,CAAC,SAAS,CAAC,aAAa,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;AACzC,CAAC"}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{ "maximumVersion": "3.1", "minimumVersion": "2.22" }
|
|
||||||
18
lib/autobuild-action.js
generated
18
lib/autobuild-action.js
generated
@@ -31,10 +31,10 @@ async function run() {
|
|||||||
let language = undefined;
|
let language = undefined;
|
||||||
try {
|
try {
|
||||||
actionsUtil.prepareLocalRunEnvironment();
|
actionsUtil.prepareLocalRunEnvironment();
|
||||||
if (!(await actionsUtil.sendStatusReport(await actionsUtil.createStatusReportBase("autobuild", "starting", startedAt)))) {
|
if (!(await actionsUtil.sendStatusReport(await actionsUtil.createStatusReportBase("autobuild", "starting", startedAt), true))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const config = await config_utils.getConfig(actionsUtil.getTemporaryDirectory(), logger);
|
const config = await config_utils.getConfig(actionsUtil.getRequiredEnvParam("RUNNER_TEMP"), logger);
|
||||||
if (config === undefined) {
|
if (config === undefined) {
|
||||||
throw new Error("Config file could not be found at expected location. Has the 'init' action been called?");
|
throw new Error("Config file could not be found at expected location. Has the 'init' action been called?");
|
||||||
}
|
}
|
||||||
@@ -51,14 +51,8 @@ async function run() {
|
|||||||
}
|
}
|
||||||
await sendCompletedStatusReport(startedAt, language ? [language] : []);
|
await sendCompletedStatusReport(startedAt, language ? [language] : []);
|
||||||
}
|
}
|
||||||
async function runWrapper() {
|
run().catch((e) => {
|
||||||
try {
|
core.setFailed(`autobuild action failed. ${e}`);
|
||||||
await run();
|
console.log(e);
|
||||||
}
|
});
|
||||||
catch (error) {
|
|
||||||
core.setFailed(`autobuild action failed. ${error}`);
|
|
||||||
console.log(error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void runWrapper();
|
|
||||||
//# sourceMappingURL=autobuild-action.js.map
|
//# sourceMappingURL=autobuild-action.js.map
|
||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"autobuild-action.js","sourceRoot":"","sources":["../src/autobuild-action.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAsC;AAEtC,4DAA8C;AAC9C,2CAAuE;AACvE,6DAA+C;AAE/C,uCAA6C;AAS7C,KAAK,UAAU,yBAAyB,CACtC,SAAe,EACf,YAAsB,EACtB,eAAwB,EACxB,KAAa;;IAEb,MAAM,MAAM,GACV,eAAe,KAAK,SAAS,IAAI,KAAK,KAAK,SAAS;QAClD,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,SAAS,CAAC;IAChB,MAAM,gBAAgB,GAAG,MAAM,WAAW,CAAC,sBAAsB,CAC/D,WAAW,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AA6B,CAAC,EAAE,CAAC,CAAC;IACjD,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACjB,CAAC,CAAC,CAAC"}
|
||||||
270
lib/codeql.js
generated
270
lib/codeql.js
generated
@@ -10,21 +10,19 @@ 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 });
|
||||||
|
const toolrunnner = __importStar(require("@actions/exec/lib/toolrunner"));
|
||||||
|
const http = __importStar(require("@actions/http-client"));
|
||||||
|
const toolcache = __importStar(require("@actions/tool-cache"));
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
|
const semver = __importStar(require("semver"));
|
||||||
const stream = __importStar(require("stream"));
|
const stream = __importStar(require("stream"));
|
||||||
const globalutil = __importStar(require("util"));
|
const globalutil = __importStar(require("util"));
|
||||||
const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
|
const v4_1 = __importDefault(require("uuid/v4"));
|
||||||
const http = __importStar(require("@actions/http-client"));
|
|
||||||
const fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
|
|
||||||
const query_string_1 = __importDefault(require("query-string"));
|
|
||||||
const semver = __importStar(require("semver"));
|
|
||||||
const uuid_1 = require("uuid");
|
|
||||||
const actions_util_1 = require("./actions-util");
|
const actions_util_1 = require("./actions-util");
|
||||||
const api = __importStar(require("./api-client"));
|
const api = __importStar(require("./api-client"));
|
||||||
const defaults = __importStar(require("./defaults.json")); // Referenced from codeql-action-sync-tool!
|
const defaults = __importStar(require("./defaults.json")); // Referenced from codeql-action-sync-tool!
|
||||||
const error_matcher_1 = require("./error-matcher");
|
const error_matcher_1 = require("./error-matcher");
|
||||||
const 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"));
|
||||||
/**
|
/**
|
||||||
@@ -33,87 +31,40 @@ const util = __importStar(require("./util"));
|
|||||||
*/
|
*/
|
||||||
let cachedCodeQL = undefined;
|
let cachedCodeQL = undefined;
|
||||||
const CODEQL_BUNDLE_VERSION = defaults.bundleVersion;
|
const CODEQL_BUNDLE_VERSION = defaults.bundleVersion;
|
||||||
|
const CODEQL_BUNDLE_NAME = "codeql-bundle.tar.gz";
|
||||||
const CODEQL_DEFAULT_ACTION_REPOSITORY = "github/codeql-action";
|
const CODEQL_DEFAULT_ACTION_REPOSITORY = "github/codeql-action";
|
||||||
function getCodeQLBundleName() {
|
function getCodeQLActionRepository(mode) {
|
||||||
let platform;
|
|
||||||
if (process.platform === "win32") {
|
|
||||||
platform = "win64";
|
|
||||||
}
|
|
||||||
else if (process.platform === "linux") {
|
|
||||||
platform = "linux64";
|
|
||||||
}
|
|
||||||
else if (process.platform === "darwin") {
|
|
||||||
platform = "osx64";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return "codeql-bundle.tar.gz";
|
|
||||||
}
|
|
||||||
return `codeql-bundle-${platform}.tar.gz`;
|
|
||||||
}
|
|
||||||
function getCodeQLActionRepository(mode, logger) {
|
|
||||||
if (mode !== "actions") {
|
if (mode !== "actions") {
|
||||||
return CODEQL_DEFAULT_ACTION_REPOSITORY;
|
return CODEQL_DEFAULT_ACTION_REPOSITORY;
|
||||||
}
|
}
|
||||||
else {
|
// Actions do not know their own repository name,
|
||||||
return getActionsCodeQLActionRepository(logger);
|
// so we currently use this hack to find the name based on where our files are.
|
||||||
}
|
// This can be removed once the change to the runner in https://github.com/actions/runner/pull/585 is deployed.
|
||||||
}
|
const runnerTemp = actions_util_1.getRequiredEnvParam("RUNNER_TEMP");
|
||||||
function getActionsCodeQLActionRepository(logger) {
|
const actionsDirectory = path.join(path.dirname(runnerTemp), "_actions");
|
||||||
if (process.env["GITHUB_ACTION_REPOSITORY"] !== undefined) {
|
const relativeScriptPath = path.relative(actionsDirectory, __filename);
|
||||||
return process.env["GITHUB_ACTION_REPOSITORY"];
|
// This handles the case where the Action does not come from an Action repository,
|
||||||
}
|
// e.g. our integration tests which use the Action code from the current checkout.
|
||||||
// The Actions Runner used with GitHub Enterprise Server 2.22 did not set the GITHUB_ACTION_REPOSITORY variable.
|
if (relativeScriptPath.startsWith("..") ||
|
||||||
// This fallback logic can be removed after the end-of-support for 2.22 on 2021-09-23.
|
path.isAbsolute(relativeScriptPath)) {
|
||||||
if (actions_util_1.isRunningLocalAction()) {
|
|
||||||
// This handles the case where the Action does not come from an Action repository,
|
|
||||||
// e.g. our integration tests which use the Action code from the current checkout.
|
|
||||||
logger.info("The CodeQL Action is checked out locally. Using the default CodeQL Action repository.");
|
|
||||||
return CODEQL_DEFAULT_ACTION_REPOSITORY;
|
return CODEQL_DEFAULT_ACTION_REPOSITORY;
|
||||||
}
|
}
|
||||||
logger.info("GITHUB_ACTION_REPOSITORY environment variable was not set. Falling back to legacy method of finding the GitHub Action.");
|
const relativeScriptPathParts = relativeScriptPath.split(path.sep);
|
||||||
const relativeScriptPathParts = actions_util_1.getRelativeScriptPath().split(path.sep);
|
|
||||||
return `${relativeScriptPathParts[0]}/${relativeScriptPathParts[1]}`;
|
return `${relativeScriptPathParts[0]}/${relativeScriptPathParts[1]}`;
|
||||||
}
|
}
|
||||||
async function getCodeQLBundleDownloadURL(apiDetails, mode, variant, logger) {
|
async function getCodeQLBundleDownloadURL(githubAuth, githubUrl, mode, logger) {
|
||||||
const codeQLActionRepository = getCodeQLActionRepository(mode, logger);
|
const codeQLActionRepository = getCodeQLActionRepository(mode);
|
||||||
const potentialDownloadSources = [
|
const potentialDownloadSources = [
|
||||||
// This GitHub instance, and this Action.
|
// This GitHub instance, and this Action.
|
||||||
[apiDetails.url, codeQLActionRepository],
|
[githubUrl, codeQLActionRepository],
|
||||||
// This GitHub instance, and the canonical Action.
|
// This GitHub instance, and the canonical Action.
|
||||||
[apiDetails.url, CODEQL_DEFAULT_ACTION_REPOSITORY],
|
[githubUrl, CODEQL_DEFAULT_ACTION_REPOSITORY],
|
||||||
// GitHub.com, and the canonical Action.
|
// GitHub.com, and the canonical Action.
|
||||||
[util.GITHUB_DOTCOM_URL, CODEQL_DEFAULT_ACTION_REPOSITORY],
|
[util.GITHUB_DOTCOM_URL, CODEQL_DEFAULT_ACTION_REPOSITORY],
|
||||||
];
|
];
|
||||||
// We now filter out any duplicates.
|
// We now filter out any duplicates.
|
||||||
// Duplicates will happen either because the GitHub instance is GitHub.com, or because the Action is not a fork.
|
// Duplicates will happen either because the GitHub instance is GitHub.com, or because the Action is not a fork.
|
||||||
const uniqueDownloadSources = potentialDownloadSources.filter((source, index, self) => {
|
const uniqueDownloadSources = potentialDownloadSources.filter((url, index, self) => index === self.indexOf(url));
|
||||||
return !self.slice(0, index).some((other) => fast_deep_equal_1.default(source, other));
|
|
||||||
});
|
|
||||||
const codeQLBundleName = getCodeQLBundleName();
|
|
||||||
if (variant === util.GitHubVariant.GHAE) {
|
|
||||||
try {
|
|
||||||
const release = await api
|
|
||||||
.getApiClient(apiDetails)
|
|
||||||
.request("GET /enterprise/code-scanning/codeql-bundle/find/{tag}", {
|
|
||||||
tag: CODEQL_BUNDLE_VERSION,
|
|
||||||
});
|
|
||||||
const assetID = release.data.assets[codeQLBundleName];
|
|
||||||
if (assetID !== undefined) {
|
|
||||||
const download = await api
|
|
||||||
.getApiClient(apiDetails)
|
|
||||||
.request("GET /enterprise/code-scanning/codeql-bundle/download/{asset_id}", { asset_id: assetID });
|
|
||||||
const downloadURL = download.data.url;
|
|
||||||
logger.info(`Found CodeQL bundle at GitHub AE endpoint with URL ${downloadURL}.`);
|
|
||||||
return downloadURL;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
logger.info(`Attempted to fetch bundle from GitHub AE endpoint but the bundle ${codeQLBundleName} was not found in the assets ${JSON.stringify(release.data.assets)}.`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
logger.info(`Attempted to fetch bundle from GitHub AE endpoint but got error ${e}.`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (const downloadSource of uniqueDownloadSources) {
|
for (const downloadSource of uniqueDownloadSources) {
|
||||||
const [apiURL, repository] = downloadSource;
|
const [apiURL, repository] = downloadSource;
|
||||||
// If we've reached the final case, short-circuit the API check since we know the bundle exists and is public.
|
// If we've reached the final case, short-circuit the API check since we know the bundle exists and is public.
|
||||||
@@ -123,13 +74,15 @@ async function getCodeQLBundleDownloadURL(apiDetails, mode, variant, logger) {
|
|||||||
}
|
}
|
||||||
const [repositoryOwner, repositoryName] = repository.split("/");
|
const [repositoryOwner, repositoryName] = repository.split("/");
|
||||||
try {
|
try {
|
||||||
const release = await api.getApiClient(apiDetails).repos.getReleaseByTag({
|
const release = await api
|
||||||
|
.getApiClient(githubAuth, githubUrl)
|
||||||
|
.repos.getReleaseByTag({
|
||||||
owner: repositoryOwner,
|
owner: repositoryOwner,
|
||||||
repo: repositoryName,
|
repo: repositoryName,
|
||||||
tag: CODEQL_BUNDLE_VERSION,
|
tag: CODEQL_BUNDLE_VERSION,
|
||||||
});
|
});
|
||||||
for (const asset of release.data.assets) {
|
for (const asset of release.data.assets) {
|
||||||
if (asset.name === codeQLBundleName) {
|
if (asset.name === CODEQL_BUNDLE_NAME) {
|
||||||
logger.info(`Found CodeQL bundle in ${downloadSource[1]} on ${downloadSource[0]} with URL ${asset.url}.`);
|
logger.info(`Found CodeQL bundle in ${downloadSource[1]} on ${downloadSource[0]} with URL ${asset.url}.`);
|
||||||
return asset.url;
|
return asset.url;
|
||||||
}
|
}
|
||||||
@@ -139,13 +92,13 @@ async function getCodeQLBundleDownloadURL(apiDetails, mode, variant, logger) {
|
|||||||
logger.info(`Looked for CodeQL bundle in ${downloadSource[1]} on ${downloadSource[0]} but got error ${e}.`);
|
logger.info(`Looked for CodeQL bundle in ${downloadSource[1]} on ${downloadSource[0]} but got error ${e}.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return `https://github.com/${CODEQL_DEFAULT_ACTION_REPOSITORY}/releases/download/${CODEQL_BUNDLE_VERSION}/${codeQLBundleName}`;
|
return `https://github.com/${CODEQL_DEFAULT_ACTION_REPOSITORY}/releases/download/${CODEQL_BUNDLE_VERSION}/${CODEQL_BUNDLE_NAME}`;
|
||||||
}
|
}
|
||||||
// We have to download CodeQL manually because the toolcache doesn't support Accept headers.
|
// We have to download CodeQL manually because the toolcache doesn't support Accept headers.
|
||||||
// This can be removed once https://github.com/actions/toolkit/pull/530 is merged and released.
|
// This can be removed once https://github.com/actions/toolkit/pull/530 is merged and released.
|
||||||
async function toolcacheDownloadTool(url, headers, tempDir, logger) {
|
async function toolcacheDownloadTool(url, headers, tempDir, logger) {
|
||||||
const client = new http.HttpClient("CodeQL Action");
|
const client = new http.HttpClient("CodeQL Action");
|
||||||
const dest = path.join(tempDir, uuid_1.v4());
|
const dest = path.join(tempDir, v4_1.default());
|
||||||
const response = await client.get(url, headers);
|
const response = await client.get(url, headers);
|
||||||
if (response.message.statusCode !== 200) {
|
if (response.message.statusCode !== 200) {
|
||||||
logger.info(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`);
|
logger.info(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`);
|
||||||
@@ -156,49 +109,29 @@ async function toolcacheDownloadTool(url, headers, tempDir, logger) {
|
|||||||
await pipeline(response.message, fs.createWriteStream(dest));
|
await pipeline(response.message, fs.createWriteStream(dest));
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
async function setupCodeQL(codeqlURL, apiDetails, tempDir, toolCacheDir, mode, variant, logger) {
|
async function setupCodeQL(codeqlURL, githubAuth, githubUrl, tempDir, toolsDir, mode, logger) {
|
||||||
|
// Setting these two env vars makes the toolcache code safe to use outside,
|
||||||
|
// of actions but this is obviously not a great thing we're doing and it would
|
||||||
|
// be better to write our own implementation to use outside of actions.
|
||||||
|
process.env["RUNNER_TEMP"] = tempDir;
|
||||||
|
process.env["RUNNER_TOOL_CACHE"] = toolsDir;
|
||||||
try {
|
try {
|
||||||
// We use the special value of 'latest' to prioritize the version in the
|
const codeqlURLVersion = getCodeQLURLVersion(codeqlURL || `/${CODEQL_BUNDLE_VERSION}/`, logger);
|
||||||
// defaults over any pinned cached version.
|
let codeqlFolder = toolcache.find("CodeQL", codeqlURLVersion);
|
||||||
const forceLatest = codeqlURL === "latest";
|
|
||||||
if (forceLatest) {
|
|
||||||
codeqlURL = undefined;
|
|
||||||
}
|
|
||||||
const codeqlURLVersion = getCodeQLURLVersion(codeqlURL || `/${CODEQL_BUNDLE_VERSION}/`);
|
|
||||||
const codeqlURLSemVer = convertToSemVer(codeqlURLVersion, logger);
|
|
||||||
// If we find the specified version, we always use that.
|
|
||||||
let codeqlFolder = toolcache.find("CodeQL", codeqlURLSemVer, mode, toolCacheDir, logger);
|
|
||||||
// If we don't find the requested version, in some cases we may allow a
|
|
||||||
// different version to save download time if the version hasn't been
|
|
||||||
// specified explicitly (in which case we always honor it).
|
|
||||||
if (!codeqlFolder && !codeqlURL && !forceLatest) {
|
|
||||||
const codeqlVersions = toolcache.findAllVersions("CodeQL", mode, toolCacheDir, logger);
|
|
||||||
if (codeqlVersions.length === 1) {
|
|
||||||
const tmpCodeqlFolder = toolcache.find("CodeQL", codeqlVersions[0], mode, toolCacheDir, logger);
|
|
||||||
if (fs.existsSync(path.join(tmpCodeqlFolder, "pinned-version"))) {
|
|
||||||
logger.debug(`CodeQL in cache overriding the default ${CODEQL_BUNDLE_VERSION}`);
|
|
||||||
codeqlFolder = tmpCodeqlFolder;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (codeqlFolder) {
|
if (codeqlFolder) {
|
||||||
logger.debug(`CodeQL found in cache ${codeqlFolder}`);
|
logger.debug(`CodeQL found in cache ${codeqlFolder}`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!codeqlURL) {
|
if (!codeqlURL) {
|
||||||
codeqlURL = await getCodeQLBundleDownloadURL(apiDetails, mode, variant, logger);
|
codeqlURL = await getCodeQLBundleDownloadURL(githubAuth, githubUrl, mode, logger);
|
||||||
}
|
}
|
||||||
const parsedCodeQLURL = new URL(codeqlURL);
|
|
||||||
const parsedQueryString = query_string_1.default.parse(parsedCodeQLURL.search);
|
|
||||||
const headers = { accept: "application/octet-stream" };
|
const headers = { accept: "application/octet-stream" };
|
||||||
// We only want to provide an authorization header if we are downloading
|
// We only want to provide an authorization header if we are downloading
|
||||||
// from the same GitHub instance the Action is running on.
|
// from the same GitHub instance the Action is running on.
|
||||||
// This avoids leaking Enterprise tokens to dotcom.
|
// This avoids leaking Enterprise tokens to dotcom.
|
||||||
// We also don't want to send an authorization header if there's already a token provided in the URL.
|
if (codeqlURL.startsWith(`${githubUrl}/`)) {
|
||||||
if (codeqlURL.startsWith(`${apiDetails.url}/`) &&
|
|
||||||
parsedQueryString["token"] === undefined) {
|
|
||||||
logger.debug("Downloading CodeQL bundle with token.");
|
logger.debug("Downloading CodeQL bundle with token.");
|
||||||
headers.authorization = `token ${apiDetails.auth}`;
|
headers.authorization = `token ${githubAuth}`;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
logger.debug("Downloading CodeQL bundle without token.");
|
logger.debug("Downloading CodeQL bundle without token.");
|
||||||
@@ -206,8 +139,8 @@ async function setupCodeQL(codeqlURL, apiDetails, tempDir, toolCacheDir, mode, v
|
|||||||
logger.info(`Downloading CodeQL tools from ${codeqlURL}. This may take a while.`);
|
logger.info(`Downloading CodeQL tools from ${codeqlURL}. This may take a while.`);
|
||||||
const codeqlPath = await toolcacheDownloadTool(codeqlURL, headers, tempDir, logger);
|
const codeqlPath = await toolcacheDownloadTool(codeqlURL, headers, tempDir, logger);
|
||||||
logger.debug(`CodeQL bundle download to ${codeqlPath} complete.`);
|
logger.debug(`CodeQL bundle download to ${codeqlPath} complete.`);
|
||||||
const codeqlExtracted = await toolcache.extractTar(codeqlPath, mode, tempDir, logger);
|
const codeqlExtracted = await toolcache.extractTar(codeqlPath);
|
||||||
codeqlFolder = await toolcache.cacheDir(codeqlExtracted, "CodeQL", codeqlURLSemVer, mode, toolCacheDir, logger);
|
codeqlFolder = await toolcache.cacheDir(codeqlExtracted, "CodeQL", codeqlURLVersion);
|
||||||
}
|
}
|
||||||
let codeqlCmd = path.join(codeqlFolder, "codeql", "codeql");
|
let codeqlCmd = path.join(codeqlFolder, "codeql", "codeql");
|
||||||
if (process.platform === "win32") {
|
if (process.platform === "win32") {
|
||||||
@@ -217,7 +150,7 @@ async function setupCodeQL(codeqlURL, apiDetails, tempDir, toolCacheDir, mode, v
|
|||||||
throw new Error(`Unsupported platform: ${process.platform}`);
|
throw new Error(`Unsupported platform: ${process.platform}`);
|
||||||
}
|
}
|
||||||
cachedCodeQL = getCodeQLForCmd(codeqlCmd);
|
cachedCodeQL = getCodeQLForCmd(codeqlCmd);
|
||||||
return { codeql: cachedCodeQL, toolsVersion: codeqlURLVersion };
|
return cachedCodeQL;
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
logger.error(e);
|
logger.error(e);
|
||||||
@@ -225,26 +158,23 @@ async function setupCodeQL(codeqlURL, apiDetails, tempDir, toolCacheDir, mode, v
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.setupCodeQL = setupCodeQL;
|
exports.setupCodeQL = setupCodeQL;
|
||||||
function getCodeQLURLVersion(url) {
|
function getCodeQLURLVersion(url, logger) {
|
||||||
const match = url.match(/\/codeql-bundle-(.*)\//);
|
const match = url.match(/\/codeql-bundle-(.*)\//);
|
||||||
if (match === null || match.length < 2) {
|
if (match === null || match.length < 2) {
|
||||||
throw new Error(`Malformed tools url: ${url}. Version could not be inferred`);
|
throw new Error(`Malformed tools url: ${url}. Version could not be inferred`);
|
||||||
}
|
}
|
||||||
return match[1];
|
let version = match[1];
|
||||||
}
|
|
||||||
exports.getCodeQLURLVersion = getCodeQLURLVersion;
|
|
||||||
function convertToSemVer(version, logger) {
|
|
||||||
if (!semver.valid(version)) {
|
if (!semver.valid(version)) {
|
||||||
logger.debug(`Bundle version ${version} is not in SemVer format. Will treat it as pre-release 0.0.0-${version}.`);
|
logger.debug(`Bundle version ${version} is not in SemVer format. Will treat it as pre-release 0.0.0-${version}.`);
|
||||||
version = `0.0.0-${version}`;
|
version = `0.0.0-${version}`;
|
||||||
}
|
}
|
||||||
const s = semver.clean(version);
|
const s = semver.clean(version);
|
||||||
if (!s) {
|
if (!s) {
|
||||||
throw new Error(`Bundle version ${version} is not in SemVer format.`);
|
throw new Error(`Malformed tools url ${url}. Version should be in SemVer format but have ${version} instead`);
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
exports.convertToSemVer = convertToSemVer;
|
exports.getCodeQLURLVersion = getCodeQLURLVersion;
|
||||||
/**
|
/**
|
||||||
* Use the CodeQL executable located at the given path.
|
* Use the CodeQL executable located at the given path.
|
||||||
*/
|
*/
|
||||||
@@ -308,16 +238,13 @@ function getCodeQLForCmd(cmd) {
|
|||||||
return cmd;
|
return cmd;
|
||||||
},
|
},
|
||||||
async printVersion() {
|
async printVersion() {
|
||||||
await new toolrunner.ToolRunner(cmd, ["version", "--format=json"]).exec();
|
await new toolrunnner.ToolRunner(cmd, [
|
||||||
|
"version",
|
||||||
|
"--format=json",
|
||||||
|
]).exec();
|
||||||
},
|
},
|
||||||
async getTracerEnv(databasePath) {
|
async getTracerEnv(databasePath) {
|
||||||
// Write tracer-env.js to a temp location.
|
// Write tracer-env.js to a temp location.
|
||||||
// BEWARE: The name and location of this file is recognized by `codeql database
|
|
||||||
// trace-command` in order to enable special support for concatenable tracer
|
|
||||||
// configurations. Consequently the name must not be changed.
|
|
||||||
// (This warning can be removed once a different way to recognize the
|
|
||||||
// action/runner has been implemented in `codeql database trace-command`
|
|
||||||
// _and_ is present in the latest supported CLI release.)
|
|
||||||
const tracerEnvJs = path.resolve(databasePath, "working", "tracer-env.js");
|
const tracerEnvJs = path.resolve(databasePath, "working", "tracer-env.js");
|
||||||
fs.mkdirSync(path.dirname(tracerEnvJs), { recursive: true });
|
fs.mkdirSync(path.dirname(tracerEnvJs), { recursive: true });
|
||||||
fs.writeFileSync(tracerEnvJs, `
|
fs.writeFileSync(tracerEnvJs, `
|
||||||
@@ -332,14 +259,8 @@ function getCodeQLForCmd(cmd) {
|
|||||||
}
|
}
|
||||||
process.stdout.write(process.argv[2]);
|
process.stdout.write(process.argv[2]);
|
||||||
fs.writeFileSync(process.argv[2], JSON.stringify(env), 'utf-8');`);
|
fs.writeFileSync(process.argv[2], JSON.stringify(env), 'utf-8');`);
|
||||||
// BEWARE: The name and location of this file is recognized by `codeql database
|
|
||||||
// trace-command` in order to enable special support for concatenable tracer
|
|
||||||
// configurations. Consequently the name must not be changed.
|
|
||||||
// (This warning can be removed once a different way to recognize the
|
|
||||||
// action/runner has been implemented in `codeql database trace-command`
|
|
||||||
// _and_ is present in the latest supported CLI release.)
|
|
||||||
const envFile = path.resolve(databasePath, "working", "env.tmp");
|
const envFile = path.resolve(databasePath, "working", "env.tmp");
|
||||||
await new toolrunner.ToolRunner(cmd, [
|
await new toolrunnner.ToolRunner(cmd, [
|
||||||
"database",
|
"database",
|
||||||
"trace-command",
|
"trace-command",
|
||||||
databasePath,
|
databasePath,
|
||||||
@@ -351,7 +272,7 @@ function getCodeQLForCmd(cmd) {
|
|||||||
return JSON.parse(fs.readFileSync(envFile, "utf-8"));
|
return JSON.parse(fs.readFileSync(envFile, "utf-8"));
|
||||||
},
|
},
|
||||||
async databaseInit(databasePath, language, sourceRoot) {
|
async databaseInit(databasePath, language, sourceRoot) {
|
||||||
await new toolrunner.ToolRunner(cmd, [
|
await new toolrunnner.ToolRunner(cmd, [
|
||||||
"database",
|
"database",
|
||||||
"init",
|
"init",
|
||||||
databasePath,
|
databasePath,
|
||||||
@@ -374,12 +295,12 @@ function getCodeQLForCmd(cmd) {
|
|||||||
"-Dhttp.keepAlive=false",
|
"-Dhttp.keepAlive=false",
|
||||||
"-Dmaven.wagon.http.pool=false",
|
"-Dmaven.wagon.http.pool=false",
|
||||||
].join(" ");
|
].join(" ");
|
||||||
await new toolrunner.ToolRunner(autobuildCmd).exec();
|
await new toolrunnner.ToolRunner(autobuildCmd).exec();
|
||||||
},
|
},
|
||||||
async extractScannedLanguage(databasePath, language) {
|
async extractScannedLanguage(databasePath, language) {
|
||||||
// Get extractor location
|
// Get extractor location
|
||||||
let extractorPath = "";
|
let extractorPath = "";
|
||||||
await new toolrunner.ToolRunner(cmd, [
|
await new toolrunnner.ToolRunner(cmd, [
|
||||||
"resolve",
|
"resolve",
|
||||||
"extractor",
|
"extractor",
|
||||||
"--format=json",
|
"--format=json",
|
||||||
@@ -409,11 +330,10 @@ function getCodeQLForCmd(cmd) {
|
|||||||
traceCommand,
|
traceCommand,
|
||||||
], error_matcher_1.errorMatchers);
|
], error_matcher_1.errorMatchers);
|
||||||
},
|
},
|
||||||
async finalizeDatabase(databasePath, threadsFlag) {
|
async finalizeDatabase(databasePath) {
|
||||||
await toolrunner_error_catcher_1.toolrunnerErrorCatcher(cmd, [
|
await toolrunner_error_catcher_1.toolrunnerErrorCatcher(cmd, [
|
||||||
"database",
|
"database",
|
||||||
"finalize",
|
"finalize",
|
||||||
threadsFlag,
|
|
||||||
...getExtraOptionsFromEnv(["database", "finalize"]),
|
...getExtraOptionsFromEnv(["database", "finalize"]),
|
||||||
databasePath,
|
databasePath,
|
||||||
], error_matcher_1.errorMatchers);
|
], error_matcher_1.errorMatchers);
|
||||||
@@ -430,7 +350,7 @@ function getCodeQLForCmd(cmd) {
|
|||||||
codeqlArgs.push("--search-path", extraSearchPath);
|
codeqlArgs.push("--search-path", extraSearchPath);
|
||||||
}
|
}
|
||||||
let output = "";
|
let output = "";
|
||||||
await new toolrunner.ToolRunner(cmd, codeqlArgs, {
|
await new toolrunnner.ToolRunner(cmd, codeqlArgs, {
|
||||||
listeners: {
|
listeners: {
|
||||||
stdout: (data) => {
|
stdout: (data) => {
|
||||||
output += data.toString();
|
output += data.toString();
|
||||||
@@ -439,77 +359,63 @@ function getCodeQLForCmd(cmd) {
|
|||||||
}).exec();
|
}).exec();
|
||||||
return JSON.parse(output);
|
return JSON.parse(output);
|
||||||
},
|
},
|
||||||
async databaseAnalyze(databasePath, sarifFile, extraSearchPath, querySuite, memoryFlag, addSnippetsFlag, threadsFlag, automationDetailsId) {
|
async databaseAnalyze(databasePath, sarifFile, querySuite, memoryFlag, addSnippetsFlag, threadsFlag) {
|
||||||
const args = [
|
await new toolrunnner.ToolRunner(cmd, [
|
||||||
"database",
|
"database",
|
||||||
"analyze",
|
"analyze",
|
||||||
memoryFlag,
|
memoryFlag,
|
||||||
threadsFlag,
|
threadsFlag,
|
||||||
databasePath,
|
databasePath,
|
||||||
"--min-disk-free=1024",
|
|
||||||
"--format=sarif-latest",
|
"--format=sarif-latest",
|
||||||
"--sarif-multicause-markdown",
|
|
||||||
`--output=${sarifFile}`,
|
`--output=${sarifFile}`,
|
||||||
addSnippetsFlag,
|
addSnippetsFlag,
|
||||||
// Enable progress verbosity so we log each query as it's interpreted. This aids debugging
|
|
||||||
// when interpretation takes a while for one of the queries being analyzed.
|
|
||||||
"-v",
|
|
||||||
...getExtraOptionsFromEnv(["database", "analyze"]),
|
...getExtraOptionsFromEnv(["database", "analyze"]),
|
||||||
];
|
querySuite,
|
||||||
if (extraSearchPath !== undefined) {
|
]).exec();
|
||||||
args.push("--search-path", extraSearchPath);
|
|
||||||
}
|
|
||||||
if (automationDetailsId !== undefined) {
|
|
||||||
args.push("--sarif-category", automationDetailsId);
|
|
||||||
}
|
|
||||||
args.push(querySuite);
|
|
||||||
await new toolrunner.ToolRunner(cmd, args).exec();
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Gets the options for `path` of `options` as an array of extra option strings.
|
* Gets the options for `path` of `options` as an array of extra option strings.
|
||||||
*/
|
*/
|
||||||
function getExtraOptionsFromEnv(paths) {
|
function getExtraOptionsFromEnv(path) {
|
||||||
const options = util.getExtraOptionsEnvParam();
|
const options = util.getExtraOptionsEnvParam();
|
||||||
return getExtraOptions(options, paths, []);
|
return getExtraOptions(options, path, []);
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Gets `options` as an array of extra option strings.
|
|
||||||
*
|
|
||||||
* - throws an exception mentioning `pathInfo` if this conversion is impossible.
|
|
||||||
*/
|
|
||||||
function asExtraOptions(options, pathInfo) {
|
|
||||||
if (options === undefined) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
if (!Array.isArray(options)) {
|
|
||||||
const msg = `The extra options for '${pathInfo.join(".")}' ('${JSON.stringify(options)}') are not in an array.`;
|
|
||||||
throw new Error(msg);
|
|
||||||
}
|
|
||||||
return options.map((o) => {
|
|
||||||
const t = typeof o;
|
|
||||||
if (t !== "string" && t !== "number" && t !== "boolean") {
|
|
||||||
const msg = `The extra option for '${pathInfo.join(".")}' ('${JSON.stringify(o)}') is not a primitive value.`;
|
|
||||||
throw new Error(msg);
|
|
||||||
}
|
|
||||||
return `${o}`;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Gets the options for `path` of `options` as an array of extra option strings.
|
* Gets the options for `path` of `options` as an array of extra option strings.
|
||||||
*
|
*
|
||||||
* - the special terminal step name '*' in `options` matches all path steps
|
* - the special terminal step name '*' in `options` matches all path steps
|
||||||
* - throws an exception if this conversion is impossible.
|
* - throws an exception if this conversion is impossible.
|
||||||
*
|
|
||||||
* Exported for testing.
|
|
||||||
*/
|
*/
|
||||||
function getExtraOptions(options, paths, pathInfo) {
|
function getExtraOptions(options, path, pathInfo) {
|
||||||
var _a, _b, _c;
|
var _a, _b, _c;
|
||||||
|
/**
|
||||||
|
* Gets `options` as an array of extra option strings.
|
||||||
|
*
|
||||||
|
* - throws an exception mentioning `pathInfo` if this conversion is impossible.
|
||||||
|
*/
|
||||||
|
function asExtraOptions(options, pathInfo) {
|
||||||
|
if (options === undefined) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
if (!Array.isArray(options)) {
|
||||||
|
const msg = `The extra options for '${pathInfo.join(".")}' ('${JSON.stringify(options)}') are not in an array.`;
|
||||||
|
throw new Error(msg);
|
||||||
|
}
|
||||||
|
return options.map((o) => {
|
||||||
|
const t = typeof o;
|
||||||
|
if (t !== "string" && t !== "number" && t !== "boolean") {
|
||||||
|
const msg = `The extra option for '${pathInfo.join(".")}' ('${JSON.stringify(o)}') is not a primitive value.`;
|
||||||
|
throw new Error(msg);
|
||||||
|
}
|
||||||
|
return `${o}`;
|
||||||
|
});
|
||||||
|
}
|
||||||
const all = asExtraOptions((_a = options) === null || _a === void 0 ? void 0 : _a["*"], pathInfo.concat("*"));
|
const all = asExtraOptions((_a = options) === null || _a === void 0 ? void 0 : _a["*"], pathInfo.concat("*"));
|
||||||
const specific = paths.length === 0
|
const specific = path.length === 0
|
||||||
? asExtraOptions(options, pathInfo)
|
? asExtraOptions(options, pathInfo)
|
||||||
: getExtraOptions((_b = options) === null || _b === void 0 ? void 0 : _b[paths[0]], (_c = paths) === null || _c === void 0 ? void 0 : _c.slice(1), pathInfo.concat(paths[0]));
|
: getExtraOptions((_b = options) === null || _b === void 0 ? void 0 : _b[path[0]], (_c = path) === null || _c === void 0 ? void 0 : _c.slice(1), pathInfo.concat(path[0]));
|
||||||
return all.concat(specific);
|
return all.concat(specific);
|
||||||
}
|
}
|
||||||
exports.getExtraOptions = getExtraOptions;
|
exports.getExtraOptions = getExtraOptions;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
118
lib/codeql.test.js
generated
118
lib/codeql.test.js
generated
@@ -10,142 +10,31 @@ 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 });
|
||||||
const path = __importStar(require("path"));
|
|
||||||
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 path = __importStar(require("path"));
|
||||||
const codeql = __importStar(require("./codeql"));
|
const codeql = __importStar(require("./codeql"));
|
||||||
const defaults = __importStar(require("./defaults.json"));
|
|
||||||
const logging_1 = require("./logging");
|
const logging_1 = require("./logging");
|
||||||
const testing_utils_1 = require("./testing-utils");
|
const testing_utils_1 = require("./testing-utils");
|
||||||
const util = __importStar(require("./util"));
|
const util = __importStar(require("./util"));
|
||||||
testing_utils_1.setupTests(ava_1.default);
|
testing_utils_1.setupTests(ava_1.default);
|
||||||
const sampleApiDetails = {
|
|
||||||
auth: "token",
|
|
||||||
url: "https://github.com",
|
|
||||||
};
|
|
||||||
const sampleGHAEApiDetails = {
|
|
||||||
auth: "token",
|
|
||||||
url: "https://example.githubenterprise.com",
|
|
||||||
};
|
|
||||||
ava_1.default("download codeql bundle cache", async (t) => {
|
ava_1.default("download codeql bundle cache", async (t) => {
|
||||||
await util.withTmpDir(async (tmpDir) => {
|
await util.withTmpDir(async (tmpDir) => {
|
||||||
testing_utils_1.setupActionsVars(tmpDir, tmpDir);
|
|
||||||
const versions = ["20200601", "20200610"];
|
const versions = ["20200601", "20200610"];
|
||||||
for (let i = 0; i < versions.length; i++) {
|
for (let i = 0; i < versions.length; i++) {
|
||||||
const version = versions[i];
|
const version = versions[i];
|
||||||
nock_1.default("https://example.com")
|
nock_1.default("https://example.com")
|
||||||
.get(`/download/codeql-bundle-${version}/codeql-bundle.tar.gz`)
|
.get(`/download/codeql-bundle-${version}/codeql-bundle.tar.gz`)
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
||||||
await codeql.setupCodeQL(`https://example.com/download/codeql-bundle-${version}/codeql-bundle.tar.gz`, sampleApiDetails, tmpDir, tmpDir, "runner", util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
|
await codeql.setupCodeQL(`https://example.com/download/codeql-bundle-${version}/codeql-bundle.tar.gz`, "token", "https://github.example.com", tmpDir, tmpDir, "runner", logging_1.getRunnerLogger(true));
|
||||||
t.assert(toolcache.find("CodeQL", `0.0.0-${version}`));
|
t.assert(toolcache.find("CodeQL", `0.0.0-${version}`));
|
||||||
}
|
}
|
||||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||||
t.is(cachedVersions.length, 2);
|
t.is(cachedVersions.length, 2);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("download codeql bundle cache explicitly requested with pinned different version cached", async (t) => {
|
|
||||||
await util.withTmpDir(async (tmpDir) => {
|
|
||||||
testing_utils_1.setupActionsVars(tmpDir, tmpDir);
|
|
||||||
nock_1.default("https://example.com")
|
|
||||||
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
|
|
||||||
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, "runner", util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
|
|
||||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
|
||||||
nock_1.default("https://example.com")
|
|
||||||
.get(`/download/codeql-bundle-20200610/codeql-bundle.tar.gz`)
|
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
|
||||||
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200610/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, "runner", util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
|
|
||||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200610"));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
ava_1.default("don't download codeql bundle cache with pinned different version cached", async (t) => {
|
|
||||||
await util.withTmpDir(async (tmpDir) => {
|
|
||||||
testing_utils_1.setupActionsVars(tmpDir, tmpDir);
|
|
||||||
nock_1.default("https://example.com")
|
|
||||||
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
|
|
||||||
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, "runner", util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
|
|
||||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
|
||||||
await codeql.setupCodeQL(undefined, sampleApiDetails, tmpDir, tmpDir, "runner", util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
|
|
||||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
|
||||||
t.is(cachedVersions.length, 1);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
ava_1.default("download codeql bundle cache with different version cached (not pinned)", async (t) => {
|
|
||||||
await util.withTmpDir(async (tmpDir) => {
|
|
||||||
testing_utils_1.setupActionsVars(tmpDir, tmpDir);
|
|
||||||
nock_1.default("https://example.com")
|
|
||||||
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
|
||||||
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, "runner", util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
|
|
||||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
|
||||||
const platform = process.platform === "win32"
|
|
||||||
? "win64"
|
|
||||||
: process.platform === "linux"
|
|
||||||
? "linux64"
|
|
||||||
: "osx64";
|
|
||||||
nock_1.default("https://github.com")
|
|
||||||
.get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/codeql-bundle-${platform}.tar.gz`)
|
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
|
||||||
await codeql.setupCodeQL(undefined, sampleApiDetails, tmpDir, tmpDir, "runner", util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
|
|
||||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
|
||||||
t.is(cachedVersions.length, 2);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
ava_1.default('download codeql bundle cache with pinned different version cached if "latest" tools specified', async (t) => {
|
|
||||||
await util.withTmpDir(async (tmpDir) => {
|
|
||||||
testing_utils_1.setupActionsVars(tmpDir, tmpDir);
|
|
||||||
nock_1.default("https://example.com")
|
|
||||||
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
|
|
||||||
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, "runner", util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
|
|
||||||
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
|
||||||
const platform = process.platform === "win32"
|
|
||||||
? "win64"
|
|
||||||
: process.platform === "linux"
|
|
||||||
? "linux64"
|
|
||||||
: "osx64";
|
|
||||||
nock_1.default("https://github.com")
|
|
||||||
.get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/codeql-bundle-${platform}.tar.gz`)
|
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle.tar.gz`));
|
|
||||||
await codeql.setupCodeQL("latest", sampleApiDetails, tmpDir, tmpDir, "runner", util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
|
|
||||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
|
||||||
t.is(cachedVersions.length, 2);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
ava_1.default("download codeql bundle from github ae endpoint", async (t) => {
|
|
||||||
await util.withTmpDir(async (tmpDir) => {
|
|
||||||
testing_utils_1.setupActionsVars(tmpDir, tmpDir);
|
|
||||||
const bundleAssetID = 10;
|
|
||||||
const platform = process.platform === "win32"
|
|
||||||
? "win64"
|
|
||||||
: process.platform === "linux"
|
|
||||||
? "linux64"
|
|
||||||
: "osx64";
|
|
||||||
const codeQLBundleName = `codeql-bundle-${platform}.tar.gz`;
|
|
||||||
nock_1.default("https://example.githubenterprise.com")
|
|
||||||
.get(`/api/v3/enterprise/code-scanning/codeql-bundle/find/${defaults.bundleVersion}`)
|
|
||||||
.reply(200, {
|
|
||||||
assets: { [codeQLBundleName]: bundleAssetID },
|
|
||||||
});
|
|
||||||
nock_1.default("https://example.githubenterprise.com")
|
|
||||||
.get(`/api/v3/enterprise/code-scanning/codeql-bundle/download/${bundleAssetID}`)
|
|
||||||
.reply(200, {
|
|
||||||
url: `https://example.githubenterprise.com/github/codeql-action/releases/download/${defaults.bundleVersion}/${codeQLBundleName}`,
|
|
||||||
});
|
|
||||||
nock_1.default("https://example.githubenterprise.com")
|
|
||||||
.get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/${codeQLBundleName}`)
|
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
|
|
||||||
await codeql.setupCodeQL(undefined, sampleGHAEApiDetails, tmpDir, tmpDir, "runner", util.GitHubVariant.GHAE, logging_1.getRunnerLogger(true));
|
|
||||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
|
||||||
t.is(cachedVersions.length, 1);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
ava_1.default("parse codeql bundle url version", (t) => {
|
ava_1.default("parse codeql bundle url version", (t) => {
|
||||||
t.deepEqual(codeql.getCodeQLURLVersion("https://github.com/.../codeql-bundle-20200601/..."), "20200601");
|
|
||||||
});
|
|
||||||
ava_1.default("convert to semver", (t) => {
|
|
||||||
const tests = {
|
const tests = {
|
||||||
"20200601": "0.0.0-20200601",
|
"20200601": "0.0.0-20200601",
|
||||||
"20200601.0": "0.0.0-20200601.0",
|
"20200601.0": "0.0.0-20200601.0",
|
||||||
@@ -155,8 +44,9 @@ ava_1.default("convert to semver", (t) => {
|
|||||||
"1.2.3-beta.1": "1.2.3-beta.1",
|
"1.2.3-beta.1": "1.2.3-beta.1",
|
||||||
};
|
};
|
||||||
for (const [version, expectedVersion] of Object.entries(tests)) {
|
for (const [version, expectedVersion] of Object.entries(tests)) {
|
||||||
|
const url = `https://github.com/.../codeql-bundle-${version}/...`;
|
||||||
try {
|
try {
|
||||||
const parsedVersion = codeql.convertToSemVer(version, logging_1.getRunnerLogger(true));
|
const parsedVersion = codeql.getCodeQLURLVersion(url, logging_1.getRunnerLogger(true));
|
||||||
t.deepEqual(parsedVersion, expectedVersion);
|
t.deepEqual(parsedVersion, expectedVersion);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
95
lib/config-utils.js
generated
95
lib/config-utils.js
generated
@@ -8,8 +8,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const path = __importStar(require("path"));
|
|
||||||
const yaml = __importStar(require("js-yaml"));
|
const yaml = __importStar(require("js-yaml"));
|
||||||
|
const path = __importStar(require("path"));
|
||||||
const api = __importStar(require("./api-client"));
|
const api = __importStar(require("./api-client"));
|
||||||
const externalQueries = __importStar(require("./external-queries"));
|
const externalQueries = __importStar(require("./external-queries"));
|
||||||
const languages_1 = require("./languages");
|
const languages_1 = require("./languages");
|
||||||
@@ -78,10 +78,7 @@ async function runResolveQueries(codeQL, resultMap, toResolve, extraSearchPath)
|
|||||||
}
|
}
|
||||||
const queries = Object.keys(queryPaths).filter((q) => !queryIsDisabled(language, q));
|
const queries = Object.keys(queryPaths).filter((q) => !queryIsDisabled(language, q));
|
||||||
if (extraSearchPath !== undefined) {
|
if (extraSearchPath !== undefined) {
|
||||||
resultMap[language].custom.push({
|
resultMap[language].custom.push(...queries);
|
||||||
searchPath: extraSearchPath,
|
|
||||||
queries,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
resultMap[language].builtin.push(...queries);
|
resultMap[language].builtin.push(...queries);
|
||||||
@@ -102,8 +99,8 @@ const builtinSuites = ["security-extended", "security-and-quality"];
|
|||||||
* Throws an error if suiteName is not a valid builtin suite.
|
* Throws an error if suiteName is not a valid builtin suite.
|
||||||
*/
|
*/
|
||||||
async function addBuiltinSuiteQueries(languages, codeQL, resultMap, suiteName, configFile) {
|
async function addBuiltinSuiteQueries(languages, codeQL, resultMap, suiteName, configFile) {
|
||||||
const found = builtinSuites.find((suite) => suite === suiteName);
|
const suite = builtinSuites.find((suite) => suite === suiteName);
|
||||||
if (!found) {
|
if (!suite) {
|
||||||
throw new Error(getQueryUsesInvalid(configFile, suiteName));
|
throw new Error(getQueryUsesInvalid(configFile, suiteName));
|
||||||
}
|
}
|
||||||
const suites = languages.map((l) => `${l}-${suiteName}.qls`);
|
const suites = languages.map((l) => `${l}-${suiteName}.qls`);
|
||||||
@@ -131,7 +128,7 @@ async function addLocalQueries(codeQL, resultMap, localQueryPath, checkoutPath,
|
|||||||
/**
|
/**
|
||||||
* Retrieve the set of queries at the referenced remote repo and add them to resultMap.
|
* Retrieve the set of queries at the referenced remote repo and add them to resultMap.
|
||||||
*/
|
*/
|
||||||
async function addRemoteQueries(codeQL, resultMap, queryUses, tempDir, apiDetails, logger, configFile) {
|
async function addRemoteQueries(codeQL, resultMap, queryUses, tempDir, githubUrl, logger, configFile) {
|
||||||
let tok = queryUses.split("@");
|
let tok = queryUses.split("@");
|
||||||
if (tok.length !== 2) {
|
if (tok.length !== 2) {
|
||||||
throw new Error(getQueryUsesInvalid(configFile, queryUses));
|
throw new Error(getQueryUsesInvalid(configFile, queryUses));
|
||||||
@@ -150,7 +147,7 @@ async function addRemoteQueries(codeQL, resultMap, queryUses, tempDir, apiDetail
|
|||||||
}
|
}
|
||||||
const nwo = `${tok[0]}/${tok[1]}`;
|
const nwo = `${tok[0]}/${tok[1]}`;
|
||||||
// Checkout the external repository
|
// Checkout the external repository
|
||||||
const checkoutPath = await externalQueries.checkoutExternalRepository(nwo, ref, apiDetails, tempDir, logger);
|
const checkoutPath = await externalQueries.checkoutExternalRepository(nwo, ref, githubUrl, tempDir, logger);
|
||||||
const queryPath = tok.length > 2
|
const queryPath = tok.length > 2
|
||||||
? path.join(checkoutPath, tok.slice(2).join("/"))
|
? path.join(checkoutPath, tok.slice(2).join("/"))
|
||||||
: checkoutPath;
|
: checkoutPath;
|
||||||
@@ -164,7 +161,7 @@ async function addRemoteQueries(codeQL, resultMap, queryUses, tempDir, apiDetail
|
|||||||
* local paths starting with './', or references to remote repos, or
|
* local paths starting with './', or references to remote repos, or
|
||||||
* a finite set of hardcoded terms for builtin suites.
|
* a finite set of hardcoded terms for builtin suites.
|
||||||
*/
|
*/
|
||||||
async function parseQueryUses(languages, codeQL, resultMap, queryUses, tempDir, checkoutPath, apiDetails, logger, configFile) {
|
async function parseQueryUses(languages, codeQL, resultMap, queryUses, tempDir, checkoutPath, githubUrl, logger, configFile) {
|
||||||
queryUses = queryUses.trim();
|
queryUses = queryUses.trim();
|
||||||
if (queryUses === "") {
|
if (queryUses === "") {
|
||||||
throw new Error(getQueryUsesInvalid(configFile));
|
throw new Error(getQueryUsesInvalid(configFile));
|
||||||
@@ -180,7 +177,7 @@ async function parseQueryUses(languages, codeQL, resultMap, queryUses, tempDir,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Otherwise, must be a reference to another repo
|
// Otherwise, must be a reference to another repo
|
||||||
await addRemoteQueries(codeQL, resultMap, queryUses, tempDir, apiDetails, logger, configFile);
|
await addRemoteQueries(codeQL, resultMap, queryUses, tempDir, githubUrl, logger, configFile);
|
||||||
}
|
}
|
||||||
// Regex validating stars in paths or paths-ignore entries.
|
// Regex validating stars in paths or paths-ignore entries.
|
||||||
// The intention is to only allow ** to appear when immediately
|
// The intention is to only allow ** to appear when immediately
|
||||||
@@ -188,44 +185,44 @@ async function parseQueryUses(languages, codeQL, resultMap, queryUses, tempDir,
|
|||||||
const pathStarsRegex = /.*(?:\*\*[^/].*|\*\*$|[^/]\*\*.*)/;
|
const pathStarsRegex = /.*(?:\*\*[^/].*|\*\*$|[^/]\*\*.*)/;
|
||||||
// Characters that are supported by filters in workflows, but not by us.
|
// Characters that are supported by filters in workflows, but not by us.
|
||||||
// See https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
|
// See https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
|
||||||
const filterPatternCharactersRegex = /.*[?+[\]!].*/;
|
const filterPatternCharactersRegex = /.*[\?\+\[\]!].*/;
|
||||||
// Checks that a paths of paths-ignore entry is valid, possibly modifying it
|
// Checks that a paths of paths-ignore entry is valid, possibly modifying it
|
||||||
// to make it valid, or if not possible then throws an error.
|
// to make it valid, or if not possible then throws an error.
|
||||||
function validateAndSanitisePath(originalPath, propertyName, configFile, logger) {
|
function validateAndSanitisePath(originalPath, propertyName, configFile, logger) {
|
||||||
// Take a copy so we don't modify the original path, so we can still construct error messages
|
// Take a copy so we don't modify the original path, so we can still construct error messages
|
||||||
let newPath = originalPath;
|
let path = originalPath;
|
||||||
// All paths are relative to the src root, so strip off leading slashes.
|
// All paths are relative to the src root, so strip off leading slashes.
|
||||||
while (newPath.charAt(0) === "/") {
|
while (path.charAt(0) === "/") {
|
||||||
newPath = newPath.substring(1);
|
path = path.substring(1);
|
||||||
}
|
}
|
||||||
// Trailing ** are redundant, so strip them off
|
// Trailing ** are redundant, so strip them off
|
||||||
if (newPath.endsWith("/**")) {
|
if (path.endsWith("/**")) {
|
||||||
newPath = newPath.substring(0, newPath.length - 2);
|
path = path.substring(0, path.length - 2);
|
||||||
}
|
}
|
||||||
// An empty path is not allowed as it's meaningless
|
// An empty path is not allowed as it's meaningless
|
||||||
if (newPath === "") {
|
if (path === "") {
|
||||||
throw new Error(getConfigFilePropertyError(configFile, propertyName, `"${originalPath}" is not an invalid path. ` +
|
throw new Error(getConfigFilePropertyError(configFile, propertyName, `"${originalPath}" is not an invalid path. ` +
|
||||||
`It is not necessary to include it, and it is not allowed to exclude it.`));
|
`It is not necessary to include it, and it is not allowed to exclude it.`));
|
||||||
}
|
}
|
||||||
// Check for illegal uses of **
|
// Check for illegal uses of **
|
||||||
if (newPath.match(pathStarsRegex)) {
|
if (path.match(pathStarsRegex)) {
|
||||||
throw new Error(getConfigFilePropertyError(configFile, propertyName, `"${originalPath}" contains an invalid "**" wildcard. ` +
|
throw new Error(getConfigFilePropertyError(configFile, propertyName, `"${originalPath}" contains an invalid "**" wildcard. ` +
|
||||||
`They must be immediately preceded and followed by a slash as in "/**/", or come at the start or end.`));
|
`They must be immediately preceeded and followed by a slash as in "/**/", or come at the start or end.`));
|
||||||
}
|
}
|
||||||
// Check for other regex characters that we don't support.
|
// Check for other regex characters that we don't support.
|
||||||
// Output a warning so the user knows, but otherwise continue normally.
|
// Output a warning so the user knows, but otherwise continue normally.
|
||||||
if (newPath.match(filterPatternCharactersRegex)) {
|
if (path.match(filterPatternCharactersRegex)) {
|
||||||
logger.warning(getConfigFilePropertyError(configFile, propertyName, `"${originalPath}" contains an unsupported character. ` +
|
logger.warning(getConfigFilePropertyError(configFile, propertyName, `"${originalPath}" contains an unsupported character. ` +
|
||||||
`The filter pattern characters ?, +, [, ], ! are not supported and will be matched literally.`));
|
`The filter pattern characters ?, +, [, ], ! are not supported and will be matched literally.`));
|
||||||
}
|
}
|
||||||
// Ban any uses of backslash for now.
|
// Ban any uses of backslash for now.
|
||||||
// This may not play nicely with project layouts.
|
// This may not play nicely with project layouts.
|
||||||
// This restriction can be lifted later if we determine they are ok.
|
// This restriction can be lifted later if we determine they are ok.
|
||||||
if (newPath.indexOf("\\") !== -1) {
|
if (path.indexOf("\\") !== -1) {
|
||||||
throw new Error(getConfigFilePropertyError(configFile, propertyName, `"${originalPath}" contains an "\\" character. These are not allowed in filters. ` +
|
throw new Error(getConfigFilePropertyError(configFile, propertyName, `"${originalPath}" contains an "\\" character. These are not allowed in filters. ` +
|
||||||
`If running on windows we recommend using "/" instead for path filters.`));
|
`If running on windows we recommend using "/" instead for path filters.`));
|
||||||
}
|
}
|
||||||
return newPath;
|
return path;
|
||||||
}
|
}
|
||||||
exports.validateAndSanitisePath = validateAndSanitisePath;
|
exports.validateAndSanitisePath = validateAndSanitisePath;
|
||||||
// An undefined configFile in some of these functions indicates that
|
// An undefined configFile in some of these functions indicates that
|
||||||
@@ -304,10 +301,10 @@ exports.getUnknownLanguagesError = getUnknownLanguagesError;
|
|||||||
/**
|
/**
|
||||||
* Gets the set of languages in the current repository
|
* Gets the set of languages in the current repository
|
||||||
*/
|
*/
|
||||||
async function getLanguagesInRepo(repository, apiDetails, logger) {
|
async function getLanguagesInRepo(repository, githubAuth, githubUrl, logger) {
|
||||||
logger.debug(`GitHub repo ${repository.owner} ${repository.repo}`);
|
logger.debug(`GitHub repo ${repository.owner} ${repository.repo}`);
|
||||||
const response = await api
|
const response = await api
|
||||||
.getApiClient(apiDetails, { allowLocalRun: true })
|
.getApiClient(githubAuth, githubUrl, true)
|
||||||
.repos.listLanguages({
|
.repos.listLanguages({
|
||||||
owner: repository.owner,
|
owner: repository.owner,
|
||||||
repo: repository.repo,
|
repo: repository.repo,
|
||||||
@@ -336,7 +333,7 @@ async function getLanguagesInRepo(repository, apiDetails, logger) {
|
|||||||
* If no languages could be detected from either the workflow or the repository
|
* If no languages could be detected from either the workflow or the repository
|
||||||
* then throw an error.
|
* then throw an error.
|
||||||
*/
|
*/
|
||||||
async function getLanguages(languagesInput, repository, apiDetails, logger) {
|
async function getLanguages(languagesInput, repository, githubAuth, githubUrl, logger) {
|
||||||
// Obtain from action input 'languages' if set
|
// Obtain from action input 'languages' if set
|
||||||
let languages = (languagesInput || "")
|
let languages = (languagesInput || "")
|
||||||
.split(",")
|
.split(",")
|
||||||
@@ -345,7 +342,7 @@ async function getLanguages(languagesInput, repository, apiDetails, logger) {
|
|||||||
logger.info(`Languages from configuration: ${JSON.stringify(languages)}`);
|
logger.info(`Languages from configuration: ${JSON.stringify(languages)}`);
|
||||||
if (languages.length === 0) {
|
if (languages.length === 0) {
|
||||||
// Obtain languages as all languages in the repo that can be analysed
|
// Obtain languages as all languages in the repo that can be analysed
|
||||||
languages = await getLanguagesInRepo(repository, apiDetails, logger);
|
languages = await getLanguagesInRepo(repository, githubAuth, githubUrl, logger);
|
||||||
logger.info(`Automatically detected languages: ${JSON.stringify(languages)}`);
|
logger.info(`Automatically detected languages: ${JSON.stringify(languages)}`);
|
||||||
}
|
}
|
||||||
// If the languages parameter was not given and no languages were
|
// If the languages parameter was not given and no languages were
|
||||||
@@ -370,12 +367,12 @@ async function getLanguages(languagesInput, repository, apiDetails, logger) {
|
|||||||
}
|
}
|
||||||
return parsedLanguages;
|
return parsedLanguages;
|
||||||
}
|
}
|
||||||
async function addQueriesFromWorkflow(codeQL, queriesInput, languages, resultMap, tempDir, checkoutPath, apiDetails, logger) {
|
async function addQueriesFromWorkflow(codeQL, queriesInput, languages, resultMap, tempDir, checkoutPath, githubUrl, logger) {
|
||||||
queriesInput = queriesInput.trim();
|
queriesInput = queriesInput.trim();
|
||||||
// "+" means "don't override config file" - see shouldAddConfigFileQueries
|
// "+" means "don't override config file" - see shouldAddConfigFileQueries
|
||||||
queriesInput = queriesInput.replace(/^\+/, "");
|
queriesInput = queriesInput.replace(/^\+/, "");
|
||||||
for (const query of queriesInput.split(",")) {
|
for (const query of queriesInput.split(",")) {
|
||||||
await parseQueryUses(languages, codeQL, resultMap, query, tempDir, checkoutPath, apiDetails, logger);
|
await parseQueryUses(languages, codeQL, resultMap, query, tempDir, checkoutPath, githubUrl, logger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Returns true if either no queries were provided in the workflow.
|
// Returns true if either no queries were provided in the workflow.
|
||||||
@@ -391,12 +388,12 @@ 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, repository, tempDir, toolCacheDir, codeQL, checkoutPath, gitHubVersion, apiDetails, logger) {
|
async function getDefaultConfig(languagesInput, queriesInput, repository, tempDir, toolCacheDir, codeQL, checkoutPath, githubAuth, githubUrl, logger) {
|
||||||
const languages = await getLanguages(languagesInput, repository, apiDetails, logger);
|
const languages = await getLanguages(languagesInput, repository, githubAuth, githubUrl, logger);
|
||||||
const queries = {};
|
const queries = {};
|
||||||
await addDefaultQueries(codeQL, languages, queries);
|
await addDefaultQueries(codeQL, languages, queries);
|
||||||
if (queriesInput) {
|
if (queriesInput) {
|
||||||
await addQueriesFromWorkflow(codeQL, queriesInput, languages, queries, tempDir, checkoutPath, apiDetails, logger);
|
await addQueriesFromWorkflow(codeQL, queriesInput, languages, queries, tempDir, checkoutPath, githubUrl, logger);
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
languages,
|
languages,
|
||||||
@@ -407,14 +404,13 @@ async function getDefaultConfig(languagesInput, queriesInput, repository, tempDi
|
|||||||
tempDir,
|
tempDir,
|
||||||
toolCacheDir,
|
toolCacheDir,
|
||||||
codeQLCmd: codeQL.getPath(),
|
codeQLCmd: codeQL.getPath(),
|
||||||
gitHubVersion,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
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, configFile, repository, tempDir, toolCacheDir, codeQL, checkoutPath, gitHubVersion, apiDetails, logger) {
|
async function loadConfig(languagesInput, queriesInput, configFile, repository, tempDir, toolCacheDir, codeQL, checkoutPath, githubAuth, githubUrl, logger) {
|
||||||
let parsedYAML;
|
let parsedYAML;
|
||||||
if (isLocal(configFile)) {
|
if (isLocal(configFile)) {
|
||||||
// Treat the config file as relative to the workspace
|
// Treat the config file as relative to the workspace
|
||||||
@@ -422,7 +418,7 @@ async function loadConfig(languagesInput, queriesInput, configFile, repository,
|
|||||||
parsedYAML = getLocalConfig(configFile, checkoutPath);
|
parsedYAML = getLocalConfig(configFile, checkoutPath);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
parsedYAML = await getRemoteConfig(configFile, apiDetails);
|
parsedYAML = await getRemoteConfig(configFile, githubAuth, githubUrl);
|
||||||
}
|
}
|
||||||
// Validate that the 'name' property is syntactically correct,
|
// Validate that the 'name' property is syntactically correct,
|
||||||
// even though we don't use the value yet.
|
// even though we don't use the value yet.
|
||||||
@@ -434,7 +430,7 @@ async function loadConfig(languagesInput, queriesInput, configFile, repository,
|
|||||||
throw new Error(getNameInvalid(configFile));
|
throw new Error(getNameInvalid(configFile));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const languages = await getLanguages(languagesInput, repository, apiDetails, logger);
|
const languages = await getLanguages(languagesInput, repository, githubAuth, githubUrl, logger);
|
||||||
const queries = {};
|
const queries = {};
|
||||||
const pathsIgnore = [];
|
const pathsIgnore = [];
|
||||||
const paths = [];
|
const paths = [];
|
||||||
@@ -453,7 +449,7 @@ async function loadConfig(languagesInput, queriesInput, configFile, repository,
|
|||||||
// unless they're prefixed with "+", in which case they supplement those
|
// unless they're prefixed with "+", in which case they supplement those
|
||||||
// in the config file.
|
// in the config file.
|
||||||
if (queriesInput) {
|
if (queriesInput) {
|
||||||
await addQueriesFromWorkflow(codeQL, queriesInput, languages, queries, tempDir, checkoutPath, apiDetails, logger);
|
await addQueriesFromWorkflow(codeQL, queriesInput, languages, queries, tempDir, checkoutPath, githubUrl, logger);
|
||||||
}
|
}
|
||||||
if (shouldAddConfigFileQueries(queriesInput) &&
|
if (shouldAddConfigFileQueries(queriesInput) &&
|
||||||
QUERIES_PROPERTY in parsedYAML) {
|
QUERIES_PROPERTY in parsedYAML) {
|
||||||
@@ -465,29 +461,29 @@ async function loadConfig(languagesInput, queriesInput, configFile, repository,
|
|||||||
typeof query[QUERIES_USES_PROPERTY] !== "string") {
|
typeof query[QUERIES_USES_PROPERTY] !== "string") {
|
||||||
throw new Error(getQueryUsesInvalid(configFile));
|
throw new Error(getQueryUsesInvalid(configFile));
|
||||||
}
|
}
|
||||||
await parseQueryUses(languages, codeQL, queries, query[QUERIES_USES_PROPERTY], tempDir, checkoutPath, apiDetails, logger, configFile);
|
await parseQueryUses(languages, codeQL, queries, query[QUERIES_USES_PROPERTY], tempDir, checkoutPath, githubUrl, logger, configFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (PATHS_IGNORE_PROPERTY in parsedYAML) {
|
if (PATHS_IGNORE_PROPERTY in parsedYAML) {
|
||||||
if (!(parsedYAML[PATHS_IGNORE_PROPERTY] instanceof Array)) {
|
if (!(parsedYAML[PATHS_IGNORE_PROPERTY] instanceof Array)) {
|
||||||
throw new Error(getPathsIgnoreInvalid(configFile));
|
throw new Error(getPathsIgnoreInvalid(configFile));
|
||||||
}
|
}
|
||||||
for (const ignorePath of parsedYAML[PATHS_IGNORE_PROPERTY]) {
|
for (const path of parsedYAML[PATHS_IGNORE_PROPERTY]) {
|
||||||
if (typeof ignorePath !== "string" || ignorePath === "") {
|
if (typeof path !== "string" || path === "") {
|
||||||
throw new Error(getPathsIgnoreInvalid(configFile));
|
throw new Error(getPathsIgnoreInvalid(configFile));
|
||||||
}
|
}
|
||||||
pathsIgnore.push(validateAndSanitisePath(ignorePath, PATHS_IGNORE_PROPERTY, configFile, logger));
|
pathsIgnore.push(validateAndSanitisePath(path, PATHS_IGNORE_PROPERTY, configFile, logger));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (PATHS_PROPERTY in parsedYAML) {
|
if (PATHS_PROPERTY in parsedYAML) {
|
||||||
if (!(parsedYAML[PATHS_PROPERTY] instanceof Array)) {
|
if (!(parsedYAML[PATHS_PROPERTY] instanceof Array)) {
|
||||||
throw new Error(getPathsInvalid(configFile));
|
throw new Error(getPathsInvalid(configFile));
|
||||||
}
|
}
|
||||||
for (const includePath of parsedYAML[PATHS_PROPERTY]) {
|
for (const path of parsedYAML[PATHS_PROPERTY]) {
|
||||||
if (typeof includePath !== "string" || includePath === "") {
|
if (typeof path !== "string" || path === "") {
|
||||||
throw new Error(getPathsInvalid(configFile));
|
throw new Error(getPathsInvalid(configFile));
|
||||||
}
|
}
|
||||||
paths.push(validateAndSanitisePath(includePath, PATHS_PROPERTY, configFile, logger));
|
paths.push(validateAndSanitisePath(path, PATHS_PROPERTY, configFile, 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
|
||||||
@@ -509,7 +505,6 @@ async function loadConfig(languagesInput, queriesInput, configFile, repository,
|
|||||||
tempDir,
|
tempDir,
|
||||||
toolCacheDir,
|
toolCacheDir,
|
||||||
codeQLCmd: codeQL.getPath(),
|
codeQLCmd: codeQL.getPath(),
|
||||||
gitHubVersion,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -518,15 +513,15 @@ async function loadConfig(languagesInput, queriesInput, configFile, repository,
|
|||||||
* 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, configFile, repository, tempDir, toolCacheDir, codeQL, checkoutPath, gitHubVersion, apiDetails, logger) {
|
async function initConfig(languagesInput, queriesInput, configFile, repository, tempDir, toolCacheDir, codeQL, checkoutPath, githubAuth, githubUrl, logger) {
|
||||||
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, repository, tempDir, toolCacheDir, codeQL, checkoutPath, gitHubVersion, apiDetails, logger);
|
config = await getDefaultConfig(languagesInput, queriesInput, repository, tempDir, toolCacheDir, codeQL, checkoutPath, githubAuth, githubUrl, logger);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
config = await loadConfig(languagesInput, queriesInput, configFile, repository, tempDir, toolCacheDir, codeQL, checkoutPath, gitHubVersion, apiDetails, logger);
|
config = await loadConfig(languagesInput, queriesInput, configFile, repository, tempDir, toolCacheDir, codeQL, checkoutPath, githubAuth, githubUrl, logger);
|
||||||
}
|
}
|
||||||
// Save the config so we can easily access it again in the future
|
// Save the config so we can easily access it again in the future
|
||||||
await saveConfig(config, logger);
|
await saveConfig(config, logger);
|
||||||
@@ -551,7 +546,7 @@ function getLocalConfig(configFile, checkoutPath) {
|
|||||||
}
|
}
|
||||||
return yaml.safeLoad(fs.readFileSync(configFile, "utf8"));
|
return yaml.safeLoad(fs.readFileSync(configFile, "utf8"));
|
||||||
}
|
}
|
||||||
async function getRemoteConfig(configFile, apiDetails) {
|
async function getRemoteConfig(configFile, githubAuth, githubUrl) {
|
||||||
// retrieve the various parts of the config location, and ensure they're present
|
// retrieve the various parts of the config location, and ensure they're present
|
||||||
const format = new RegExp("(?<owner>[^/]+)/(?<repo>[^/]+)/(?<path>[^@]+)@(?<ref>.*)");
|
const format = new RegExp("(?<owner>[^/]+)/(?<repo>[^/]+)/(?<path>[^@]+)@(?<ref>.*)");
|
||||||
const pieces = format.exec(configFile);
|
const pieces = format.exec(configFile);
|
||||||
@@ -560,7 +555,7 @@ async function getRemoteConfig(configFile, apiDetails) {
|
|||||||
throw new Error(getConfigFileRepoFormatInvalidMessage(configFile));
|
throw new Error(getConfigFileRepoFormatInvalidMessage(configFile));
|
||||||
}
|
}
|
||||||
const response = await api
|
const response = await api
|
||||||
.getApiClient(apiDetails, { allowLocalRun: true, allowExternal: true })
|
.getApiClient(githubAuth, githubUrl, true)
|
||||||
.repos.getContent({
|
.repos.getContent({
|
||||||
owner: pieces.groups.owner,
|
owner: pieces.groups.owner,
|
||||||
repo: pieces.groups.repo,
|
repo: pieces.groups.repo,
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
94
lib/config-utils.test.js
generated
94
lib/config-utils.test.js
generated
@@ -10,10 +10,10 @@ 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 });
|
||||||
const fs = __importStar(require("fs"));
|
|
||||||
const path = __importStar(require("path"));
|
|
||||||
const github = __importStar(require("@actions/github"));
|
const github = __importStar(require("@actions/github"));
|
||||||
const ava_1 = __importDefault(require("ava"));
|
const ava_1 = __importDefault(require("ava"));
|
||||||
|
const fs = __importStar(require("fs"));
|
||||||
|
const path = __importStar(require("path"));
|
||||||
const sinon_1 = __importDefault(require("sinon"));
|
const sinon_1 = __importDefault(require("sinon"));
|
||||||
const api = __importStar(require("./api-client"));
|
const api = __importStar(require("./api-client"));
|
||||||
const codeql_1 = require("./codeql");
|
const codeql_1 = require("./codeql");
|
||||||
@@ -23,12 +23,6 @@ const logging_1 = require("./logging");
|
|||||||
const testing_utils_1 = require("./testing-utils");
|
const testing_utils_1 = require("./testing-utils");
|
||||||
const util = __importStar(require("./util"));
|
const util = __importStar(require("./util"));
|
||||||
testing_utils_1.setupTests(ava_1.default);
|
testing_utils_1.setupTests(ava_1.default);
|
||||||
const sampleApiDetails = {
|
|
||||||
auth: "token",
|
|
||||||
externalRepoAuth: "token",
|
|
||||||
url: "https://github.example.com",
|
|
||||||
};
|
|
||||||
const gitHubVersion = { type: util.GitHubVariant.DOTCOM };
|
|
||||||
// Returns the filepath of the newly-created file
|
// Returns the filepath of the newly-created file
|
||||||
function createConfigFile(inputFileContents, tmpDir) {
|
function createConfigFile(inputFileContents, tmpDir) {
|
||||||
const configFilePath = path.join(tmpDir, "input");
|
const configFilePath = path.join(tmpDir, "input");
|
||||||
@@ -72,8 +66,8 @@ ava_1.default("load empty config", async (t) => {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const config = await configUtils.initConfig(languages, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logger);
|
const config = await configUtils.initConfig(languages, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, "token", "https://github.example.com", logger);
|
||||||
t.deepEqual(config, await configUtils.getDefaultConfig(languages, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logger));
|
t.deepEqual(config, await configUtils.getDefaultConfig(languages, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, "token", "https://github.example.com", logger));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("loading config saves config", async (t) => {
|
ava_1.default("loading config saves config", async (t) => {
|
||||||
@@ -92,7 +86,7 @@ ava_1.default("loading config saves config", async (t) => {
|
|||||||
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, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logger);
|
const config1 = await configUtils.initConfig("javascript,python", undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, "token", "https://github.example.com", 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
|
||||||
@@ -103,7 +97,7 @@ ava_1.default("loading config saves config", async (t) => {
|
|||||||
ava_1.default("load input outside of workspace", async (t) => {
|
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, "../input", { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(undefined, undefined, "../input", { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, "token", "https://github.example.com", logging_1.getRunnerLogger(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -116,7 +110,7 @@ ava_1.default("load non-local input with invalid repo syntax", async (t) => {
|
|||||||
// 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, configFile, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(undefined, undefined, configFile, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, "token", "https://github.example.com", logging_1.getRunnerLogger(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -130,7 +124,7 @@ ava_1.default("load non-existent input", async (t) => {
|
|||||||
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, configFile, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(languages, undefined, configFile, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, "token", "https://github.example.com", logging_1.getRunnerLogger(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -172,12 +166,7 @@ ava_1.default("load non-empty input", async (t) => {
|
|||||||
queries: {
|
queries: {
|
||||||
javascript: {
|
javascript: {
|
||||||
builtin: [],
|
builtin: [],
|
||||||
custom: [
|
custom: ["/foo/a.ql", "/bar/b.ql"],
|
||||||
{
|
|
||||||
queries: ["/foo/a.ql", "/bar/b.ql"],
|
|
||||||
searchPath: tmpDir,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
pathsIgnore: ["a", "b"],
|
pathsIgnore: ["a", "b"],
|
||||||
@@ -192,11 +181,10 @@ ava_1.default("load non-empty input", async (t) => {
|
|||||||
tempDir: tmpDir,
|
tempDir: tmpDir,
|
||||||
toolCacheDir: tmpDir,
|
toolCacheDir: tmpDir,
|
||||||
codeQLCmd: codeQL.getPath(),
|
codeQLCmd: codeQL.getPath(),
|
||||||
gitHubVersion,
|
|
||||||
};
|
};
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const configFilePath = createConfigFile(inputFileContents, tmpDir);
|
const configFilePath = createConfigFile(inputFileContents, tmpDir);
|
||||||
const actualConfig = await configUtils.initConfig(languages, undefined, configFilePath, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
const actualConfig = await configUtils.initConfig(languages, undefined, configFilePath, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, "token", "https://github.example.com", 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);
|
||||||
});
|
});
|
||||||
@@ -225,14 +213,14 @@ ava_1.default("Default queries are used", async (t) => {
|
|||||||
});
|
});
|
||||||
// The important point of this config is that it doesn't specify
|
// The important point of this config is that it doesn't specify
|
||||||
// the disable-default-queries field.
|
// the disable-default-queries field.
|
||||||
// Any other details are hopefully irrelevant for this test.
|
// Any other details are hopefully irrelevant for this tetst.
|
||||||
const inputFileContents = `
|
const inputFileContents = `
|
||||||
paths:
|
paths:
|
||||||
- foo`;
|
- foo`;
|
||||||
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, configFilePath, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(languages, undefined, configFilePath, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, "token", "https://github.example.com", 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, [
|
||||||
@@ -275,7 +263,7 @@ ava_1.default("Queries can be specified in config file", async (t) => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const config = await configUtils.initConfig(languages, undefined, configFilePath, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
const config = await configUtils.initConfig(languages, undefined, configFilePath, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, "token", "https://github.example.com", 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.
|
||||||
@@ -286,7 +274,7 @@ ava_1.default("Queries can be specified in config file", async (t) => {
|
|||||||
t.deepEqual(config.queries["javascript"].builtin.length, 1);
|
t.deepEqual(config.queries["javascript"].builtin.length, 1);
|
||||||
t.deepEqual(config.queries["javascript"].custom.length, 1);
|
t.deepEqual(config.queries["javascript"].custom.length, 1);
|
||||||
t.regex(config.queries["javascript"].builtin[0], /javascript-code-scanning.qls$/);
|
t.regex(config.queries["javascript"].builtin[0], /javascript-code-scanning.qls$/);
|
||||||
t.regex(config.queries["javascript"].custom[0].queries[0], /.*\/foo$/);
|
t.regex(config.queries["javascript"].custom[0], /.*\/foo$/);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("Queries from config file can be overridden in workflow file", async (t) => {
|
ava_1.default("Queries from config file can be overridden in workflow file", async (t) => {
|
||||||
@@ -297,7 +285,7 @@ ava_1.default("Queries from config file can be overridden in workflow file", asy
|
|||||||
- uses: ./foo`;
|
- uses: ./foo`;
|
||||||
const configFilePath = createConfigFile(inputFileContents, tmpDir);
|
const configFilePath = createConfigFile(inputFileContents, tmpDir);
|
||||||
// This config item should take precedence over the config file but shouldn't affect the default queries.
|
// This config item should take precedence over the config file but shouldn't affect the default queries.
|
||||||
const testQueries = "./override";
|
const queries = "./override";
|
||||||
fs.mkdirSync(path.join(tmpDir, "foo"));
|
fs.mkdirSync(path.join(tmpDir, "foo"));
|
||||||
fs.mkdirSync(path.join(tmpDir, "override"));
|
fs.mkdirSync(path.join(tmpDir, "override"));
|
||||||
const resolveQueriesArgs = [];
|
const resolveQueriesArgs = [];
|
||||||
@@ -308,7 +296,7 @@ ava_1.default("Queries from config file can be overridden in workflow file", asy
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const config = await configUtils.initConfig(languages, testQueries, configFilePath, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
const config = await configUtils.initConfig(languages, queries, configFilePath, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, "token", "https://github.example.com", 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.
|
||||||
@@ -319,7 +307,7 @@ ava_1.default("Queries from config file can be overridden in workflow file", asy
|
|||||||
t.deepEqual(config.queries["javascript"].builtin.length, 1);
|
t.deepEqual(config.queries["javascript"].builtin.length, 1);
|
||||||
t.deepEqual(config.queries["javascript"].custom.length, 1);
|
t.deepEqual(config.queries["javascript"].custom.length, 1);
|
||||||
t.regex(config.queries["javascript"].builtin[0], /javascript-code-scanning.qls$/);
|
t.regex(config.queries["javascript"].builtin[0], /javascript-code-scanning.qls$/);
|
||||||
t.regex(config.queries["javascript"].custom[0].queries[0], /.*\/override$/);
|
t.regex(config.queries["javascript"].custom[0], /.*\/override$/);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("Queries in workflow file can be used in tandem with the 'disable default queries' option", async (t) => {
|
ava_1.default("Queries in workflow file can be used in tandem with the 'disable default queries' option", async (t) => {
|
||||||
@@ -330,7 +318,7 @@ ava_1.default("Queries in workflow file can be used in tandem with the 'disable
|
|||||||
name: my config
|
name: my config
|
||||||
disable-default-queries: true`;
|
disable-default-queries: true`;
|
||||||
const configFilePath = createConfigFile(inputFileContents, tmpDir);
|
const configFilePath = createConfigFile(inputFileContents, tmpDir);
|
||||||
const testQueries = "./workflow-query";
|
const queries = "./workflow-query";
|
||||||
fs.mkdirSync(path.join(tmpDir, "workflow-query"));
|
fs.mkdirSync(path.join(tmpDir, "workflow-query"));
|
||||||
const resolveQueriesArgs = [];
|
const resolveQueriesArgs = [];
|
||||||
const codeQL = codeql_1.setCodeQL({
|
const codeQL = codeql_1.setCodeQL({
|
||||||
@@ -340,7 +328,7 @@ ava_1.default("Queries in workflow file can be used in tandem with the 'disable
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const config = await configUtils.initConfig(languages, testQueries, configFilePath, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
const config = await configUtils.initConfig(languages, queries, configFilePath, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, "token", "https://github.example.com", 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
|
||||||
@@ -350,14 +338,14 @@ ava_1.default("Queries in workflow file can be used in tandem with the 'disable
|
|||||||
// Now check that the end result contains only the workflow query, and not the default one
|
// Now check that the end result contains only the workflow query, and not the default one
|
||||||
t.deepEqual(config.queries["javascript"].builtin.length, 0);
|
t.deepEqual(config.queries["javascript"].builtin.length, 0);
|
||||||
t.deepEqual(config.queries["javascript"].custom.length, 1);
|
t.deepEqual(config.queries["javascript"].custom.length, 1);
|
||||||
t.regex(config.queries["javascript"].custom[0].queries[0], /.*\/workflow-query$/);
|
t.regex(config.queries["javascript"].custom[0], /.*\/workflow-query$/);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("Multiple queries can be specified in workflow file, no config file required", async (t) => {
|
ava_1.default("Multiple queries can be specified in workflow file, no config file required", async (t) => {
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
fs.mkdirSync(path.join(tmpDir, "override1"));
|
fs.mkdirSync(path.join(tmpDir, "override1"));
|
||||||
fs.mkdirSync(path.join(tmpDir, "override2"));
|
fs.mkdirSync(path.join(tmpDir, "override2"));
|
||||||
const testQueries = "./override1,./override2";
|
const queries = "./override1,./override2";
|
||||||
const resolveQueriesArgs = [];
|
const resolveQueriesArgs = [];
|
||||||
const codeQL = codeql_1.setCodeQL({
|
const codeQL = codeql_1.setCodeQL({
|
||||||
async resolveQueries(queries, extraSearchPath) {
|
async resolveQueries(queries, extraSearchPath) {
|
||||||
@@ -366,7 +354,7 @@ ava_1.default("Multiple queries can be specified in workflow file, no config fil
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const config = await configUtils.initConfig(languages, testQueries, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
const config = await configUtils.initConfig(languages, queries, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, "token", "https://github.example.com", 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
|
||||||
@@ -379,8 +367,8 @@ ava_1.default("Multiple queries can be specified in workflow file, no config fil
|
|||||||
t.deepEqual(config.queries["javascript"].builtin.length, 1);
|
t.deepEqual(config.queries["javascript"].builtin.length, 1);
|
||||||
t.deepEqual(config.queries["javascript"].custom.length, 2);
|
t.deepEqual(config.queries["javascript"].custom.length, 2);
|
||||||
t.regex(config.queries["javascript"].builtin[0], /javascript-code-scanning.qls$/);
|
t.regex(config.queries["javascript"].builtin[0], /javascript-code-scanning.qls$/);
|
||||||
t.regex(config.queries["javascript"].custom[0].queries[0], /.*\/override1$/);
|
t.regex(config.queries["javascript"].custom[0], /.*\/override1$/);
|
||||||
t.regex(config.queries["javascript"].custom[1].queries[0], /.*\/override2$/);
|
t.regex(config.queries["javascript"].custom[1], /.*\/override2$/);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("Queries in workflow file can be added to the set of queries without overriding config file", async (t) => {
|
ava_1.default("Queries in workflow file can be added to the set of queries without overriding config file", async (t) => {
|
||||||
@@ -393,7 +381,7 @@ ava_1.default("Queries in workflow file can be added to the set of queries witho
|
|||||||
- uses: ./foo`;
|
- uses: ./foo`;
|
||||||
const configFilePath = createConfigFile(inputFileContents, tmpDir);
|
const configFilePath = createConfigFile(inputFileContents, tmpDir);
|
||||||
// These queries shouldn't override anything, because the value is prefixed with "+"
|
// These queries shouldn't override anything, because the value is prefixed with "+"
|
||||||
const testQueries = "+./additional1,./additional2";
|
const queries = "+./additional1,./additional2";
|
||||||
fs.mkdirSync(path.join(tmpDir, "foo"));
|
fs.mkdirSync(path.join(tmpDir, "foo"));
|
||||||
fs.mkdirSync(path.join(tmpDir, "additional1"));
|
fs.mkdirSync(path.join(tmpDir, "additional1"));
|
||||||
fs.mkdirSync(path.join(tmpDir, "additional2"));
|
fs.mkdirSync(path.join(tmpDir, "additional2"));
|
||||||
@@ -405,7 +393,7 @@ ava_1.default("Queries in workflow file can be added to the set of queries witho
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const config = await configUtils.initConfig(languages, testQueries, configFilePath, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
const config = await configUtils.initConfig(languages, queries, configFilePath, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, "token", "https://github.example.com", 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,
|
||||||
@@ -421,9 +409,9 @@ ava_1.default("Queries in workflow file can be added to the set of queries witho
|
|||||||
t.deepEqual(config.queries["javascript"].builtin.length, 1);
|
t.deepEqual(config.queries["javascript"].builtin.length, 1);
|
||||||
t.deepEqual(config.queries["javascript"].custom.length, 3);
|
t.deepEqual(config.queries["javascript"].custom.length, 3);
|
||||||
t.regex(config.queries["javascript"].builtin[0], /javascript-code-scanning.qls$/);
|
t.regex(config.queries["javascript"].builtin[0], /javascript-code-scanning.qls$/);
|
||||||
t.regex(config.queries["javascript"].custom[0].queries[0], /.*\/additional1$/);
|
t.regex(config.queries["javascript"].custom[0], /.*\/additional1$/);
|
||||||
t.regex(config.queries["javascript"].custom[1].queries[0], /.*\/additional2$/);
|
t.regex(config.queries["javascript"].custom[1], /.*\/additional2$/);
|
||||||
t.regex(config.queries["javascript"].custom[2].queries[0], /.*\/foo$/);
|
t.regex(config.queries["javascript"].custom[2], /.*\/foo$/);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("Invalid queries in workflow file handled correctly", async (t) => {
|
ava_1.default("Invalid queries in workflow file handled correctly", async (t) => {
|
||||||
@@ -433,7 +421,7 @@ ava_1.default("Invalid queries in workflow file handled correctly", async (t) =>
|
|||||||
// This function just needs to be type-correct; it doesn't need to do anything,
|
// This function just needs to be type-correct; it doesn't need to do anything,
|
||||||
// since we're deliberately passing in invalid data
|
// since we're deliberately passing in invalid data
|
||||||
const codeQL = codeql_1.setCodeQL({
|
const codeQL = codeql_1.setCodeQL({
|
||||||
async resolveQueries() {
|
async resolveQueries(_queries, _extraSearchPath) {
|
||||||
return {
|
return {
|
||||||
byLanguage: {
|
byLanguage: {
|
||||||
javascript: {},
|
javascript: {},
|
||||||
@@ -444,7 +432,7 @@ ava_1.default("Invalid queries in workflow file handled correctly", async (t) =>
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(languages, queries, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(languages, queries, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, "token", "https://github.example.com", logging_1.getRunnerLogger(true));
|
||||||
t.fail("initConfig did not throw error");
|
t.fail("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -487,7 +475,7 @@ ava_1.default("API client used when reading remote config", async (t) => {
|
|||||||
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, configFile, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(languages, undefined, configFile, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, "token", "https://github.example.com", logging_1.getRunnerLogger(true));
|
||||||
t.assert(spyGetContents.called);
|
t.assert(spyGetContents.called);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -497,7 +485,7 @@ ava_1.default("Remote config handles the case where a directory is provided", as
|
|||||||
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, repoReference, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(undefined, undefined, repoReference, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, "token", "https://github.example.com", logging_1.getRunnerLogger(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -513,7 +501,7 @@ ava_1.default("Invalid format of remote config handled correctly", async (t) =>
|
|||||||
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, repoReference, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(undefined, undefined, repoReference, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, "token", "https://github.example.com", logging_1.getRunnerLogger(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -525,7 +513,7 @@ ava_1.default("No detected languages", async (t) => {
|
|||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
mockListLanguages([]);
|
mockListLanguages([]);
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(undefined, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(undefined, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, "token", "https://github.example.com", logging_1.getRunnerLogger(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -537,7 +525,7 @@ ava_1.default("Unknown languages", async (t) => {
|
|||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
const languages = "ruby,english";
|
const languages = "ruby,english";
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(languages, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(languages, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, "token", "https://github.example.com", logging_1.getRunnerLogger(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -562,7 +550,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, configFile, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(languages, undefined, configFile, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, "token", "https://github.example.com", logging_1.getRunnerLogger(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -616,11 +604,11 @@ ava_1.default("path validations", (t) => {
|
|||||||
// Dummy values to pass to validateAndSanitisePath
|
// Dummy values to pass to validateAndSanitisePath
|
||||||
const propertyName = "paths";
|
const propertyName = "paths";
|
||||||
const configFile = "./.github/codeql/config.yml";
|
const configFile = "./.github/codeql/config.yml";
|
||||||
for (const validPath of validPaths) {
|
for (const path of validPaths) {
|
||||||
t.truthy(configUtils.validateAndSanitisePath(validPath, propertyName, configFile, logging_1.getRunnerLogger(true)));
|
t.truthy(configUtils.validateAndSanitisePath(path, propertyName, configFile, logging_1.getRunnerLogger(true)));
|
||||||
}
|
}
|
||||||
for (const invalidPath of invalidPaths) {
|
for (const path of invalidPaths) {
|
||||||
t.throws(() => configUtils.validateAndSanitisePath(invalidPath, propertyName, configFile, logging_1.getRunnerLogger(true)));
|
t.throws(() => configUtils.validateAndSanitisePath(path, propertyName, configFile, logging_1.getRunnerLogger(true)));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ava_1.default("path sanitisation", (t) => {
|
ava_1.default("path sanitisation", (t) => {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
89
lib/count-loc.js
generated
89
lib/count-loc.js
generated
@@ -1,89 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const github_linguist_1 = require("github-linguist");
|
|
||||||
const languages_1 = require("./languages");
|
|
||||||
const util_1 = require("./util");
|
|
||||||
// Map from linguist language names to language prefixes used in the action and codeql
|
|
||||||
const linguistToMetrics = {
|
|
||||||
c: languages_1.Language.cpp,
|
|
||||||
"c++": languages_1.Language.cpp,
|
|
||||||
"c#": languages_1.Language.csharp,
|
|
||||||
go: languages_1.Language.go,
|
|
||||||
java: languages_1.Language.java,
|
|
||||||
javascript: languages_1.Language.javascript,
|
|
||||||
python: languages_1.Language.python,
|
|
||||||
typescript: languages_1.Language.javascript,
|
|
||||||
};
|
|
||||||
const nameToLinguist = Object.entries(linguistToMetrics).reduce((obj, [key, name]) => {
|
|
||||||
if (!obj[name]) {
|
|
||||||
obj[name] = [];
|
|
||||||
}
|
|
||||||
obj[name].push(key);
|
|
||||||
return obj;
|
|
||||||
}, {});
|
|
||||||
function getIdPrefix(language) {
|
|
||||||
switch (language) {
|
|
||||||
case languages_1.Language.cpp:
|
|
||||||
return "cpp";
|
|
||||||
case languages_1.Language.csharp:
|
|
||||||
return "cs";
|
|
||||||
case languages_1.Language.go:
|
|
||||||
return "go";
|
|
||||||
case languages_1.Language.java:
|
|
||||||
return "java";
|
|
||||||
case languages_1.Language.javascript:
|
|
||||||
return "js";
|
|
||||||
case languages_1.Language.python:
|
|
||||||
return "py";
|
|
||||||
default:
|
|
||||||
util_1.assertNever(language);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.getIdPrefix = getIdPrefix;
|
|
||||||
/**
|
|
||||||
* Count the lines of code of the specified language using the include
|
|
||||||
* and exclude glob paths.
|
|
||||||
*
|
|
||||||
* @param cwd the root directory to start the count from
|
|
||||||
* @param include glob patterns to include in the search for relevant files
|
|
||||||
* @param exclude glob patterns to exclude in the search for relevant files
|
|
||||||
* @param dbLanguages list of languages to include in the results
|
|
||||||
* @param logger object to log results
|
|
||||||
*/
|
|
||||||
async function countLoc(cwd, include, exclude, dbLanguages, logger) {
|
|
||||||
const result = await new github_linguist_1.LocDir({
|
|
||||||
cwd,
|
|
||||||
include: Array.isArray(include) && include.length > 0 ? include : ["**"],
|
|
||||||
exclude,
|
|
||||||
analysisLanguages: dbLanguages.flatMap((lang) => nameToLinguist[lang]),
|
|
||||||
}).loadInfo();
|
|
||||||
// The analysis counts LoC in all languages. We need to
|
|
||||||
// extract the languages we care about. Also, note that
|
|
||||||
// the analysis uses slightly different names for language.
|
|
||||||
const lineCounts = Object.entries(result.languages).reduce((obj, [language, { code }]) => {
|
|
||||||
const metricsLanguage = linguistToMetrics[language];
|
|
||||||
if (metricsLanguage && dbLanguages.includes(metricsLanguage)) {
|
|
||||||
obj[metricsLanguage] = code + (obj[metricsLanguage] || 0);
|
|
||||||
}
|
|
||||||
return obj;
|
|
||||||
}, {});
|
|
||||||
if (Object.keys(lineCounts).length) {
|
|
||||||
logger.debug("Lines of code count:");
|
|
||||||
for (const [language, count] of Object.entries(lineCounts)) {
|
|
||||||
logger.debug(` ${language}: ${count}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
logger.info("Could not determine the total number of lines of code in this repository. " +
|
|
||||||
"Because of this, it will not be possible to compare the number of lines " +
|
|
||||||
"of code analyzed by code scanning with the total number of lines of " +
|
|
||||||
"code in the repository. This will not affect the results produced by code " +
|
|
||||||
"scanning. If you have any questions, you can raise an issue at " +
|
|
||||||
"https://github.com/github/codeql-action/issues. Please include a link " +
|
|
||||||
"to the repository if public, or otherwise information about the code scanning " +
|
|
||||||
"workflow you are using.");
|
|
||||||
}
|
|
||||||
return lineCounts;
|
|
||||||
}
|
|
||||||
exports.countLoc = countLoc;
|
|
||||||
//# sourceMappingURL=count-loc.js.map
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"count-loc.js","sourceRoot":"","sources":["../src/count-loc.ts"],"names":[],"mappings":";;AAAA,qDAAyC;AAEzC,2CAAuC;AAEvC,iCAAqC;AAKrC,sFAAsF;AACtF,MAAM,iBAAiB,GAA6B;IAClD,CAAC,EAAE,oBAAQ,CAAC,GAAG;IACf,KAAK,EAAE,oBAAQ,CAAC,GAAG;IACnB,IAAI,EAAE,oBAAQ,CAAC,MAAM;IACrB,EAAE,EAAE,oBAAQ,CAAC,EAAE;IACf,IAAI,EAAE,oBAAQ,CAAC,IAAI;IACnB,UAAU,EAAE,oBAAQ,CAAC,UAAU;IAC/B,MAAM,EAAE,oBAAQ,CAAC,MAAM;IACvB,UAAU,EAAE,oBAAQ,CAAC,UAAU;CAChC,CAAC;AAEF,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,MAAM,CAC7D,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE;IACnB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QACd,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;KAChB;IACD,GAAG,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpB,OAAO,GAAG,CAAC;AACb,CAAC,EACD,EAAgC,CACjC,CAAC;AAEF,SAAgB,WAAW,CAAC,QAAkB;IAC5C,QAAQ,QAAQ,EAAE;QAChB,KAAK,oBAAQ,CAAC,GAAG;YACf,OAAO,KAAK,CAAC;QACf,KAAK,oBAAQ,CAAC,MAAM;YAClB,OAAO,IAAI,CAAC;QACd,KAAK,oBAAQ,CAAC,EAAE;YACd,OAAO,IAAI,CAAC;QACd,KAAK,oBAAQ,CAAC,IAAI;YAChB,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AC,MAAM,EAAE;QAClC,MAAM,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC;QACrC,KAAK,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;YAC1D,MAAM,CAAC,KAAK,CAAC,KAAK,QAAQ,KAAK,KAAK,EAAE,CAAC,CAAC;SACzC;KACF;SAAM;QACL,MAAM,CAAC,IAAI,CACT,4EAA4E;YAC1E,0EAA0E;YAC1E,sEAAsE;YACtE,4EAA4E;YAC5E,iEAAiE;YACjE,wEAAwE;YACxE,gFAAgF;YAChF,yBAAyB,CAC5B,CAAC;KACH;IAED,OAAO,UAAU,CAAC;AACpB,CAAC;AA/CD,4BA+CC"}
|
|
||||||
60
lib/count-loc.test.js
generated
60
lib/count-loc.test.js
generated
@@ -1,60 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
||||||
result["default"] = mod;
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const path = __importStar(require("path"));
|
|
||||||
const ava_1 = __importDefault(require("ava"));
|
|
||||||
const count_loc_1 = require("./count-loc");
|
|
||||||
const languages_1 = require("./languages");
|
|
||||||
const logging_1 = require("./logging");
|
|
||||||
const testing_utils_1 = require("./testing-utils");
|
|
||||||
testing_utils_1.setupTests(ava_1.default);
|
|
||||||
ava_1.default("ensure lines of code works for cpp and js", async (t) => {
|
|
||||||
const results = await count_loc_1.countLoc(path.join(__dirname, "../tests/multi-language-repo"), [], [], [languages_1.Language.cpp, languages_1.Language.javascript], logging_1.getRunnerLogger(true));
|
|
||||||
t.deepEqual(results, {
|
|
||||||
cpp: 6,
|
|
||||||
javascript: 3,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
ava_1.default("ensure lines of code can handle undefined language", async (t) => {
|
|
||||||
const results = await count_loc_1.countLoc(path.join(__dirname, "../tests/multi-language-repo"), [], [], [languages_1.Language.javascript, languages_1.Language.python, "hucairz"], logging_1.getRunnerLogger(true));
|
|
||||||
t.deepEqual(results, {
|
|
||||||
javascript: 3,
|
|
||||||
python: 5,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
ava_1.default("ensure lines of code can handle empty languages", async (t) => {
|
|
||||||
const results = await count_loc_1.countLoc(path.join(__dirname, "../tests/multi-language-repo"), [], [], [], logging_1.getRunnerLogger(true));
|
|
||||||
t.deepEqual(results, {});
|
|
||||||
});
|
|
||||||
ava_1.default("ensure lines of code can handle includes", async (t) => {
|
|
||||||
// note that "**" is always included. The includes are for extra
|
|
||||||
// directories outside the normal structure.
|
|
||||||
const results = await count_loc_1.countLoc(path.join(__dirname, "../tests/multi-language-repo"), ["../../src/testdata"], [], [languages_1.Language.javascript], logging_1.getRunnerLogger(true));
|
|
||||||
t.deepEqual(results, {
|
|
||||||
javascript: 12,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
ava_1.default("ensure lines of code can handle empty includes", async (t) => {
|
|
||||||
// note that "**" is always included. The includes are for extra
|
|
||||||
// directories outside the normal structure.
|
|
||||||
const results = await count_loc_1.countLoc(path.join(__dirname, "../tests/multi-language-repo"), ["idontexist"], [], [languages_1.Language.javascript], logging_1.getRunnerLogger(true));
|
|
||||||
t.deepEqual(results, {
|
|
||||||
// should get no results
|
|
||||||
});
|
|
||||||
});
|
|
||||||
ava_1.default("ensure lines of code can handle exclude", async (t) => {
|
|
||||||
const results = await count_loc_1.countLoc(path.join(__dirname, "../tests/multi-language-repo"), [], ["**/*.py"], [languages_1.Language.javascript, languages_1.Language.python], logging_1.getRunnerLogger(true));
|
|
||||||
t.deepEqual(results, {
|
|
||||||
javascript: 3,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
//# sourceMappingURL=count-loc.test.js.map
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"count-loc.test.js","sourceRoot":"","sources":["../src/count-loc.test.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA6B;AAE7B,8CAAuB;AAEvB,2CAAuC;AACvC,2CAAuC;AACvC,uCAA4C;AAC5C,mDAA6C;AAE7C,0BAAU,CAAC,aAAI,CAAC,CAAC;AAEjB,aAAI,CAAC,2CAA2C,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAC5D,MAAM,OAAO,GAAG,MAAM,oBAAQ,CAC5B,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,8BAA8B,CAAC,EACpD,EAAE,EACF,EAAE,EACF,CAAC,oBAAQ,CAAC,GAAG,EAAE,oBAAQ,CAAC,UAAU,CAAC,EACnC,yBAAe,CAAC,IAAI,CAAC,CACtB,CAAC;IAEF,CAAC,CAAC,SAAS,CAAC,OAAO,EAAE;QACnB,GAAG,EAAE,CAAC;QACN,UAAU,EAAE,CAAC;KACd,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,aAAI,CAAC,oDAAoD,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IACrE,MAAM,OAAO,GAAG,MAAM,oBAAQ,CAC5B,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,8BAA8B,CAAC,EACpD,EAAE,EACF,EAAE,EACF,CAAC,oBAAQ,CAAC,UAAU,EAAE,oBAAQ,CAAC,MAAM,EAAE,SAAqB,CAAC,EAC7D,yBAAe,CAAC,IAAI,CAAC,CACtB,CAAC;IAEF,CAAC,CAAC,SAAS,CAAC,OAAO,EAAE;QACnB,UAAU,EAAE,CAAC;QACb,MAAM,EAAE,CAAC;KACV,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,aAAI,CAAC,iDAAiD,EAAE,KAA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C,SAAS,EAAE,8BAA8B,CAAC,EACpD,EAAE,EACF,CAAC,SAAS,CAAC,EACX,CAAC,oBAAQ,CAAC,UAAU,EAAE,oBAAQ,CAAC,MAAM,CAAC,EACtC,yBAAe,CAAC,IAAI,CAAC,CACtB,CAAC;IAEF,CAAC,CAAC,SAAS,CAAC,OAAO,EAAE;QACnB,UAAU,EAAE,CAAC;KACd,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"bundleVersion": "codeql-bundle-20210503"
|
"bundleVersion": "codeql-bundle-20200826"
|
||||||
}
|
}
|
||||||
|
|||||||
26
lib/external-queries.js
generated
26
lib/external-queries.js
generated
@@ -7,14 +7,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
const toolrunnner = __importStar(require("@actions/exec/lib/toolrunner"));
|
||||||
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 safeWhich = __importStar(require("@chrisgavin/safe-which"));
|
|
||||||
/**
|
/**
|
||||||
* Check out repository at the given ref, and return the directory of the checkout.
|
* Check out repository at the given ref, and return the directory of the checkout.
|
||||||
*/
|
*/
|
||||||
async function checkoutExternalRepository(repository, ref, apiDetails, tempDir, logger) {
|
async function checkoutExternalRepository(repository, ref, githubUrl, tempDir, logger) {
|
||||||
logger.info(`Checking out ${repository}`);
|
logger.info(`Checking out ${repository}`);
|
||||||
const checkoutLocation = path.join(tempDir, repository, ref);
|
const checkoutLocation = path.join(tempDir, repository, ref);
|
||||||
if (!checkoutLocation.startsWith(tempDir)) {
|
if (!checkoutLocation.startsWith(tempDir)) {
|
||||||
@@ -22,13 +21,13 @@ async function checkoutExternalRepository(repository, ref, apiDetails, tempDir,
|
|||||||
throw new Error(`'${repository}@${ref}' is not a valid repository and reference.`);
|
throw new Error(`'${repository}@${ref}' is not a valid repository and reference.`);
|
||||||
}
|
}
|
||||||
if (!fs.existsSync(checkoutLocation)) {
|
if (!fs.existsSync(checkoutLocation)) {
|
||||||
const repoCloneURL = buildCheckoutURL(repository, apiDetails);
|
const repoURL = `${githubUrl}/${repository}`;
|
||||||
await new toolrunner.ToolRunner(await safeWhich.safeWhich("git"), [
|
await new toolrunnner.ToolRunner("git", [
|
||||||
"clone",
|
"clone",
|
||||||
repoCloneURL,
|
repoURL,
|
||||||
checkoutLocation,
|
checkoutLocation,
|
||||||
]).exec();
|
]).exec();
|
||||||
await new toolrunner.ToolRunner(await safeWhich.safeWhich("git"), [
|
await new toolrunnner.ToolRunner("git", [
|
||||||
`--work-tree=${checkoutLocation}`,
|
`--work-tree=${checkoutLocation}`,
|
||||||
`--git-dir=${checkoutLocation}/.git`,
|
`--git-dir=${checkoutLocation}/.git`,
|
||||||
"checkout",
|
"checkout",
|
||||||
@@ -38,17 +37,4 @@ async function checkoutExternalRepository(repository, ref, apiDetails, tempDir,
|
|||||||
return checkoutLocation;
|
return checkoutLocation;
|
||||||
}
|
}
|
||||||
exports.checkoutExternalRepository = checkoutExternalRepository;
|
exports.checkoutExternalRepository = checkoutExternalRepository;
|
||||||
function buildCheckoutURL(repository, apiDetails) {
|
|
||||||
const repoCloneURL = new URL(apiDetails.url);
|
|
||||||
if (apiDetails.externalRepoAuth !== undefined) {
|
|
||||||
repoCloneURL.username = "x-access-token";
|
|
||||||
repoCloneURL.password = apiDetails.externalRepoAuth;
|
|
||||||
}
|
|
||||||
if (!repoCloneURL.pathname.endsWith("/")) {
|
|
||||||
repoCloneURL.pathname += "/";
|
|
||||||
}
|
|
||||||
repoCloneURL.pathname += `${repository}`;
|
|
||||||
return repoCloneURL.toString();
|
|
||||||
}
|
|
||||||
exports.buildCheckoutURL = buildCheckoutURL;
|
|
||||||
//# sourceMappingURL=external-queries.js.map
|
//# sourceMappingURL=external-queries.js.map
|
||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"external-queries.js","sourceRoot":"","sources":["../src/external-queries.ts"],"names":[],"mappings":";;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,yEAA2D;AAC3D,kEAAoD;AAKpD;;GAEG;AACI,KAAK,UAAU,0BAA0B,CAC9C,UAAkB,EAClB,GAAW,EACX,UAAwC,EACxC,OAAe,EACf,MAAc;IAEd,MAAM,CAAC,IAAI,CAAC,gBAAgB,UAAU,EAAE,CAAC,CAAC;IAE1C,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC;IAE7D,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE;QACzC,wGAAwG;QACxG,MAAM,IAAI,KAAK,CACb,IAAI,UAAU,IAAI,GAAG,4CAA4C,CAClE,CAAC;KACH;IAED,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE;QACpC,MAAM,YAAY,GAAG,gBAAgB,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QAC9D,MAAM,IAAI,UAAU,CAAC,UAAU,CAAC,MAAM,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE;YAChE,OAAO;YACP,YAAY;YACZ,gBAAgB;SACjB,CAAC,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,UAAU,CAAC,UAAU,CAAC,MAAM,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE;YAChE,eAAe,gBAAgB,EAAE;YACjC,aAAa,gBAAgB,OAAO;YACpC,UAAU;YACV,GAAG;SACJ,CAAC,CAAC,IAAI,EAAE,CAAC;KACX;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAlCD,gEAkCC;AAED,SAAgB,gBAAgB,C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;YACP,OAAO;YACP,gBAAgB;SACjB,CAAC,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,WAAW,CAAC,UAAU,CAAC,KAAK,EAAE;YACtC,eAAe,gBAAgB,EAAE;YACjC,aAAa,gBAAgB,OAAO;YACpC,UAAU;YACV,GAAG;SACJ,CAAC,CAAC,IAAI,EAAE,CAAC;KACX;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAlCD,gEAkCC"}
|
||||||
30
lib/external-queries.test.js
generated
30
lib/external-queries.test.js
generated
@@ -10,11 +10,10 @@ 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 });
|
||||||
|
const toolrunnner = __importStar(require("@actions/exec/lib/toolrunner"));
|
||||||
|
const ava_1 = __importDefault(require("ava"));
|
||||||
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 safeWhich = __importStar(require("@chrisgavin/safe-which"));
|
|
||||||
const ava_1 = __importDefault(require("ava"));
|
|
||||||
const externalQueries = __importStar(require("./external-queries"));
|
const externalQueries = __importStar(require("./external-queries"));
|
||||||
const logging_1 = require("./logging");
|
const logging_1 = require("./logging");
|
||||||
const testing_utils_1 = require("./testing-utils");
|
const testing_utils_1 = require("./testing-utils");
|
||||||
@@ -44,7 +43,7 @@ ava_1.default("checkoutExternalQueries", async (t) => {
|
|||||||
];
|
];
|
||||||
console.log(`Running: git ${command.join(" ")}`);
|
console.log(`Running: git ${command.join(" ")}`);
|
||||||
try {
|
try {
|
||||||
await new toolrunner.ToolRunner(await safeWhich.safeWhich("git"), command, {
|
await new toolrunnner.ToolRunner("git", command, {
|
||||||
silent: true,
|
silent: true,
|
||||||
listeners: {
|
listeners: {
|
||||||
stdout: (data) => {
|
stdout: (data) => {
|
||||||
@@ -67,7 +66,6 @@ ava_1.default("checkoutExternalQueries", async (t) => {
|
|||||||
await runGit(["init", repoPath]);
|
await runGit(["init", repoPath]);
|
||||||
await runGit(["config", "user.email", "test@github.com"]);
|
await runGit(["config", "user.email", "test@github.com"]);
|
||||||
await runGit(["config", "user.name", "Test Test"]);
|
await runGit(["config", "user.name", "Test Test"]);
|
||||||
await runGit(["config", "commit.gpgsign", "false"]);
|
|
||||||
fs.writeFileSync(path.join(repoPath, "a"), "a content");
|
fs.writeFileSync(path.join(repoPath, "a"), "a content");
|
||||||
await runGit(["add", "a"]);
|
await runGit(["add", "a"]);
|
||||||
await runGit(["commit", "-m", "commit1"]);
|
await runGit(["commit", "-m", "commit1"]);
|
||||||
@@ -81,35 +79,17 @@ ava_1.default("checkoutExternalQueries", async (t) => {
|
|||||||
const commit2Sha = await runGit(["rev-parse", "HEAD"]);
|
const commit2Sha = await runGit(["rev-parse", "HEAD"]);
|
||||||
// Checkout the first commit, which should contain 'a' and 'b'
|
// Checkout the first commit, which should contain 'a' and 'b'
|
||||||
t.false(fs.existsSync(path.join(tmpDir, repoName)));
|
t.false(fs.existsSync(path.join(tmpDir, repoName)));
|
||||||
await externalQueries.checkoutExternalRepository(repoName, commit1Sha, { url: `file://${testRepoBaseDir}`, externalRepoAuth: "" }, tmpDir, logging_1.getRunnerLogger(true));
|
await externalQueries.checkoutExternalRepository(repoName, commit1Sha, `file://${testRepoBaseDir}`, tmpDir, logging_1.getRunnerLogger(true));
|
||||||
t.true(fs.existsSync(path.join(tmpDir, repoName)));
|
t.true(fs.existsSync(path.join(tmpDir, repoName)));
|
||||||
t.true(fs.existsSync(path.join(tmpDir, repoName, commit1Sha)));
|
t.true(fs.existsSync(path.join(tmpDir, repoName, commit1Sha)));
|
||||||
t.true(fs.existsSync(path.join(tmpDir, repoName, commit1Sha, "a")));
|
t.true(fs.existsSync(path.join(tmpDir, repoName, commit1Sha, "a")));
|
||||||
t.true(fs.existsSync(path.join(tmpDir, repoName, commit1Sha, "b")));
|
t.true(fs.existsSync(path.join(tmpDir, repoName, commit1Sha, "b")));
|
||||||
// Checkout the second commit as well, which should only contain 'a'
|
// Checkout the second commit as well, which should only contain 'a'
|
||||||
t.false(fs.existsSync(path.join(tmpDir, repoName, commit2Sha)));
|
t.false(fs.existsSync(path.join(tmpDir, repoName, commit2Sha)));
|
||||||
await externalQueries.checkoutExternalRepository(repoName, commit2Sha, { url: `file://${testRepoBaseDir}`, externalRepoAuth: "" }, tmpDir, logging_1.getRunnerLogger(true));
|
await externalQueries.checkoutExternalRepository(repoName, commit2Sha, `file://${testRepoBaseDir}`, tmpDir, logging_1.getRunnerLogger(true));
|
||||||
t.true(fs.existsSync(path.join(tmpDir, repoName, commit2Sha)));
|
t.true(fs.existsSync(path.join(tmpDir, repoName, commit2Sha)));
|
||||||
t.true(fs.existsSync(path.join(tmpDir, repoName, commit2Sha, "a")));
|
t.true(fs.existsSync(path.join(tmpDir, repoName, commit2Sha, "a")));
|
||||||
t.false(fs.existsSync(path.join(tmpDir, repoName, commit2Sha, "b")));
|
t.false(fs.existsSync(path.join(tmpDir, repoName, commit2Sha, "b")));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("buildCheckoutURL", (t) => {
|
|
||||||
t.deepEqual(externalQueries.buildCheckoutURL("foo/bar", {
|
|
||||||
url: "https://github.com",
|
|
||||||
externalRepoAuth: undefined,
|
|
||||||
}), "https://github.com/foo/bar");
|
|
||||||
t.deepEqual(externalQueries.buildCheckoutURL("foo/bar", {
|
|
||||||
url: "https://github.example.com/",
|
|
||||||
externalRepoAuth: undefined,
|
|
||||||
}), "https://github.example.com/foo/bar");
|
|
||||||
t.deepEqual(externalQueries.buildCheckoutURL("foo/bar", {
|
|
||||||
url: "https://github.com",
|
|
||||||
externalRepoAuth: "abc",
|
|
||||||
}), "https://x-access-token:abc@github.com/foo/bar");
|
|
||||||
t.deepEqual(externalQueries.buildCheckoutURL("foo/bar", {
|
|
||||||
url: "https://github.example.com/",
|
|
||||||
externalRepoAuth: "abc",
|
|
||||||
}), "https://x-access-token:abc@github.example.com/foo/bar");
|
|
||||||
});
|
|
||||||
//# sourceMappingURL=external-queries.test.js.map
|
//# sourceMappingURL=external-queries.test.js.map
|
||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"external-queries.test.js","sourceRoot":"","sources":["../src/external-queries.test.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,yEAA2D;AAC3D,kEAAoD;AACpD,8CAAuB;AAEvB,oEAAsD;AACtD,uCAA4C;AAC5C,mDAA6C;AAC7C,6CAA+B;AAE/B,0BAAU,CAAC,aAAI,CAAC,CAAC;AAEjB,aAAI,CAAC,yBAAyB,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAC1C,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;QACrC,kDAAkD;QAClD,mFAAmF;QACnF,gDAAgD;QAChD,wCAAwC;QACxC,8EAA8E;QAC9E,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;QAC3D,MAAM,QAAQ,GAAG,WAAW,CAAC;QAC7B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC;QACtD,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAE/C,oDAAoD;QACpD,oCAAoC;QACpC,2DAA2D;QAC3D,MAAM,MAAM,GAAG,KAAK,WAAW,OAAiB;YAC9C,IAAI,MAAM,GAAG,EAAE,CAAC;YAChB,IAAI,MAAM,GAAG,EAAE,CAAC;YAChB,OAAO,GAAG;gBACR,aAAa,UAAU,EAAE;gBACzB,eAAe,QAAQ,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C,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;QAC/D,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;QACpE,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;IACvE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
||||||
28
lib/fingerprints.js
generated
28
lib/fingerprints.js
generated
@@ -46,7 +46,7 @@ function hash(callback, input) {
|
|||||||
// Indexes match up with those from the window variable.
|
// Indexes match up with those from the window variable.
|
||||||
const lineNumbers = Array(BLOCK_SIZE).fill(-1);
|
const lineNumbers = Array(BLOCK_SIZE).fill(-1);
|
||||||
// The current hash value, updated as we read each character
|
// The current hash value, updated as we read each character
|
||||||
let hashRaw = long_1.default.ZERO;
|
let hash = long_1.default.ZERO;
|
||||||
const firstMod = computeFirstMod();
|
const firstMod = computeFirstMod();
|
||||||
// The current index in the window, will wrap around to zero when we reach BLOCK_SIZE
|
// The current index in the window, will wrap around to zero when we reach BLOCK_SIZE
|
||||||
let index = 0;
|
let index = 0;
|
||||||
@@ -61,7 +61,7 @@ function hash(callback, input) {
|
|||||||
const hashCounts = {};
|
const hashCounts = {};
|
||||||
// Output the current hash and line number to the callback function
|
// Output the current hash and line number to the callback function
|
||||||
const outputHash = function () {
|
const outputHash = function () {
|
||||||
const hashValue = hashRaw.toUnsigned().toString(16);
|
const hashValue = hash.toUnsigned().toString(16);
|
||||||
if (!hashCounts[hashValue]) {
|
if (!hashCounts[hashValue]) {
|
||||||
hashCounts[hashValue] = 0;
|
hashCounts[hashValue] = 0;
|
||||||
}
|
}
|
||||||
@@ -73,7 +73,7 @@ function hash(callback, input) {
|
|||||||
const updateHash = function (current) {
|
const updateHash = function (current) {
|
||||||
const begin = window[index];
|
const begin = window[index];
|
||||||
window[index] = current;
|
window[index] = current;
|
||||||
hashRaw = MOD.multiply(hashRaw)
|
hash = MOD.multiply(hash)
|
||||||
.add(long_1.default.fromInt(current))
|
.add(long_1.default.fromInt(current))
|
||||||
.subtract(firstMod.multiply(long_1.default.fromInt(begin)));
|
.subtract(firstMod.multiply(long_1.default.fromInt(begin)));
|
||||||
index = (index + 1) % BLOCK_SIZE;
|
index = (index + 1) % BLOCK_SIZE;
|
||||||
@@ -120,7 +120,7 @@ function hash(callback, input) {
|
|||||||
}
|
}
|
||||||
exports.hash = hash;
|
exports.hash = hash;
|
||||||
// Generate a hash callback function that updates the given result in-place
|
// Generate a hash callback function that updates the given result in-place
|
||||||
// when it receives a hash for the correct line number. Ignores hashes for other lines.
|
// when it recieves a hash for the correct line number. Ignores hashes for other lines.
|
||||||
function locationUpdateCallback(result, location, logger) {
|
function locationUpdateCallback(result, location, logger) {
|
||||||
var _a, _b;
|
var _a, _b;
|
||||||
let locationStartLine = (_b = (_a = location.physicalLocation) === null || _a === void 0 ? void 0 : _a.region) === null || _b === void 0 ? void 0 : _b.startLine;
|
let locationStartLine = (_b = (_a = location.physicalLocation) === null || _a === void 0 ? void 0 : _a.region) === null || _b === void 0 ? void 0 : _b.startLine;
|
||||||
@@ -130,7 +130,7 @@ function locationUpdateCallback(result, location, logger) {
|
|||||||
// using the hash of the first line of the file.
|
// using the hash of the first line of the file.
|
||||||
locationStartLine = 1;
|
locationStartLine = 1;
|
||||||
}
|
}
|
||||||
return function (lineNumber, hashValue) {
|
return function (lineNumber, hash) {
|
||||||
// Ignore hashes for lines that don't concern us
|
// Ignore hashes for lines that don't concern us
|
||||||
if (locationStartLine !== lineNumber) {
|
if (locationStartLine !== lineNumber) {
|
||||||
return;
|
return;
|
||||||
@@ -142,10 +142,10 @@ function locationUpdateCallback(result, location, logger) {
|
|||||||
// If the hash doesn't match the existing fingerprint then
|
// If the hash doesn't match the existing fingerprint then
|
||||||
// output a warning and don't overwrite it.
|
// output a warning and don't overwrite it.
|
||||||
if (!existingFingerprint) {
|
if (!existingFingerprint) {
|
||||||
result.partialFingerprints.primaryLocationLineHash = hashValue;
|
result.partialFingerprints.primaryLocationLineHash = hash;
|
||||||
}
|
}
|
||||||
else if (existingFingerprint !== hashValue) {
|
else if (existingFingerprint !== hash) {
|
||||||
logger.warning(`Calculated fingerprint of ${hashValue} for file ${location.physicalLocation.artifactLocation.uri} line ${lineNumber}, but found existing inconsistent fingerprint value ${existingFingerprint}`);
|
logger.warning(`Calculated fingerprint of ${hash} for file ${location.physicalLocation.artifactLocation.uri} line ${lineNumber}, but found existing inconsistent fingerprint value ${existingFingerprint}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -160,14 +160,14 @@ function resolveUriToFile(location, artifacts, checkoutPath, logger) {
|
|||||||
location.index < 0 ||
|
location.index < 0 ||
|
||||||
location.index >= artifacts.length ||
|
location.index >= artifacts.length ||
|
||||||
typeof artifacts[location.index].location !== "object") {
|
typeof artifacts[location.index].location !== "object") {
|
||||||
logger.debug(`Ignoring location as index "${location.index}" is invalid`);
|
logger.debug(`Ignoring location as URI "${location.index}" is invalid`);
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
location = artifacts[location.index].location;
|
location = artifacts[location.index].location;
|
||||||
}
|
}
|
||||||
// Get the URI and decode
|
// Get the URI and decode
|
||||||
if (typeof location.uri !== "string") {
|
if (typeof location.uri !== "string") {
|
||||||
logger.debug(`Ignoring location as URI "${location.uri}" is invalid`);
|
logger.debug(`Ignoring location as index "${location.uri}" is invalid`);
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
let uri = decodeURIComponent(location.uri);
|
let uri = decodeURIComponent(location.uri);
|
||||||
@@ -197,10 +197,6 @@ function resolveUriToFile(location, artifacts, checkoutPath, logger) {
|
|||||||
logger.debug(`Unable to compute fingerprint for non-existent file: ${uri}`);
|
logger.debug(`Unable to compute fingerprint for non-existent file: ${uri}`);
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
if (fs.statSync(uri).isDirectory()) {
|
|
||||||
logger.debug(`Unable to compute fingerprint for directory: ${uri}`);
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return uri;
|
return uri;
|
||||||
}
|
}
|
||||||
exports.resolveUriToFile = resolveUriToFile;
|
exports.resolveUriToFile = resolveUriToFile;
|
||||||
@@ -235,9 +231,9 @@ function addFingerprints(sarifContents, checkoutPath, logger) {
|
|||||||
// Now hash each file that was found
|
// Now hash each file that was found
|
||||||
for (const [filepath, callbacks] of Object.entries(callbacksByFile)) {
|
for (const [filepath, callbacks] of Object.entries(callbacksByFile)) {
|
||||||
// A callback that forwards the hash to all other callbacks for that file
|
// A callback that forwards the hash to all other callbacks for that file
|
||||||
const teeCallback = function (lineNumber, hashValue) {
|
const teeCallback = function (lineNumber, hash) {
|
||||||
for (const c of Object.values(callbacks)) {
|
for (const c of Object.values(callbacks)) {
|
||||||
c(lineNumber, hashValue);
|
c(lineNumber, hash);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const fileContents = fs.readFileSync(filepath).toString();
|
const fileContents = fs.readFileSync(filepath).toString();
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
24
lib/fingerprints.test.js
generated
24
lib/fingerprints.test.js
generated
@@ -1,4 +1,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
@@ -6,13 +9,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
result["default"] = mod;
|
result["default"] = 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 ava_1 = __importDefault(require("ava"));
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const ava_1 = __importDefault(require("ava"));
|
|
||||||
const fingerprints = __importStar(require("./fingerprints"));
|
const fingerprints = __importStar(require("./fingerprints"));
|
||||||
const logging_1 = require("./logging");
|
const logging_1 = require("./logging");
|
||||||
const testing_utils_1 = require("./testing-utils");
|
const testing_utils_1 = require("./testing-utils");
|
||||||
@@ -108,9 +108,7 @@ ava_1.default("hash", (t) => {
|
|||||||
});
|
});
|
||||||
function testResolveUriToFile(uri, index, artifactsURIs) {
|
function testResolveUriToFile(uri, index, artifactsURIs) {
|
||||||
const location = { uri, index };
|
const location = { uri, index };
|
||||||
const artifacts = artifactsURIs.map((artifactURI) => ({
|
const artifacts = artifactsURIs.map((uri) => ({ location: { uri } }));
|
||||||
location: { uri: artifactURI },
|
|
||||||
}));
|
|
||||||
return fingerprints.resolveUriToFile(location, artifacts, process.cwd(), logging_1.getRunnerLogger(true));
|
return fingerprints.resolveUriToFile(location, artifacts, process.cwd(), logging_1.getRunnerLogger(true));
|
||||||
}
|
}
|
||||||
ava_1.default("resolveUriToFile", (t) => {
|
ava_1.default("resolveUriToFile", (t) => {
|
||||||
@@ -121,13 +119,13 @@ ava_1.default("resolveUriToFile", (t) => {
|
|||||||
const cwd = process.cwd();
|
const cwd = process.cwd();
|
||||||
const filepath = __filename;
|
const filepath = __filename;
|
||||||
t.true(filepath.startsWith(`${cwd}/`));
|
t.true(filepath.startsWith(`${cwd}/`));
|
||||||
const relativeFilepath = filepath.substring(cwd.length + 1);
|
const relativeFilepaht = filepath.substring(cwd.length + 1);
|
||||||
// Absolute paths are unmodified
|
// Absolute paths are unmodified
|
||||||
t.is(testResolveUriToFile(filepath, undefined, []), filepath);
|
t.is(testResolveUriToFile(filepath, undefined, []), filepath);
|
||||||
t.is(testResolveUriToFile(`file://${filepath}`, undefined, []), filepath);
|
t.is(testResolveUriToFile(`file://${filepath}`, undefined, []), filepath);
|
||||||
// Relative paths are made absolute
|
// Relative paths are made absolute
|
||||||
t.is(testResolveUriToFile(relativeFilepath, undefined, []), filepath);
|
t.is(testResolveUriToFile(relativeFilepaht, undefined, []), filepath);
|
||||||
t.is(testResolveUriToFile(`file://${relativeFilepath}`, undefined, []), filepath);
|
t.is(testResolveUriToFile(`file://${relativeFilepaht}`, undefined, []), filepath);
|
||||||
// Absolute paths outside the src root are discarded
|
// Absolute paths outside the src root are discarded
|
||||||
t.is(testResolveUriToFile("/src/foo/bar.js", undefined, []), undefined);
|
t.is(testResolveUriToFile("/src/foo/bar.js", undefined, []), undefined);
|
||||||
t.is(testResolveUriToFile("file:///src/foo/bar.js", undefined, []), undefined);
|
t.is(testResolveUriToFile("file:///src/foo/bar.js", undefined, []), undefined);
|
||||||
@@ -137,7 +135,7 @@ ava_1.default("resolveUriToFile", (t) => {
|
|||||||
// Invalid URIs are discarded
|
// Invalid URIs are discarded
|
||||||
t.is(testResolveUriToFile(1, undefined, []), undefined);
|
t.is(testResolveUriToFile(1, undefined, []), undefined);
|
||||||
t.is(testResolveUriToFile(undefined, undefined, []), undefined);
|
t.is(testResolveUriToFile(undefined, undefined, []), undefined);
|
||||||
// Non-existent files are discarded
|
// Non-existant files are discarded
|
||||||
t.is(testResolveUriToFile(`${filepath}2`, undefined, []), undefined);
|
t.is(testResolveUriToFile(`${filepath}2`, undefined, []), undefined);
|
||||||
// Index is resolved
|
// Index is resolved
|
||||||
t.is(testResolveUriToFile(undefined, 0, [filepath]), filepath);
|
t.is(testResolveUriToFile(undefined, 0, [filepath]), filepath);
|
||||||
@@ -145,10 +143,6 @@ ava_1.default("resolveUriToFile", (t) => {
|
|||||||
// Invalid indexes are discarded
|
// Invalid indexes are discarded
|
||||||
t.is(testResolveUriToFile(undefined, 1, [filepath]), undefined);
|
t.is(testResolveUriToFile(undefined, 1, [filepath]), undefined);
|
||||||
t.is(testResolveUriToFile(undefined, "0", [filepath]), undefined);
|
t.is(testResolveUriToFile(undefined, "0", [filepath]), undefined);
|
||||||
// Directories are discarded
|
|
||||||
const dirpath = __dirname;
|
|
||||||
t.is(testResolveUriToFile(dirpath, undefined, []), undefined);
|
|
||||||
t.is(testResolveUriToFile(`file://${dirpath}`, undefined, []), undefined);
|
|
||||||
});
|
});
|
||||||
ava_1.default("addFingerprints", (t) => {
|
ava_1.default("addFingerprints", (t) => {
|
||||||
// Run an end-to-end test on a test file
|
// Run an end-to-end test on a test file
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
53
lib/init-action.js
generated
53
lib/init-action.js
generated
@@ -10,11 +10,9 @@ 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 init_1 = require("./init");
|
const init_1 = require("./init");
|
||||||
const languages_1 = require("./languages");
|
|
||||||
const logging_1 = require("./logging");
|
const logging_1 = require("./logging");
|
||||||
const repository_1 = require("./repository");
|
const repository_1 = require("./repository");
|
||||||
const util_1 = require("./util");
|
async function sendSuccessStatusReport(startedAt, config) {
|
||||||
async function sendSuccessStatusReport(startedAt, config, toolsVersion) {
|
|
||||||
var _a;
|
var _a;
|
||||||
const statusReportBase = await actionsUtil.createStatusReportBase("init", "success", startedAt);
|
const statusReportBase = await actionsUtil.createStatusReportBase("init", "success", startedAt);
|
||||||
const languages = config.languages.join(",");
|
const languages = config.languages.join(",");
|
||||||
@@ -43,8 +41,6 @@ async function sendSuccessStatusReport(startedAt, config, toolsVersion) {
|
|||||||
paths_ignore: pathsIgnore,
|
paths_ignore: pathsIgnore,
|
||||||
disable_default_queries: disableDefaultQueries,
|
disable_default_queries: disableDefaultQueries,
|
||||||
queries: queries.join(","),
|
queries: queries.join(","),
|
||||||
tools_input: actionsUtil.getOptionalInput("tools") || "",
|
|
||||||
tools_resolved_version: toolsVersion,
|
|
||||||
};
|
};
|
||||||
await actionsUtil.sendStatusReport(statusReport);
|
await actionsUtil.sendStatusReport(statusReport);
|
||||||
}
|
}
|
||||||
@@ -53,32 +49,18 @@ async function run() {
|
|||||||
const logger = logging_1.getActionsLogger();
|
const logger = logging_1.getActionsLogger();
|
||||||
let config;
|
let config;
|
||||||
let codeql;
|
let codeql;
|
||||||
let toolsVersion;
|
|
||||||
const apiDetails = {
|
|
||||||
auth: actionsUtil.getRequiredInput("token"),
|
|
||||||
externalRepoAuth: actionsUtil.getOptionalInput("external-repository-token"),
|
|
||||||
url: actionsUtil.getRequiredEnvParam("GITHUB_SERVER_URL"),
|
|
||||||
};
|
|
||||||
const gitHubVersion = await util_1.getGitHubVersion(apiDetails);
|
|
||||||
util_1.checkGitHubVersionInRange(gitHubVersion, "actions", logger);
|
|
||||||
try {
|
try {
|
||||||
actionsUtil.prepareLocalRunEnvironment();
|
actionsUtil.prepareLocalRunEnvironment();
|
||||||
const workflowErrors = await actionsUtil.validateWorkflow();
|
if (!(await actionsUtil.sendStatusReport(await actionsUtil.createStatusReportBase("init", "starting", startedAt), true))) {
|
||||||
if (!(await actionsUtil.sendStatusReport(await actionsUtil.createStatusReportBase("init", "starting", startedAt, workflowErrors)))) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const initCodeQLResult = await init_1.initCodeQL(actionsUtil.getOptionalInput("tools"), apiDetails, actionsUtil.getTemporaryDirectory(), actionsUtil.getToolCacheDirectory(), "actions", gitHubVersion.type, logger);
|
codeql = await init_1.initCodeQL(actionsUtil.getOptionalInput("tools"), actionsUtil.getRequiredInput("token"), actionsUtil.getRequiredEnvParam("GITHUB_SERVER_URL"), actionsUtil.getRequiredEnvParam("RUNNER_TEMP"), actionsUtil.getRequiredEnvParam("RUNNER_TOOL_CACHE"), "actions", logger);
|
||||||
codeql = initCodeQLResult.codeql;
|
config = await init_1.initConfig(actionsUtil.getOptionalInput("languages"), actionsUtil.getOptionalInput("queries"), actionsUtil.getOptionalInput("config-file"), repository_1.parseRepositoryNwo(actionsUtil.getRequiredEnvParam("GITHUB_REPOSITORY")), actionsUtil.getRequiredEnvParam("RUNNER_TEMP"), actionsUtil.getRequiredEnvParam("RUNNER_TOOL_CACHE"), codeql, actionsUtil.getRequiredEnvParam("GITHUB_WORKSPACE"), actionsUtil.getRequiredInput("token"), actionsUtil.getRequiredEnvParam("GITHUB_SERVER_URL"), logger);
|
||||||
toolsVersion = initCodeQLResult.toolsVersion;
|
try {
|
||||||
config = await init_1.initConfig(actionsUtil.getOptionalInput("languages"), actionsUtil.getOptionalInput("queries"), actionsUtil.getOptionalInput("config-file"), repository_1.parseRepositoryNwo(actionsUtil.getRequiredEnvParam("GITHUB_REPOSITORY")), actionsUtil.getTemporaryDirectory(), actionsUtil.getRequiredEnvParam("RUNNER_TOOL_CACHE"), codeql, actionsUtil.getRequiredEnvParam("GITHUB_WORKSPACE"), gitHubVersion, apiDetails, logger);
|
await init_1.installPythonDeps(codeql, logger);
|
||||||
if (config.languages.includes(languages_1.Language.python) &&
|
}
|
||||||
actionsUtil.getRequiredInput("setup-python-dependencies") === "true") {
|
catch (err) {
|
||||||
try {
|
logger.warning(`${err.message} You can call this action with 'setup-python-dependencies: false' to disable this process`);
|
||||||
await init_1.installPythonDeps(codeql, logger);
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
logger.warning(`${err.message} You can call this action with 'setup-python-dependencies: false' to disable this process`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
@@ -106,7 +88,6 @@ async function run() {
|
|||||||
await init_1.injectWindowsTracer("Runner.Worker.exe", undefined, config, codeql, tracerConfig);
|
await init_1.injectWindowsTracer("Runner.Worker.exe", undefined, config, codeql, tracerConfig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
core.setOutput("codeql-path", config.codeQLCmd);
|
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
@@ -114,16 +95,10 @@ async function run() {
|
|||||||
await actionsUtil.sendStatusReport(await actionsUtil.createStatusReportBase("init", "failure", startedAt, error.message, error.stack));
|
await actionsUtil.sendStatusReport(await actionsUtil.createStatusReportBase("init", "failure", startedAt, error.message, error.stack));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await sendSuccessStatusReport(startedAt, config, toolsVersion);
|
await sendSuccessStatusReport(startedAt, config);
|
||||||
}
|
}
|
||||||
async function runWrapper() {
|
run().catch((e) => {
|
||||||
try {
|
core.setFailed(`init action failed: ${e}`);
|
||||||
await run();
|
console.log(e);
|
||||||
}
|
});
|
||||||
catch (error) {
|
|
||||||
core.setFailed(`init action failed: ${error}`);
|
|
||||||
console.log(error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void runWrapper();
|
|
||||||
//# sourceMappingURL=init-action.js.map
|
//# sourceMappingURL=init-action.js.map
|
||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"init-action.js","sourceRoot":"","sources":["../src/init-action.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAsC;AAEtC,4DAA8C;AAG9C,iCAMgB;AAChB,2CAAuC;AACvC,uCAA6C;AAC7C,6CAAkD;AAClD,iCAAqE;AAsBrE,KAAK,UAAU,uBAAuB,CACpC,SAAe,EACf,MAA0B,EAC1B,YAAoB;;IAEpB,MAAM,gBAAgB,GAAG,MAAM,WAAW,CAAC,sBAAsB,CAC/D,MAAM,EACN,SAAS,EACT,SAAS,CACV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AAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;IAChB,IAAI,CAAC,SAAS,CAAC,uBAAuB,CAAC,EAAE,CAAC,CAAC;IAC3C,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACjB,CAAC,CAAC,CAAC"}
|
||||||
51
lib/init.js
generated
51
lib/init.js
generated
@@ -7,26 +7,25 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
const toolrunnner = __importStar(require("@actions/exec/lib/toolrunner"));
|
||||||
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 safeWhich = __importStar(require("@chrisgavin/safe-which"));
|
|
||||||
const analysisPaths = __importStar(require("./analysis-paths"));
|
const analysisPaths = __importStar(require("./analysis-paths"));
|
||||||
const codeql_1 = require("./codeql");
|
const codeql_1 = require("./codeql");
|
||||||
const configUtils = __importStar(require("./config-utils"));
|
const configUtils = __importStar(require("./config-utils"));
|
||||||
const tracer_config_1 = require("./tracer-config");
|
const tracer_config_1 = require("./tracer-config");
|
||||||
const util = __importStar(require("./util"));
|
const util = __importStar(require("./util"));
|
||||||
async function initCodeQL(codeqlURL, apiDetails, tempDir, toolCacheDir, mode, variant, logger) {
|
async function initCodeQL(codeqlURL, githubAuth, githubUrl, tempDir, toolsDir, mode, logger) {
|
||||||
logger.startGroup("Setup CodeQL tools");
|
logger.startGroup("Setup CodeQL tools");
|
||||||
const { codeql, toolsVersion } = await codeql_1.setupCodeQL(codeqlURL, apiDetails, tempDir, toolCacheDir, mode, variant, logger);
|
const codeql = await codeql_1.setupCodeQL(codeqlURL, githubAuth, githubUrl, tempDir, toolsDir, mode, logger);
|
||||||
await codeql.printVersion();
|
await codeql.printVersion();
|
||||||
logger.endGroup();
|
logger.endGroup();
|
||||||
return { codeql, toolsVersion };
|
return codeql;
|
||||||
}
|
}
|
||||||
exports.initCodeQL = initCodeQL;
|
exports.initCodeQL = initCodeQL;
|
||||||
async function initConfig(languagesInput, queriesInput, configFile, repository, tempDir, toolCacheDir, codeQL, checkoutPath, gitHubVersion, apiDetails, logger) {
|
async function initConfig(languagesInput, queriesInput, configFile, repository, tempDir, toolCacheDir, codeQL, checkoutPath, githubAuth, githubUrl, logger) {
|
||||||
logger.startGroup("Load language configuration");
|
logger.startGroup("Load language configuration");
|
||||||
const config = await configUtils.initConfig(languagesInput, queriesInput, configFile, repository, tempDir, toolCacheDir, codeQL, checkoutPath, gitHubVersion, apiDetails, logger);
|
const config = await configUtils.initConfig(languagesInput, queriesInput, configFile, repository, tempDir, toolCacheDir, codeQL, checkoutPath, githubAuth, githubUrl, logger);
|
||||||
analysisPaths.printPathFiltersWarning(config, logger);
|
analysisPaths.printPathFiltersWarning(config, logger);
|
||||||
logger.endGroup();
|
logger.endGroup();
|
||||||
return config;
|
return config;
|
||||||
@@ -103,10 +102,6 @@ async function injectWindowsTracer(processName, processLevel, config, codeql, tr
|
|||||||
Write-Host "Found Runner.Worker.exe process which means we are running on GitHub Actions"
|
Write-Host "Found Runner.Worker.exe process which means we are running on GitHub Actions"
|
||||||
Write-Host "Aborting search early and using process: $p"
|
Write-Host "Aborting search early and using process: $p"
|
||||||
Break
|
Break
|
||||||
} elseif ($p[0].Name -eq "Agent.Worker.exe") {
|
|
||||||
Write-Host "Found Agent.Worker.exe process which means we are running on Azure Pipelines"
|
|
||||||
Write-Host "Aborting search early and using process: $p"
|
|
||||||
Break
|
|
||||||
} else {
|
} else {
|
||||||
$id = $p[0].ParentProcessId
|
$id = $p[0].ParentProcessId
|
||||||
}
|
}
|
||||||
@@ -117,7 +112,7 @@ async function injectWindowsTracer(processName, processLevel, config, codeql, tr
|
|||||||
}
|
}
|
||||||
const injectTracerPath = path.join(config.tempDir, "inject-tracer.ps1");
|
const injectTracerPath = path.join(config.tempDir, "inject-tracer.ps1");
|
||||||
fs.writeFileSync(injectTracerPath, script);
|
fs.writeFileSync(injectTracerPath, script);
|
||||||
await new toolrunner.ToolRunner(await safeWhich.safeWhich("powershell"), [
|
await new toolrunnner.ToolRunner("powershell", [
|
||||||
"-ExecutionPolicy",
|
"-ExecutionPolicy",
|
||||||
"Bypass",
|
"Bypass",
|
||||||
"-file",
|
"-file",
|
||||||
@@ -128,45 +123,31 @@ async function injectWindowsTracer(processName, processLevel, config, codeql, tr
|
|||||||
exports.injectWindowsTracer = injectWindowsTracer;
|
exports.injectWindowsTracer = injectWindowsTracer;
|
||||||
async function installPythonDeps(codeql, logger) {
|
async function installPythonDeps(codeql, logger) {
|
||||||
logger.startGroup("Setup Python dependencies");
|
logger.startGroup("Setup Python dependencies");
|
||||||
|
if (process.platform !== "linux") {
|
||||||
|
logger.info("Currently, auto-installing python dependancies is only supported on linux");
|
||||||
|
logger.endGroup();
|
||||||
|
return;
|
||||||
|
}
|
||||||
const scriptsFolder = path.resolve(__dirname, "../python-setup");
|
const scriptsFolder = path.resolve(__dirname, "../python-setup");
|
||||||
// Setup tools on the GitHub hosted runners
|
// Setup tools on the Github hosted runners
|
||||||
if (process.env["ImageOS"] !== undefined) {
|
if (process.env["ImageOS"] !== undefined) {
|
||||||
try {
|
try {
|
||||||
if (process.platform === "win32") {
|
await new toolrunnner.ToolRunner(path.join(scriptsFolder, "install_tools.sh")).exec();
|
||||||
await new toolrunner.ToolRunner(await safeWhich.safeWhich("powershell"), [path.join(scriptsFolder, "install_tools.ps1")]).exec();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
await new toolrunner.ToolRunner(path.join(scriptsFolder, "install_tools.sh")).exec();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
// This script tries to install some needed tools in the runner. It should not fail, but if it does
|
// This script tries to install some needed tools in the runner. It should not fail, but if it does
|
||||||
// we just abort the process without failing the action
|
// we just abort the process without failing the action
|
||||||
logger.endGroup();
|
logger.endGroup();
|
||||||
logger.warning("Unable to download and extract the tools needed for installing the python dependencies. You can call this action with 'setup-python-dependencies: false' to disable this process.");
|
logger.warning("Unable to download and extract the tools needed for installing the python dependecies. You can call this action with 'setup-python-dependencies: false' to disable this process.");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Install dependencies
|
// Install dependencies
|
||||||
try {
|
try {
|
||||||
const script = "auto_install_packages.py";
|
await new toolrunnner.ToolRunner(path.join(scriptsFolder, "auto_install_packages.py"), [path.dirname(codeql.getPath())]).exec();
|
||||||
if (process.platform === "win32") {
|
|
||||||
await new toolrunner.ToolRunner(await safeWhich.safeWhich("py"), [
|
|
||||||
"-3",
|
|
||||||
path.join(scriptsFolder, script),
|
|
||||||
path.dirname(codeql.getPath()),
|
|
||||||
]).exec();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
await new toolrunner.ToolRunner(path.join(scriptsFolder, script), [
|
|
||||||
path.dirname(codeql.getPath()),
|
|
||||||
]).exec();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
logger.endGroup();
|
logger.endGroup();
|
||||||
logger.warning("We were unable to install your python dependencies. You can call this action with 'setup-python-dependencies: false' to disable this process.");
|
logger.warning("We were unable to install your python dependencies. You can call this action with 'setup-python-dependencies: false' to disable this process.");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
logger.endGroup();
|
logger.endGroup();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,qCAA+C;AAC/C,4DAA8C;AAG9C,mDAAwE;AACxE,6CAA+B;AAExB,K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AAC;IAEjE,2CAA2C;IAC3C,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,SAAS,EAAE;QACxC,IAAI;YACF,MAAM,IAAI,WAAW,CAAC,UAAU,CAC9B,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAC7C,CAAC,IAAI,EAAE,CAAC;SACV;QAAC,OAAO,CAAC,EAAE;YACV,mGAAmG;YACnG,uDAAuD;YACvD,MAAM,CAAC,QAAQ,EAAE,CAAC;YAClB,MAAM,CAAC,OAAO,CACZ,kLAAkL,CACnL,CAAC;SACH;KACF;IAED,uBAAuB;IACvB,IAAI;QACF,MAAM,IAAI,WAAW,CAAC,UAAU,CAC9B,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,0BAA0B,CAAC,EACpD,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CACjC,CAAC,IAAI,EAAE,CAAC;KACV;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,CAAC,QAAQ,EAAE,CAAC;QAClB,MAAM,CAAC,OAAO,CACZ,+IAA+I,CAChJ,CAAC;KACH;IACD,MAAM,CAAC,QAAQ,EAAE,CAAC;AACpB,CAAC;AA1CD,8CA0CC"}
|
||||||
4
lib/languages.js
generated
4
lib/languages.js
generated
@@ -33,9 +33,7 @@ function parseLanguage(language) {
|
|||||||
}
|
}
|
||||||
exports.parseLanguage = parseLanguage;
|
exports.parseLanguage = parseLanguage;
|
||||||
function isTracedLanguage(language) {
|
function isTracedLanguage(language) {
|
||||||
return (["cpp", "java", "csharp"].includes(language) ||
|
return ["cpp", "java", "csharp"].includes(language);
|
||||||
(process.env["CODEQL_EXTRACTOR_GO_BUILD_TRACING"] === "on" &&
|
|
||||||
language === Language.go));
|
|
||||||
}
|
}
|
||||||
exports.isTracedLanguage = isTracedLanguage;
|
exports.isTracedLanguage = isTracedLanguage;
|
||||||
function isScannedLanguage(language) {
|
function isScannedLanguage(language) {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C,CAAC;AACrC,CAAC;AAFD,8CAEC"}
|
{"version":3,"file":"languages.js","sourceRoot":"","sources":["../src/languages.ts"],"names":[],"mappings":";;AAAA,wCAAwC;AACxC,IAAY,QAOX;AAPD,WAAY,QAAQ;IAClB,6BAAiB,CAAA;IACjB,uBAAW,CAAA;IACX,qBAAS,CAAA;IACT,yBAAa,CAAA;IACb,qCAAyB,CAAA;IACzB,6BAAiB,CAAA;AACnB,CAAC,EAPW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAOnB;AAED,iCAAiC;AACjC,MAAM,gBAAgB,GAAiC;IACrD,CAAC,EAAE,QAAQ,CAAC,GAAG;IACf,KAAK,EAAE,QAAQ,CAAC,GAAG;IACnB,IAAI,EAAE,QAAQ,CAAC,MAAM;IACrB,UAAU,EAAE,QAAQ,CAAC,UAAU;CAChC,CAAC;AAEF,gGAAgG;AAChG,SAAgB,aAAa,CAAC,QAAgB;IAC5C,0BAA0B;IAC1B,QAAQ,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;IAElC,6BAA6B;IAC7B,IAAI,QAAQ,IAAI,QAAQ,EAAE;QACxB,OAAO,QAAoB,CAAC;KAC7B;IAED,yBAAyB;IACzB,IAAI,QAAQ,IAAI,gBAAgB,EAAE;QAChC,OAAO,gBAAgB,CAAC,QAAQ,CAAC,CAAC;KACnC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAfD,sCAeC;AAED,SAAgB,gBAAgB,CAAC,QAAkB;IACjD,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACtD,CAAC;AAFD,4CAEC;AAED,SAAgB,iBAAiB,CAAC,QAAkB;IAClD,OAAO,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;AACrC,CAAC;AAFD,8CAEC"}
|
||||||
2
lib/languages.test.js
generated
2
lib/languages.test.js
generated
@@ -7,7 +7,7 @@ const ava_1 = __importDefault(require("ava"));
|
|||||||
const languages_1 = require("./languages");
|
const languages_1 = require("./languages");
|
||||||
const testing_utils_1 = require("./testing-utils");
|
const testing_utils_1 = require("./testing-utils");
|
||||||
testing_utils_1.setupTests(ava_1.default);
|
testing_utils_1.setupTests(ava_1.default);
|
||||||
ava_1.default("parseLanguage", async (t) => {
|
ava_1.default("parseLangauge", async (t) => {
|
||||||
// Exact matches
|
// Exact matches
|
||||||
t.deepEqual(languages_1.parseLanguage("csharp"), languages_1.Language.csharp);
|
t.deepEqual(languages_1.parseLanguage("csharp"), languages_1.Language.csharp);
|
||||||
t.deepEqual(languages_1.parseLanguage("cpp"), languages_1.Language.cpp);
|
t.deepEqual(languages_1.parseLanguage("cpp"), languages_1.Language.cpp);
|
||||||
|
|||||||
1
lib/logging.js
generated
1
lib/logging.js
generated
@@ -18,7 +18,6 @@ function getRunnerLogger(debugMode) {
|
|||||||
info: console.info,
|
info: console.info,
|
||||||
warning: console.warn,
|
warning: console.warn,
|
||||||
error: console.error,
|
error: console.error,
|
||||||
isDebug: () => debugMode,
|
|
||||||
startGroup: () => undefined,
|
startGroup: () => undefined,
|
||||||
endGroup: () => undefined,
|
endGroup: () => undefined,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"logging.js","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAsC;AActC,SAAgB,gBAAgB;IAC9B,OAAO,IAAI,CAAC;AACd,CAAC;AAFD,4CAEC;AAED,SAAgB,eAAe,CAAC,SAAkB;IAChD,OAAO;QACL,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,SAAS;QAClD,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,OAAO,EAAE,OAAO,CAAC,IAAI;QACrB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS;QACxB,UAAU,EAAE,GAAG,EAAE,CAAC,SAAS;QAC3B,QAAQ,EAAE,GAAG,EAAE,CAAC,SAAS;KAC1B,CAAC;AACJ,CAAC;AAVD,0CAUC"}
|
{"version":3,"file":"logging.js","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":";;;;;;;;;AAAA,oDAAsC;AAYtC,SAAgB,gBAAgB;IAC9B,OAAO,IAAI,CAAC;AACd,CAAC;AAFD,4CAEC;AAED,SAAgB,eAAe,CAAC,SAAkB;IAChD,OAAO;QACL,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,SAAS;QAClD,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,OAAO,EAAE,OAAO,CAAC,IAAI;QACrB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,UAAU,EAAE,GAAG,EAAE,CAAC,SAAS;QAC3B,QAAQ,EAAE,GAAG,EAAE,CAAC,SAAS;KAC1B,CAAC;AACJ,CAAC;AATD,0CASC"}
|
||||||
79
lib/runner.js
generated
79
lib/runner.js
generated
@@ -7,10 +7,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
const commander_1 = require("commander");
|
||||||
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 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");
|
||||||
@@ -23,6 +23,24 @@ const upload_lib = __importStar(require("./upload-lib"));
|
|||||||
const util_1 = require("./util");
|
const util_1 = require("./util");
|
||||||
const program = new commander_1.Command();
|
const program = new commander_1.Command();
|
||||||
program.version("0.0.1");
|
program.version("0.0.1");
|
||||||
|
function parseGithubUrl(inputUrl) {
|
||||||
|
try {
|
||||||
|
const url = new URL(inputUrl);
|
||||||
|
// If we detect this is trying to be to github.com
|
||||||
|
// then return with a fixed canonical URL.
|
||||||
|
if (url.hostname === "github.com" || url.hostname === "api.github.com") {
|
||||||
|
return "https://github.com";
|
||||||
|
}
|
||||||
|
// Remove the API prefix if it's present
|
||||||
|
if (url.pathname.indexOf("/api/v3") !== -1) {
|
||||||
|
url.pathname = url.pathname.substring(0, url.pathname.indexOf("/api/v3"));
|
||||||
|
}
|
||||||
|
return url.toString();
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
throw new Error(`"${inputUrl}" is not a valid URL`);
|
||||||
|
}
|
||||||
|
}
|
||||||
function getTempDir(userInput) {
|
function getTempDir(userInput) {
|
||||||
const tempDir = path.join(userInput || process.cwd(), "codeql-runner");
|
const tempDir = path.join(userInput || process.cwd(), "codeql-runner");
|
||||||
if (!fs.existsSync(tempDir)) {
|
if (!fs.existsSync(tempDir)) {
|
||||||
@@ -82,8 +100,7 @@ program
|
|||||||
.description("Initializes CodeQL")
|
.description("Initializes CodeQL")
|
||||||
.requiredOption("--repository <repository>", "Repository name. (Required)")
|
.requiredOption("--repository <repository>", "Repository name. (Required)")
|
||||||
.requiredOption("--github-url <url>", "URL of GitHub instance. (Required)")
|
.requiredOption("--github-url <url>", "URL of GitHub instance. (Required)")
|
||||||
.option("--github-auth <auth>", "GitHub Apps token or personal access token. This option is insecure and deprecated, please use `--github-auth-stdin` instead.")
|
.requiredOption("--github-auth <auth>", "GitHub Apps token or personal access token. (Required)")
|
||||||
.option("--github-auth-stdin", "Read GitHub Apps token or personal access token from stdin.")
|
|
||||||
.option("--languages <languages>", "Comma-separated list of languages to analyze. Otherwise detects and analyzes all supported languages from the repo.")
|
.option("--languages <languages>", "Comma-separated list of languages to analyze. Otherwise detects and analyzes all supported languages from the repo.")
|
||||||
.option("--queries <queries>", "Comma-separated list of additional queries to run. This overrides the same setting in a configuration file.")
|
.option("--queries <queries>", "Comma-separated list of additional queries to run. This overrides the same setting in a configuration file.")
|
||||||
.option("--config-file <file>", "Path to config file.")
|
.option("--config-file <file>", "Path to config file.")
|
||||||
@@ -92,8 +109,9 @@ program
|
|||||||
.option("--tools-dir <dir>", "Directory to use for CodeQL tools and other files to store between runs. Default is a subdirectory of the home directory.")
|
.option("--tools-dir <dir>", "Directory to use for CodeQL tools and other files to store between runs. Default is a subdirectory of the home directory.")
|
||||||
.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("--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.")
|
// This prevents a message like: error: unknown option '--trace-process-level'
|
||||||
.option("--trace-process-level <number>", "(Advanced, windows-only) Inject a windows tracer of this process into a parent process <number> levels up.")
|
// Remove this if commander.js starts supporting hidden options.
|
||||||
|
.allowUnknownOption()
|
||||||
.action(async (cmd) => {
|
.action(async (cmd) => {
|
||||||
const logger = logging_1.getRunnerLogger(cmd.debug);
|
const logger = logging_1.getRunnerLogger(cmd.debug);
|
||||||
try {
|
try {
|
||||||
@@ -103,22 +121,14 @@ program
|
|||||||
logger.info(`Cleaning temp directory ${tempDir}`);
|
logger.info(`Cleaning temp directory ${tempDir}`);
|
||||||
fs.rmdirSync(tempDir, { recursive: true });
|
fs.rmdirSync(tempDir, { recursive: true });
|
||||||
fs.mkdirSync(tempDir, { recursive: true });
|
fs.mkdirSync(tempDir, { recursive: true });
|
||||||
const auth = await util_1.getGitHubAuth(logger, cmd.githubAuth, cmd.githubAuthStdin);
|
|
||||||
const apiDetails = {
|
|
||||||
auth,
|
|
||||||
externalRepoAuth: auth,
|
|
||||||
url: util_1.parseGitHubUrl(cmd.githubUrl),
|
|
||||||
};
|
|
||||||
const gitHubVersion = await util_1.getGitHubVersion(apiDetails);
|
|
||||||
util_1.checkGitHubVersionInRange(gitHubVersion, "runner", logger);
|
|
||||||
let codeql;
|
let codeql;
|
||||||
if (cmd.codeqlPath !== undefined) {
|
if (cmd.codeqlPath !== undefined) {
|
||||||
codeql = codeql_1.getCodeQL(cmd.codeqlPath);
|
codeql = codeql_1.getCodeQL(cmd.codeqlPath);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
codeql = (await init_1.initCodeQL(undefined, apiDetails, tempDir, toolsDir, "runner", gitHubVersion.type, logger)).codeql;
|
codeql = await init_1.initCodeQL(undefined, cmd.githubAuth, parseGithubUrl(cmd.githubUrl), tempDir, toolsDir, "runner", logger);
|
||||||
}
|
}
|
||||||
const config = await init_1.initConfig(cmd.languages, cmd.queries, cmd.configFile, repository_1.parseRepositoryNwo(cmd.repository), tempDir, toolsDir, codeql, cmd.checkoutPath || process.cwd(), gitHubVersion, apiDetails, logger);
|
const config = await init_1.initConfig(cmd.languages, cmd.queries, cmd.configFile, repository_1.parseRepositoryNwo(cmd.repository), tempDir, toolsDir, codeql, cmd.checkoutPath || process.cwd(), cmd.githubAuth, parseGithubUrl(cmd.githubUrl), logger);
|
||||||
const tracerConfig = await init_1.runInit(codeql, config);
|
const tracerConfig = await init_1.runInit(codeql, config);
|
||||||
if (tracerConfig === undefined) {
|
if (tracerConfig === undefined) {
|
||||||
return;
|
return;
|
||||||
@@ -126,7 +136,7 @@ program
|
|||||||
if (process.platform === "win32") {
|
if (process.platform === "win32") {
|
||||||
await init_1.injectWindowsTracer(parseTraceProcessName(), parseTraceProcessLevel(), config, codeql, tracerConfig);
|
await init_1.injectWindowsTracer(parseTraceProcessName(), parseTraceProcessLevel(), config, codeql, tracerConfig);
|
||||||
}
|
}
|
||||||
// Always output a json file of the env that can be consumed programmatically
|
// Always output a json file of the env that can be consumed programatically
|
||||||
const jsonEnvFile = path.join(config.tempDir, codeqlEnvJsonFilename);
|
const jsonEnvFile = path.join(config.tempDir, codeqlEnvJsonFilename);
|
||||||
fs.writeFileSync(jsonEnvFile, JSON.stringify(tracerConfig.env));
|
fs.writeFileSync(jsonEnvFile, JSON.stringify(tracerConfig.env));
|
||||||
if (process.platform === "win32") {
|
if (process.platform === "win32") {
|
||||||
@@ -141,7 +151,7 @@ program
|
|||||||
.join("\n");
|
.join("\n");
|
||||||
fs.writeFileSync(powershellEnvFile, powershellEnvFileContents);
|
fs.writeFileSync(powershellEnvFile, powershellEnvFileContents);
|
||||||
logger.info(`\nCodeQL environment output to "${jsonEnvFile}", "${batEnvFile}" and "${powershellEnvFile}". ` +
|
logger.info(`\nCodeQL environment output to "${jsonEnvFile}", "${batEnvFile}" and "${powershellEnvFile}". ` +
|
||||||
`Please export these variables to future processes so that CodeQL can monitor the build. ` +
|
`Please export these variables to future processes so the build can be traced. ` +
|
||||||
`If using cmd/batch run "call ${batEnvFile}" ` +
|
`If using cmd/batch run "call ${batEnvFile}" ` +
|
||||||
`or if using PowerShell run "cat ${powershellEnvFile} | Invoke-Expression".`);
|
`or if using PowerShell run "cat ${powershellEnvFile} | Invoke-Expression".`);
|
||||||
}
|
}
|
||||||
@@ -150,11 +160,11 @@ program
|
|||||||
const shEnvFile = path.join(config.tempDir, "codeql-env.sh");
|
const shEnvFile = path.join(config.tempDir, "codeql-env.sh");
|
||||||
const shEnvFileContents = Object.entries(tracerConfig.env)
|
const shEnvFileContents = Object.entries(tracerConfig.env)
|
||||||
// Some vars contain ${LIB} that we do not want to be expanded when executing this script
|
// Some vars contain ${LIB} that we do not want to be expanded when executing this script
|
||||||
.map(([key, value]) => `export ${key}='${value.replace(/'/g, "'\"'\"'")}'`)
|
.map(([key, value]) => `export ${key}="${value.replace(/\$/g, "\\$")}"`)
|
||||||
.join("\n");
|
.join("\n");
|
||||||
fs.writeFileSync(shEnvFile, shEnvFileContents);
|
fs.writeFileSync(shEnvFile, shEnvFileContents);
|
||||||
logger.info(`\nCodeQL environment output to "${jsonEnvFile}" and "${shEnvFile}". ` +
|
logger.info(`\nCodeQL environment output to "${jsonEnvFile}" and "${shEnvFile}". ` +
|
||||||
`Please export these variables to future processes so that CodeQL can monitor the build, ` +
|
`Please export these variables to future processes so the build can be traced, ` +
|
||||||
`for example by running ". ${shEnvFile}".`);
|
`for example by running ". ${shEnvFile}".`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -207,8 +217,7 @@ program
|
|||||||
.requiredOption("--commit <commit>", "SHA of commit that was analyzed. (Required)")
|
.requiredOption("--commit <commit>", "SHA of commit that was analyzed. (Required)")
|
||||||
.requiredOption("--ref <ref>", "Name of ref that was analyzed. (Required)")
|
.requiredOption("--ref <ref>", "Name of ref that was analyzed. (Required)")
|
||||||
.requiredOption("--github-url <url>", "URL of GitHub instance. (Required)")
|
.requiredOption("--github-url <url>", "URL of GitHub instance. (Required)")
|
||||||
.option("--github-auth <auth>", "GitHub Apps token or personal access token. This option is insecure and deprecated, please use `--github-auth-stdin` instead.")
|
.requiredOption("--github-auth <auth>", "GitHub Apps token or personal access token. (Required)")
|
||||||
.option("--github-auth-stdin", "Read GitHub Apps token or personal access token from stdin.")
|
|
||||||
.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.")
|
||||||
@@ -217,28 +226,18 @@ program
|
|||||||
.option("--threads <threads>", "Number of threads to use when running queries. " +
|
.option("--threads <threads>", "Number of threads to use when running queries. " +
|
||||||
"Default is to use all available cores.")
|
"Default is to use all available cores.")
|
||||||
.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("--debug", "Print more verbose output", false)
|
.option("--debug", "Print more verbose output", false)
|
||||||
.action(async (cmd) => {
|
.action(async (cmd) => {
|
||||||
const logger = logging_1.getRunnerLogger(cmd.debug);
|
const logger = logging_1.getRunnerLogger(cmd.debug);
|
||||||
try {
|
try {
|
||||||
|
const tempDir = getTempDir(cmd.tempDir);
|
||||||
|
const outputDir = cmd.outputDir || path.join(tempDir, "codeql-sarif");
|
||||||
const config = await config_utils_1.getConfig(getTempDir(cmd.tempDir), logger);
|
const config = await config_utils_1.getConfig(getTempDir(cmd.tempDir), logger);
|
||||||
if (config === undefined) {
|
if (config === undefined) {
|
||||||
throw new Error("Config file could not be found at expected location. " +
|
throw new Error("Config file could not be found at expected location. " +
|
||||||
"Was the 'init' command run with the same '--temp-dir' argument as this command.");
|
"Was the 'init' command run with the same '--temp-dir' argument as this command.");
|
||||||
}
|
}
|
||||||
const auth = await util_1.getGitHubAuth(logger, cmd.githubAuth, cmd.githubAuthStdin);
|
await analyze_1.runAnalyze(repository_1.parseRepositoryNwo(cmd.repository), cmd.commit, parseRef(cmd.ref), undefined, undefined, undefined, cmd.checkoutPath || process.cwd(), undefined, cmd.githubAuth, parseGithubUrl(cmd.githubUrl), cmd.upload, "runner", outputDir, util_1.getMemoryFlag(cmd.ram), util_1.getAddSnippetsFlag(cmd.addSnippets), util_1.getThreadsFlag(cmd.threads, logger), config, logger);
|
||||||
const apiDetails = {
|
|
||||||
auth,
|
|
||||||
url: util_1.parseGitHubUrl(cmd.githubUrl),
|
|
||||||
};
|
|
||||||
const outputDir = cmd.outputDir || path.join(config.tempDir, "codeql-sarif");
|
|
||||||
await analyze_1.runAnalyze(outputDir, util_1.getMemoryFlag(cmd.ram), util_1.getAddSnippetsFlag(cmd.addSnippets), util_1.getThreadsFlag(cmd.threads, logger), cmd.category, config, logger);
|
|
||||||
if (!cmd.upload) {
|
|
||||||
logger.info("Not uploading results");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await upload_lib.uploadFromRunner(outputDir, repository_1.parseRepositoryNwo(cmd.repository), cmd.commit, parseRef(cmd.ref), cmd.category, cmd.checkoutPath || process.cwd(), config.gitHubVersion, apiDetails, logger);
|
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
logger.error("Analyze failed");
|
logger.error("Analyze failed");
|
||||||
@@ -254,21 +253,13 @@ program
|
|||||||
.requiredOption("--commit <commit>", "SHA of commit that was analyzed. (Required)")
|
.requiredOption("--commit <commit>", "SHA of commit that was analyzed. (Required)")
|
||||||
.requiredOption("--ref <ref>", "Name of ref that was analyzed. (Required)")
|
.requiredOption("--ref <ref>", "Name of ref that was analyzed. (Required)")
|
||||||
.requiredOption("--github-url <url>", "URL of GitHub instance. (Required)")
|
.requiredOption("--github-url <url>", "URL of GitHub instance. (Required)")
|
||||||
.option("--github-auth <auth>", "GitHub Apps token or personal access token. This option is insecure and deprecated, please use `--github-auth-stdin` instead.")
|
.requiredOption("--github-auth <auth>", "GitHub Apps token or personal access token. (Required)")
|
||||||
.option("--github-auth-stdin", "Read GitHub Apps token or personal access token from stdin.")
|
|
||||||
.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("--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)
|
||||||
.action(async (cmd) => {
|
.action(async (cmd) => {
|
||||||
const logger = logging_1.getRunnerLogger(cmd.debug);
|
const logger = logging_1.getRunnerLogger(cmd.debug);
|
||||||
const auth = await util_1.getGitHubAuth(logger, cmd.githubAuth, cmd.githubAuthStdin);
|
|
||||||
const apiDetails = {
|
|
||||||
auth,
|
|
||||||
url: util_1.parseGitHubUrl(cmd.githubUrl),
|
|
||||||
};
|
|
||||||
try {
|
try {
|
||||||
const gitHubVersion = await util_1.getGitHubVersion(apiDetails);
|
await upload_lib.upload(cmd.sarifFile, repository_1.parseRepositoryNwo(cmd.repository), cmd.commit, parseRef(cmd.ref), undefined, undefined, undefined, cmd.checkoutPath || process.cwd(), undefined, cmd.githubAuth, parseGithubUrl(cmd.githubUrl), "runner", logger);
|
||||||
await upload_lib.uploadFromRunner(cmd.sarifFile, repository_1.parseRepositoryNwo(cmd.repository), cmd.commit, parseRef(cmd.ref), cmd.category, cmd.checkoutPath || process.cwd(), gitHubVersion, apiDetails, logger);
|
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
logger.error("Upload failed");
|
logger.error("Upload failed");
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
6
lib/testdata/testFile3.js
vendored
6
lib/testdata/testFile3.js
vendored
@@ -1,6 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var a;
|
|
||||||
var b;
|
|
||||||
var c;
|
|
||||||
var d;
|
|
||||||
//# sourceMappingURL=testFile3.js.map
|
|
||||||
1
lib/testdata/testFile3.js.map
vendored
1
lib/testdata/testFile3.js.map
vendored
@@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"testFile3.js","sourceRoot":"","sources":["../../src/testdata/testFile3.ts"],"names":[],"mappings":";AAAA,IAAI,CAAC,CAAC;AACN,IAAI,CAAC,CAAC;AACN,IAAI,CAAC,CAAC;AACN,IAAI,CAAC,CAAC"}
|
|
||||||
7
lib/testing-utils.js
generated
7
lib/testing-utils.js
generated
@@ -72,11 +72,4 @@ function setupTests(test) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.setupTests = setupTests;
|
exports.setupTests = setupTests;
|
||||||
// Sets environment variables that make using some libraries designed for
|
|
||||||
// use only on actions safe to use outside of actions.
|
|
||||||
function setupActionsVars(tempDir, toolsDir) {
|
|
||||||
process.env["RUNNER_TEMP"] = tempDir;
|
|
||||||
process.env["RUNNER_TOOL_CACHE"] = toolsDir;
|
|
||||||
}
|
|
||||||
exports.setupActionsVars = setupActionsVars;
|
|
||||||
//# 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":";;;;;;;;;;;;AACA,kDAA0B;AAE1B,iDAAmC;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;IACd,CAAC,CAAC;AACJ,CAAC;AAED,SAAgB,UAAU,CAAC,IAAwB;IACjD,MAAM,SAAS,GAAG,IAAkC,CAAC;IAErD,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE;QACzB,gEAAgE;QAChE,0CAA0C;QAC1C,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;QAErB,iEAAiE;QACjE,CAAC,CAAC,OAAO,CAAC,UAAU,GAAG,EAAE,CAAC;QAC1B,MAAM,kBAAkB,GAA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K,CAAC,OAAO,EAAE,CAAC;QAEhB,oCAAoC;QACpC,OAAO,CAAC,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC;IAC9B,CAAC,CAAC,CAAC;AACL,CAAC;AAvCD,gCAuCC"}
|
||||||
262
lib/toolcache.js
generated
262
lib/toolcache.js
generated
@@ -1,262 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
||||||
result["default"] = mod;
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const fs = __importStar(require("fs"));
|
|
||||||
const os = __importStar(require("os"));
|
|
||||||
const path = __importStar(require("path"));
|
|
||||||
const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
|
|
||||||
const io = __importStar(require("@actions/io"));
|
|
||||||
const actionsToolcache = __importStar(require("@actions/tool-cache"));
|
|
||||||
const safeWhich = __importStar(require("@chrisgavin/safe-which"));
|
|
||||||
const semver = __importStar(require("semver"));
|
|
||||||
/*
|
|
||||||
* This file acts as an interface to the functionality of the actions toolcache.
|
|
||||||
* That library is not safe to use outside of actions as it makes assumptions about
|
|
||||||
* the state of the filesystem and available environment variables.
|
|
||||||
*
|
|
||||||
* On actions we can just delegate to the toolcache library, however outside of
|
|
||||||
* actions we provide our own implementation.
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* Extract a compressed tar archive.
|
|
||||||
*
|
|
||||||
* See extractTar function from node_modules/@actions/tool-cache/lib/tool-cache.d.ts
|
|
||||||
*
|
|
||||||
* @param file path to the tar
|
|
||||||
* @param mode should run the actions or runner implementation
|
|
||||||
* @param tempDir path to the temporary directory
|
|
||||||
* @param logger logger to use
|
|
||||||
* @returns path to the destination directory
|
|
||||||
*/
|
|
||||||
async function extractTar(file, mode, tempDir, logger) {
|
|
||||||
if (mode === "actions") {
|
|
||||||
return await actionsToolcache.extractTar(file);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Initial implementation copied from node_modules/@actions/tool-cache/lib/tool-cache.js
|
|
||||||
if (!file) {
|
|
||||||
throw new Error("parameter 'file' is required");
|
|
||||||
}
|
|
||||||
// Create dest
|
|
||||||
const dest = createExtractFolder(tempDir);
|
|
||||||
// Determine whether GNU tar
|
|
||||||
logger.debug("Checking tar --version");
|
|
||||||
let versionOutput = "";
|
|
||||||
await new toolrunner.ToolRunner(await safeWhich.safeWhich("tar"), ["--version"], {
|
|
||||||
ignoreReturnCode: true,
|
|
||||||
silent: true,
|
|
||||||
listeners: {
|
|
||||||
stdout: (data) => (versionOutput += data.toString()),
|
|
||||||
stderr: (data) => (versionOutput += data.toString()),
|
|
||||||
},
|
|
||||||
}).exec();
|
|
||||||
logger.debug(versionOutput.trim());
|
|
||||||
const isGnuTar = versionOutput.toUpperCase().includes("GNU TAR");
|
|
||||||
// Initialize args
|
|
||||||
const args = ["xz"];
|
|
||||||
if (logger.isDebug()) {
|
|
||||||
args.push("-v");
|
|
||||||
}
|
|
||||||
let destArg = dest;
|
|
||||||
let fileArg = file;
|
|
||||||
if (process.platform === "win32" && isGnuTar) {
|
|
||||||
args.push("--force-local");
|
|
||||||
destArg = dest.replace(/\\/g, "/");
|
|
||||||
// Technically only the dest needs to have `/` but for aesthetic consistency
|
|
||||||
// convert slashes in the file arg too.
|
|
||||||
fileArg = file.replace(/\\/g, "/");
|
|
||||||
}
|
|
||||||
if (isGnuTar) {
|
|
||||||
// Suppress warnings when using GNU tar to extract archives created by BSD tar
|
|
||||||
args.push("--warning=no-unknown-keyword");
|
|
||||||
}
|
|
||||||
args.push("-C", destArg, "-f", fileArg);
|
|
||||||
await new toolrunner.ToolRunner(`tar`, args).exec();
|
|
||||||
return dest;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.extractTar = extractTar;
|
|
||||||
/**
|
|
||||||
* Caches a directory and installs it into the tool cacheDir.
|
|
||||||
*
|
|
||||||
* Also see cacheDir function from node_modules/@actions/tool-cache/lib/tool-cache.d.ts
|
|
||||||
*
|
|
||||||
* @param sourceDir the directory to cache into tools
|
|
||||||
* @param tool tool name
|
|
||||||
* @param version version of the tool. semver format
|
|
||||||
* @param mode should run the actions or runner implementation
|
|
||||||
* @param toolCacheDir path to the tool cache directory
|
|
||||||
* @param logger logger to use
|
|
||||||
*/
|
|
||||||
async function cacheDir(sourceDir, tool, version, mode, toolCacheDir, logger) {
|
|
||||||
if (mode === "actions") {
|
|
||||||
return await actionsToolcache.cacheDir(sourceDir, tool, version);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Initial implementation copied from node_modules/@actions/tool-cache/lib/tool-cache.js
|
|
||||||
version = semver.clean(version) || version;
|
|
||||||
const arch = os.arch();
|
|
||||||
logger.debug(`Caching tool ${tool} ${version} ${arch}`);
|
|
||||||
logger.debug(`source dir: ${sourceDir}`);
|
|
||||||
if (!fs.statSync(sourceDir).isDirectory()) {
|
|
||||||
throw new Error("sourceDir is not a directory");
|
|
||||||
}
|
|
||||||
// Create the tool dir
|
|
||||||
const destPath = createToolPath(tool, version, arch, toolCacheDir, logger);
|
|
||||||
// copy each child item. do not move. move can fail on Windows
|
|
||||||
// due to anti-virus software having an open handle on a file.
|
|
||||||
for (const itemName of fs.readdirSync(sourceDir)) {
|
|
||||||
const s = path.join(sourceDir, itemName);
|
|
||||||
await io.cp(s, destPath, { recursive: true });
|
|
||||||
}
|
|
||||||
// write .complete
|
|
||||||
completeToolPath(tool, version, arch, toolCacheDir, logger);
|
|
||||||
return destPath;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.cacheDir = cacheDir;
|
|
||||||
/**
|
|
||||||
* Finds the path to a tool version in the local installed tool cache.
|
|
||||||
*
|
|
||||||
* Also see find function from node_modules/@actions/tool-cache/lib/tool-cache.d.ts
|
|
||||||
*
|
|
||||||
* @param toolName name of the tool
|
|
||||||
* @param versionSpec version of the tool
|
|
||||||
* @param mode should run the actions or runner implementation
|
|
||||||
* @param toolCacheDir path to the tool cache directory
|
|
||||||
* @param logger logger to use
|
|
||||||
*/
|
|
||||||
function find(toolName, versionSpec, mode, toolCacheDir, logger) {
|
|
||||||
if (mode === "actions") {
|
|
||||||
return actionsToolcache.find(toolName, versionSpec);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Initial implementation copied from node_modules/@actions/tool-cache/lib/tool-cache.js
|
|
||||||
if (!toolName) {
|
|
||||||
throw new Error("toolName parameter is required");
|
|
||||||
}
|
|
||||||
if (!versionSpec) {
|
|
||||||
throw new Error("versionSpec parameter is required");
|
|
||||||
}
|
|
||||||
const arch = os.arch();
|
|
||||||
// attempt to resolve an explicit version
|
|
||||||
if (!isExplicitVersion(versionSpec, logger)) {
|
|
||||||
const localVersions = findAllVersions(toolName, mode, toolCacheDir, logger);
|
|
||||||
const match = evaluateVersions(localVersions, versionSpec, logger);
|
|
||||||
versionSpec = match;
|
|
||||||
}
|
|
||||||
// check for the explicit version in the cache
|
|
||||||
let toolPath = "";
|
|
||||||
if (versionSpec) {
|
|
||||||
versionSpec = semver.clean(versionSpec) || "";
|
|
||||||
const cachePath = path.join(toolCacheDir, toolName, versionSpec, arch);
|
|
||||||
logger.debug(`checking cache: ${cachePath}`);
|
|
||||||
if (fs.existsSync(cachePath) && fs.existsSync(`${cachePath}.complete`)) {
|
|
||||||
logger.debug(`Found tool in cache ${toolName} ${versionSpec} ${arch}`);
|
|
||||||
toolPath = cachePath;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
logger.debug("not found");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return toolPath;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.find = find;
|
|
||||||
/**
|
|
||||||
* Finds the paths to all versions of a tool that are installed in the local tool cache.
|
|
||||||
*
|
|
||||||
* Also see findAllVersions function from node_modules/@actions/tool-cache/lib/tool-cache.d.ts
|
|
||||||
*
|
|
||||||
* @param toolName name of the tool
|
|
||||||
* @param mode should run the actions or runner implementation
|
|
||||||
* @param toolCacheDir path to the tool cache directory
|
|
||||||
* @param logger logger to use
|
|
||||||
*/
|
|
||||||
function findAllVersions(toolName, mode, toolCacheDir, logger) {
|
|
||||||
if (mode === "actions") {
|
|
||||||
return actionsToolcache.findAllVersions(toolName);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Initial implementation copied from node_modules/@actions/tool-cache/lib/tool-cache.js
|
|
||||||
const versions = [];
|
|
||||||
const arch = os.arch();
|
|
||||||
const toolPath = path.join(toolCacheDir, toolName);
|
|
||||||
if (fs.existsSync(toolPath)) {
|
|
||||||
const children = fs.readdirSync(toolPath);
|
|
||||||
for (const child of children) {
|
|
||||||
if (isExplicitVersion(child, logger)) {
|
|
||||||
const fullPath = path.join(toolPath, child, arch || "");
|
|
||||||
if (fs.existsSync(fullPath) &&
|
|
||||||
fs.existsSync(`${fullPath}.complete`)) {
|
|
||||||
versions.push(child);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return versions;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.findAllVersions = findAllVersions;
|
|
||||||
function createExtractFolder(tempDir) {
|
|
||||||
// create a temp dir
|
|
||||||
const dest = path.join(tempDir, "toolcache-temp");
|
|
||||||
if (!fs.existsSync(dest)) {
|
|
||||||
fs.mkdirSync(dest);
|
|
||||||
}
|
|
||||||
return dest;
|
|
||||||
}
|
|
||||||
function createToolPath(tool, version, arch, toolCacheDir, logger) {
|
|
||||||
const folderPath = path.join(toolCacheDir, tool, semver.clean(version) || version, arch || "");
|
|
||||||
logger.debug(`destination ${folderPath}`);
|
|
||||||
const markerPath = `${folderPath}.complete`;
|
|
||||||
fs.rmdirSync(folderPath, { recursive: true });
|
|
||||||
fs.rmdirSync(markerPath, { recursive: true });
|
|
||||||
fs.mkdirSync(folderPath, { recursive: true });
|
|
||||||
return folderPath;
|
|
||||||
}
|
|
||||||
function completeToolPath(tool, version, arch, toolCacheDir, logger) {
|
|
||||||
const folderPath = path.join(toolCacheDir, tool, semver.clean(version) || version, arch || "");
|
|
||||||
const markerPath = `${folderPath}.complete`;
|
|
||||||
fs.writeFileSync(markerPath, "");
|
|
||||||
logger.debug("finished caching tool");
|
|
||||||
}
|
|
||||||
function isExplicitVersion(versionSpec, logger) {
|
|
||||||
const c = semver.clean(versionSpec) || "";
|
|
||||||
logger.debug(`isExplicit: ${c}`);
|
|
||||||
const valid = semver.valid(c) != null;
|
|
||||||
logger.debug(`explicit? ${valid}`);
|
|
||||||
return valid;
|
|
||||||
}
|
|
||||||
function evaluateVersions(versions, versionSpec, logger) {
|
|
||||||
let version = "";
|
|
||||||
logger.debug(`evaluating ${versions.length} versions`);
|
|
||||||
versions = versions.sort((a, b) => {
|
|
||||||
if (semver.gt(a, b)) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
});
|
|
||||||
for (let i = versions.length - 1; i >= 0; i--) {
|
|
||||||
const potential = versions[i];
|
|
||||||
const satisfied = semver.satisfies(potential, versionSpec);
|
|
||||||
if (satisfied) {
|
|
||||||
version = potential;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (version) {
|
|
||||||
logger.debug(`matched: ${version}`);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
logger.debug("match not found");
|
|
||||||
}
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=toolcache.js.map
|
|
||||||
File diff suppressed because one or more lines are too long
7
lib/toolrunner-error-catcher.js
generated
7
lib/toolrunner-error-catcher.js
generated
@@ -7,8 +7,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
|
const toolrunnner = __importStar(require("@actions/exec/lib/toolrunner"));
|
||||||
const safeWhich = __importStar(require("@chrisgavin/safe-which"));
|
|
||||||
/**
|
/**
|
||||||
* Wrapper for toolrunner.Toolrunner which checks for specific return code and/or regex matches in console output.
|
* Wrapper for toolrunner.Toolrunner which checks for specific return code and/or regex matches in console output.
|
||||||
* Output will be streamed to the live console as well as captured for subsequent processing.
|
* Output will be streamed to the live console as well as captured for subsequent processing.
|
||||||
@@ -51,7 +50,7 @@ async function toolrunnerErrorCatcher(commandLine, args, matchers, options) {
|
|||||||
// 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
|
||||||
let returnState;
|
let returnState;
|
||||||
try {
|
try {
|
||||||
returnState = await new toolrunner.ToolRunner(await safeWhich.safeWhich(commandLine), args, {
|
returnState = await new toolrunnner.ToolRunner(commandLine, args, {
|
||||||
...options,
|
...options,
|
||||||
listeners,
|
listeners,
|
||||||
ignoreReturnCode: true,
|
ignoreReturnCode: true,
|
||||||
@@ -76,7 +75,7 @@ async function toolrunnerErrorCatcher(commandLine, args, matchers, options) {
|
|||||||
return returnState;
|
return returnState;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new Error(`The process '${commandLine}' failed with exit code ${returnState}`);
|
throw new Error(`The process \'${commandLine}\' failed with exit code ${returnState}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -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,SA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C,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;aAChC;iBAAM;gBACL,4FAA4F;gBAC5F,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;aAC5B;QACH,CAAC;KACF,CAAC;IAEF,0GAA0G;IAC1G,IAAI,WAA2B,CAAC;IAChC,IAAI;QACF,WAAW,GAAG,MAAM,IAAI,WAAW,CAAC,UAAU,CAAC,WAAW,EAAE,IAAI,EAAE;YAChE,GAAG,OAAO;YACV,SAAS;YACT,gBAAgB,EAAE,IAAI;SACvB,CAAC,CAAC,IAAI,EAAE,CAAC;KACX;IAAC,OAAO,CAAC,EAAE;QACV,WAAW,GAAG,CAAC,CAAC;KACjB;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,WAChC,OAAO,CAAC,WAAW,0CAAE,IAAI,CAAC,MAAM,EAAC,WACjC,OAAO,CAAC,WAAW,0CAAE,IAAI,CAAC,MAAM,EAAC,EACjC;gBACA,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;aAClC;SACF;KACF;IAED,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE;QACnC,qFAAqF;QACrF,UAAI,OAAO,0CAAE,gBAAgB,EAAE;YAC7B,OAAO,WAAW,CAAC;SACpB;aAAM;YACL,MAAM,IAAI,KAAK,CACb,iBAAiB,WAAW,4BAA4B,WAAW,EAAE,CACtE,CAAC;SACH;KACF;SAAM;QACL,MAAM,WAAW,CAAC;KACnB;AACH,CAAC;AArED,wDAqEC"}
|
||||||
58
lib/tracer-config.js
generated
58
lib/tracer-config.js
generated
@@ -13,9 +13,13 @@ const languages_1 = require("./languages");
|
|||||||
const util = __importStar(require("./util"));
|
const util = __importStar(require("./util"));
|
||||||
const CRITICAL_TRACER_VARS = new Set([
|
const CRITICAL_TRACER_VARS = new Set([
|
||||||
"SEMMLE_PRELOAD_libtrace",
|
"SEMMLE_PRELOAD_libtrace",
|
||||||
|
,
|
||||||
"SEMMLE_RUNNER",
|
"SEMMLE_RUNNER",
|
||||||
|
,
|
||||||
"SEMMLE_COPY_EXECUTABLES_ROOT",
|
"SEMMLE_COPY_EXECUTABLES_ROOT",
|
||||||
|
,
|
||||||
"SEMMLE_DEPTRACE_SOCKET",
|
"SEMMLE_DEPTRACE_SOCKET",
|
||||||
|
,
|
||||||
"SEMMLE_JAVA_TOOL_OPTIONS",
|
"SEMMLE_JAVA_TOOL_OPTIONS",
|
||||||
]);
|
]);
|
||||||
async function getTracerConfigForLanguage(codeql, config, language) {
|
async function getTracerConfigForLanguage(codeql, config, language) {
|
||||||
@@ -45,7 +49,7 @@ async function getTracerConfigForLanguage(codeql, config, language) {
|
|||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
exports.getTracerConfigForLanguage = getTracerConfigForLanguage;
|
exports.getTracerConfigForLanguage = getTracerConfigForLanguage;
|
||||||
function concatTracerConfigs(tracerConfigs, config, writeBothEnvironments = false) {
|
function concatTracerConfigs(tracerConfigs, config) {
|
||||||
// A tracer config is a map containing additional environment variables and a tracer 'spec' file.
|
// A tracer config is a map containing additional environment variables and a tracer 'spec' file.
|
||||||
// A tracer 'spec' file has the following format [log_file, number_of_blocks, blocks_text]
|
// A tracer 'spec' file has the following format [log_file, number_of_blocks, blocks_text]
|
||||||
// Merge the environments
|
// Merge the environments
|
||||||
@@ -103,42 +107,20 @@ function concatTracerConfigs(tracerConfigs, config, writeBothEnvironments = fals
|
|||||||
envSize += 1;
|
envSize += 1;
|
||||||
}
|
}
|
||||||
fs.writeFileSync(spec, newSpecContent.join("\n"));
|
fs.writeFileSync(spec, newSpecContent.join("\n"));
|
||||||
if (writeBothEnvironments || process.platform !== "win32") {
|
// Prepare the content of the compound environment file
|
||||||
// Prepare the content of the compound environment file on Unix
|
let buffer = Buffer.alloc(4);
|
||||||
let buffer = Buffer.alloc(4);
|
buffer.writeInt32LE(envSize, 0);
|
||||||
buffer.writeInt32LE(envSize, 0);
|
for (const e of Object.entries(env)) {
|
||||||
for (const e of Object.entries(env)) {
|
const key = e[0];
|
||||||
const key = e[0];
|
const value = e[1];
|
||||||
const value = e[1];
|
const lineBuffer = new Buffer(`${key}=${value}\0`, "utf8");
|
||||||
const lineBuffer = Buffer.from(`${key}=${value}\0`, "utf8");
|
|
||||||
const sizeBuffer = Buffer.alloc(4);
|
|
||||||
sizeBuffer.writeInt32LE(lineBuffer.length, 0);
|
|
||||||
buffer = Buffer.concat([buffer, sizeBuffer, lineBuffer]);
|
|
||||||
}
|
|
||||||
// Write the compound environment for Unix
|
|
||||||
const envPath = `${spec}.environment`;
|
|
||||||
fs.writeFileSync(envPath, buffer);
|
|
||||||
}
|
|
||||||
if (writeBothEnvironments || process.platform === "win32") {
|
|
||||||
// Prepare the content of the compound environment file on Windows
|
|
||||||
let bufferWindows = Buffer.alloc(0);
|
|
||||||
let length = 0;
|
|
||||||
for (const e of Object.entries(env)) {
|
|
||||||
const key = e[0];
|
|
||||||
const value = e[1];
|
|
||||||
const string = `${key}=${value}\0`;
|
|
||||||
length += string.length;
|
|
||||||
const lineBuffer = Buffer.from(string, "utf16le");
|
|
||||||
bufferWindows = Buffer.concat([bufferWindows, lineBuffer]);
|
|
||||||
}
|
|
||||||
const sizeBuffer = Buffer.alloc(4);
|
const sizeBuffer = Buffer.alloc(4);
|
||||||
sizeBuffer.writeInt32LE(length + 1, 0); // Add one for trailing null character marking end
|
sizeBuffer.writeInt32LE(lineBuffer.length, 0);
|
||||||
const trailingNull = Buffer.from(`\0`, "utf16le");
|
buffer = Buffer.concat([buffer, sizeBuffer, lineBuffer]);
|
||||||
bufferWindows = Buffer.concat([sizeBuffer, bufferWindows, trailingNull]);
|
|
||||||
// Write the compound environment for Windows
|
|
||||||
const envPathWindows = `${spec}.win32env`;
|
|
||||||
fs.writeFileSync(envPathWindows, bufferWindows);
|
|
||||||
}
|
}
|
||||||
|
// Write the compound environment
|
||||||
|
const envPath = `${spec}.environment`;
|
||||||
|
fs.writeFileSync(envPath, buffer);
|
||||||
return { env, spec };
|
return { env, spec };
|
||||||
}
|
}
|
||||||
exports.concatTracerConfigs = concatTracerConfigs;
|
exports.concatTracerConfigs = concatTracerConfigs;
|
||||||
@@ -163,12 +145,6 @@ async function getCombinedTracerConfig(config, codeql) {
|
|||||||
else if (process.platform !== "win32") {
|
else if (process.platform !== "win32") {
|
||||||
mainTracerConfig.env["LD_PRELOAD"] = path.join(codeQLDir, "tools", "linux64", "${LIB}trace.so");
|
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 order to trace when System Integrity Protection is enabled.
|
|
||||||
// The executable also exists and works for other platforms so we output this env
|
|
||||||
// var with a path to the runner regardless so it's always available.
|
|
||||||
const runnerExeName = process.platform === "win32" ? "runner.exe" : "runner";
|
|
||||||
mainTracerConfig.env["CODEQL_RUNNER"] = path.join(mainTracerConfig.env["CODEQL_DIST"], "tools", mainTracerConfig.env["CODEQL_PLATFORM"], runnerExeName);
|
|
||||||
return mainTracerConfig;
|
return mainTracerConfig;
|
||||||
}
|
}
|
||||||
exports.getCombinedTracerConfig = getCombinedTracerConfig;
|
exports.getCombinedTracerConfig = getCombinedTracerConfig;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
44
lib/tracer-config.test.js
generated
44
lib/tracer-config.test.js
generated
@@ -1,4 +1,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
@@ -6,13 +9,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
result["default"] = mod;
|
result["default"] = 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 ava_1 = __importDefault(require("ava"));
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const ava_1 = __importDefault(require("ava"));
|
|
||||||
const codeql_1 = require("./codeql");
|
const codeql_1 = require("./codeql");
|
||||||
const languages_1 = require("./languages");
|
const languages_1 = require("./languages");
|
||||||
const testing_utils_1 = require("./testing-utils");
|
const testing_utils_1 = require("./testing-utils");
|
||||||
@@ -29,7 +29,6 @@ function getTestConfig(tmpDir) {
|
|||||||
tempDir: tmpDir,
|
tempDir: tmpDir,
|
||||||
toolCacheDir: tmpDir,
|
toolCacheDir: tmpDir,
|
||||||
codeQLCmd: "",
|
codeQLCmd: "",
|
||||||
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// A very minimal setup
|
// A very minimal setup
|
||||||
@@ -59,6 +58,7 @@ ava_1.default("getTracerConfigForLanguage - existing / critical vars", async (t)
|
|||||||
process.env["SEMMLE_COPY_EXECUTABLES_ROOT"] = "abc";
|
process.env["SEMMLE_COPY_EXECUTABLES_ROOT"] = "abc";
|
||||||
process.env["SEMMLE_DEPTRACE_SOCKET"] = "abc";
|
process.env["SEMMLE_DEPTRACE_SOCKET"] = "abc";
|
||||||
process.env["SEMMLE_JAVA_TOOL_OPTIONS"] = "abc";
|
process.env["SEMMLE_JAVA_TOOL_OPTIONS"] = "abc";
|
||||||
|
process.env["SEMMLE_DEPTRACE_SOCKET"] = "abc";
|
||||||
process.env["CODEQL_VAR"] = "abc";
|
process.env["CODEQL_VAR"] = "abc";
|
||||||
// Now CodeQL returns all these variables, and one more, with different values
|
// Now CodeQL returns all these variables, and one more, with different values
|
||||||
const codeQL = codeql_1.setCodeQL({
|
const codeQL = codeql_1.setCodeQL({
|
||||||
@@ -216,26 +216,17 @@ ava_1.default("concatTracerConfigs - compound environment file is created correc
|
|||||||
foo: "bar_baz",
|
foo: "bar_baz",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const result = tracer_config_1.concatTracerConfigs({ javascript: tc1, python: tc2 }, config, true);
|
const result = tracer_config_1.concatTracerConfigs({ javascript: tc1, python: tc2 }, config);
|
||||||
// Check binary contents for the Unix file
|
|
||||||
const envPath = `${result.spec}.environment`;
|
const envPath = `${result.spec}.environment`;
|
||||||
t.true(fs.existsSync(envPath));
|
t.true(fs.existsSync(envPath));
|
||||||
const buffer = fs.readFileSync(envPath);
|
const buffer = fs.readFileSync(envPath);
|
||||||
|
// Contents is binary data
|
||||||
t.deepEqual(buffer.length, 28);
|
t.deepEqual(buffer.length, 28);
|
||||||
t.deepEqual(buffer.readInt32LE(0), 2); // number of env vars
|
t.deepEqual(buffer.readInt32LE(0), 2); // number of env vars
|
||||||
t.deepEqual(buffer.readInt32LE(4), 4); // length of env var definition
|
t.deepEqual(buffer.readInt32LE(4), 4); // length of env var definition
|
||||||
t.deepEqual(buffer.toString("utf8", 8, 12), "a=a\0"); // [key]=[value]\0
|
t.deepEqual(buffer.toString("utf8", 8, 12), "a=a\0"); // [key]=[value]\0
|
||||||
t.deepEqual(buffer.readInt32LE(12), 12); // length of env var definition
|
t.deepEqual(buffer.readInt32LE(12), 12); // length of env var definition
|
||||||
t.deepEqual(buffer.toString("utf8", 16, 28), "foo=bar_baz\0"); // [key]=[value]\0
|
t.deepEqual(buffer.toString("utf8", 16, 28), "foo=bar_baz\0"); // [key]=[value]\0
|
||||||
// Check binary contents for the Windows file
|
|
||||||
const envPathWindows = `${result.spec}.win32env`;
|
|
||||||
t.true(fs.existsSync(envPathWindows));
|
|
||||||
const bufferWindows = fs.readFileSync(envPathWindows);
|
|
||||||
t.deepEqual(bufferWindows.length, 38);
|
|
||||||
t.deepEqual(bufferWindows.readInt32LE(0), 4 + 12 + 1); // number of tchars to represent the environment
|
|
||||||
t.deepEqual(bufferWindows.toString("utf16le", 4, 12), "a=a\0"); // [key]=[value]\0
|
|
||||||
t.deepEqual(bufferWindows.toString("utf16le", 12, 36), "foo=bar_baz\0"); // [key]=[value]\0
|
|
||||||
t.deepEqual(bufferWindows.toString("utf16le", 36, 38), "\0"); // trailing null character
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("getCombinedTracerConfig - return undefined when no languages are traced languages", async (t) => {
|
ava_1.default("getCombinedTracerConfig - return undefined when no languages are traced languages", async (t) => {
|
||||||
@@ -247,7 +238,6 @@ ava_1.default("getCombinedTracerConfig - return undefined when no languages are
|
|||||||
async getTracerEnv() {
|
async getTracerEnv() {
|
||||||
return {
|
return {
|
||||||
ODASA_TRACER_CONFIGURATION: "abc",
|
ODASA_TRACER_CONFIGURATION: "abc",
|
||||||
CODEQL_DIST: "/",
|
|
||||||
foo: "bar",
|
foo: "bar",
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@@ -260,28 +250,17 @@ ava_1.default("getCombinedTracerConfig - valid spec file", async (t) => {
|
|||||||
const config = getTestConfig(tmpDir);
|
const config = getTestConfig(tmpDir);
|
||||||
const spec = path.join(tmpDir, "spec");
|
const spec = path.join(tmpDir, "spec");
|
||||||
fs.writeFileSync(spec, "foo.log\n2\nabc\ndef");
|
fs.writeFileSync(spec, "foo.log\n2\nabc\ndef");
|
||||||
const bundlePath = path.join(tmpDir, "bundle");
|
|
||||||
const codeqlPlatform = process.platform === "win32"
|
|
||||||
? "win64"
|
|
||||||
: process.platform === "darwin"
|
|
||||||
? "osx64"
|
|
||||||
: "linux64";
|
|
||||||
const codeQL = codeql_1.setCodeQL({
|
const codeQL = codeql_1.setCodeQL({
|
||||||
async getTracerEnv() {
|
async getTracerEnv() {
|
||||||
return {
|
return {
|
||||||
ODASA_TRACER_CONFIGURATION: spec,
|
ODASA_TRACER_CONFIGURATION: spec,
|
||||||
CODEQL_DIST: bundlePath,
|
|
||||||
CODEQL_PLATFORM: codeqlPlatform,
|
|
||||||
foo: "bar",
|
foo: "bar",
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const result = await tracer_config_1.getCombinedTracerConfig(config, codeQL);
|
const result = await tracer_config_1.getCombinedTracerConfig(config, codeQL);
|
||||||
t.notDeepEqual(result, undefined);
|
|
||||||
const expectedEnv = {
|
const expectedEnv = {
|
||||||
foo: "bar",
|
foo: "bar",
|
||||||
CODEQL_DIST: bundlePath,
|
|
||||||
CODEQL_PLATFORM: codeqlPlatform,
|
|
||||||
ODASA_TRACER_CONFIGURATION: result.spec,
|
ODASA_TRACER_CONFIGURATION: result.spec,
|
||||||
};
|
};
|
||||||
if (process.platform === "darwin") {
|
if (process.platform === "darwin") {
|
||||||
@@ -290,15 +269,6 @@ ava_1.default("getCombinedTracerConfig - valid spec file", async (t) => {
|
|||||||
else if (process.platform !== "win32") {
|
else if (process.platform !== "win32") {
|
||||||
expectedEnv["LD_PRELOAD"] = path.join(path.dirname(codeQL.getPath()), "tools", "linux64", "${LIB}trace.so");
|
expectedEnv["LD_PRELOAD"] = path.join(path.dirname(codeQL.getPath()), "tools", "linux64", "${LIB}trace.so");
|
||||||
}
|
}
|
||||||
if (process.platform === "win32") {
|
|
||||||
expectedEnv["CODEQL_RUNNER"] = path.join(bundlePath, "tools/win64/runner.exe");
|
|
||||||
}
|
|
||||||
else if (process.platform === "darwin") {
|
|
||||||
expectedEnv["CODEQL_RUNNER"] = path.join(bundlePath, "tools/osx64/runner");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
expectedEnv["CODEQL_RUNNER"] = path.join(bundlePath, "tools/linux64/runner");
|
|
||||||
}
|
|
||||||
t.deepEqual(result, {
|
t.deepEqual(result, {
|
||||||
spec: path.join(tmpDir, "compound-spec"),
|
spec: path.join(tmpDir, "compound-spec"),
|
||||||
env: expectedEnv,
|
env: expectedEnv,
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
184
lib/upload-lib.js
generated
184
lib/upload-lib.js
generated
@@ -10,17 +10,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const fs = __importStar(require("fs"));
|
|
||||||
const path = __importStar(require("path"));
|
|
||||||
const zlib_1 = __importDefault(require("zlib"));
|
|
||||||
const core = __importStar(require("@actions/core"));
|
const core = __importStar(require("@actions/core"));
|
||||||
const file_url_1 = __importDefault(require("file-url"));
|
const file_url_1 = __importDefault(require("file-url"));
|
||||||
|
const fs = __importStar(require("fs"));
|
||||||
const jsonschema = __importStar(require("jsonschema"));
|
const jsonschema = __importStar(require("jsonschema"));
|
||||||
const semver = __importStar(require("semver"));
|
const path = __importStar(require("path"));
|
||||||
const actionsUtil = __importStar(require("./actions-util"));
|
const zlib_1 = __importDefault(require("zlib"));
|
||||||
const api = __importStar(require("./api-client"));
|
const api = __importStar(require("./api-client"));
|
||||||
const fingerprints = __importStar(require("./fingerprints"));
|
const fingerprints = __importStar(require("./fingerprints"));
|
||||||
const repository_1 = require("./repository");
|
|
||||||
const sharedEnv = __importStar(require("./shared-environment"));
|
const sharedEnv = __importStar(require("./shared-environment"));
|
||||||
const util = __importStar(require("./util"));
|
const util = __importStar(require("./util"));
|
||||||
// Takes a list of paths to sarif files and combines them together,
|
// Takes a list of paths to sarif files and combines them together,
|
||||||
@@ -37,51 +34,23 @@ function combineSarifFiles(sarifFiles) {
|
|||||||
combinedSarif.version = sarifObject.version;
|
combinedSarif.version = sarifObject.version;
|
||||||
}
|
}
|
||||||
else if (combinedSarif.version !== sarifObject.version) {
|
else if (combinedSarif.version !== sarifObject.version) {
|
||||||
throw new Error(`Different SARIF versions encountered: ${combinedSarif.version} and ${sarifObject.version}`);
|
throw `Different SARIF versions encountered: ${combinedSarif.version} and ${sarifObject.version}`;
|
||||||
}
|
}
|
||||||
combinedSarif.runs.push(...sarifObject.runs);
|
combinedSarif.runs.push(...sarifObject.runs);
|
||||||
}
|
}
|
||||||
return JSON.stringify(combinedSarif);
|
return JSON.stringify(combinedSarif);
|
||||||
}
|
}
|
||||||
exports.combineSarifFiles = combineSarifFiles;
|
exports.combineSarifFiles = combineSarifFiles;
|
||||||
// Populates the run.automationDetails.id field using the analysis_key and environment
|
|
||||||
// and return an updated sarif file contents.
|
|
||||||
function populateRunAutomationDetails(sarifContents, category, analysis_key, environment) {
|
|
||||||
if (analysis_key === undefined) {
|
|
||||||
return sarifContents;
|
|
||||||
}
|
|
||||||
const automationID = getAutomationID(category, analysis_key, environment);
|
|
||||||
const sarif = JSON.parse(sarifContents);
|
|
||||||
for (const run of sarif.runs || []) {
|
|
||||||
if (run.automationDetails === undefined) {
|
|
||||||
run.automationDetails = {
|
|
||||||
id: automationID,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return JSON.stringify(sarif);
|
|
||||||
}
|
|
||||||
exports.populateRunAutomationDetails = populateRunAutomationDetails;
|
|
||||||
function getAutomationID(category, analysis_key, environment) {
|
|
||||||
if (category !== undefined) {
|
|
||||||
let automationID = category;
|
|
||||||
if (!automationID.endsWith("/")) {
|
|
||||||
automationID += "/";
|
|
||||||
}
|
|
||||||
return automationID;
|
|
||||||
}
|
|
||||||
return actionsUtil.computeAutomationID(analysis_key, environment);
|
|
||||||
}
|
|
||||||
// Upload the given payload.
|
// Upload the given payload.
|
||||||
// If the request fails then this will retry a small number of times.
|
// If the request fails then this will retry a small number of times.
|
||||||
async function uploadPayload(payload, repositoryNwo, apiDetails, mode, logger) {
|
async function uploadPayload(payload, repositoryNwo, githubAuth, githubUrl, mode, logger) {
|
||||||
logger.info("Uploading results");
|
logger.info("Uploading results");
|
||||||
// If in test mode we don't want to upload the results
|
// If in test mode we don't want to upload the results
|
||||||
const testMode = process.env["TEST_MODE"] === "true" || false;
|
const testMode = process.env["TEST_MODE"] === "true" || false;
|
||||||
if (testMode) {
|
if (testMode) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const client = api.getApiClient(apiDetails);
|
const client = api.getApiClient(githubAuth, githubUrl);
|
||||||
const reqURL = mode === "actions"
|
const reqURL = mode === "actions"
|
||||||
? "PUT /repos/:owner/:repo/code-scanning/analysis"
|
? "PUT /repos/:owner/:repo/code-scanning/analysis"
|
||||||
: "POST /repos/:owner/:repo/code-scanning/sarifs";
|
: "POST /repos/:owner/:repo/code-scanning/sarifs";
|
||||||
@@ -93,72 +62,36 @@ async function uploadPayload(payload, repositoryNwo, apiDetails, mode, logger) {
|
|||||||
logger.debug(`response status: ${response.status}`);
|
logger.debug(`response status: ${response.status}`);
|
||||||
logger.info("Successfully uploaded results");
|
logger.info("Successfully uploaded results");
|
||||||
}
|
}
|
||||||
// Recursively walks a directory and returns all SARIF files it finds.
|
// Uploads a single sarif file or a directory of sarif files
|
||||||
// Does not follow symlinks.
|
// depending on what the path happens to refer to.
|
||||||
function findSarifFilesInDir(sarifPath) {
|
// Returns true iff the upload occurred and succeeded
|
||||||
|
async function upload(sarifPath, repositoryNwo, commitOid, ref, analysisKey, analysisName, workflowRunID, checkoutPath, environment, githubAuth, githubUrl, mode, logger) {
|
||||||
const sarifFiles = [];
|
const sarifFiles = [];
|
||||||
const walkSarifFiles = (dir) => {
|
|
||||||
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
||||||
for (const entry of entries) {
|
|
||||||
if (entry.isFile() && entry.name.endsWith(".sarif")) {
|
|
||||||
sarifFiles.push(path.resolve(dir, entry.name));
|
|
||||||
}
|
|
||||||
else if (entry.isDirectory()) {
|
|
||||||
walkSarifFiles(path.resolve(dir, entry.name));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
walkSarifFiles(sarifPath);
|
|
||||||
return sarifFiles;
|
|
||||||
}
|
|
||||||
exports.findSarifFilesInDir = findSarifFilesInDir;
|
|
||||||
// Uploads a single sarif file or a directory of sarif files
|
|
||||||
// depending on what the path happens to refer to.
|
|
||||||
// Returns true iff the upload occurred and succeeded
|
|
||||||
async function uploadFromActions(sarifPath, gitHubVersion, apiDetails, logger) {
|
|
||||||
return await uploadFiles(getSarifFilePaths(sarifPath), repository_1.parseRepositoryNwo(actionsUtil.getRequiredEnvParam("GITHUB_REPOSITORY")), await actionsUtil.getCommitOid(), await actionsUtil.getRef(), await actionsUtil.getAnalysisKey(), actionsUtil.getOptionalInput("category"), actionsUtil.getRequiredEnvParam("GITHUB_WORKFLOW"), actionsUtil.getWorkflowRunID(), actionsUtil.getRequiredInput("checkout_path"), actionsUtil.getRequiredInput("matrix"), gitHubVersion, apiDetails, "actions", logger);
|
|
||||||
}
|
|
||||||
exports.uploadFromActions = uploadFromActions;
|
|
||||||
// Uploads a single sarif file or a directory of sarif files
|
|
||||||
// depending on what the path happens to refer to.
|
|
||||||
// Returns true iff the upload occurred and succeeded
|
|
||||||
async function uploadFromRunner(sarifPath, repositoryNwo, commitOid, ref, category, checkoutPath, gitHubVersion, apiDetails, logger) {
|
|
||||||
return await uploadFiles(getSarifFilePaths(sarifPath), repositoryNwo, commitOid, ref, undefined, category, undefined, undefined, checkoutPath, undefined, gitHubVersion, apiDetails, "runner", logger);
|
|
||||||
}
|
|
||||||
exports.uploadFromRunner = uploadFromRunner;
|
|
||||||
function getSarifFilePaths(sarifPath) {
|
|
||||||
if (!fs.existsSync(sarifPath)) {
|
if (!fs.existsSync(sarifPath)) {
|
||||||
throw new Error(`Path does not exist: ${sarifPath}`);
|
throw new Error(`Path does not exist: ${sarifPath}`);
|
||||||
}
|
}
|
||||||
let sarifFiles;
|
|
||||||
if (fs.lstatSync(sarifPath).isDirectory()) {
|
if (fs.lstatSync(sarifPath).isDirectory()) {
|
||||||
sarifFiles = findSarifFilesInDir(sarifPath);
|
const paths = fs
|
||||||
|
.readdirSync(sarifPath)
|
||||||
|
.filter((f) => f.endsWith(".sarif"))
|
||||||
|
.map((f) => path.resolve(sarifPath, f));
|
||||||
|
for (const path of paths) {
|
||||||
|
sarifFiles.push(path);
|
||||||
|
}
|
||||||
if (sarifFiles.length === 0) {
|
if (sarifFiles.length === 0) {
|
||||||
throw new Error(`No SARIF files found to upload in "${sarifPath}".`);
|
throw new Error(`No SARIF files found to upload in "${sarifPath}".`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sarifFiles = [sarifPath];
|
sarifFiles.push(sarifPath);
|
||||||
}
|
}
|
||||||
return sarifFiles;
|
return await uploadFiles(sarifFiles, repositoryNwo, commitOid, ref, analysisKey, analysisName, workflowRunID, checkoutPath, environment, githubAuth, githubUrl, mode, logger);
|
||||||
}
|
}
|
||||||
|
exports.upload = upload;
|
||||||
// Counts the number of results in the given SARIF file
|
// Counts the number of results in the given SARIF file
|
||||||
function countResultsInSarif(sarif) {
|
function countResultsInSarif(sarif) {
|
||||||
let numResults = 0;
|
let numResults = 0;
|
||||||
let parsedSarif;
|
for (const run of JSON.parse(sarif).runs) {
|
||||||
try {
|
|
||||||
parsedSarif = JSON.parse(sarif);
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
throw new Error(`Invalid SARIF. JSON syntax error: ${e.message}`);
|
|
||||||
}
|
|
||||||
if (!Array.isArray(parsedSarif.runs)) {
|
|
||||||
throw new Error("Invalid SARIF. Missing 'runs' array.");
|
|
||||||
}
|
|
||||||
for (const run of parsedSarif.runs) {
|
|
||||||
if (!Array.isArray(run.results)) {
|
|
||||||
throw new Error("Invalid SARIF. Missing 'results' array in run.");
|
|
||||||
}
|
|
||||||
numResults += run.results.length;
|
numResults += run.results.length;
|
||||||
}
|
}
|
||||||
return numResults;
|
return numResults;
|
||||||
@@ -184,50 +117,9 @@ function validateSarifFileSchema(sarifFilePath, logger) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.validateSarifFileSchema = validateSarifFileSchema;
|
exports.validateSarifFileSchema = validateSarifFileSchema;
|
||||||
// buildPayload constructs a map ready to be uploaded to the API from the given
|
|
||||||
// parameters, respecting the current mode and target GitHub instance version.
|
|
||||||
function buildPayload(commitOid, ref, analysisKey, analysisName, zippedSarif, workflowRunID, checkoutURI, environment, toolNames, gitHubVersion, mode) {
|
|
||||||
if (mode === "actions") {
|
|
||||||
const payloadObj = {
|
|
||||||
commit_oid: commitOid,
|
|
||||||
ref,
|
|
||||||
analysis_key: analysisKey,
|
|
||||||
analysis_name: analysisName,
|
|
||||||
sarif: zippedSarif,
|
|
||||||
workflow_run_id: workflowRunID,
|
|
||||||
checkout_uri: checkoutURI,
|
|
||||||
environment,
|
|
||||||
started_at: process.env[sharedEnv.CODEQL_WORKFLOW_STARTED_AT],
|
|
||||||
tool_names: toolNames,
|
|
||||||
base_ref: undefined,
|
|
||||||
base_sha: undefined,
|
|
||||||
};
|
|
||||||
// This behaviour can be made the default when support for GHES 3.0 is discontinued.
|
|
||||||
if (gitHubVersion.type !== util.GitHubVariant.GHES ||
|
|
||||||
semver.satisfies(gitHubVersion.version, `>=3.1`)) {
|
|
||||||
if (process.env.GITHUB_EVENT_NAME === "pull_request" &&
|
|
||||||
process.env.GITHUB_EVENT_PATH) {
|
|
||||||
const githubEvent = JSON.parse(fs.readFileSync(process.env.GITHUB_EVENT_PATH, "utf8"));
|
|
||||||
payloadObj.base_ref = `refs/heads/${githubEvent.pull_request.base.ref}`;
|
|
||||||
payloadObj.base_sha = githubEvent.pull_request.base.sha;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return payloadObj;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return {
|
|
||||||
commit_sha: commitOid,
|
|
||||||
ref,
|
|
||||||
sarif: zippedSarif,
|
|
||||||
checkout_uri: checkoutURI,
|
|
||||||
tool_name: toolNames[0],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.buildPayload = buildPayload;
|
|
||||||
// Uploads the given set of sarif files.
|
// Uploads the given set of sarif files.
|
||||||
// Returns true iff the upload occurred and succeeded
|
// Returns true iff the upload occurred and succeeded
|
||||||
async function uploadFiles(sarifFiles, repositoryNwo, commitOid, ref, analysisKey, category, analysisName, workflowRunID, checkoutPath, environment, gitHubVersion, apiDetails, mode, logger) {
|
async function uploadFiles(sarifFiles, repositoryNwo, commitOid, ref, analysisKey, analysisName, workflowRunID, checkoutPath, environment, githubAuth, githubUrl, mode, logger) {
|
||||||
logger.info(`Uploading sarif files: ${JSON.stringify(sarifFiles)}`);
|
logger.info(`Uploading sarif files: ${JSON.stringify(sarifFiles)}`);
|
||||||
if (mode === "actions") {
|
if (mode === "actions") {
|
||||||
// This check only works on actions as env vars don't persist between calls to the runner
|
// This check only works on actions as env vars don't persist between calls to the runner
|
||||||
@@ -243,20 +135,42 @@ async function uploadFiles(sarifFiles, repositoryNwo, commitOid, ref, analysisKe
|
|||||||
}
|
}
|
||||||
let sarifPayload = combineSarifFiles(sarifFiles);
|
let sarifPayload = combineSarifFiles(sarifFiles);
|
||||||
sarifPayload = fingerprints.addFingerprints(sarifPayload, checkoutPath, logger);
|
sarifPayload = fingerprints.addFingerprints(sarifPayload, checkoutPath, logger);
|
||||||
sarifPayload = populateRunAutomationDetails(sarifPayload, category, analysisKey, environment);
|
const zipped_sarif = zlib_1.default.gzipSync(sarifPayload).toString("base64");
|
||||||
const zippedSarif = zlib_1.default.gzipSync(sarifPayload).toString("base64");
|
|
||||||
const checkoutURI = file_url_1.default(checkoutPath);
|
const checkoutURI = file_url_1.default(checkoutPath);
|
||||||
const toolNames = util.getToolNames(sarifPayload);
|
const toolNames = util.getToolNames(sarifPayload);
|
||||||
const payload = buildPayload(commitOid, ref, analysisKey, analysisName, zippedSarif, workflowRunID, checkoutURI, environment, toolNames, gitHubVersion, mode);
|
let payload;
|
||||||
|
if (mode === "actions") {
|
||||||
|
payload = JSON.stringify({
|
||||||
|
commit_oid: commitOid,
|
||||||
|
ref,
|
||||||
|
analysis_key: analysisKey,
|
||||||
|
analysis_name: analysisName,
|
||||||
|
sarif: zipped_sarif,
|
||||||
|
workflow_run_id: workflowRunID,
|
||||||
|
checkout_uri: checkoutURI,
|
||||||
|
environment,
|
||||||
|
started_at: process.env[sharedEnv.CODEQL_WORKFLOW_STARTED_AT],
|
||||||
|
tool_names: toolNames,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
payload = JSON.stringify({
|
||||||
|
commit_sha: commitOid,
|
||||||
|
ref,
|
||||||
|
sarif: zipped_sarif,
|
||||||
|
checkout_uri: checkoutURI,
|
||||||
|
tool_name: toolNames[0],
|
||||||
|
});
|
||||||
|
}
|
||||||
// Log some useful debug info about the info
|
// Log some useful debug info about the info
|
||||||
const rawUploadSizeBytes = sarifPayload.length;
|
const rawUploadSizeBytes = sarifPayload.length;
|
||||||
logger.debug(`Raw upload size: ${rawUploadSizeBytes} bytes`);
|
logger.debug(`Raw upload size: ${rawUploadSizeBytes} bytes`);
|
||||||
const zippedUploadSizeBytes = zippedSarif.length;
|
const zippedUploadSizeBytes = zipped_sarif.length;
|
||||||
logger.debug(`Base64 zipped upload size: ${zippedUploadSizeBytes} bytes`);
|
logger.debug(`Base64 zipped upload size: ${zippedUploadSizeBytes} bytes`);
|
||||||
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
|
||||||
await uploadPayload(payload, repositoryNwo, apiDetails, mode, logger);
|
await uploadPayload(payload, repositoryNwo, githubAuth, githubUrl, mode, logger);
|
||||||
return {
|
return {
|
||||||
raw_upload_size_bytes: rawUploadSizeBytes,
|
raw_upload_size_bytes: rawUploadSizeBytes,
|
||||||
zipped_upload_size_bytes: zippedUploadSizeBytes,
|
zipped_upload_size_bytes: zippedUploadSizeBytes,
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
81
lib/upload-lib.test.js
generated
81
lib/upload-lib.test.js
generated
@@ -1,4 +1,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
@@ -6,17 +9,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
result["default"] = mod;
|
result["default"] = 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 path = __importStar(require("path"));
|
|
||||||
const ava_1 = __importDefault(require("ava"));
|
const ava_1 = __importDefault(require("ava"));
|
||||||
const logging_1 = require("./logging");
|
const logging_1 = require("./logging");
|
||||||
const testing_utils_1 = require("./testing-utils");
|
const testing_utils_1 = require("./testing-utils");
|
||||||
const uploadLib = __importStar(require("./upload-lib"));
|
const uploadLib = __importStar(require("./upload-lib"));
|
||||||
const util_1 = require("./util");
|
|
||||||
testing_utils_1.setupTests(ava_1.default);
|
testing_utils_1.setupTests(ava_1.default);
|
||||||
ava_1.default("validateSarifFileSchema - valid", (t) => {
|
ava_1.default("validateSarifFileSchema - valid", (t) => {
|
||||||
const inputFile = `${__dirname}/../src/testdata/valid-sarif.sarif`;
|
const inputFile = `${__dirname}/../src/testdata/valid-sarif.sarif`;
|
||||||
@@ -26,76 +23,4 @@ ava_1.default("validateSarifFileSchema - invalid", (t) => {
|
|||||||
const inputFile = `${__dirname}/../src/testdata/invalid-sarif.sarif`;
|
const inputFile = `${__dirname}/../src/testdata/invalid-sarif.sarif`;
|
||||||
t.throws(() => uploadLib.validateSarifFileSchema(inputFile, logging_1.getRunnerLogger(true)));
|
t.throws(() => uploadLib.validateSarifFileSchema(inputFile, logging_1.getRunnerLogger(true)));
|
||||||
});
|
});
|
||||||
ava_1.default("validate correct payload used per version", async (t) => {
|
|
||||||
const newVersions = [
|
|
||||||
{ type: util_1.GitHubVariant.DOTCOM },
|
|
||||||
{ type: util_1.GitHubVariant.GHES, version: "3.1.0" },
|
|
||||||
];
|
|
||||||
const oldVersions = [
|
|
||||||
{ type: util_1.GitHubVariant.GHES, version: "2.22.1" },
|
|
||||||
{ type: util_1.GitHubVariant.GHES, version: "3.0.0" },
|
|
||||||
];
|
|
||||||
const allVersions = newVersions.concat(oldVersions);
|
|
||||||
process.env["GITHUB_EVENT_NAME"] = "push";
|
|
||||||
for (const version of allVersions) {
|
|
||||||
const payload = uploadLib.buildPayload("commit", "refs/heads/master", "key", undefined, "", undefined, "/opt/src", undefined, ["CodeQL", "eslint"], version, "actions");
|
|
||||||
// Not triggered by a pull request
|
|
||||||
t.falsy(payload.base_ref);
|
|
||||||
t.falsy(payload.base_sha);
|
|
||||||
}
|
|
||||||
process.env["GITHUB_EVENT_NAME"] = "pull_request";
|
|
||||||
process.env["GITHUB_EVENT_PATH"] = `${__dirname}/../src/testdata/pull_request.json`;
|
|
||||||
for (const version of newVersions) {
|
|
||||||
const payload = uploadLib.buildPayload("commit", "refs/pull/123/merge", "key", undefined, "", undefined, "/opt/src", undefined, ["CodeQL", "eslint"], version, "actions");
|
|
||||||
t.deepEqual(payload.base_ref, "refs/heads/master");
|
|
||||||
t.deepEqual(payload.base_sha, "f95f852bd8fca8fcc58a9a2d6c842781e32a215e");
|
|
||||||
}
|
|
||||||
for (const version of oldVersions) {
|
|
||||||
const payload = uploadLib.buildPayload("commit", "refs/pull/123/merge", "key", undefined, "", undefined, "/opt/src", undefined, ["CodeQL", "eslint"], version, "actions");
|
|
||||||
// These older versions won't expect these values
|
|
||||||
t.falsy(payload.base_ref);
|
|
||||||
t.falsy(payload.base_sha);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
ava_1.default("finding SARIF files", async (t) => {
|
|
||||||
await util_1.withTmpDir(async (tmpDir) => {
|
|
||||||
// include a couple of sarif files
|
|
||||||
fs.writeFileSync(path.join(tmpDir, "a.sarif"), "");
|
|
||||||
fs.writeFileSync(path.join(tmpDir, "b.sarif"), "");
|
|
||||||
// other random files shouldn't be returned
|
|
||||||
fs.writeFileSync(path.join(tmpDir, "c.foo"), "");
|
|
||||||
// we should recursively look in subdirectories
|
|
||||||
fs.mkdirSync(path.join(tmpDir, "dir1"));
|
|
||||||
fs.writeFileSync(path.join(tmpDir, "dir1", "d.sarif"), "");
|
|
||||||
fs.mkdirSync(path.join(tmpDir, "dir1", "dir2"));
|
|
||||||
fs.writeFileSync(path.join(tmpDir, "dir1", "dir2", "e.sarif"), "");
|
|
||||||
// we should ignore symlinks
|
|
||||||
fs.mkdirSync(path.join(tmpDir, "dir3"));
|
|
||||||
fs.symlinkSync(tmpDir, path.join(tmpDir, "dir3", "symlink1"), "dir");
|
|
||||||
fs.symlinkSync(path.join(tmpDir, "a.sarif"), path.join(tmpDir, "dir3", "symlink2.sarif"), "file");
|
|
||||||
const sarifFiles = uploadLib.findSarifFilesInDir(tmpDir);
|
|
||||||
t.deepEqual(sarifFiles, [
|
|
||||||
path.join(tmpDir, "a.sarif"),
|
|
||||||
path.join(tmpDir, "b.sarif"),
|
|
||||||
path.join(tmpDir, "dir1", "d.sarif"),
|
|
||||||
path.join(tmpDir, "dir1", "dir2", "e.sarif"),
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
ava_1.default("populateRunAutomationDetails", (t) => {
|
|
||||||
let sarif = '{"runs": [{}]}';
|
|
||||||
const analysisKey = ".github/workflows/codeql-analysis.yml:analyze";
|
|
||||||
let expectedSarif = '{"runs":[{"automationDetails":{"id":"language:javascript/os:linux/"}}]}';
|
|
||||||
// Category has priority over analysis_key/environment
|
|
||||||
let modifiedSarif = uploadLib.populateRunAutomationDetails(sarif, "language:javascript/os:linux", analysisKey, '{"language": "other", "os": "other"}');
|
|
||||||
t.deepEqual(modifiedSarif, expectedSarif);
|
|
||||||
// It doesn't matter if the category has a slash at the end or not
|
|
||||||
modifiedSarif = uploadLib.populateRunAutomationDetails(sarif, "language:javascript/os:linux/", analysisKey, "");
|
|
||||||
t.deepEqual(modifiedSarif, expectedSarif);
|
|
||||||
// check that the automation details doesn't get overwritten
|
|
||||||
sarif = '{"runs":[{"automationDetails":{"id":"my_id"}}]}';
|
|
||||||
expectedSarif = '{"runs":[{"automationDetails":{"id":"my_id"}}]}';
|
|
||||||
modifiedSarif = uploadLib.populateRunAutomationDetails(sarif, undefined, analysisKey, '{"os": "linux", "language": "javascript"}');
|
|
||||||
t.deepEqual(modifiedSarif, expectedSarif);
|
|
||||||
});
|
|
||||||
//# sourceMappingURL=upload-lib.test.js.map
|
//# sourceMappingURL=upload-lib.test.js.map
|
||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"upload-lib.test.js","sourceRoot":"","sources":["../src/upload-lib.test.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,8CAAuB;AAEvB,uCAA4C;AAC5C,mDAA6C;AAC7C,wDAA0C;AAC1C,iCAAkE;AAElE,0BAAU,CAAC,aAAI,CAAC,CAAC;AAEjB,aAAI,CAAC,iCAAiC,EAAE,CAAC,CAAC,EAAE,EAAE;IAC5C,MAAM,SAAS,GA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upload-lib.test.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8CAAuB;AAEvB,uCAA4C;AAC5C,mDAA6C;AAC7C,wDAA0C;AAE1C,0BAAU,CAAC,aAAI,CAAC,CAAC;AAEjB,aAAI,CAAC,iCAAiC,EAAE,CAAC,CAAC,EAAE,EAAE;IAC5C,MAAM,SAAS,GAAG,GAAG,SAAS,oCAAoC,CAAC;IACnE,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE,CACf,SAAS,CAAC,uBAAuB,CAAC,SAAS,EAAE,yBAAe,CAAC,IAAI,CAAC,CAAC,CACpE,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,aAAI,CAAC,mCAAmC,EAAE,CAAC,CAAC,EAAE,EAAE;IAC9C,MAAM,SAAS,GAAG,GAAG,SAAS,sCAAsC,CAAC;IACrE,CAAC,CAAC,MAAM,CAAC,GAAG,EAAE,CACZ,SAAS,CAAC,uBAAuB,CAAC,SAAS,EAAE,yBAAe,CAAC,IAAI,CAAC,CAAC,CACpE,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
||||||
25
lib/upload-sarif-action.js
generated
25
lib/upload-sarif-action.js
generated
@@ -10,8 +10,8 @@ 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");
|
|
||||||
async function sendSuccessStatusReport(startedAt, uploadStats) {
|
async function sendSuccessStatusReport(startedAt, uploadStats) {
|
||||||
const statusReportBase = await actionsUtil.createStatusReportBase("upload-sarif", "success", startedAt);
|
const statusReportBase = await actionsUtil.createStatusReportBase("upload-sarif", "success", startedAt);
|
||||||
const statusReport = {
|
const statusReport = {
|
||||||
@@ -22,16 +22,11 @@ async function sendSuccessStatusReport(startedAt, uploadStats) {
|
|||||||
}
|
}
|
||||||
async function run() {
|
async function run() {
|
||||||
const startedAt = new Date();
|
const startedAt = new Date();
|
||||||
if (!(await actionsUtil.sendStatusReport(await actionsUtil.createStatusReportBase("upload-sarif", "starting", startedAt)))) {
|
if (!(await actionsUtil.sendStatusReport(await actionsUtil.createStatusReportBase("upload-sarif", "starting", startedAt), true))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const apiDetails = {
|
const uploadStats = await upload_lib.upload(actionsUtil.getRequiredInput("sarif_file"), repository_1.parseRepositoryNwo(actionsUtil.getRequiredEnvParam("GITHUB_REPOSITORY")), await actionsUtil.getCommitOid(), actionsUtil.getRef(), await actionsUtil.getAnalysisKey(), actionsUtil.getRequiredEnvParam("GITHUB_WORKFLOW"), actionsUtil.getWorkflowRunID(), actionsUtil.getRequiredInput("checkout_path"), actionsUtil.getRequiredInput("matrix"), actionsUtil.getRequiredInput("token"), actionsUtil.getRequiredEnvParam("GITHUB_SERVER_URL"), "actions", logging_1.getActionsLogger());
|
||||||
auth: actionsUtil.getRequiredInput("token"),
|
|
||||||
url: actionsUtil.getRequiredEnvParam("GITHUB_SERVER_URL"),
|
|
||||||
};
|
|
||||||
const gitHubVersion = await util_1.getGitHubVersion(apiDetails);
|
|
||||||
const uploadStats = await upload_lib.uploadFromActions(actionsUtil.getRequiredInput("sarif_file"), gitHubVersion, apiDetails, logging_1.getActionsLogger());
|
|
||||||
await sendSuccessStatusReport(startedAt, uploadStats);
|
await sendSuccessStatusReport(startedAt, uploadStats);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
@@ -41,14 +36,8 @@ async function run() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async function runWrapper() {
|
run().catch((e) => {
|
||||||
try {
|
core.setFailed(`codeql/upload-sarif action failed: ${e}`);
|
||||||
await run();
|
console.log(e);
|
||||||
}
|
});
|
||||||
catch (error) {
|
|
||||||
core.setFailed(`codeql/upload-sarif action failed: ${error}`);
|
|
||||||
console.log(error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void runWrapper();
|
|
||||||
//# sourceMappingURL=upload-sarif-action.js.map
|
//# sourceMappingURL=upload-sarif-action.js.map
|
||||||
@@ -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,yDAA2C;AAC3C,iCAA0C;AAM1C,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,GAAG,gBAAgB;QACnB,GAAG,WAAW;KACf,CAAC;IACF,MAAM,WAAW,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;AACnD,CAAC;AAED,KAAK,UAAU,GAAG;IAChB,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;IAC7B,IACE,CAAC,CAAC,MAAM,WAAW,CAAC,gBAAgB,CAClC,MAAM,WAAW,CAAC,sBAAsB,CACtC,cAAc,EACd,UAAU,EACV,SAAS,CACV,CACF,CAAC,EACF;QACA,OAAO;KACR;IAED,IAAI;QACF,MAAM,UAAU,GAAG;YACjB,IAAI,EAAE,WAAW,CAAC,gBAAgB,CAAC,OAAO,CAAC;YAC3C,GAAG,EAAE,WAAW,CAAC,mBAAmB,CAAC,mBAAmB,CAAC;SAC1D,CAAC;QAEF,MAAM,aAAa,GAAG,MAAM,uBAAgB,CAAC,UAAU,CAAC,CAAC;QAEzD,MAAM,WAAW,GAAG,MAAM,UAAU,CAAC,iBAAiB,CACpD,WAAW,CAAC,gBAAgB,CAAC,YAAY,CAAC,EAC1C,aAAa,EACb,UAAU,EACV,0BAAgB,EAAE,CACnB,CAAC;QACF,MAAM,uBAAuB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;KACvD;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC9B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACnB,MAAM,WAAW,CAAC,gBAAgB,CAChC,MAAM,WAAW,CAAC,sBAAsB,CACtC,cAAc,EACd,SAAS,EACT,SAAS,EACT,KAAK,CAAC,OAAO,EACb,KAAK,CAAC,KAAK,CACZ,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"}
|
{"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;AAM3C,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,GAAG,gBAAgB;QACnB,GAAG,WAAW;KACf,CAAC;IACF,MAAM,WAAW,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;AACnD,CAAC;AAED,KAAK,UAAU,GAAG;IAChB,MAAM,SAAS,GAA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S,CAAC,sCAAsC,CAAC,EAAE,CAAC,CAAC;IAC1D,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACjB,CAAC,CAAC,CAAC"}
|
||||||
192
lib/util.js
generated
192
lib/util.js
generated
@@ -10,10 +10,6 @@ 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 core = __importStar(require("@actions/core"));
|
|
||||||
const semver = __importStar(require("semver"));
|
|
||||||
const api_client_1 = require("./api-client");
|
|
||||||
const apiCompatibility = __importStar(require("./api-compatibility.json"));
|
|
||||||
/**
|
/**
|
||||||
* The URL for github.com.
|
* The URL for github.com.
|
||||||
*/
|
*/
|
||||||
@@ -72,21 +68,9 @@ async function withTmpDir(body) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
exports.withTmpDir = withTmpDir;
|
exports.withTmpDir = withTmpDir;
|
||||||
/**
|
|
||||||
* Gets an OS-specific amount of memory (in MB) to reserve for OS processes
|
|
||||||
* when the user doesn't explicitly specify a memory setting.
|
|
||||||
* This is a heuristic to avoid OOM errors (exit code 137 / SIGKILL)
|
|
||||||
* from committing too much of the available memory to CodeQL.
|
|
||||||
* @returns number
|
|
||||||
*/
|
|
||||||
function getSystemReservedMemoryMegaBytes() {
|
|
||||||
// Windows needs more memory for OS processes.
|
|
||||||
return 1024 * (process.platform === "win32" ? 1.5 : 1);
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Get the codeql `--ram` flag as configured by the `ram` input. If no value was
|
* 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
|
* specified, the total available memory will be used minus 256 MB.
|
||||||
* reserved for the OS.
|
|
||||||
*
|
*
|
||||||
* @returns string
|
* @returns string
|
||||||
*/
|
*/
|
||||||
@@ -101,8 +85,8 @@ function getMemoryFlag(userInput) {
|
|||||||
else {
|
else {
|
||||||
const totalMemoryBytes = os.totalmem();
|
const totalMemoryBytes = os.totalmem();
|
||||||
const totalMemoryMegaBytes = totalMemoryBytes / (1024 * 1024);
|
const totalMemoryMegaBytes = totalMemoryBytes / (1024 * 1024);
|
||||||
const reservedMemoryMegaBytes = getSystemReservedMemoryMegaBytes();
|
const systemReservedMemoryMegaBytes = 256;
|
||||||
memoryToUseMegaBytes = totalMemoryMegaBytes - reservedMemoryMegaBytes;
|
memoryToUseMegaBytes = totalMemoryMegaBytes - systemReservedMemoryMegaBytes;
|
||||||
}
|
}
|
||||||
return `--ram=${Math.floor(memoryToUseMegaBytes)}`;
|
return `--ram=${Math.floor(memoryToUseMegaBytes)}`;
|
||||||
}
|
}
|
||||||
@@ -167,174 +151,4 @@ function getCodeQLDatabasePath(tempDir, language) {
|
|||||||
return path.resolve(getCodeQLDatabasesDir(tempDir), language);
|
return path.resolve(getCodeQLDatabasesDir(tempDir), language);
|
||||||
}
|
}
|
||||||
exports.getCodeQLDatabasePath = getCodeQLDatabasePath;
|
exports.getCodeQLDatabasePath = getCodeQLDatabasePath;
|
||||||
/**
|
|
||||||
* Parses user input of a github.com or GHES URL to a canonical form.
|
|
||||||
* Removes any API prefix or suffix if one is present.
|
|
||||||
*/
|
|
||||||
function parseGitHubUrl(inputUrl) {
|
|
||||||
const originalUrl = inputUrl;
|
|
||||||
if (inputUrl.indexOf("://") === -1) {
|
|
||||||
inputUrl = `https://${inputUrl}`;
|
|
||||||
}
|
|
||||||
if (!inputUrl.startsWith("http://") && !inputUrl.startsWith("https://")) {
|
|
||||||
throw new Error(`"${originalUrl}" is not a http or https URL`);
|
|
||||||
}
|
|
||||||
let url;
|
|
||||||
try {
|
|
||||||
url = new URL(inputUrl);
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
throw new Error(`"${originalUrl}" is not a valid URL`);
|
|
||||||
}
|
|
||||||
// If we detect this is trying to be to github.com
|
|
||||||
// then return with a fixed canonical URL.
|
|
||||||
if (url.hostname === "github.com" || url.hostname === "api.github.com") {
|
|
||||||
return exports.GITHUB_DOTCOM_URL;
|
|
||||||
}
|
|
||||||
// Remove the API prefix if it's present
|
|
||||||
if (url.pathname.indexOf("/api/v3") !== -1) {
|
|
||||||
url.pathname = url.pathname.substring(0, url.pathname.indexOf("/api/v3"));
|
|
||||||
}
|
|
||||||
// Also consider subdomain isolation on GHES
|
|
||||||
if (url.hostname.startsWith("api.")) {
|
|
||||||
url.hostname = url.hostname.substring(4);
|
|
||||||
}
|
|
||||||
// Normalise path to having a trailing slash for consistency
|
|
||||||
if (!url.pathname.endsWith("/")) {
|
|
||||||
url.pathname = `${url.pathname}/`;
|
|
||||||
}
|
|
||||||
return url.toString();
|
|
||||||
}
|
|
||||||
exports.parseGitHubUrl = parseGitHubUrl;
|
|
||||||
const GITHUB_ENTERPRISE_VERSION_HEADER = "x-github-enterprise-version";
|
|
||||||
const CODEQL_ACTION_WARNED_ABOUT_VERSION_ENV_VAR = "CODEQL_ACTION_WARNED_ABOUT_VERSION";
|
|
||||||
let hasBeenWarnedAboutVersion = false;
|
|
||||||
var GitHubVariant;
|
|
||||||
(function (GitHubVariant) {
|
|
||||||
GitHubVariant[GitHubVariant["DOTCOM"] = 0] = "DOTCOM";
|
|
||||||
GitHubVariant[GitHubVariant["GHES"] = 1] = "GHES";
|
|
||||||
GitHubVariant[GitHubVariant["GHAE"] = 2] = "GHAE";
|
|
||||||
})(GitHubVariant = exports.GitHubVariant || (exports.GitHubVariant = {}));
|
|
||||||
async function getGitHubVersion(apiDetails) {
|
|
||||||
// We can avoid making an API request in the standard dotcom case
|
|
||||||
if (parseGitHubUrl(apiDetails.url) === exports.GITHUB_DOTCOM_URL) {
|
|
||||||
return { type: GitHubVariant.DOTCOM };
|
|
||||||
}
|
|
||||||
// Doesn't strictly have to be the meta endpoint as we're only
|
|
||||||
// using the response headers which are available on every request.
|
|
||||||
const apiClient = api_client_1.getApiClient(apiDetails);
|
|
||||||
const response = await apiClient.meta.get();
|
|
||||||
// This happens on dotcom, although we expect to have already returned in that
|
|
||||||
// case. This can also serve as a fallback in cases we haven't foreseen.
|
|
||||||
if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === undefined) {
|
|
||||||
return { type: GitHubVariant.DOTCOM };
|
|
||||||
}
|
|
||||||
if (response.headers[GITHUB_ENTERPRISE_VERSION_HEADER] === "GitHub AE") {
|
|
||||||
return { type: GitHubVariant.GHAE };
|
|
||||||
}
|
|
||||||
const version = response.headers[GITHUB_ENTERPRISE_VERSION_HEADER];
|
|
||||||
return { type: GitHubVariant.GHES, version };
|
|
||||||
}
|
|
||||||
exports.getGitHubVersion = getGitHubVersion;
|
|
||||||
function checkGitHubVersionInRange(version, mode, logger) {
|
|
||||||
if (hasBeenWarnedAboutVersion || version.type !== GitHubVariant.GHES) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const disallowedAPIVersionReason = apiVersionInRange(version.version, apiCompatibility.minimumVersion, apiCompatibility.maximumVersion);
|
|
||||||
const toolName = mode === "actions" ? "Action" : "Runner";
|
|
||||||
if (disallowedAPIVersionReason === DisallowedAPIVersionReason.ACTION_TOO_OLD) {
|
|
||||||
logger.warning(`The CodeQL ${toolName} version you are using is too old to be compatible with GitHub Enterprise ${version.version}. If you experience issues, please upgrade to a more recent version of the CodeQL ${toolName}.`);
|
|
||||||
}
|
|
||||||
if (disallowedAPIVersionReason === DisallowedAPIVersionReason.ACTION_TOO_NEW) {
|
|
||||||
logger.warning(`GitHub Enterprise ${version.version} is too old to be compatible with this version of the CodeQL ${toolName}. If you experience issues, please upgrade to a more recent version of GitHub Enterprise or use an older version of the CodeQL ${toolName}.`);
|
|
||||||
}
|
|
||||||
hasBeenWarnedAboutVersion = true;
|
|
||||||
if (mode === "actions") {
|
|
||||||
core.exportVariable(CODEQL_ACTION_WARNED_ABOUT_VERSION_ENV_VAR, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.checkGitHubVersionInRange = checkGitHubVersionInRange;
|
|
||||||
var DisallowedAPIVersionReason;
|
|
||||||
(function (DisallowedAPIVersionReason) {
|
|
||||||
DisallowedAPIVersionReason[DisallowedAPIVersionReason["ACTION_TOO_OLD"] = 0] = "ACTION_TOO_OLD";
|
|
||||||
DisallowedAPIVersionReason[DisallowedAPIVersionReason["ACTION_TOO_NEW"] = 1] = "ACTION_TOO_NEW";
|
|
||||||
})(DisallowedAPIVersionReason = exports.DisallowedAPIVersionReason || (exports.DisallowedAPIVersionReason = {}));
|
|
||||||
function apiVersionInRange(version, minimumVersion, maximumVersion) {
|
|
||||||
if (!semver.satisfies(version, `>=${minimumVersion}`)) {
|
|
||||||
return DisallowedAPIVersionReason.ACTION_TOO_NEW;
|
|
||||||
}
|
|
||||||
if (!semver.satisfies(version, `<=${maximumVersion}`)) {
|
|
||||||
return DisallowedAPIVersionReason.ACTION_TOO_OLD;
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
exports.apiVersionInRange = apiVersionInRange;
|
|
||||||
/**
|
|
||||||
* Retrieves the github auth token for use with the runner. There are
|
|
||||||
* three possible locations for the token:
|
|
||||||
*
|
|
||||||
* 1. from the cli (considered insecure)
|
|
||||||
* 2. from stdin
|
|
||||||
* 3. from the GITHUB_TOKEN environment variable
|
|
||||||
*
|
|
||||||
* If both 1 & 2 are specified, then an error is thrown.
|
|
||||||
* If 1 & 3 or 2 & 3 are specified, then the environment variable is ignored.
|
|
||||||
*
|
|
||||||
* @param githubAuth a github app token or PAT
|
|
||||||
* @param fromStdIn read the github app token or PAT from stdin up to, but excluding the first whitespace
|
|
||||||
* @param readable the readable stream to use for getting the token (defaults to stdin)
|
|
||||||
*
|
|
||||||
* @return a promise resolving to the auth token.
|
|
||||||
*/
|
|
||||||
async function getGitHubAuth(logger, githubAuth, fromStdIn, readable = process.stdin) {
|
|
||||||
if (githubAuth && fromStdIn) {
|
|
||||||
throw new Error("Cannot specify both `--github-auth` and `--github-auth-stdin`. Please use `--github-auth-stdin`, which is more secure.");
|
|
||||||
}
|
|
||||||
if (githubAuth) {
|
|
||||||
logger.warning("Using `--github-auth` via the CLI is insecure. Use `--github-auth-stdin` instead.");
|
|
||||||
return githubAuth;
|
|
||||||
}
|
|
||||||
if (fromStdIn) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
let token = "";
|
|
||||||
readable.on("data", (data) => {
|
|
||||||
token += data.toString("utf8");
|
|
||||||
});
|
|
||||||
readable.on("end", () => {
|
|
||||||
token = token.split(/\s+/)[0].trim();
|
|
||||||
if (token) {
|
|
||||||
resolve(token);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
reject(new Error("Standard input is empty"));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
readable.on("error", (err) => {
|
|
||||||
reject(err);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (process.env.GITHUB_TOKEN) {
|
|
||||||
return process.env.GITHUB_TOKEN;
|
|
||||||
}
|
|
||||||
throw new Error("No GitHub authentication token was specified. Please provide a token via the GITHUB_TOKEN environment variable, or by adding the `--github-auth-stdin` flag and passing the token via standard input.");
|
|
||||||
}
|
|
||||||
exports.getGitHubAuth = getGitHubAuth;
|
|
||||||
/**
|
|
||||||
* This error is used to indicate a runtime failure of an exhaustivity check enforced at compile time.
|
|
||||||
*/
|
|
||||||
class ExhaustivityCheckingError extends Error {
|
|
||||||
constructor(expectedExhaustiveValue) {
|
|
||||||
super("Internal error: exhaustivity checking failure");
|
|
||||||
this.expectedExhaustiveValue = expectedExhaustiveValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Used to perform compile-time exhaustivity checking on a value. This function will not be executed at runtime unless
|
|
||||||
* the type system has been subverted.
|
|
||||||
*/
|
|
||||||
function assertNever(value) {
|
|
||||||
throw new ExhaustivityCheckingError(value);
|
|
||||||
}
|
|
||||||
exports.assertNever = assertNever;
|
|
||||||
//# sourceMappingURL=util.js.map
|
//# sourceMappingURL=util.js.map
|
||||||
File diff suppressed because one or more lines are too long
121
lib/util.test.js
generated
121
lib/util.test.js
generated
@@ -1,4 +1,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
@@ -6,17 +9,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
result["default"] = mod;
|
result["default"] = 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 ava_1 = __importDefault(require("ava"));
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const os = __importStar(require("os"));
|
const os = __importStar(require("os"));
|
||||||
const stream = __importStar(require("stream"));
|
|
||||||
const github = __importStar(require("@actions/github"));
|
|
||||||
const ava_1 = __importDefault(require("ava"));
|
|
||||||
const sinon_1 = __importDefault(require("sinon"));
|
|
||||||
const api = __importStar(require("./api-client"));
|
|
||||||
const logging_1 = require("./logging");
|
const logging_1 = require("./logging");
|
||||||
const testing_utils_1 = require("./testing-utils");
|
const testing_utils_1 = require("./testing-utils");
|
||||||
const util = __importStar(require("./util"));
|
const util = __importStar(require("./util"));
|
||||||
@@ -28,10 +24,9 @@ ava_1.default("getToolNames", (t) => {
|
|||||||
});
|
});
|
||||||
ava_1.default("getMemoryFlag() should return the correct --ram flag", (t) => {
|
ava_1.default("getMemoryFlag() should return the correct --ram flag", (t) => {
|
||||||
const totalMem = Math.floor(os.totalmem() / (1024 * 1024));
|
const totalMem = Math.floor(os.totalmem() / (1024 * 1024));
|
||||||
const expectedThreshold = process.platform === "win32" ? 1536 : 1024;
|
|
||||||
const tests = [
|
const tests = [
|
||||||
[undefined, `--ram=${totalMem - expectedThreshold}`],
|
[undefined, `--ram=${totalMem - 256}`],
|
||||||
["", `--ram=${totalMem - expectedThreshold}`],
|
["", `--ram=${totalMem - 256}`],
|
||||||
["512", "--ram=512"],
|
["512", "--ram=512"],
|
||||||
];
|
];
|
||||||
for (const [input, expectedFlag] of tests) {
|
for (const [input, expectedFlag] of tests) {
|
||||||
@@ -71,6 +66,7 @@ ava_1.default("getThreadsFlag() throws if the threads input is not an integer",
|
|||||||
t.throws(() => util.getThreadsFlag("hello!", logging_1.getRunnerLogger(true)));
|
t.throws(() => util.getThreadsFlag("hello!", logging_1.getRunnerLogger(true)));
|
||||||
});
|
});
|
||||||
ava_1.default("isLocalRun() runs correctly", (t) => {
|
ava_1.default("isLocalRun() runs correctly", (t) => {
|
||||||
|
const origLocalRun = process.env.CODEQL_LOCAL_RUN;
|
||||||
process.env.CODEQL_LOCAL_RUN = "";
|
process.env.CODEQL_LOCAL_RUN = "";
|
||||||
t.assert(!util.isLocalRun());
|
t.assert(!util.isLocalRun());
|
||||||
process.env.CODEQL_LOCAL_RUN = "false";
|
process.env.CODEQL_LOCAL_RUN = "false";
|
||||||
@@ -81,6 +77,7 @@ ava_1.default("isLocalRun() runs correctly", (t) => {
|
|||||||
t.assert(util.isLocalRun());
|
t.assert(util.isLocalRun());
|
||||||
process.env.CODEQL_LOCAL_RUN = "hucairz";
|
process.env.CODEQL_LOCAL_RUN = "hucairz";
|
||||||
t.assert(util.isLocalRun());
|
t.assert(util.isLocalRun());
|
||||||
|
process.env.CODEQL_LOCAL_RUN = origLocalRun;
|
||||||
});
|
});
|
||||||
ava_1.default("getExtraOptionsEnvParam() succeeds on valid JSON with invalid options (for now)", (t) => {
|
ava_1.default("getExtraOptionsEnvParam() succeeds on valid JSON with invalid options (for now)", (t) => {
|
||||||
const origExtraOptions = process.env.CODEQL_ACTION_EXTRA_OPTIONS;
|
const origExtraOptions = process.env.CODEQL_ACTION_EXTRA_OPTIONS;
|
||||||
@@ -102,106 +99,4 @@ ava_1.default("getExtraOptionsEnvParam() fails on invalid JSON", (t) => {
|
|||||||
t.throws(util.getExtraOptionsEnvParam);
|
t.throws(util.getExtraOptionsEnvParam);
|
||||||
process.env.CODEQL_ACTION_EXTRA_OPTIONS = origExtraOptions;
|
process.env.CODEQL_ACTION_EXTRA_OPTIONS = origExtraOptions;
|
||||||
});
|
});
|
||||||
ava_1.default("parseGitHubUrl", (t) => {
|
|
||||||
t.deepEqual(util.parseGitHubUrl("github.com"), "https://github.com");
|
|
||||||
t.deepEqual(util.parseGitHubUrl("https://github.com"), "https://github.com");
|
|
||||||
t.deepEqual(util.parseGitHubUrl("https://api.github.com"), "https://github.com");
|
|
||||||
t.deepEqual(util.parseGitHubUrl("https://github.com/foo/bar"), "https://github.com");
|
|
||||||
t.deepEqual(util.parseGitHubUrl("github.example.com"), "https://github.example.com/");
|
|
||||||
t.deepEqual(util.parseGitHubUrl("https://github.example.com"), "https://github.example.com/");
|
|
||||||
t.deepEqual(util.parseGitHubUrl("https://api.github.example.com"), "https://github.example.com/");
|
|
||||||
t.deepEqual(util.parseGitHubUrl("https://github.example.com/api/v3"), "https://github.example.com/");
|
|
||||||
t.deepEqual(util.parseGitHubUrl("https://github.example.com:1234"), "https://github.example.com:1234/");
|
|
||||||
t.deepEqual(util.parseGitHubUrl("https://api.github.example.com:1234"), "https://github.example.com:1234/");
|
|
||||||
t.deepEqual(util.parseGitHubUrl("https://github.example.com:1234/api/v3"), "https://github.example.com:1234/");
|
|
||||||
t.deepEqual(util.parseGitHubUrl("https://github.example.com/base/path"), "https://github.example.com/base/path/");
|
|
||||||
t.deepEqual(util.parseGitHubUrl("https://github.example.com/base/path/api/v3"), "https://github.example.com/base/path/");
|
|
||||||
t.throws(() => util.parseGitHubUrl(""), {
|
|
||||||
message: '"" is not a valid URL',
|
|
||||||
});
|
|
||||||
t.throws(() => util.parseGitHubUrl("ssh://github.com"), {
|
|
||||||
message: '"ssh://github.com" is not a http or https URL',
|
|
||||||
});
|
|
||||||
t.throws(() => util.parseGitHubUrl("http:///::::433"), {
|
|
||||||
message: '"http:///::::433" is not a valid URL',
|
|
||||||
});
|
|
||||||
});
|
|
||||||
ava_1.default("allowed API versions", async (t) => {
|
|
||||||
t.is(util.apiVersionInRange("1.33.0", "1.33", "2.0"), undefined);
|
|
||||||
t.is(util.apiVersionInRange("1.33.1", "1.33", "2.0"), undefined);
|
|
||||||
t.is(util.apiVersionInRange("1.34.0", "1.33", "2.0"), undefined);
|
|
||||||
t.is(util.apiVersionInRange("2.0.0", "1.33", "2.0"), undefined);
|
|
||||||
t.is(util.apiVersionInRange("2.0.1", "1.33", "2.0"), undefined);
|
|
||||||
t.is(util.apiVersionInRange("1.32.0", "1.33", "2.0"), util.DisallowedAPIVersionReason.ACTION_TOO_NEW);
|
|
||||||
t.is(util.apiVersionInRange("2.1.0", "1.33", "2.0"), util.DisallowedAPIVersionReason.ACTION_TOO_OLD);
|
|
||||||
});
|
|
||||||
function mockGetMetaVersionHeader(versionHeader) {
|
|
||||||
// Passing an auth token is required, so we just use a dummy value
|
|
||||||
const client = github.getOctokit("123");
|
|
||||||
const response = {
|
|
||||||
headers: {
|
|
||||||
"x-github-enterprise-version": versionHeader,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
const spyGetContents = sinon_1.default
|
|
||||||
.stub(client.meta, "get")
|
|
||||||
.resolves(response);
|
|
||||||
sinon_1.default.stub(api, "getApiClient").value(() => client);
|
|
||||||
return spyGetContents;
|
|
||||||
}
|
|
||||||
ava_1.default("getGitHubVersion", async (t) => {
|
|
||||||
const v = await util.getGitHubVersion({
|
|
||||||
auth: "",
|
|
||||||
url: "https://github.com",
|
|
||||||
});
|
|
||||||
t.deepEqual(util.GitHubVariant.DOTCOM, v.type);
|
|
||||||
mockGetMetaVersionHeader("2.0");
|
|
||||||
const v2 = await util.getGitHubVersion({
|
|
||||||
auth: "",
|
|
||||||
url: "https://ghe.example.com",
|
|
||||||
});
|
|
||||||
t.deepEqual({ type: util.GitHubVariant.GHES, version: "2.0" }, v2);
|
|
||||||
mockGetMetaVersionHeader("GitHub AE");
|
|
||||||
const ghae = await util.getGitHubVersion({
|
|
||||||
auth: "",
|
|
||||||
url: "https://example.githubenterprise.com",
|
|
||||||
});
|
|
||||||
t.deepEqual({ type: util.GitHubVariant.GHAE }, ghae);
|
|
||||||
mockGetMetaVersionHeader(undefined);
|
|
||||||
const v3 = await util.getGitHubVersion({
|
|
||||||
auth: "",
|
|
||||||
url: "https://ghe.example.com",
|
|
||||||
});
|
|
||||||
t.deepEqual({ type: util.GitHubVariant.DOTCOM }, v3);
|
|
||||||
});
|
|
||||||
ava_1.default("getGitHubAuth", async (t) => {
|
|
||||||
const msgs = [];
|
|
||||||
const mockLogger = {
|
|
||||||
warning: (msg) => msgs.push(msg),
|
|
||||||
};
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
||||||
t.throwsAsync(async () => util.getGitHubAuth(mockLogger, "abc", true));
|
|
||||||
process.env.GITHUB_TOKEN = "123";
|
|
||||||
t.is("123", await util.getGitHubAuth(mockLogger, undefined, undefined));
|
|
||||||
t.is(msgs.length, 0);
|
|
||||||
t.is("abc", await util.getGitHubAuth(mockLogger, "abc", undefined));
|
|
||||||
t.is(msgs.length, 1); // warning expected
|
|
||||||
msgs.length = 0;
|
|
||||||
await mockStdInForAuth(t, mockLogger, "def", "def");
|
|
||||||
await mockStdInForAuth(t, mockLogger, "def", "", "def");
|
|
||||||
await mockStdInForAuth(t, mockLogger, "def", "def\n some extra garbage", "ghi");
|
|
||||||
await mockStdInForAuth(t, mockLogger, "defghi", "def", "ghi\n123");
|
|
||||||
await mockStdInForAuthExpectError(t, mockLogger, "");
|
|
||||||
await mockStdInForAuthExpectError(t, mockLogger, "", " ", "abc");
|
|
||||||
await mockStdInForAuthExpectError(t, mockLogger, " def\n some extra garbage", "ghi");
|
|
||||||
t.is(msgs.length, 0);
|
|
||||||
});
|
|
||||||
async function mockStdInForAuth(t, mockLogger, expected, ...text) {
|
|
||||||
const stdin = stream.Readable.from(text);
|
|
||||||
t.is(expected, await util.getGitHubAuth(mockLogger, undefined, true, stdin));
|
|
||||||
}
|
|
||||||
async function mockStdInForAuthExpectError(t, mockLogger, ...text) {
|
|
||||||
const stdin = stream.Readable.from(text);
|
|
||||||
await t.throwsAsync(async () => util.getGitHubAuth(mockLogger, undefined, true, stdin));
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=util.test.js.map
|
//# sourceMappingURL=util.test.js.map
|
||||||
File diff suppressed because one or more lines are too long
1
node_modules/.bin/loc
generated
vendored
1
node_modules/.bin/loc
generated
vendored
@@ -1 +0,0 @@
|
|||||||
../github-linguist/dist/cli.js
|
|
||||||
2
node_modules/.bin/uuid
generated
vendored
2
node_modules/.bin/uuid
generated
vendored
@@ -1 +1 @@
|
|||||||
../uuid/dist/bin/uuid
|
../uuid/bin/uuid
|
||||||
5713
node_modules/.package-lock.json
generated
vendored
5713
node_modules/.package-lock.json
generated
vendored
File diff suppressed because it is too large
Load Diff
9
node_modules/@actions/core/LICENSE.md
generated
vendored
9
node_modules/@actions/core/LICENSE.md
generated
vendored
@@ -1,9 +0,0 @@
|
|||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Copyright 2019 GitHub
|
|
||||||
|
|
||||||
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.
|
|
||||||
9
node_modules/@actions/core/README.md
generated
vendored
9
node_modules/@actions/core/README.md
generated
vendored
@@ -82,14 +82,7 @@ try {
|
|||||||
core.warning('myInput was not set');
|
core.warning('myInput was not set');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (core.isDebug()) {
|
|
||||||
// curl -v https://github.com
|
|
||||||
} else {
|
|
||||||
// curl https://github.com
|
|
||||||
}
|
|
||||||
|
|
||||||
// Do stuff
|
// Do stuff
|
||||||
core.info('Output to the actions build log')
|
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
core.error(`Error ${err}, action may still succeed though`);
|
core.error(`Error ${err}, action may still succeed though`);
|
||||||
@@ -144,4 +137,4 @@ const core = require('@actions/core');
|
|||||||
var pid = core.getState("pidToKill");
|
var pid = core.getState("pidToKill");
|
||||||
|
|
||||||
process.kill(pid);
|
process.kill(pid);
|
||||||
```
|
```
|
||||||
10
node_modules/@actions/core/lib/command.d.ts
generated
vendored
10
node_modules/@actions/core/lib/command.d.ts
generated
vendored
@@ -1,16 +1,16 @@
|
|||||||
interface CommandProperties {
|
interface CommandProperties {
|
||||||
[key: string]: any;
|
[key: string]: string;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Commands
|
* Commands
|
||||||
*
|
*
|
||||||
* Command Format:
|
* Command Format:
|
||||||
* ::name key=value,key=value::message
|
* ##[name key=value;key=value]message
|
||||||
*
|
*
|
||||||
* Examples:
|
* Examples:
|
||||||
* ::warning::This is the message
|
* ##[warning]This is the user warning message
|
||||||
* ::set-env name=MY_VAR::some value
|
* ##[set-secret name=mypassword]definitelyNotAPassword!
|
||||||
*/
|
*/
|
||||||
export declare function issueCommand(command: string, properties: CommandProperties, message: any): void;
|
export declare function issueCommand(command: string, properties: CommandProperties, message: string): void;
|
||||||
export declare function issue(name: string, message?: string): void;
|
export declare function issue(name: string, message?: string): void;
|
||||||
export {};
|
export {};
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user