Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
2d2b121
document new notification behavior
mchammer01 Feb 1, 2021
25ef40b
tidy up
mchammer01 Feb 1, 2021
2dc3839
fix inline formatting
mchammer01 Feb 1, 2021
b674598
Apply suggestions from code review
mchammer01 Feb 2, 2021
5109b56
Merge branch 'main' into 3634-dependabot-combined-notification
mchammer01 Feb 2, 2021
cf1a0e7
Merge branch 'main' into 3634-dependabot-combined-notification
mchammer01 Feb 11, 2021
36bf562
Merge branch 'main' into 3634-dependabot-combined-notification
mchammer01 Feb 18, 2021
2177ad1
Merge branch 'main' into 3634-dependabot-combined-notification
mchammer01 Feb 22, 2021
c1f20bc
fix incorrect Liquid versioning
mchammer01 Feb 22, 2021
8ab785e
Merge branch 'main' into 3634-dependabot-combined-notification
mchammer01 Feb 22, 2021
85c2faa
repo sync
Octomerger Mar 15, 2021
d25ee7d
add content about workflow availability
mchammer01 Mar 15, 2021
537ad75
reword
mchammer01 Mar 15, 2021
ba7db08
apply versioning
mchammer01 Mar 15, 2021
7b05542
fix ordered list formatting
mchammer01 Mar 15, 2021
e2bf0fd
address review comment
mchammer01 Mar 15, 2021
4d124dc
Preview for slash command early access doc updates (#18232)
Mar 15, 2021
522728f
Branch was updated using the 'autoupdate branch' Actions workflow.
Octomerger Mar 15, 2021
edd7500
repo sync
Octomerger Mar 15, 2021
83f1e3a
[SEO] Correct footer links (#18136)
skullface Mar 15, 2021
9eccffe
[March 15] Dependabot version updates support for private registries …
hubwriter Mar 15, 2021
beef176
empty commit for preview (#18256)
Mar 15, 2021
c535420
decorate script fix (#18201)
rachmari Mar 16, 2021
5994a4f
add 2.21.16 release notes
bwestover Mar 16, 2021
11af364
add 2.22.8 release notes
bwestover Mar 16, 2021
3051487
add 3.0.2 release notes
bwestover Mar 16, 2021
9b58c6d
try adding back quotes
bwestover Mar 16, 2021
b1f4b29
Revert "try adding back quotes"
bwestover Mar 16, 2021
3a7cb3b
space_invader
bwestover Mar 16, 2021
149addd
Merge branch 'main' of github.com:github/docs-internal into patch-rel…
bwestover Mar 16, 2021
b45ace3
encode a colon
bwestover Mar 16, 2021
2bf7faf
Update data/release-notes/3-0/2.yml
bwestover Mar 16, 2021
f7f3e11
update versioning
mchammer01 Mar 16, 2021
1e0ff90
Merge branch 'main' into 3634-dependabot-combined-notification
mchammer01 Mar 16, 2021
42c894f
Merge branch '3634-dependabot-combined-notification' of github.com:gi…
mchammer01 Mar 16, 2021
9ebe58a
Merge branch '3634-dependabot-combined-notification' of github.com:gi…
mchammer01 Mar 16, 2021
ff2f58a
yet more versioning updates
mchammer01 Mar 16, 2021
6f3f214
Update github-sponsors-additional-terms.md (#17937)
Mar 16, 2021
b304674
Merge branch 'main' into patch-release-notes-2021-03-16
sarahs Mar 16, 2021
f425ada
Merge pull request #18258 from github/patch-release-notes-2021-03-16
sarahs Mar 16, 2021
fc38a40
check for openapi type property (#18257)
rachmari Mar 16, 2021
8f63a44
Update OpenAPI Descriptions (#18249)
github-openapi-bot Mar 16, 2021
0240147
Group user docs on code security into a new "product" (#18196)
felicitymay Mar 16, 2021
8d757ee
Move team discussions content to orgs category (#18217)
emilyistoofunky Mar 16, 2021
60bd45b
Merge branch 'main' into repo-sync
rachmari Mar 16, 2021
fecda83
repo sync
Octomerger Mar 16, 2021
a34dcc4
Actions for Project Management (#17849)
Mar 16, 2021
c6f0298
Branch was updated using the 'autoupdate branch' Actions workflow.
Octomerger Mar 16, 2021
52aeeab
repo sync
Octomerger Mar 16, 2021
f2d8ccb
Add missing Audit Log events for GitHub Actions (#17616)
Mar 17, 2021
54ef0fd
[Ready to ship, March 16] New types of push notifications for GitHub …
ethanpalm Mar 17, 2021
b18d884
Adding additional information for workflow_runs (#18235)
asciimike Mar 17, 2021
ea6adac
Branch was updated using the 'autoupdate branch' Actions workflow.
Octomerger Mar 17, 2021
8b6dc9f
repo sync
Octomerger Mar 17, 2021
6a7e93f
Revert "Group user docs on code security into a new "product" (#18196…
felicitymay Mar 17, 2021
1bc1e84
Code scanning: uploading results as PR checks (#18050)
shati-patel Mar 17, 2021
fb5dec6
Clarify the availability of GHAS licenses for dotcom (#18246)
felicitymay Mar 17, 2021
cd2a217
do not error if frontmatter includes next GHES release or hardcoded next
sarahs Mar 17, 2021
5006cda
add tests
sarahs Mar 17, 2021
4aa879e
Update Packages support overview diagram (#18231)
jmarlena Mar 17, 2021
1d04403
rerun CI
sarahs Mar 17, 2021
56d8ebd
Merge branch 'main' into support-next-release-in-frontmatter
sarahs Mar 17, 2021
443d028
Merge pull request #18281 from github/support-next-release-in-frontma…
sarahs Mar 17, 2021
0192f59
[March 17] Remove all notes about ubuntu-latest migration and fix lab…
AlenaSviridenko Mar 17, 2021
b1b8cb8
add topic frontmatter to articles (#18245)
rachmari Mar 17, 2021
17f09e0
Add target completion date status commmand (#18286)
chiedo Mar 17, 2021
02ee72f
add topics attribute to search (#18212)
rachmari Mar 17, 2021
2e07070
Add filters params to search endpoint (#18289)
heiskr Mar 17, 2021
0c8bf6f
Branch was updated using the 'autoupdate branch' Actions workflow.
Octomerger Mar 17, 2021
7dc3c71
repo sync
Octomerger Mar 17, 2021
ddb0c20
Update search example with topics with white space (#18290)
rachmari Mar 17, 2021
7deb7a8
Merge branch 'main' into 3634-dependabot-combined-notification
mchammer01 Mar 18, 2021
55cbdbf
Update content/github/finding-security-vulnerabilities-and-errors-in-…
mchammer01 Mar 18, 2021
680ad2e
Merge branch 'main' into 3045-workflow-availability
mchammer01 Mar 18, 2021
3623ef0
Merge pull request #18253 from github/3045-workflow-availability
mchammer01 Mar 18, 2021
3d90904
Merge branch 'main' into 3634-dependabot-combined-notification
mchammer01 Mar 18, 2021
44cf73d
Add workflow to triage ready-for-doc-review PRs (#18226)
shati-patel Mar 18, 2021
fa42d8d
Adding enterprise release note for bug fix (#18265)
belaltaher8 Mar 18, 2021
6de2bf3
Add How We Work boards automation (#18298)
chiedo Mar 18, 2021
35fdf0d
Merge How We Work Workflows and Fix bugs (#18299)
chiedo Mar 18, 2021
c416d31
Merge branch 'main' into 3634-dependabot-combined-notification
mchammer01 Mar 18, 2021
31a9ea6
Merge pull request #17590 from github/3634-dependabot-combined-notifi…
mchammer01 Mar 18, 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
Prev Previous commit
Next Next commit
Code scanning: uploading results as PR checks (#18050)
  • Loading branch information
shati-patel authored Mar 17, 2021
commit 1bc1e848c0d80462c0f623920ebe07c7879d1c36
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,18 @@ To customize the way the {% data variables.product.prodname_codeql_runner %} sca

Scanning code whenever a pull request is created prevents developers from introducing new vulnerabilities and errors into the code.

To scan a pull request, run the `analyze` command and use the `--ref` flag to specify the pull request. The reference is `refs/pull/<pr-number>/head` or `refs/pull/<pr-number>/merge`, depending on whether you have checked out the HEAD commit of the pull request branch or a merge commit with the base branch.
To scan a pull request, run the `analyze` command and use the `--ref` flag to specify the pull request. The reference is `refs/pull/<PR-number>/head` or `refs/pull/<PR-number>/merge`, depending on whether you have checked out the HEAD commit of the pull request branch or a merge commit with the base branch.

```shell
$ /path/to-runner/codeql-runner-linux analyze --ref refs/pull/42/head
$ /path/to-runner/codeql-runner-linux analyze --ref refs/pull/42/merge
```

{% note %}

**Note**: If you analyze code with a third-party tool and want the results to appear as pull request checks, you must run the `upload` command and use the `--ref` flag to specify the pull request instead of the branch. The reference is `refs/pull/<PR-number>/head` or `refs/pull/<PR-number>/merge`.

{% endnote %}

### Overriding automatic language detection

The {% data variables.product.prodname_codeql_runner %} automatically detects and scans code written in the supported languages.
Expand Down Expand Up @@ -110,7 +116,9 @@ If the `autobuild` command can't build your code, you can run the build steps yo

By default, the {% data variables.product.prodname_codeql_runner %} uploads results from {% data variables.product.prodname_code_scanning %} when you run the `analyze` command. You can also upload SARIF files separately, by using the `upload` command.

Once you've uploaded the data, {% data variables.product.prodname_dotcom %} displays the alerts in your repository. For more information, see "[Managing {% data variables.product.prodname_code_scanning %} alerts for your repository](/github/finding-security-vulnerabilities-and-errors-in-your-code/managing-code-scanning-alerts-for-your-repository#viewing-the-alerts-for-a-repository)."
Once you've uploaded the data, {% data variables.product.prodname_dotcom %} displays the alerts in your repository.
- If you uploaded to a pull request, for example `--ref refs/pull/42/merge` or `--ref refs/pull/42/head`, then the results appear as alerts in a pull request check. For more information, see "[Triaging code scanning alerts in pull requests](/github/finding-security-vulnerabilities-and-errors-in-your-code/triaging-code-scanning-alerts-in-pull-requests)."
- If you uploaded to a branch, for example `--ref refs/heads/my-branch`, then the results appear in the **Security** tab for your repository. For more information, see "[Managing code scanning alerts for your repository](/github/finding-security-vulnerabilities-and-errors-in-your-code/managing-code-scanning-alerts-for-your-repository#viewing-the-alerts-for-a-repository)."

### {% data variables.product.prodname_codeql_runner %} command reference

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ To view the command-line reference for the runner, use the `-h` flag. For exampl

This example runs {% data variables.product.prodname_codeql %} analysis on a Linux CI server for the `octo-org/example-repo` repository hosted on `{% data variables.command_line.git_url_example %}`. The process is very simple because the repository contains only languages that can be analyzed by {% data variables.product.prodname_codeql %} directly, without being built (that is, Go, JavaScript, Python, and TypeScript).

In this example, the server has access to download the {% data variables.product.prodname_codeql %} bundle directly from the `github/codeql-action` repository, so there is no need to use the `--codeql-path` flag.

1. Check out the repository to analyze.
1. Move into the directory where the repository is checked out.
1. Initialize the {% data variables.product.prodname_codeql_runner %} and create {% data variables.product.prodname_codeql %} databases for the languages detected.
Expand All @@ -110,19 +112,7 @@ This example runs {% data variables.product.prodname_codeql %} analysis on a Lin
> Created CodeQL database at /srv/checkout/example-repo/codeql-runner/codeql_databases/javascript.
```

1. Populate the {% data variables.product.prodname_codeql_runner %} databases, analyze them, and upload the results to {% data variables.product.product_name %}.

```shell
$ /path/to-runner/codeql-runner-linux analyze --repository octo-org/example-repo
--github-url {% data variables.command_line.git_url_example %} --github-auth TOKEN
--commit 5b6a3078b31dc346e5ce7b86837d6abbe7a18bbd --ref refs/heads/main
> Finalizing database creation
> ...
> POST /repos/octo-org/example-repo/code-scanning/sarifs - 202 in 786ms
> Successfully uploaded results
```

The server has access to download the {% data variables.product.prodname_codeql %} bundle directly from the `github/codeql-action` repository, so there is no need to use the `--codeql-path` flag. When the analysis is complete, the {% data variables.product.prodname_codeql_runner %} uploads the results to the {% data variables.product.prodname_code_scanning %} view. For more information, see "[Managing {% data variables.product.prodname_code_scanning %} alerts for your repository](/github/finding-security-vulnerabilities-and-errors-in-your-code/managing-code-scanning-alerts-for-your-repository)."
{% data reusables.code-scanning.codeql-runner-analyze-example %}

#### Compiled language example

Expand All @@ -139,8 +129,8 @@ This example is similar to the previous example, however this time the repositor
> ...
> CodeQL environment output to "/srv/checkout/example-repo-2/codeql-runner/codeql-env.json"
and "/srv/checkout/example-repo-2/codeql-runner/codeql-env.sh".
Please export these variables to future processes so that CodeQL can monitor the build, for example by running "
. /srv/checkout/example-repo-2/codeql-runner/codeql-env.sh".
Please export these variables to future processes so that CodeQL can monitor the build, for example by running
". /srv/checkout/example-repo-2/codeql-runner/codeql-env.sh".
```

1. Source the script generated by the `init` action to set up the environment to monitor the build. Note the leading dot and space in the following code snippet.
Expand All @@ -151,17 +141,7 @@ This example is similar to the previous example, however this time the repositor

1. Build the code. On macOS, you need to prefix the build command with the environment variable `$CODEQL_RUNNER`. For more information, see "[Troubleshooting CodeQL code scanning in your CI system](/github/finding-security-vulnerabilities-and-errors-in-your-code/troubleshooting-codeql-code-scanning-in-your-ci-system#no-code-found-during-the-build)."

1. Populate the {% data variables.product.prodname_codeql %} databases, analyze them, and upload the results to {% data variables.product.prodname_dotcom %}.

```shell
$ /path/to-runner/codeql-runner-linux analyze --repository octo-org/example-repo-2
--github-url {% data variables.command_line.git_url_example %} --github-auth TOKEN
--commit ae7b655ef30b50fb726ae7b3daa79571a39d194d --ref refs/heads/main
> Finalizing database creation
> ...
> POST /repos/octo-org/example-repo-2/code-scanning/sarifs - 202 in 573ms
> Successfully uploaded results
```
{% data reusables.code-scanning.codeql-runner-analyze-example %}

{% note %}

Expand Down
25 changes: 25 additions & 0 deletions data/reusables/code-scanning/codeql-runner-analyze-example.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
1. Populate the {% data variables.product.prodname_codeql %} databases, analyze them, and upload the results to {% data variables.product.product_name %}. The results will appear in the **Security** tab for your repository.

```shell
$ /path/to-runner/codeql-runner-linux analyze --repository octo-org/example-repo
--github-url {% data variables.command_line.git_url_example %} --github-auth TOKEN
--commit 5b6a3078b31dc346e5ce7b86837d6abbe7a18bbd --ref refs/heads/my-branch
> Finalizing database creation
> ...
> POST /repos/octo-org/example-repo/code-scanning/sarifs - 202 in 786ms
> Successfully uploaded results
```

1. To upload {% data variables.product.prodname_code_scanning %} results as pull request checks, specify the pull request using the <nobr>`--ref`</nobr> flag. We recommend setting up the {% data variables.product.prodname_codeql_runner %} so that it runs on the [`pull_request`](/developers/webhooks-and-events/webhook-events-and-payloads#pull_request) webhook event.

```shell
$ /path/to-runner/codeql-runner-linux analyze --repository octo-org/example-repo
--github-url {% data variables.command_line.git_url_example %} --github-auth TOKEN
--commit 1dc7a1346e5ce7b86835b68bbda3078b37d6abbe --ref refs/pull/123/merge
> Finalizing database creation
> ...
> POST /repos/octo-org/example-repo/code-scanning/sarifs - 202 in 786ms
> Successfully uploaded results
```

For more information about viewing {% data variables.product.prodname_code_scanning %} alerts, see "[Triaging code scanning alerts in pull requests](/github/finding-security-vulnerabilities-and-errors-in-your-code/triaging-code-scanning-alerts-in-pull-requests)" and "[Managing code scanning alerts for your repository](/github/finding-security-vulnerabilities-and-errors-in-your-code/managing-code-scanning-alerts-for-your-repository)."