Code Monkey home page Code Monkey logo

snyk-filter's Introduction

Snyk logo


Custom Filtering for Snyk CLI

snyk-filter takes the JSON outputted from the Snyk CLI, e.g. snyk test --json and applies custom filtering of the results, as well as options to fail your build.

Known Vulnerabilities CircleCI Inactively Maintained

This repository is in maintenance mode, no new features are being developed. Bug & security fixes will continue to be delivered. Open source contributions are welcome for small features & fixes (no breaking changes)

How do I use it?

Install

npm i -g snyk-filter

Note about node-jq

snyk-filter uses the node-jq library, which requires that a jq binary is installed. This typically happens transparently via npm install -g, but on some systems JQ does not get properly installed locally. If you receive an error after installation regarding node-jq, then jq should be installed manually to avoid this error.

# install jq ahead of time (ubuntu example)
sudo apt-get install -y jq

# tell node-jq to skip trying to install it on its own
export NODE_JQ_SKIP_INSTALL_BINARY=true

# tell node-jq where the existing jq binary is
export JQ_PATH=$(which jq)

# finally, install snyk-filter (does not work with node version > 12)
sudo npm install -g

Usage

  1. Implement your custom JQ filters in a .snyk-filter/snyk.yml file relative to your current working directory where you will be running snyk test from (see in sample-filters and tweak things from there - use JQPlay )

  2. Then pipe your snyk test --json output into snyk-filter or use the -i argument to input a json file. Use the -f argument to point to the yml file containing your custom filters if you are not using the default location (.snyk-filter/snyk.yml).

  3. Return code of snyk-filter will be 0 for pass (no issues) and 1 for fail (issues found)

Example with Snyk CLI (using .snyk-filter/snyk.yml by default)

snyk test --json | snyk-filter

Example with Snyk CLI and custom yml file location

snyk test --json | snyk-filter -f /path/to/example-cvss-9-or-above.yml

Example

snyk-filter -i snyk_results.json

Example with custom yml file location

snyk-filter -i snyk_results.json -f /path/to/example-high-upgradeable-vulns.yml

Options

--json to output json

License

License: Apache License, Version 2.0

snyk-filter's People

Contributors

aarlaud avatar scott-es avatar snyk-bot avatar lili2311 avatar thisislawatts avatar mattsnyk avatar amitsnyk avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.