Skip to content

Commit 5dd0aae

Browse files
authored
Snyk code test support and readme changes (#39)
<!-- markdownlint-disable-file MD041 --> ## Pull request checklist Please check if your PR fulfills the following requirements: - [x] I have read the [CONTRIBUTING](https://github.com/fabasoad/pre-commit-snyk/blob/main/CONTRIBUTING.md) doc. - [ ] Tests for the changes have been added (for bug fixes / features). - [x] Docs have been reviewed and added / updated if needed (for bug fixes / features). ## Pull request type <!-- Please do not submit updates to dependencies unless it fixes an issue. --> <!-- Please try to limit your pull request to one type, submit multiple pull requests if needed. --> Please check the type of change your PR introduces: - [ ] Bugfix - [x] Feature - [ ] Code style update (formatting, renaming) - [ ] Refactoring (no functional changes, no api changes) - [ ] Build related changes - [ ] Documentation content changes - [ ] Other (please describe): ## What is the current behavior <!-- Please describe the current behavior that you are modifying, or link to a relevant issue. --> ## What is the new behavior <!-- Please describe the behavior or changes that are being added by this PR. --> - Added support for `snyk code test` - Updated readme - ## Does this introduce a breaking change - [ ] Yes - [x] No <!-- If this introduces a breaking change, please describe the impact and migration path for existing applications below. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. --> <!-- This document was adapted from the open-source [appium/appium](https://github.com/appium/appium/blob/master/.github/PULL_REQUEST_TEMPLATE.md) repository. --> --- Closes #{IssueNumber}
1 parent de9e143 commit 5dd0aae

4 files changed

Lines changed: 36 additions & 3 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
!.vscode/settings.json
55
.envrc
66
.idea
7+
.dccache

.pre-commit-hooks.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@
2222
language: script
2323
pass_filenames: false
2424

25+
- id: snyk-code
26+
name: Snyk Code
27+
description: Runs 'snyk code test' command
28+
entry: hooks/snyk-code.sh
29+
language: script
30+
pass_filenames: false
31+
2532
- id: snyk-log4shell
2633
name: Snyk log4shell
2734
description: Runs 'snyk log4shell' command

README.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
1. [snyk-container](#snyk-container)
99
2. [snyk-iac](#snyk-iac)
1010
3. [snyk-test](#snyk-test)
11-
4. [snyk-log4shell](#snyk-log4shell)
11+
4. [snyk-code](#snyk-code)
12+
5. [snyk-log4shell](#snyk-log4shell)
1213

1314
## Description
1415

@@ -52,13 +53,20 @@ repos:
5253
rev: <rev>
5354
hooks:
5455
- id: snyk-iac
55-
args:
56-
- <folder>
56+
args:["<folder>","--severity-threshold=<severity-level>"]
5757
```
5858

5959
Where:
6060

6161
- `<folder>` is the folder path that you want to test.
62+
- `<severity-level>` only vulnerabilities of the specified level or higher are reported.
63+
64+
Options are:
65+
66+
- low
67+
- medium
68+
- high
69+
- critical
6270

6371
### snyk-test
6472

@@ -71,6 +79,17 @@ repos:
7179
args: ["--severity-threshold=critical"]
7280
```
7381

82+
### snyk-code
83+
84+
```yaml
85+
repos:
86+
- repo: https://github.com/fabasoad/pre-commit-snyk
87+
rev: <rev>
88+
hooks:
89+
- id: snyk-code
90+
args: ["--severity-threshold=critical"]
91+
```
92+
7493
### snyk-log4shell
7594

7695
```yaml

hooks/snyk-code.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
set -eu
3+
SCRIPT_DIR="$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)"
4+
bash "${SCRIPT_DIR}"/installation/main.sh
5+
6+
snyk code test "$@"

0 commit comments

Comments
 (0)