Skip to content

Commit

Permalink
Snyk code test support and readme changes (#39)
Browse files Browse the repository at this point in the history
<!-- 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}
  • Loading branch information
jezd-axyl authored Oct 26, 2023
1 parent de9e143 commit 5dd0aae
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 3 deletions.
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 "$@"

0 comments on commit 5dd0aae

Please sign in to comment.