Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge main into v1 #549

Merged
merged 37 commits into from
Jun 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
8a1d7c2
Fix wording in README
okyanusoz Apr 3, 2021
e94d93a
Merge branch 'main' into patch-1
aeisenberg May 17, 2021
d9a17ba
Merge branch 'main' into patch-1
aeisenberg May 28, 2021
fad7cc4
Merge pull request #438 from okyanusoz/patch-1
aeisenberg May 31, 2021
4758879
Send the version and mode with the user agent
aeisenberg May 20, 2021
4164096
Use the version from package.json in the runner
aeisenberg May 31, 2021
1a4cdd3
Use the version from package.json in the runner
aeisenberg May 31, 2021
ca94508
Merge pull request #516 from github/aeisenberg/user-agent
aeisenberg May 31, 2021
981b5cb
Fix the mergeback workflow
aeisenberg May 31, 2021
7d701d2
Merge remote-tracking branch 'upstream/v1' into aeisenberg/mergeback-fix
aeisenberg May 31, 2021
a94829c
Manually update the CHANGELOG
aeisenberg May 31, 2021
c02d8cc
Fix EOF newlines after `npm version patch`
aeisenberg May 31, 2021
f0e82b7
1.0.1
aeisenberg May 31, 2021
4b4a5ee
Merge pull request #534 from github/aeisenberg/mergeback-fix
aeisenberg Jun 1, 2021
539d968
Use commander preAction hook for setMode
aeisenberg May 31, 2021
2fee124
Update supported GitHub Enterprise Server versions.
web-flow Jun 2, 2021
1d05ad7
Merge pull request #536 from github/aeisenberg/commander
aeisenberg Jun 2, 2021
739e14d
Merge branch 'main' into update-supported-enterprise-server-versions
aeisenberg Jun 2, 2021
0cbd4b5
Add some dependencies for uploading artifacts
May 24, 2021
e8486b0
Merge branch 'main' into update-supported-enterprise-server-versions
aeisenberg Jun 2, 2021
4ac9009
Merge pull request #541 from github/update-supported-enterprise-serve…
aeisenberg Jun 2, 2021
61b5618
Update unguarded-action-lib.ql
robertbrignull Jun 2, 2021
1ec2fd7
Merge pull request #542 from github/robertbrignull/import-actions-lib
adityasharad Jun 2, 2021
3708898
Add environment variables to signal feature and version to the CLI
aeisenberg Jun 1, 2021
2c2ebdc
Remove local environment running
aeisenberg Jun 1, 2021
082575f
Merge branch 'main' into aeisenberg/env-vars
aeisenberg Jun 2, 2021
cc0733f
Fix Unguarded actions library use code scanning error
aeisenberg Jun 2, 2021
f60ef17
Cleaning up comments around env vars
aeisenberg Jun 3, 2021
cbdf0df
Merge pull request #539 from github/aeisenberg/env-vars
aeisenberg Jun 3, 2021
41dff7f
Add back retrying.
chrisgavin Jun 4, 2021
ddb83a4
Cleanup CodeQL DBs and output their location for later steps
May 24, 2021
1644ade
Add `--sarif-group-rules-by-pack` flag
edoardopirovano Jun 4, 2021
f8c65b7
Fix stub in tests.
chrisgavin Jun 7, 2021
48efe6e
Merge branch 'main' into retrying-fix
chrisgavin Jun 7, 2021
242fd82
Merge pull request #547 from github/retrying-fix
chrisgavin Jun 7, 2021
68d7c5f
1.0.1
invalid-email-address Jun 7, 2021
511fe43
Empty commit to trigger CI.
chrisgavin Jun 7, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions .github/workflows/post-release-mergeback.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,24 +74,27 @@ jobs:
set +e # don't fail on an errored command
git ls-remote --tags origin | grep "$VERSION"
EXISTS="$?"
if [ "$EXISTS" -ne 0 ]; then
echo "::set-output name=exists::true"
echo "Tag $TAG exists. Not going to re-release."
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'
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'
if: steps.check.outputs.exists != 'true'
env:
VERSION: "${{ steps.getVersion.outputs.version }}"
NEW_BRANCH: "${{ steps.getVersion.outputs.newBranch }}"
Expand Down
40 changes: 29 additions & 11 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,38 @@ jobs:
shell: bash
run: ./build.sh
- uses: ./../action/analyze
id: analysis
env:
TEST_MODE: true
- run: |
cd "$RUNNER_TEMP/customDbLocation"
# List all directories as there will be precisely one directory per database
# but there may be other files in this directory such as query suites.
if [ "$(ls -d */ | wc -l)" != 6 ] || \
[[ ! -d cpp ]] || \
[[ ! -d csharp ]] || \
[[ ! -d go ]] || \
[[ ! -d java ]] || \
[[ ! -d javascript ]] || \
[[ ! -d python ]]; then
echo "Did not find expected number of databases. Database dir contains: $(ls)"
CPP_DB=${{ fromJson(steps.analysis.outputs.db-locations).cpp }}
if [[ ! -d $CPP_DB ]] || [[ ! $CPP_DB == ${{ runner.temp }}/customDbLocation/* ]]; then
echo "Did not create a database for CPP, or created it in the wrong location."
exit 1
fi
CSHARP_DB=${{ fromJson(steps.analysis.outputs.db-locations).csharp }}
if [[ ! -d $CSHARP_DB ]] || [[ ! $CSHARP_DB == ${{ runner.temp }}/customDbLocation/* ]]; then
echo "Did not create a database for C Sharp, or created it in the wrong location."
exit 1
fi
GO_DB=${{ fromJson(steps.analysis.outputs.db-locations).go }}
if [[ ! -d $GO_DB ]] || [[ ! $GO_DB == ${{ runner.temp }}/customDbLocation/* ]]; then
echo "Did not create a database for Go, or created it in the wrong location."
exit 1
fi
JAVA_DB=${{ fromJson(steps.analysis.outputs.db-locations).java }}
if [[ ! -d $JAVA_DB ]] || [[ ! $JAVA_DB == ${{ runner.temp }}/customDbLocation/* ]]; then
echo "Did not create a database for Java, or created it in the wrong location."
exit 1
fi
JAVASCRIPT_DB=${{ fromJson(steps.analysis.outputs.db-locations).javascript }}
if [[ ! -d $JAVASCRIPT_DB ]] || [[ ! $JAVASCRIPT_DB == ${{ runner.temp }}/customDbLocation/* ]]; then
echo "Did not create a database for Javascript, or created it in the wrong location."
exit 1
fi
PYTHON_DB=${{ fromJson(steps.analysis.outputs.db-locations).python }}
if [[ ! -d $PYTHON_DB ]] || [[ ! $PYTHON_DB == ${{ runner.temp }}/customDbLocation/* ]]; then
echo "Did not create a database for Python, or created it in the wrong location."
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/script/check-node-modules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ npm run removeNPMAbsolutePaths
# Check that repo is still clean
if [ ! -z "$(git status --porcelain)" ]; then
# If we get a fail here then the PR needs attention
>&2 echo "Failed: node_modules are not up to date. Run 'npm ci' and 'npm run removeNPMAbsolutePaths' to update"
>&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."
git status
exit 1
fi
Expand Down
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# CodeQL Action and CodeQL Runner Changelog

## 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)
- 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)
- Add metrics and diagnostics summaries from custom query suites to the analysis summary log group. [#532](https://github.com/github/codeql-action/pull/532)
24 changes: 2 additions & 22 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Please note that this project is released with a [Contributor Code of Conduct][c

## Development and Testing

Before you start, ensure that you have a recent version of node installed. 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 (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`.

### Common tasks

Expand All @@ -28,32 +28,12 @@ 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.

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.
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.

### 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.

### 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

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.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# CodeQL Action

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.
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.

For a list of recent changes, see the CodeQL Action's [changelog](CHANGELOG.md).

Expand Down
7 changes: 7 additions & 0 deletions analyze/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ inputs:
description: Upload the SARIF file
required: false
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:
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
Expand All @@ -34,6 +38,9 @@ inputs:
default: ${{ github.token }}
matrix:
default: ${{ toJson(matrix) }}
outputs:
db-locations:
description: A map from language to absolute path for each database created by CodeQL.
runs:
using: 'node12'
main: '../lib/analyze-action.js'
65 changes: 17 additions & 48 deletions lib/actions-util.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading