Skip to content

Commit

Permalink
Disable the Slack notifications for Docker Image scans (#1956)
Browse files Browse the repository at this point in the history
* Making slack notification optional for docker image scan.

* Moving slack-init step.

* Moving slack-init step.
  • Loading branch information
mishah334 committed Aug 14, 2023
1 parent 9a9b0b6 commit a6bc2db
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 20 deletions.
29 changes: 19 additions & 10 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ jobs:
report_url:
type: string
default: ""
slack_notify:
type: boolean
default: false
environment:
SCAN_IMAGE: << parameters.docker_image >>
SCAN_TOOL: Trivy
Expand All @@ -61,16 +64,21 @@ jobs:
- run:
name: Scan the local image with trivy
command: bin/trivy-scan.sh "<< parameters.docker_image >>" ".circleci/trivyignore"
- run:
name: Slack Init
command: |
echo 'export SLACK_MSG_TEMPLATE=$(cat ./.circleci/slack_message_templates/security_scan_fail.json)' >> $BASH_ENV
source $BASH_ENV
when: on_fail
- slack/notify:
event: fail
template: SLACK_MSG_TEMPLATE
channel: C03HS1H9G1E
- when:
condition:
or:
- << parameters.slack_notify >>
steps:
- run:
name: Slack Init
command: |
echo 'export SLACK_MSG_TEMPLATE=$(cat ./.circleci/slack_message_templates/security_scan_fail.json)' >> $BASH_ENV
source $BASH_ENV
when: on_fail
- slack/notify:
event: fail
template: SLACK_MSG_TEMPLATE
channel: C03HS1H9G1E
- save_cache:
key: trivy-cache-{{ checksum "date" }}
paths:
Expand Down Expand Up @@ -346,6 +354,7 @@ workflows:
jobs:
- trivy-scan-docker:
report_url: << pipeline.parameters.scan-docker-images-report-url >>
slack_notify: false
matrix:
parameters:
docker_image:
Expand Down
29 changes: 19 additions & 10 deletions .circleci/config.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ jobs:
report_url:
type: string
default: ""
slack_notify:
type: boolean
default: false
environment:
SCAN_IMAGE: << parameters.docker_image >>
SCAN_TOOL: Trivy
Expand All @@ -59,16 +62,21 @@ jobs:
- run:
name: Scan the local image with trivy
command: bin/trivy-scan.sh "<< parameters.docker_image >>" ".circleci/trivyignore"
- run:
name: Slack Init
command: |
echo 'export SLACK_MSG_TEMPLATE=$(cat ./.circleci/slack_message_templates/security_scan_fail.json)' >> $BASH_ENV
source $BASH_ENV
when: on_fail
- slack/notify:
event: fail
template: SLACK_MSG_TEMPLATE
channel: C03HS1H9G1E
- when:
condition:
or:
- << parameters.slack_notify >>
steps:
- run:
name: Slack Init
command: |
echo 'export SLACK_MSG_TEMPLATE=$(cat ./.circleci/slack_message_templates/security_scan_fail.json)' >> $BASH_ENV
source $BASH_ENV
when: on_fail
- slack/notify:
event: fail
template: SLACK_MSG_TEMPLATE
channel: C03HS1H9G1E
- save_cache:
{% raw %}key: trivy-cache-{{ checksum "date" }}{% endraw %}
paths:
Expand Down Expand Up @@ -281,6 +289,7 @@ workflows:
jobs:
- trivy-scan-docker:
report_url: << pipeline.parameters.scan-docker-images-report-url >>
slack_notify: false
matrix:
parameters:
docker_image:
Expand Down

0 comments on commit a6bc2db

Please sign in to comment.