|
1 | 1 | name: "Security Scan Composite Action"
|
2 |
| -description: "GitHub Action for scanning container image for vulnerabilities using Lacework" |
| 2 | +description: > |
| 3 | + GitHub Action for scanning container images for vulnerabilities using Lacework. |
3 | 4 |
|
4 | 5 | inputs:
|
| 6 | + skip-checkout: |
| 7 | + required: false |
| 8 | + default: "false" |
| 9 | + description: Skip repository checkout in this step |
| 10 | + |
5 | 11 | dockerhub-user:
|
6 | 12 | required: false
|
7 | 13 | default: ""
|
8 |
| - description: username for dockerhub |
| 14 | + description: DockerHub username |
9 | 15 | dockerhub-password:
|
10 | 16 | required: false
|
11 | 17 | default: ""
|
12 |
| - description: password for dockerhub |
13 |
| - docker-config-file: |
| 18 | + description: DockerHub password |
| 19 | + image-name: |
14 | 20 | required: false
|
15 |
| - description: Path to the docker config file (defaults to .docker-config.json) Must contain imageName, may contain dockerfile |
16 |
| - default: .docker-config.json |
17 |
| - github-token: |
| 21 | + description: Docker image name |
| 22 | + image-tag: |
18 | 23 | required: true
|
19 |
| - description: GitHub token |
| 24 | + description: Docker image tag |
| 25 | + enable-docker-build: |
| 26 | + required: false |
| 27 | + default: true |
| 28 | + description: Enable Docker build |
20 | 29 | lw-account-name:
|
21 | 30 | required: true
|
22 | 31 | description: Lacework account name
|
23 | 32 | lw-access-token:
|
24 | 33 | required: true
|
25 | 34 | description: Lacework access token
|
26 |
| - image-name: |
27 |
| - required: false |
28 |
| - description: Docker image name |
29 |
| - image-tag: |
| 35 | + github-token: |
30 | 36 | required: true
|
31 |
| - description: Docker image tag |
32 |
| - image-platform: |
33 |
| - description: Target platform to build image for (eg. linux/amd64 (default), linux/arm64, etc) |
34 |
| - required: false |
35 |
| - default: linux/amd64 |
36 |
| - |
| 37 | + description: GitHub token |
37 | 38 | build-args:
|
38 | 39 | required: false
|
39 |
| - description: List of build arguments for docker build as key-value pairs (e.g., KEY=VALUE) |
40 |
| - default: "" |
41 |
| - secrets: |
42 |
| - required: false |
43 |
| - description: List of secrets for docker build as key-value pairs (e.g., SECRET_KEY=VALUE) |
44 |
| - default: "" |
45 |
| - enable-docker-build: |
46 |
| - required: false |
47 |
| - default: true |
48 |
| - description: Docker image tag |
| 40 | + description: Docker build arguments |
49 | 41 |
|
50 | 42 | outputs:
|
51 |
| - comment-id: |
52 |
| - description: Comment ID of the test report |
53 |
| - value: ${{ steps.comment-pr.outputs.comment-id }} |
| 43 | + image-name: |
| 44 | + description: Name of the scanned Docker image. |
54 | 45 |
|
55 | 46 | runs:
|
56 | 47 | using: composite
|
57 | 48 | steps:
|
58 | 49 | - name: Checkout Repository
|
| 50 | + if: ${{ inputs.skip-checkout != 'true' }} |
59 | 51 | uses: actions/checkout@v4
|
60 | 52 |
|
61 |
| - - name: Build docker image |
| 53 | + - name: Build Docker Image |
62 | 54 | if: ${{ inputs.enable-docker-build }}
|
63 | 55 | uses: open-turo/actions-security/docker-build@v2
|
64 | 56 | id: docker-build
|
65 | 57 | with:
|
66 | 58 | dockerhub-user: ${{ inputs.dockerhub-user }}
|
67 | 59 | dockerhub-password: ${{ inputs.dockerhub-password }}
|
68 |
| - github-token: ${{ inputs.github-token }} |
69 | 60 | image-version: ${{ inputs.image-tag }}
|
70 |
| - image-platform: ${{ inputs.image-platform }} |
71 | 61 | load: true
|
72 | 62 | push: false
|
73 |
| - docker-metadata-tags: | |
74 |
| - type=ref,event=branch |
75 |
| - type=ref,event=pr |
76 | 63 | build-args: ${{ inputs.build-args }}
|
77 |
| - secrets: ${{ inputs.secrets }} |
78 | 64 |
|
79 |
| - - name: "Determining image name" |
80 |
| - shell: bash |
81 |
| - id: set_image_name |
| 65 | + - name: Determine Image Name |
82 | 66 | run: |
|
83 |
| - if [ "${{ inputs.enable-docker-build }}" == "true" ]; then |
84 |
| - echo "::set-output name=image_name::${{ steps.docker-build.outputs.image-name }}" |
| 67 | + if [ "${{ inputs.enable-docker-build }}" = "true" ]; then |
| 68 | + echo "IMAGE_NAME=${{ steps.docker-build.outputs.image-name }}" >> $GITHUB_ENV |
85 | 69 | else
|
86 |
| - echo "::set-output name=image_name::${{ inputs.image-name }}" |
| 70 | + echo "IMAGE_NAME=${{ inputs.image-name }}" >> $GITHUB_ENV |
87 | 71 | fi
|
| 72 | + shell: bash |
88 | 73 |
|
89 |
| - - name: Scan container image for vulnerabilities using Lacework |
| 74 | + - name: Scan Container Image |
90 | 75 | uses: lacework/lw-scanner-action@v1.4.3
|
91 | 76 | with:
|
92 | 77 | LW_ACCOUNT_NAME: ${{ inputs.lw-account-name }}
|
93 | 78 | LW_ACCESS_TOKEN: ${{ inputs.lw-access-token }}
|
94 |
| - IMAGE_NAME: ${{ steps.set_image_name.outputs.image_name }} |
| 79 | + IMAGE_NAME: ${{ env.IMAGE_NAME }} |
95 | 80 | IMAGE_TAG: ${{ inputs.image-tag }}
|
96 | 81 | SAVE_RESULTS_IN_LACEWORK: true
|
97 |
| - RESULTS_IN_GITHUB_SUMMARY: true |
98 |
| - PRETTY_OUTPUT: true |
99 |
| - |
100 |
| - - name: Check if Lacework scan results file exist |
101 |
| - id: check-results |
102 |
| - run: | |
103 |
| - if [ -f results.stdout ]; then |
104 |
| - echo "Scan results file (results.stdout) exists" |
105 |
| - exit 0 |
106 |
| - else |
107 |
| - echo "Scan results file (results.stdout) does not exist" |
108 |
| - exit 1 |
109 |
| - fi |
110 |
| - shell: bash |
111 |
| - |
112 |
| - - name: Change formatting for PR |
113 |
| - if: always() |
114 |
| - run: | |
115 |
| - echo "## Lacework Inline Scanner Results" > pr-results.md |
116 |
| - echo "<details><summary>Click to expand</summary>" >> pr-results.md |
117 |
| - echo "<pre>" >> pr-results.md |
118 |
| - cat results.stdout >> pr-results.md |
119 |
| - echo "</pre>" >> pr-results.md |
120 |
| - echo "</details>" >> pr-results.md |
121 |
| - shell: bash |
122 |
| - |
123 |
| - - name: Check for previous report comment |
124 |
| - id: fc |
125 |
| - if: github.event_name == 'pull_request' && github.event.pull_request.number != '' |
126 |
| - uses: peter-evans/find-comment@v3 |
127 |
| - with: |
128 |
| - issue-number: ${{ github.event.pull_request.number }} |
129 |
| - comment-author: "github-actions[bot]" |
130 |
| - body-includes: "Lacework Inline Scanner Results" |
131 |
| - |
132 |
| - - name: Delete previous test report comment |
133 |
| - if: github.event_name == 'pull_request' && steps.fc.outputs.comment-id != '' |
134 |
| - uses: winterjung/comment@v1 |
135 |
| - with: |
136 |
| - type: delete |
137 |
| - comment_id: ${{ steps.fc.outputs.comment-id }} |
138 |
| - token: ${{ inputs.github-token }} |
139 |
| - |
140 |
| - - name: Comment PR |
141 |
| - if: github.event_name == 'pull_request' |
142 |
| - uses: thollander/actions-comment-pull-request@v3 |
143 |
| - with: |
144 |
| - filePath: pr-results.md |
145 |
| - mode: recreate |
146 |
| - comment_tag: to_recreate |
| 82 | + ADDITIONAL_PARAMETERS: "-j=true" |
147 | 83 |
|
148 |
| - - name: Cleanup docker image |
| 84 | + - name: Cleanup Docker Image |
149 | 85 | if: always()
|
150 | 86 | run: |
|
151 |
| - docker image rm ${{ steps.docker-build.outputs.image-name }}:${{ inputs.image-tag }} |
| 87 | + echo "Cleaning up image: ${{ env.IMAGE_NAME }}:${{ inputs.image-tag }}" |
| 88 | + docker image rm ${{ env.IMAGE_NAME }}:${{ inputs.image-tag }} |
152 | 89 | shell: bash
|
0 commit comments