Skip to content

Commit f8813da

Browse files
Merge pull request #16 from therealkujo/update_bootcamp
Update instructions and add a license
2 parents a0da1df + eb3ccf9 commit f8813da

File tree

5 files changed

+60
-22
lines changed

5 files changed

+60
-22
lines changed

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 github
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
> This bootcamp is designed to help familiarize you with GitHub Advanced Security (GHAS) so that you can better understand how to use it in your own repositories.
88
99
## :mega: Prerequisites
10-
To participate in the workshop you need a GitHub account and need to be invited to the workshop organization [ghas-bootcamp](https://github.com/ghas-bootcamp). If your repository hasn't been automatically created in the workshop organization, either click `Use this template` and create a repository under this organization, or create a new repository and push a copy of the `ghas-bootcamp` repository.
10+
To participate in the workshop you need a GitHub account and need to be invited to the workshop organization [ghas-bootcamp](https://github.com/ghas-bootcamp). If your repository hasn't been automatically created in the workshop organization, either click `Use this template` and create a repository under this organization, or create a new repository and push a copy of the `ghas-bootcamp` repository to an organization with GHAS enabled.
1111

1212
```bash
1313
git clone https://github.com/ghas-bootcamp/ghas-bootcamp.git

exercises/codeql-cli.md

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,37 @@
1-
### Getting started with the CodeQL CLI
1+
## Getting started with the CodeQL CLI
22

33
When you want to generate a CodeQL database locally and run the pre-compiled queries against it, this is the way to go.
44

5-
First let's download the CodeQL bundle! Head over [here](https://github.com/github/codeql-action/releases ) and download the approprate bundle for your operating system.
6-
Once it's downloaded, untar the content to a CodeQL home folder and you can add CodeQL to your path if you'd like (or use Brew install for this)
5+
First let's download the CodeQL bundle!
76

8-
```
9-
export PATH="/Documents/codeql-home/codeql:$PATH"
10-
```
7+
### Pre-requisites
8+
9+
You will need to make sure you have the GitHub CLI installed. For more information on how to install the CLI, check out this installation [doc](https://github.com/cli/cli#installation)
10+
11+
### Install the extension
12+
13+
Using the GitHub CLI, we will install the codeql cli,
14+
15+
1. `gh extensions install github/gh-codeql`
16+
1. `sudo gh codeql install-stub` (this allows you to run `codeql` in your terminal without having to invoke `gh codeql`)
17+
1. `codeql set-version latest` (this will auto download the latest version of the cli)
1118

1219
Check to make sure you can use the CodeQL CLI
1320

1421
```
1522
codeql --version
1623
```
1724

25+
## Using the CodeQL CLI
26+
1827
Now we need to use the CodeQL CLI on an actual repository. Let's start here with our [GHAS training material](https://github.com/ghas-bootcamp/ghas-bootcamp)
1928
There's multiple languages being used here, so for the purposes of this tutorial let's try to scan the Javascript portions of the codebase.
2029

2130
Clone this repository and `cd` into it.
2231

32+
### Install the Javascript Bundle
33+
34+
We will need to download the latest javascript queries to scan the code with. In your terminal, run `codeql pack download codeql/javascript-queries`
2335

2436
### codeql database create
2537

@@ -30,7 +42,7 @@ You can rely on the autobuild.sh script as well, or you can supply your own buil
3042
Please review this [list](https://codeql.github.com/docs/codeql-overview/supported-languages-and-frameworks/) of currently supported languages and frameworks.
3143

3244

33-
```
45+
```bash
3446
codeql database create db --language=javascript
3547
```
3648

@@ -52,18 +64,22 @@ Now that we have a database to work with, let's run some queries against it! We
5264
- `$CODEQL_SUPPORT_LANGUAGE-security-extended.qls`
5365
- `$CODEQL_SUPPORT_LANGUAGE-security-and-quality.qls`
5466

55-
If you have the CodeQL bundle on path, you can reference these query suites by their filenames. If you don't, you can use the full path to the query suite.
56-
As mentioned in the beginning, the queries from the CodeQL bundle are pre-compiled.
57-
If you have a custom query suite, you will see that CodeQL will create a compiled query plan.
67+
By default when we scan with `codeql/javascript-queries` it will default to `javascript-code-scanning.qls`.
5868

59-
```
60-
codeql database analyze db javascript-code-scanning.qls --format=sarif-latest --output=codeql-javascript-results.sarif
69+
```bash
70+
codeql database analyze db --format=sarif-latest --output=codeql-javascript-results.sarif codeql/javascript-queries
6171
```
6272

6373
You will see the queries being evaluated. When this process is done, a SARIF should have been created. The SARIF contains results from the analysis.
6474
If the results array is empty, it means no results were found. If you want to view the SARIF, you can use `jq` to parse through it, or you can use a SARIF Viewer, such as this [one](https://marketplace.visualstudio.com/items?itemName=WDGIS.MicrosoftSarifViewer). Also if you have the `vs-codeql-starter` [workspace](https://github.com/github/vscode-codeql-starter), you can run particular queries against an imported CodeQL database and see the analysis in the IDE.
6575

66-
Here are some advanced things to note:
76+
To scan your code using the other query suites, you just need to append that to the original command
77+
78+
```bash
79+
codeql database analyze db --format=sarif-latest --output=codeql-javascript-results.sarif codeql/javascript-queries:codeql-suites/javascript-security-extended.qls
80+
```
81+
82+
#### Things to note
6783
- When dealing with multiple analyses for the same commit (whether you're analysing multiple languages or have parallelized builds for a monorepo), make sure to use the `--sarif-category` flag to categorize the analyses.
6884
Failure to do so, in particular on a pull request, can cause confusion in that Code Scanning may not be able to detect a baseline analysis to compare the PR results.
6985
- Use this [endpoint](https://docs.github.com/en/rest/reference/code-scanning#list-code-scanning-analyses-for-a-repository) to list the CodeQL analyses of a repository, so that you can inspect the category for each analysis.
@@ -84,7 +100,9 @@ The `--ref` and `--commit` flag combinations can be one of the following:
84100
- ` curl -H "Accept: application/vnd.github.v3+json" \\n -H "Authorization: token $GH_TOKEN" \\n https://api.github.com/repos/<org-name>/<repo-name>/pulls/<pull-request-number> | jq '.merge_commit_sha'`
85101
- The merge commit is a commit created to make sure PR checks are ran; this commit doesn't exist in the actual source tree/`git log`.
86102

87-
```
103+
If you are supplying the `--commit` flag, make sure you use the full commit hash and not the shortened one
104+
105+
```bash
88106
codeql github upload-results --repository=$GITHUB_REPOSITORY --ref=$GITHUB_REF --commit=$GITHUB_SHA --sarif=codeql-javascript-results.sarif --github-auth-stdin=<YOUR TOKEN>
89107
```
90108

exercises/lab 2 - secret-scanning.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ While we can close a detected secret as being used in a test, we can also config
4747
4848
Use a pattern to exclude the file `storage-service/src/main/resources/application.dev.properties`
4949
50+
Merge your changes to `.github/secret_scanning.yml` to your default branch before going to the next step.
51+
5052
<details>
5153
<summary>Solution</summary>
5254
A possible solution is:

exercises/lab 3 - code-scanning.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,11 @@ CodeQL requires a build of compiled languages. An analysis job can fail if our *
4949
<details>
5050
<summary>Solution</summary>
5151

52-
```yaml
53-
- name: Setup Java JDK
54-
uses: actions/setup-java@v2.2.0
55-
if: matrix.language == 'java'
52+
uses: actions/setup-java@v3
5653
with:
57-
java-version: 15
58-
distribution: 'zulu'
59-
```
54+
java-version: 16
55+
distribution: 'microsoft'
56+
6057
</details>
6158

6259

0 commit comments

Comments
 (0)