Skip to content

Slack

NightVision can deliver scan results to Slack based on the SARIF file created via nightvision sarif export. The SARIF output can be converted into many formats, including for Azure Boards, Slack, and more. This example code can be found at the following repo: Slack Integration Repository


  1. First, create a Slack app by going to (Slack API token create).

  2. Do not click on Generate Token - that will give you the wrong type of token. Click on the Create an App button.

  1. In the Create an App modal, click “From scratch”.

  1. Enter a name for the app, like “NightVision Scan Report Bot.” Select your workspace from the dropdown. Then click Create App.

  1. You will be redirected to the Basic Information tab for your app automatically. Select OAuth & Permissions from the sidebar.

  1. Scroll down to the Bot Token Scopes in the Scopes section. Select Add an OAuth Scope and add the following scopes to your token:
    1. chat:write: This allows your bot to send messages.
    2. files:write: This allows your bot to upload files
    3. chat:write.public (optional): This allows your bot to send messages to channels that it isn’t a member of.


  1. On the same page, scroll up to the OAuth Tokens section. Click on Install to<your workspace name> to authorize the permissions you have configured.

  1. After installing the app, you’ll redirected back to the OAuth & Permissions page. Here, you can find your Bot User OAuth Access Token. This token usually begins with xoxb-. Click Copy and save the token for later.
  2. Now go to your Slack workspace where the app was installed.
  3. Navigate to the channel where you want your app to post messages. In the chat, type: /invite @YourBotName and select the bot.


Adding the NightVision Slack Importer to a pipeline:

Section titled “Adding the NightVision Slack Importer to a pipeline:”

Adding the tool to any pipeline is very easy. You can take a look at the following GitHub workflow where the tool is included in the pipeline:

Slack Importer Repository

yaml
- name: (7) Install nightvision slack importer and dependencies
run: |
git clone https://github.com/jxbt/nightvision_slack_importer.git
cd nightvision_slack_importer
sudo apt-get update
sudo apt-get install -y python3-pip python3-venv google-chrome-stable
python3 -m venv .venv
source .venv/bin/activate
pip3 install -r requirements.txt
- name: (8) Run NightVision Slack Importer
run: |
cd nightvision_slack_importer
source .venv/bin/activate
python3 nightvision_slack_importer.py --sarif ../results.sarif --token ${{ env.SLACK_TOKEN }} --channel ${{ env.SLACK_CHANNEL_ID }}

You can also create this PDF locally with the following:

shell
# this will make a results.sarif file
nightvision export sarif -s $SCANID --swagger-file $PATH/$TO/openapi-spec.yml
# then download the repo and run the python script to make a pdf report
git clone https://github.com/alex-nightvision/nightvision_slack_importer.git
cd nightvision_slack_importer
pip3 install -r requirements.txt
python nightvision_slack_importer.py -l -f $PATH/$TO/results.sarif
shell
# this will make a results.sarif file
nightvision export sarif -s $SCANID --swagger-file $PATH/$TO/openapi-spec.yml
# then download the repo and run the python script to make a pdf report
git clone https://github.com/alex-nightvision/nightvision_slack_importer.git
cd nightvision_slack_importer
pip3 install -r requirements.txt
python nightvision_slack_importer.py -l -f $PATH/$TO/results.sarif