Skip to content

Commit 9f33f90

Browse files
patrickmoore-ncmicjustus-nc
authored andcommitted
new CI workflow template
1 parent 45b22d6 commit 9f33f90

File tree

3 files changed

+167
-111
lines changed

3 files changed

+167
-111
lines changed

.github/actions/create-sbom-report/action.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
name: Software Bill of Materials Report
2+
<<<<<<< HEAD
23
description: Generates and uploads an SBOM report for the specified Docker image.
4+
=======
5+
>>>>>>> e78d94f (new CI workflow template)
36

47
inputs:
58
build_datetime:
@@ -8,10 +11,17 @@ inputs:
811
build_timestamp:
912
description: Build timestamp, set by the CI/CD pipeline workflow
1013
required: true
14+
<<<<<<< HEAD
15+
=======
16+
project_name:
17+
description: Project Name
18+
required: true
19+
>>>>>>> e78d94f (new CI workflow template)
1120
image_name:
1221
description: Docker Image to be scanned
1322
required: true
1423

24+
<<<<<<< HEAD
1525
outputs:
1626
sbom_repository_report:
1727
value: ${{ steps.report.outputs.sbom_repository_report }}
@@ -31,10 +41,30 @@ runs:
3141
mkdir sbom
3242
echo "sbom_repository_report=${SBOM_REPOSITORY_REPORT}" >> ${GITHUB_OUTPUT}
3343
bash ${GITHUB_WORKSPACE}/templates/scripts/reports/create-sbom-report.sh
44+
=======
45+
runs:
46+
using: composite
47+
env:
48+
BUILD_DATETIME: ${{ inputs.build_datetime }}
49+
SBOM_REPOSITORY_REPORT: sbom/sbom-${{ inputs.image_name }}-repository-report
50+
CHECK_DOCKER_IMAGE: ${{ inputs.project_name }}-${{ inputs.image_name }}:latest
51+
FORCE_USE_DOCKER: true
52+
steps:
53+
- name: Create SBOM report
54+
run: |
55+
mkdir sbom
56+
echo "sbom_repository_report=${SBOM_REPOSITORY_REPORT}" >> ${GITHUB_OUTPUT}
57+
${GITHUB_WORKSPACE}/templates/scripts/reports/create-sbom-report.sh
58+
>>>>>>> e78d94f (new CI workflow template)
3459

3560
- name: Upload SBOM report as an artefact
3661
uses: actions/upload-artifact@v4
3762
with:
63+
<<<<<<< HEAD
3864
name: ${{ inputs.image_name }}-sbom
3965
path: ${{ inputs.image_name }}-sbom.json
66+
=======
67+
name: sbom-${{ inputs.image_name }}-repository-report.json
68+
path: ${{ env.SBOM_REPOSITORY_REPORT }}.json
69+
>>>>>>> e78d94f (new CI workflow template)
4070
retention-days: 21

.github/actions/scan-vulnerabilities/action.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
name: Vulnerabilities Report
2+
<<<<<<< HEAD
23
description: Generates and uploads a vulnerability report from an SBOM for the given image.
4+
=======
5+
>>>>>>> e78d94f (new CI workflow template)
36

47
inputs:
58
build_datetime:
@@ -8,11 +11,18 @@ inputs:
811
build_timestamp:
912
description: Build timestamp, set by the CI/CD pipeline workflow
1013
required: true
14+
<<<<<<< HEAD
15+
=======
16+
project_name:
17+
description: Project Name
18+
required: true
19+
>>>>>>> e78d94f (new CI workflow template)
1120
image_name:
1221
description: Docker Image to be scanned
1322
required: true
1423
sbom_repository_report:
1524
description: File path of SBOM report
25+
<<<<<<< HEAD
1626
required: true
1727

1828
runs:
@@ -28,13 +38,32 @@ runs:
2838
VULNERABILITIES_REPOSITORY_REPORT: ${{ inputs.image_name }}-vulnerabilities-repository-report
2939
VULNERABILITIES_SUMMARY_LOGFILE: ${{ inputs.image_name }}-vulnerabilities-summary.txt
3040
SBOM_REPOSITORY_REPORT: ${{ inputs.sbom_repository_report }}
41+
=======
42+
required: true
43+
44+
runs:
45+
using: composite
46+
env:
47+
BUILD_DATETIME: ${{ inputs.build_datetime }}
48+
CHECK_DOCKER_IMAGE: ${{ inputs.project_name }}-${{ inputs.image_name }}:latest
49+
FORCE_USE_DOCKER: true
50+
VULNERABILITIES_REPOSITORY_REPORT: ${{ inputs.image_name }}-vulnerabilities-repository-report
51+
VULNERABILITIES_SUMMARY_LOGFILE: ${{ inputs.image_name }}-vulnerabilities-summary.txt
52+
SBOM_REPOSITORY_REPORT: {{ inputs.sbom_repository_report }}
53+
steps:
54+
- name: Create vulnerabilites report
55+
>>>>>>> e78d94f (new CI workflow template)
3156
run: |
3257
mkdir vulnerabilities
3358
bash -x ${GITHUB_WORKSPACE}/templates/scripts/reports/scan-vulnerabilities.sh
3459
curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | sudo sh -s -- -b /usr/local/bin
60+
<<<<<<< HEAD
3561

3662
SCAN_RESULTS=$(grype "${CHECK_DOCKER_IMAGE}" --scope all-layers)
3763
echo "${SCAN_RESULTS}" > "vulnerabilities/${VULNERABILITIES_REPOSITORY_REPORT}.json"
64+
=======
65+
SCAN_RESULTS=$(grype "${{ inputs.image_name }}:latest" --scope all-layers)
66+
>>>>>>> e78d94f (new CI workflow template)
3867

3968
# ANSI color codes
4069
RED="\033[0;31m"
@@ -46,6 +75,7 @@ runs:
4675
for SEVERITY in CRITICAL HIGH MEDIUM; do
4776
{
4877
echo
78+
<<<<<<< HEAD
4979
echo "${CHECK_DOCKER_IMAGE}: vulnerabilities"
5080
echo -e "=== ${RED}${SEVERITY}${RESET} Vulnerabilities list ==="
5181
# If grep finds nothing, we print a fallback message
@@ -60,4 +90,20 @@ runs:
6090
path: |
6191
vulnerabilities/${{ inputs.image_name }}-vulnerabilities-repository-report.json
6292
vulnerabilities/${{ inputs.image_name }}-vulnerabilities-summary.txt
93+
=======
94+
echo "${{ inputs.image_name }}: vulnerabilities"
95+
echo -e "=== ${RED}${SEVERITY}${RESET} Vulnerabilities list ==="
96+
# If grep finds nothing, we print a fallback message
97+
echo "${SCAN_RESULTS}" | grep -i "${SEVERITY}" || echo "No ${SEVERITY} vulnerabilities found."
98+
} | tee -a "vunerabilities/${VULNERABILITIES_SUMMARY_LOGFILE}"
99+
done
100+
101+
- name: Upload vulnerabilities report
102+
uses: actions/upload-artifact@v4
103+
with:
104+
name: ${{ env.VULNERABILITIES_REPOSITORY_REPORT }}.json
105+
path: |
106+
vulnerabilities/${{ env.VULNERABILITIES_REPOSITORY_REPORT }}.json
107+
vulnerabilities/${{ env.VULNERABILITIES_SUMMARY_LOGFILE }}.json
108+
>>>>>>> e78d94f (new CI workflow template)
63109
retention-days: 21

0 commit comments

Comments
 (0)