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

adds examples for Snyk Org and multiple files for IaC #82

Merged
merged 3 commits into from
Mar 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ All Snyk GitHub Actions support integration with GitHub Code Scanning to show vu

### Continuing on error

The above examples will fail the workflow when issues are found. If you want to ensure the Action continues, even if Snyk finds vulnerabilities, then [continue-on-error](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepscontinue-on-error) can be used..
The above examples will fail the workflow when issues are found. If you want to ensure the Action continues, even if Snyk finds vulnerabilities, then [continue-on-error](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstepscontinue-on-error) can be used.

```yaml
name: Example workflow using Snyk with continue on error
Expand All @@ -130,6 +130,28 @@ jobs:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
```

### Specifying Snyk Organization

If you want to run tests within a specific [Snyk Organization](https://docs.snyk.io/introducing-snyk/snyks-core-concepts/groups-organizations-and-users#snyk-organizations), then the `--org` argument can be used.

```yaml
name: Example workflow using Snyk with continue on error
on: push
jobs:
security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Run Snyk to check for vulnerabilities
uses: snyk/actions/node@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
args: --org=${{ secrets.SNYK_ORG }}
```

The Actions example above refers to a Snyk Organization identifier `SNYK_ORG` that must be specified as a GitHub Actions Secret.

Made with 💜 by Snyk

[cli-gh]: https://github.com/snyk/snyk 'Snyk CLI'
Expand Down
43 changes: 35 additions & 8 deletions iac/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ jobs:
file: your/kubernetes-manifest.yaml
```

The Snyk Infrastructurer as Code Action has properties which are passed to the underlying image. These are
The Snyk Infrastructure as Code Action has properties which are passed to the underlying image. These are
passed to the action using `with`.

| Property | Default | Description |
| -------- | ------- | ----------------------------------------------------------------------- |
| args | | Override the default arguments to the Snyk image |
| command | test | Specify which command to run, currently only `test` is supported |
| file | | The file to check for issues. Currently only single files are supported |
| json | false | In addition to the stdout, save the results as snyk.json |
| sarif | true | In addition to the stdout, save the results as snyk.sarif |
| Property | Default | Description |
|----------|---------|------------------------------------------------------------------|
| args | | Override the default arguments to the Snyk image |
| command | test | Specify which command to run, currently only `test` is supported |
| file | | The file to check for issues. |
| json | false | In addition to the stdout, save the results as snyk.json |
| sarif | true | In addition to the stdout, save the results as snyk.sarif |

For example, you can choose to only report on high severity vulnerabilities.

Expand Down Expand Up @@ -79,3 +79,30 @@ jobs:
with:
sarif_file: snyk.sarif
```

### Specifying Multiple Files

If you want to run IaC tests against multiple files, the [Build Matrix](https://docs.github.com/en/actions/using-jobs/using-a-build-matrix-for-your-jobs) feature can be used.

```yaml
name: Example workflow for Snyk Infrastructure as Code with multiple files
on: push
jobs:
security:
runs-on: ubuntu-latest
strategy:
matrix:
files:
- main.tf
- outputs.tf
- variables.tf
steps:
- name: Run Snyk to check Kubernetes manifest file for issues
uses: snyk/actions/iac@master
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
file: ${{ matrix.files }}
```

The Actions example above refers to a `files` list that must contain at least _one_ supported file.