mirror of
https://github.com/github/codeql-action.git
synced 2025-12-09 01:08:10 +08:00
Compare commits
4 Commits
codeql-bun
...
auto-fix-c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5beb81ff18 | ||
|
|
4b68707883 | ||
|
|
78e9a06da9 | ||
|
|
5ecd82aa69 |
14
.github/dependabot.yml
vendored
14
.github/dependabot.yml
vendored
@@ -1,14 +0,0 @@
|
|||||||
version: 2
|
|
||||||
updates:
|
|
||||||
- package-ecosystem: "npm"
|
|
||||||
directory: "/"
|
|
||||||
schedule:
|
|
||||||
interval: "weekly"
|
|
||||||
day: "thursday" # Gives us a working day to merge this before our typical release
|
|
||||||
labels:
|
|
||||||
- "Update dependencies"
|
|
||||||
- package-ecosystem: "npm"
|
|
||||||
directory: "/runner"
|
|
||||||
schedule:
|
|
||||||
interval: "weekly"
|
|
||||||
day: "thursday" # Gives us a working day to merge this before our typical release
|
|
||||||
84
.github/update-release-branch.py
vendored
84
.github/update-release-branch.py
vendored
@@ -4,17 +4,6 @@ import random
|
|||||||
import requests
|
import requests
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import json
|
|
||||||
import datetime
|
|
||||||
import os
|
|
||||||
|
|
||||||
EMPTY_CHANGELOG = """# CodeQL Action and CodeQL Runner Changelog
|
|
||||||
|
|
||||||
## [UNRELEASED]
|
|
||||||
|
|
||||||
No user facing changes.
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
# The branch being merged from.
|
# The branch being merged from.
|
||||||
# This is the one that contains day-to-day development work.
|
# This is the one that contains day-to-day development work.
|
||||||
@@ -60,42 +49,32 @@ def open_pr(repo, all_commits, short_main_sha, branch_name):
|
|||||||
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 = []
|
body = 'Merging ' + short_main_sha + ' into ' + LATEST_RELEASE_BRANCH
|
||||||
body.append('Merging ' + short_main_sha + ' into ' + LATEST_RELEASE_BRANCH)
|
|
||||||
|
|
||||||
conductor = get_conductor(repo, pull_requests, commits_without_pull_requests)
|
conductor = get_conductor(repo, pull_requests, commits_without_pull_requests)
|
||||||
body.append('')
|
body += '\n\nConductor for this PR is @' + conductor
|
||||||
body.append('Conductor for this PR is @' + conductor)
|
|
||||||
|
|
||||||
# List all PRs merged
|
# List all PRs merged
|
||||||
if len(pull_requests) > 0:
|
if len(pull_requests) > 0:
|
||||||
body.append('')
|
body += '\n\nContains the following pull requests:'
|
||||||
body.append('Contains the following pull requests:')
|
|
||||||
for pr in pull_requests:
|
for pr in pull_requests:
|
||||||
merger = get_merger_of_pr(repo, pr)
|
merger = get_merger_of_pr(repo, pr)
|
||||||
body.append('- #' + str(pr.number) + ' - ' + pr.title +' (@' + merger + ')')
|
body += '\n- #' + str(pr.number)
|
||||||
|
body += ' - ' + pr.title
|
||||||
|
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.append('')
|
body += '\n\nContains the following commits not from a pull request:'
|
||||||
body.append('Contains the following commits not from a pull request:')
|
|
||||||
for commit in commits_without_pull_requests:
|
for commit in commits_without_pull_requests:
|
||||||
body.append('- ' + commit.sha + ' - ' + get_truncated_commit_message(commit) + ' (@' + commit.author.login + ')')
|
body += '\n- ' + commit.sha
|
||||||
|
body += ' - ' + get_truncated_commit_message(commit)
|
||||||
body.append('')
|
body += ' (@' + commit.author.login + ')'
|
||||||
body.append('Please review the following:')
|
|
||||||
body.append(' - [ ] The CHANGELOG displays the correct version and date.')
|
|
||||||
body.append(' - [ ] The CHANGELOG includes all relevant, user-facing changes since the last release.')
|
|
||||||
body.append(' - [ ] There are no unexpected commits being merged into the ' + LATEST_RELEASE_BRANCH + ' branch.')
|
|
||||||
body.append(' - [ ] The docs team is aware of any documentation changes that need to be released.')
|
|
||||||
body.append(' - [ ] The mergeback PR is merged back into ' + MAIN_BRANCH + ' after this PR is merged.')
|
|
||||||
|
|
||||||
title = 'Merge ' + MAIN_BRANCH + ' into ' + LATEST_RELEASE_BRANCH
|
title = 'Merge ' + MAIN_BRANCH + ' into ' + LATEST_RELEASE_BRANCH
|
||||||
|
|
||||||
# Create the pull request
|
# Create the pull request
|
||||||
# PR checks won't be triggered on PRs created by Actions. Therefore mark the PR as draft so that
|
pr = repo.create_pull(title=title, body=body, head=branch_name, base=LATEST_RELEASE_BRANCH)
|
||||||
# a maintainer can take the PR out of draft, thereby triggering the PR checks.
|
|
||||||
pr = repo.create_pull(title=title, body='\n'.join(body), head=branch_name, base=LATEST_RELEASE_BRANCH, draft=True)
|
|
||||||
print('Created PR #' + str(pr.number))
|
print('Created PR #' + str(pr.number))
|
||||||
|
|
||||||
# Assign the conductor
|
# Assign the conductor
|
||||||
@@ -116,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 + '..' + ORIGIN + '/' + 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]
|
||||||
@@ -126,7 +105,7 @@ def get_commit_difference(repo):
|
|||||||
|
|
||||||
# Is the given commit the automatic merge commit from when merging a PR
|
# Is the given commit the automatic merge commit from when merging a PR
|
||||||
def is_pr_merge_commit(commit):
|
def is_pr_merge_commit(commit):
|
||||||
return commit.committer is not None and commit.committer.login == 'web-flow' and len(commit.parents) > 1
|
return commit.committer.login == 'web-flow' and len(commit.parents) > 1
|
||||||
|
|
||||||
# Gets a copy of the commit message that should display nicely
|
# Gets a copy of the commit message that should display nicely
|
||||||
def get_truncated_commit_message(commit):
|
def get_truncated_commit_message(commit):
|
||||||
@@ -156,28 +135,6 @@ def get_pr_for_commit(repo, commit):
|
|||||||
def get_merger_of_pr(repo, pr):
|
def get_merger_of_pr(repo, pr):
|
||||||
return repo.get_commit(pr.merge_commit_sha).author.login
|
return repo.get_commit(pr.merge_commit_sha).author.login
|
||||||
|
|
||||||
def get_current_version():
|
|
||||||
with open('package.json', 'r') as f:
|
|
||||||
return json.load(f)['version']
|
|
||||||
|
|
||||||
def get_today_string():
|
|
||||||
today = datetime.datetime.today()
|
|
||||||
return '{:%d %b %Y}'.format(today)
|
|
||||||
|
|
||||||
def update_changelog(version):
|
|
||||||
if (os.path.exists('CHANGELOG.md')):
|
|
||||||
content = ''
|
|
||||||
with open('CHANGELOG.md', 'r') as f:
|
|
||||||
content = f.read()
|
|
||||||
else:
|
|
||||||
content = EMPTY_CHANGELOG
|
|
||||||
|
|
||||||
newContent = content.replace('[UNRELEASED]', version + ' - ' + get_today_string(), 1)
|
|
||||||
|
|
||||||
with open('CHANGELOG.md', 'w') as f:
|
|
||||||
f.write(newContent)
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
if len(sys.argv) != 3:
|
if len(sys.argv) != 3:
|
||||||
raise Exception('Usage: update-release.branch.py <github token> <repository nwo>')
|
raise Exception('Usage: update-release.branch.py <github token> <repository nwo>')
|
||||||
@@ -185,11 +142,10 @@ def main():
|
|||||||
repository_nwo = sys.argv[2]
|
repository_nwo = sys.argv[2]
|
||||||
|
|
||||||
repo = Github(github_token).get_repo(repository_nwo)
|
repo = Github(github_token).get_repo(repository_nwo)
|
||||||
version = get_current_version()
|
|
||||||
|
|
||||||
# Print what we intend to go
|
# Print what we intend to go
|
||||||
print('Considering difference between ' + MAIN_BRANCH + ' and ' + LATEST_RELEASE_BRANCH)
|
print('Considering difference between ' + MAIN_BRANCH + ' and ' + LATEST_RELEASE_BRANCH)
|
||||||
short_main_sha = run_git('rev-parse', '--short', ORIGIN + '/' + MAIN_BRANCH).strip()
|
short_main_sha = run_git('rev-parse', '--short', MAIN_BRANCH).strip()
|
||||||
print('Current head of ' + MAIN_BRANCH + ' is ' + short_main_sha)
|
print('Current head of ' + MAIN_BRANCH + ' is ' + short_main_sha)
|
||||||
|
|
||||||
# See if there are any commits to merge in
|
# See if there are any commits to merge in
|
||||||
@@ -201,7 +157,7 @@ def main():
|
|||||||
# The branch name is based off of the name of branch being merged into
|
# The branch name is based off of the name of branch being merged into
|
||||||
# and the SHA of the branch being merged from. Thus if the branch already
|
# and the SHA of the branch being merged from. Thus if the branch already
|
||||||
# exists we can assume we don't need to recreate it.
|
# exists we can assume we don't need to recreate it.
|
||||||
new_branch_name = 'update-v' + version + '-' + short_main_sha
|
new_branch_name = 'update-' + LATEST_RELEASE_BRANCH + '-' + short_main_sha
|
||||||
print('Branch name is ' + new_branch_name)
|
print('Branch name is ' + new_branch_name)
|
||||||
|
|
||||||
# Check if the branch already exists. If so we can abort as this script
|
# Check if the branch already exists. If so we can abort as this script
|
||||||
@@ -212,15 +168,7 @@ def main():
|
|||||||
|
|
||||||
# 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, ORIGIN + '/' + MAIN_BRANCH)
|
run_git('checkout', '-b', new_branch_name, MAIN_BRANCH)
|
||||||
|
|
||||||
print('Updating changelog')
|
|
||||||
update_changelog(version)
|
|
||||||
|
|
||||||
# Create a commit that updates the CHANGELOG
|
|
||||||
run_git('add', 'CHANGELOG.md')
|
|
||||||
run_git('commit', '-m', version)
|
|
||||||
|
|
||||||
run_git('push', ORIGIN, new_branch_name)
|
run_git('push', ORIGIN, new_branch_name)
|
||||||
|
|
||||||
# Open a PR to update the branch
|
# Open a PR to update the branch
|
||||||
|
|||||||
@@ -5,9 +5,6 @@ on:
|
|||||||
paths:
|
paths:
|
||||||
- .github/workflows/check-expected-release-files.yml
|
- .github/workflows/check-expected-release-files.yml
|
||||||
- src/defaults.json
|
- src/defaults.json
|
||||||
# Run checks on reopened draft PRs to support triggering PR checks on draft PRs that were opened
|
|
||||||
# by other workflows.
|
|
||||||
types: [opened, synchronize, reopened, ready_for_review]
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check-expected-release-files:
|
check-expected-release-files:
|
||||||
|
|||||||
3
.github/workflows/codeql.yml
vendored
3
.github/workflows/codeql.yml
vendored
@@ -5,9 +5,6 @@ on:
|
|||||||
branches: [main, v1]
|
branches: [main, v1]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [main, v1]
|
branches: [main, v1]
|
||||||
# Run checks on reopened draft PRs to support triggering PR checks on draft PRs that were opened
|
|
||||||
# by other workflows.
|
|
||||||
types: [opened, synchronize, reopened, ready_for_review]
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# Identify the CodeQL tool versions to use in the analysis job.
|
# Identify the CodeQL tool versions to use in the analysis job.
|
||||||
|
|||||||
119
.github/workflows/post-release-mergeback.yml
vendored
119
.github/workflows/post-release-mergeback.yml
vendored
@@ -1,119 +0,0 @@
|
|||||||
# This workflow runs after a release of the action.
|
|
||||||
# It merges any changes from the release back into the
|
|
||||||
# main branch. Typically, this is just a single commit
|
|
||||||
# that updates the changelog.
|
|
||||||
name: Tag release and merge back
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
baseBranch:
|
|
||||||
description: 'The base branch to merge into'
|
|
||||||
default: main
|
|
||||||
required: false
|
|
||||||
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- v1
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
merge-back:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
if: github.repository == 'github/codeql-action'
|
|
||||||
env:
|
|
||||||
BASE_BRANCH: "${{ github.event.inputs.baseBranch || 'main' }}"
|
|
||||||
HEAD_BRANCH: "${{ github.head_ref || github.ref }}"
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Dump GitHub Event context
|
|
||||||
env:
|
|
||||||
GITHUB_EVENT_CONTEXT: "${{ toJson(github.event) }}"
|
|
||||||
run: echo "$GITHUB_EVENT_CONTEXT"
|
|
||||||
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- uses: actions/setup-node@v2
|
|
||||||
|
|
||||||
- name: Update git config
|
|
||||||
run: |
|
|
||||||
git config --global user.email "github-actions@github.com"
|
|
||||||
git config --global user.name "github-actions[bot]"
|
|
||||||
|
|
||||||
- name: Get version and new branch
|
|
||||||
id: getVersion
|
|
||||||
run: |
|
|
||||||
VERSION="v$(jq '.version' -r 'package.json')"
|
|
||||||
SHORT_SHA="${GITHUB_SHA:0:8}"
|
|
||||||
echo "::set-output name=version::$VERSION"
|
|
||||||
NEW_BRANCH="mergeback/${VERSION}-to-${BASE_BRANCH}-${SHORT_SHA}"
|
|
||||||
echo "::set-output name=newBranch::$NEW_BRANCH"
|
|
||||||
|
|
||||||
|
|
||||||
- name: Dump branches
|
|
||||||
env:
|
|
||||||
NEW_BRANCH: "${{ steps.getVersion.outputs.newBranch }}"
|
|
||||||
run: |
|
|
||||||
echo "BASE_BRANCH $BASE_BRANCH"
|
|
||||||
echo "HEAD_BRANCH $HEAD_BRANCH"
|
|
||||||
echo "NEW_BRANCH $NEW_BRANCH"
|
|
||||||
|
|
||||||
- name: Create mergeback branch
|
|
||||||
env:
|
|
||||||
NEW_BRANCH: "${{ steps.getVersion.outputs.newBranch }}"
|
|
||||||
run: |
|
|
||||||
git checkout -b "$NEW_BRANCH"
|
|
||||||
|
|
||||||
- name: Check for tag
|
|
||||||
id: check
|
|
||||||
env:
|
|
||||||
VERSION: "${{ steps.getVersion.outputs.version }}"
|
|
||||||
run: |
|
|
||||||
set +e # don't fail on an errored command
|
|
||||||
git ls-remote --tags origin | grep "$VERSION"
|
|
||||||
EXISTS="$?"
|
|
||||||
if [ "$EXISTS" -eq 0 ]; then
|
|
||||||
echo "Tag $TAG exists. Not going to re-release."
|
|
||||||
echo "::set-output name=exists::true"
|
|
||||||
else
|
|
||||||
echo "Tag $TAG does not exist yet."
|
|
||||||
fi
|
|
||||||
|
|
||||||
# we didn't tag the release during the update-release-branch workflow because the
|
|
||||||
# commit that actually makes it to the release branch is a merge commit,
|
|
||||||
# and not yet known during the first workflow. We tag now because we know the correct commit.
|
|
||||||
- name: Tag release
|
|
||||||
if: steps.check.outputs.exists != 'true'
|
|
||||||
env:
|
|
||||||
VERSION: ${{ steps.getVersion.outputs.version }}
|
|
||||||
run: |
|
|
||||||
git tag -a "$VERSION" -m "$VERSION"
|
|
||||||
git fetch --unshallow # unshallow the repo in order to allow pushes
|
|
||||||
git push origin --follow-tags "$VERSION"
|
|
||||||
|
|
||||||
- name: Create mergeback branch
|
|
||||||
if: steps.check.outputs.exists != 'true'
|
|
||||||
env:
|
|
||||||
VERSION: "${{ steps.getVersion.outputs.version }}"
|
|
||||||
NEW_BRANCH: "${{ steps.getVersion.outputs.newBranch }}"
|
|
||||||
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
|
||||||
run: |
|
|
||||||
set -exu
|
|
||||||
PR_TITLE="Mergeback $VERSION $HEAD_BRANCH into $BASE_BRANCH"
|
|
||||||
PR_BODY="Updates version and changelog."
|
|
||||||
|
|
||||||
# Update the changelog
|
|
||||||
perl -i -pe 's/^/## \[UNRELEASED\]\n\nNo user facing changes.\n\n/ if($.==3)' CHANGELOG.md
|
|
||||||
git add .
|
|
||||||
git commit -m "Update changelog and version after $VERSION"
|
|
||||||
npm version patch
|
|
||||||
|
|
||||||
git push origin "$NEW_BRANCH"
|
|
||||||
|
|
||||||
# PR checks won't be triggered on PRs created by Actions. Therefore mark the PR as draft
|
|
||||||
# so that a maintainer can take the PR out of draft, thereby triggering the PR checks.
|
|
||||||
gh pr create \
|
|
||||||
--head "$NEW_BRANCH" \
|
|
||||||
--base "$BASE_BRANCH" \
|
|
||||||
--title "$PR_TITLE" \
|
|
||||||
--label "Update dependencies" \
|
|
||||||
--body "$PR_BODY" \
|
|
||||||
--draft
|
|
||||||
303
.github/workflows/pr-checks.yml
vendored
303
.github/workflows/pr-checks.yml
vendored
@@ -7,10 +7,6 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches: [main, v1]
|
branches: [main, v1]
|
||||||
pull_request:
|
pull_request:
|
||||||
# Run checks on reopened draft PRs to support triggering PR checks on draft PRs that were opened
|
|
||||||
# by other workflows.
|
|
||||||
types: [opened, synchronize, reopened, ready_for_review]
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
lint-js:
|
lint-js:
|
||||||
@@ -30,7 +26,7 @@ jobs:
|
|||||||
run: .github/workflows/script/check-js.sh
|
run: .github/workflows/script/check-js.sh
|
||||||
|
|
||||||
check-node-modules:
|
check-node-modules:
|
||||||
runs-on: macos-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
@@ -69,219 +65,20 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
run: ./build.sh
|
run: ./build.sh
|
||||||
- uses: ./../action/analyze
|
- uses: ./../action/analyze
|
||||||
id: analysis
|
|
||||||
env:
|
env:
|
||||||
TEST_MODE: true
|
TEST_MODE: true
|
||||||
- run: |
|
- run: |
|
||||||
CPP_DB=${{ fromJson(steps.analysis.outputs.db-locations).cpp }}
|
cd "$RUNNER_TEMP/customDbLocation"
|
||||||
if [[ ! -d $CPP_DB ]] || [[ ! $CPP_DB == ${{ runner.temp }}/customDbLocation/* ]]; then
|
# List all directories as there will be precisely one directory per database
|
||||||
echo "Did not create a database for CPP, or created it in the wrong location."
|
# but there may be other files in this directory such as query suites.
|
||||||
exit 1
|
if [ "$(ls -d */ | wc -l)" != 6 ] || \
|
||||||
fi
|
[[ ! -d cpp ]] || \
|
||||||
CSHARP_DB=${{ fromJson(steps.analysis.outputs.db-locations).csharp }}
|
[[ ! -d csharp ]] || \
|
||||||
if [[ ! -d $CSHARP_DB ]] || [[ ! $CSHARP_DB == ${{ runner.temp }}/customDbLocation/* ]]; then
|
[[ ! -d go ]] || \
|
||||||
echo "Did not create a database for C Sharp, or created it in the wrong location."
|
[[ ! -d java ]] || \
|
||||||
exit 1
|
[[ ! -d javascript ]] || \
|
||||||
fi
|
[[ ! -d python ]]; then
|
||||||
GO_DB=${{ fromJson(steps.analysis.outputs.db-locations).go }}
|
echo "Did not find expected number of databases. Database dir contains: $(ls)"
|
||||||
if [[ ! -d $GO_DB ]] || [[ ! $GO_DB == ${{ runner.temp }}/customDbLocation/* ]]; then
|
|
||||||
echo "Did not create a database for Go, or created it in the wrong location."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
JAVA_DB=${{ fromJson(steps.analysis.outputs.db-locations).java }}
|
|
||||||
if [[ ! -d $JAVA_DB ]] || [[ ! $JAVA_DB == ${{ runner.temp }}/customDbLocation/* ]]; then
|
|
||||||
echo "Did not create a database for Java, or created it in the wrong location."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
JAVASCRIPT_DB=${{ fromJson(steps.analysis.outputs.db-locations).javascript }}
|
|
||||||
if [[ ! -d $JAVASCRIPT_DB ]] || [[ ! $JAVASCRIPT_DB == ${{ runner.temp }}/customDbLocation/* ]]; then
|
|
||||||
echo "Did not create a database for Javascript, or created it in the wrong location."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
PYTHON_DB=${{ fromJson(steps.analysis.outputs.db-locations).python }}
|
|
||||||
if [[ ! -d $PYTHON_DB ]] || [[ ! $PYTHON_DB == ${{ runner.temp }}/customDbLocation/* ]]; then
|
|
||||||
echo "Did not create a database for Python, or created it in the wrong location."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Packaging test that runs against a javascript database
|
|
||||||
# Specifying packs in the config file.
|
|
||||||
test-packaging-javascript-config:
|
|
||||||
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
|
|
||||||
with:
|
|
||||||
config-file: ".github/codeql/codeql-config-packaging.yml"
|
|
||||||
languages: javascript
|
|
||||||
- name: Build code
|
|
||||||
shell: bash
|
|
||||||
run: ./build.sh
|
|
||||||
- uses: ./../action/analyze
|
|
||||||
with:
|
|
||||||
output: "${{ runner.temp }}/results"
|
|
||||||
env:
|
|
||||||
TEST_MODE: true
|
|
||||||
- name: Assert Results
|
|
||||||
run: |
|
|
||||||
cd "$RUNNER_TEMP/results"
|
|
||||||
# We should have 3 hits from these rules
|
|
||||||
EXPECTED_RULES="javascript/example/empty-or-one-block javascript/example/empty-or-one-block javascript/example/two-block"
|
|
||||||
|
|
||||||
# use tr to replace newlines with spaces and xargs to trim leading and trailing whitespace
|
|
||||||
RULES="$(cat javascript.sarif | jq -r '.runs[0].results[].ruleId' | sort | tr "\n" " " | xargs)"
|
|
||||||
echo "Found matching rules '$RULES'"
|
|
||||||
if [ "$RULES" != "$EXPECTED_RULES" ]; then
|
|
||||||
echo "Did not match expected rules '$EXPECTED_RULES'."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Packaging test that runs against a javascript database
|
|
||||||
# Specifying packs as an input.
|
|
||||||
test-packaging-javascript-inputs:
|
|
||||||
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
|
|
||||||
with:
|
|
||||||
config-file: ".github/codeql/codeql-config-packaging2.yml"
|
|
||||||
languages: javascript
|
|
||||||
packs: dsp-testing/codeql-pack1@0.0.4, dsp-testing/codeql-pack2
|
|
||||||
|
|
||||||
- name: Build code
|
|
||||||
shell: bash
|
|
||||||
run: ./build.sh
|
|
||||||
- uses: ./../action/analyze
|
|
||||||
with:
|
|
||||||
output: "${{ runner.temp }}/results"
|
|
||||||
env:
|
|
||||||
TEST_MODE: true
|
|
||||||
- name: Assert Results
|
|
||||||
run: |
|
|
||||||
cd "$RUNNER_TEMP/results"
|
|
||||||
# We should have 3 hits from these rules
|
|
||||||
EXPECTED_RULES="javascript/example/empty-or-one-block javascript/example/empty-or-one-block javascript/example/two-block"
|
|
||||||
|
|
||||||
# use tr to replace newlines with spaces and xargs to trim leading and trailing whitespace
|
|
||||||
RULES="$(cat javascript.sarif | jq -r '.runs[0].results[].ruleId' | sort | tr "\n" " " | xargs)"
|
|
||||||
echo "Found matching rules '$RULES'"
|
|
||||||
if [ "$RULES" != "$EXPECTED_RULES" ]; then
|
|
||||||
echo "Did not match expected rules '$EXPECTED_RULES'."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Packaging test that runs against a javascript database
|
|
||||||
# Specifying packs in the config file and inputs.
|
|
||||||
test-packaging-javascript-config-and-inputs:
|
|
||||||
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
|
|
||||||
with:
|
|
||||||
config-file: ".github/codeql/codeql-config-packaging3.yml"
|
|
||||||
packs: +dsp-testing/codeql-pack1@0.0.4
|
|
||||||
languages: javascript
|
|
||||||
|
|
||||||
- name: Build code
|
|
||||||
shell: bash
|
|
||||||
run: ./build.sh
|
|
||||||
- uses: ./../action/analyze
|
|
||||||
with:
|
|
||||||
output: "${{ runner.temp }}/results"
|
|
||||||
env:
|
|
||||||
TEST_MODE: true
|
|
||||||
- name: Assert Results
|
|
||||||
run: |
|
|
||||||
cd "$RUNNER_TEMP/results"
|
|
||||||
# We should have 3 hits from these rules
|
|
||||||
EXPECTED_RULES="javascript/example/empty-or-one-block javascript/example/empty-or-one-block javascript/example/two-block"
|
|
||||||
|
|
||||||
# use tr to replace newlines with spaces and xargs to trim leading and trailing whitespace
|
|
||||||
RULES="$(cat javascript.sarif | jq -r '.runs[0].results[].ruleId' | sort | tr "\n" " " | xargs)"
|
|
||||||
echo "Found matching rules '$RULES'"
|
|
||||||
if [ "$RULES" != "$EXPECTED_RULES" ]; then
|
|
||||||
echo "Did not match expected rules '$EXPECTED_RULES'."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Tests a split workflow where database construction and query execution happen in different steps
|
|
||||||
test-split-workflow:
|
|
||||||
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
|
|
||||||
with:
|
|
||||||
config-file: ".github/codeql/codeql-config-packaging3.yml"
|
|
||||||
packs: +dsp-testing/codeql-pack1@0.0.4
|
|
||||||
languages: javascript
|
|
||||||
tools: latest
|
|
||||||
- name: Build code
|
|
||||||
shell: bash
|
|
||||||
run: ./build.sh
|
|
||||||
- uses: ./../action/analyze
|
|
||||||
with:
|
|
||||||
skip-queries: true
|
|
||||||
output: "${{ runner.temp }}/results"
|
|
||||||
env:
|
|
||||||
TEST_MODE: true
|
|
||||||
- name: Assert No Results
|
|
||||||
run: |
|
|
||||||
if [ "$(ls -A $RUNNER_TEMP/results)" ]; then
|
|
||||||
echo "Expected results directory to be empty after skipping query execution!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
- uses: ./../action/analyze
|
|
||||||
with:
|
|
||||||
output: "${{ runner.temp }}/results"
|
|
||||||
env:
|
|
||||||
TEST_MODE: true
|
|
||||||
- name: Assert Results
|
|
||||||
run: |
|
|
||||||
cd "$RUNNER_TEMP/results"
|
|
||||||
# We should have 3 hits from these rules
|
|
||||||
EXPECTED_RULES="javascript/example/empty-or-one-block javascript/example/empty-or-one-block javascript/example/two-block"
|
|
||||||
|
|
||||||
# use tr to replace newlines with spaces and xargs to trim leading and trailing whitespace
|
|
||||||
RULES="$(cat javascript.sarif | jq -r '.runs[0].results[].ruleId' | sort | tr "\n" " " | xargs)"
|
|
||||||
echo "Found matching rules '$RULES'"
|
|
||||||
if [ "$RULES" != "$EXPECTED_RULES" ]; then
|
|
||||||
echo "Did not match expected rules '$EXPECTED_RULES'."
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -291,7 +88,6 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
versions: ${{ steps.compare.outputs.versions }}
|
versions: ${{ steps.compare.outputs.versions }}
|
||||||
nightly-url: ${{ steps.get-url.outputs.nightly-url }}
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
@@ -317,45 +113,22 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
tools: latest
|
tools: latest
|
||||||
languages: javascript
|
languages: javascript
|
||||||
- name: Remove empty database
|
- name: Compare default and latest CodeQL bundle versions
|
||||||
# allows us to run init a third time
|
|
||||||
run: |
|
|
||||||
rm -rf "$RUNNER_TEMP/codeql_databases"
|
|
||||||
- name: Get nightly release URL
|
|
||||||
id: get-url
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
|
|
||||||
shell: bash
|
|
||||||
# This workflow step gets an unstable testing version of the CodeQL CLI. It should not be used outside of these tests.
|
|
||||||
run: |
|
|
||||||
export LATEST=`gh release list --repo dsp-testing/codeql-cli-nightlies -L 1 | cut -f 3`
|
|
||||||
echo "::set-output name=nightly-url::https://github.com/dsp-testing/codeql-cli-nightlies/releases/download/$LATEST/codeql-bundle.tar.gz"
|
|
||||||
- name: Init with a CodeQL bundle from a nightly release
|
|
||||||
id: init-nightly
|
|
||||||
uses: ./../action/init
|
|
||||||
with:
|
|
||||||
tools: ${{ steps.get-url.outputs.nightly-url }}
|
|
||||||
languages: javascript
|
|
||||||
- name: Compare CodeQL bundle versions
|
|
||||||
id: compare
|
id: compare
|
||||||
env:
|
env:
|
||||||
CODEQL_DEFAULT: ${{ steps.init-default.outputs.codeql-path }}
|
CODEQL_DEFAULT: ${{ steps.init-default.outputs.codeql-path }}
|
||||||
CODEQL_LATEST: ${{ steps.init-latest.outputs.codeql-path }}
|
CODEQL_LATEST: ${{ steps.init-latest.outputs.codeql-path }}
|
||||||
CODEQL_NIGHTLY: ${{ steps.init-nightly.outputs.codeql-path }}
|
|
||||||
NIGHTLY_URL: ${{ steps.get-url.outputs.nightly-url }}
|
|
||||||
run: |
|
run: |
|
||||||
CODEQL_VERSION_DEFAULT="$("$CODEQL_DEFAULT" version --format terse)"
|
CODEQL_VERSION_DEFAULT="$("$CODEQL_DEFAULT" version --format terse)"
|
||||||
CODEQL_VERSION_LATEST="$("$CODEQL_LATEST" version --format terse)"
|
CODEQL_VERSION_LATEST="$("$CODEQL_LATEST" version --format terse)"
|
||||||
CODEQL_VERSION_NIGHTLY="$("$CODEQL_NIGHTLY" version --format terse)"
|
|
||||||
echo "Default CodeQL bundle version is $CODEQL_VERSION_DEFAULT"
|
echo "Default CodeQL bundle version is $CODEQL_VERSION_DEFAULT"
|
||||||
echo "Latest CodeQL bundle version is $CODEQL_VERSION_LATEST"
|
echo "Latest CodeQL bundle version is $CODEQL_VERSION_LATEST"
|
||||||
echo "Nightly CodeQL bundle version is $CODEQL_VERSION_NIGHTLY"
|
|
||||||
if [[ "$CODEQL_VERSION_DEFAULT" == "$CODEQL_VERSION_LATEST" ]]; then
|
if [[ "$CODEQL_VERSION_DEFAULT" == "$CODEQL_VERSION_LATEST" ]]; then
|
||||||
# Skip `tools: latest` since it would be the same as `tools: null`
|
# Just use `tools: null` to avoid duplication in the integration tests.
|
||||||
VERSIONS_JSON="[null, \"$NIGHTLY_URL\"]"
|
VERSIONS_JSON='[null]'
|
||||||
else
|
else
|
||||||
# Run integration tests with all three bundles.
|
# Use both `tools: null` and `tools: latest` in the integration tests.
|
||||||
VERSIONS_JSON="[null, \"$NIGHTLY_URL\", \"latest\"]"
|
VERSIONS_JSON='[null, "latest"]'
|
||||||
fi
|
fi
|
||||||
# Output a JSON-encoded list with the distinct versions to test against.
|
# Output a JSON-encoded list with the distinct versions to test against.
|
||||||
echo "Suggested matrix config for integration tests: $VERSIONS_JSON"
|
echo "Suggested matrix config for integration tests: $VERSIONS_JSON"
|
||||||
@@ -877,45 +650,3 @@ jobs:
|
|||||||
# Deliberately don't use TEST_MODE here. This is specifically testing
|
# Deliberately don't use TEST_MODE here. This is specifically testing
|
||||||
# the compatibility with the API.
|
# the compatibility with the API.
|
||||||
runner/dist/codeql-runner-linux upload --sarif-file src/testdata/empty-sarif.sarif --repository $GITHUB_REPOSITORY --commit $GITHUB_SHA --ref $GITHUB_REF --github-url $GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
runner/dist/codeql-runner-linux upload --sarif-file src/testdata/empty-sarif.sarif --repository $GITHUB_REPOSITORY --commit $GITHUB_SHA --ref $GITHUB_REF --github-url $GITHUB_SERVER_URL --github-auth ${{ github.token }}
|
||||||
|
|
||||||
multi-language-repo_test-local-codeql:
|
|
||||||
needs: [check-js, check-node-modules, check-codeql-versions]
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Move codeql-action
|
|
||||||
run: |
|
|
||||||
wget ${{ needs.check-codeql-versions.outputs.nightly-url }}
|
|
||||||
mkdir ../action
|
|
||||||
mv * .github ../action/
|
|
||||||
mv ../action/tests/multi-language-repo/{*,.github} .
|
|
||||||
mv ../action/.github/workflows .github
|
|
||||||
- uses: ./../action/init
|
|
||||||
with:
|
|
||||||
tools: ../action/codeql-bundle.tar.gz
|
|
||||||
- name: Build code
|
|
||||||
run: ./build.sh
|
|
||||||
- uses: ./../action/analyze
|
|
||||||
|
|
||||||
test-javascript-source-root:
|
|
||||||
needs: [check-js, check-node-modules]
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- uses: ./init
|
|
||||||
with:
|
|
||||||
languages: javascript
|
|
||||||
source-root: tests/multi-language-repo
|
|
||||||
- uses: ./analyze
|
|
||||||
with:
|
|
||||||
skip-queries: true
|
|
||||||
upload: false
|
|
||||||
- name: Assert database exists
|
|
||||||
run: |
|
|
||||||
cd "$RUNNER_TEMP/codeql_databases"
|
|
||||||
if [[ ! -d javascript ]]; then
|
|
||||||
echo "Did not find a JavaScript database"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|||||||
3
.github/workflows/python-deps.yml
vendored
3
.github/workflows/python-deps.yml
vendored
@@ -4,9 +4,6 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches: [main, v1]
|
branches: [main, v1]
|
||||||
pull_request:
|
pull_request:
|
||||||
# Run checks on reopened draft PRs to support triggering PR checks on draft PRs that were opened
|
|
||||||
# by other workflows.
|
|
||||||
types: [opened, synchronize, reopened, ready_for_review]
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test-setup-python-scripts:
|
test-setup-python-scripts:
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ if [ ! -z "$(git status --porcelain)" ]; then
|
|||||||
>&2 echo "Failed: Repo should be clean before testing!"
|
>&2 echo "Failed: Repo should be clean before testing!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
sudo npm install --force -g npm@latest
|
|
||||||
# Reinstall modules and then clean to remove absolute paths
|
# Reinstall modules and then clean to remove absolute paths
|
||||||
# Use 'npm ci' instead of 'npm install' as this is intended to be reproducible
|
# Use 'npm ci' instead of 'npm install' as this is intended to be reproducible
|
||||||
npm ci
|
npm ci
|
||||||
@@ -15,7 +14,7 @@ npm run removeNPMAbsolutePaths
|
|||||||
# Check that repo is still clean
|
# Check that repo is still clean
|
||||||
if [ ! -z "$(git status --porcelain)" ]; then
|
if [ ! -z "$(git status --porcelain)" ]; then
|
||||||
# If we get a fail here then the PR needs attention
|
# If we get a fail here then the PR needs attention
|
||||||
>&2 echo "Failed: node_modules are not up to date. Run 'npm ci && npm run removeNPMAbsolutePaths' on a macOS machine to update. Note it is important this command is run on macOS and not any other operating system as there is one dependency (fsevents) that is needed for macOS and may not be installed if the command is run on a Windows or Linux machine."
|
>&2 echo "Failed: node_modules are not up to date. Run 'npm ci' and 'npm run removeNPMAbsolutePaths' to update"
|
||||||
git status
|
git status
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
39
.github/workflows/update-dependencies.yml
vendored
39
.github/workflows/update-dependencies.yml
vendored
@@ -1,39 +0,0 @@
|
|||||||
name: Update dependencies
|
|
||||||
on:
|
|
||||||
pull_request_target:
|
|
||||||
types: [opened, synchronize, reopened, ready_for_review, labeled]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
update:
|
|
||||||
name: Update dependencies
|
|
||||||
runs-on: macos-latest
|
|
||||||
if: contains(github.event.pull_request.labels.*.name, 'Update dependencies')
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Remove PR label
|
|
||||||
env:
|
|
||||||
REPOSITORY: '${{ github.repository }}'
|
|
||||||
PR_NUMBER: '${{ github.event.pull_request.number }}'
|
|
||||||
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
|
|
||||||
run: |
|
|
||||||
gh api "repos/$REPOSITORY/issues/$PR_NUMBER/labels/Update%20dependencies" -X DELETE
|
|
||||||
|
|
||||||
- name: Push updated dependencies
|
|
||||||
env:
|
|
||||||
BRANCH: '${{ github.head_ref }}'
|
|
||||||
run: |
|
|
||||||
git fetch
|
|
||||||
git checkout $BRANCH
|
|
||||||
sudo npm install --force -g npm@latest
|
|
||||||
npm install
|
|
||||||
npm ci
|
|
||||||
npm run removeNPMAbsolutePaths
|
|
||||||
if [ ! -z "$(git status --porcelain)" ]; then
|
|
||||||
git config --global user.email "github-actions@github.com"
|
|
||||||
git config --global user.name "github-actions[bot]"
|
|
||||||
git add node_modules
|
|
||||||
git commit -am "Update checked-in dependencies"
|
|
||||||
git push origin "$BRANCH"
|
|
||||||
fi
|
|
||||||
9
.github/workflows/update-release-branch.yml
vendored
9
.github/workflows/update-release-branch.yml
vendored
@@ -22,17 +22,12 @@ jobs:
|
|||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v2
|
||||||
with:
|
with:
|
||||||
python-version: 3.8
|
python-version: 3.5
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install PyGithub==1.55 requests
|
pip install PyGithub==1.51 requests
|
||||||
|
|
||||||
- name: Update git config
|
|
||||||
run: |
|
|
||||||
git config --global user.email "github-actions@github.com"
|
|
||||||
git config --global user.name "github-actions[bot]"
|
|
||||||
|
|
||||||
- name: Update release branch
|
- name: Update release branch
|
||||||
run: python .github/update-release-branch.py ${{ secrets.GITHUB_TOKEN }} ${{ github.repository }}
|
run: python .github/update-release-branch.py ${{ secrets.GITHUB_TOKEN }} ${{ github.repository }}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
update-supported-enterprise-server-versions:
|
update-supported-enterprise-server-versions:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: ${{ github.repository == 'github/codeql-action' }}
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Setup Python
|
- name: Setup Python
|
||||||
|
|||||||
53
CHANGELOG.md
53
CHANGELOG.md
@@ -2,56 +2,5 @@
|
|||||||
|
|
||||||
## [UNRELEASED]
|
## [UNRELEASED]
|
||||||
|
|
||||||
No user facing changes.
|
|
||||||
|
|
||||||
## 1.0.10 - 03 Aug 2021
|
|
||||||
|
|
||||||
- Fix an issue where a summary of diagnostics information from CodeQL was not output to the logs of the `analyze` step of the Action. [#672](https://github.com/github/codeql-action/pull/672)
|
|
||||||
|
|
||||||
## 1.0.9 - 02 Aug 2021
|
|
||||||
|
|
||||||
No user facing changes.
|
|
||||||
|
|
||||||
## 1.0.8 - 26 Jul 2021
|
|
||||||
|
|
||||||
- Update default CodeQL bundle version to 2.5.8. [#631](https://github.com/github/codeql-action/pull/631)
|
|
||||||
|
|
||||||
## 1.0.7 - 21 Jul 2021
|
|
||||||
|
|
||||||
No user facing changes.
|
|
||||||
|
|
||||||
## 1.0.6 - 19 Jul 2021
|
|
||||||
|
|
||||||
- The `init` step of the Action now supports a `source-root` input as a path to the root source-code directory. By default, the path is relative to `$GITHUB_WORKSPACE`. [#607](https://github.com/github/codeql-action/pull/607)
|
|
||||||
- The `init` step will now try to install a few Python tools needed by this Action when running on a self-hosted runner. [#616](https://github.com/github/codeql-action/pull/616)
|
|
||||||
|
|
||||||
## 1.0.5 - 12 Jul 2021
|
|
||||||
|
|
||||||
- The `analyze` step of the Action now supports a `skip-queries` option to merely build the CodeQL database without analyzing. This functionality is not present in the runner. Additionally, the step will no longer fail if it encounters a finalized database, and will instead continue with query execution. [#602](https://github.com/github/codeql-action/pull/602)
|
|
||||||
- Update the warning message when the baseline lines of code count is unavailable. [#608](https://github.com/github/codeql-action/pull/608)
|
|
||||||
|
|
||||||
## 1.0.4 - 28 Jun 2021
|
|
||||||
|
|
||||||
- Fix `RUNNER_TEMP environment variable must be set` when using runner. [#594](https://github.com/github/codeql-action/pull/594)
|
|
||||||
- Fix couting of lines of code for C# projects. [#586](https://github.com/github/codeql-action/pull/586)
|
|
||||||
|
|
||||||
## 1.0.3 - 23 Jun 2021
|
|
||||||
|
|
||||||
No user facing changes.
|
|
||||||
|
|
||||||
## 1.0.2 - 17 Jun 2021
|
|
||||||
|
|
||||||
- Fix out of memory in hash computation. [#550](https://github.com/github/codeql-action/pull/550)
|
|
||||||
- Clean up logging during analyze results. [#557](https://github.com/github/codeql-action/pull/557)
|
|
||||||
- Add `--finalize-dataset` to `database finalize` call, freeing up some disk space after database creation. [#558](https://github.com/github/codeql-action/pull/558)
|
|
||||||
|
|
||||||
## 1.0.1 - 07 Jun 2021
|
|
||||||
|
|
||||||
- Pass the `--sarif-group-rules-by-pack` argument to CodeQL CLI invocations that generate SARIF. This means the SARIF rule object for each query will now be found underneath its corresponding query pack in `runs[].tool.extensions`. [#546](https://github.com/github/codeql-action/pull/546)
|
|
||||||
- Output the location of CodeQL databases created in the analyze step. [#543](https://github.com/github/codeql-action/pull/543)
|
|
||||||
|
|
||||||
## 1.0.0 - 31 May 2021
|
|
||||||
|
|
||||||
- Add this changelog file. [#507](https://github.com/github/codeql-action/pull/507)
|
- Add this changelog file. [#507](https://github.com/github/codeql-action/pull/507)
|
||||||
- Improve grouping of analysis logs. Add a new log group containing a summary of metrics and diagnostics, if they were produced by CodeQL builtin queries. [#515](https://github.com/github/codeql-action/pull/515)
|
- Improve grouping of analysis logs. Add a new log group containing a summary of metrics and diagnostics, if they were produced by CodeQL builtin queries. [#515](https://github.com/github/codeql-action/pull/515)
|
||||||
- Add metrics and diagnostics summaries from custom query suites to the analysis summary log group. [#532](https://github.com/github/codeql-action/pull/532)
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
**/* @github/codeql-action-reviewers
|
|
||||||
@@ -12,7 +12,7 @@ Please note that this project is released with a [Contributor Code of Conduct][c
|
|||||||
|
|
||||||
## Development and Testing
|
## Development and Testing
|
||||||
|
|
||||||
Before you start, ensure that you have a recent version of node (14 or higher) installed, along with a recent version of npm (7 or higher). You can see which version of node is used by the action in `init/action.yml`.
|
Before you start, ensure that you have a recent version of node installed. You can see which version of node is used by the action in `init/action.yml`.
|
||||||
|
|
||||||
### Common tasks
|
### Common tasks
|
||||||
|
|
||||||
@@ -28,12 +28,32 @@ You may want to run `tsc --watch` from the command line or inside of vscode in o
|
|||||||
|
|
||||||
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.
|
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`. Note that due to a macOS-specific dependency, this command should be run on a macOS machine. There is a PR check to ensure the consistency of the `node_modules` directory.
|
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.
|
||||||
|
|
||||||
|
### Running the action locally
|
||||||
|
|
||||||
|
It is possible to run this action locally via [act](https://github.com/nektos/act) via the following steps:
|
||||||
|
|
||||||
|
1. Create a GitHub [Personal Access Token](https://github.com/settings/tokens) (PAT).
|
||||||
|
1. Install [act](https://github.com/nektos/act) v0.2.10 or greater.
|
||||||
|
1. Add a `.env` file in the root of the project you are running:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
CODEQL_LOCAL_RUN=true
|
||||||
|
GITHUB_SERVER_URL=https://github.com
|
||||||
|
|
||||||
|
# Optional, for better logging
|
||||||
|
GITHUB_JOB=<ANY_JOB_NAME>
|
||||||
|
```
|
||||||
|
|
||||||
|
1. Run `act -j codeql -s GITHUB_TOKEN=<PAT>`
|
||||||
|
|
||||||
|
Running locally will generate the CodeQL database and run all the queries, but it will avoid uploading and reporting results to GitHub. Note that this must be done on a repository that _consumes_ this action, not this repository. The use case is to debug failures of this action on specific repositories.
|
||||||
|
|
||||||
### Integration tests
|
### Integration tests
|
||||||
|
|
||||||
As well as the unit tests (see _Common tasks_ above), there are integration tests, defined in `.github/workflows/integration-testing.yml`. These are run by a CI check. Depending on the change you’re making, you may want to add a test to this file or extend an existing one.
|
As well as the unit tests (see _Common tasks_ above), there are integration tests, defined in `.github/workflows/integration-testing.yml`. These are run by a CI check. Depending on the change you’re making, you may want to add a test to this file or extend an existing one.
|
||||||
|
|||||||
12
README.md
12
README.md
@@ -1,6 +1,6 @@
|
|||||||
# CodeQL Action
|
# CodeQL Action
|
||||||
|
|
||||||
This action runs GitHub's industry-leading semantic code analysis engine, CodeQL, against a repository's source code to find security vulnerabilities. It then automatically uploads the results to GitHub so they can be displayed in the repository's security tab. CodeQL runs an extensible set of [queries](https://github.com/github/codeql), which have been developed by the community and the [GitHub Security Lab](https://securitylab.github.com/) to find common vulnerabilities in your code.
|
This action runs GitHub's industry-leading static analysis engine, CodeQL, against a repository's source code to find security vulnerabilities. It then automatically uploads the results to GitHub so they can be displayed in the repository's security tab. CodeQL runs an extensible set of [queries](https://github.com/github/codeql), which have been developed by the community and the [GitHub Security Lab](https://securitylab.github.com/) to find common vulnerabilities in your code.
|
||||||
|
|
||||||
For a list of recent changes, see the CodeQL Action's [changelog](CHANGELOG.md).
|
For a list of recent changes, see the CodeQL Action's [changelog](CHANGELOG.md).
|
||||||
|
|
||||||
@@ -22,9 +22,7 @@ name: "Code Scanning - Action"
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [main]
|
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [main]
|
|
||||||
schedule:
|
schedule:
|
||||||
# ┌───────────── minute (0 - 59)
|
# ┌───────────── minute (0 - 59)
|
||||||
# │ ┌───────────── hour (0 - 23)
|
# │ ┌───────────── hour (0 - 23)
|
||||||
@@ -130,11 +128,3 @@ By default, this will override any queries specified in a config file. If you wi
|
|||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
Read about [troubleshooting code scanning](https://help.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/troubleshooting-code-scanning).
|
Read about [troubleshooting code scanning](https://help.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/troubleshooting-code-scanning).
|
||||||
|
|
||||||
### Note on "missing analysis" message
|
|
||||||
|
|
||||||
The very first time code scanning is run and if it is on a pull request, you will probably get a message mentioning a "missing analysis". This is expected.
|
|
||||||
|
|
||||||
After code scanning has analyzed the code in a pull request, it needs to compare the analysis of the topic branch (the merge commit of the branch you used to create the pull request) with the analysis of the base branch (the branch into which you want to merge the pull request). This allows code scanning to compute which alerts are newly introduced by the pull request, which alerts were already present in the base branch, and whether any existing alerts are fixed by the changes in the pull request. Initially, if you use a pull request to add code scanning to a repository, the base branch has not yet been analyzed, so it's not possible to compute these details. In this case, when you click through from the results check on the pull request you will see the "Missing analysis for base commit SHA-HASH" message.
|
|
||||||
|
|
||||||
For more information and other causes of this message, see [Reasons for the "missing analysis" message](https://docs.github.com/en/code-security/secure-coding/automatically-scanning-your-code-for-vulnerabilities-and-errors/setting-up-code-scanning-for-a-repository#reasons-for-the-missing-analysis-message)
|
|
||||||
|
|||||||
51
add-fix-info.py
Normal file
51
add-fix-info.py
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
import json
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def main():
|
||||||
|
if len(sys.argv) != 2:
|
||||||
|
print('Usage: python3 add-fix-info.py <input.sarif>')
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
with open(sys.argv[1]) as input_file:
|
||||||
|
sarif = json.load(input_file)
|
||||||
|
|
||||||
|
for run in sarif['runs']:
|
||||||
|
for result in run['results']:
|
||||||
|
if result['ruleId'] == 'js/regex/duplicate-in-character-class':
|
||||||
|
if 'fixes' in result:
|
||||||
|
print('Found result for js/regex/duplicate-in-character-class but result already has fixes')
|
||||||
|
continue
|
||||||
|
|
||||||
|
print('Adding fix for js/regex/duplicate-in-character-class')
|
||||||
|
|
||||||
|
repeatedCharacter = re.search("^Character '(.)'", result['message']['text']).group(1)
|
||||||
|
resultPhysicalLocation = result['locations'][0]['physicalLocation']
|
||||||
|
result['fixes'] = [
|
||||||
|
{
|
||||||
|
"description": {
|
||||||
|
"text": "Remove repeated '" + repeatedCharacter + "' from character class"
|
||||||
|
},
|
||||||
|
"artifactChanges": [
|
||||||
|
{
|
||||||
|
"artifactLocation": {
|
||||||
|
"uri": resultPhysicalLocation['artifactLocation']['uri']
|
||||||
|
},
|
||||||
|
"replacements": [
|
||||||
|
{
|
||||||
|
"deletedRegion": resultPhysicalLocation['region'],
|
||||||
|
"insertedContent": {
|
||||||
|
"text": ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
with open(sys.argv[1], 'w') as input_file:
|
||||||
|
json.dump(sarif, input_file, indent = 2)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
@@ -13,10 +13,6 @@ inputs:
|
|||||||
description: Upload the SARIF file
|
description: Upload the SARIF file
|
||||||
required: false
|
required: false
|
||||||
default: "true"
|
default: "true"
|
||||||
cleanup-level:
|
|
||||||
description: "Level of cleanup to perform on CodeQL databases at the end of the analyze step. This should either be 'none' to skip cleanup, or be a valid argument for the --mode flag of the CodeQL CLI command 'codeql database cleanup' as documented at https://codeql.github.com/docs/codeql-cli/manual/database-cleanup"
|
|
||||||
required: false
|
|
||||||
default: "brutal"
|
|
||||||
ram:
|
ram:
|
||||||
description: Override the amount of memory in MB to be used by CodeQL. By default, almost all the memory of the machine is used.
|
description: Override the amount of memory in MB to be used by CodeQL. By default, almost all the memory of the machine is used.
|
||||||
required: false
|
required: false
|
||||||
@@ -24,10 +20,6 @@ inputs:
|
|||||||
description: Specify whether or not to add code snippets to the output sarif file.
|
description: Specify whether or not to add code snippets to the output sarif file.
|
||||||
required: false
|
required: false
|
||||||
default: "false"
|
default: "false"
|
||||||
skip-queries:
|
|
||||||
description: If this option is set, the CodeQL database will be built but no queries will be run on it. Thus, no results will be produced.
|
|
||||||
required: false
|
|
||||||
default: "false"
|
|
||||||
threads:
|
threads:
|
||||||
description: The number of threads to be used by CodeQL.
|
description: The number of threads to be used by CodeQL.
|
||||||
required: false
|
required: false
|
||||||
@@ -38,17 +30,10 @@ inputs:
|
|||||||
category:
|
category:
|
||||||
description: String used by Code Scanning for matching the analyses
|
description: String used by Code Scanning for matching the analyses
|
||||||
required: false
|
required: false
|
||||||
upload-database:
|
|
||||||
description: Whether to upload the resulting CodeQL database
|
|
||||||
required: false
|
|
||||||
default: "true"
|
|
||||||
token:
|
token:
|
||||||
default: ${{ github.token }}
|
default: ${{ github.token }}
|
||||||
matrix:
|
matrix:
|
||||||
default: ${{ toJson(matrix) }}
|
default: ${{ toJson(matrix) }}
|
||||||
outputs:
|
|
||||||
db-locations:
|
|
||||||
description: A map from language to absolute path for each database created by CodeQL.
|
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: 'node12'
|
||||||
main: '../lib/analyze-action.js'
|
main: '../lib/analyze-action.js'
|
||||||
|
|||||||
@@ -22,15 +22,6 @@ 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
|
||||||
packs:
|
|
||||||
description: >-
|
|
||||||
[Experimental] Comma-separated list of packs to run. Reference a pack in the format `scope/name[@version]`. If `version` is not
|
|
||||||
specified, then the latest version of the pack is used. By default, this overrides the same setting in a
|
|
||||||
configuration file; prefix with "+" to use both sets of packs.
|
|
||||||
|
|
||||||
This input is only available in single-language analyses. To use packs in multi-language
|
|
||||||
analyses, you must specify packs in the codeql-config.yml file.
|
|
||||||
required: false
|
|
||||||
external-repository-token:
|
external-repository-token:
|
||||||
description: A token for fetching external config files and queries if they reside in a private repository.
|
description: A token for fetching external config files and queries if they reside in a private repository.
|
||||||
required: false
|
required: false
|
||||||
@@ -38,9 +29,6 @@ inputs:
|
|||||||
description: Try to auto-install your python dependencies
|
description: Try to auto-install your python dependencies
|
||||||
required: true
|
required: true
|
||||||
default: 'true'
|
default: 'true'
|
||||||
source-root:
|
|
||||||
description: Path of the root source code directory, relative to $GITHUB_WORKSPACE.
|
|
||||||
required: false
|
|
||||||
outputs:
|
outputs:
|
||||||
codeql-path:
|
codeql-path:
|
||||||
description: The path of the CodeQL binary used for analysis
|
description: The path of the CodeQL binary used for analysis
|
||||||
|
|||||||
133
lib/actions-util.js
generated
133
lib/actions-util.js
generated
@@ -1,25 +1,12 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
__setModuleDefault(result, mod);
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.isAnalyzingDefaultBranch = exports.getRelativeScriptPath = exports.isRunningLocalAction = exports.sendStatusReport = exports.createStatusReportBase = exports.getRef = exports.computeAutomationID = exports.getAutomationID = exports.getAnalysisKey = exports.getWorkflowRunID = exports.getWorkflow = exports.formatWorkflowCause = exports.formatWorkflowErrors = exports.validateWorkflow = exports.getWorkflowErrors = exports.WorkflowErrors = exports.patternIsSuperset = exports.getCommitOid = exports.getToolCacheDirectory = exports.getTemporaryDirectory = exports.getOptionalInput = exports.getRequiredInput = void 0;
|
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const core = __importStar(require("@actions/core"));
|
const core = __importStar(require("@actions/core"));
|
||||||
@@ -29,10 +16,6 @@ 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");
|
||||||
/**
|
|
||||||
* The utils in this module are meant to be run inside of the action only.
|
|
||||||
* Code paths from the runner should not enter this module.
|
|
||||||
*/
|
|
||||||
/**
|
/**
|
||||||
* Wrapper around core.getInput for inputs that always have a value.
|
* Wrapper around core.getInput for inputs that always have a value.
|
||||||
* Also see getOptionalInput.
|
* Also see getOptionalInput.
|
||||||
@@ -56,24 +39,52 @@ function getOptionalInput(name) {
|
|||||||
return value.length > 0 ? value : undefined;
|
return value.length > 0 ? value : undefined;
|
||||||
}
|
}
|
||||||
exports.getOptionalInput = getOptionalInput;
|
exports.getOptionalInput = getOptionalInput;
|
||||||
|
/**
|
||||||
|
* Get an environment parameter, but throw an error if it is not set.
|
||||||
|
*/
|
||||||
|
function getRequiredEnvParam(paramName) {
|
||||||
|
const value = process.env[paramName];
|
||||||
|
if (value === undefined || value.length === 0) {
|
||||||
|
throw new Error(`${paramName} environment variable must be set`);
|
||||||
|
}
|
||||||
|
core.debug(`${paramName}=${value}`);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
exports.getRequiredEnvParam = getRequiredEnvParam;
|
||||||
function getTemporaryDirectory() {
|
function getTemporaryDirectory() {
|
||||||
const value = process.env["CODEQL_ACTION_TEMP"];
|
const value = process.env["CODEQL_ACTION_TEMP"];
|
||||||
return value !== undefined && value !== ""
|
return value !== undefined && value !== ""
|
||||||
? value
|
? value
|
||||||
: util_1.getRequiredEnvParam("RUNNER_TEMP");
|
: getRequiredEnvParam("RUNNER_TEMP");
|
||||||
}
|
}
|
||||||
exports.getTemporaryDirectory = getTemporaryDirectory;
|
exports.getTemporaryDirectory = getTemporaryDirectory;
|
||||||
function getToolCacheDirectory() {
|
function getToolCacheDirectory() {
|
||||||
const value = process.env["CODEQL_ACTION_TOOL_CACHE"];
|
const value = process.env["CODEQL_ACTION_TOOL_CACHE"];
|
||||||
return value !== undefined && value !== ""
|
return value !== undefined && value !== ""
|
||||||
? value
|
? value
|
||||||
: util_1.getRequiredEnvParam("RUNNER_TOOL_CACHE");
|
: getRequiredEnvParam("RUNNER_TOOL_CACHE");
|
||||||
}
|
}
|
||||||
exports.getToolCacheDirectory = getToolCacheDirectory;
|
exports.getToolCacheDirectory = getToolCacheDirectory;
|
||||||
|
/**
|
||||||
|
* Ensures all required environment variables are set in the context of a local run.
|
||||||
|
*/
|
||||||
|
function prepareLocalRunEnvironment() {
|
||||||
|
if (!util_1.isLocalRun()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
core.debug("Action is running locally.");
|
||||||
|
if (!process.env.GITHUB_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;
|
||||||
/**
|
/**
|
||||||
* Gets the SHA of the commit that is currently checked out.
|
* Gets the SHA of the commit that is currently checked out.
|
||||||
*/
|
*/
|
||||||
const getCommitOid = async function (ref = "HEAD") {
|
exports.getCommitOid = async function (ref = "HEAD") {
|
||||||
// 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
|
||||||
@@ -98,10 +109,9 @@ const getCommitOid = async function (ref = "HEAD") {
|
|||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
core.info(`Failed to call git to get current commit. Continuing with data from environment: ${e}`);
|
core.info(`Failed to call git to get current commit. Continuing with data from environment: ${e}`);
|
||||||
return util_1.getRequiredEnvParam("GITHUB_SHA");
|
return getRequiredEnvParam("GITHUB_SHA");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
exports.getCommitOid = getCommitOid;
|
|
||||||
function isObject(o) {
|
function isObject(o) {
|
||||||
return o !== null && typeof o === "object";
|
return o !== null && typeof o === "object";
|
||||||
}
|
}
|
||||||
@@ -161,12 +171,12 @@ exports.WorkflowErrors = toCodedErrors({
|
|||||||
CheckoutWrongHead: `git checkout HEAD^2 is no longer necessary. Please remove this step as Code Scanning recommends analyzing the merge commit for best results.`,
|
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) {
|
function getWorkflowErrors(doc) {
|
||||||
var _a, _b, _c, _d, _e;
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
||||||
const errors = [];
|
const errors = [];
|
||||||
const jobName = process.env.GITHUB_JOB;
|
const jobName = process.env.GITHUB_JOB;
|
||||||
if (jobName) {
|
if (jobName) {
|
||||||
const job = (_a = doc === null || doc === void 0 ? void 0 : doc.jobs) === null || _a === void 0 ? void 0 : _a[jobName];
|
const job = (_b = (_a = doc) === null || _a === void 0 ? void 0 : _a.jobs) === null || _b === void 0 ? void 0 : _b[jobName];
|
||||||
const steps = job === null || job === void 0 ? void 0 : job.steps;
|
const steps = (_c = job) === null || _c === void 0 ? void 0 : _c.steps;
|
||||||
if (Array.isArray(steps)) {
|
if (Array.isArray(steps)) {
|
||||||
for (const step of steps) {
|
for (const step of steps) {
|
||||||
// this was advice that we used to give in the README
|
// this was advice that we used to give in the README
|
||||||
@@ -174,7 +184,7 @@ function getWorkflowErrors(doc) {
|
|||||||
// to produce results that are more inline with expectations
|
// to produce results that are more inline with expectations
|
||||||
// (i.e: this is what will happen if you merge this PR)
|
// (i.e: this is what will happen if you merge this PR)
|
||||||
// and avoid some race conditions
|
// and avoid some race conditions
|
||||||
if ((step === null || step === void 0 ? void 0 : step.run) === "git checkout HEAD^2") {
|
if (((_d = step) === null || _d === void 0 ? void 0 : _d.run) === "git checkout HEAD^2") {
|
||||||
errors.push(exports.WorkflowErrors.CheckoutWrongHead);
|
errors.push(exports.WorkflowErrors.CheckoutWrongHead);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -204,14 +214,14 @@ function getWorkflowErrors(doc) {
|
|||||||
missingPush = true;
|
missingPush = true;
|
||||||
}
|
}
|
||||||
if (hasPush && hasPullRequest) {
|
if (hasPush && hasPullRequest) {
|
||||||
const paths = (_b = doc.on.push) === null || _b === void 0 ? void 0 : _b.paths;
|
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 you specify paths or paths-ignore you can end up with commits that have no baseline
|
||||||
// if they didn't change any files
|
// if they didn't change any files
|
||||||
// currently we cannot go back through the history and find the most recent baseline
|
// currently we cannot go back through the history and find the most recent baseline
|
||||||
if (Array.isArray(paths) && paths.length > 0) {
|
if (Array.isArray(paths) && paths.length > 0) {
|
||||||
errors.push(exports.WorkflowErrors.PathsSpecified);
|
errors.push(exports.WorkflowErrors.PathsSpecified);
|
||||||
}
|
}
|
||||||
const pathsIgnore = (_c = doc.on.push) === null || _c === void 0 ? void 0 : _c["paths-ignore"];
|
const pathsIgnore = (_f = doc.on.push) === null || _f === void 0 ? void 0 : _f["paths-ignore"];
|
||||||
if (Array.isArray(pathsIgnore) && pathsIgnore.length > 0) {
|
if (Array.isArray(pathsIgnore) && pathsIgnore.length > 0) {
|
||||||
errors.push(exports.WorkflowErrors.PathsIgnoreSpecified);
|
errors.push(exports.WorkflowErrors.PathsIgnoreSpecified);
|
||||||
}
|
}
|
||||||
@@ -220,9 +230,9 @@ function getWorkflowErrors(doc) {
|
|||||||
// if doc.on.pull_request is undefined that means 'off'
|
// if doc.on.pull_request is undefined that means 'off'
|
||||||
// we only want to check for mismatched branches if pull_request is on.
|
// we only want to check for mismatched branches if pull_request is on.
|
||||||
if (doc.on.pull_request !== undefined) {
|
if (doc.on.pull_request !== undefined) {
|
||||||
const push = branchesToArray((_d = doc.on.push) === null || _d === void 0 ? void 0 : _d.branches);
|
const push = branchesToArray((_g = doc.on.push) === null || _g === void 0 ? void 0 : _g.branches);
|
||||||
if (push !== "**") {
|
if (push !== "**") {
|
||||||
const pull_request = branchesToArray((_e = doc.on.pull_request) === null || _e === void 0 ? void 0 : _e.branches);
|
const pull_request = branchesToArray((_h = doc.on.pull_request) === null || _h === void 0 ? void 0 : _h.branches);
|
||||||
if (pull_request !== "**") {
|
if (pull_request !== "**") {
|
||||||
const difference = pull_request.filter((value) => !push.some((o) => patternIsSuperset(o, value)));
|
const difference = pull_request.filter((value) => !push.some((o) => patternIsSuperset(o, value)));
|
||||||
if (difference.length > 0) {
|
if (difference.length > 0) {
|
||||||
@@ -288,18 +298,21 @@ function formatWorkflowCause(errors) {
|
|||||||
exports.formatWorkflowCause = formatWorkflowCause;
|
exports.formatWorkflowCause = formatWorkflowCause;
|
||||||
async function getWorkflow() {
|
async function getWorkflow() {
|
||||||
const relativePath = await getWorkflowPath();
|
const relativePath = await getWorkflowPath();
|
||||||
const absolutePath = path.join(util_1.getRequiredEnvParam("GITHUB_WORKSPACE"), relativePath);
|
const absolutePath = path.join(getRequiredEnvParam("GITHUB_WORKSPACE"), relativePath);
|
||||||
return yaml.load(fs.readFileSync(absolutePath, "utf-8"));
|
return yaml.safeLoad(fs.readFileSync(absolutePath, "utf-8"));
|
||||||
}
|
}
|
||||||
exports.getWorkflow = getWorkflow;
|
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() {
|
||||||
const repo_nwo = util_1.getRequiredEnvParam("GITHUB_REPOSITORY").split("/");
|
if (util_1.isLocalRun()) {
|
||||||
|
return getRequiredEnvParam("WORKFLOW_PATH");
|
||||||
|
}
|
||||||
|
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];
|
||||||
const run_id = Number(util_1.getRequiredEnvParam("GITHUB_RUN_ID"));
|
const run_id = Number(getRequiredEnvParam("GITHUB_RUN_ID"));
|
||||||
const apiClient = api.getActionsApiClient();
|
const apiClient = api.getActionsApiClient();
|
||||||
const runsResponse = await apiClient.request("GET /repos/:owner/:repo/actions/runs/:run_id", {
|
const runsResponse = await apiClient.request("GET /repos/:owner/:repo/actions/runs/:run_id", {
|
||||||
owner,
|
owner,
|
||||||
@@ -314,7 +327,7 @@ async function getWorkflowPath() {
|
|||||||
* Get the workflow run ID.
|
* Get the workflow run ID.
|
||||||
*/
|
*/
|
||||||
function getWorkflowRunID() {
|
function getWorkflowRunID() {
|
||||||
const workflowRunID = parseInt(util_1.getRequiredEnvParam("GITHUB_RUN_ID"), 10);
|
const workflowRunID = parseInt(getRequiredEnvParam("GITHUB_RUN_ID"), 10);
|
||||||
if (Number.isNaN(workflowRunID)) {
|
if (Number.isNaN(workflowRunID)) {
|
||||||
throw new Error("GITHUB_RUN_ID must define a non NaN workflow run ID");
|
throw new Error("GITHUB_RUN_ID must define a non NaN workflow run ID");
|
||||||
}
|
}
|
||||||
@@ -335,7 +348,7 @@ async function getAnalysisKey() {
|
|||||||
return analysisKey;
|
return analysisKey;
|
||||||
}
|
}
|
||||||
const workflowPath = await getWorkflowPath();
|
const workflowPath = await getWorkflowPath();
|
||||||
const jobName = util_1.getRequiredEnvParam("GITHUB_JOB");
|
const jobName = getRequiredEnvParam("GITHUB_JOB");
|
||||||
analysisKey = `${workflowPath}:${jobName}`;
|
analysisKey = `${workflowPath}:${jobName}`;
|
||||||
core.exportVariable(analysisKeyEnvVar, analysisKey);
|
core.exportVariable(analysisKeyEnvVar, analysisKey);
|
||||||
return analysisKey;
|
return analysisKey;
|
||||||
@@ -372,8 +385,8 @@ exports.computeAutomationID = computeAutomationID;
|
|||||||
async function getRef() {
|
async 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 = util_1.getRequiredEnvParam("GITHUB_REF");
|
const ref = getRequiredEnvParam("GITHUB_REF");
|
||||||
const sha = util_1.getRequiredEnvParam("GITHUB_SHA");
|
const sha = getRequiredEnvParam("GITHUB_SHA");
|
||||||
// For pull request refs we want to detect whether the workflow
|
// For pull request refs we want to detect whether the workflow
|
||||||
// has run `git checkout HEAD^2` to analyze the 'head' ref rather
|
// has run `git checkout HEAD^2` to analyze the 'head' ref rather
|
||||||
// than the 'merge' ref. If so, we want to convert the ref that
|
// than the 'merge' ref. If so, we want to convert the ref that
|
||||||
@@ -462,6 +475,10 @@ 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_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 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 OUT_OF_DATE_MSG = "CodeQL Action is out-of-date. Please upgrade to the latest version of codeql-action.";
|
||||||
@@ -476,9 +493,13 @@ 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) {
|
||||||
|
if (util_1.isLocalRun()) {
|
||||||
|
core.debug("Not sending status report because this is a local run");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
const statusReportJSON = JSON.stringify(statusReport);
|
const statusReportJSON = JSON.stringify(statusReport);
|
||||||
core.debug(`Sending status report: ${statusReportJSON}`);
|
core.debug(`Sending status report: ${statusReportJSON}`);
|
||||||
const nwo = util_1.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 {
|
try {
|
||||||
@@ -491,7 +512,7 @@ async function sendStatusReport(statusReport) {
|
|||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
if (util_1.isHTTPError(e)) {
|
if (isHTTPError(e)) {
|
||||||
switch (e.status) {
|
switch (e.status) {
|
||||||
case 403:
|
case 403:
|
||||||
if (workflowIsTriggeredByPushEvent() && isDependabotActor()) {
|
if (workflowIsTriggeredByPushEvent() && isDependabotActor()) {
|
||||||
@@ -511,7 +532,7 @@ async function sendStatusReport(statusReport) {
|
|||||||
// schema incompatibility when reporting status
|
// schema incompatibility when reporting status
|
||||||
// this means that this action version is no longer compatible with the API
|
// 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
|
// we still want to continue as it is likely the analysis endpoint will work
|
||||||
if (util_1.getRequiredEnvParam("GITHUB_SERVER_URL") !== util_1.GITHUB_DOTCOM_URL) {
|
if (getRequiredEnvParam("GITHUB_SERVER_URL") !== util_1.GITHUB_DOTCOM_URL) {
|
||||||
core.debug(INCOMPATIBLE_MSG);
|
core.debug(INCOMPATIBLE_MSG);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -545,33 +566,9 @@ exports.isRunningLocalAction = isRunningLocalAction;
|
|||||||
// Get the location where the action is running from.
|
// 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.
|
// This can be used to get the actions name or tell if we're running a local action.
|
||||||
function getRelativeScriptPath() {
|
function getRelativeScriptPath() {
|
||||||
const runnerTemp = util_1.getRequiredEnvParam("RUNNER_TEMP");
|
const runnerTemp = getRequiredEnvParam("RUNNER_TEMP");
|
||||||
const actionsDirectory = path.join(path.dirname(runnerTemp), "_actions");
|
const actionsDirectory = path.join(path.dirname(runnerTemp), "_actions");
|
||||||
return path.relative(actionsDirectory, __filename);
|
return path.relative(actionsDirectory, __filename);
|
||||||
}
|
}
|
||||||
exports.getRelativeScriptPath = getRelativeScriptPath;
|
exports.getRelativeScriptPath = getRelativeScriptPath;
|
||||||
// Reads the contents of GITHUB_EVENT_PATH as a JSON object
|
|
||||||
function getWorkflowEvent() {
|
|
||||||
const eventJsonFile = util_1.getRequiredEnvParam("GITHUB_EVENT_PATH");
|
|
||||||
try {
|
|
||||||
return JSON.parse(fs.readFileSync(eventJsonFile, "utf-8"));
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
throw new Error(`Unable to read workflow event JSON from ${eventJsonFile}: ${e}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Is the version of the repository we are currently analyzing from the default branch,
|
|
||||||
// or alternatively from another branch or a pull request.
|
|
||||||
async function isAnalyzingDefaultBranch() {
|
|
||||||
var _a;
|
|
||||||
// Get the current ref and trim and refs/heads/ prefix
|
|
||||||
let currentRef = await getRef();
|
|
||||||
currentRef = currentRef.startsWith("refs/heads/")
|
|
||||||
? currentRef.substr("refs/heads/".length)
|
|
||||||
: currentRef;
|
|
||||||
const event = getWorkflowEvent();
|
|
||||||
const defaultBranch = (_a = event === null || event === void 0 ? void 0 : event.repository) === null || _a === void 0 ? void 0 : _a.default_branch;
|
|
||||||
return currentRef === defaultBranch;
|
|
||||||
}
|
|
||||||
exports.isAnalyzingDefaultBranch = isAnalyzingDefaultBranch;
|
|
||||||
//# sourceMappingURL=actions-util.js.map
|
//# sourceMappingURL=actions-util.js.map
|
||||||
File diff suppressed because one or more lines are too long
112
lib/actions-util.test.js
generated
112
lib/actions-util.test.js
generated
@@ -1,35 +1,20 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
||||||
__setModuleDefault(result, mod);
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
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 fs = __importStar(require("fs"));
|
|
||||||
const path = __importStar(require("path"));
|
|
||||||
const ava_1 = __importDefault(require("ava"));
|
const ava_1 = __importDefault(require("ava"));
|
||||||
const yaml = __importStar(require("js-yaml"));
|
const yaml = __importStar(require("js-yaml"));
|
||||||
const sinon_1 = __importDefault(require("sinon"));
|
const sinon_1 = __importDefault(require("sinon"));
|
||||||
const actionsutil = __importStar(require("./actions-util"));
|
const actionsutil = __importStar(require("./actions-util"));
|
||||||
const testing_utils_1 = require("./testing-utils");
|
const testing_utils_1 = require("./testing-utils");
|
||||||
const util_1 = require("./util");
|
|
||||||
function errorCodes(actual, expected) {
|
function errorCodes(actual, expected) {
|
||||||
return [actual.map(({ code }) => code), expected.map(({ code }) => code)];
|
return [actual.map(({ code }) => code), expected.map(({ code }) => code)];
|
||||||
}
|
}
|
||||||
@@ -71,6 +56,14 @@ ava_1.default("getRef() returns head PR ref if GITHUB_REF no longer checked out"
|
|||||||
t.deepEqual(actualRef, "refs/pull/1/head");
|
t.deepEqual(actualRef, "refs/pull/1/head");
|
||||||
callback.restore();
|
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) => {
|
ava_1.default("computeAutomationID()", async (t) => {
|
||||||
let actualAutomationID = actionsutil.computeAutomationID(".github/workflows/codeql-analysis.yml:analyze", '{"language": "javascript", "os": "linux"}');
|
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/");
|
t.deepEqual(actualAutomationID, ".github/workflows/codeql-analysis.yml:analyze/language:javascript/os:linux/");
|
||||||
@@ -87,6 +80,31 @@ ava_1.default("computeAutomationID()", async (t) => {
|
|||||||
actualAutomationID = actionsutil.computeAutomationID(".github/workflows/codeql-analysis.yml:analyze", undefined);
|
actualAutomationID = actionsutil.computeAutomationID(".github/workflows/codeql-analysis.yml:analyze", undefined);
|
||||||
t.deepEqual(actualAutomationID, ".github/workflows/codeql-analysis.yml:analyze/");
|
t.deepEqual(actualAutomationID, ".github/workflows/codeql-analysis.yml:analyze/");
|
||||||
});
|
});
|
||||||
|
ava_1.default("prepareEnvironment() when a local run", (t) => {
|
||||||
|
process.env.CODEQL_LOCAL_RUN = "false";
|
||||||
|
process.env.GITHUB_JOB = "YYY";
|
||||||
|
process.env.CODEQL_ACTION_ANALYSIS_KEY = "TEST";
|
||||||
|
actionsutil.prepareLocalRunEnvironment();
|
||||||
|
// unchanged
|
||||||
|
t.deepEqual(process.env.GITHUB_JOB, "YYY");
|
||||||
|
t.deepEqual(process.env.CODEQL_ACTION_ANALYSIS_KEY, "TEST");
|
||||||
|
process.env.CODEQL_LOCAL_RUN = "true";
|
||||||
|
actionsutil.prepareLocalRunEnvironment();
|
||||||
|
// unchanged
|
||||||
|
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.CODEQL_ACTION_ANALYSIS_KEY = "";
|
||||||
|
actionsutil.prepareLocalRunEnvironment();
|
||||||
|
// updated
|
||||||
|
t.deepEqual(process.env.GITHUB_JOB, "UNKNOWN-JOB");
|
||||||
|
t.deepEqual(process.env.CODEQL_ACTION_ANALYSIS_KEY, "LOCAL-RUN:UNKNOWN-JOB");
|
||||||
|
});
|
||||||
ava_1.default("getWorkflowErrors() when on is empty", (t) => {
|
ava_1.default("getWorkflowErrors() when on is empty", (t) => {
|
||||||
const errors = actionsutil.getWorkflowErrors({ on: {} });
|
const errors = actionsutil.getWorkflowErrors({ on: {} });
|
||||||
t.deepEqual(...errorCodes(errors, []));
|
t.deepEqual(...errorCodes(errors, []));
|
||||||
@@ -139,7 +157,7 @@ ava_1.default("getWorkflowErrors() when on.pull_requests is a string and correct
|
|||||||
t.deepEqual(...errorCodes(errors, []));
|
t.deepEqual(...errorCodes(errors, []));
|
||||||
});
|
});
|
||||||
ava_1.default("getWorkflowErrors() when on.push is correct with empty objects", (t) => {
|
ava_1.default("getWorkflowErrors() when on.push is correct with empty objects", (t) => {
|
||||||
const errors = actionsutil.getWorkflowErrors(yaml.load(`
|
const errors = actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
pull_request:
|
pull_request:
|
||||||
@@ -228,7 +246,7 @@ ava_1.default("getWorkflowErrors() for a range of malformed workflows", (t) => {
|
|||||||
}), []));
|
}), []));
|
||||||
});
|
});
|
||||||
ava_1.default("getWorkflowErrors() when on.pull_request for every branch but push specifies branches", (t) => {
|
ava_1.default("getWorkflowErrors() when on.pull_request for every branch but push specifies branches", (t) => {
|
||||||
const errors = actionsutil.getWorkflowErrors(yaml.load(`
|
const errors = actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
||||||
name: "CodeQL"
|
name: "CodeQL"
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -311,7 +329,7 @@ ava_1.default("patternIsSuperset()", (t) => {
|
|||||||
t.false(actionsutil.patternIsSuperset("/robin/moose/release/goose", "/robin/*/release/*"));
|
t.false(actionsutil.patternIsSuperset("/robin/moose/release/goose", "/robin/*/release/*"));
|
||||||
});
|
});
|
||||||
ava_1.default("getWorkflowErrors() when branches contain dots", (t) => {
|
ava_1.default("getWorkflowErrors() when branches contain dots", (t) => {
|
||||||
const errors = actionsutil.getWorkflowErrors(yaml.load(`
|
const errors = actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [4.1, master]
|
branches: [4.1, master]
|
||||||
@@ -322,7 +340,7 @@ ava_1.default("getWorkflowErrors() when branches contain dots", (t) => {
|
|||||||
t.deepEqual(...errorCodes(errors, []));
|
t.deepEqual(...errorCodes(errors, []));
|
||||||
});
|
});
|
||||||
ava_1.default("getWorkflowErrors() when on.push has a trailing comma", (t) => {
|
ava_1.default("getWorkflowErrors() when on.push has a trailing comma", (t) => {
|
||||||
const errors = actionsutil.getWorkflowErrors(yaml.load(`
|
const errors = actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
||||||
name: "CodeQL"
|
name: "CodeQL"
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -335,7 +353,7 @@ on:
|
|||||||
});
|
});
|
||||||
ava_1.default("getWorkflowErrors() should only report the current job's CheckoutWrongHead", (t) => {
|
ava_1.default("getWorkflowErrors() should only report the current job's CheckoutWrongHead", (t) => {
|
||||||
process.env.GITHUB_JOB = "test";
|
process.env.GITHUB_JOB = "test";
|
||||||
const errors = actionsutil.getWorkflowErrors(yaml.load(`
|
const errors = actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
||||||
name: "CodeQL"
|
name: "CodeQL"
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -359,7 +377,7 @@ jobs:
|
|||||||
});
|
});
|
||||||
ava_1.default("getWorkflowErrors() should not report a different job's CheckoutWrongHead", (t) => {
|
ava_1.default("getWorkflowErrors() should not report a different job's CheckoutWrongHead", (t) => {
|
||||||
process.env.GITHUB_JOB = "test3";
|
process.env.GITHUB_JOB = "test3";
|
||||||
const errors = actionsutil.getWorkflowErrors(yaml.load(`
|
const errors = actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
||||||
name: "CodeQL"
|
name: "CodeQL"
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -382,62 +400,36 @@ jobs:
|
|||||||
t.deepEqual(...errorCodes(errors, []));
|
t.deepEqual(...errorCodes(errors, []));
|
||||||
});
|
});
|
||||||
ava_1.default("getWorkflowErrors() when on is missing", (t) => {
|
ava_1.default("getWorkflowErrors() when on is missing", (t) => {
|
||||||
const errors = actionsutil.getWorkflowErrors(yaml.load(`
|
const errors = actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
||||||
name: "CodeQL"
|
name: "CodeQL"
|
||||||
`));
|
`));
|
||||||
t.deepEqual(...errorCodes(errors, []));
|
t.deepEqual(...errorCodes(errors, []));
|
||||||
});
|
});
|
||||||
ava_1.default("getWorkflowErrors() with a different on setup", (t) => {
|
ava_1.default("getWorkflowErrors() with a different on setup", (t) => {
|
||||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.load(`
|
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
||||||
name: "CodeQL"
|
name: "CodeQL"
|
||||||
on: "workflow_dispatch"
|
on: "workflow_dispatch"
|
||||||
`)), []));
|
`)), []));
|
||||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.load(`
|
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
||||||
name: "CodeQL"
|
name: "CodeQL"
|
||||||
on: [workflow_dispatch]
|
on: [workflow_dispatch]
|
||||||
`)), []));
|
`)), []));
|
||||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.load(`
|
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
||||||
name: "CodeQL"
|
name: "CodeQL"
|
||||||
on:
|
on:
|
||||||
workflow_dispatch: {}
|
workflow_dispatch: {}
|
||||||
`)), []));
|
`)), []));
|
||||||
});
|
});
|
||||||
ava_1.default("getWorkflowErrors() should not report an error if PRs are totally unconfigured", (t) => {
|
ava_1.default("getWorkflowErrors() should not report an error if PRs are totally unconfigured", (t) => {
|
||||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.load(`
|
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
||||||
name: "CodeQL"
|
name: "CodeQL"
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [master]
|
branches: [master]
|
||||||
`)), []));
|
`)), []));
|
||||||
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.load(`
|
t.deepEqual(...errorCodes(actionsutil.getWorkflowErrors(yaml.safeLoad(`
|
||||||
name: "CodeQL"
|
name: "CodeQL"
|
||||||
on: ["push"]
|
on: ["push"]
|
||||||
`)), []));
|
`)), []));
|
||||||
});
|
});
|
||||||
ava_1.default("initializeEnvironment", (t) => {
|
|
||||||
util_1.initializeEnvironment(util_1.Mode.actions, "1.2.3");
|
|
||||||
t.deepEqual(util_1.getMode(), util_1.Mode.actions);
|
|
||||||
t.deepEqual(process.env.CODEQL_ACTION_VERSION, "1.2.3");
|
|
||||||
util_1.initializeEnvironment(util_1.Mode.runner, "4.5.6");
|
|
||||||
t.deepEqual(util_1.getMode(), util_1.Mode.runner);
|
|
||||||
t.deepEqual(process.env.CODEQL_ACTION_VERSION, "4.5.6");
|
|
||||||
});
|
|
||||||
ava_1.default("isAnalyzingDefaultBranch()", async (t) => {
|
|
||||||
await util_1.withTmpDir(async (tmpDir) => {
|
|
||||||
const envFile = path.join(tmpDir, "event.json");
|
|
||||||
fs.writeFileSync(envFile, JSON.stringify({
|
|
||||||
repository: {
|
|
||||||
default_branch: "main",
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
process.env["GITHUB_EVENT_PATH"] = envFile;
|
|
||||||
process.env["GITHUB_REF"] = "main";
|
|
||||||
process.env["GITHUB_SHA"] = "1234";
|
|
||||||
t.deepEqual(await actionsutil.isAnalyzingDefaultBranch(), true);
|
|
||||||
process.env["GITHUB_REF"] = "refs/heads/main";
|
|
||||||
t.deepEqual(await actionsutil.isAnalyzingDefaultBranch(), true);
|
|
||||||
process.env["GITHUB_REF"] = "feature";
|
|
||||||
t.deepEqual(await actionsutil.isAnalyzingDefaultBranch(), false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
//# sourceMappingURL=actions-util.test.js.map
|
//# sourceMappingURL=actions-util.test.js.map
|
||||||
File diff suppressed because one or more lines are too long
21
lib/analysis-paths.js
generated
21
lib/analysis-paths.js
generated
@@ -1,31 +1,18 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
__setModuleDefault(result, mod);
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.includeAndExcludeAnalysisPaths = exports.printPathFiltersWarning = exports.legalWindowsPathCharactersRegex = void 0;
|
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
function isInterpretedLanguage(language) {
|
function isInterpretedLanguage(language) {
|
||||||
return (language === "javascript" || language === "python" || language === "ruby");
|
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 *
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"analysis-paths.js","sourceRoot":"","sources":["../src/analysis-paths.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAK7B,SAAS,qBAAqB,CAAC,QAAQ;IACrC,OAAO,CACL,QAAQ,KAAK,YAAY,IAAI,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,MAAM,CAC1E,CAAC;AACJ,CAAC;AAED,6FAA6F;AAChF,QAAA,+BAA+B,GAAG,cAAc,CAAC;AAE9D,uFAAuF;AACvF,SAAS,yBAAyB,CAAC,KAAe;IAChD,iCAAiC;IACjC,KAAK,GAAG,KAAK,CAAC,MAAM,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,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,qBAAqB,CAAC,EAC9C;QACA,MA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,OAAO,GAAa,EAAE,CAAC;IAC7B,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC;IACzD,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC;IAC/D,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;QACxB,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KACxD;AACH,CAAC;AArCD,wEAqCC"}
|
||||||
19
lib/analysis-paths.test.js
generated
19
lib/analysis-paths.test.js
generated
@@ -1,21 +1,9 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
__setModuleDefault(result, mod);
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
@@ -41,7 +29,6 @@ ava_1.default("emptyPaths", async (t) => {
|
|||||||
codeQLCmd: "",
|
codeQLCmd: "",
|
||||||
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
||||||
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
||||||
packs: {},
|
|
||||||
};
|
};
|
||||||
analysisPaths.includeAndExcludeAnalysisPaths(config);
|
analysisPaths.includeAndExcludeAnalysisPaths(config);
|
||||||
t.is(process.env["LGTM_INDEX_INCLUDE"], undefined);
|
t.is(process.env["LGTM_INDEX_INCLUDE"], undefined);
|
||||||
@@ -62,7 +49,6 @@ ava_1.default("nonEmptyPaths", async (t) => {
|
|||||||
codeQLCmd: "",
|
codeQLCmd: "",
|
||||||
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
||||||
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
||||||
packs: {},
|
|
||||||
};
|
};
|
||||||
analysisPaths.includeAndExcludeAnalysisPaths(config);
|
analysisPaths.includeAndExcludeAnalysisPaths(config);
|
||||||
t.is(process.env["LGTM_INDEX_INCLUDE"], "path1\npath2");
|
t.is(process.env["LGTM_INDEX_INCLUDE"], "path1\npath2");
|
||||||
@@ -84,7 +70,6 @@ ava_1.default("exclude temp dir", async (t) => {
|
|||||||
codeQLCmd: "",
|
codeQLCmd: "",
|
||||||
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
||||||
dbLocation: path.resolve(tempDir, "codeql_databases"),
|
dbLocation: path.resolve(tempDir, "codeql_databases"),
|
||||||
packs: {},
|
|
||||||
};
|
};
|
||||||
analysisPaths.includeAndExcludeAnalysisPaths(config);
|
analysisPaths.includeAndExcludeAnalysisPaths(config);
|
||||||
t.is(process.env["LGTM_INDEX_INCLUDE"], undefined);
|
t.is(process.env["LGTM_INDEX_INCLUDE"], undefined);
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"analysis-paths.test.js","sourceRoot":"","sources":["../src/analysis-paths.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAE7B,8CAAuB;AAEvB,gEAAkD;AAClD,mDAA6C;AAC7C,6CAA+B;AAE/B,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;YACxE,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,kBAAkB,CAAC;YACpD,KAAK,EAAE,EAAE;SACV,CAAC;QACF,aAAa,CAAC,8BAA8B,CAAC,MAAM,CAAC,CAAC;QACrD,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,SAAS,CAAC,CAAC;QACnD,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,oB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AoB,CAAC,EAAE,oBAAoB,CAAC,CAAC;QAC9D,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,SAAS,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
||||||
71
lib/analyze-action.js
generated
71
lib/analyze-action.js
generated
@@ -1,21 +1,9 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
__setModuleDefault(result, mod);
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
@@ -25,18 +13,15 @@ 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 database_upload_1 = require("./database-upload");
|
|
||||||
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 = __importStar(require("./util"));
|
const util = __importStar(require("./util"));
|
||||||
// eslint-disable-next-line import/no-commonjs
|
|
||||||
const pkg = require("../package.json");
|
|
||||||
async function sendStatusReport(startedAt, stats, error) {
|
async function sendStatusReport(startedAt, stats, error) {
|
||||||
const status = (stats === null || stats === void 0 ? void 0 : stats.analyze_failure_language) !== undefined || error !== undefined
|
var _a, _b, _c;
|
||||||
|
const status = ((_a = stats) === null || _a === void 0 ? void 0 : _a.analyze_failure_language) !== undefined || error !== undefined
|
||||||
? "failure"
|
? "failure"
|
||||||
: "success";
|
: "success";
|
||||||
const statusReportBase = await actionsUtil.createStatusReportBase("finish", status, startedAt, error === null || error === void 0 ? void 0 : error.message, error === null || error === void 0 ? void 0 : error.stack);
|
const statusReportBase = await actionsUtil.createStatusReportBase("finish", status, startedAt, (_b = error) === null || _b === void 0 ? void 0 : _b.message, (_c = error) === null || _c === void 0 ? void 0 : _c.stack);
|
||||||
const statusReport = {
|
const statusReport = {
|
||||||
...statusReportBase,
|
...statusReportBase,
|
||||||
...(stats || {}),
|
...(stats || {}),
|
||||||
@@ -45,11 +30,10 @@ async function sendStatusReport(startedAt, stats, error) {
|
|||||||
}
|
}
|
||||||
async function run() {
|
async function run() {
|
||||||
const startedAt = new Date();
|
const startedAt = new Date();
|
||||||
let uploadStats = undefined;
|
let stats = undefined;
|
||||||
let runStats = undefined;
|
|
||||||
let config = undefined;
|
let config = undefined;
|
||||||
util.initializeEnvironment(util.Mode.actions, pkg.version);
|
|
||||||
try {
|
try {
|
||||||
|
actionsUtil.prepareLocalRunEnvironment();
|
||||||
if (!(await actionsUtil.sendStatusReport(await actionsUtil.createStatusReportBase("finish", "starting", startedAt)))) {
|
if (!(await actionsUtil.sendStatusReport(await actionsUtil.createStatusReportBase("finish", "starting", startedAt)))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -60,41 +44,26 @@ async function run() {
|
|||||||
}
|
}
|
||||||
const apiDetails = {
|
const apiDetails = {
|
||||||
auth: actionsUtil.getRequiredInput("token"),
|
auth: actionsUtil.getRequiredInput("token"),
|
||||||
url: util.getRequiredEnvParam("GITHUB_SERVER_URL"),
|
url: actionsUtil.getRequiredEnvParam("GITHUB_SERVER_URL"),
|
||||||
};
|
};
|
||||||
const outputDir = actionsUtil.getRequiredInput("output");
|
const outputDir = actionsUtil.getRequiredInput("output");
|
||||||
const threads = util.getThreadsFlag(actionsUtil.getOptionalInput("threads"), logger);
|
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);
|
||||||
await analyze_1.runFinalize(outputDir, threads, config, logger);
|
if (actionsUtil.getRequiredInput("upload") === "true") {
|
||||||
if (actionsUtil.getRequiredInput("skip-queries") !== "true") {
|
const uploadStats = await upload_lib.uploadFromActions(outputDir, config.gitHubVersion, apiDetails, logger);
|
||||||
runStats = await analyze_1.runQueries(outputDir, util.getMemoryFlag(actionsUtil.getOptionalInput("ram")), util.getAddSnippetsFlag(actionsUtil.getRequiredInput("add-snippets")), threads, actionsUtil.getOptionalInput("category"), config, logger);
|
stats = { ...queriesStats, ...uploadStats };
|
||||||
}
|
|
||||||
if (actionsUtil.getOptionalInput("cleanup-level") !== "none") {
|
|
||||||
await analyze_1.runCleanup(config, actionsUtil.getOptionalInput("cleanup-level") || "brutal", logger);
|
|
||||||
}
|
|
||||||
const dbLocations = {};
|
|
||||||
for (const language of config.languages) {
|
|
||||||
dbLocations[language] = util.getCodeQLDatabasePath(config, language);
|
|
||||||
}
|
|
||||||
core.setOutput("db-locations", dbLocations);
|
|
||||||
if (runStats && actionsUtil.getRequiredInput("upload") === "true") {
|
|
||||||
uploadStats = await upload_lib.uploadFromActions(outputDir, config.gitHubVersion, apiDetails, logger);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
logger.info("Not uploading results");
|
logger.info("Not uploading results");
|
||||||
|
stats = { ...queriesStats };
|
||||||
}
|
}
|
||||||
const repositoryNwo = repository_1.parseRepositoryNwo(util.getRequiredEnvParam("GITHUB_REPOSITORY"));
|
|
||||||
await database_upload_1.uploadDatabases(repositoryNwo, config, apiDetails, logger);
|
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
console.log(error);
|
console.log(error);
|
||||||
if (error instanceof analyze_1.CodeQLAnalysisError) {
|
if (error instanceof analyze_1.CodeQLAnalysisError) {
|
||||||
const stats = { ...error.queriesStatusReport };
|
stats = { ...error.queriesStatusReport };
|
||||||
await sendStatusReport(startedAt, stats, error);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
await sendStatusReport(startedAt, undefined, error);
|
|
||||||
}
|
}
|
||||||
|
await sendStatusReport(startedAt, stats, error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
@@ -120,15 +89,7 @@ async function run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (runStats && uploadStats) {
|
await sendStatusReport(startedAt, stats);
|
||||||
await sendStatusReport(startedAt, { ...runStats, ...uploadStats });
|
|
||||||
}
|
|
||||||
else if (runStats) {
|
|
||||||
await sendStatusReport(startedAt, { ...runStats });
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
await sendStatusReport(startedAt, undefined);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
async function runWrapper() {
|
async function runWrapper() {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -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,uCAMmB;AACnB,iDAAmD;AACnD,uDAAoD;AACpD,uCAA6C;AAC7C,6CAAkD;AAClD,yDAA2C;AAE3C,6CAA+B;AAE/B,8CAA8C;AAC9C,MAAM,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAUvC,KAAK,UAAU,gBAAgB,CAC7B,SAAe,EACf,KAAuC,EACvC,KAAa;IAEb,MAAM,MAAM,GACV,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,wBAAwB,MAAK,SAAS,IAAI,KAAK,KAAK,SAAS;QAClE,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,SAAS,CAAC;IAChB,MAAM,gBAAgB,GAAG,MAAM,WAAW,CAAC,sBAAsB,CAC/D,QAAQ,EACR,MAAM,EACN,SAAS,EACT,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,EACd,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,CACb,CAAC;IACF,MAAM,YAAY,GAAuB;QACvC,GAAG,gBAAgB;QACnB,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;KACjB,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,IAAI,WAAW,GAAmC,SAAS,CAAC;IAC5D,IAAI,QAAQ,GAAoC,SAAS,CAAC;IAC1D,IAAI,MAAM,GAAuB,SAAS,CAAC;IAC3C,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAA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E,CAClD,CAAC;4BACF,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAC/C,CAAC;4BACF,IAAI,CAAC,QAAQ,EAAE,CAAC;yBACjB;6BAAM,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE;4BAC9B,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;yBAC7C;qBACF;gBACH,CAAC,CAAC;gBACF,YAAY,CAAC,aAAa,CAAC,CAAC;aAC7B;SACF;KACF;IAED,MAAM,gBAAgB,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;AAC3C,CAAC;AAED,KAAK,UAAU,UAAU;IACvB,IAAI;QACF,MAAM,GAAG,EAAE,CAAC;KACb;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,SAAS,CAAC,0BAA0B,KAAK,EAAE,CAAC,CAAC;QAClD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;KACpB;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"}
|
||||||
169
lib/analyze.js
generated
169
lib/analyze.js
generated
@@ -1,34 +1,21 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
__setModuleDefault(result, mod);
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.runCleanup = exports.runFinalize = exports.runQueries = exports.CodeQLAnalysisError = void 0;
|
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
|
const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
|
||||||
const yaml = __importStar(require("js-yaml"));
|
|
||||||
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 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 util = __importStar(require("./util"));
|
const util = __importStar(require("./util"));
|
||||||
class CodeQLAnalysisError extends Error {
|
class CodeQLAnalysisError extends Error {
|
||||||
constructor(queriesStatusReport, message) {
|
constructor(queriesStatusReport, message) {
|
||||||
@@ -69,8 +56,7 @@ async function createdDBForScannedLanguages(config, logger) {
|
|||||||
analysisPaths.includeAndExcludeAnalysisPaths(config);
|
analysisPaths.includeAndExcludeAnalysisPaths(config);
|
||||||
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) {
|
||||||
if (languages_1.isScannedLanguage(language) &&
|
if (languages_1.isScannedLanguage(language)) {
|
||||||
!dbIsFinalized(config, language, logger)) {
|
|
||||||
logger.startGroup(`Extracting ${language}`);
|
logger.startGroup(`Extracting ${language}`);
|
||||||
if (language === languages_1.Language.python) {
|
if (language === languages_1.Language.python) {
|
||||||
await setupPythonExtractor(logger);
|
await setupPythonExtractor(logger);
|
||||||
@@ -80,29 +66,13 @@ async function createdDBForScannedLanguages(config, logger) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function dbIsFinalized(config, language, logger) {
|
|
||||||
const dbPath = util.getCodeQLDatabasePath(config, language);
|
|
||||||
try {
|
|
||||||
const dbInfo = yaml.load(fs.readFileSync(path.resolve(dbPath, "codeql-database.yml"), "utf8"));
|
|
||||||
return !("inProgress" in dbInfo);
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
logger.warning(`Could not check whether database for ${language} was finalized. Assuming it is not.`);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async function finalizeDatabaseCreation(config, threadsFlag, logger) {
|
async function finalizeDatabaseCreation(config, threadsFlag, 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) {
|
||||||
if (dbIsFinalized(config, language, logger)) {
|
logger.startGroup(`Finalizing ${language}`);
|
||||||
logger.info(`There is already a finalized database for ${language} at the location where the CodeQL Action places databases, so we did not create one.`);
|
await codeql.finalizeDatabase(util.getCodeQLDatabasePath(config, language), threadsFlag);
|
||||||
}
|
logger.endGroup();
|
||||||
else {
|
|
||||||
logger.startGroup(`Finalizing ${language}`);
|
|
||||||
await codeql.finalizeDatabase(util.getCodeQLDatabasePath(config, language), threadsFlag);
|
|
||||||
logger.endGroup();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Runs queries and creates sarif files in the given folder
|
// Runs queries and creates sarif files in the given folder
|
||||||
@@ -115,130 +85,88 @@ async function runQueries(sarifFolder, memoryFlag, addSnippetsFlag, threadsFlag,
|
|||||||
// that here.
|
// that here.
|
||||||
config.paths, config.pathsIgnore, config.languages, logger);
|
config.paths, config.pathsIgnore, config.languages, logger);
|
||||||
for (const language of config.languages) {
|
for (const language of config.languages) {
|
||||||
|
logger.startGroup(`Analyzing ${language}`);
|
||||||
const queries = config.queries[language];
|
const queries = config.queries[language];
|
||||||
const packsWithVersion = config.packs[language] || [];
|
if (queries === undefined ||
|
||||||
const hasBuiltinQueries = (queries === null || queries === void 0 ? void 0 : queries.builtin.length) > 0;
|
(queries.builtin.length === 0 && queries.custom.length === 0)) {
|
||||||
const hasCustomQueries = (queries === null || queries === void 0 ? void 0 : queries.custom.length) > 0;
|
|
||||||
const hasPackWithCustomQueries = packsWithVersion.length > 0;
|
|
||||||
if (!hasBuiltinQueries && !hasCustomQueries && !hasPackWithCustomQueries) {
|
|
||||||
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 (hasPackWithCustomQueries) {
|
let analysisSummary = "";
|
||||||
logger.info("*************");
|
|
||||||
logger.info("Performing analysis with custom QL Packs. QL Packs are an experimental feature.");
|
|
||||||
logger.info("And should not be used in production yet.");
|
|
||||||
logger.info("*************");
|
|
||||||
logger.startGroup(`Downloading custom packs for ${language}`);
|
|
||||||
const codeql = codeql_1.getCodeQL(config.codeQLCmd);
|
|
||||||
const results = await codeql.packDownload(packsWithVersion);
|
|
||||||
logger.info(`Downloaded packs: ${results.packs
|
|
||||||
.map((r) => `${r.name}@${r.version || "latest"}`)
|
|
||||||
.join(", ")}`);
|
|
||||||
logger.endGroup();
|
|
||||||
}
|
|
||||||
logger.startGroup(`Running queries for ${language}`);
|
|
||||||
const querySuitePaths = [];
|
|
||||||
if (queries["builtin"].length > 0) {
|
if (queries["builtin"].length > 0) {
|
||||||
const startTimeBuiltIn = new Date().getTime();
|
const startTimeBuliltIn = new Date().getTime();
|
||||||
querySuitePaths.push(await runQueryGroup(language, "builtin", createQuerySuiteContents(queries["builtin"]), undefined));
|
const { sarifFile, stdout } = await runQueryGroup(language, "builtin", queries["builtin"], sarifFolder, undefined);
|
||||||
|
analysisSummary = stdout;
|
||||||
|
await injectLinesOfCode(sarifFile, language, locPromise);
|
||||||
statusReport[`analyze_builtin_queries_${language}_duration_ms`] =
|
statusReport[`analyze_builtin_queries_${language}_duration_ms`] =
|
||||||
new Date().getTime() - startTimeBuiltIn;
|
new Date().getTime() - startTimeBuliltIn;
|
||||||
}
|
}
|
||||||
const startTimeCustom = new Date().getTime();
|
const startTimeCustom = new Date().getTime();
|
||||||
let ranCustom = false;
|
const temporarySarifDir = config.tempDir;
|
||||||
|
const temporarySarifFiles = [];
|
||||||
for (let i = 0; i < queries["custom"].length; ++i) {
|
for (let i = 0; i < queries["custom"].length; ++i) {
|
||||||
if (queries["custom"][i].queries.length > 0) {
|
if (queries["custom"][i].queries.length > 0) {
|
||||||
querySuitePaths.push(await runQueryGroup(language, `custom-${i}`, createQuerySuiteContents(queries["custom"][i].queries), queries["custom"][i].searchPath));
|
const { sarifFile } = await runQueryGroup(language, `custom-${i}`, queries["custom"][i].queries, temporarySarifDir, queries["custom"][i].searchPath);
|
||||||
ranCustom = true;
|
temporarySarifFiles.push(sarifFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (packsWithVersion.length > 0) {
|
if (temporarySarifFiles.length > 0) {
|
||||||
querySuitePaths.push(await runQueryGroup(language, "packs", createPackSuiteContents(packsWithVersion), undefined));
|
const sarifFile = path.join(sarifFolder, `${language}-custom.sarif`);
|
||||||
ranCustom = true;
|
fs.writeFileSync(sarifFile, upload_lib_1.combineSarifFiles(temporarySarifFiles));
|
||||||
}
|
await injectLinesOfCode(sarifFile, language, locPromise);
|
||||||
if (ranCustom) {
|
|
||||||
statusReport[`analyze_custom_queries_${language}_duration_ms`] =
|
statusReport[`analyze_custom_queries_${language}_duration_ms`] =
|
||||||
new Date().getTime() - startTimeCustom;
|
new Date().getTime() - startTimeCustom;
|
||||||
}
|
}
|
||||||
logger.endGroup();
|
logger.endGroup();
|
||||||
logger.startGroup(`Interpreting results for ${language}`);
|
// Print the LoC baseline and the summary results from database analyze.
|
||||||
const startTimeInterpretResults = new Date().getTime();
|
logger.startGroup(`Analysis summary for ${language}`);
|
||||||
const sarifFile = path.join(sarifFolder, `${language}.sarif`);
|
|
||||||
const analysisSummary = await runInterpretResults(language, querySuitePaths, sarifFile);
|
|
||||||
await injectLinesOfCode(sarifFile, language, locPromise);
|
|
||||||
statusReport[`interpret_results_${language}_duration_ms`] =
|
|
||||||
new Date().getTime() - startTimeInterpretResults;
|
|
||||||
logger.endGroup();
|
|
||||||
logger.info(analysisSummary);
|
|
||||||
printLinesOfCodeSummary(logger, language, await locPromise);
|
printLinesOfCodeSummary(logger, language, await locPromise);
|
||||||
|
logger.info(analysisSummary);
|
||||||
|
logger.endGroup();
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
logger.info(e);
|
logger.info(e);
|
||||||
logger.info(e.stack);
|
|
||||||
statusReport.analyze_failure_language = language;
|
statusReport.analyze_failure_language = language;
|
||||||
throw new CodeQLAnalysisError(statusReport, `Error running analysis for ${language}: ${e}`);
|
throw new CodeQLAnalysisError(statusReport, `Error running analysis for ${language}: ${e}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return statusReport;
|
return statusReport;
|
||||||
async function runInterpretResults(language, queries, sarifFile) {
|
async function runQueryGroup(language, type, queries, destinationFolder, searchPath) {
|
||||||
const databasePath = util.getCodeQLDatabasePath(config, language);
|
|
||||||
const codeql = codeql_1.getCodeQL(config.codeQLCmd);
|
|
||||||
return await codeql.databaseInterpretResults(databasePath, queries, sarifFile, addSnippetsFlag, threadsFlag, automationDetailsId);
|
|
||||||
}
|
|
||||||
async function runQueryGroup(language, type, querySuiteContents, searchPath) {
|
|
||||||
const databasePath = util.getCodeQLDatabasePath(config, language);
|
const databasePath = util.getCodeQLDatabasePath(config, language);
|
||||||
// Pass the queries to codeql using a file instead of using the command
|
// Pass the queries to codeql using a file instead of using the command
|
||||||
// line to avoid command line length restrictions, particularly on windows.
|
// line to avoid command line length restrictions, particularly on windows.
|
||||||
const querySuitePath = `${databasePath}-queries-${type}.qls`;
|
const querySuitePath = `${databasePath}-queries-${type}.qls`;
|
||||||
|
const querySuiteContents = queries
|
||||||
|
.map((q) => `- query: ${q}`)
|
||||||
|
.join("\n");
|
||||||
fs.writeFileSync(querySuitePath, querySuiteContents);
|
fs.writeFileSync(querySuitePath, querySuiteContents);
|
||||||
logger.debug(`Query suite file for ${language}-${type}...\n${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);
|
const codeql = codeql_1.getCodeQL(config.codeQLCmd);
|
||||||
await codeql.databaseRunQueries(databasePath, searchPath, querySuitePath, memoryFlag, threadsFlag);
|
const databaseAnalyzeStdout = await codeql.databaseAnalyze(databasePath, sarifFile, searchPath, querySuitePath, memoryFlag, addSnippetsFlag, threadsFlag, automationDetailsId);
|
||||||
logger.debug(`BQRS results produced for ${language} (queries: ${type})"`);
|
logger.debug(`SARIF results for database ${language} created at "${sarifFile}"`);
|
||||||
return querySuitePath;
|
return { sarifFile, stdout: databaseAnalyzeStdout };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.runQueries = runQueries;
|
exports.runQueries = runQueries;
|
||||||
function createQuerySuiteContents(queries) {
|
async function runAnalyze(outputDir, memoryFlag, addSnippetsFlag, threadsFlag, automationDetailsId, config, logger) {
|
||||||
return queries.map((q) => `- query: ${q}`).join("\n");
|
|
||||||
}
|
|
||||||
function createPackSuiteContents(packsWithVersion) {
|
|
||||||
return packsWithVersion.map(packWithVersionToQuerySuiteEntry).join("\n");
|
|
||||||
}
|
|
||||||
function packWithVersionToQuerySuiteEntry(pack) {
|
|
||||||
let text = `- qlpack: ${pack.packName}`;
|
|
||||||
if (pack.version) {
|
|
||||||
text += `\n version: ${pack.version}`;
|
|
||||||
}
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
async function runFinalize(outputDir, 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");
|
||||||
await finalizeDatabaseCreation(config, threadsFlag, logger);
|
await finalizeDatabaseCreation(config, threadsFlag, logger);
|
||||||
|
logger.info("Analyzing database");
|
||||||
|
const queriesStats = await runQueries(outputDir, memoryFlag, addSnippetsFlag, threadsFlag, automationDetailsId, config, logger);
|
||||||
|
return { ...queriesStats };
|
||||||
}
|
}
|
||||||
exports.runFinalize = runFinalize;
|
exports.runAnalyze = runAnalyze;
|
||||||
async function runCleanup(config, cleanupLevel, logger) {
|
|
||||||
logger.startGroup("Cleaning up databases");
|
|
||||||
for (const language of config.languages) {
|
|
||||||
const codeql = codeql_1.getCodeQL(config.codeQLCmd);
|
|
||||||
const databasePath = util.getCodeQLDatabasePath(config, language);
|
|
||||||
await codeql.databaseCleanup(databasePath, cleanupLevel);
|
|
||||||
}
|
|
||||||
logger.endGroup();
|
|
||||||
}
|
|
||||||
exports.runCleanup = runCleanup;
|
|
||||||
async function injectLinesOfCode(sarifFile, language, locPromise) {
|
async function injectLinesOfCode(sarifFile, language, locPromise) {
|
||||||
var _a;
|
|
||||||
const lineCounts = await locPromise;
|
const lineCounts = await locPromise;
|
||||||
const idPrefix = count_loc_1.getIdPrefix(language);
|
const idPrefix = count_loc_1.getIdPrefix(language);
|
||||||
if (language in lineCounts) {
|
if (language in lineCounts) {
|
||||||
const sarif = JSON.parse(fs.readFileSync(sarifFile, "utf8"));
|
const sarif = JSON.parse(fs.readFileSync(sarifFile, "utf8"));
|
||||||
if (Array.isArray(sarif.runs)) {
|
if (Array.isArray(sarif.runs)) {
|
||||||
for (const run of sarif.runs) {
|
for (const run of sarif.runs) {
|
||||||
// Old style: Baseline is inserted when rule ID has suffix /summary/lines-of-code
|
|
||||||
const ruleId = `${idPrefix}/summary/lines-of-code`;
|
const ruleId = `${idPrefix}/summary/lines-of-code`;
|
||||||
run.properties = run.properties || {};
|
run.properties = run.properties || {};
|
||||||
run.properties.metricResults = run.properties.metricResults || [];
|
run.properties.metricResults = run.properties.metricResults || [];
|
||||||
@@ -249,15 +177,6 @@ async function injectLinesOfCode(sarifFile, language, locPromise) {
|
|||||||
if (rule) {
|
if (rule) {
|
||||||
rule.baseline = lineCounts[language];
|
rule.baseline = lineCounts[language];
|
||||||
}
|
}
|
||||||
// New style: Baseline is inserted when matching rule has tag lines-of-code
|
|
||||||
for (const metric of run.properties.metricResults) {
|
|
||||||
if (metric.rule && metric.rule.toolComponent) {
|
|
||||||
const matchingRule = run.tool.extensions[metric.rule.toolComponent.index].rules[metric.rule.index];
|
|
||||||
if ((_a = matchingRule.properties.tags) === null || _a === void 0 ? void 0 : _a.includes("lines-of-code")) {
|
|
||||||
metric.baseline = lineCounts[language];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fs.writeFileSync(sarifFile, JSON.stringify(sarif));
|
fs.writeFileSync(sarifFile, JSON.stringify(sarif));
|
||||||
@@ -265,7 +184,7 @@ async function injectLinesOfCode(sarifFile, language, locPromise) {
|
|||||||
}
|
}
|
||||||
function printLinesOfCodeSummary(logger, language, lineCounts) {
|
function printLinesOfCodeSummary(logger, language, lineCounts) {
|
||||||
if (language in lineCounts) {
|
if (language in lineCounts) {
|
||||||
logger.info(`Counted a baseline of ${lineCounts[language]} lines of code for ${language}.`);
|
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
155
lib/analyze.test.js
generated
155
lib/analyze.test.js
generated
@@ -1,21 +1,9 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
__setModuleDefault(result, mod);
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
@@ -25,8 +13,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||||||
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 ava_1 = __importDefault(require("ava"));
|
||||||
const yaml = __importStar(require("js-yaml"));
|
|
||||||
const semver_1 = require("semver");
|
|
||||||
const sinon_1 = __importDefault(require("sinon"));
|
const sinon_1 = __importDefault(require("sinon"));
|
||||||
const analyze_1 = require("./analyze");
|
const analyze_1 = require("./analyze");
|
||||||
const codeql_1 = require("./codeql");
|
const codeql_1 = require("./codeql");
|
||||||
@@ -53,27 +39,9 @@ ava_1.default("status report fields and search path setting", async (t) => {
|
|||||||
const memoryFlag = "";
|
const memoryFlag = "";
|
||||||
const addSnippetsFlag = "";
|
const addSnippetsFlag = "";
|
||||||
const threadsFlag = "";
|
const threadsFlag = "";
|
||||||
const packs = {
|
|
||||||
[languages_1.Language.cpp]: [
|
|
||||||
{
|
|
||||||
packName: "a/b",
|
|
||||||
version: semver_1.clean("1.0.0"),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
[languages_1.Language.java]: [
|
|
||||||
{
|
|
||||||
packName: "c/d",
|
|
||||||
version: semver_1.clean("2.0.0"),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
for (const language of Object.values(languages_1.Language)) {
|
for (const language of Object.values(languages_1.Language)) {
|
||||||
codeql_1.setCodeQL({
|
codeql_1.setCodeQL({
|
||||||
packDownload: async () => ({ packs: [] }),
|
databaseAnalyze: async (_, sarifFile, searchPath) => {
|
||||||
databaseRunQueries: async (_db, searchPath) => {
|
|
||||||
searchPathsUsed.push(searchPath);
|
|
||||||
},
|
|
||||||
databaseInterpretResults: async (_db, _queriesRun, sarifFile) => {
|
|
||||||
fs.writeFileSync(sarifFile, JSON.stringify({
|
fs.writeFileSync(sarifFile, JSON.stringify({
|
||||||
runs: [
|
runs: [
|
||||||
// variant 1 uses ruleId
|
// variant 1 uses ruleId
|
||||||
@@ -100,38 +68,10 @@ ava_1.default("status report fields and search path setting", async (t) => {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// variant 3 references a rule with the lines-of-code tag
|
|
||||||
{
|
|
||||||
tool: {
|
|
||||||
extensions: [
|
|
||||||
{
|
|
||||||
rules: [
|
|
||||||
{
|
|
||||||
properties: {
|
|
||||||
tags: ["lines-of-code"],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
properties: {
|
|
||||||
metricResults: [
|
|
||||||
{
|
|
||||||
rule: {
|
|
||||||
index: 0,
|
|
||||||
toolComponent: {
|
|
||||||
index: 0,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
value: 123,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{},
|
{},
|
||||||
],
|
],
|
||||||
}));
|
}));
|
||||||
|
searchPathsUsed.push(searchPath);
|
||||||
return "";
|
return "";
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -149,7 +89,6 @@ ava_1.default("status report fields and search path setting", async (t) => {
|
|||||||
type: util.GitHubVariant.DOTCOM,
|
type: util.GitHubVariant.DOTCOM,
|
||||||
},
|
},
|
||||||
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
||||||
packs,
|
|
||||||
};
|
};
|
||||||
fs.mkdirSync(util.getCodeQLDatabasePath(config, language), {
|
fs.mkdirSync(util.getCodeQLDatabasePath(config, language), {
|
||||||
recursive: true,
|
recursive: true,
|
||||||
@@ -159,18 +98,8 @@ ava_1.default("status report fields and search path setting", async (t) => {
|
|||||||
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, undefined, config, logging_1.getRunnerLogger(true));
|
||||||
const hasPacks = language in packs;
|
t.deepEqual(Object.keys(builtinStatusReport).length, 1);
|
||||||
const statusReportKeys = Object.keys(builtinStatusReport).sort();
|
t.true(`analyze_builtin_queries_${language}_duration_ms` in builtinStatusReport);
|
||||||
if (hasPacks) {
|
|
||||||
t.deepEqual(statusReportKeys.length, 3, statusReportKeys.toString());
|
|
||||||
t.deepEqual(statusReportKeys[0], `analyze_builtin_queries_${language}_duration_ms`);
|
|
||||||
t.deepEqual(statusReportKeys[1], `analyze_custom_queries_${language}_duration_ms`);
|
|
||||||
t.deepEqual(statusReportKeys[2], `interpret_results_${language}_duration_ms`);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
t.deepEqual(statusReportKeys[0], `analyze_builtin_queries_${language}_duration_ms`);
|
|
||||||
t.deepEqual(statusReportKeys[1], `interpret_results_${language}_duration_ms`);
|
|
||||||
}
|
|
||||||
config.queries[language] = {
|
config.queries[language] = {
|
||||||
builtin: [],
|
builtin: [],
|
||||||
custom: [
|
custom: [
|
||||||
@@ -185,21 +114,17 @@ ava_1.default("status report fields and search path setting", async (t) => {
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
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, undefined, config, logging_1.getRunnerLogger(true));
|
||||||
t.deepEqual(Object.keys(customStatusReport).length, 2);
|
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);
|
||||||
const expectedSearchPathsUsed = hasPacks
|
t.deepEqual(searchPathsUsed, [undefined, "/1", "/2"]);
|
||||||
? [undefined, undefined, "/1", "/2", undefined]
|
|
||||||
: [undefined, "/1", "/2"];
|
|
||||||
t.deepEqual(searchPathsUsed, expectedSearchPathsUsed);
|
|
||||||
t.true(`interpret_results_${language}_duration_ms` in customStatusReport);
|
|
||||||
}
|
}
|
||||||
verifyLineCounts(tmpDir);
|
verifyLineCounts(tmpDir);
|
||||||
verifyQuerySuites(tmpDir);
|
|
||||||
});
|
});
|
||||||
function verifyLineCounts(tmpDir) {
|
function verifyLineCounts(tmpDir) {
|
||||||
// eslint-disable-next-line github/array-foreach
|
// eslint-disable-next-line github/array-foreach
|
||||||
Object.keys(languages_1.Language).forEach((lang, i) => {
|
Object.keys(languages_1.Language).forEach((lang, i) => {
|
||||||
verifyLineCountForFile(lang, path.join(tmpDir, `${lang}.sarif`), i + 1);
|
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) {
|
function verifyLineCountForFile(lang, filePath, lineCount) {
|
||||||
@@ -221,64 +146,8 @@ ava_1.default("status report fields and search path setting", async (t) => {
|
|||||||
baseline: lineCount,
|
baseline: lineCount,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
t.deepEqual(sarif.runs[2].properties.metricResults, [
|
// when the rule doesn't exists, it should not be added
|
||||||
{
|
t.deepEqual(sarif.runs[2].properties.metricResults, []);
|
||||||
rule: {
|
|
||||||
index: 0,
|
|
||||||
toolComponent: {
|
|
||||||
index: 0,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
value: 123,
|
|
||||||
baseline: lineCount,
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
// when the rule doesn't exist, it should not be added
|
|
||||||
t.deepEqual(sarif.runs[3].properties.metricResults, []);
|
|
||||||
}
|
|
||||||
function verifyQuerySuites(tmpDir) {
|
|
||||||
const qlsContent = [
|
|
||||||
{
|
|
||||||
query: "foo.ql",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
const qlsContent2 = [
|
|
||||||
{
|
|
||||||
query: "bar.ql",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
const qlsPackContentCpp = [
|
|
||||||
{
|
|
||||||
qlpack: "a/b",
|
|
||||||
version: "1.0.0",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
const qlsPackContentJava = [
|
|
||||||
{
|
|
||||||
qlpack: "c/d",
|
|
||||||
version: "2.0.0",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
for (const lang of Object.values(languages_1.Language)) {
|
|
||||||
t.deepEqual(readContents(`${lang}-queries-builtin.qls`), qlsContent);
|
|
||||||
t.deepEqual(readContents(`${lang}-queries-custom-0.qls`), qlsContent);
|
|
||||||
t.deepEqual(readContents(`${lang}-queries-custom-1.qls`), qlsContent2);
|
|
||||||
const packSuiteName = `${lang}-queries-packs.qls`;
|
|
||||||
if (lang === languages_1.Language.cpp) {
|
|
||||||
t.deepEqual(readContents(packSuiteName), qlsPackContentCpp);
|
|
||||||
}
|
|
||||||
else if (lang === languages_1.Language.java) {
|
|
||||||
t.deepEqual(readContents(packSuiteName), qlsPackContentJava);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
t.false(fs.existsSync(path.join(tmpDir, "codeql_databases", packSuiteName)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function readContents(name) {
|
|
||||||
const x = fs.readFileSync(path.join(tmpDir, "codeql_databases", name), "utf8");
|
|
||||||
console.log(x);
|
|
||||||
return yaml.load(fs.readFileSync(path.join(tmpDir, "codeql_databases", name), "utf8"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//# sourceMappingURL=analyze.test.js.map
|
//# sourceMappingURL=analyze.test.js.map
|
||||||
File diff suppressed because one or more lines are too long
37
lib/api-client.js
generated
37
lib/api-client.js
generated
@@ -1,51 +1,36 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
__setModuleDefault(result, mod);
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
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 };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.getActionsApiClient = exports.getApiClient = exports.DisallowedAPIVersionReason = void 0;
|
|
||||||
const path = __importStar(require("path"));
|
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 actions_util_1 = require("./actions-util");
|
const actions_util_1 = require("./actions-util");
|
||||||
const util_1 = require("./util");
|
const util_1 = require("./util");
|
||||||
// eslint-disable-next-line import/no-commonjs
|
|
||||||
const pkg = require("../package.json");
|
|
||||||
var DisallowedAPIVersionReason;
|
var DisallowedAPIVersionReason;
|
||||||
(function (DisallowedAPIVersionReason) {
|
(function (DisallowedAPIVersionReason) {
|
||||||
DisallowedAPIVersionReason[DisallowedAPIVersionReason["ACTION_TOO_OLD"] = 0] = "ACTION_TOO_OLD";
|
DisallowedAPIVersionReason[DisallowedAPIVersionReason["ACTION_TOO_OLD"] = 0] = "ACTION_TOO_OLD";
|
||||||
DisallowedAPIVersionReason[DisallowedAPIVersionReason["ACTION_TOO_NEW"] = 1] = "ACTION_TOO_NEW";
|
DisallowedAPIVersionReason[DisallowedAPIVersionReason["ACTION_TOO_NEW"] = 1] = "ACTION_TOO_NEW";
|
||||||
})(DisallowedAPIVersionReason = exports.DisallowedAPIVersionReason || (exports.DisallowedAPIVersionReason = {}));
|
})(DisallowedAPIVersionReason = exports.DisallowedAPIVersionReason || (exports.DisallowedAPIVersionReason = {}));
|
||||||
const getApiClient = function (apiDetails, { allowExternal = false } = {}) {
|
exports.getApiClient = function (apiDetails, { allowLocalRun = false, allowExternal = false } = {}) {
|
||||||
|
if (util_1.isLocalRun() && !allowLocalRun) {
|
||||||
|
throw new Error("Invalid API call in local run");
|
||||||
|
}
|
||||||
const auth = (allowExternal && apiDetails.externalRepoAuth) || apiDetails.auth;
|
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(auth, {
|
|
||||||
baseUrl: getApiUrl(apiDetails.url),
|
baseUrl: getApiUrl(apiDetails.url),
|
||||||
userAgent: `CodeQL-${util_1.getMode()}/${pkg.version}`,
|
userAgent: "CodeQL Action",
|
||||||
log: console_log_level_1.default({ level: "debug" }),
|
log: console_log_level_1.default({ level: "debug" }),
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
exports.getApiClient = getApiClient;
|
|
||||||
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 connect to github.com
|
||||||
@@ -60,12 +45,12 @@ function getApiUrl(githubUrl) {
|
|||||||
// 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 converted this function should be removed or made canonical
|
||||||
// and called only from the action entrypoints.
|
// and called only from the action entrypoints.
|
||||||
function getActionsApiClient() {
|
function getActionsApiClient(allowLocalRun = false) {
|
||||||
const apiDetails = {
|
const apiDetails = {
|
||||||
auth: actions_util_1.getRequiredInput("token"),
|
auth: actions_util_1.getRequiredInput("token"),
|
||||||
url: util_1.getRequiredEnvParam("GITHUB_SERVER_URL"),
|
url: actions_util_1.getRequiredEnvParam("GITHUB_SERVER_URL"),
|
||||||
};
|
};
|
||||||
return exports.getApiClient(apiDetails);
|
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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AO,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,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,qFAAqF;AACrF,+CAA+C;AAC/C,SAAgB,mBAAmB,CAAC,aAAa,GAAG,KAAK;IACvD,MAAM,UAAU,GAAG;QACjB,IAAI,EAAE,+BAAgB,CAAC,OAAO,CAAC;QAC/B,GAAG,EAAE,kCAAmB,CAAC,mBAAmB,CAAC;KAC9C,CAAC;IAEF,OAAO,oBAAY,CAAC,UAAU,EAAE,EAAE,aAAa,EAAE,CAAC,CAAC;AACrD,CAAC;AAPD,kDAOC"}
|
||||||
33
lib/api-client.test.js
generated
33
lib/api-client.test.js
generated
@@ -1,21 +1,9 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
__setModuleDefault(result, mod);
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
@@ -27,17 +15,10 @@ const ava_1 = __importDefault(require("ava"));
|
|||||||
const sinon_1 = __importDefault(require("sinon"));
|
const sinon_1 = __importDefault(require("sinon"));
|
||||||
const api_client_1 = require("./api-client");
|
const api_client_1 = require("./api-client");
|
||||||
const testing_utils_1 = require("./testing-utils");
|
const testing_utils_1 = require("./testing-utils");
|
||||||
const util_1 = require("./util");
|
|
||||||
// eslint-disable-next-line import/no-commonjs
|
|
||||||
const pkg = require("../package.json");
|
|
||||||
testing_utils_1.setupTests(ava_1.default);
|
testing_utils_1.setupTests(ava_1.default);
|
||||||
let pluginStub;
|
|
||||||
let githubStub;
|
let githubStub;
|
||||||
ava_1.default.beforeEach(() => {
|
ava_1.default.beforeEach(() => {
|
||||||
pluginStub = sinon_1.default.stub(githubUtils.GitHub, "plugin");
|
githubStub = sinon_1.default.stub(githubUtils, "GitHub");
|
||||||
githubStub = sinon_1.default.stub();
|
|
||||||
pluginStub.returns(githubStub);
|
|
||||||
util_1.initializeEnvironment(util_1.Mode.actions, pkg.version);
|
|
||||||
});
|
});
|
||||||
ava_1.default("Get the client API", async (t) => {
|
ava_1.default("Get the client API", async (t) => {
|
||||||
doTest(t, {
|
doTest(t, {
|
||||||
@@ -47,7 +28,7 @@ ava_1.default("Get the client API", async (t) => {
|
|||||||
}, undefined, {
|
}, undefined, {
|
||||||
auth: "token xyz",
|
auth: "token xyz",
|
||||||
baseUrl: "http://hucairz/api/v3",
|
baseUrl: "http://hucairz/api/v3",
|
||||||
userAgent: `CodeQL-Action/${pkg.version}`,
|
userAgent: "CodeQL Action",
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("Get the client API external", async (t) => {
|
ava_1.default("Get the client API external", async (t) => {
|
||||||
@@ -58,7 +39,7 @@ ava_1.default("Get the client API external", async (t) => {
|
|||||||
}, { allowExternal: true }, {
|
}, { allowExternal: true }, {
|
||||||
auth: "token abc",
|
auth: "token abc",
|
||||||
baseUrl: "http://hucairz/api/v3",
|
baseUrl: "http://hucairz/api/v3",
|
||||||
userAgent: `CodeQL-Action/${pkg.version}`,
|
userAgent: "CodeQL Action",
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("Get the client API external not present", async (t) => {
|
ava_1.default("Get the client API external not present", async (t) => {
|
||||||
@@ -68,7 +49,7 @@ ava_1.default("Get the client API external not present", async (t) => {
|
|||||||
}, { allowExternal: true }, {
|
}, { allowExternal: true }, {
|
||||||
auth: "token xyz",
|
auth: "token xyz",
|
||||||
baseUrl: "http://hucairz/api/v3",
|
baseUrl: "http://hucairz/api/v3",
|
||||||
userAgent: `CodeQL-Action/${pkg.version}`,
|
userAgent: "CodeQL Action",
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("Get the client API with github url", async (t) => {
|
ava_1.default("Get the client API with github url", async (t) => {
|
||||||
@@ -78,7 +59,7 @@ ava_1.default("Get the client API with github url", async (t) => {
|
|||||||
}, undefined, {
|
}, undefined, {
|
||||||
auth: "token xyz",
|
auth: "token xyz",
|
||||||
baseUrl: "https://api.github.com",
|
baseUrl: "https://api.github.com",
|
||||||
userAgent: `CodeQL-Action/${pkg.version}`,
|
userAgent: "CodeQL Action",
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
function doTest(t, clientArgs, clientOptions, expected) {
|
function doTest(t, clientArgs, clientOptions, expected) {
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"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;AAC7C,iCAAqD;AAErD,8CAA8C;AAC9C,MAAM,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAEvC,0BAAU,CAAC,aAAI,CAAC,CAAC;AAEjB,IAAI,UAA2B,CAAC;AAChC,IAAI,UAA2B,CAAC;AAEhC,aAAI,CAAC,UAAU,CAAC,GAAG,EAAE;IACnB,UAAU,GAAG,eAAK,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACtD,UAAU,GAAG,eAAK,CAAC,IAAI,EAAE,CAAC;IAC1B,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAC/B,4BAAqB,CAAC,WAAI,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;AACnD,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,iBAAiB,GAAG,CAAC,OAAO,EAAE;KAC1C,CACF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,aAAI,CAAC,6BAA6B,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAC9C,MAAM,CACJ,CAAC,EACD;QACE,IAAI,EAA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AAS,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 +1 @@
|
|||||||
{ "maximumVersion": "3.2", "minimumVersion": "2.22" }
|
{ "maximumVersion": "3.1", "minimumVersion": "2.22" }
|
||||||
|
|||||||
32
lib/autobuild-action.js
generated
32
lib/autobuild-action.js
generated
@@ -1,54 +1,40 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
__setModuleDefault(result, mod);
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const core = __importStar(require("@actions/core"));
|
const core = __importStar(require("@actions/core"));
|
||||||
const actions_util_1 = require("./actions-util");
|
const actionsUtil = __importStar(require("./actions-util"));
|
||||||
const autobuild_1 = require("./autobuild");
|
const autobuild_1 = require("./autobuild");
|
||||||
const config_utils = __importStar(require("./config-utils"));
|
const config_utils = __importStar(require("./config-utils"));
|
||||||
const logging_1 = require("./logging");
|
const logging_1 = require("./logging");
|
||||||
const util_1 = require("./util");
|
|
||||||
// eslint-disable-next-line import/no-commonjs
|
|
||||||
const pkg = require("../package.json");
|
|
||||||
async function sendCompletedStatusReport(startedAt, allLanguages, failingLanguage, cause) {
|
async function sendCompletedStatusReport(startedAt, allLanguages, failingLanguage, cause) {
|
||||||
util_1.initializeEnvironment(util_1.Mode.actions, pkg.version);
|
var _a, _b;
|
||||||
const status = failingLanguage !== undefined || cause !== undefined
|
const status = failingLanguage !== undefined || cause !== undefined
|
||||||
? "failure"
|
? "failure"
|
||||||
: "success";
|
: "success";
|
||||||
const statusReportBase = await actions_util_1.createStatusReportBase("autobuild", status, startedAt, cause === null || cause === void 0 ? void 0 : cause.message, cause === null || cause === void 0 ? void 0 : cause.stack);
|
const statusReportBase = await actionsUtil.createStatusReportBase("autobuild", status, startedAt, (_a = cause) === null || _a === void 0 ? void 0 : _a.message, (_b = cause) === null || _b === void 0 ? void 0 : _b.stack);
|
||||||
const statusReport = {
|
const statusReport = {
|
||||||
...statusReportBase,
|
...statusReportBase,
|
||||||
autobuild_languages: allLanguages.join(","),
|
autobuild_languages: allLanguages.join(","),
|
||||||
autobuild_failure: failingLanguage,
|
autobuild_failure: failingLanguage,
|
||||||
};
|
};
|
||||||
await actions_util_1.sendStatusReport(statusReport);
|
await actionsUtil.sendStatusReport(statusReport);
|
||||||
}
|
}
|
||||||
async function run() {
|
async function run() {
|
||||||
const logger = logging_1.getActionsLogger();
|
const logger = logging_1.getActionsLogger();
|
||||||
const startedAt = new Date();
|
const startedAt = new Date();
|
||||||
let language = undefined;
|
let language = undefined;
|
||||||
try {
|
try {
|
||||||
if (!(await actions_util_1.sendStatusReport(await actions_util_1.createStatusReportBase("autobuild", "starting", startedAt)))) {
|
actionsUtil.prepareLocalRunEnvironment();
|
||||||
|
if (!(await actionsUtil.sendStatusReport(await actionsUtil.createStatusReportBase("autobuild", "starting", startedAt)))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const config = await config_utils.getConfig(actions_util_1.getTemporaryDirectory(), logger);
|
const config = await config_utils.getConfig(actionsUtil.getTemporaryDirectory(), 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?");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"autobuild-action.js","sourceRoot":"","sources":["../src/autobuild-action.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsC;AAEtC,iDAKwB;AACxB,2CAAuE;AACvE,6DAA+C;AAE/C,uCAA6C;AAC7C,iCAAqD;AAErD,8CAA8C;AAC9C,MAAM,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAC,CA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B,QAAQ,EACR,KAAK,CACN,CAAC;QACF,OAAO;KACR;IAED,MAAM,yBAAyB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AACzE,CAAC;AAED,KAAK,UAAU,UAAU;IACvB,IAAI;QACF,MAAM,GAAG,EAAE,CAAC;KACb;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,CAAC,SAAS,CAAC,4BAA4B,KAAK,EAAE,CAAC,CAAC;QACpD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;KACpB;AACH,CAAC;AAED,KAAK,UAAU,EAAE,CAAC"}
|
||||||
1
lib/autobuild.js
generated
1
lib/autobuild.js
generated
@@ -1,6 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.runAutobuild = exports.determineAutobuildLanguage = void 0;
|
|
||||||
const codeql_1 = require("./codeql");
|
const codeql_1 = require("./codeql");
|
||||||
const languages_1 = require("./languages");
|
const languages_1 = require("./languages");
|
||||||
function determineAutobuildLanguage(config, logger) {
|
function determineAutobuildLanguage(config, logger) {
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"autobuild.js","sourceRoot":"","sources":["../src/autobuild.ts"],"names":[],"mappings":";;;AAAA,qCAAqC;AAErC,2CAAyD;AAGzD,SAAgB,0BAA0B,CACxC,MAA2B,EAC3B,MAAc;IAEd,0CAA0C;IAC1C,mFAAmF;IACnF,oFAAoF;IACpF,4EAA4E;IAC5E,MAAM,kBAAkB,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,4BAAgB,CAAC,CAAC;IACrE,MAAM,QAAQ,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAAC;IAEvC,IAAI,CAAC,QAAQ,EAAE;QACb,MAAM,CAAC,IAAI,CACT,iEAAiE,CA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AE;QACjC,MAAM,CAAC,OAAO,CACZ,oCAAoC,QAAQ,8BAA8B,kBAAkB;aACzF,KAAK,CAAC,CAAC,CAAC;aACR,IAAI,CAAC,OAAO,CAAC,uDAAuD,CACxE,CAAC;KACH;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AA7BD,gEA6BC;AAEM,KAAK,UAAU,YAAY,CAChC,QAAkB,EAClB,MAA2B,EAC3B,MAAc;IAEd,MAAM,CAAC,UAAU,CAAC,qCAAqC,QAAQ,OAAO,CAAC,CAAC;IACxE,MAAM,MAAM,GAAG,kBAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAC3C,MAAM,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IACpC,MAAM,CAAC,QAAQ,EAAE,CAAC;AACpB,CAAC;AATD,oCASC"}
|
||||||
322
lib/codeql.js
generated
322
lib/codeql.js
generated
@@ -1,34 +1,25 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
__setModuleDefault(result, mod);
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
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 };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.getExtraOptions = exports.getCachedCodeQL = exports.setCodeQL = exports.getCodeQL = exports.convertToSemVer = exports.getCodeQLURLVersion = exports.setupCodeQL = exports.getCodeQLActionRepository = exports.CommandInvocationError = void 0;
|
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
|
const stream = __importStar(require("stream"));
|
||||||
|
const globalutil = __importStar(require("util"));
|
||||||
const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
|
const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
|
||||||
|
const http = __importStar(require("@actions/http-client"));
|
||||||
const fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
|
const fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
|
||||||
const query_string_1 = __importDefault(require("query-string"));
|
const query_string_1 = __importDefault(require("query-string"));
|
||||||
const semver = __importStar(require("semver"));
|
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!
|
||||||
@@ -36,14 +27,6 @@ const error_matcher_1 = require("./error-matcher");
|
|||||||
const toolcache = __importStar(require("./toolcache"));
|
const toolcache = __importStar(require("./toolcache"));
|
||||||
const toolrunner_error_catcher_1 = require("./toolrunner-error-catcher");
|
const toolrunner_error_catcher_1 = require("./toolrunner-error-catcher");
|
||||||
const util = __importStar(require("./util"));
|
const util = __importStar(require("./util"));
|
||||||
class CommandInvocationError extends Error {
|
|
||||||
constructor(cmd, args, exitCode, error) {
|
|
||||||
super(`Failure invoking ${cmd} with arguments ${args}.\n
|
|
||||||
Exit code ${exitCode} and error was:\n
|
|
||||||
${error}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.CommandInvocationError = CommandInvocationError;
|
|
||||||
/**
|
/**
|
||||||
* Stores the CodeQL object, and is populated by `setupCodeQL` or `getCodeQL`.
|
* Stores the CodeQL object, and is populated by `setupCodeQL` or `getCodeQL`.
|
||||||
* Can be overridden in tests using `setCodeQL`.
|
* Can be overridden in tests using `setCodeQL`.
|
||||||
@@ -67,15 +50,14 @@ function getCodeQLBundleName() {
|
|||||||
}
|
}
|
||||||
return `codeql-bundle-${platform}.tar.gz`;
|
return `codeql-bundle-${platform}.tar.gz`;
|
||||||
}
|
}
|
||||||
function getCodeQLActionRepository(logger) {
|
function getCodeQLActionRepository(mode, logger) {
|
||||||
if (!util.isActions()) {
|
if (mode !== "actions") {
|
||||||
return CODEQL_DEFAULT_ACTION_REPOSITORY;
|
return CODEQL_DEFAULT_ACTION_REPOSITORY;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return getActionsCodeQLActionRepository(logger);
|
return getActionsCodeQLActionRepository(logger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.getCodeQLActionRepository = getCodeQLActionRepository;
|
|
||||||
function getActionsCodeQLActionRepository(logger) {
|
function getActionsCodeQLActionRepository(logger) {
|
||||||
if (process.env["GITHUB_ACTION_REPOSITORY"] !== undefined) {
|
if (process.env["GITHUB_ACTION_REPOSITORY"] !== undefined) {
|
||||||
return process.env["GITHUB_ACTION_REPOSITORY"];
|
return process.env["GITHUB_ACTION_REPOSITORY"];
|
||||||
@@ -92,8 +74,8 @@ function getActionsCodeQLActionRepository(logger) {
|
|||||||
const relativeScriptPathParts = actions_util_1.getRelativeScriptPath().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, variant, logger) {
|
async function getCodeQLBundleDownloadURL(apiDetails, mode, variant, logger) {
|
||||||
const codeQLActionRepository = getCodeQLActionRepository(logger);
|
const codeQLActionRepository = getCodeQLActionRepository(mode, logger);
|
||||||
const potentialDownloadSources = [
|
const potentialDownloadSources = [
|
||||||
// This GitHub instance, and this Action.
|
// This GitHub instance, and this Action.
|
||||||
[apiDetails.url, codeQLActionRepository],
|
[apiDetails.url, codeQLActionRepository],
|
||||||
@@ -159,7 +141,22 @@ async function getCodeQLBundleDownloadURL(apiDetails, variant, logger) {
|
|||||||
}
|
}
|
||||||
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}/${codeQLBundleName}`;
|
||||||
}
|
}
|
||||||
async function setupCodeQL(codeqlURL, apiDetails, tempDir, toolCacheDir, variant, logger) {
|
// 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.
|
||||||
|
async function toolcacheDownloadTool(url, headers, tempDir, logger) {
|
||||||
|
const client = new http.HttpClient("CodeQL Action");
|
||||||
|
const dest = path.join(tempDir, uuid_1.v4());
|
||||||
|
const response = await client.get(url, headers);
|
||||||
|
if (response.message.statusCode !== 200) {
|
||||||
|
logger.info(`Failed to download from "${url}". Code(${response.message.statusCode}) Message(${response.message.statusMessage})`);
|
||||||
|
throw new Error(`Unexpected HTTP response: ${response.message.statusCode}`);
|
||||||
|
}
|
||||||
|
const pipeline = globalutil.promisify(stream.pipeline);
|
||||||
|
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
||||||
|
await pipeline(response.message, fs.createWriteStream(dest));
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
async function setupCodeQL(codeqlURL, apiDetails, tempDir, toolCacheDir, mode, variant, logger) {
|
||||||
try {
|
try {
|
||||||
// We use the special value of 'latest' to prioritize the version in the
|
// We use the special value of 'latest' to prioritize the version in the
|
||||||
// defaults over any pinned cached version.
|
// defaults over any pinned cached version.
|
||||||
@@ -167,58 +164,50 @@ async function setupCodeQL(codeqlURL, apiDetails, tempDir, toolCacheDir, variant
|
|||||||
if (forceLatest) {
|
if (forceLatest) {
|
||||||
codeqlURL = undefined;
|
codeqlURL = undefined;
|
||||||
}
|
}
|
||||||
let codeqlFolder;
|
const codeqlURLVersion = getCodeQLURLVersion(codeqlURL || `/${CODEQL_BUNDLE_VERSION}/`);
|
||||||
let codeqlURLVersion;
|
const codeqlURLSemVer = convertToSemVer(codeqlURLVersion, logger);
|
||||||
if (codeqlURL && !codeqlURL.startsWith("http")) {
|
// If we find the specified version, we always use that.
|
||||||
codeqlFolder = await toolcache.extractTar(codeqlURL, tempDir, logger);
|
let codeqlFolder = toolcache.find("CodeQL", codeqlURLSemVer, mode, toolCacheDir, logger);
|
||||||
codeqlURLVersion = "local";
|
// 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) {
|
||||||
|
logger.debug(`CodeQL found in cache ${codeqlFolder}`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
codeqlURLVersion = getCodeQLURLVersion(codeqlURL || `/${CODEQL_BUNDLE_VERSION}/`);
|
if (!codeqlURL) {
|
||||||
const codeqlURLSemVer = convertToSemVer(codeqlURLVersion, logger);
|
codeqlURL = await getCodeQLBundleDownloadURL(apiDetails, mode, variant, logger);
|
||||||
// If we find the specified version, we always use that.
|
|
||||||
codeqlFolder = toolcache.find("CodeQL", codeqlURLSemVer, 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", toolCacheDir, logger);
|
|
||||||
if (codeqlVersions.length === 1) {
|
|
||||||
const tmpCodeqlFolder = toolcache.find("CodeQL", codeqlVersions[0], 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) {
|
const parsedCodeQLURL = new URL(codeqlURL);
|
||||||
logger.debug(`CodeQL found in cache ${codeqlFolder}`);
|
const parsedQueryString = query_string_1.default.parse(parsedCodeQLURL.search);
|
||||||
|
const headers = { accept: "application/octet-stream" };
|
||||||
|
// We only want to provide an authorization header if we are downloading
|
||||||
|
// from the same GitHub instance the Action is running on.
|
||||||
|
// 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(`${apiDetails.url}/`) &&
|
||||||
|
parsedQueryString["token"] === undefined) {
|
||||||
|
logger.debug("Downloading CodeQL bundle with token.");
|
||||||
|
headers.authorization = `token ${apiDetails.auth}`;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!codeqlURL) {
|
logger.debug("Downloading CodeQL bundle without token.");
|
||||||
codeqlURL = await getCodeQLBundleDownloadURL(apiDetails, variant, logger);
|
|
||||||
}
|
|
||||||
const parsedCodeQLURL = new URL(codeqlURL);
|
|
||||||
const parsedQueryString = query_string_1.default.parse(parsedCodeQLURL.search);
|
|
||||||
const headers = { accept: "application/octet-stream" };
|
|
||||||
// We only want to provide an authorization header if we are downloading
|
|
||||||
// from the same GitHub instance the Action is running on.
|
|
||||||
// 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(`${apiDetails.url}/`) &&
|
|
||||||
parsedQueryString["token"] === undefined) {
|
|
||||||
logger.debug("Downloading CodeQL bundle with token.");
|
|
||||||
headers.authorization = `token ${apiDetails.auth}`;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
logger.debug("Downloading CodeQL bundle without token.");
|
|
||||||
}
|
|
||||||
logger.info(`Downloading CodeQL tools from ${codeqlURL}. This may take a while.`);
|
|
||||||
const codeqlPath = await toolcache.downloadTool(codeqlURL, tempDir, headers);
|
|
||||||
logger.debug(`CodeQL bundle download to ${codeqlPath} complete.`);
|
|
||||||
const codeqlExtracted = await toolcache.extractTar(codeqlPath, tempDir, logger);
|
|
||||||
codeqlFolder = await toolcache.cacheDir(codeqlExtracted, "CodeQL", codeqlURLSemVer, toolCacheDir, logger);
|
|
||||||
}
|
}
|
||||||
|
logger.info(`Downloading CodeQL tools from ${codeqlURL}. This may take a while.`);
|
||||||
|
const codeqlPath = await toolcacheDownloadTool(codeqlURL, headers, tempDir, logger);
|
||||||
|
logger.debug(`CodeQL bundle download to ${codeqlPath} complete.`);
|
||||||
|
const codeqlExtracted = await toolcache.extractTar(codeqlPath, mode, tempDir, logger);
|
||||||
|
codeqlFolder = await toolcache.cacheDir(codeqlExtracted, "CodeQL", codeqlURLSemVer, mode, toolCacheDir, logger);
|
||||||
}
|
}
|
||||||
let codeqlCmd = path.join(codeqlFolder, "codeql", "codeql");
|
let codeqlCmd = path.join(codeqlFolder, "codeql", "codeql");
|
||||||
if (process.platform === "win32") {
|
if (process.platform === "win32") {
|
||||||
@@ -293,13 +282,8 @@ function setCodeQL(partialCodeql) {
|
|||||||
runAutobuild: resolveFunction(partialCodeql, "runAutobuild"),
|
runAutobuild: resolveFunction(partialCodeql, "runAutobuild"),
|
||||||
extractScannedLanguage: resolveFunction(partialCodeql, "extractScannedLanguage"),
|
extractScannedLanguage: resolveFunction(partialCodeql, "extractScannedLanguage"),
|
||||||
finalizeDatabase: resolveFunction(partialCodeql, "finalizeDatabase"),
|
finalizeDatabase: resolveFunction(partialCodeql, "finalizeDatabase"),
|
||||||
resolveLanguages: resolveFunction(partialCodeql, "resolveLanguages"),
|
|
||||||
resolveQueries: resolveFunction(partialCodeql, "resolveQueries"),
|
resolveQueries: resolveFunction(partialCodeql, "resolveQueries"),
|
||||||
packDownload: resolveFunction(partialCodeql, "packDownload"),
|
databaseAnalyze: resolveFunction(partialCodeql, "databaseAnalyze"),
|
||||||
databaseCleanup: resolveFunction(partialCodeql, "databaseCleanup"),
|
|
||||||
databaseBundle: resolveFunction(partialCodeql, "databaseBundle"),
|
|
||||||
databaseRunQueries: resolveFunction(partialCodeql, "databaseRunQueries"),
|
|
||||||
databaseInterpretResults: resolveFunction(partialCodeql, "databaseInterpretResults"),
|
|
||||||
};
|
};
|
||||||
return cachedCodeQL;
|
return cachedCodeQL;
|
||||||
}
|
}
|
||||||
@@ -324,7 +308,7 @@ function getCodeQLForCmd(cmd) {
|
|||||||
return cmd;
|
return cmd;
|
||||||
},
|
},
|
||||||
async printVersion() {
|
async printVersion() {
|
||||||
await runTool(cmd, ["version", "--format=json"]);
|
await new toolrunner.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.
|
||||||
@@ -355,7 +339,7 @@ function getCodeQLForCmd(cmd) {
|
|||||||
// action/runner has been implemented in `codeql database trace-command`
|
// action/runner has been implemented in `codeql database trace-command`
|
||||||
// _and_ is present in the latest supported CLI release.)
|
// _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 runTool(cmd, [
|
await new toolrunner.ToolRunner(cmd, [
|
||||||
"database",
|
"database",
|
||||||
"trace-command",
|
"trace-command",
|
||||||
databasePath,
|
databasePath,
|
||||||
@@ -363,18 +347,18 @@ function getCodeQLForCmd(cmd) {
|
|||||||
process.execPath,
|
process.execPath,
|
||||||
tracerEnvJs,
|
tracerEnvJs,
|
||||||
envFile,
|
envFile,
|
||||||
]);
|
]).exec();
|
||||||
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 runTool(cmd, [
|
await new toolrunner.ToolRunner(cmd, [
|
||||||
"database",
|
"database",
|
||||||
"init",
|
"init",
|
||||||
databasePath,
|
databasePath,
|
||||||
`--language=${language}`,
|
`--language=${language}`,
|
||||||
`--source-root=${sourceRoot}`,
|
`--source-root=${sourceRoot}`,
|
||||||
...getExtraOptionsFromEnv(["database", "init"]),
|
...getExtraOptionsFromEnv(["database", "init"]),
|
||||||
]);
|
]).exec();
|
||||||
},
|
},
|
||||||
async runAutobuild(language) {
|
async runAutobuild(language) {
|
||||||
const cmdName = process.platform === "win32" ? "autobuild.cmd" : "autobuild.sh";
|
const cmdName = process.platform === "win32" ? "autobuild.cmd" : "autobuild.sh";
|
||||||
@@ -390,7 +374,7 @@ function getCodeQLForCmd(cmd) {
|
|||||||
"-Dhttp.keepAlive=false",
|
"-Dhttp.keepAlive=false",
|
||||||
"-Dmaven.wagon.http.pool=false",
|
"-Dmaven.wagon.http.pool=false",
|
||||||
].join(" ");
|
].join(" ");
|
||||||
await runTool(autobuildCmd);
|
await new toolrunner.ToolRunner(autobuildCmd).exec();
|
||||||
},
|
},
|
||||||
async extractScannedLanguage(databasePath, language) {
|
async extractScannedLanguage(databasePath, language) {
|
||||||
// Get extractor location
|
// Get extractor location
|
||||||
@@ -429,22 +413,11 @@ function getCodeQLForCmd(cmd) {
|
|||||||
await toolrunner_error_catcher_1.toolrunnerErrorCatcher(cmd, [
|
await toolrunner_error_catcher_1.toolrunnerErrorCatcher(cmd, [
|
||||||
"database",
|
"database",
|
||||||
"finalize",
|
"finalize",
|
||||||
"--finalize-dataset",
|
|
||||||
threadsFlag,
|
threadsFlag,
|
||||||
...getExtraOptionsFromEnv(["database", "finalize"]),
|
...getExtraOptionsFromEnv(["database", "finalize"]),
|
||||||
databasePath,
|
databasePath,
|
||||||
], error_matcher_1.errorMatchers);
|
], error_matcher_1.errorMatchers);
|
||||||
},
|
},
|
||||||
async resolveLanguages() {
|
|
||||||
const codeqlArgs = ["resolve", "languages", "--format=json"];
|
|
||||||
const output = await runTool(cmd, codeqlArgs);
|
|
||||||
try {
|
|
||||||
return JSON.parse(output);
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
throw new Error(`Unexpected output from codeql resolve languages: ${e}`);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
async resolveQueries(queries, extraSearchPath) {
|
async resolveQueries(queries, extraSearchPath) {
|
||||||
const codeqlArgs = [
|
const codeqlArgs = [
|
||||||
"resolve",
|
"resolve",
|
||||||
@@ -456,111 +429,53 @@ function getCodeQLForCmd(cmd) {
|
|||||||
if (extraSearchPath !== undefined) {
|
if (extraSearchPath !== undefined) {
|
||||||
codeqlArgs.push("--additional-packs", extraSearchPath);
|
codeqlArgs.push("--additional-packs", extraSearchPath);
|
||||||
}
|
}
|
||||||
const output = await runTool(cmd, codeqlArgs);
|
let output = "";
|
||||||
try {
|
await new toolrunner.ToolRunner(cmd, codeqlArgs, {
|
||||||
return JSON.parse(output);
|
listeners: {
|
||||||
}
|
stdout: (data) => {
|
||||||
catch (e) {
|
output += data.toString();
|
||||||
throw new Error(`Unexpected output from codeql resolve queries: ${e}`);
|
},
|
||||||
}
|
},
|
||||||
|
}).exec();
|
||||||
|
return JSON.parse(output);
|
||||||
},
|
},
|
||||||
async databaseRunQueries(databasePath, extraSearchPath, querySuitePath, memoryFlag, threadsFlag) {
|
async databaseAnalyze(databasePath, sarifFile, extraSearchPath, querySuite, memoryFlag, addSnippetsFlag, threadsFlag, automationDetailsId) {
|
||||||
const codeqlArgs = [
|
const args = [
|
||||||
"database",
|
"database",
|
||||||
"run-queries",
|
"analyze",
|
||||||
memoryFlag,
|
memoryFlag,
|
||||||
threadsFlag,
|
threadsFlag,
|
||||||
databasePath,
|
databasePath,
|
||||||
"--min-disk-free=1024",
|
"--min-disk-free=1024",
|
||||||
"-v",
|
|
||||||
...getExtraOptionsFromEnv(["database", "run-queries"]),
|
|
||||||
];
|
|
||||||
if (extraSearchPath !== undefined) {
|
|
||||||
codeqlArgs.push("--additional-packs", extraSearchPath);
|
|
||||||
}
|
|
||||||
codeqlArgs.push(querySuitePath);
|
|
||||||
await runTool(cmd, codeqlArgs);
|
|
||||||
},
|
|
||||||
async databaseInterpretResults(databasePath, querySuitePaths, sarifFile, addSnippetsFlag, threadsFlag, automationDetailsId) {
|
|
||||||
const codeqlArgs = [
|
|
||||||
"database",
|
|
||||||
"interpret-results",
|
|
||||||
threadsFlag,
|
|
||||||
"--format=sarif-latest",
|
"--format=sarif-latest",
|
||||||
"--print-diagnostics-summary",
|
"--sarif-multicause-markdown",
|
||||||
"--print-metrics-summary",
|
|
||||||
"--sarif-group-rules-by-pack",
|
|
||||||
"-v",
|
|
||||||
`--output=${sarifFile}`,
|
`--output=${sarifFile}`,
|
||||||
addSnippetsFlag,
|
addSnippetsFlag,
|
||||||
...getExtraOptionsFromEnv(["database", "interpret-results"]),
|
// 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"]),
|
||||||
];
|
];
|
||||||
|
if (extraSearchPath !== undefined) {
|
||||||
|
args.push("--additional-packs", extraSearchPath);
|
||||||
|
}
|
||||||
if (automationDetailsId !== undefined) {
|
if (automationDetailsId !== undefined) {
|
||||||
codeqlArgs.push("--sarif-category", automationDetailsId);
|
args.push("--sarif-category", automationDetailsId);
|
||||||
}
|
}
|
||||||
codeqlArgs.push(databasePath, ...querySuitePaths);
|
args.push(querySuite);
|
||||||
// capture stdout, which contains analysis summaries
|
// capture stdout, which contains analysis summaries
|
||||||
return await runTool(cmd, codeqlArgs);
|
let output = "";
|
||||||
},
|
await new toolrunner.ToolRunner(cmd, args, {
|
||||||
/**
|
listeners: {
|
||||||
* Download specified packs into the package cache. If the specified
|
stdout: (data) => {
|
||||||
* package and version already exists (e.g., from a previous analysis run),
|
output += data.toString("utf8");
|
||||||
* then it is not downloaded again (unless the extra option `--force` is
|
},
|
||||||
* specified).
|
},
|
||||||
*
|
}).exec();
|
||||||
* If no version is specified, then the latest version is
|
return output;
|
||||||
* downloaded. The check to determine what the latest version is is done
|
|
||||||
* each time this package is requested.
|
|
||||||
*/
|
|
||||||
async packDownload(packs) {
|
|
||||||
const codeqlArgs = [
|
|
||||||
"pack",
|
|
||||||
"download",
|
|
||||||
"--format=json",
|
|
||||||
...getExtraOptionsFromEnv(["pack", "download"]),
|
|
||||||
...packs.map(packWithVersionToString),
|
|
||||||
];
|
|
||||||
const output = await runTool(cmd, codeqlArgs);
|
|
||||||
try {
|
|
||||||
const parsedOutput = JSON.parse(output);
|
|
||||||
if (Array.isArray(parsedOutput.packs) &&
|
|
||||||
// TODO PackDownloadOutput will not include the version if it is not specified
|
|
||||||
// in the input. The version is always the latest version available.
|
|
||||||
// It should be added to the output, but this requires a CLI change
|
|
||||||
parsedOutput.packs.every((p) => p.name /* && p.version */)) {
|
|
||||||
return parsedOutput;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw new Error("Unexpected output from pack download");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
throw new Error(`Attempted to download specified packs but got an error:\n${output}\n${e}`);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
async databaseCleanup(databasePath, cleanupLevel) {
|
|
||||||
const codeqlArgs = [
|
|
||||||
"database",
|
|
||||||
"cleanup",
|
|
||||||
databasePath,
|
|
||||||
`--mode=${cleanupLevel}`,
|
|
||||||
];
|
|
||||||
await runTool(cmd, codeqlArgs);
|
|
||||||
},
|
|
||||||
async databaseBundle(databasePath, outputFilePath) {
|
|
||||||
const args = [
|
|
||||||
"database",
|
|
||||||
"bundle",
|
|
||||||
databasePath,
|
|
||||||
`--output=${outputFilePath}`,
|
|
||||||
];
|
|
||||||
await new toolrunner.ToolRunner(cmd, args).exec();
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
function packWithVersionToString(pack) {
|
|
||||||
return pack.version ? `${pack.packName}@${pack.version}` : pack.packName;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
*/
|
*/
|
||||||
@@ -599,39 +514,12 @@ function asExtraOptions(options, pathInfo) {
|
|||||||
* Exported for testing.
|
* Exported for testing.
|
||||||
*/
|
*/
|
||||||
function getExtraOptions(options, paths, pathInfo) {
|
function getExtraOptions(options, paths, pathInfo) {
|
||||||
const all = asExtraOptions(options === null || options === void 0 ? void 0 : options["*"], pathInfo.concat("*"));
|
var _a, _b, _c;
|
||||||
|
const all = asExtraOptions((_a = options) === null || _a === void 0 ? void 0 : _a["*"], pathInfo.concat("*"));
|
||||||
const specific = paths.length === 0
|
const specific = paths.length === 0
|
||||||
? asExtraOptions(options, pathInfo)
|
? asExtraOptions(options, pathInfo)
|
||||||
: getExtraOptions(options === null || options === void 0 ? void 0 : options[paths[0]], paths === null || paths === void 0 ? void 0 : paths.slice(1), pathInfo.concat(paths[0]));
|
: 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]));
|
||||||
return all.concat(specific);
|
return all.concat(specific);
|
||||||
}
|
}
|
||||||
exports.getExtraOptions = getExtraOptions;
|
exports.getExtraOptions = getExtraOptions;
|
||||||
/*
|
|
||||||
* A constant defining the maximum number of characters we will keep from
|
|
||||||
* the programs stderr for logging. This serves two purposes:
|
|
||||||
* (1) It avoids an OOM if a program fails in a way that results it
|
|
||||||
* printing many log lines.
|
|
||||||
* (2) It avoids us hitting the limit of how much data we can send in our
|
|
||||||
* status reports on GitHub.com.
|
|
||||||
*/
|
|
||||||
const maxErrorSize = 20000;
|
|
||||||
async function runTool(cmd, args = []) {
|
|
||||||
let output = "";
|
|
||||||
let error = "";
|
|
||||||
const exitCode = await new toolrunner.ToolRunner(cmd, args, {
|
|
||||||
listeners: {
|
|
||||||
stdout: (data) => {
|
|
||||||
output += data.toString();
|
|
||||||
},
|
|
||||||
stderr: (data) => {
|
|
||||||
const toRead = Math.min(maxErrorSize - error.length, data.length);
|
|
||||||
error += data.toString("utf8", 0, toRead);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
ignoreReturnCode: true,
|
|
||||||
}).exec();
|
|
||||||
if (exitCode !== 0)
|
|
||||||
throw new CommandInvocationError(cmd, args, exitCode, error);
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=codeql.js.map
|
//# sourceMappingURL=codeql.js.map
|
||||||
File diff suppressed because one or more lines are too long
55
lib/codeql.test.js
generated
55
lib/codeql.test.js
generated
@@ -1,21 +1,9 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
__setModuleDefault(result, mod);
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
@@ -31,7 +19,6 @@ 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"));
|
||||||
const util_1 = require("./util");
|
|
||||||
testing_utils_1.setupTests(ava_1.default);
|
testing_utils_1.setupTests(ava_1.default);
|
||||||
const sampleApiDetails = {
|
const sampleApiDetails = {
|
||||||
auth: "token",
|
auth: "token",
|
||||||
@@ -41,9 +28,6 @@ const sampleGHAEApiDetails = {
|
|||||||
auth: "token",
|
auth: "token",
|
||||||
url: "https://example.githubenterprise.com",
|
url: "https://example.githubenterprise.com",
|
||||||
};
|
};
|
||||||
ava_1.default.beforeEach(() => {
|
|
||||||
util_1.initializeEnvironment(util_1.Mode.actions, "1.2.3");
|
|
||||||
});
|
|
||||||
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);
|
testing_utils_1.setupActionsVars(tmpDir, tmpDir);
|
||||||
@@ -53,7 +37,7 @@ ava_1.default("download codeql bundle cache", async (t) => {
|
|||||||
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, util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
|
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));
|
||||||
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");
|
||||||
@@ -66,12 +50,12 @@ ava_1.default("download codeql bundle cache explicitly requested with pinned dif
|
|||||||
nock_1.default("https://example.com")
|
nock_1.default("https://example.com")
|
||||||
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
|
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
|
||||||
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
|
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"));
|
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
||||||
nock_1.default("https://example.com")
|
nock_1.default("https://example.com")
|
||||||
.get(`/download/codeql-bundle-20200610/codeql-bundle.tar.gz`)
|
.get(`/download/codeql-bundle-20200610/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-20200610/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
|
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"));
|
t.assert(toolcache.find("CodeQL", "0.0.0-20200610"));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -81,9 +65,9 @@ ava_1.default("don't download codeql bundle cache with pinned different version
|
|||||||
nock_1.default("https://example.com")
|
nock_1.default("https://example.com")
|
||||||
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
|
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
|
||||||
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
|
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"));
|
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
||||||
await codeql.setupCodeQL(undefined, sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
|
await codeql.setupCodeQL(undefined, sampleApiDetails, tmpDir, tmpDir, "runner", util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
|
||||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||||
t.is(cachedVersions.length, 1);
|
t.is(cachedVersions.length, 1);
|
||||||
});
|
});
|
||||||
@@ -94,7 +78,7 @@ ava_1.default("download codeql bundle cache with different version cached (not p
|
|||||||
nock_1.default("https://example.com")
|
nock_1.default("https://example.com")
|
||||||
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
.get(`/download/codeql-bundle-20200601/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-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
|
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"));
|
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
||||||
const platform = process.platform === "win32"
|
const platform = process.platform === "win32"
|
||||||
? "win64"
|
? "win64"
|
||||||
@@ -104,7 +88,7 @@ ava_1.default("download codeql bundle cache with different version cached (not p
|
|||||||
nock_1.default("https://github.com")
|
nock_1.default("https://github.com")
|
||||||
.get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/codeql-bundle-${platform}.tar.gz`)
|
.get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/codeql-bundle-${platform}.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(undefined, sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
|
await codeql.setupCodeQL(undefined, sampleApiDetails, tmpDir, tmpDir, "runner", util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
|
||||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||||
t.is(cachedVersions.length, 2);
|
t.is(cachedVersions.length, 2);
|
||||||
});
|
});
|
||||||
@@ -115,7 +99,7 @@ ava_1.default('download codeql bundle cache with pinned different version cached
|
|||||||
nock_1.default("https://example.com")
|
nock_1.default("https://example.com")
|
||||||
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
.get(`/download/codeql-bundle-20200601/codeql-bundle.tar.gz`)
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
|
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
|
||||||
await codeql.setupCodeQL("https://example.com/download/codeql-bundle-20200601/codeql-bundle.tar.gz", sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
|
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"));
|
t.assert(toolcache.find("CodeQL", "0.0.0-20200601"));
|
||||||
const platform = process.platform === "win32"
|
const platform = process.platform === "win32"
|
||||||
? "win64"
|
? "win64"
|
||||||
@@ -125,7 +109,7 @@ ava_1.default('download codeql bundle cache with pinned different version cached
|
|||||||
nock_1.default("https://github.com")
|
nock_1.default("https://github.com")
|
||||||
.get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/codeql-bundle-${platform}.tar.gz`)
|
.get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/codeql-bundle-${platform}.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("latest", sampleApiDetails, tmpDir, tmpDir, util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
|
await codeql.setupCodeQL("latest", sampleApiDetails, tmpDir, tmpDir, "runner", util.GitHubVariant.DOTCOM, logging_1.getRunnerLogger(true));
|
||||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||||
t.is(cachedVersions.length, 2);
|
t.is(cachedVersions.length, 2);
|
||||||
});
|
});
|
||||||
@@ -153,7 +137,7 @@ ava_1.default("download codeql bundle from github ae endpoint", async (t) => {
|
|||||||
nock_1.default("https://example.githubenterprise.com")
|
nock_1.default("https://example.githubenterprise.com")
|
||||||
.get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/${codeQLBundleName}`)
|
.get(`/github/codeql-action/releases/download/${defaults.bundleVersion}/${codeQLBundleName}`)
|
||||||
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
|
.replyWithFile(200, path.join(__dirname, `/../src/testdata/codeql-bundle-pinned.tar.gz`));
|
||||||
await codeql.setupCodeQL(undefined, sampleGHAEApiDetails, tmpDir, tmpDir, util.GitHubVariant.GHAE, logging_1.getRunnerLogger(true));
|
await codeql.setupCodeQL(undefined, sampleGHAEApiDetails, tmpDir, tmpDir, "runner", util.GitHubVariant.GHAE, logging_1.getRunnerLogger(true));
|
||||||
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
const cachedVersions = toolcache.findAllVersions("CodeQL");
|
||||||
t.is(cachedVersions.length, 1);
|
t.is(cachedVersions.length, 1);
|
||||||
});
|
});
|
||||||
@@ -202,19 +186,4 @@ ava_1.default("getExtraOptions throws for bad content", (t) => {
|
|||||||
t.throws(() => codeql.getExtraOptions({ foo: 87 }, ["foo"], []));
|
t.throws(() => codeql.getExtraOptions({ foo: 87 }, ["foo"], []));
|
||||||
t.throws(() => codeql.getExtraOptions({ "*": [42], foo: { "*": 87, bar: [99] } }, ["foo", "bar"], []));
|
t.throws(() => codeql.getExtraOptions({ "*": [42], foo: { "*": 87, bar: [99] } }, ["foo", "bar"], []));
|
||||||
});
|
});
|
||||||
ava_1.default("getCodeQLActionRepository", (t) => {
|
|
||||||
const logger = logging_1.getRunnerLogger(true);
|
|
||||||
util_1.initializeEnvironment(util_1.Mode.runner, "1.2.3");
|
|
||||||
const repoActions = codeql.getCodeQLActionRepository(logger);
|
|
||||||
t.deepEqual(repoActions, "github/codeql-action");
|
|
||||||
util_1.initializeEnvironment(util_1.Mode.actions, "1.2.3");
|
|
||||||
// isRunningLocalAction() === true
|
|
||||||
delete process.env["GITHUB_ACTION_REPOSITORY"];
|
|
||||||
process.env["RUNNER_TEMP"] = path.dirname(__dirname);
|
|
||||||
const repoLocalRunner = codeql.getCodeQLActionRepository(logger);
|
|
||||||
t.deepEqual(repoLocalRunner, "github/codeql-action");
|
|
||||||
process.env["GITHUB_ACTION_REPOSITORY"] = "xxx/yyy";
|
|
||||||
const repoEnv = codeql.getCodeQLActionRepository(logger);
|
|
||||||
t.deepEqual(repoEnv, "xxx/yyy");
|
|
||||||
});
|
|
||||||
//# sourceMappingURL=codeql.test.js.map
|
//# sourceMappingURL=codeql.test.js.map
|
||||||
File diff suppressed because one or more lines are too long
233
lib/config-utils.js
generated
233
lib/config-utils.js
generated
@@ -1,29 +1,15 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
__setModuleDefault(result, mod);
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.getConfig = exports.getPathToParsedConfigFile = exports.initConfig = exports.parsePacks = exports.parsePacksFromConfig = exports.getDefaultConfig = exports.getUnknownLanguagesError = exports.getNoLanguagesError = exports.getConfigFileDirectoryGivenMessage = exports.getConfigFileFormatInvalidMessage = exports.getConfigFileRepoFormatInvalidMessage = exports.getConfigFileDoesNotExistErrorMessage = exports.getConfigFileOutsideWorkspaceErrorMessage = exports.getLocalPathDoesNotExist = exports.getLocalPathOutsideOfRepository = exports.getPacksStrInvalid = exports.getPacksInvalid = exports.getPacksInvalidSplit = exports.getPacksRequireLanguage = exports.getPathsInvalid = exports.getPathsIgnoreInvalid = exports.getQueryUsesInvalid = exports.getQueriesInvalid = exports.getDisableDefaultQueriesInvalid = exports.getNameInvalid = exports.validateAndSanitisePath = void 0;
|
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const yaml = __importStar(require("js-yaml"));
|
const yaml = __importStar(require("js-yaml"));
|
||||||
const semver = __importStar(require("semver"));
|
|
||||||
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");
|
||||||
@@ -34,7 +20,6 @@ const QUERIES_PROPERTY = "queries";
|
|||||||
const QUERIES_USES_PROPERTY = "uses";
|
const QUERIES_USES_PROPERTY = "uses";
|
||||||
const PATHS_IGNORE_PROPERTY = "paths-ignore";
|
const PATHS_IGNORE_PROPERTY = "paths-ignore";
|
||||||
const PATHS_PROPERTY = "paths";
|
const PATHS_PROPERTY = "paths";
|
||||||
const PACKS_PROPERTY = "packs";
|
|
||||||
/**
|
/**
|
||||||
* A list of queries from https://github.com/github/codeql that
|
* A list of queries from https://github.com/github/codeql that
|
||||||
* we don't want to run. Disabling them here is a quicker alternative to
|
* we don't want to run. Disabling them here is a quicker alternative to
|
||||||
@@ -127,10 +112,10 @@ async function addBuiltinSuiteQueries(languages, codeQL, resultMap, suiteName, c
|
|||||||
/**
|
/**
|
||||||
* Retrieve the set of queries at localQueryPath and add them to resultMap.
|
* Retrieve the set of queries at localQueryPath and add them to resultMap.
|
||||||
*/
|
*/
|
||||||
async function addLocalQueries(codeQL, resultMap, localQueryPath, workspacePath, configFile) {
|
async function addLocalQueries(codeQL, resultMap, localQueryPath, checkoutPath, configFile) {
|
||||||
// Resolve the local path against the workspace so that when this is
|
// Resolve the local path against the workspace so that when this is
|
||||||
// passed to codeql it resolves to exactly the path we expect it to resolve to.
|
// passed to codeql it resolves to exactly the path we expect it to resolve to.
|
||||||
let absoluteQueryPath = path.join(workspacePath, localQueryPath);
|
let absoluteQueryPath = path.join(checkoutPath, localQueryPath);
|
||||||
// Check the file exists
|
// Check the file exists
|
||||||
if (!fs.existsSync(absoluteQueryPath)) {
|
if (!fs.existsSync(absoluteQueryPath)) {
|
||||||
throw new Error(getLocalPathDoesNotExist(configFile, localQueryPath));
|
throw new Error(getLocalPathDoesNotExist(configFile, localQueryPath));
|
||||||
@@ -138,11 +123,10 @@ async function addLocalQueries(codeQL, resultMap, localQueryPath, workspacePath,
|
|||||||
// Call this after checking file exists, because it'll fail if file doesn't exist
|
// Call this after checking file exists, because it'll fail if file doesn't exist
|
||||||
absoluteQueryPath = fs.realpathSync(absoluteQueryPath);
|
absoluteQueryPath = fs.realpathSync(absoluteQueryPath);
|
||||||
// Check the local path doesn't jump outside the repo using '..' or symlinks
|
// Check the local path doesn't jump outside the repo using '..' or symlinks
|
||||||
if (!(absoluteQueryPath + path.sep).startsWith(fs.realpathSync(workspacePath) + path.sep)) {
|
if (!(absoluteQueryPath + path.sep).startsWith(fs.realpathSync(checkoutPath) + path.sep)) {
|
||||||
throw new Error(getLocalPathOutsideOfRepository(configFile, localQueryPath));
|
throw new Error(getLocalPathOutsideOfRepository(configFile, localQueryPath));
|
||||||
}
|
}
|
||||||
const extraSearchPath = workspacePath;
|
await runResolveQueries(codeQL, resultMap, [absoluteQueryPath], checkoutPath);
|
||||||
await runResolveQueries(codeQL, resultMap, [absoluteQueryPath], extraSearchPath);
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
@@ -180,14 +164,14 @@ 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, workspacePath, apiDetails, logger, configFile) {
|
async function parseQueryUses(languages, codeQL, resultMap, queryUses, tempDir, checkoutPath, apiDetails, logger, configFile) {
|
||||||
queryUses = queryUses.trim();
|
queryUses = queryUses.trim();
|
||||||
if (queryUses === "") {
|
if (queryUses === "") {
|
||||||
throw new Error(getQueryUsesInvalid(configFile));
|
throw new Error(getQueryUsesInvalid(configFile));
|
||||||
}
|
}
|
||||||
// Check for the local path case before we start trying to parse the repository name
|
// Check for the local path case before we start trying to parse the repository name
|
||||||
if (queryUses.startsWith("./")) {
|
if (queryUses.startsWith("./")) {
|
||||||
await addLocalQueries(codeQL, resultMap, queryUses.slice(2), workspacePath, configFile);
|
await addLocalQueries(codeQL, resultMap, queryUses.slice(2), checkoutPath, configFile);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Check for one of the builtin suites
|
// Check for one of the builtin suites
|
||||||
@@ -270,24 +254,6 @@ function getPathsInvalid(configFile) {
|
|||||||
return getConfigFilePropertyError(configFile, PATHS_PROPERTY, "must be an array of non-empty strings");
|
return getConfigFilePropertyError(configFile, PATHS_PROPERTY, "must be an array of non-empty strings");
|
||||||
}
|
}
|
||||||
exports.getPathsInvalid = getPathsInvalid;
|
exports.getPathsInvalid = getPathsInvalid;
|
||||||
function getPacksRequireLanguage(lang, configFile) {
|
|
||||||
return getConfigFilePropertyError(configFile, PACKS_PROPERTY, `has "${lang}", but it is not one of the languages to analyze`);
|
|
||||||
}
|
|
||||||
exports.getPacksRequireLanguage = getPacksRequireLanguage;
|
|
||||||
function getPacksInvalidSplit(configFile) {
|
|
||||||
return getConfigFilePropertyError(configFile, PACKS_PROPERTY, "must split packages by language");
|
|
||||||
}
|
|
||||||
exports.getPacksInvalidSplit = getPacksInvalidSplit;
|
|
||||||
function getPacksInvalid(configFile) {
|
|
||||||
return getConfigFilePropertyError(configFile, PACKS_PROPERTY, "must be an array of non-empty strings");
|
|
||||||
}
|
|
||||||
exports.getPacksInvalid = getPacksInvalid;
|
|
||||||
function getPacksStrInvalid(packStr, configFile) {
|
|
||||||
return configFile
|
|
||||||
? getConfigFilePropertyError(configFile, PACKS_PROPERTY, `"${packStr}" is not a valid pack`)
|
|
||||||
: `"${packStr}" is not a valid pack`;
|
|
||||||
}
|
|
||||||
exports.getPacksStrInvalid = getPacksStrInvalid;
|
|
||||||
function getLocalPathOutsideOfRepository(configFile, localPath) {
|
function getLocalPathOutsideOfRepository(configFile, localPath) {
|
||||||
return getConfigFilePropertyError(configFile, `${QUERIES_PROPERTY}.${QUERIES_USES_PROPERTY}`, `is invalid as the local path "${localPath}" is outside of the repository`);
|
return getConfigFilePropertyError(configFile, `${QUERIES_PROPERTY}.${QUERIES_USES_PROPERTY}`, `is invalid as the local path "${localPath}" is outside of the repository`);
|
||||||
}
|
}
|
||||||
@@ -340,7 +306,9 @@ exports.getUnknownLanguagesError = getUnknownLanguagesError;
|
|||||||
*/
|
*/
|
||||||
async function getLanguagesInRepo(repository, apiDetails, logger) {
|
async function getLanguagesInRepo(repository, apiDetails, logger) {
|
||||||
logger.debug(`GitHub repo ${repository.owner} ${repository.repo}`);
|
logger.debug(`GitHub repo ${repository.owner} ${repository.repo}`);
|
||||||
const response = await api.getApiClient(apiDetails).repos.listLanguages({
|
const response = await api
|
||||||
|
.getApiClient(apiDetails, { allowLocalRun: true })
|
||||||
|
.repos.listLanguages({
|
||||||
owner: repository.owner,
|
owner: repository.owner,
|
||||||
repo: repository.repo,
|
repo: repository.repo,
|
||||||
});
|
});
|
||||||
@@ -368,7 +336,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(codeQL, languagesInput, repository, apiDetails, logger) {
|
async function getLanguages(languagesInput, repository, apiDetails, logger) {
|
||||||
// Obtain from action input 'languages' if set
|
// Obtain from action input 'languages' if set
|
||||||
let languages = (languagesInput || "")
|
let languages = (languagesInput || "")
|
||||||
.split(",")
|
.split(",")
|
||||||
@@ -378,8 +346,6 @@ async function getLanguages(codeQL, languagesInput, repository, apiDetails, logg
|
|||||||
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, apiDetails, logger);
|
||||||
const availableLanguages = await codeQL.resolveLanguages();
|
|
||||||
languages = languages.filter((value) => value in availableLanguages);
|
|
||||||
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
|
||||||
@@ -404,12 +370,12 @@ async function getLanguages(codeQL, languagesInput, repository, apiDetails, logg
|
|||||||
}
|
}
|
||||||
return parsedLanguages;
|
return parsedLanguages;
|
||||||
}
|
}
|
||||||
async function addQueriesFromWorkflow(codeQL, queriesInput, languages, resultMap, tempDir, workspacePath, apiDetails, logger) {
|
async function addQueriesFromWorkflow(codeQL, queriesInput, languages, resultMap, tempDir, checkoutPath, apiDetails, 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, workspacePath, apiDetails, logger);
|
await parseQueryUses(languages, codeQL, resultMap, query, tempDir, checkoutPath, apiDetails, logger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Returns true if either no queries were provided in the workflow.
|
// Returns true if either no queries were provided in the workflow.
|
||||||
@@ -425,9 +391,8 @@ function shouldAddConfigFileQueries(queriesInput) {
|
|||||||
/**
|
/**
|
||||||
* Get the default config for when the user has not supplied one.
|
* Get the default config for when the user has not supplied one.
|
||||||
*/
|
*/
|
||||||
async function getDefaultConfig(languagesInput, queriesInput, packsInput, dbLocation, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, logger) {
|
async function getDefaultConfig(languagesInput, queriesInput, dbLocation, repository, tempDir, toolCacheDir, codeQL, checkoutPath, gitHubVersion, apiDetails, logger) {
|
||||||
var _a;
|
const languages = await getLanguages(languagesInput, repository, apiDetails, logger);
|
||||||
const languages = await getLanguages(codeQL, languagesInput, repository, apiDetails, logger);
|
|
||||||
const queries = {};
|
const queries = {};
|
||||||
for (const language of languages) {
|
for (const language of languages) {
|
||||||
queries[language] = {
|
queries[language] = {
|
||||||
@@ -437,15 +402,13 @@ async function getDefaultConfig(languagesInput, queriesInput, packsInput, dbLoca
|
|||||||
}
|
}
|
||||||
await addDefaultQueries(codeQL, languages, queries);
|
await addDefaultQueries(codeQL, languages, queries);
|
||||||
if (queriesInput) {
|
if (queriesInput) {
|
||||||
await addQueriesFromWorkflow(codeQL, queriesInput, languages, queries, tempDir, workspacePath, apiDetails, logger);
|
await addQueriesFromWorkflow(codeQL, queriesInput, languages, queries, tempDir, checkoutPath, apiDetails, logger);
|
||||||
}
|
}
|
||||||
const packs = (_a = parsePacksFromInput(packsInput, languages)) !== null && _a !== void 0 ? _a : {};
|
|
||||||
return {
|
return {
|
||||||
languages,
|
languages,
|
||||||
queries,
|
queries,
|
||||||
pathsIgnore: [],
|
pathsIgnore: [],
|
||||||
paths: [],
|
paths: [],
|
||||||
packs,
|
|
||||||
originalUserInput: {},
|
originalUserInput: {},
|
||||||
tempDir,
|
tempDir,
|
||||||
toolCacheDir,
|
toolCacheDir,
|
||||||
@@ -458,13 +421,12 @@ exports.getDefaultConfig = getDefaultConfig;
|
|||||||
/**
|
/**
|
||||||
* Load the config from the given file.
|
* Load the config from the given file.
|
||||||
*/
|
*/
|
||||||
async function loadConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, logger) {
|
async function loadConfig(languagesInput, queriesInput, configFile, dbLocation, repository, tempDir, toolCacheDir, codeQL, checkoutPath, gitHubVersion, apiDetails, logger) {
|
||||||
var _a;
|
|
||||||
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
|
||||||
configFile = path.resolve(workspacePath, configFile);
|
configFile = path.resolve(checkoutPath, configFile);
|
||||||
parsedYAML = getLocalConfig(configFile, workspacePath);
|
parsedYAML = getLocalConfig(configFile, checkoutPath);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
parsedYAML = await getRemoteConfig(configFile, apiDetails);
|
parsedYAML = await getRemoteConfig(configFile, apiDetails);
|
||||||
@@ -479,7 +441,7 @@ async function loadConfig(languagesInput, queriesInput, packsInput, configFile,
|
|||||||
throw new Error(getNameInvalid(configFile));
|
throw new Error(getNameInvalid(configFile));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const languages = await getLanguages(codeQL, languagesInput, repository, apiDetails, logger);
|
const languages = await getLanguages(languagesInput, repository, apiDetails, logger);
|
||||||
const queries = {};
|
const queries = {};
|
||||||
for (const language of languages) {
|
for (const language of languages) {
|
||||||
queries[language] = {
|
queries[language] = {
|
||||||
@@ -504,24 +466,23 @@ async function loadConfig(languagesInput, queriesInput, packsInput, configFile,
|
|||||||
// 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, workspacePath, apiDetails, logger);
|
await addQueriesFromWorkflow(codeQL, queriesInput, languages, queries, tempDir, checkoutPath, apiDetails, logger);
|
||||||
}
|
}
|
||||||
if (shouldAddConfigFileQueries(queriesInput) &&
|
if (shouldAddConfigFileQueries(queriesInput) &&
|
||||||
QUERIES_PROPERTY in parsedYAML) {
|
QUERIES_PROPERTY in parsedYAML) {
|
||||||
const queriesArr = parsedYAML[QUERIES_PROPERTY];
|
if (!(parsedYAML[QUERIES_PROPERTY] instanceof Array)) {
|
||||||
if (!Array.isArray(queriesArr)) {
|
|
||||||
throw new Error(getQueriesInvalid(configFile));
|
throw new Error(getQueriesInvalid(configFile));
|
||||||
}
|
}
|
||||||
for (const query of queriesArr) {
|
for (const query of parsedYAML[QUERIES_PROPERTY]) {
|
||||||
if (!(QUERIES_USES_PROPERTY in query) ||
|
if (!(QUERIES_USES_PROPERTY in query) ||
|
||||||
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, workspacePath, apiDetails, logger, configFile);
|
await parseQueryUses(languages, codeQL, queries, query[QUERIES_USES_PROPERTY], tempDir, checkoutPath, apiDetails, logger, configFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (PATHS_IGNORE_PROPERTY in parsedYAML) {
|
if (PATHS_IGNORE_PROPERTY in parsedYAML) {
|
||||||
if (!Array.isArray(parsedYAML[PATHS_IGNORE_PROPERTY])) {
|
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 ignorePath of parsedYAML[PATHS_IGNORE_PROPERTY]) {
|
||||||
@@ -532,7 +493,7 @@ async function loadConfig(languagesInput, queriesInput, packsInput, configFile,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (PATHS_PROPERTY in parsedYAML) {
|
if (PATHS_PROPERTY in parsedYAML) {
|
||||||
if (!Array.isArray(parsedYAML[PATHS_PROPERTY])) {
|
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 includePath of parsedYAML[PATHS_PROPERTY]) {
|
||||||
@@ -542,13 +503,11 @@ async function loadConfig(languagesInput, queriesInput, packsInput, configFile,
|
|||||||
paths.push(validateAndSanitisePath(includePath, PATHS_PROPERTY, configFile, logger));
|
paths.push(validateAndSanitisePath(includePath, PATHS_PROPERTY, configFile, logger));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const packs = parsePacks((_a = parsedYAML[PACKS_PROPERTY]) !== null && _a !== void 0 ? _a : {}, packsInput, languages, configFile);
|
|
||||||
return {
|
return {
|
||||||
languages,
|
languages,
|
||||||
queries,
|
queries,
|
||||||
pathsIgnore,
|
pathsIgnore,
|
||||||
paths,
|
paths,
|
||||||
packs,
|
|
||||||
originalUserInput: parsedYAML,
|
originalUserInput: parsedYAML,
|
||||||
tempDir,
|
tempDir,
|
||||||
toolCacheDir,
|
toolCacheDir,
|
||||||
@@ -557,120 +516,6 @@ async function loadConfig(languagesInput, queriesInput, packsInput, configFile,
|
|||||||
dbLocation: dbLocationOrDefault(dbLocation, tempDir),
|
dbLocation: dbLocationOrDefault(dbLocation, tempDir),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Pack names must be in the form of `scope/name`, with only alpha-numeric characters,
|
|
||||||
* and `-` allowed as long as not the first or last char.
|
|
||||||
**/
|
|
||||||
const PACK_IDENTIFIER_PATTERN = (function () {
|
|
||||||
const alphaNumeric = "[a-z0-9]";
|
|
||||||
const alphaNumericDash = "[a-z0-9-]";
|
|
||||||
const component = `${alphaNumeric}(${alphaNumericDash}*${alphaNumeric})?`;
|
|
||||||
return new RegExp(`^${component}/${component}$`);
|
|
||||||
})();
|
|
||||||
// Exported for testing
|
|
||||||
function parsePacksFromConfig(packsByLanguage, languages, configFile) {
|
|
||||||
const packs = {};
|
|
||||||
if (Array.isArray(packsByLanguage)) {
|
|
||||||
if (languages.length === 1) {
|
|
||||||
// single language analysis, so language is implicit
|
|
||||||
packsByLanguage = {
|
|
||||||
[languages[0]]: packsByLanguage,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// this is an error since multi-language analysis requires
|
|
||||||
// packs split by language
|
|
||||||
throw new Error(getPacksInvalidSplit(configFile));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (const [lang, packsArr] of Object.entries(packsByLanguage)) {
|
|
||||||
if (!Array.isArray(packsArr)) {
|
|
||||||
throw new Error(getPacksInvalid(configFile));
|
|
||||||
}
|
|
||||||
if (!languages.includes(lang)) {
|
|
||||||
throw new Error(getPacksRequireLanguage(lang, configFile));
|
|
||||||
}
|
|
||||||
packs[lang] = [];
|
|
||||||
for (const packStr of packsArr) {
|
|
||||||
packs[lang].push(toPackWithVersion(packStr, configFile));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return packs;
|
|
||||||
}
|
|
||||||
exports.parsePacksFromConfig = parsePacksFromConfig;
|
|
||||||
function parsePacksFromInput(packsInput, languages) {
|
|
||||||
if (!(packsInput === null || packsInput === void 0 ? void 0 : packsInput.trim())) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
if (languages.length > 1) {
|
|
||||||
throw new Error("Cannot specify a 'packs' input in a multi-language analysis. Use a codeql-config.yml file instead and specify packs by language.");
|
|
||||||
}
|
|
||||||
else if (languages.length === 0) {
|
|
||||||
throw new Error("No languages specified. Cannot process the packs input.");
|
|
||||||
}
|
|
||||||
packsInput = packsInput.trim();
|
|
||||||
if (packsInput.startsWith("+")) {
|
|
||||||
packsInput = packsInput.substring(1).trim();
|
|
||||||
if (!packsInput) {
|
|
||||||
throw new Error("A '+' was used in the 'packs' input to specify that you wished to add some packs to your CodeQL analysis. However, no packs were specified. Please either remove the '+' or specify some packs.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
[languages[0]]: packsInput.split(",").reduce((packs, pack) => {
|
|
||||||
packs.push(toPackWithVersion(pack, ""));
|
|
||||||
return packs;
|
|
||||||
}, []),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
function toPackWithVersion(packStr, configFile) {
|
|
||||||
if (typeof packStr !== "string") {
|
|
||||||
throw new Error(getPacksStrInvalid(packStr, configFile));
|
|
||||||
}
|
|
||||||
const nameWithVersion = packStr.trim().split("@");
|
|
||||||
let version;
|
|
||||||
if (nameWithVersion.length > 2 ||
|
|
||||||
!PACK_IDENTIFIER_PATTERN.test(nameWithVersion[0])) {
|
|
||||||
throw new Error(getPacksStrInvalid(packStr, configFile));
|
|
||||||
}
|
|
||||||
else if (nameWithVersion.length === 2) {
|
|
||||||
version = semver.clean(nameWithVersion[1]) || undefined;
|
|
||||||
if (!version) {
|
|
||||||
throw new Error(getPacksStrInvalid(packStr, configFile));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
packName: nameWithVersion[0].trim(),
|
|
||||||
version,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
// exported for testing
|
|
||||||
function parsePacks(rawPacksFromConfig, rawPacksInput, languages, configFile) {
|
|
||||||
const packsFromInput = parsePacksFromInput(rawPacksInput, languages);
|
|
||||||
const packsFomConfig = parsePacksFromConfig(rawPacksFromConfig, languages, configFile);
|
|
||||||
if (!packsFromInput) {
|
|
||||||
return packsFomConfig;
|
|
||||||
}
|
|
||||||
if (!shouldCombinePacks(rawPacksInput)) {
|
|
||||||
return packsFromInput;
|
|
||||||
}
|
|
||||||
return combinePacks(packsFromInput, packsFomConfig);
|
|
||||||
}
|
|
||||||
exports.parsePacks = parsePacks;
|
|
||||||
function shouldCombinePacks(packsInput) {
|
|
||||||
return !!(packsInput === null || packsInput === void 0 ? void 0 : packsInput.trim().startsWith("+"));
|
|
||||||
}
|
|
||||||
function combinePacks(packs1, packs2) {
|
|
||||||
const packs = {};
|
|
||||||
for (const lang of Object.keys(packs1)) {
|
|
||||||
packs[lang] = packs1[lang].concat(packs2[lang] || []);
|
|
||||||
}
|
|
||||||
for (const lang of Object.keys(packs2)) {
|
|
||||||
if (!packs[lang]) {
|
|
||||||
packs[lang] = packs2[lang];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return packs;
|
|
||||||
}
|
|
||||||
function dbLocationOrDefault(dbLocation, tempDir) {
|
function dbLocationOrDefault(dbLocation, tempDir) {
|
||||||
return dbLocation || path.resolve(tempDir, "codeql_databases");
|
return dbLocation || path.resolve(tempDir, "codeql_databases");
|
||||||
}
|
}
|
||||||
@@ -680,24 +525,22 @@ function dbLocationOrDefault(dbLocation, tempDir) {
|
|||||||
* This will parse the config from the user input if present, or generate
|
* This will parse the config from the user input if present, or generate
|
||||||
* a default config. The parsed config is then stored to a known location.
|
* a default config. The parsed config is then stored to a known location.
|
||||||
*/
|
*/
|
||||||
async function initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, logger) {
|
async function initConfig(languagesInput, queriesInput, configFile, dbLocation, repository, tempDir, toolCacheDir, codeQL, checkoutPath, gitHubVersion, apiDetails, logger) {
|
||||||
var _a, _b, _c;
|
|
||||||
let config;
|
let config;
|
||||||
// If no config file was provided create an empty one
|
// If no config file was provided create an empty one
|
||||||
if (!configFile) {
|
if (!configFile) {
|
||||||
logger.debug("No configuration file was provided");
|
logger.debug("No configuration file was provided");
|
||||||
config = await getDefaultConfig(languagesInput, queriesInput, packsInput, dbLocation, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, logger);
|
config = await getDefaultConfig(languagesInput, queriesInput, dbLocation, repository, tempDir, toolCacheDir, codeQL, checkoutPath, gitHubVersion, apiDetails, logger);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
config = await loadConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, logger);
|
config = await loadConfig(languagesInput, queriesInput, configFile, dbLocation, repository, tempDir, toolCacheDir, codeQL, checkoutPath, gitHubVersion, apiDetails, logger);
|
||||||
}
|
}
|
||||||
// The list of queries should not be empty for any language. If it is then
|
// The list of queries should not be empty for any language. If it is then
|
||||||
// it is a user configuration error.
|
// it is a user configuration error.
|
||||||
for (const language of config.languages) {
|
for (const language of config.languages) {
|
||||||
const hasBuiltinQueries = ((_a = config.queries[language]) === null || _a === void 0 ? void 0 : _a.builtin.length) > 0;
|
if (config.queries[language] === undefined ||
|
||||||
const hasCustomQueries = ((_b = config.queries[language]) === null || _b === void 0 ? void 0 : _b.custom.length) > 0;
|
(config.queries[language].builtin.length === 0 &&
|
||||||
const hasPacks = (((_c = config.packs[language]) === null || _c === void 0 ? void 0 : _c.length) || 0) > 0;
|
config.queries[language].custom.length === 0)) {
|
||||||
if (!hasPacks && !hasBuiltinQueries && !hasCustomQueries) {
|
|
||||||
throw new Error(`Did not detect any queries to run for ${language}. ` +
|
throw new Error(`Did not detect any queries to run for ${language}. ` +
|
||||||
"Please make sure that the default queries are enabled, or you are specifying queries to run.");
|
"Please make sure that the default queries are enabled, or you are specifying queries to run.");
|
||||||
}
|
}
|
||||||
@@ -714,16 +557,16 @@ function isLocal(configPath) {
|
|||||||
}
|
}
|
||||||
return configPath.indexOf("@") === -1;
|
return configPath.indexOf("@") === -1;
|
||||||
}
|
}
|
||||||
function getLocalConfig(configFile, workspacePath) {
|
function getLocalConfig(configFile, checkoutPath) {
|
||||||
// Error if the config file is now outside of the workspace
|
// Error if the config file is now outside of the workspace
|
||||||
if (!(configFile + path.sep).startsWith(workspacePath + path.sep)) {
|
if (!(configFile + path.sep).startsWith(checkoutPath + path.sep)) {
|
||||||
throw new Error(getConfigFileOutsideWorkspaceErrorMessage(configFile));
|
throw new Error(getConfigFileOutsideWorkspaceErrorMessage(configFile));
|
||||||
}
|
}
|
||||||
// Error if the file does not exist
|
// Error if the file does not exist
|
||||||
if (!fs.existsSync(configFile)) {
|
if (!fs.existsSync(configFile)) {
|
||||||
throw new Error(getConfigFileDoesNotExistErrorMessage(configFile));
|
throw new Error(getConfigFileDoesNotExistErrorMessage(configFile));
|
||||||
}
|
}
|
||||||
return yaml.load(fs.readFileSync(configFile, "utf8"));
|
return yaml.safeLoad(fs.readFileSync(configFile, "utf8"));
|
||||||
}
|
}
|
||||||
async function getRemoteConfig(configFile, apiDetails) {
|
async function getRemoteConfig(configFile, apiDetails) {
|
||||||
// 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
|
||||||
@@ -734,7 +577,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, { allowExternal: true })
|
.getApiClient(apiDetails, { allowLocalRun: true, allowExternal: true })
|
||||||
.repos.getContent({
|
.repos.getContent({
|
||||||
owner: pieces.groups.owner,
|
owner: pieces.groups.owner,
|
||||||
repo: pieces.groups.repo,
|
repo: pieces.groups.repo,
|
||||||
@@ -751,7 +594,7 @@ async function getRemoteConfig(configFile, apiDetails) {
|
|||||||
else {
|
else {
|
||||||
throw new Error(getConfigFileFormatInvalidMessage(configFile));
|
throw new Error(getConfigFileFormatInvalidMessage(configFile));
|
||||||
}
|
}
|
||||||
return yaml.load(Buffer.from(fileContents, "base64").toString("binary"));
|
return yaml.safeLoad(Buffer.from(fileContents, "base64").toString("binary"));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Get the file path where the parsed config will be stored.
|
* Get the file path where the parsed config will be stored.
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
277
lib/config-utils.test.js
generated
277
lib/config-utils.test.js
generated
@@ -1,21 +1,9 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
__setModuleDefault(result, mod);
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
@@ -26,7 +14,6 @@ const fs = __importStar(require("fs"));
|
|||||||
const path = __importStar(require("path"));
|
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 semver_1 = require("semver");
|
|
||||||
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");
|
||||||
@@ -88,8 +75,8 @@ ava_1.default("load empty config", async (t) => {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const config = await configUtils.initConfig(languages, undefined, undefined, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logger);
|
const config = await configUtils.initConfig(languages, undefined, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logger);
|
||||||
t.deepEqual(config, await configUtils.getDefaultConfig(languages, undefined, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logger));
|
t.deepEqual(config, await configUtils.getDefaultConfig(languages, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logger));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("loading config saves config", async (t) => {
|
ava_1.default("loading config saves config", async (t) => {
|
||||||
@@ -111,7 +98,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, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logger);
|
const config1 = await configUtils.initConfig("javascript,python", undefined, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logger);
|
||||||
// The saved config file should now exist
|
// The saved config file should now exist
|
||||||
t.true(fs.existsSync(configUtils.getPathToParsedConfigFile(tmpDir)));
|
t.true(fs.existsSync(configUtils.getPathToParsedConfigFile(tmpDir)));
|
||||||
// And that same newly-initialised config should now be returned by getConfig
|
// And that same newly-initialised config should now be returned by getConfig
|
||||||
@@ -122,7 +109,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, undefined, "../input", undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(undefined, undefined, "../input", undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -135,7 +122,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, undefined, configFile, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(undefined, undefined, configFile, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -149,7 +136,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, undefined, configFile, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(languages, undefined, configFile, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -213,11 +200,10 @@ ava_1.default("load non-empty input", async (t) => {
|
|||||||
codeQLCmd: codeQL.getPath(),
|
codeQLCmd: codeQL.getPath(),
|
||||||
gitHubVersion,
|
gitHubVersion,
|
||||||
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
||||||
packs: {},
|
|
||||||
};
|
};
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const configFilePath = createConfigFile(inputFileContents, tmpDir);
|
const configFilePath = createConfigFile(inputFileContents, tmpDir);
|
||||||
const actualConfig = await configUtils.initConfig(languages, undefined, undefined, configFilePath, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
const actualConfig = await configUtils.initConfig(languages, undefined, configFilePath, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, 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);
|
||||||
});
|
});
|
||||||
@@ -253,7 +239,7 @@ ava_1.default("Default queries are used", async (t) => {
|
|||||||
fs.mkdirSync(path.join(tmpDir, "foo"));
|
fs.mkdirSync(path.join(tmpDir, "foo"));
|
||||||
const languages = "javascript";
|
const languages = "javascript";
|
||||||
const configFilePath = createConfigFile(inputFileContents, tmpDir);
|
const configFilePath = createConfigFile(inputFileContents, tmpDir);
|
||||||
await configUtils.initConfig(languages, undefined, undefined, configFilePath, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(languages, undefined, configFilePath, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, 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, [
|
||||||
@@ -296,7 +282,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, undefined, configFilePath, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
const config = await configUtils.initConfig(languages, undefined, configFilePath, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, 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.
|
||||||
@@ -329,7 +315,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, undefined, configFilePath, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
const config = await configUtils.initConfig(languages, testQueries, configFilePath, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, 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.
|
||||||
@@ -361,7 +347,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, undefined, configFilePath, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
const config = await configUtils.initConfig(languages, testQueries, configFilePath, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, 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
|
||||||
@@ -387,7 +373,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, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
const config = await configUtils.initConfig(languages, testQueries, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, 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
|
||||||
@@ -426,7 +412,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, undefined, configFilePath, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
const config = await configUtils.initConfig(languages, testQueries, configFilePath, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, 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,
|
||||||
@@ -465,7 +451,7 @@ ava_1.default("Invalid queries in workflow file handled correctly", async (t) =>
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(languages, queries, undefined, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(languages, queries, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
||||||
t.fail("initConfig did not throw error");
|
t.fail("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -508,7 +494,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, undefined, configFile, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(languages, undefined, configFile, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
||||||
t.assert(spyGetContents.called);
|
t.assert(spyGetContents.called);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -518,7 +504,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, undefined, repoReference, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(undefined, undefined, repoReference, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -534,7 +520,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, undefined, repoReference, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(undefined, undefined, repoReference, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -545,13 +531,8 @@ ava_1.default("Invalid format of remote config handled correctly", async (t) =>
|
|||||||
ava_1.default("No detected languages", async (t) => {
|
ava_1.default("No detected languages", async (t) => {
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
mockListLanguages([]);
|
mockListLanguages([]);
|
||||||
const codeQL = codeql_1.setCodeQL({
|
|
||||||
async resolveLanguages() {
|
|
||||||
return {};
|
|
||||||
},
|
|
||||||
});
|
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(undefined, undefined, undefined, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(undefined, undefined, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -561,111 +542,16 @@ ava_1.default("No detected languages", async (t) => {
|
|||||||
});
|
});
|
||||||
ava_1.default("Unknown languages", async (t) => {
|
ava_1.default("Unknown languages", async (t) => {
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
const languages = "rubbish,english";
|
const languages = "ruby,english";
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(languages, undefined, undefined, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(languages, undefined, undefined, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeql_1.getCachedCodeQL(), tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
t.deepEqual(err, new Error(configUtils.getUnknownLanguagesError(["rubbish", "english"])));
|
t.deepEqual(err, new Error(configUtils.getUnknownLanguagesError(["ruby", "english"])));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("Config specifies packages", async (t) => {
|
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
|
||||||
const codeQL = codeql_1.setCodeQL({
|
|
||||||
async resolveQueries() {
|
|
||||||
return {
|
|
||||||
byLanguage: {},
|
|
||||||
noDeclaredLanguage: {},
|
|
||||||
multipleDeclaredLanguages: {},
|
|
||||||
};
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const inputFileContents = `
|
|
||||||
name: my config
|
|
||||||
disable-default-queries: true
|
|
||||||
packs:
|
|
||||||
- a/b@1.2.3
|
|
||||||
`;
|
|
||||||
const configFile = path.join(tmpDir, "codeql-config.yaml");
|
|
||||||
fs.writeFileSync(configFile, inputFileContents);
|
|
||||||
const languages = "javascript";
|
|
||||||
const { packs } = await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
|
||||||
t.deepEqual(packs, {
|
|
||||||
[languages_1.Language.javascript]: [
|
|
||||||
{
|
|
||||||
packName: "a/b",
|
|
||||||
version: semver_1.clean("1.2.3"),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
ava_1.default("Config specifies packages for multiple languages", async (t) => {
|
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
|
||||||
const codeQL = codeql_1.setCodeQL({
|
|
||||||
async resolveQueries() {
|
|
||||||
return {
|
|
||||||
byLanguage: {
|
|
||||||
cpp: { "/foo/a.ql": {} },
|
|
||||||
},
|
|
||||||
noDeclaredLanguage: {},
|
|
||||||
multipleDeclaredLanguages: {},
|
|
||||||
};
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const inputFileContents = `
|
|
||||||
name: my config
|
|
||||||
disable-default-queries: true
|
|
||||||
queries:
|
|
||||||
- uses: ./foo
|
|
||||||
packs:
|
|
||||||
javascript:
|
|
||||||
- a/b@1.2.3
|
|
||||||
python:
|
|
||||||
- c/d@1.2.3
|
|
||||||
`;
|
|
||||||
const configFile = path.join(tmpDir, "codeql-config.yaml");
|
|
||||||
fs.writeFileSync(configFile, inputFileContents);
|
|
||||||
fs.mkdirSync(path.join(tmpDir, "foo"));
|
|
||||||
const languages = "javascript,python,cpp";
|
|
||||||
const { packs, queries } = await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, { owner: "github", repo: "example" }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
|
||||||
t.deepEqual(packs, {
|
|
||||||
[languages_1.Language.javascript]: [
|
|
||||||
{
|
|
||||||
packName: "a/b",
|
|
||||||
version: semver_1.clean("1.2.3"),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
[languages_1.Language.python]: [
|
|
||||||
{
|
|
||||||
packName: "c/d",
|
|
||||||
version: semver_1.clean("1.2.3"),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
t.deepEqual(queries, {
|
|
||||||
cpp: {
|
|
||||||
builtin: [],
|
|
||||||
custom: [
|
|
||||||
{
|
|
||||||
queries: ["/foo/a.ql"],
|
|
||||||
searchPath: tmpDir,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
javascript: {
|
|
||||||
builtin: [],
|
|
||||||
custom: [],
|
|
||||||
},
|
|
||||||
python: {
|
|
||||||
builtin: [],
|
|
||||||
custom: [],
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
function doInvalidInputTest(testName, inputFileContents, expectedErrorMessageGenerator) {
|
function doInvalidInputTest(testName, inputFileContents, expectedErrorMessageGenerator) {
|
||||||
ava_1.default(`load invalid input - ${testName}`, async (t) => {
|
ava_1.default(`load invalid input - ${testName}`, async (t) => {
|
||||||
return await util.withTmpDir(async (tmpDir) => {
|
return await util.withTmpDir(async (tmpDir) => {
|
||||||
@@ -683,7 +569,7 @@ function doInvalidInputTest(testName, inputFileContents, expectedErrorMessageGen
|
|||||||
const inputFile = path.join(tmpDir, configFile);
|
const inputFile = path.join(tmpDir, configFile);
|
||||||
fs.writeFileSync(inputFile, inputFileContents, "utf8");
|
fs.writeFileSync(inputFile, inputFileContents, "utf8");
|
||||||
try {
|
try {
|
||||||
await configUtils.initConfig(languages, undefined, undefined, configFile, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
await configUtils.initConfig(languages, undefined, configFile, undefined, { owner: "github", repo: "example " }, tmpDir, tmpDir, codeQL, tmpDir, gitHubVersion, sampleApiDetails, logging_1.getRunnerLogger(true));
|
||||||
throw new Error("initConfig did not throw error");
|
throw new Error("initConfig did not throw error");
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
@@ -753,119 +639,4 @@ ava_1.default("path sanitisation", (t) => {
|
|||||||
// Trailing stars are stripped
|
// Trailing stars are stripped
|
||||||
t.deepEqual(configUtils.validateAndSanitisePath("foo/**", propertyName, configFile, logging_1.getRunnerLogger(true)), "foo/");
|
t.deepEqual(configUtils.validateAndSanitisePath("foo/**", propertyName, configFile, logging_1.getRunnerLogger(true)), "foo/");
|
||||||
});
|
});
|
||||||
/**
|
|
||||||
* Test macro for ensuring the packs block is valid
|
|
||||||
*/
|
|
||||||
function parsePacksMacro(t, packsByLanguage, languages, expected) {
|
|
||||||
t.deepEqual(configUtils.parsePacksFromConfig(packsByLanguage, languages, "/a/b"), expected);
|
|
||||||
}
|
|
||||||
parsePacksMacro.title = (providedTitle) => `Parse Packs: ${providedTitle}`;
|
|
||||||
/**
|
|
||||||
* Test macro for testing when the packs block is invalid
|
|
||||||
*/
|
|
||||||
function parsePacksErrorMacro(t, packsByLanguage, languages, expected) {
|
|
||||||
t.throws(() => {
|
|
||||||
configUtils.parsePacksFromConfig(packsByLanguage, languages, "/a/b");
|
|
||||||
}, {
|
|
||||||
message: expected,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
parsePacksErrorMacro.title = (providedTitle) => `Parse Packs Error: ${providedTitle}`;
|
|
||||||
/**
|
|
||||||
* Test macro for testing when the packs block is invalid
|
|
||||||
*/
|
|
||||||
function invalidPackNameMacro(t, name) {
|
|
||||||
parsePacksErrorMacro(t, { [languages_1.Language.cpp]: [name] }, [languages_1.Language.cpp], new RegExp(`The configuration file "/a/b" is invalid: property "packs" "${name}" is not a valid pack`));
|
|
||||||
}
|
|
||||||
invalidPackNameMacro.title = (_, arg) => `Invalid pack string: ${arg}`;
|
|
||||||
ava_1.default("no packs", parsePacksMacro, {}, [], {});
|
|
||||||
ava_1.default("two packs", parsePacksMacro, ["a/b", "c/d@1.2.3"], [languages_1.Language.cpp], {
|
|
||||||
[languages_1.Language.cpp]: [
|
|
||||||
{ packName: "a/b", version: undefined },
|
|
||||||
{ packName: "c/d", version: semver_1.clean("1.2.3") },
|
|
||||||
],
|
|
||||||
});
|
|
||||||
ava_1.default("two packs with spaces", parsePacksMacro, [" a/b ", " c/d@1.2.3 "], [languages_1.Language.cpp], {
|
|
||||||
[languages_1.Language.cpp]: [
|
|
||||||
{ packName: "a/b", version: undefined },
|
|
||||||
{ packName: "c/d", version: semver_1.clean("1.2.3") },
|
|
||||||
],
|
|
||||||
});
|
|
||||||
ava_1.default("two packs with language", parsePacksMacro, {
|
|
||||||
[languages_1.Language.cpp]: ["a/b", "c/d@1.2.3"],
|
|
||||||
[languages_1.Language.java]: ["d/e", "f/g@1.2.3"],
|
|
||||||
}, [languages_1.Language.cpp, languages_1.Language.java, languages_1.Language.csharp], {
|
|
||||||
[languages_1.Language.cpp]: [
|
|
||||||
{ packName: "a/b", version: undefined },
|
|
||||||
{ packName: "c/d", version: semver_1.clean("1.2.3") },
|
|
||||||
],
|
|
||||||
[languages_1.Language.java]: [
|
|
||||||
{ packName: "d/e", version: undefined },
|
|
||||||
{ packName: "f/g", version: semver_1.clean("1.2.3") },
|
|
||||||
],
|
|
||||||
});
|
|
||||||
ava_1.default("no language", parsePacksErrorMacro, ["a/b@1.2.3"], [languages_1.Language.java, languages_1.Language.python], /The configuration file "\/a\/b" is invalid: property "packs" must split packages by language/);
|
|
||||||
ava_1.default("invalid language", parsePacksErrorMacro, { [languages_1.Language.java]: ["c/d"] }, [languages_1.Language.cpp], /The configuration file "\/a\/b" is invalid: property "packs" has "java", but it is not one of the languages to analyze/);
|
|
||||||
ava_1.default("not an array", parsePacksErrorMacro, { [languages_1.Language.cpp]: "c/d" }, [languages_1.Language.cpp], /The configuration file "\/a\/b" is invalid: property "packs" must be an array of non-empty strings/);
|
|
||||||
ava_1.default(invalidPackNameMacro, "c"); // all packs require at least a scope and a name
|
|
||||||
ava_1.default(invalidPackNameMacro, "c-/d");
|
|
||||||
ava_1.default(invalidPackNameMacro, "-c/d");
|
|
||||||
ava_1.default(invalidPackNameMacro, "c/d_d");
|
|
||||||
ava_1.default(invalidPackNameMacro, "c/d@x");
|
|
||||||
/**
|
|
||||||
* Test macro for testing the packs block and the packs input
|
|
||||||
*/
|
|
||||||
function parseInputAndConfigMacro(t, packsFromConfig, packsFromInput, languages, expected) {
|
|
||||||
t.deepEqual(configUtils.parsePacks(packsFromConfig, packsFromInput, languages, "/a/b"), expected);
|
|
||||||
}
|
|
||||||
parseInputAndConfigMacro.title = (providedTitle) => `Parse Packs input and config: ${providedTitle}`;
|
|
||||||
function parseInputAndConfigErrorMacro(t, packsFromConfig, packsFromInput, languages, expected) {
|
|
||||||
t.throws(() => {
|
|
||||||
configUtils.parsePacks(packsFromConfig, packsFromInput, languages, "/a/b");
|
|
||||||
}, {
|
|
||||||
message: expected,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
parseInputAndConfigErrorMacro.title = (providedTitle) => `Parse Packs input and config Error: ${providedTitle}`;
|
|
||||||
ava_1.default("input only", parseInputAndConfigMacro, {}, " c/d ", [languages_1.Language.cpp], {
|
|
||||||
[languages_1.Language.cpp]: [{ packName: "c/d", version: undefined }],
|
|
||||||
});
|
|
||||||
ava_1.default("input only with multiple", parseInputAndConfigMacro, {}, "a/b , c/d@1.2.3", [languages_1.Language.cpp], {
|
|
||||||
[languages_1.Language.cpp]: [
|
|
||||||
{ packName: "a/b", version: undefined },
|
|
||||||
{ packName: "c/d", version: "1.2.3" },
|
|
||||||
],
|
|
||||||
});
|
|
||||||
ava_1.default("input only with +", parseInputAndConfigMacro, {}, " + a/b , c/d@1.2.3 ", [languages_1.Language.cpp], {
|
|
||||||
[languages_1.Language.cpp]: [
|
|
||||||
{ packName: "a/b", version: undefined },
|
|
||||||
{ packName: "c/d", version: "1.2.3" },
|
|
||||||
],
|
|
||||||
});
|
|
||||||
ava_1.default("config only", parseInputAndConfigMacro, ["a/b", "c/d"], " ", [languages_1.Language.cpp], {
|
|
||||||
[languages_1.Language.cpp]: [
|
|
||||||
{ packName: "a/b", version: undefined },
|
|
||||||
{ packName: "c/d", version: undefined },
|
|
||||||
],
|
|
||||||
});
|
|
||||||
ava_1.default("input overrides", parseInputAndConfigMacro, ["a/b", "c/d"], " e/f, g/h@1.2.3 ", [languages_1.Language.cpp], {
|
|
||||||
[languages_1.Language.cpp]: [
|
|
||||||
{ packName: "e/f", version: undefined },
|
|
||||||
{ packName: "g/h", version: "1.2.3" },
|
|
||||||
],
|
|
||||||
});
|
|
||||||
ava_1.default("input and config", parseInputAndConfigMacro, ["a/b", "c/d"], " +e/f, g/h@1.2.3 ", [languages_1.Language.cpp], {
|
|
||||||
[languages_1.Language.cpp]: [
|
|
||||||
{ packName: "e/f", version: undefined },
|
|
||||||
{ packName: "g/h", version: "1.2.3" },
|
|
||||||
{ packName: "a/b", version: undefined },
|
|
||||||
{ packName: "c/d", version: undefined },
|
|
||||||
],
|
|
||||||
});
|
|
||||||
ava_1.default("input with no language", parseInputAndConfigErrorMacro, {}, "c/d", [], /No languages specified/);
|
|
||||||
ava_1.default("input with two languages", parseInputAndConfigErrorMacro, {}, "c/d", [languages_1.Language.cpp, languages_1.Language.csharp], /multi-language analysis/);
|
|
||||||
ava_1.default("input with + only", parseInputAndConfigErrorMacro, {}, " + ", [languages_1.Language.cpp], /remove the '\+'/);
|
|
||||||
ava_1.default("input with invalid pack name", parseInputAndConfigErrorMacro, {}, " xxx", [languages_1.Language.cpp], /"xxx" is not a valid pack/);
|
|
||||||
// errors
|
|
||||||
// input w invalid pack name
|
|
||||||
//# sourceMappingURL=config-utils.test.js.map
|
//# sourceMappingURL=config-utils.test.js.map
|
||||||
File diff suppressed because one or more lines are too long
19
lib/count-loc.js
generated
19
lib/count-loc.js
generated
@@ -1,6 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.countLoc = exports.getIdPrefix = void 0;
|
|
||||||
const github_linguist_1 = require("github-linguist");
|
const github_linguist_1 = require("github-linguist");
|
||||||
const languages_1 = require("./languages");
|
const languages_1 = require("./languages");
|
||||||
const util_1 = require("./util");
|
const util_1 = require("./util");
|
||||||
@@ -13,7 +12,6 @@ const linguistToMetrics = {
|
|||||||
java: languages_1.Language.java,
|
java: languages_1.Language.java,
|
||||||
javascript: languages_1.Language.javascript,
|
javascript: languages_1.Language.javascript,
|
||||||
python: languages_1.Language.python,
|
python: languages_1.Language.python,
|
||||||
ruby: languages_1.Language.ruby,
|
|
||||||
typescript: languages_1.Language.javascript,
|
typescript: languages_1.Language.javascript,
|
||||||
};
|
};
|
||||||
const nameToLinguist = Object.entries(linguistToMetrics).reduce((obj, [key, name]) => {
|
const nameToLinguist = Object.entries(linguistToMetrics).reduce((obj, [key, name]) => {
|
||||||
@@ -37,8 +35,6 @@ function getIdPrefix(language) {
|
|||||||
return "js";
|
return "js";
|
||||||
case languages_1.Language.python:
|
case languages_1.Language.python:
|
||||||
return "py";
|
return "py";
|
||||||
case languages_1.Language.ruby:
|
|
||||||
return "rb";
|
|
||||||
default:
|
default:
|
||||||
util_1.assertNever(language);
|
util_1.assertNever(language);
|
||||||
}
|
}
|
||||||
@@ -78,13 +74,14 @@ async function countLoc(cwd, include, exclude, dbLanguages, logger) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
logger.info("Could not determine the baseline lines of code count in this repository. " +
|
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 lines " +
|
"Because of this, it will not be possible to compare the number of lines " +
|
||||||
"of code analyzed by code scanning with the baseline. This will not affect " +
|
"of code analyzed by code scanning with the total number of lines of " +
|
||||||
"the results produced by code scanning. If you have any questions, you can " +
|
"code in the repository. This will not affect the results produced by code " +
|
||||||
"raise an issue at https://github.com/github/codeql-action/issues. Please " +
|
"scanning. If you have any questions, you can raise an issue at " +
|
||||||
"include a link to the repository if public, or otherwise information about " +
|
"https://github.com/github/codeql-action/issues. Please include a link " +
|
||||||
"the code scanning workflow you are using.");
|
"to the repository if public, or otherwise information about the code scanning " +
|
||||||
|
"workflow you are using.");
|
||||||
}
|
}
|
||||||
return lineCounts;
|
return lineCounts;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"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,IAAI,EAAE,oBAAQ,CAAC,IAAI;IACnB,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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E,CAAC;IAEd,uDAAuD;IACvD,uDAAuD;IACvD,2DAA2D;IAC3D,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,CACxD,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE;QAC5B,MAAM,eAAe,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC;QACpD,IAAI,eAAe,IAAI,WAAW,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE;YAC5D,GAAG,CAAC,eAAe,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;SAC3D;QACD,OAAO,GAAG,CAAC;IACb,CAAC,EACD,EAA8B,CAC/B,CAAC;IAEF,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,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"}
|
||||||
28
lib/count-loc.test.js
generated
28
lib/count-loc.test.js
generated
@@ -1,21 +1,9 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
__setModuleDefault(result, mod);
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
@@ -33,19 +21,13 @@ 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));
|
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, {
|
t.deepEqual(results, {
|
||||||
cpp: 6,
|
cpp: 6,
|
||||||
javascript: 9,
|
javascript: 3,
|
||||||
});
|
|
||||||
});
|
|
||||||
ava_1.default("ensure lines of code works for csharp", async (t) => {
|
|
||||||
const results = await count_loc_1.countLoc(path.join(__dirname, "../tests/multi-language-repo"), [], [], [languages_1.Language.csharp], logging_1.getRunnerLogger(true));
|
|
||||||
t.deepEqual(results, {
|
|
||||||
csharp: 10,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
ava_1.default("ensure lines of code can handle undefined language", async (t) => {
|
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));
|
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, {
|
t.deepEqual(results, {
|
||||||
javascript: 9,
|
javascript: 3,
|
||||||
python: 5,
|
python: 5,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -72,7 +54,7 @@ ava_1.default("ensure lines of code can handle empty includes", async (t) => {
|
|||||||
ava_1.default("ensure lines of code can handle exclude", async (t) => {
|
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));
|
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, {
|
t.deepEqual(results, {
|
||||||
javascript: 9,
|
javascript: 3,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
//# sourceMappingURL=count-loc.test.js.map
|
//# sourceMappingURL=count-loc.test.js.map
|
||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"count-loc.test.js","sourceRoot":"","sources":["../src/count-loc.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAE7B,8CAAuB;AAEvB,2CAAuC;AACvC,2CAAuC;AAC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tB,CAAC;IAEF,CAAC,CAAC,SAAS,CAAC,OAAO,EAAE;IACnB,wBAAwB;KACzB,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,aAAI,CAAC,yCAAyC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE;IAC1D,MAAM,OAAO,GAAG,MAAM,oBAAQ,CAC5B,IAAI,CAAC,IAAI,CAAC,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"}
|
||||||
85
lib/database-upload.js
generated
85
lib/database-upload.js
generated
@@ -1,85 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
||||||
__setModuleDefault(result, mod);
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.uploadDatabases = void 0;
|
|
||||||
const fs = __importStar(require("fs"));
|
|
||||||
const actionsUtil = __importStar(require("./actions-util"));
|
|
||||||
const api_client_1 = require("./api-client");
|
|
||||||
const codeql_1 = require("./codeql");
|
|
||||||
const util = __importStar(require("./util"));
|
|
||||||
async function uploadDatabases(repositoryNwo, config, apiDetails, logger) {
|
|
||||||
if (actionsUtil.getRequiredInput("upload-database") !== "true") {
|
|
||||||
logger.debug("Database upload disabled in workflow. Skipping upload.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Do nothing when not running against github.com
|
|
||||||
if (config.gitHubVersion.type !== util.GitHubVariant.DOTCOM) {
|
|
||||||
logger.debug("Not running against github.com. Skipping upload.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!(await actionsUtil.isAnalyzingDefaultBranch())) {
|
|
||||||
// We only want to upload a database if we are analyzing the default branch.
|
|
||||||
logger.debug("Not analyzing default branch. Skipping upload.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const client = api_client_1.getApiClient(apiDetails);
|
|
||||||
try {
|
|
||||||
await client.request("GET /repos/:owner/:repo/code-scanning/codeql/databases", {
|
|
||||||
owner: repositoryNwo.owner,
|
|
||||||
repo: repositoryNwo.repo,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
if (util.isHTTPError(e) && e.status === 404) {
|
|
||||||
logger.debug("Repository is not opted in to database uploads. Skipping upload.");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
console.log(e);
|
|
||||||
logger.info(`Skipping database upload due to unknown error: ${e}`);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const codeql = codeql_1.getCodeQL(config.codeQLCmd);
|
|
||||||
for (const language of config.languages) {
|
|
||||||
// Bundle the database up into a single zip file
|
|
||||||
const databasePath = util.getCodeQLDatabasePath(config, language);
|
|
||||||
const databaseBundlePath = `${databasePath}.zip`;
|
|
||||||
await codeql.databaseBundle(databasePath, databaseBundlePath);
|
|
||||||
// Upload the database bundle
|
|
||||||
const payload = fs.readFileSync(databaseBundlePath);
|
|
||||||
try {
|
|
||||||
await client.request(`PUT /repos/:owner/:repo/code-scanning/codeql/databases/:language`, {
|
|
||||||
owner: repositoryNwo.owner,
|
|
||||||
repo: repositoryNwo.repo,
|
|
||||||
language,
|
|
||||||
data: payload,
|
|
||||||
});
|
|
||||||
logger.debug(`Successfully uploaded database for ${language}`);
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
console.log(e);
|
|
||||||
// Log a warning but don't fail the workflow
|
|
||||||
logger.warning(`Failed to upload database for ${language}: ${e}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.uploadDatabases = uploadDatabases;
|
|
||||||
//# sourceMappingURL=database-upload.js.map
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"database-upload.js","sourceRoot":"","sources":["../src/database-upload.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AAEzB,4DAA8C;AAC9C,6CAA8D;AAC9D,qCAAqC;AAIrC,6CAA+B;AAExB,KAAK,UAAU,eAAe,CACnC,aAA4B,EAC5B,MAAc,EACd,UAA4B,EAC5B,MAAc;IAEd,IAAI,WAAW,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,KAAK,MAAM,EAAE;QAC9D,MAAM,CAAC,KAAK,CAAC,wDAAwD,CAAC,CAAC;QACvE,OAAO;KACR;IAED,iDAAiD;IACjD,IAAI,MAAM,CAAC,aAAa,CAAC,IAAI,KAAK,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE;QAC3D,MAAM,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAC;QACjE,OAAO;KACR;IAED,IAAI,CAAC,CAAC,MAAM,WAAW,CAAC,wBAAwB,EAAE,CAAC,EAAE;QACnD,4EAA4E;QAC5E,MAAM,CAAC,KAAK,CAAC,gDAAgD,CAAC,C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AAC,EAAE;YACV,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACf,4CAA4C;YAC5C,MAAM,CAAC,OAAO,CAAC,iCAAiC,QAAQ,KAAK,CAAC,EAAE,CAAC,CAAC;SACnE;KACF;AACH,CAAC;AAtED,0CAsEC"}
|
|
||||||
248
lib/database-upload.test.js
generated
248
lib/database-upload.test.js
generated
@@ -1,248 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
||||||
__setModuleDefault(result, mod);
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const fs = __importStar(require("fs"));
|
|
||||||
const github = __importStar(require("@actions/github"));
|
|
||||||
const ava_1 = __importDefault(require("ava"));
|
|
||||||
const sinon_1 = __importDefault(require("sinon"));
|
|
||||||
const actionsUtil = __importStar(require("./actions-util"));
|
|
||||||
const apiClient = __importStar(require("./api-client"));
|
|
||||||
const codeql_1 = require("./codeql");
|
|
||||||
const database_upload_1 = require("./database-upload");
|
|
||||||
const languages_1 = require("./languages");
|
|
||||||
const testing_utils_1 = require("./testing-utils");
|
|
||||||
const util_1 = require("./util");
|
|
||||||
testing_utils_1.setupTests(ava_1.default);
|
|
||||||
ava_1.default.beforeEach(() => {
|
|
||||||
util_1.initializeEnvironment(util_1.Mode.actions, "1.2.3");
|
|
||||||
});
|
|
||||||
const testRepoName = { owner: "github", repo: "example" };
|
|
||||||
const testApiDetails = {
|
|
||||||
auth: "1234",
|
|
||||||
url: "https://github.com",
|
|
||||||
};
|
|
||||||
function getTestConfig(tmpDir) {
|
|
||||||
return {
|
|
||||||
languages: [languages_1.Language.javascript],
|
|
||||||
queries: {},
|
|
||||||
pathsIgnore: [],
|
|
||||||
paths: [],
|
|
||||||
originalUserInput: {},
|
|
||||||
tempDir: tmpDir,
|
|
||||||
toolCacheDir: tmpDir,
|
|
||||||
codeQLCmd: "foo",
|
|
||||||
gitHubVersion: { type: util_1.GitHubVariant.DOTCOM },
|
|
||||||
dbLocation: tmpDir,
|
|
||||||
packs: {},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
function getRecordingLogger(messages) {
|
|
||||||
return {
|
|
||||||
debug: (message) => {
|
|
||||||
messages.push({ type: "debug", message });
|
|
||||||
console.debug(message);
|
|
||||||
},
|
|
||||||
info: (message) => {
|
|
||||||
messages.push({ type: "info", message });
|
|
||||||
console.info(message);
|
|
||||||
},
|
|
||||||
warning: (message) => {
|
|
||||||
messages.push({ type: "warning", message });
|
|
||||||
console.warn(message);
|
|
||||||
},
|
|
||||||
error: (message) => {
|
|
||||||
messages.push({ type: "error", message });
|
|
||||||
console.error(message);
|
|
||||||
},
|
|
||||||
isDebug: () => true,
|
|
||||||
startGroup: () => undefined,
|
|
||||||
endGroup: () => undefined,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
function mockHttpRequests(optInStatusCode, databaseUploadStatusCode) {
|
|
||||||
// Passing an auth token is required, so we just use a dummy value
|
|
||||||
const client = github.getOctokit("123");
|
|
||||||
const requestSpy = sinon_1.default.stub(client, "request");
|
|
||||||
const optInSpy = requestSpy.withArgs("GET /repos/:owner/:repo/code-scanning/codeql/databases");
|
|
||||||
if (optInStatusCode < 300) {
|
|
||||||
optInSpy.resolves(undefined);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
optInSpy.throws(new util_1.HTTPError("some error message", optInStatusCode));
|
|
||||||
}
|
|
||||||
if (databaseUploadStatusCode !== undefined) {
|
|
||||||
const databaseUploadSpy = requestSpy.withArgs("PUT /repos/:owner/:repo/code-scanning/codeql/databases/:language");
|
|
||||||
if (databaseUploadStatusCode < 300) {
|
|
||||||
databaseUploadSpy.resolves(undefined);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
databaseUploadSpy.throws(new util_1.HTTPError("some error message", databaseUploadStatusCode));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sinon_1.default.stub(apiClient, "getApiClient").value(() => client);
|
|
||||||
}
|
|
||||||
ava_1.default("Abort database upload if 'upload-database' input set to false", async (t) => {
|
|
||||||
await util_1.withTmpDir(async (tmpDir) => {
|
|
||||||
testing_utils_1.setupActionsVars(tmpDir, tmpDir);
|
|
||||||
sinon_1.default
|
|
||||||
.stub(actionsUtil, "getRequiredInput")
|
|
||||||
.withArgs("upload-database")
|
|
||||||
.returns("false");
|
|
||||||
sinon_1.default.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
|
||||||
const loggedMessages = [];
|
|
||||||
await database_upload_1.uploadDatabases(testRepoName, getTestConfig(tmpDir), testApiDetails, getRecordingLogger(loggedMessages));
|
|
||||||
t.assert(loggedMessages.find((v) => v.type === "debug" &&
|
|
||||||
v.message === "Database upload disabled in workflow. Skipping upload.") !== undefined);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
ava_1.default("Abort database upload if running against GHES", async (t) => {
|
|
||||||
await util_1.withTmpDir(async (tmpDir) => {
|
|
||||||
testing_utils_1.setupActionsVars(tmpDir, tmpDir);
|
|
||||||
sinon_1.default
|
|
||||||
.stub(actionsUtil, "getRequiredInput")
|
|
||||||
.withArgs("upload-database")
|
|
||||||
.returns("true");
|
|
||||||
sinon_1.default.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
|
||||||
const config = getTestConfig(tmpDir);
|
|
||||||
config.gitHubVersion = { type: util_1.GitHubVariant.GHES, version: "3.0" };
|
|
||||||
const loggedMessages = [];
|
|
||||||
await database_upload_1.uploadDatabases(testRepoName, config, testApiDetails, getRecordingLogger(loggedMessages));
|
|
||||||
t.assert(loggedMessages.find((v) => v.type === "debug" &&
|
|
||||||
v.message === "Not running against github.com. Skipping upload.") !== undefined);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
ava_1.default("Abort database upload if running against GHAE", async (t) => {
|
|
||||||
await util_1.withTmpDir(async (tmpDir) => {
|
|
||||||
testing_utils_1.setupActionsVars(tmpDir, tmpDir);
|
|
||||||
sinon_1.default
|
|
||||||
.stub(actionsUtil, "getRequiredInput")
|
|
||||||
.withArgs("upload-database")
|
|
||||||
.returns("true");
|
|
||||||
sinon_1.default.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
|
||||||
const config = getTestConfig(tmpDir);
|
|
||||||
config.gitHubVersion = { type: util_1.GitHubVariant.GHAE };
|
|
||||||
const loggedMessages = [];
|
|
||||||
await database_upload_1.uploadDatabases(testRepoName, config, testApiDetails, getRecordingLogger(loggedMessages));
|
|
||||||
t.assert(loggedMessages.find((v) => v.type === "debug" &&
|
|
||||||
v.message === "Not running against github.com. Skipping upload.") !== undefined);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
ava_1.default("Abort database upload if not analyzing default branch", async (t) => {
|
|
||||||
await util_1.withTmpDir(async (tmpDir) => {
|
|
||||||
testing_utils_1.setupActionsVars(tmpDir, tmpDir);
|
|
||||||
sinon_1.default
|
|
||||||
.stub(actionsUtil, "getRequiredInput")
|
|
||||||
.withArgs("upload-database")
|
|
||||||
.returns("true");
|
|
||||||
sinon_1.default.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(false);
|
|
||||||
const loggedMessages = [];
|
|
||||||
await database_upload_1.uploadDatabases(testRepoName, getTestConfig(tmpDir), testApiDetails, getRecordingLogger(loggedMessages));
|
|
||||||
t.assert(loggedMessages.find((v) => v.type === "debug" &&
|
|
||||||
v.message === "Not analyzing default branch. Skipping upload.") !== undefined);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
ava_1.default("Abort database upload if opt-in request returns 404", async (t) => {
|
|
||||||
await util_1.withTmpDir(async (tmpDir) => {
|
|
||||||
testing_utils_1.setupActionsVars(tmpDir, tmpDir);
|
|
||||||
sinon_1.default
|
|
||||||
.stub(actionsUtil, "getRequiredInput")
|
|
||||||
.withArgs("upload-database")
|
|
||||||
.returns("true");
|
|
||||||
sinon_1.default.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
|
||||||
mockHttpRequests(404);
|
|
||||||
codeql_1.setCodeQL({
|
|
||||||
async databaseBundle() {
|
|
||||||
return;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const loggedMessages = [];
|
|
||||||
await database_upload_1.uploadDatabases(testRepoName, getTestConfig(tmpDir), testApiDetails, getRecordingLogger(loggedMessages));
|
|
||||||
t.assert(loggedMessages.find((v) => v.type === "debug" &&
|
|
||||||
v.message ===
|
|
||||||
"Repository is not opted in to database uploads. Skipping upload.") !== undefined);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
ava_1.default("Abort database upload if opt-in request fails with something other than 404", async (t) => {
|
|
||||||
await util_1.withTmpDir(async (tmpDir) => {
|
|
||||||
testing_utils_1.setupActionsVars(tmpDir, tmpDir);
|
|
||||||
sinon_1.default
|
|
||||||
.stub(actionsUtil, "getRequiredInput")
|
|
||||||
.withArgs("upload-database")
|
|
||||||
.returns("true");
|
|
||||||
sinon_1.default.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
|
||||||
mockHttpRequests(500);
|
|
||||||
codeql_1.setCodeQL({
|
|
||||||
async databaseBundle() {
|
|
||||||
return;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const loggedMessages = [];
|
|
||||||
await database_upload_1.uploadDatabases(testRepoName, getTestConfig(tmpDir), testApiDetails, getRecordingLogger(loggedMessages));
|
|
||||||
t.assert(loggedMessages.find((v) => v.type === "info" &&
|
|
||||||
v.message ===
|
|
||||||
"Skipping database upload due to unknown error: Error: some error message") !== undefined);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
ava_1.default("Don't crash if uploading a database fails", async (t) => {
|
|
||||||
await util_1.withTmpDir(async (tmpDir) => {
|
|
||||||
testing_utils_1.setupActionsVars(tmpDir, tmpDir);
|
|
||||||
sinon_1.default
|
|
||||||
.stub(actionsUtil, "getRequiredInput")
|
|
||||||
.withArgs("upload-database")
|
|
||||||
.returns("true");
|
|
||||||
sinon_1.default.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
|
||||||
mockHttpRequests(204, 500);
|
|
||||||
codeql_1.setCodeQL({
|
|
||||||
async databaseBundle(_, outputFilePath) {
|
|
||||||
fs.writeFileSync(outputFilePath, "");
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const loggedMessages = [];
|
|
||||||
await database_upload_1.uploadDatabases(testRepoName, getTestConfig(tmpDir), testApiDetails, getRecordingLogger(loggedMessages));
|
|
||||||
t.assert(loggedMessages.find((v) => v.type === "warning" &&
|
|
||||||
v.message ===
|
|
||||||
"Failed to upload database for javascript: Error: some error message") !== undefined);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
ava_1.default("Successfully uploading a database", async (t) => {
|
|
||||||
await util_1.withTmpDir(async (tmpDir) => {
|
|
||||||
testing_utils_1.setupActionsVars(tmpDir, tmpDir);
|
|
||||||
sinon_1.default
|
|
||||||
.stub(actionsUtil, "getRequiredInput")
|
|
||||||
.withArgs("upload-database")
|
|
||||||
.returns("true");
|
|
||||||
sinon_1.default.stub(actionsUtil, "isAnalyzingDefaultBranch").resolves(true);
|
|
||||||
mockHttpRequests(204, 201);
|
|
||||||
codeql_1.setCodeQL({
|
|
||||||
async databaseBundle(_, outputFilePath) {
|
|
||||||
fs.writeFileSync(outputFilePath, "");
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const loggedMessages = [];
|
|
||||||
await database_upload_1.uploadDatabases(testRepoName, getTestConfig(tmpDir), testApiDetails, getRecordingLogger(loggedMessages));
|
|
||||||
t.assert(loggedMessages.find((v) => v.type === "debug" &&
|
|
||||||
v.message === "Successfully uploaded database for javascript") !== undefined);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
//# sourceMappingURL=database-upload.test.js.map
|
|
||||||
File diff suppressed because one or more lines are too long
@@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"bundleVersion": "codeql-bundle-20210726"
|
"bundleVersion": "codeql-bundle-20210517"
|
||||||
}
|
}
|
||||||
|
|||||||
1
lib/error-matcher.js
generated
1
lib/error-matcher.js
generated
@@ -1,6 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.errorMatchers = exports.namedMatchersForTesting = void 0;
|
|
||||||
// exported only for testing purposes
|
// exported only for testing purposes
|
||||||
exports.namedMatchersForTesting = {
|
exports.namedMatchersForTesting = {
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"error-matcher.js","sourceRoot":"","sources":["../src/error-matcher.ts"],"names":[],"mappings":";;;AAQA,qCAAqC;AACxB,QAAA,uBAAuB,GAAoC;IACtE;;MAEE;IACF,iBAAiB,EAAE;QACjB,QAAQ,EAAE,EAAE;QACZ,WAAW,EAAE,IAAI,MAAM,CAAC,2CAA2C,CAAC;QACpE,OAAO,EACL,+CAA+C;YAC/C,yJAAyJ;KAC5J;CACF,CAAC;AAEF,oEAAoE;AACvD,QAAA,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,+BAAuB,CAAC,CAAC"}
|
{"version":3,"file":"error-matcher.js","sourceRoot":"","sources":["../src/error-matcher.ts"],"names":[],"mappings":";;AAQA,qCAAqC;AACxB,QAAA,uBAAuB,GAAoC;IACtE;;MAEE;IACF,iBAAiB,EAAE;QACjB,QAAQ,EAAE,EAAE;QACZ,WAAW,EAAE,IAAI,MAAM,CAAC,2CAA2C,CAAC;QACpE,OAAO,EACL,+CAA+C;YAC/C,yJAAyJ;KAC5J;CACF,CAAC;AAEF,oEAAoE;AACvD,QAAA,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,+BAAuB,CAAC,CAAC"}
|
||||||
17
lib/external-queries.js
generated
17
lib/external-queries.js
generated
@@ -1,25 +1,12 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
__setModuleDefault(result, mod);
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.buildCheckoutURL = exports.checkoutExternalRepository = void 0;
|
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
|
const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
|
||||||
|
|||||||
@@ -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,MA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ict";
|
"use strict";
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
__setModuleDefault(result, mod);
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
|||||||
@@ -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,C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C,CAAC;IACvE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,aAAI,CAAC,kBAAkB,EAAE,CAAC,CAAC,EAAE,EAAE;IAC7B,CAAC,CAAC,SAAS,CACT,eAAe,CAAC,gBAAgB,CAAC,SAAS,EAAE;QAC1C,GAAG,EAAE,oBAAoB;QACzB,gBAAgB,EAAE,SAAS;KAC5B,CAAC,EACF,4BAA4B,CAC7B,CAAC;IACF,CAAC,CAAC,SAAS,CACT,eAAe,CAAC,gBAAgB,CAAC,SAAS,EAAE;QAC1C,GAAG,EAAE,6BAA6B;QAClC,gBAAgB,EAAE,SAAS;KAC5B,CAAC,EACF,oCAAoC,CACrC,CAAC;IAEF,CAAC,CAAC,SAAS,CACT,eAAe,CAAC,gBAAgB,CAAC,SAAS,EAAE;QAC1C,GAAG,EAAE,oBAAoB;QACzB,gBAAgB,EAAE,KAAK;KACxB,CAAC,EACF,+CAA+C,CAChD,CAAC;IACF,CAAC,CAAC,SAAS,CACT,eAAe,CAAC,gBAAgB,CAAC,SAAS,EAAE;QAC1C,GAAG,EAAE,6BAA6B;QAClC,gBAAgB,EAAE,KAAK;KACxB,CAAC,EACF,uDAAuD,CACxD,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
||||||
53
lib/fingerprints.js
generated
53
lib/fingerprints.js
generated
@@ -1,35 +1,21 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
__setModuleDefault(result, mod);
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
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 };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.addFingerprints = exports.resolveUriToFile = exports.hash = void 0;
|
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const long_1 = __importDefault(require("long"));
|
const long_1 = __importDefault(require("long"));
|
||||||
const tab = "\t".charCodeAt(0);
|
const tab = "\t".charCodeAt(0);
|
||||||
const space = " ".charCodeAt(0);
|
const space = " ".charCodeAt(0);
|
||||||
const lf = "\n".charCodeAt(0);
|
const lf = "\n".charCodeAt(0);
|
||||||
const cr = "\r".charCodeAt(0);
|
const cr = "\r".charCodeAt(0);
|
||||||
const EOF = 65535;
|
|
||||||
const BLOCK_SIZE = 100;
|
const BLOCK_SIZE = 100;
|
||||||
const MOD = long_1.default.fromInt(37); // L
|
const MOD = long_1.default.fromInt(37); // L
|
||||||
// Compute the starting point for the hash mod
|
// Compute the starting point for the hash mod
|
||||||
@@ -50,9 +36,9 @@ function computeFirstMod() {
|
|||||||
* the hashes of the lines near the end of the file.
|
* the hashes of the lines near the end of the file.
|
||||||
*
|
*
|
||||||
* @param callback function that is called with the line number (1-based) and hash for every line
|
* @param callback function that is called with the line number (1-based) and hash for every line
|
||||||
* @param filepath The path to the file to hash
|
* @param input The file's contents
|
||||||
*/
|
*/
|
||||||
async function hash(callback, filepath) {
|
function hash(callback, input) {
|
||||||
// A rolling view in to the input
|
// A rolling view in to the input
|
||||||
const window = Array(BLOCK_SIZE).fill(0);
|
const window = Array(BLOCK_SIZE).fill(0);
|
||||||
// If the character in the window is the start of a new line
|
// If the character in the window is the start of a new line
|
||||||
@@ -96,11 +82,12 @@ async function hash(callback, filepath) {
|
|||||||
// as we go. Once we reach a point in the window again then we've processed
|
// as we go. Once we reach a point in the window again then we've processed
|
||||||
// BLOCK_SIZE characters and if the last character at this point in the window
|
// BLOCK_SIZE characters and if the last character at this point in the window
|
||||||
// was the start of a line then we should output the hash for that line.
|
// was the start of a line then we should output the hash for that line.
|
||||||
const processCharacter = function (current) {
|
for (let i = 0, len = input.length; i <= len; i++) {
|
||||||
|
let current = i === len ? 65535 : input.charCodeAt(i);
|
||||||
// skip tabs, spaces, and line feeds that come directly after a carriage return
|
// skip tabs, spaces, and line feeds that come directly after a carriage return
|
||||||
if (current === space || current === tab || (prevCR && current === lf)) {
|
if (current === space || current === tab || (prevCR && current === lf)) {
|
||||||
prevCR = false;
|
prevCR = false;
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
// replace CR with LF
|
// replace CR with LF
|
||||||
if (current === cr) {
|
if (current === cr) {
|
||||||
@@ -122,14 +109,7 @@ async function hash(callback, filepath) {
|
|||||||
lineStart = true;
|
lineStart = true;
|
||||||
}
|
}
|
||||||
updateHash(current);
|
updateHash(current);
|
||||||
};
|
|
||||||
const readStream = fs.createReadStream(filepath, "utf8");
|
|
||||||
for await (const data of readStream) {
|
|
||||||
for (let i = 0; i < data.length; ++i) {
|
|
||||||
processCharacter(data.charCodeAt(i));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
processCharacter(EOF);
|
|
||||||
// Flush the remaining lines
|
// Flush the remaining lines
|
||||||
for (let i = 0; i < BLOCK_SIZE; i++) {
|
for (let i = 0; i < BLOCK_SIZE; i++) {
|
||||||
if (lineNumbers[index] !== -1) {
|
if (lineNumbers[index] !== -1) {
|
||||||
@@ -173,7 +153,7 @@ function locationUpdateCallback(result, location, logger) {
|
|||||||
// the source file so we can hash it.
|
// the source file so we can hash it.
|
||||||
// If possible returns a absolute file path for the source file,
|
// If possible returns a absolute file path for the source file,
|
||||||
// or if not possible then returns undefined.
|
// or if not possible then returns undefined.
|
||||||
function resolveUriToFile(location, artifacts, sourceRoot, logger) {
|
function resolveUriToFile(location, artifacts, checkoutPath, logger) {
|
||||||
// This may be referencing an artifact
|
// This may be referencing an artifact
|
||||||
if (!location.uri && location.index !== undefined) {
|
if (!location.uri && location.index !== undefined) {
|
||||||
if (typeof location.index !== "number" ||
|
if (typeof location.index !== "number" ||
|
||||||
@@ -201,7 +181,7 @@ function resolveUriToFile(location, artifacts, sourceRoot, logger) {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
// Discard any absolute paths that aren't in the src root
|
// Discard any absolute paths that aren't in the src root
|
||||||
const srcRootPrefix = `${sourceRoot}/`;
|
const srcRootPrefix = `${checkoutPath}/`;
|
||||||
if (uri.startsWith("/") && !uri.startsWith(srcRootPrefix)) {
|
if (uri.startsWith("/") && !uri.startsWith(srcRootPrefix)) {
|
||||||
logger.debug(`Ignoring location URI "${uri}" as it is outside of the src root`);
|
logger.debug(`Ignoring location URI "${uri}" as it is outside of the src root`);
|
||||||
return undefined;
|
return undefined;
|
||||||
@@ -226,8 +206,8 @@ function resolveUriToFile(location, artifacts, sourceRoot, logger) {
|
|||||||
exports.resolveUriToFile = resolveUriToFile;
|
exports.resolveUriToFile = resolveUriToFile;
|
||||||
// Compute fingerprints for results in the given sarif file
|
// Compute fingerprints for results in the given sarif file
|
||||||
// and return an updated sarif file contents.
|
// and return an updated sarif file contents.
|
||||||
async function addFingerprints(sarifContents, sourceRoot, logger) {
|
function addFingerprints(sarifContents, checkoutPath, logger) {
|
||||||
var _a, _b, _c;
|
var _a, _b;
|
||||||
const sarif = JSON.parse(sarifContents);
|
const sarif = JSON.parse(sarifContents);
|
||||||
// Gather together results for the same file and construct
|
// Gather together results for the same file and construct
|
||||||
// callbacks to accept hashes for that file and update the location
|
// callbacks to accept hashes for that file and update the location
|
||||||
@@ -238,15 +218,11 @@ async function addFingerprints(sarifContents, sourceRoot, logger) {
|
|||||||
for (const result of run.results || []) {
|
for (const result of run.results || []) {
|
||||||
// Check the primary location is defined correctly and is in the src root
|
// Check the primary location is defined correctly and is in the src root
|
||||||
const primaryLocation = (result.locations || [])[0];
|
const primaryLocation = (result.locations || [])[0];
|
||||||
if (!((_a = primaryLocation === null || primaryLocation === void 0 ? void 0 : primaryLocation.physicalLocation) === null || _a === void 0 ? void 0 : _a.artifactLocation)) {
|
if (!((_b = (_a = primaryLocation) === null || _a === void 0 ? void 0 : _a.physicalLocation) === null || _b === void 0 ? void 0 : _b.artifactLocation)) {
|
||||||
logger.debug(`Unable to compute fingerprint for invalid location: ${JSON.stringify(primaryLocation)}`);
|
logger.debug(`Unable to compute fingerprint for invalid location: ${JSON.stringify(primaryLocation)}`);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (((_c = (_b = primaryLocation === null || primaryLocation === void 0 ? void 0 : primaryLocation.physicalLocation) === null || _b === void 0 ? void 0 : _b.region) === null || _c === void 0 ? void 0 : _c.startLine) === undefined) {
|
const filepath = resolveUriToFile(primaryLocation.physicalLocation.artifactLocation, artifacts, checkoutPath, logger);
|
||||||
// Locations without a line number are unlikely to be source files
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const filepath = resolveUriToFile(primaryLocation.physicalLocation.artifactLocation, artifacts, sourceRoot, logger);
|
|
||||||
if (!filepath) {
|
if (!filepath) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -264,7 +240,8 @@ async function addFingerprints(sarifContents, sourceRoot, logger) {
|
|||||||
c(lineNumber, hashValue);
|
c(lineNumber, hashValue);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
await hash(teeCallback, filepath);
|
const fileContents = fs.readFileSync(filepath).toString();
|
||||||
|
hash(teeCallback, fileContents);
|
||||||
}
|
}
|
||||||
return JSON.stringify(sarif);
|
return JSON.stringify(sarif);
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
71
lib/fingerprints.test.js
generated
71
lib/fingerprints.test.js
generated
@@ -1,21 +1,9 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
__setModuleDefault(result, mod);
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
@@ -28,33 +16,28 @@ 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");
|
||||||
const util = __importStar(require("./util"));
|
|
||||||
testing_utils_1.setupTests(ava_1.default);
|
testing_utils_1.setupTests(ava_1.default);
|
||||||
async function testHash(t, input, expectedHashes) {
|
function testHash(t, input, expectedHashes) {
|
||||||
await util.withTmpDir(async (tmpDir) => {
|
let index = 0;
|
||||||
const tmpFile = path.resolve(tmpDir, "testfile");
|
const callback = function (lineNumber, hash) {
|
||||||
fs.writeFileSync(tmpFile, input);
|
t.is(lineNumber, index + 1);
|
||||||
let index = 0;
|
t.is(hash, expectedHashes[index]);
|
||||||
const callback = function (lineNumber, hash) {
|
index++;
|
||||||
t.is(lineNumber, index + 1);
|
};
|
||||||
t.is(hash, expectedHashes[index]);
|
fingerprints.hash(callback, input);
|
||||||
index++;
|
t.is(index, input.split(/\r\n|\r|\n/).length);
|
||||||
};
|
|
||||||
await fingerprints.hash(callback, tmpFile);
|
|
||||||
t.is(index, input.split(/\r\n|\r|\n/).length);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
ava_1.default("hash", async (t) => {
|
ava_1.default("hash", (t) => {
|
||||||
// Try empty file
|
// Try empty file
|
||||||
await testHash(t, "", ["c129715d7a2bc9a3:1"]);
|
testHash(t, "", ["c129715d7a2bc9a3:1"]);
|
||||||
// Try various combinations of newline characters
|
// Try various combinations of newline characters
|
||||||
await testHash(t, " a\nb\n \t\tc\n d", [
|
testHash(t, " a\nb\n \t\tc\n d", [
|
||||||
"271789c17abda88f:1",
|
"271789c17abda88f:1",
|
||||||
"54703d4cd895b18:1",
|
"54703d4cd895b18:1",
|
||||||
"180aee12dab6264:1",
|
"180aee12dab6264:1",
|
||||||
"a23a3dc5e078b07b:1",
|
"a23a3dc5e078b07b:1",
|
||||||
]);
|
]);
|
||||||
await testHash(t, " hello; \t\nworld!!!\n\n\n \t\tGreetings\n End", [
|
testHash(t, " hello; \t\nworld!!!\n\n\n \t\tGreetings\n End", [
|
||||||
"8b7cf3e952e7aeb2:1",
|
"8b7cf3e952e7aeb2:1",
|
||||||
"b1ae1287ec4718d9:1",
|
"b1ae1287ec4718d9:1",
|
||||||
"bff680108adb0fcc:1",
|
"bff680108adb0fcc:1",
|
||||||
@@ -62,7 +45,7 @@ ava_1.default("hash", async (t) => {
|
|||||||
"b86d3392aea1be30:1",
|
"b86d3392aea1be30:1",
|
||||||
"e6ceba753e1a442:1",
|
"e6ceba753e1a442:1",
|
||||||
]);
|
]);
|
||||||
await testHash(t, " hello; \t\nworld!!!\n\n\n \t\tGreetings\n End\n", [
|
testHash(t, " hello; \t\nworld!!!\n\n\n \t\tGreetings\n End\n", [
|
||||||
"e9496ae3ebfced30:1",
|
"e9496ae3ebfced30:1",
|
||||||
"fb7c023a8b9ccb3f:1",
|
"fb7c023a8b9ccb3f:1",
|
||||||
"ce8ba1a563dcdaca:1",
|
"ce8ba1a563dcdaca:1",
|
||||||
@@ -71,7 +54,7 @@ ava_1.default("hash", async (t) => {
|
|||||||
"c8e28b0b4002a3a0:1",
|
"c8e28b0b4002a3a0:1",
|
||||||
"c129715d7a2bc9a3:1",
|
"c129715d7a2bc9a3:1",
|
||||||
]);
|
]);
|
||||||
await testHash(t, " hello; \t\nworld!!!\r\r\r \t\tGreetings\r End\r", [
|
testHash(t, " hello; \t\nworld!!!\r\r\r \t\tGreetings\r End\r", [
|
||||||
"e9496ae3ebfced30:1",
|
"e9496ae3ebfced30:1",
|
||||||
"fb7c023a8b9ccb3f:1",
|
"fb7c023a8b9ccb3f:1",
|
||||||
"ce8ba1a563dcdaca:1",
|
"ce8ba1a563dcdaca:1",
|
||||||
@@ -80,7 +63,7 @@ ava_1.default("hash", async (t) => {
|
|||||||
"c8e28b0b4002a3a0:1",
|
"c8e28b0b4002a3a0:1",
|
||||||
"c129715d7a2bc9a3:1",
|
"c129715d7a2bc9a3:1",
|
||||||
]);
|
]);
|
||||||
await testHash(t, " hello; \t\r\nworld!!!\r\n\r\n\r\n \t\tGreetings\r\n End\r\n", [
|
testHash(t, " hello; \t\r\nworld!!!\r\n\r\n\r\n \t\tGreetings\r\n End\r\n", [
|
||||||
"e9496ae3ebfced30:1",
|
"e9496ae3ebfced30:1",
|
||||||
"fb7c023a8b9ccb3f:1",
|
"fb7c023a8b9ccb3f:1",
|
||||||
"ce8ba1a563dcdaca:1",
|
"ce8ba1a563dcdaca:1",
|
||||||
@@ -89,7 +72,7 @@ ava_1.default("hash", async (t) => {
|
|||||||
"c8e28b0b4002a3a0:1",
|
"c8e28b0b4002a3a0:1",
|
||||||
"c129715d7a2bc9a3:1",
|
"c129715d7a2bc9a3:1",
|
||||||
]);
|
]);
|
||||||
await testHash(t, " hello; \t\nworld!!!\r\n\n\r \t\tGreetings\r End\r\n", [
|
testHash(t, " hello; \t\nworld!!!\r\n\n\r \t\tGreetings\r End\r\n", [
|
||||||
"e9496ae3ebfced30:1",
|
"e9496ae3ebfced30:1",
|
||||||
"fb7c023a8b9ccb3f:1",
|
"fb7c023a8b9ccb3f:1",
|
||||||
"ce8ba1a563dcdaca:1",
|
"ce8ba1a563dcdaca:1",
|
||||||
@@ -99,7 +82,7 @@ ava_1.default("hash", async (t) => {
|
|||||||
"c129715d7a2bc9a3:1",
|
"c129715d7a2bc9a3:1",
|
||||||
]);
|
]);
|
||||||
// Try repeating line that will generate identical hashes
|
// Try repeating line that will generate identical hashes
|
||||||
await testHash(t, "Lorem ipsum dolor sit amet.\n".repeat(10), [
|
testHash(t, "Lorem ipsum dolor sit amet.\n".repeat(10), [
|
||||||
"a7f2ff13bc495cf2:1",
|
"a7f2ff13bc495cf2:1",
|
||||||
"a7f2ff13bc495cf2:2",
|
"a7f2ff13bc495cf2:2",
|
||||||
"a7f2ff13bc495cf2:3",
|
"a7f2ff13bc495cf2:3",
|
||||||
@@ -112,7 +95,7 @@ ava_1.default("hash", async (t) => {
|
|||||||
"cc97dc7b1d7d8f7b:1",
|
"cc97dc7b1d7d8f7b:1",
|
||||||
"c129715d7a2bc9a3:1",
|
"c129715d7a2bc9a3:1",
|
||||||
]);
|
]);
|
||||||
await testHash(t, "x = 2\nx = 1\nprint(x)\nx = 3\nprint(x)\nx = 4\nprint(x)\n", [
|
testHash(t, "x = 2\nx = 1\nprint(x)\nx = 3\nprint(x)\nx = 4\nprint(x)\n", [
|
||||||
"e54938cc54b302f1:1",
|
"e54938cc54b302f1:1",
|
||||||
"bb609acbe9138d60:1",
|
"bb609acbe9138d60:1",
|
||||||
"1131fd5871777f34:1",
|
"1131fd5871777f34:1",
|
||||||
@@ -167,7 +150,7 @@ ava_1.default("resolveUriToFile", (t) => {
|
|||||||
t.is(testResolveUriToFile(dirpath, undefined, []), undefined);
|
t.is(testResolveUriToFile(dirpath, undefined, []), undefined);
|
||||||
t.is(testResolveUriToFile(`file://${dirpath}`, undefined, []), undefined);
|
t.is(testResolveUriToFile(`file://${dirpath}`, undefined, []), undefined);
|
||||||
});
|
});
|
||||||
ava_1.default("addFingerprints", async (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
|
||||||
let input = fs
|
let input = fs
|
||||||
.readFileSync(`${__dirname}/../src/testdata/fingerprinting.input.sarif`)
|
.readFileSync(`${__dirname}/../src/testdata/fingerprinting.input.sarif`)
|
||||||
@@ -179,10 +162,10 @@ ava_1.default("addFingerprints", async (t) => {
|
|||||||
input = JSON.stringify(JSON.parse(input));
|
input = JSON.stringify(JSON.parse(input));
|
||||||
expected = JSON.stringify(JSON.parse(expected));
|
expected = JSON.stringify(JSON.parse(expected));
|
||||||
// The URIs in the SARIF files resolve to files in the testdata directory
|
// The URIs in the SARIF files resolve to files in the testdata directory
|
||||||
const sourceRoot = path.normalize(`${__dirname}/../src/testdata`);
|
const checkoutPath = path.normalize(`${__dirname}/../src/testdata`);
|
||||||
t.deepEqual(await fingerprints.addFingerprints(input, sourceRoot, logging_1.getRunnerLogger(true)), expected);
|
t.deepEqual(fingerprints.addFingerprints(input, checkoutPath, logging_1.getRunnerLogger(true)), expected);
|
||||||
});
|
});
|
||||||
ava_1.default("missingRegions", async (t) => {
|
ava_1.default("missingRegions", (t) => {
|
||||||
// Run an end-to-end test on a test file
|
// Run an end-to-end test on a test file
|
||||||
let input = fs
|
let input = fs
|
||||||
.readFileSync(`${__dirname}/../src/testdata/fingerprinting2.input.sarif`)
|
.readFileSync(`${__dirname}/../src/testdata/fingerprinting2.input.sarif`)
|
||||||
@@ -194,7 +177,7 @@ ava_1.default("missingRegions", async (t) => {
|
|||||||
input = JSON.stringify(JSON.parse(input));
|
input = JSON.stringify(JSON.parse(input));
|
||||||
expected = JSON.stringify(JSON.parse(expected));
|
expected = JSON.stringify(JSON.parse(expected));
|
||||||
// The URIs in the SARIF files resolve to files in the testdata directory
|
// The URIs in the SARIF files resolve to files in the testdata directory
|
||||||
const sourceRoot = path.normalize(`${__dirname}/../src/testdata`);
|
const checkoutPath = path.normalize(`${__dirname}/../src/testdata`);
|
||||||
t.deepEqual(await fingerprints.addFingerprints(input, sourceRoot, logging_1.getRunnerLogger(true)), expected);
|
t.deepEqual(fingerprints.addFingerprints(input, checkoutPath, logging_1.getRunnerLogger(true)), expected);
|
||||||
});
|
});
|
||||||
//# sourceMappingURL=fingerprints.test.js.map
|
//# sourceMappingURL=fingerprints.test.js.map
|
||||||
File diff suppressed because one or more lines are too long
58
lib/init-action.js
generated
58
lib/init-action.js
generated
@@ -1,46 +1,31 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
__setModuleDefault(result, mod);
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const path = __importStar(require("path"));
|
|
||||||
const core = __importStar(require("@actions/core"));
|
const core = __importStar(require("@actions/core"));
|
||||||
const actions_util_1 = 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 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");
|
const util_1 = require("./util");
|
||||||
// eslint-disable-next-line import/no-commonjs
|
|
||||||
const pkg = require("../package.json");
|
|
||||||
async function sendSuccessStatusReport(startedAt, config, toolsVersion) {
|
async function sendSuccessStatusReport(startedAt, config, toolsVersion) {
|
||||||
var _a;
|
var _a;
|
||||||
const statusReportBase = await actions_util_1.createStatusReportBase("init", "success", startedAt);
|
const statusReportBase = await actionsUtil.createStatusReportBase("init", "success", startedAt);
|
||||||
const languages = config.languages.join(",");
|
const languages = config.languages.join(",");
|
||||||
const workflowLanguages = actions_util_1.getOptionalInput("languages");
|
const workflowLanguages = actionsUtil.getOptionalInput("languages");
|
||||||
const paths = (config.originalUserInput.paths || []).join(",");
|
const paths = (config.originalUserInput.paths || []).join(",");
|
||||||
const pathsIgnore = (config.originalUserInput["paths-ignore"] || []).join(",");
|
const pathsIgnore = (config.originalUserInput["paths-ignore"] || []).join(",");
|
||||||
const disableDefaultQueries = config.originalUserInput["disable-default-queries"]
|
const disableDefaultQueries = config.originalUserInput["disable-default-queries"]
|
||||||
? languages
|
? languages
|
||||||
: "";
|
: "";
|
||||||
const queries = [];
|
const queries = [];
|
||||||
let queriesInput = (_a = actions_util_1.getOptionalInput("queries")) === null || _a === void 0 ? void 0 : _a.trim();
|
let queriesInput = (_a = actionsUtil.getOptionalInput("queries")) === null || _a === void 0 ? void 0 : _a.trim();
|
||||||
if (queriesInput === undefined || queriesInput.startsWith("+")) {
|
if (queriesInput === undefined || queriesInput.startsWith("+")) {
|
||||||
queries.push(...(config.originalUserInput.queries || []).map((q) => q.uses));
|
queries.push(...(config.originalUserInput.queries || []).map((q) => q.uses));
|
||||||
}
|
}
|
||||||
@@ -58,36 +43,36 @@ 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: actions_util_1.getOptionalInput("tools") || "",
|
tools_input: actionsUtil.getOptionalInput("tools") || "",
|
||||||
tools_resolved_version: toolsVersion,
|
tools_resolved_version: toolsVersion,
|
||||||
};
|
};
|
||||||
await actions_util_1.sendStatusReport(statusReport);
|
await actionsUtil.sendStatusReport(statusReport);
|
||||||
}
|
}
|
||||||
async function run() {
|
async function run() {
|
||||||
const startedAt = new Date();
|
const startedAt = new Date();
|
||||||
const logger = logging_1.getActionsLogger();
|
const logger = logging_1.getActionsLogger();
|
||||||
util_1.initializeEnvironment(util_1.Mode.actions, pkg.version);
|
|
||||||
let config;
|
let config;
|
||||||
let codeql;
|
let codeql;
|
||||||
let toolsVersion;
|
let toolsVersion;
|
||||||
const apiDetails = {
|
const apiDetails = {
|
||||||
auth: actions_util_1.getRequiredInput("token"),
|
auth: actionsUtil.getRequiredInput("token"),
|
||||||
externalRepoAuth: actions_util_1.getOptionalInput("external-repository-token"),
|
externalRepoAuth: actionsUtil.getOptionalInput("external-repository-token"),
|
||||||
url: util_1.getRequiredEnvParam("GITHUB_SERVER_URL"),
|
url: actionsUtil.getRequiredEnvParam("GITHUB_SERVER_URL"),
|
||||||
};
|
};
|
||||||
const gitHubVersion = await util_1.getGitHubVersion(apiDetails);
|
const gitHubVersion = await util_1.getGitHubVersion(apiDetails);
|
||||||
util_1.checkGitHubVersionInRange(gitHubVersion, logger, util_1.Mode.actions);
|
util_1.checkGitHubVersionInRange(gitHubVersion, "actions", logger);
|
||||||
try {
|
try {
|
||||||
const workflowErrors = await actions_util_1.validateWorkflow();
|
actionsUtil.prepareLocalRunEnvironment();
|
||||||
if (!(await actions_util_1.sendStatusReport(await actions_util_1.createStatusReportBase("init", "starting", startedAt, workflowErrors)))) {
|
const workflowErrors = await actionsUtil.validateWorkflow();
|
||||||
|
if (!(await actionsUtil.sendStatusReport(await actionsUtil.createStatusReportBase("init", "starting", startedAt, workflowErrors)))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const initCodeQLResult = await init_1.initCodeQL(actions_util_1.getOptionalInput("tools"), apiDetails, actions_util_1.getTemporaryDirectory(), actions_util_1.getToolCacheDirectory(), gitHubVersion.type, logger);
|
const initCodeQLResult = await init_1.initCodeQL(actionsUtil.getOptionalInput("tools"), apiDetails, actionsUtil.getTemporaryDirectory(), actionsUtil.getToolCacheDirectory(), "actions", gitHubVersion.type, logger);
|
||||||
codeql = initCodeQLResult.codeql;
|
codeql = initCodeQLResult.codeql;
|
||||||
toolsVersion = initCodeQLResult.toolsVersion;
|
toolsVersion = initCodeQLResult.toolsVersion;
|
||||||
config = await init_1.initConfig(actions_util_1.getOptionalInput("languages"), actions_util_1.getOptionalInput("queries"), actions_util_1.getOptionalInput("packs"), actions_util_1.getOptionalInput("config-file"), actions_util_1.getOptionalInput("db-location"), repository_1.parseRepositoryNwo(util_1.getRequiredEnvParam("GITHUB_REPOSITORY")), actions_util_1.getTemporaryDirectory(), util_1.getRequiredEnvParam("RUNNER_TOOL_CACHE"), codeql, util_1.getRequiredEnvParam("GITHUB_WORKSPACE"), gitHubVersion, apiDetails, logger);
|
config = await init_1.initConfig(actionsUtil.getOptionalInput("languages"), actionsUtil.getOptionalInput("queries"), actionsUtil.getOptionalInput("config-file"), actionsUtil.getOptionalInput("db-location"), repository_1.parseRepositoryNwo(actionsUtil.getRequiredEnvParam("GITHUB_REPOSITORY")), actionsUtil.getTemporaryDirectory(), actionsUtil.getRequiredEnvParam("RUNNER_TOOL_CACHE"), codeql, actionsUtil.getRequiredEnvParam("GITHUB_WORKSPACE"), gitHubVersion, apiDetails, logger);
|
||||||
if (config.languages.includes(languages_1.Language.python) &&
|
if (config.languages.includes(languages_1.Language.python) &&
|
||||||
actions_util_1.getRequiredInput("setup-python-dependencies") === "true") {
|
actionsUtil.getRequiredInput("setup-python-dependencies") === "true") {
|
||||||
try {
|
try {
|
||||||
await init_1.installPythonDeps(codeql, logger);
|
await init_1.installPythonDeps(codeql, logger);
|
||||||
}
|
}
|
||||||
@@ -99,7 +84,7 @@ async function run() {
|
|||||||
catch (e) {
|
catch (e) {
|
||||||
core.setFailed(e.message);
|
core.setFailed(e.message);
|
||||||
console.log(e);
|
console.log(e);
|
||||||
await actions_util_1.sendStatusReport(await actions_util_1.createStatusReportBase("init", "aborted", startedAt, e.message));
|
await actionsUtil.sendStatusReport(await actionsUtil.createStatusReportBase("init", "aborted", startedAt, e.message));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -112,8 +97,7 @@ async function run() {
|
|||||||
// Setup CODEQL_RAM flag (todo improve this https://github.com/github/dsp-code-scanning/issues/935)
|
// Setup CODEQL_RAM flag (todo improve this https://github.com/github/dsp-code-scanning/issues/935)
|
||||||
const codeqlRam = process.env["CODEQL_RAM"] || "6500";
|
const codeqlRam = process.env["CODEQL_RAM"] || "6500";
|
||||||
core.exportVariable("CODEQL_RAM", codeqlRam);
|
core.exportVariable("CODEQL_RAM", codeqlRam);
|
||||||
const sourceRoot = path.resolve(util_1.getRequiredEnvParam("GITHUB_WORKSPACE"), actions_util_1.getOptionalInput("source-root") || "");
|
const tracerConfig = await init_1.runInit(codeql, config);
|
||||||
const tracerConfig = await init_1.runInit(codeql, config, sourceRoot);
|
|
||||||
if (tracerConfig !== undefined) {
|
if (tracerConfig !== undefined) {
|
||||||
for (const [key, value] of Object.entries(tracerConfig.env)) {
|
for (const [key, value] of Object.entries(tracerConfig.env)) {
|
||||||
core.exportVariable(key, value);
|
core.exportVariable(key, value);
|
||||||
@@ -127,7 +111,7 @@ async function run() {
|
|||||||
catch (error) {
|
catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
console.log(error);
|
console.log(error);
|
||||||
await actions_util_1.sendStatusReport(await actions_util_1.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, toolsVersion);
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"init-action.js","sourceRoot":"","sources":["../src/init-action.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAE7B,oDAAsC;AAEtC,iDASwB;AAGxB,iCAMgB;AAChB,2CAAuC;AACvC,uCA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EAAE,CAAC"}
|
||||||
60
lib/init.js
generated
60
lib/init.js
generated
@@ -1,25 +1,12 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
__setModuleDefault(result, mod);
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.installPythonDeps = exports.injectWindowsTracer = exports.runInit = exports.initConfig = exports.initCodeQL = void 0;
|
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
|
const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
|
||||||
@@ -29,23 +16,24 @@ 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, variant, logger) {
|
async function initCodeQL(codeqlURL, apiDetails, tempDir, toolCacheDir, mode, variant, logger) {
|
||||||
logger.startGroup("Setup CodeQL tools");
|
logger.startGroup("Setup CodeQL tools");
|
||||||
const { codeql, toolsVersion } = await codeql_1.setupCodeQL(codeqlURL, apiDetails, tempDir, toolCacheDir, variant, logger);
|
const { codeql, toolsVersion } = await codeql_1.setupCodeQL(codeqlURL, apiDetails, tempDir, toolCacheDir, mode, variant, logger);
|
||||||
await codeql.printVersion();
|
await codeql.printVersion();
|
||||||
logger.endGroup();
|
logger.endGroup();
|
||||||
return { codeql, toolsVersion };
|
return { codeql, toolsVersion };
|
||||||
}
|
}
|
||||||
exports.initCodeQL = initCodeQL;
|
exports.initCodeQL = initCodeQL;
|
||||||
async function initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, logger) {
|
async function initConfig(languagesInput, queriesInput, configFile, dbLocation, repository, tempDir, toolCacheDir, codeQL, checkoutPath, gitHubVersion, apiDetails, logger) {
|
||||||
logger.startGroup("Load language configuration");
|
logger.startGroup("Load language configuration");
|
||||||
const config = await configUtils.initConfig(languagesInput, queriesInput, packsInput, configFile, dbLocation, repository, tempDir, toolCacheDir, codeQL, workspacePath, gitHubVersion, apiDetails, logger);
|
const config = await configUtils.initConfig(languagesInput, queriesInput, configFile, dbLocation, repository, tempDir, toolCacheDir, codeQL, checkoutPath, gitHubVersion, apiDetails, logger);
|
||||||
analysisPaths.printPathFiltersWarning(config, logger);
|
analysisPaths.printPathFiltersWarning(config, logger);
|
||||||
logger.endGroup();
|
logger.endGroup();
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
exports.initConfig = initConfig;
|
exports.initConfig = initConfig;
|
||||||
async function runInit(codeql, config, sourceRoot) {
|
async function runInit(codeql, config) {
|
||||||
|
const sourceRoot = path.resolve();
|
||||||
fs.mkdirSync(config.dbLocation, { recursive: true });
|
fs.mkdirSync(config.dbLocation, { recursive: true });
|
||||||
// TODO: replace this code once CodeQL supports multi-language tracing
|
// TODO: replace this code once CodeQL supports multi-language tracing
|
||||||
for (const language of config.languages) {
|
for (const language of config.languages) {
|
||||||
@@ -141,15 +129,26 @@ exports.injectWindowsTracer = injectWindowsTracer;
|
|||||||
async function installPythonDeps(codeql, logger) {
|
async function installPythonDeps(codeql, logger) {
|
||||||
logger.startGroup("Setup Python dependencies");
|
logger.startGroup("Setup Python dependencies");
|
||||||
const scriptsFolder = path.resolve(__dirname, "../python-setup");
|
const scriptsFolder = path.resolve(__dirname, "../python-setup");
|
||||||
|
// Setup tools on the GitHub hosted runners
|
||||||
|
if (process.env["ImageOS"] !== undefined) {
|
||||||
|
try {
|
||||||
|
if (process.platform === "win32") {
|
||||||
|
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) {
|
||||||
|
// 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
|
||||||
|
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.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Install dependencies
|
||||||
try {
|
try {
|
||||||
if (process.platform === "win32") {
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
const script = "auto_install_packages.py";
|
const script = "auto_install_packages.py";
|
||||||
if (process.platform === "win32") {
|
if (process.platform === "win32") {
|
||||||
await new toolrunner.ToolRunner(await safeWhich.safeWhich("py"), [
|
await new toolrunner.ToolRunner(await safeWhich.safeWhich("py"), [
|
||||||
@@ -166,10 +165,7 @@ async function installPythonDeps(codeql, logger) {
|
|||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
logger.endGroup();
|
logger.endGroup();
|
||||||
logger.warning(`An error occurred while trying to automatically install Python dependencies: ${e}\n` +
|
logger.warning("We were unable to install your python dependencies. You can call this action with 'setup-python-dependencies: false' to disable this process.");
|
||||||
"Please make sure any necessary dependencies are installed before calling the codeql-action/analyze " +
|
|
||||||
"step, and add a 'setup-python-dependencies: false' argument to this step to disable our automatic " +
|
|
||||||
"dependency installation and avoid this warning.");
|
|
||||||
return;
|
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,KAAK,UAAU,UAAU,CAC9B,SAA6B,EAC7B,UAA4B,EAC5B,OAAe,EACf,YAAoB,EACpB,OAA2B,EAC3B,MAAc;IAEd,MAAM,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC;IACxC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,oBAAW,CAChD,SAAS,EACT,UAAU,EACV,OAAO,EACP,Y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ACZ,mLAAmL,CACpL,CAAC;YACF,OAAO;SACR;KACF;IAED,uBAAuB;IACvB,IAAI;QACF,MAAM,MAAM,GAAG,0BAA0B,CAAC;QAC1C,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE;YAChC,MAAM,IAAI,UAAU,CAAC,UAAU,CAAC,MAAM,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE;gBAC/D,IAAI;gBACJ,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC;gBAChC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;aAC/B,CAAC,CAAC,IAAI,EAAE,CAAC;SACX;aAAM;YACL,MAAM,IAAI,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC,EAAE;gBAChE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;aAC/B,CAAC,CAAC,IAAI,EAAE,CAAC;SACX;KACF;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,CAAC,QAAQ,EAAE,CAAC;QAClB,MAAM,CAAC,OAAO,CACZ,+IAA+I,CAChJ,CAAC;QACF,OAAO;KACR;IACD,MAAM,CAAC,QAAQ,EAAE,CAAC;AACpB,CAAC;AAnDD,8CAmDC"}
|
||||||
2
lib/languages.js
generated
2
lib/languages.js
generated
@@ -1,6 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.isScannedLanguage = exports.isTracedLanguage = exports.parseLanguage = exports.Language = void 0;
|
|
||||||
// All the languages supported by CodeQL
|
// All the languages supported by CodeQL
|
||||||
var Language;
|
var Language;
|
||||||
(function (Language) {
|
(function (Language) {
|
||||||
@@ -10,7 +9,6 @@ var Language;
|
|||||||
Language["java"] = "java";
|
Language["java"] = "java";
|
||||||
Language["javascript"] = "javascript";
|
Language["javascript"] = "javascript";
|
||||||
Language["python"] = "python";
|
Language["python"] = "python";
|
||||||
Language["ruby"] = "ruby";
|
|
||||||
})(Language = exports.Language || (exports.Language = {}));
|
})(Language = exports.Language || (exports.Language = {}));
|
||||||
// Additional names for languages
|
// Additional names for languages
|
||||||
const LANGUAGE_ALIASES = {
|
const LANGUAGE_ALIASES = {
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"languages.js","sourceRoot":"","sources":["../src/languages.ts"],"names":[],"mappings":";;;AAAA,wCAAwC;AACxC,IAAY,QAQX;AARD,WAAY,QAAQ;IAClB,6BAAiB,CAAA;IACjB,uBAAW,CAAA;IACX,qBAAS,CAAA;IACT,yBAAa,CAAA;IACb,qCAAyB,CAAA;IACzB,6BAAiB,CAAA;IACjB,yBAAa,CAAA;AACf,CAAC,EARW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAQnB;AAED,iCAAiC;AACjC,MAAM,gBAAgB,GAAiC;IACrD,CAAC,EAAE,QAAQ,CAAC,GAAG;IACf,KAAK,EAAE,QAAQ,CAAC,GAAG;IACnB,IAAI,EAAE,QAAQ,CAAC,MAAM;IACrB,UAAU,EAAE,QAAQ,CAAC,UAAU;CAChC,CAAC;AAEF,gGAAgG;AAChG,SAAgB,aAAa,CAAC,QAAgB;IAC5C,0BAA0B;IAC1B,QAAQ,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;IAElC,6BAA6B;IAC7B,IAAI,QAAQ,IAAI,QAAQ,EAAE;QACxB,OAAO,QAAoB,CAAC;KAC7B;IAED,yBAAyB;IACzB,IAAI,QAAQ,IAAI,gBAAgB,EAAE;QAChC,OAAO,gBAAgB,CAAC,QAAQ,CAAC,CAAC;KACnC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAfD,sCAeC;AAED,SAAgB,gBAAgB,CAAC,QAAkB;IACjD,OAAO,CACL,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,QAAQ,C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AC,QAAQ,CAAC;QAC5C,CAAC,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,KAAK,IAAI;YACxD,QAAQ,KAAK,QAAQ,CAAC,EAAE,CAAC,CAC5B,CAAC;AACJ,CAAC;AAND,4CAMC;AAED,SAAgB,iBAAiB,CAAC,QAAkB;IAClD,OAAO,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;AACrC,CAAC;AAFD,8CAEC"}
|
||||||
17
lib/logging.js
generated
17
lib/logging.js
generated
@@ -1,25 +1,12 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
__setModuleDefault(result, mod);
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.getRunnerLogger = exports.getActionsLogger = void 0;
|
|
||||||
const core = __importStar(require("@actions/core"));
|
const core = __importStar(require("@actions/core"));
|
||||||
function getActionsLogger() {
|
function getActionsLogger() {
|
||||||
return core;
|
return core;
|
||||||
|
|||||||
@@ -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;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"}
|
||||||
1
lib/repository.js
generated
1
lib/repository.js
generated
@@ -1,6 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.parseRepositoryNwo = void 0;
|
|
||||||
function parseRepositoryNwo(input) {
|
function parseRepositoryNwo(input) {
|
||||||
const parts = input.split("/");
|
const parts = input.split("/");
|
||||||
if (parts.length !== 2) {
|
if (parts.length !== 2) {
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"repository.js","sourceRoot":"","sources":["../src/repository.ts"],"names":[],"mappings":";;;AAMA,SAAgB,kBAAkB,CAAC,KAAa;IAC9C,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC/B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;QACtB,MAAM,IAAI,KAAK,CAAC,IAAI,KAAK,kCAAkC,CAAC,CAAC;KAC9D;IACD,OAAO;QACL,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;QACf,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;KACf,CAAC;AACJ,CAAC;AATD,gDASC"}
|
{"version":3,"file":"repository.js","sourceRoot":"","sources":["../src/repository.ts"],"names":[],"mappings":";;AAMA,SAAgB,kBAAkB,CAAC,KAAa;IAC9C,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC/B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;QACtB,MAAM,IAAI,KAAK,CAAC,IAAI,KAAK,kCAAkC,CAAC,CAAC;KAC9D;IACD,OAAO;QACL,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;QACf,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;KACf,CAAC;AACJ,CAAC;AATD,gDASC"}
|
||||||
49
lib/runner.js
generated
49
lib/runner.js
generated
@@ -1,21 +1,9 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
__setModuleDefault(result, mod);
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
@@ -33,12 +21,8 @@ const logging_1 = require("./logging");
|
|||||||
const repository_1 = require("./repository");
|
const repository_1 = require("./repository");
|
||||||
const upload_lib = __importStar(require("./upload-lib"));
|
const upload_lib = __importStar(require("./upload-lib"));
|
||||||
const util_1 = require("./util");
|
const util_1 = require("./util");
|
||||||
// eslint-disable-next-line import/no-commonjs
|
|
||||||
const pkg = require("../package.json");
|
|
||||||
const program = new commander_1.Command();
|
const program = new commander_1.Command();
|
||||||
program.version(pkg.version).hook("preAction", () => {
|
program.version("0.0.1");
|
||||||
util_1.initializeEnvironment(util_1.Mode.runner, pkg.version);
|
|
||||||
});
|
|
||||||
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)) {
|
||||||
@@ -102,12 +86,6 @@ program
|
|||||||
.option("--github-auth-stdin", "Read GitHub Apps token or personal access token from stdin.")
|
.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("--packs <packs>", `[Experimental] Comma-separated list of packs to run. Reference a pack in the format scope/name[@version]. If version is not
|
|
||||||
specified, then the latest version of the pack is used. By default, this overrides the same setting in a
|
|
||||||
configuration file; prefix with "+" to use both sets of packs.
|
|
||||||
|
|
||||||
This option is only available in single-language analyses. To use packs in multi-language
|
|
||||||
analyses, you must specify packs in the codeql-config.yml file.`)
|
|
||||||
.option("--config-file <file>", "Path to config file.")
|
.option("--config-file <file>", "Path to config file.")
|
||||||
.option("--codeql-path <path>", "Path to a copy of the CodeQL CLI executable to use. Otherwise downloads a copy.")
|
.option("--codeql-path <path>", "Path to a copy of the CodeQL CLI executable to use. Otherwise downloads a copy.")
|
||||||
.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".')
|
||||||
@@ -121,7 +99,6 @@ program
|
|||||||
try {
|
try {
|
||||||
const tempDir = getTempDir(cmd.tempDir);
|
const tempDir = getTempDir(cmd.tempDir);
|
||||||
const toolsDir = getToolsDir(cmd.toolsDir);
|
const toolsDir = getToolsDir(cmd.toolsDir);
|
||||||
const checkoutPath = cmd.checkoutPath || process.cwd();
|
|
||||||
// Wipe the temp dir
|
// Wipe the temp dir
|
||||||
logger.info(`Cleaning temp directory ${tempDir}`);
|
logger.info(`Cleaning temp directory ${tempDir}`);
|
||||||
fs.rmdirSync(tempDir, { recursive: true });
|
fs.rmdirSync(tempDir, { recursive: true });
|
||||||
@@ -133,18 +110,16 @@ program
|
|||||||
url: util_1.parseGitHubUrl(cmd.githubUrl),
|
url: util_1.parseGitHubUrl(cmd.githubUrl),
|
||||||
};
|
};
|
||||||
const gitHubVersion = await util_1.getGitHubVersion(apiDetails);
|
const gitHubVersion = await util_1.getGitHubVersion(apiDetails);
|
||||||
util_1.checkGitHubVersionInRange(gitHubVersion, logger, util_1.Mode.runner);
|
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, gitHubVersion.type, logger)).codeql;
|
codeql = (await init_1.initCodeQL(undefined, apiDetails, tempDir, toolsDir, "runner", gitHubVersion.type, logger)).codeql;
|
||||||
}
|
}
|
||||||
const workspacePath = checkoutPath;
|
const config = await init_1.initConfig(cmd.languages, cmd.queries, cmd.configFile, undefined, 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.packs, cmd.configFile, undefined, repository_1.parseRepositoryNwo(cmd.repository), tempDir, toolsDir, codeql, workspacePath, gitHubVersion, apiDetails, logger);
|
const tracerConfig = await init_1.runInit(codeql, config);
|
||||||
const sourceRoot = checkoutPath;
|
|
||||||
const tracerConfig = await init_1.runInit(codeql, config, sourceRoot);
|
|
||||||
if (tracerConfig === undefined) {
|
if (tracerConfig === undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -258,15 +233,12 @@ program
|
|||||||
url: util_1.parseGitHubUrl(cmd.githubUrl),
|
url: util_1.parseGitHubUrl(cmd.githubUrl),
|
||||||
};
|
};
|
||||||
const outputDir = cmd.outputDir || path.join(config.tempDir, "codeql-sarif");
|
const outputDir = cmd.outputDir || path.join(config.tempDir, "codeql-sarif");
|
||||||
const threads = util_1.getThreadsFlag(cmd.threads, logger);
|
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);
|
||||||
await analyze_1.runFinalize(outputDir, threads, config, logger);
|
|
||||||
await analyze_1.runQueries(outputDir, util_1.getMemoryFlag(cmd.ram), util_1.getAddSnippetsFlag(cmd.addSnippets), threads, cmd.category, config, logger);
|
|
||||||
if (!cmd.upload) {
|
if (!cmd.upload) {
|
||||||
logger.info("Not uploading results");
|
logger.info("Not uploading results");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const sourceRoot = cmd.checkoutPath || process.cwd();
|
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);
|
||||||
await upload_lib.uploadFromRunner(outputDir, repository_1.parseRepositoryNwo(cmd.repository), cmd.commit, parseRef(cmd.ref), cmd.category, sourceRoot, config.gitHubVersion, apiDetails, logger);
|
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
logger.error("Analyze failed");
|
logger.error("Analyze failed");
|
||||||
@@ -296,8 +268,7 @@ program
|
|||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
const gitHubVersion = await util_1.getGitHubVersion(apiDetails);
|
const gitHubVersion = await util_1.getGitHubVersion(apiDetails);
|
||||||
const sourceRoot = cmd.checkoutPath || process.cwd();
|
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);
|
||||||
await upload_lib.uploadFromRunner(cmd.sarifFile, repository_1.parseRepositoryNwo(cmd.repository), cmd.commit, parseRef(cmd.ref), cmd.category, sourceRoot, 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
1
lib/shared-environment.js
generated
1
lib/shared-environment.js
generated
@@ -1,6 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.CODEQL_WORKFLOW_STARTED_AT = exports.ODASA_TRACER_CONFIGURATION = void 0;
|
|
||||||
exports.ODASA_TRACER_CONFIGURATION = "ODASA_TRACER_CONFIGURATION";
|
exports.ODASA_TRACER_CONFIGURATION = "ODASA_TRACER_CONFIGURATION";
|
||||||
// The time at which the first action (normally init) started executing.
|
// The time at which the first action (normally init) started executing.
|
||||||
// If a workflow invokes a different action without first invoking the init
|
// If a workflow invokes a different action without first invoking the init
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"shared-environment.js","sourceRoot":"","sources":["../src/shared-environment.ts"],"names":[],"mappings":";;;AAAa,QAAA,0BAA0B,GAAG,4BAA4B,CAAC;AACvE,wEAAwE;AACxE,2EAA2E;AAC3E,4EAA4E;AAC5E,2EAA2E;AAC3E,+BAA+B;AAClB,QAAA,0BAA0B,GAAG,4BAA4B,CAAC"}
|
{"version":3,"file":"shared-environment.js","sourceRoot":"","sources":["../src/shared-environment.ts"],"names":[],"mappings":";;AAAa,QAAA,0BAA0B,GAAG,4BAA4B,CAAC;AACvE,wEAAwE;AACxE,2EAA2E;AAC3E,4EAA4E;AAC5E,2EAA2E;AAC3E,+BAA+B;AAClB,QAAA,0BAA0B,GAAG,4BAA4B,CAAC"}
|
||||||
27
lib/testing-utils.js
generated
27
lib/testing-utils.js
generated
@@ -1,28 +1,15 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
||||||
__setModuleDefault(result, mod);
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
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 });
|
||||||
exports.setupActionsVars = exports.setupTests = void 0;
|
|
||||||
const sinon_1 = __importDefault(require("sinon"));
|
const sinon_1 = __importDefault(require("sinon"));
|
||||||
const CodeQL = __importStar(require("./codeql"));
|
const CodeQL = __importStar(require("./codeql"));
|
||||||
function wrapOutput(context) {
|
function wrapOutput(context) {
|
||||||
|
|||||||
@@ -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,C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1D,OAAO,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC;QAC7C,OAAO,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC;QAC7C,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE;YACb,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;SAC5C;QAED,uCAAuC;QACvC,eAAK,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;AAED,yEAAyE;AACzE,sDAAsD;AACtD,SAAgB,gBAAgB,CAAC,OAAe,EAAE,QAAgB;IAChE,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,GAAG,OAAO,CAAC;IACrC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,GAAG,QAAQ,CAAC;AAC9C,CAAC;AAHD,4CAGC"}
|
||||||
44
lib/toolcache.js
generated
44
lib/toolcache.js
generated
@@ -1,25 +1,12 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
__setModuleDefault(result, mod);
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.downloadTool = exports.findAllVersions = exports.find = exports.cacheDir = exports.extractTar = void 0;
|
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const os = __importStar(require("os"));
|
const os = __importStar(require("os"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
@@ -28,8 +15,6 @@ const io = __importStar(require("@actions/io"));
|
|||||||
const actionsToolcache = __importStar(require("@actions/tool-cache"));
|
const actionsToolcache = __importStar(require("@actions/tool-cache"));
|
||||||
const safeWhich = __importStar(require("@chrisgavin/safe-which"));
|
const safeWhich = __importStar(require("@chrisgavin/safe-which"));
|
||||||
const semver = __importStar(require("semver"));
|
const semver = __importStar(require("semver"));
|
||||||
const uuid_1 = require("uuid");
|
|
||||||
const util_1 = require("./util");
|
|
||||||
/*
|
/*
|
||||||
* This file acts as an interface to the functionality of the actions toolcache.
|
* 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
|
* That library is not safe to use outside of actions as it makes assumptions about
|
||||||
@@ -49,8 +34,8 @@ const util_1 = require("./util");
|
|||||||
* @param logger logger to use
|
* @param logger logger to use
|
||||||
* @returns path to the destination directory
|
* @returns path to the destination directory
|
||||||
*/
|
*/
|
||||||
async function extractTar(file, tempDir, logger) {
|
async function extractTar(file, mode, tempDir, logger) {
|
||||||
if (util_1.isActions()) {
|
if (mode === "actions") {
|
||||||
return await actionsToolcache.extractTar(file);
|
return await actionsToolcache.extractTar(file);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -109,8 +94,8 @@ exports.extractTar = extractTar;
|
|||||||
* @param toolCacheDir path to the tool cache directory
|
* @param toolCacheDir path to the tool cache directory
|
||||||
* @param logger logger to use
|
* @param logger logger to use
|
||||||
*/
|
*/
|
||||||
async function cacheDir(sourceDir, tool, version, toolCacheDir, logger) {
|
async function cacheDir(sourceDir, tool, version, mode, toolCacheDir, logger) {
|
||||||
if (util_1.isActions()) {
|
if (mode === "actions") {
|
||||||
return await actionsToolcache.cacheDir(sourceDir, tool, version);
|
return await actionsToolcache.cacheDir(sourceDir, tool, version);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -147,8 +132,8 @@ exports.cacheDir = cacheDir;
|
|||||||
* @param toolCacheDir path to the tool cache directory
|
* @param toolCacheDir path to the tool cache directory
|
||||||
* @param logger logger to use
|
* @param logger logger to use
|
||||||
*/
|
*/
|
||||||
function find(toolName, versionSpec, toolCacheDir, logger) {
|
function find(toolName, versionSpec, mode, toolCacheDir, logger) {
|
||||||
if (util_1.isActions()) {
|
if (mode === "actions") {
|
||||||
return actionsToolcache.find(toolName, versionSpec);
|
return actionsToolcache.find(toolName, versionSpec);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -162,7 +147,7 @@ function find(toolName, versionSpec, toolCacheDir, logger) {
|
|||||||
const arch = os.arch();
|
const arch = os.arch();
|
||||||
// attempt to resolve an explicit version
|
// attempt to resolve an explicit version
|
||||||
if (!isExplicitVersion(versionSpec, logger)) {
|
if (!isExplicitVersion(versionSpec, logger)) {
|
||||||
const localVersions = findAllVersions(toolName, toolCacheDir, logger);
|
const localVersions = findAllVersions(toolName, mode, toolCacheDir, logger);
|
||||||
const match = evaluateVersions(localVersions, versionSpec, logger);
|
const match = evaluateVersions(localVersions, versionSpec, logger);
|
||||||
versionSpec = match;
|
versionSpec = match;
|
||||||
}
|
}
|
||||||
@@ -190,11 +175,12 @@ exports.find = find;
|
|||||||
* Also see findAllVersions function from node_modules/@actions/tool-cache/lib/tool-cache.d.ts
|
* Also see findAllVersions function from node_modules/@actions/tool-cache/lib/tool-cache.d.ts
|
||||||
*
|
*
|
||||||
* @param toolName name of the tool
|
* @param toolName name of the tool
|
||||||
|
* @param mode should run the actions or runner implementation
|
||||||
* @param toolCacheDir path to the tool cache directory
|
* @param toolCacheDir path to the tool cache directory
|
||||||
* @param logger logger to use
|
* @param logger logger to use
|
||||||
*/
|
*/
|
||||||
function findAllVersions(toolName, toolCacheDir, logger) {
|
function findAllVersions(toolName, mode, toolCacheDir, logger) {
|
||||||
if (util_1.isActions()) {
|
if (mode === "actions") {
|
||||||
return actionsToolcache.findAllVersions(toolName);
|
return actionsToolcache.findAllVersions(toolName);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -218,12 +204,6 @@ function findAllVersions(toolName, toolCacheDir, logger) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.findAllVersions = findAllVersions;
|
exports.findAllVersions = findAllVersions;
|
||||||
async function downloadTool(url, tempDir, headers) {
|
|
||||||
const dest = path.join(tempDir, uuid_1.v4());
|
|
||||||
const finalHeaders = Object.assign({ "User-Agent": "CodeQL Action" }, headers);
|
|
||||||
return await actionsToolcache.downloadTool(url, dest, undefined, finalHeaders);
|
|
||||||
}
|
|
||||||
exports.downloadTool = downloadTool;
|
|
||||||
function createExtractFolder(tempDir) {
|
function createExtractFolder(tempDir) {
|
||||||
// create a temp dir
|
// create a temp dir
|
||||||
const dest = path.join(tempDir, "toolcache-temp");
|
const dest = path.join(tempDir, "toolcache-temp");
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
35
lib/toolrunner-error-catcher.js
generated
35
lib/toolrunner-error-catcher.js
generated
@@ -1,25 +1,12 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
__setModuleDefault(result, mod);
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.toolrunnerErrorCatcher = void 0;
|
|
||||||
const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
|
const toolrunner = __importStar(require("@actions/exec/lib/toolrunner"));
|
||||||
const safeWhich = __importStar(require("@chrisgavin/safe-which"));
|
const safeWhich = __importStar(require("@chrisgavin/safe-which"));
|
||||||
/**
|
/**
|
||||||
@@ -34,14 +21,14 @@ const safeWhich = __importStar(require("@chrisgavin/safe-which"));
|
|||||||
* @returns Promise<number> exit code
|
* @returns Promise<number> exit code
|
||||||
*/
|
*/
|
||||||
async function toolrunnerErrorCatcher(commandLine, args, matchers, options) {
|
async function toolrunnerErrorCatcher(commandLine, args, matchers, options) {
|
||||||
var _a, _b;
|
var _a, _b, _c;
|
||||||
let stdout = "";
|
let stdout = "";
|
||||||
let stderr = "";
|
let stderr = "";
|
||||||
const listeners = {
|
const listeners = {
|
||||||
stdout: (data) => {
|
stdout: (data) => {
|
||||||
var _a;
|
var _a, _b;
|
||||||
stdout += data.toString();
|
stdout += data.toString();
|
||||||
if (((_a = options === null || options === void 0 ? void 0 : options.listeners) === null || _a === void 0 ? void 0 : _a.stdout) !== undefined) {
|
if (((_b = (_a = options) === null || _a === void 0 ? void 0 : _a.listeners) === null || _b === void 0 ? void 0 : _b.stdout) !== undefined) {
|
||||||
options.listeners.stdout(data);
|
options.listeners.stdout(data);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -50,9 +37,9 @@ async function toolrunnerErrorCatcher(commandLine, args, matchers, options) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
stderr: (data) => {
|
stderr: (data) => {
|
||||||
var _a;
|
var _a, _b;
|
||||||
stderr += data.toString();
|
stderr += data.toString();
|
||||||
if (((_a = options === null || options === void 0 ? void 0 : options.listeners) === null || _a === void 0 ? void 0 : _a.stderr) !== undefined) {
|
if (((_b = (_a = options) === null || _a === void 0 ? void 0 : _a.listeners) === null || _b === void 0 ? void 0 : _b.stderr) !== undefined) {
|
||||||
options.listeners.stderr(data);
|
options.listeners.stderr(data);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -67,7 +54,7 @@ async function toolrunnerErrorCatcher(commandLine, args, matchers, options) {
|
|||||||
returnState = await new toolrunner.ToolRunner(await safeWhich.safeWhich(commandLine), args, {
|
returnState = await new toolrunner.ToolRunner(await safeWhich.safeWhich(commandLine), args, {
|
||||||
...options,
|
...options,
|
||||||
listeners,
|
listeners,
|
||||||
ignoreReturnCode: true, // so we can check for specific codes using the matchers
|
ignoreReturnCode: true,
|
||||||
}).exec();
|
}).exec();
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
@@ -78,16 +65,14 @@ async function toolrunnerErrorCatcher(commandLine, args, matchers, options) {
|
|||||||
return returnState;
|
return returnState;
|
||||||
if (matchers) {
|
if (matchers) {
|
||||||
for (const matcher of matchers) {
|
for (const matcher of matchers) {
|
||||||
if (matcher.exitCode === returnState ||
|
if (matcher.exitCode === returnState || ((_a = matcher.outputRegex) === null || _a === void 0 ? void 0 : _a.test(stderr)) || ((_b = matcher.outputRegex) === null || _b === void 0 ? void 0 : _b.test(stdout))) {
|
||||||
((_a = matcher.outputRegex) === null || _a === void 0 ? void 0 : _a.test(stderr)) ||
|
|
||||||
((_b = matcher.outputRegex) === null || _b === void 0 ? void 0 : _b.test(stdout))) {
|
|
||||||
throw new Error(matcher.message);
|
throw new Error(matcher.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (typeof returnState === "number") {
|
if (typeof returnState === "number") {
|
||||||
// only if we were instructed to ignore the return code do we ever return it non-zero
|
// only if we were instructed to ignore the return code do we ever return it non-zero
|
||||||
if (options === null || options === void 0 ? void 0 : options.ignoreReturnCode) {
|
if ((_c = options) === null || _c === void 0 ? void 0 : _c.ignoreReturnCode) {
|
||||||
return returnState;
|
return 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,SAAS,GAAG;QAChB,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE;;YACvB,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC1B,IAA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test.js
generated
@@ -1,21 +1,9 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
__setModuleDefault(result, mod);
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
@@ -42,7 +30,7 @@ ava_1.default("regex matchers are applied to stdout for non-zero exit code", asy
|
|||||||
];
|
];
|
||||||
await t.throwsAsync(exec.exec("node", testArgs), {
|
await t.throwsAsync(exec.exec("node", testArgs), {
|
||||||
instanceOf: Error,
|
instanceOf: Error,
|
||||||
message: /failed with exit code 1/,
|
message: "The process 'node' failed with exit code 1",
|
||||||
});
|
});
|
||||||
await t.throwsAsync(toolrunner_error_catcher_1.toolrunnerErrorCatcher("node", testArgs, matchers), {
|
await t.throwsAsync(toolrunner_error_catcher_1.toolrunnerErrorCatcher("node", testArgs, matchers), {
|
||||||
instanceOf: Error,
|
instanceOf: Error,
|
||||||
@@ -56,7 +44,7 @@ ava_1.default("regex matchers are applied to stderr for non-zero exit code", asy
|
|||||||
];
|
];
|
||||||
await t.throwsAsync(exec.exec("node", testArgs), {
|
await t.throwsAsync(exec.exec("node", testArgs), {
|
||||||
instanceOf: Error,
|
instanceOf: Error,
|
||||||
message: /failed with exit code 1/,
|
message: "The process 'node' failed with exit code 1",
|
||||||
});
|
});
|
||||||
await t.throwsAsync(toolrunner_error_catcher_1.toolrunnerErrorCatcher("node", testArgs, matchers), {
|
await t.throwsAsync(toolrunner_error_catcher_1.toolrunnerErrorCatcher("node", testArgs, matchers), {
|
||||||
instanceOf: Error,
|
instanceOf: Error,
|
||||||
@@ -72,7 +60,7 @@ ava_1.default("matcher returns correct error message when multiple matchers defi
|
|||||||
];
|
];
|
||||||
await t.throwsAsync(exec.exec("node", testArgs), {
|
await t.throwsAsync(exec.exec("node", testArgs), {
|
||||||
instanceOf: Error,
|
instanceOf: Error,
|
||||||
message: /failed with exit code 1/,
|
message: "The process 'node' failed with exit code 1",
|
||||||
});
|
});
|
||||||
await t.throwsAsync(toolrunner_error_catcher_1.toolrunnerErrorCatcher("node", testArgs, matchers), {
|
await t.throwsAsync(toolrunner_error_catcher_1.toolrunnerErrorCatcher("node", testArgs, matchers), {
|
||||||
instanceOf: Error,
|
instanceOf: Error,
|
||||||
@@ -88,7 +76,7 @@ ava_1.default("matcher returns first match to regex when multiple matches", asyn
|
|||||||
];
|
];
|
||||||
await t.throwsAsync(exec.exec("node", testArgs), {
|
await t.throwsAsync(exec.exec("node", testArgs), {
|
||||||
instanceOf: Error,
|
instanceOf: Error,
|
||||||
message: /failed with exit code 1/,
|
message: "The process 'node' failed with exit code 1",
|
||||||
});
|
});
|
||||||
await t.throwsAsync(toolrunner_error_catcher_1.toolrunnerErrorCatcher("node", testArgs, matchers), {
|
await t.throwsAsync(toolrunner_error_catcher_1.toolrunnerErrorCatcher("node", testArgs, matchers), {
|
||||||
instanceOf: Error,
|
instanceOf: Error,
|
||||||
@@ -106,7 +94,7 @@ ava_1.default("exit code matchers are applied", async (t) => {
|
|||||||
];
|
];
|
||||||
await t.throwsAsync(exec.exec("node", testArgs), {
|
await t.throwsAsync(exec.exec("node", testArgs), {
|
||||||
instanceOf: Error,
|
instanceOf: Error,
|
||||||
message: /failed with exit code 123/,
|
message: "The process 'node' failed with exit code 123",
|
||||||
});
|
});
|
||||||
await t.throwsAsync(toolrunner_error_catcher_1.toolrunnerErrorCatcher("node", testArgs, matchers), {
|
await t.throwsAsync(toolrunner_error_catcher_1.toolrunnerErrorCatcher("node", testArgs, matchers), {
|
||||||
instanceOf: Error,
|
instanceOf: Error,
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
17
lib/tracer-config.js
generated
17
lib/tracer-config.js
generated
@@ -1,25 +1,12 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
__setModuleDefault(result, mod);
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.getCombinedTracerConfig = exports.concatTracerConfigs = exports.getTracerConfigForLanguage = void 0;
|
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const languages_1 = require("./languages");
|
const languages_1 = require("./languages");
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
17
lib/tracer-config.test.js
generated
17
lib/tracer-config.test.js
generated
@@ -1,21 +1,9 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
__setModuleDefault(result, mod);
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
@@ -43,7 +31,6 @@ function getTestConfig(tmpDir) {
|
|||||||
codeQLCmd: "",
|
codeQLCmd: "",
|
||||||
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
gitHubVersion: { type: util.GitHubVariant.DOTCOM },
|
||||||
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
dbLocation: path.resolve(tmpDir, "codeql_databases"),
|
||||||
packs: {},
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// A very minimal setup
|
// A very minimal setup
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
43
lib/upload-lib.js
generated
43
lib/upload-lib.js
generated
@@ -1,28 +1,15 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
__setModuleDefault(result, mod);
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
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 };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.buildPayload = exports.validateSarifFileSchema = exports.countResultsInSarif = exports.uploadFromRunner = exports.uploadFromActions = exports.findSarifFilesInDir = exports.populateRunAutomationDetails = exports.combineSarifFiles = void 0;
|
|
||||||
const fs = __importStar(require("fs"));
|
const fs = __importStar(require("fs"));
|
||||||
const path = __importStar(require("path"));
|
const path = __importStar(require("path"));
|
||||||
const zlib_1 = __importDefault(require("zlib"));
|
const zlib_1 = __importDefault(require("zlib"));
|
||||||
@@ -87,7 +74,7 @@ function getAutomationID(category, 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, logger) {
|
async function uploadPayload(payload, repositoryNwo, apiDetails, 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;
|
||||||
@@ -95,7 +82,7 @@ async function uploadPayload(payload, repositoryNwo, apiDetails, logger) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const client = api.getApiClient(apiDetails);
|
const client = api.getApiClient(apiDetails);
|
||||||
const reqURL = util.isActions()
|
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";
|
||||||
const response = await client.request(reqURL, {
|
const response = await client.request(reqURL, {
|
||||||
@@ -129,14 +116,14 @@ exports.findSarifFilesInDir = findSarifFilesInDir;
|
|||||||
// depending on what the path happens to refer to.
|
// depending on what the path happens to refer to.
|
||||||
// Returns true iff the upload occurred and succeeded
|
// Returns true iff the upload occurred and succeeded
|
||||||
async function uploadFromActions(sarifPath, gitHubVersion, apiDetails, logger) {
|
async function uploadFromActions(sarifPath, gitHubVersion, apiDetails, logger) {
|
||||||
return await uploadFiles(getSarifFilePaths(sarifPath), repository_1.parseRepositoryNwo(util.getRequiredEnvParam("GITHUB_REPOSITORY")), await actionsUtil.getCommitOid(), await actionsUtil.getRef(), await actionsUtil.getAnalysisKey(), actionsUtil.getOptionalInput("category"), util.getRequiredEnvParam("GITHUB_WORKFLOW"), actionsUtil.getWorkflowRunID(), actionsUtil.getRequiredInput("checkout_path"), actionsUtil.getRequiredInput("matrix"), 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;
|
exports.uploadFromActions = uploadFromActions;
|
||||||
// Uploads a single sarif file or a directory of sarif files
|
// Uploads a single sarif file or a directory of sarif files
|
||||||
// depending on what the path happens to refer to.
|
// depending on what the path happens to refer to.
|
||||||
// Returns true iff the upload occurred and succeeded
|
// Returns true iff the upload occurred and succeeded
|
||||||
async function uploadFromRunner(sarifPath, repositoryNwo, commitOid, ref, category, sourceRoot, gitHubVersion, apiDetails, logger) {
|
async function uploadFromRunner(sarifPath, repositoryNwo, commitOid, ref, category, checkoutPath, gitHubVersion, apiDetails, logger) {
|
||||||
return await uploadFiles(getSarifFilePaths(sarifPath), repositoryNwo, commitOid, ref, undefined, category, undefined, undefined, sourceRoot, undefined, gitHubVersion, apiDetails, logger);
|
return await uploadFiles(getSarifFilePaths(sarifPath), repositoryNwo, commitOid, ref, undefined, category, undefined, undefined, checkoutPath, undefined, gitHubVersion, apiDetails, "runner", logger);
|
||||||
}
|
}
|
||||||
exports.uploadFromRunner = uploadFromRunner;
|
exports.uploadFromRunner = uploadFromRunner;
|
||||||
function getSarifFilePaths(sarifPath) {
|
function getSarifFilePaths(sarifPath) {
|
||||||
@@ -199,8 +186,8 @@ function validateSarifFileSchema(sarifFilePath, logger) {
|
|||||||
exports.validateSarifFileSchema = validateSarifFileSchema;
|
exports.validateSarifFileSchema = validateSarifFileSchema;
|
||||||
// buildPayload constructs a map ready to be uploaded to the API from the given
|
// buildPayload constructs a map ready to be uploaded to the API from the given
|
||||||
// parameters, respecting the current mode and target GitHub instance version.
|
// parameters, respecting the current mode and target GitHub instance version.
|
||||||
function buildPayload(commitOid, ref, analysisKey, analysisName, zippedSarif, workflowRunID, checkoutURI, environment, toolNames, gitHubVersion) {
|
function buildPayload(commitOid, ref, analysisKey, analysisName, zippedSarif, workflowRunID, checkoutURI, environment, toolNames, gitHubVersion, mode) {
|
||||||
if (util.isActions()) {
|
if (mode === "actions") {
|
||||||
const payloadObj = {
|
const payloadObj = {
|
||||||
commit_oid: commitOid,
|
commit_oid: commitOid,
|
||||||
ref,
|
ref,
|
||||||
@@ -240,10 +227,10 @@ function buildPayload(commitOid, ref, analysisKey, analysisName, zippedSarif, wo
|
|||||||
exports.buildPayload = buildPayload;
|
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, sourceRoot, environment, gitHubVersion, apiDetails, logger) {
|
async function uploadFiles(sarifFiles, repositoryNwo, commitOid, ref, analysisKey, category, analysisName, workflowRunID, checkoutPath, environment, gitHubVersion, apiDetails, mode, logger) {
|
||||||
logger.startGroup("Uploading results");
|
logger.startGroup("Uploading results");
|
||||||
logger.info(`Processing sarif files: ${JSON.stringify(sarifFiles)}`);
|
logger.info(`Processing sarif files: ${JSON.stringify(sarifFiles)}`);
|
||||||
if (util.isActions()) {
|
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
|
||||||
const sentinelEnvVar = "CODEQL_UPLOAD_SARIF";
|
const sentinelEnvVar = "CODEQL_UPLOAD_SARIF";
|
||||||
if (process.env[sentinelEnvVar]) {
|
if (process.env[sentinelEnvVar]) {
|
||||||
@@ -256,12 +243,12 @@ async function uploadFiles(sarifFiles, repositoryNwo, commitOid, ref, analysisKe
|
|||||||
validateSarifFileSchema(file, logger);
|
validateSarifFileSchema(file, logger);
|
||||||
}
|
}
|
||||||
let sarifPayload = combineSarifFiles(sarifFiles);
|
let sarifPayload = combineSarifFiles(sarifFiles);
|
||||||
sarifPayload = await fingerprints.addFingerprints(sarifPayload, sourceRoot, logger);
|
sarifPayload = fingerprints.addFingerprints(sarifPayload, checkoutPath, logger);
|
||||||
sarifPayload = populateRunAutomationDetails(sarifPayload, category, analysisKey, environment);
|
sarifPayload = populateRunAutomationDetails(sarifPayload, category, analysisKey, environment);
|
||||||
const zippedSarif = zlib_1.default.gzipSync(sarifPayload).toString("base64");
|
const zippedSarif = zlib_1.default.gzipSync(sarifPayload).toString("base64");
|
||||||
const checkoutURI = file_url_1.default(sourceRoot);
|
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);
|
const payload = buildPayload(commitOid, ref, analysisKey, analysisName, zippedSarif, workflowRunID, checkoutURI, environment, toolNames, gitHubVersion, mode);
|
||||||
// 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`);
|
||||||
@@ -270,7 +257,7 @@ async function uploadFiles(sarifFiles, repositoryNwo, commitOid, ref, analysisKe
|
|||||||
const numResultInSarif = countResultsInSarif(sarifPayload);
|
const numResultInSarif = countResultsInSarif(sarifPayload);
|
||||||
logger.debug(`Number of results in upload: ${numResultInSarif}`);
|
logger.debug(`Number of results in upload: ${numResultInSarif}`);
|
||||||
// Make the upload
|
// Make the upload
|
||||||
await uploadPayload(payload, repositoryNwo, apiDetails, logger);
|
await uploadPayload(payload, repositoryNwo, apiDetails, mode, logger);
|
||||||
logger.endGroup();
|
logger.endGroup();
|
||||||
return {
|
return {
|
||||||
raw_upload_size_bytes: rawUploadSizeBytes,
|
raw_upload_size_bytes: rawUploadSizeBytes,
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
25
lib/upload-lib.test.js
generated
25
lib/upload-lib.test.js
generated
@@ -1,21 +1,9 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
__setModuleDefault(result, mod);
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
@@ -30,9 +18,6 @@ const testing_utils_1 = require("./testing-utils");
|
|||||||
const uploadLib = __importStar(require("./upload-lib"));
|
const uploadLib = __importStar(require("./upload-lib"));
|
||||||
const util_1 = require("./util");
|
const util_1 = require("./util");
|
||||||
testing_utils_1.setupTests(ava_1.default);
|
testing_utils_1.setupTests(ava_1.default);
|
||||||
ava_1.default.beforeEach(() => {
|
|
||||||
util_1.initializeEnvironment(util_1.Mode.actions, "1.2.3");
|
|
||||||
});
|
|
||||||
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`;
|
||||||
t.notThrows(() => uploadLib.validateSarifFileSchema(inputFile, logging_1.getRunnerLogger(true)));
|
t.notThrows(() => uploadLib.validateSarifFileSchema(inputFile, logging_1.getRunnerLogger(true)));
|
||||||
@@ -53,7 +38,7 @@ ava_1.default("validate correct payload used per version", async (t) => {
|
|||||||
const allVersions = newVersions.concat(oldVersions);
|
const allVersions = newVersions.concat(oldVersions);
|
||||||
process.env["GITHUB_EVENT_NAME"] = "push";
|
process.env["GITHUB_EVENT_NAME"] = "push";
|
||||||
for (const version of allVersions) {
|
for (const version of allVersions) {
|
||||||
const payload = uploadLib.buildPayload("commit", "refs/heads/master", "key", undefined, "", undefined, "/opt/src", undefined, ["CodeQL", "eslint"], version);
|
const payload = uploadLib.buildPayload("commit", "refs/heads/master", "key", undefined, "", undefined, "/opt/src", undefined, ["CodeQL", "eslint"], version, "actions");
|
||||||
// Not triggered by a pull request
|
// Not triggered by a pull request
|
||||||
t.falsy(payload.base_ref);
|
t.falsy(payload.base_ref);
|
||||||
t.falsy(payload.base_sha);
|
t.falsy(payload.base_sha);
|
||||||
@@ -61,12 +46,12 @@ ava_1.default("validate correct payload used per version", async (t) => {
|
|||||||
process.env["GITHUB_EVENT_NAME"] = "pull_request";
|
process.env["GITHUB_EVENT_NAME"] = "pull_request";
|
||||||
process.env["GITHUB_EVENT_PATH"] = `${__dirname}/../src/testdata/pull_request.json`;
|
process.env["GITHUB_EVENT_PATH"] = `${__dirname}/../src/testdata/pull_request.json`;
|
||||||
for (const version of newVersions) {
|
for (const version of newVersions) {
|
||||||
const payload = uploadLib.buildPayload("commit", "refs/pull/123/merge", "key", undefined, "", undefined, "/opt/src", undefined, ["CodeQL", "eslint"], version);
|
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_ref, "refs/heads/master");
|
||||||
t.deepEqual(payload.base_sha, "f95f852bd8fca8fcc58a9a2d6c842781e32a215e");
|
t.deepEqual(payload.base_sha, "f95f852bd8fca8fcc58a9a2d6c842781e32a215e");
|
||||||
}
|
}
|
||||||
for (const version of oldVersions) {
|
for (const version of oldVersions) {
|
||||||
const payload = uploadLib.buildPayload("commit", "refs/pull/123/merge", "key", undefined, "", undefined, "/opt/src", undefined, ["CodeQL", "eslint"], version);
|
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
|
// These older versions won't expect these values
|
||||||
t.falsy(payload.base_ref);
|
t.falsy(payload.base_ref);
|
||||||
t.falsy(payload.base_sha);
|
t.falsy(payload.base_sha);
|
||||||
|
|||||||
@@ -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,iCAMgB;AAEhB,0BAAU,CAAC,aAAI,CAAC,CAAC;AAEjB,aAAI,CAAC,UAAU,CAAC,GAAG,EAAE;IACnB,4BAAqB,CAAC,WAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC/C,CAAC,CAAC,CAAC;AAEH,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;AAEH,aAA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AAM,EAAE,SAAS,CAAC;YACpC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC;SAC7C,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,aAAI,CAAC,8BAA8B,EAAE,CAAC,CAAC,EAAE,EAAE;IACzC,IAAI,KAAK,GAAG,gBAAgB,CAAC;IAC7B,MAAM,WAAW,GAAG,+CAA+C,CAAC;IAEpE,IAAI,aAAa,GACf,yEAAyE,CAAC;IAE5E,sDAAsD;IACtD,IAAI,aAAa,GAAG,SAAS,CAAC,4BAA4B,CACxD,KAAK,EACL,8BAA8B,EAC9B,WAAW,EACX,sCAAsC,CACvC,CAAC;IACF,CAAC,CAAC,SAAS,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;IAE1C,kEAAkE;IAClE,aAAa,GAAG,SAAS,CAAC,4BAA4B,CACpD,KAAK,EACL,+BAA+B,EAC/B,WAAW,EACX,EAAE,CACH,CAAC;IACF,CAAC,CAAC,SAAS,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;IAE1C,4DAA4D;IAC5D,KAAK,GAAG,iDAAiD,CAAC;IAC1D,aAAa,GAAG,iDAAiD,CAAC;IAClE,aAAa,GAAG,SAAS,CAAC,4BAA4B,CACpD,KAAK,EACL,SAAS,EACT,WAAW,EACX,2CAA2C,CAC5C,CAAC;IACF,CAAC,CAAC,SAAS,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;AAC5C,CAAC,CAAC,CAAC"}
|
||||||
21
lib/upload-sarif-action.js
generated
21
lib/upload-sarif-action.js
generated
@@ -1,21 +1,9 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||||
__setModuleDefault(result, mod);
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
@@ -24,8 +12,6 @@ const actionsUtil = __importStar(require("./actions-util"));
|
|||||||
const logging_1 = require("./logging");
|
const logging_1 = require("./logging");
|
||||||
const upload_lib = __importStar(require("./upload-lib"));
|
const upload_lib = __importStar(require("./upload-lib"));
|
||||||
const util_1 = require("./util");
|
const util_1 = require("./util");
|
||||||
// eslint-disable-next-line import/no-commonjs
|
|
||||||
const pkg = require("../package.json");
|
|
||||||
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 = {
|
||||||
@@ -35,7 +21,6 @@ async function sendSuccessStatusReport(startedAt, uploadStats) {
|
|||||||
await actionsUtil.sendStatusReport(statusReport);
|
await actionsUtil.sendStatusReport(statusReport);
|
||||||
}
|
}
|
||||||
async function run() {
|
async function run() {
|
||||||
util_1.initializeEnvironment(util_1.Mode.actions, pkg.version);
|
|
||||||
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)))) {
|
||||||
return;
|
return;
|
||||||
@@ -43,7 +28,7 @@ async function run() {
|
|||||||
try {
|
try {
|
||||||
const apiDetails = {
|
const apiDetails = {
|
||||||
auth: actionsUtil.getRequiredInput("token"),
|
auth: actionsUtil.getRequiredInput("token"),
|
||||||
url: util_1.getRequiredEnvParam("GITHUB_SERVER_URL"),
|
url: actionsUtil.getRequiredEnvParam("GITHUB_SERVER_URL"),
|
||||||
};
|
};
|
||||||
const gitHubVersion = await util_1.getGitHubVersion(apiDetails);
|
const gitHubVersion = await util_1.getGitHubVersion(apiDetails);
|
||||||
const uploadStats = await upload_lib.uploadFromActions(actionsUtil.getRequiredInput("sarif_file"), gitHubVersion, apiDetails, logging_1.getActionsLogger());
|
const uploadStats = await upload_lib.uploadFromActions(actionsUtil.getRequiredInput("sarif_file"), gitHubVersion, apiDetails, logging_1.getActionsLogger());
|
||||||
|
|||||||
@@ -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,iCAKgB;AAEhB,8CAA8C;AAC9C,MAAM,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAMvC,KAAK,UAAU,uBAAuB,CACpC,SAAe,EACf,WAA0C;IAE1C,MAAM,gBAAgB,GAAG,MAAM,WAAW,CAAC,sBAAsB,CAC/D,cAAc,EACd,SAAS,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AC1C,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"}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user