Integrate JFrog Xray with Slack
Tags: cloud, javascript, cicd, jfrog
Published: 2020-03-30 17:20:59

---
title: Integrate JFrog Xray with Slack
published: true
date: 2020-03-30 15:08:00 UTC
tags: cloud,JavaScript,ci/cd,JFrog
canonical_url: https://greenido.wordpress.com/2020/03/30/integrate-jfrog-xray-with-slack/
---

![](https://camo.githubusercontent.com/18e53855697007c311742438d5d88758bf6af494/68747470733a2f2f63646e2e676c697463682e636f6d2f31386639376333662d623865662d343462612d613636312d65393135623331303639366425324653637265656e25323053686f74253230323032302d30332d32382532306174253230352e35372e3436253230504d2e706e673f763d31353835343433343834393537)

The need to protect your software and to be updated about vulnerabilities is expanding. JFrog Xray is unique in its capabilities to perform analysis of  **all**  the binaries you are consuming in your project. It works with Artifactory to perform a deep analysis of binary components at any stage of the application lifecycle. Xray provides great visibility into issues lurking in components anywhere in your organization and there are many cases where you wish to get notified on a security violation (or a license breach) directly to [Slack](http://slack.com/).

![](https://camo.githubusercontent.com/6ede3090ec284f3e22f8dd520df3283e8e577d2b/68747470733a2f2f63646e2e676c697463682e636f6d2f31386639376333662d623865662d343462612d613636312d65393135623331303639366425324653637265656e25323053686f74253230323032302d30332d3330253230617425323031302e35352e3130253230414d2e706e673f763d31353835353930393236393435)

## Getting Started

We will use [Xray’s Webhooks](https://www.jfrog.com/confluence/display/JFROG/Configuring+Xray#ConfiguringXray-ConfiguringWebhooks) to define our server’s and base on the [policies/rules](https://www.jfrog.com/confluence/display/JFROG/Creating+Xray+Policies+and+Rules) our Webhook will be notified with the alerts about violations (security or licenses).

The project uses [Express.js](http://expressjs.com/), a minimal and flexible Node.js framework that includes a myriad of HTTP utility methods for quickly creating robust APIs. We also use the [Body Parser](https://github.com/expressjs/body-parser) package, which is Node.js middleware that allows us to process any POST requests we receive.

Before we start, you can fork the code from **[github.com/greenido/jfrog-xray-2-slack-example](https://github.com/greenido/jfrog-xray-2-slack-example) **

Now, you want to check the **[routes.js](https://github.com/greenido/jfrog-xray-2-slack-example/blob/master/routes.js)** file and see the end-point that is being used:

**/xray/api**  – Get the notification from Xray and send messages to Slack. Each violation will be sent as one message. To make it more efficient we aren’t sending all the issues’ data per violation.   
However, if you wish to get more information, please feel free to fork this project and add fields to the message.

### Steps To Follow

1. Defined Xray’s Webhook by following [these steps](https://www.jfrog.com/confluence/display/JFROG/Configuring+Xray#ConfiguringXray-ConfiguringWebhooks) or see below here at step #5.

2. Copy this project and change:

```
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/specific-string-from-slack/more-chars-from-slack-that-are-unique
```

3. Create a Slack App by following this tutorial on [Incoming Webhooks For Slack](https://slack.com/help/articles/115005265063-Incoming-Webhooks-for-Slack)

4. Check and see the channel you defined at #3 for incoming notification.

5. Configure the webhook and attach it to a policy.

B. Open the Admin panel and under “Xray Security & Compliance” you will see the option to define Webhooks:

![](https://greenido.files.wordpress.com/2020/03/define-1-screen-2020-03-28-at-6.33.59-pm.png?w=860)

C. You will get this screen, so you can add or edit your Webhooks

![](https://greenido.files.wordpress.com/2020/03/create-webhook-2020-03-28-at-6.34.07-pm.png?w=822)

D. Enter the URL end-point of your server. If you are using authentication (which is recommended) you need to enter the user/password.

![](https://greenido.files.wordpress.com/2020/03/screen-shot-2020-03-28-at-6.34.22-pm.png?w=856)

E. Open a policy with rules like in the example below.

![](https://greenido.files.wordpress.com/2020/03/screen-shot-2020-03-28-at-6.32.11-pm-1.png?w=1024)

F. On each rule you need to see that you attached the Webhook:

![](https://greenido.files.wordpress.com/2020/03/screen-shot-2020-03-28-at-6.32.35-pm.png?w=607)

That is it on the Xray side of the house.

6. Over on Slack – the messages should look like this:

![](https://camo.githubusercontent.com/52a6aab47085e2a2eb590c715dcd5444a79e1c5f/68747470733a2f2f63646e2e676c697463682e636f6d2f31386639376333662d623865662d343462612d613636312d65393135623331303639366425324653637265656e25323053686f74253230323032302d30332d32382532306174253230342e31342e3130253230504d2e706e673f763d31353835343337323938373637)

That’s it ![👊🏽](https://s0.wp.com/wp-content/mu-plugins/wpcom-smileys/twemoji/2/72x72/1f44a-1f3fd.png)

**Psst…** If you wish to be up and running without the need to install anything you can take [this project](https://glitch.com/edit/#!/xray-2-slack) and ‘remix’ it to create your own version. This will give you the option to have a server up and ready without the need to install it on your own.

Please feel free to improve this [project](https://github.com/greenido/jfrog-xray-2-slack-example) with ideas and pull requests.

If you have your own data that you want Xray to use – check how to create your [custom integration](https://dev.to/jfrog/how-to-build-an-integration-with-jfrog-xray-3pe3) with Xray. This option will give you the ability to enrich Xray’s data. All the details are in this [post](https://dev.to/jfrog/how-to-build-an-integration-with-jfrog-xray-3pe3).

Be safe and updated!