1+ # Copyright (C) 2024 Intel Corporation
2+ # SPDX-License-Identifier: Apache-2.0
3+
4+ name : Manual Image BoM and CVE Scan
5+ on :
6+ workflow_dispatch :
7+ inputs :
8+ node :
9+ default : " gaudi"
10+ description : " Hardware to run scan"
11+ required : true
12+ type : string
13+ tag :
14+ # default: "latest"
15+ default : " test1"
16+ description : " Tag for images to scan"
17+ required : true
18+ type : string
19+ sbom_scan :
20+ default : true
21+ description : ' Scan images for BoM'
22+ required : false
23+ type : boolean
24+ trivy_scan :
25+ default : true
26+ description : ' Scan images for CVE'
27+ required : false
28+ type : boolean
29+
30+ permissions : read-all
31+ jobs :
32+ clean-workspace :
33+ runs-on : " docker-build-${{ inputs.node }}"
34+ steps :
35+ - name : Clean up Working Directory
36+ run : |
37+ sudo rm -rf ${{github.workspace}}/* || true
38+ # docker system prune -f
39+
40+ scan-docker :
41+ needs : clean-workspace
42+ runs-on : " docker-build-${{ inputs.node }}"
43+ strategy :
44+ matrix :
45+ image : ["studio-frontend", "studio-backend", "app-frontend", "app-backend"]
46+ fail-fast : false
47+ steps :
48+ - name : Pull Image
49+ run : |
50+ docker pull ${OPEA_IMAGE_REPO}opea/${{ matrix.image }}:${{ inputs.tag }}
51+ echo "OPEA_IMAGE_REPO=${OPEA_IMAGE_REPO}" >> $GITHUB_ENV
52+
53+ - name : SBOM Scan Container
54+ 55+ if : ${{ inputs.sbom_scan }}
56+ with :
57+ image : ${{ env.OPEA_IMAGE_REPO }}opea/${{ matrix.image }}:${{ inputs.tag }}
58+ output-file : ${{ matrix.image }}-sbom-scan.txt
59+ format : ' spdx-json'
60+
61+ - name : Security Scan Container
62+ uses :
aquasecurity/[email protected] 63+ if : ${{ inputs.trivy_scan }}
64+ with :
65+ image-ref : ${{ env.OPEA_IMAGE_REPO }}opea/${{ matrix.image }}:${{ inputs.tag }}
66+ output : ${{ matrix.image }}-trivy-scan.txt
67+ format : ' table'
68+ exit-code : ' 1'
69+ ignore-unfixed : true
70+ vuln-type : ' os,library'
71+ severity : ' CRITICAL,HIGH'
72+
73+ - name : Cleanup
74+ if : always()
75+ run : docker rmi -f ${OPEA_IMAGE_REPO}opea/${{ matrix.image }}:${{ inputs.tag }} || true
76+
77+ - name : Collect Logs
78+ if : always()
79+ run : |
80+ mkdir -p /tmp/scan-${{ inputs.tag }}-${{ github.run_number }}
81+ mv ${{ matrix.image }}-*-scan.txt /tmp/scan-${{ inputs.tag }}-${{ github.run_number }}
82+
83+ upload-artifacts :
84+ needs : scan-docker
85+ runs-on : " docker-build-${{ inputs.node }}"
86+ if : always()
87+ steps :
88+ - name : Upload SBOM Artifacts
89+ 90+ with :
91+ name : sbom-scan-${{ inputs.tag }}-${{ github.run_number }}
92+ path : /tmp/scan-${{ inputs.tag }}-${{ github.run_number }}/*-sbom-scan.txt
93+ overwrite : true
94+
95+ - name : Upload Trivy Artifacts
96+ 97+ with :
98+ name : trivy-scan-${{ inputs.tag }}-${{ github.run_number }}
99+ path : /tmp/scan-${{ inputs.tag }}-${{ github.run_number }}/*-trivy-scan.txt
100+ overwrite : true
101+
102+ - name : Remove Logs
103+ run : rm -rf /tmp/scan-${{ inputs.tag }}-${{ github.run_number }} && rm -rf /tmp/sbom-action-*
0 commit comments