Giter Club home page Giter Club logo

snyk-slacker-3000's Introduction

Snyk Slacker 3000

Warning This is basically a copy of an internal app that was made in a hurry, but we're opening it up so that others can take inspiration from it. Use at your own discretion! The build logic assumes that the app will be run as a container on nais. Some manual setup in Snyk and Slack is required, but not described in detail here.

Custom Snyk webhook integration to support filtering of alerts on severity.

How to use for your team's Snyk organization

Follow these steps to receive Slack messages for "high" and "critical" severity Snyk vulnerabilities and license issues for your team:

  1. Add the Slack App "Snyker" to your desired Slack channel (Member list -> Integrations -> Add apps -> Search for "Snyker")
  2. Submit a pull request to this repository, updating config.js with an additional entry:
{
  "snykOrg": "…display name of your snyk org…",
  "slackChannelId": "…slack channel ID…",
  "severity": ["critical", "high"],
  "issueType": ["vuln", "license"]
}

Note on Snyk org: Use the display name of your org, and not the normalised version used in URLs and from the Snyk CLI. These are normally the same, but they're sometimes slightly different. E.g. team aura (display name) has an URL aura-bkp, which is also what's used from the CLI (--org=aura-bkp). Here, aura should be used for snykOrg.

Note on Slack ID: To find your Slack channel ID, right-click the channel name and select "Copy link". The last part of the copied URL will be the channel ID.

How does it work?

The notifier bot works by registrering itself as a Snyk webhook receiver for the organizations mapped in config.json. This is done on startup, by first checking the existing webhooks for each mapped organization, and then creating new ones for those without a configured webhook with the bot as a callback URL.

On startup:

  1. List all authorized Snyk organizations
  2. For each organization listed in config.json, list all Snyk webhooks
  3. If no organization webhook is found with the correct callback URL, create a new one

On webhook callback received:

  1. Verify webhook signature (HMAC). Discard if invalid
  2. Lookup the organization name in config.json. Discard if not found
  3. Filter new issues based on the found config
  4. If new issues found matching the filter, notify configured Slack channel

Development

Requires node version >=16

Local development

Install and start the bot locally:

$ npm install
$ npm start

See the table below for required environment variables.

Be aware: If you specify SNYK_WEBHOOK_CALLBACK_URL, the bot will register that URL as a callback receiver in Snyk on startup.

Configuration

Environment variable Description Required Default
APP_PORT Port of webhook receiver server No 3000
SNYK_API_BASE_URL Base URL for Snyk API No https://snyk.io/api/v1
SNYK_API_KEY Organization API token Yes
SNYK_WEBHOOK_CALLBACK_URL URL for Snyk webhooks No
SNYK_WEBHOOK_SECRET Secret used to verify webhook callbacks Yes
SLACK_BOT_TOKEN Slackbot API token Yes
SLACK_SIGNING_SECRET Slackbot signing secret Yes
SLACK_ALERT_CHANNEL Slack channel for important log messages No

snyk-slacker-3000's People

Contributors

albrektsson avatar dependabot[bot] avatar jksolbakken avatar jrtm avatar

Watchers

 avatar  avatar  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.