-
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@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405
with:
python-version: '3.13'
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@ec61189d14ec14c8efccab744f656cffd0e33f37
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@f2e9fc6c2b355c1890b65e6f6f0e2ac3e6e22f78
with:
registry-type: private
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@57a97c7e7821a5776cebc9bb87c984fa69cba8f1
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@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f
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@c510788139115d15c3b36f95a3497c6b15172165
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.