-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (60 loc) · 2.06 KB
/
Copy pathdocker-image-scan.yml
File metadata and controls
69 lines (60 loc) · 2.06 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
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@v5
- uses: actions/setup-python@v6
with:
python-version: '3.13'
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v5
with:
role-to-assume: arn:aws:iam::979633842206:role/EnergyAppsDeployment
role-session-name: energy-apps-trivy-scan
aws-region: eu-west-1
- name: ECR login
id: ecr-login
uses: aws-actions/amazon-ecr-login@v2
with:
registry-type: private
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
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 }}/energy-apps:latest
format: 'json'
output: 'trivy-results.json'
ignore-unfixed: true
- name: Upload scan results
id: upload-artifact
uses: actions/upload-artifact@v5
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: Energy Apps
SEVERITY: HIGH,CRITICAL
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
SLACK_CHANNEL_ID: "C08LQKF02TA" #content-platform_security
run: python3 -m trivy_image_slack_reporter