-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (75 loc) · 2.88 KB
/
Copy pathdocker-image-scan.yml
File metadata and controls
85 lines (75 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: Docker Image Security Scan
on:
schedule:
# Runs at 10:00 AM UTC every Monday
- cron: '0 10 * * 1'
# Optional: Allow manual triggering
workflow_dispatch:
jobs:
scan:
name: Scan Latest Image
runs-on: runs-on
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1
with:
python-version: '3.13'
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@e6de054238d6b7531b4efff3b6587d9aade6a06c
with:
role-to-assume: arn:aws:iam::979633842206:role/LocalOfficeSearchApiDeployment
role-session-name: local-office-search-api-trivy-scan
aws-region: eu-west-1
- name: ECR login
id: ecr-login
uses: aws-actions/amazon-ecr-login@d539f0932e70871a027e9d5a9d8fc38589180a64
with:
registry-type: private
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25
id: trivy-scan
env:
TRIVY_JAVA_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-java-db
TRIVY_DB_REPOSITORY: public.ecr.aws/aquasecurity/trivy-db
TRIVY_DISABLE_VEX_NOTICE: true
with:
image-ref: ${{ steps.ecr-login.outputs.registry }}/local-office-search-api:latest
format: 'json'
output: 'trivy-results.json'
ignore-unfixed: true
- name: Upload scan results
id: upload-artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
with:
name: trivy-scan-results
path: trivy-results.json
retention-days: 7
- name: Install Dependency
run: pip install git+https://github.com/citizensadvice/trivy-image-slack-reporter.git@2.0.0
- name: Send Slack notification
env:
RESULTS_FILE: trivy-results.json
ARTIFACT_URL: ${{ steps.upload-artifact.outputs.artifact-url }}
IMAGE_TITLE: Local Office Search API
SEVERITY: HIGH,CRITICAL
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
SLACK_CHANNEL_ID: "C08LQKF02TA" #content-platform_security
run: python3 -m trivy_image_slack_reporter
slack-failure:
name: Slack Notification (Failure)
runs-on: runs-on
needs: scan
if: failure()
steps:
- name: Notify Slack
uses: citizensadvice/message-slack-action@080d90bef86e16b0f1d9b07406fad8a9f541fc27
with:
slack_bot_token: ${{ secrets.SLACK_BOT_TOKEN }}
github_token: ${{ secrets.GITHUB_TOKEN }}
channel_id: "C08LQKF02TA" #content-platform_security
title: ":x: :shield: Trivy scan failure for Local Office Search API"
message: |
Trivy scan job failed.