Skip to content
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
!.vscode/settings.json
.envrc
.idea
.dccache
7 changes: 7 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
language: script
pass_filenames: false

- id: snyk-code
name: Snyk Code
description: Runs 'snyk code test' command
entry: hooks/snyk-code.sh
language: script
pass_filenames: false

- id: snyk-log4shell
name: Snyk log4shell
description: Runs 'snyk log4shell' command
Expand Down
25 changes: 22 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
1. [snyk-container](#snyk-container)
2. [snyk-iac](#snyk-iac)
3. [snyk-test](#snyk-test)
4. [snyk-log4shell](#snyk-log4shell)
4. [snyk-code](#snyk-code)
5. [snyk-log4shell](#snyk-log4shell)

## Description

Expand Down Expand Up @@ -52,13 +53,20 @@ repos:
rev: <rev>
hooks:
- id: snyk-iac
args:
- <folder>
args:["<folder>","--severity-threshold=<severity-level>"]
```

Where:

- `<folder>` is the folder path that you want to test.
- `<severity-level>` only vulnerabilities of the specified level or higher are reported.

Options are:

- low
- medium
- high
- critical

### snyk-test

Expand All @@ -71,6 +79,17 @@ repos:
args: ["--severity-threshold=critical"]
```

### snyk-code

```yaml
repos:
- repo: https://github.com/fabasoad/pre-commit-snyk
rev: <rev>
hooks:
- id: snyk-code
args: ["--severity-threshold=critical"]
```

### snyk-log4shell

```yaml
Expand Down
6 changes: 6 additions & 0 deletions hooks/snyk-code.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -eu
SCRIPT_DIR="$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)"
bash "${SCRIPT_DIR}"/installation/main.sh

snyk code test "$@"