|
1 |
| -# GitHub Actions CI workflow that runs vulnerability scans on the application's Docker image |
2 |
| -# to ensure images built are secure before they are deployed. |
3 |
| - |
4 |
| -# NOTE: The workflow isn't able to pass the docker image between jobs, so each builds the image. |
5 |
| -# A future PR will pass the image between the scans to reduce overhead and increase speed |
6 |
| -name: Vulnerability Scans |
7 |
| - |
8 |
| -on: |
9 |
| - workflow_call: |
10 |
| - inputs: |
11 |
| - app_name: |
12 |
| - description: "name of application folder under infra directory" |
13 |
| - required: true |
14 |
| - type: string |
15 |
| - |
16 |
| -jobs: |
17 |
| - hadolint-scan: |
18 |
| - runs-on: ubuntu-latest |
19 |
| - |
20 |
| - steps: |
21 |
| - - uses: actions/checkout@v3 |
22 |
| - |
23 |
| - # Scans Dockerfile for any bad practices or issues |
24 |
| - - name: Scan Dockerfile by hadolint |
25 |
| - |
26 |
| - with: |
27 |
| - dockerfile: ${{ inputs.app_name }}/Dockerfile |
28 |
| - format: tty |
29 |
| - failure-threshold: warning |
30 |
| - output-file: hadolint-results.txt |
31 |
| - |
32 |
| - - name: Save output to workflow summary |
33 |
| - if: always() # Runs even if there is a failure |
34 |
| - run: cat hadolint-results.txt >> "$GITHUB_STEP_SUMMARY" |
35 |
| - |
36 |
| - trivy-scan: |
37 |
| - runs-on: ubuntu-latest |
38 |
| - |
39 |
| - steps: |
40 |
| - - uses: actions/checkout@v3 |
41 |
| - |
42 |
| - - name: Build and tag Docker image for scanning |
43 |
| - id: build-image |
44 |
| - run: | |
45 |
| - make APP_NAME=${{ inputs.app_name }} release-build |
46 |
| - IMAGE_NAME=$(make APP_NAME=${{ inputs.app_name }} release-image-name) |
47 |
| - IMAGE_TAG=$(make release-image-tag) |
48 |
| - echo "image=$IMAGE_NAME:$IMAGE_TAG" >> "$GITHUB_OUTPUT" |
49 |
| -
|
50 |
| - - name: Run Trivy vulnerability scan |
51 |
| - uses: aquasecurity/trivy-action@master |
52 |
| - with: |
53 |
| - scan-type: image |
54 |
| - image-ref: ${{ steps.build-image.outputs.image }} |
55 |
| - format: table |
56 |
| - exit-code: 1 |
57 |
| - ignore-unfixed: true |
58 |
| - vuln-type: os |
59 |
| - scanners: vuln,secret |
60 |
| - |
61 |
| - - name: Save output to workflow summary |
62 |
| - if: always() # Runs even if there is a failure |
63 |
| - run: | |
64 |
| - echo "View results in GitHub Action logs" >> "$GITHUB_STEP_SUMMARY" |
65 |
| -
|
66 |
| - anchore-scan: |
67 |
| - runs-on: ubuntu-latest |
68 |
| - |
69 |
| - steps: |
70 |
| - - uses: actions/checkout@v3 |
71 |
| - |
72 |
| - - name: Build and tag Docker image for scanning |
73 |
| - id: build-image |
74 |
| - run: | |
75 |
| - make APP_NAME=${{ inputs.app_name }} release-build |
76 |
| - IMAGE_NAME=$(make APP_NAME=${{ inputs.app_name }} release-image-name) |
77 |
| - IMAGE_TAG=$(make release-image-tag) |
78 |
| - echo "image=$IMAGE_NAME:$IMAGE_TAG" >> "$GITHUB_OUTPUT" |
79 |
| -
|
80 |
| - - name: Run Anchore vulnerability scan |
81 |
| - uses: anchore/scan-action@v3 |
82 |
| - with: |
83 |
| - image: ${{ steps.build-image.outputs.image }} |
84 |
| - output-format: table |
85 |
| - |
86 |
| - - name: Save output to workflow summary |
87 |
| - if: always() # Runs even if there is a failure |
88 |
| - run: echo "View results in GitHub Action logs" >> "$GITHUB_STEP_SUMMARY" |
89 |
| - |
90 |
| - dockle-scan: |
91 |
| - runs-on: ubuntu-latest |
92 |
| - |
93 |
| - steps: |
94 |
| - - uses: actions/checkout@v3 |
95 |
| - |
96 |
| - - name: Build and tag Docker image for scanning |
97 |
| - id: build-image |
98 |
| - run: | |
99 |
| - make APP_NAME=${{ inputs.app_name }} release-build |
100 |
| - IMAGE_NAME=$(make APP_NAME=${{ inputs.app_name }} release-image-name) |
101 |
| - IMAGE_TAG=$(make release-image-tag) |
102 |
| - echo "image=$IMAGE_NAME:$IMAGE_TAG" >> "$GITHUB_OUTPUT" |
103 |
| -
|
104 |
| - # Dockle doesn't allow you to have an ignore file for the DOCKLE_ACCEPT_FILES |
105 |
| - # variable, this will save the variable in this file to env for Dockle |
106 |
| - - name: Set any acceptable Dockle files |
107 |
| - run: | |
108 |
| - if grep -q "^DOCKLE_ACCEPT_FILES=.*" .dockleconfig; then |
109 |
| - grep -s '^DOCKLE_ACCEPT_FILES=' .dockleconfig >> "$GITHUB_ENV" |
110 |
| - fi |
111 |
| -
|
112 |
| - - name: Run Dockle container linter |
113 |
| - |
114 |
| - with: |
115 |
| - image: ${{ steps.build-image.outputs.image }} |
116 |
| - exit-code: "1" |
117 |
| - failure-threshold: WARN |
118 |
| - accept-filenames: ${{ env.DOCKLE_ACCEPT_FILES }} |
119 |
| - |
120 |
| - - name: Save output to workflow summary |
121 |
| - if: always() # Runs even if there is a failure |
122 |
| - run: | |
123 |
| - { |
124 |
| - echo '```json' |
125 |
| - cat dockle-report.json |
126 |
| - echo '```' |
127 |
| - } >> "$GITHUB_STEP_SUMMARY" |
| 1 | +# # GitHub Actions CI workflow that runs vulnerability scans on the application's Docker image |
| 2 | +# # to ensure images built are secure before they are deployed. |
| 3 | + |
| 4 | +# # NOTE: The workflow isn't able to pass the docker image between jobs, so each builds the image. |
| 5 | +# # A future PR will pass the image between the scans to reduce overhead and increase speed |
| 6 | +# name: Vulnerability Scans |
| 7 | + |
| 8 | +# on: |
| 9 | +# workflow_call: |
| 10 | +# inputs: |
| 11 | +# app_name: |
| 12 | +# description: "name of application folder under infra directory" |
| 13 | +# required: true |
| 14 | +# type: string |
| 15 | + |
| 16 | +# jobs: |
| 17 | +# hadolint-scan: |
| 18 | +# runs-on: ubuntu-latest |
| 19 | + |
| 20 | +# steps: |
| 21 | +# - uses: actions/checkout@v3 |
| 22 | + |
| 23 | +# # Scans Dockerfile for any bad practices or issues |
| 24 | +# - name: Scan Dockerfile by hadolint |
| 25 | +# uses: hadolint/[email protected] |
| 26 | +# with: |
| 27 | +# dockerfile: ${{ inputs.app_name }}/Dockerfile |
| 28 | +# format: tty |
| 29 | +# failure-threshold: warning |
| 30 | +# output-file: hadolint-results.txt |
| 31 | + |
| 32 | +# - name: Save output to workflow summary |
| 33 | +# if: always() # Runs even if there is a failure |
| 34 | +# run: cat hadolint-results.txt >> "$GITHUB_STEP_SUMMARY" |
| 35 | + |
| 36 | +# trivy-scan: |
| 37 | +# runs-on: ubuntu-latest |
| 38 | + |
| 39 | +# steps: |
| 40 | +# - uses: actions/checkout@v3 |
| 41 | + |
| 42 | +# - name: Build and tag Docker image for scanning |
| 43 | +# id: build-image |
| 44 | +# run: | |
| 45 | +# make APP_NAME=${{ inputs.app_name }} release-build |
| 46 | +# IMAGE_NAME=$(make APP_NAME=${{ inputs.app_name }} release-image-name) |
| 47 | +# IMAGE_TAG=$(make release-image-tag) |
| 48 | +# echo "image=$IMAGE_NAME:$IMAGE_TAG" >> "$GITHUB_OUTPUT" |
| 49 | + |
| 50 | +# - name: Run Trivy vulnerability scan |
| 51 | +# uses: aquasecurity/trivy-action@master |
| 52 | +# with: |
| 53 | +# scan-type: image |
| 54 | +# image-ref: ${{ steps.build-image.outputs.image }} |
| 55 | +# format: table |
| 56 | +# exit-code: 1 |
| 57 | +# ignore-unfixed: true |
| 58 | +# vuln-type: os |
| 59 | +# scanners: vuln,secret |
| 60 | + |
| 61 | +# - name: Save output to workflow summary |
| 62 | +# if: always() # Runs even if there is a failure |
| 63 | +# run: | |
| 64 | +# echo "View results in GitHub Action logs" >> "$GITHUB_STEP_SUMMARY" |
| 65 | + |
| 66 | +# anchore-scan: |
| 67 | +# runs-on: ubuntu-latest |
| 68 | + |
| 69 | +# steps: |
| 70 | +# - uses: actions/checkout@v3 |
| 71 | + |
| 72 | +# - name: Build and tag Docker image for scanning |
| 73 | +# id: build-image |
| 74 | +# run: | |
| 75 | +# make APP_NAME=${{ inputs.app_name }} release-build |
| 76 | +# IMAGE_NAME=$(make APP_NAME=${{ inputs.app_name }} release-image-name) |
| 77 | +# IMAGE_TAG=$(make release-image-tag) |
| 78 | +# echo "image=$IMAGE_NAME:$IMAGE_TAG" >> "$GITHUB_OUTPUT" |
| 79 | + |
| 80 | +# - name: Run Anchore vulnerability scan |
| 81 | +# uses: anchore/scan-action@v3 |
| 82 | +# with: |
| 83 | +# image: ${{ steps.build-image.outputs.image }} |
| 84 | +# output-format: table |
| 85 | + |
| 86 | +# - name: Save output to workflow summary |
| 87 | +# if: always() # Runs even if there is a failure |
| 88 | +# run: echo "View results in GitHub Action logs" >> "$GITHUB_STEP_SUMMARY" |
| 89 | + |
| 90 | +# dockle-scan: |
| 91 | +# runs-on: ubuntu-latest |
| 92 | + |
| 93 | +# steps: |
| 94 | +# - uses: actions/checkout@v3 |
| 95 | + |
| 96 | +# - name: Build and tag Docker image for scanning |
| 97 | +# id: build-image |
| 98 | +# run: | |
| 99 | +# make APP_NAME=${{ inputs.app_name }} release-build |
| 100 | +# IMAGE_NAME=$(make APP_NAME=${{ inputs.app_name }} release-image-name) |
| 101 | +# IMAGE_TAG=$(make release-image-tag) |
| 102 | +# echo "image=$IMAGE_NAME:$IMAGE_TAG" >> "$GITHUB_OUTPUT" |
| 103 | + |
| 104 | +# # Dockle doesn't allow you to have an ignore file for the DOCKLE_ACCEPT_FILES |
| 105 | +# # variable, this will save the variable in this file to env for Dockle |
| 106 | +# - name: Set any acceptable Dockle files |
| 107 | +# run: | |
| 108 | +# if grep -q "^DOCKLE_ACCEPT_FILES=.*" .dockleconfig; then |
| 109 | +# grep -s '^DOCKLE_ACCEPT_FILES=' .dockleconfig >> "$GITHUB_ENV" |
| 110 | +# fi |
| 111 | + |
| 112 | +# - name: Run Dockle container linter |
| 113 | + |
| 114 | +# with: |
| 115 | +# image: ${{ steps.build-image.outputs.image }} |
| 116 | +# exit-code: "1" |
| 117 | +# failure-threshold: WARN |
| 118 | +# accept-filenames: ${{ env.DOCKLE_ACCEPT_FILES }} |
| 119 | + |
| 120 | +# - name: Save output to workflow summary |
| 121 | +# if: always() # Runs even if there is a failure |
| 122 | +# run: | |
| 123 | +# { |
| 124 | +# echo '```json' |
| 125 | +# cat dockle-report.json |
| 126 | +# echo '```' |
| 127 | +# } >> "$GITHUB_STEP_SUMMARY" |
0 commit comments