Skip to content

Commit b4fd165

Browse files
committed
test: implement Lacework scanner test workflow
- adds test workflow for scanning containers - formats scan results for New Relic integration - includes debug mode and configurable inputs - preserves results as workflow artifacts feat: update action.yaml for additional outputs (image-name, image-tag) for downstream processing chore: remove scan-output-test.yaml from branch fix: resolve set-output and input issues in container-scan action fix: resolving errors fix: align outputs and cleanup references in container scan action fix: add required inputs for container scan Added input definitions for: - lw-account-name - lw-access-token - github-token - build-args Pass build-args to docker-build action feat(action): add JSON output format support - Add output-format parameter to control scan results format - Pass format parameter to Lacework scanner - Default to JSON for better parsing fix(scan): disable verbose output for JSON format - Add scanner flag to output clean JSON - Enable proper parsing of scan results fix(scan): use correct JSON output flag for Lacework scanner - Add -j=true flag to force JSON output format - Remove output-format parameter fix(scan): use correct parameter name for JSON output - Replace SCANNER_FLAGS with ADDITIONAL_PARAMETERS - Maintain -j=true flag for JSON format feat: add optional skip-checkout input to container-scan action fix(ci): restore PR commenting and result formatting in security scan action - Added steps to check and delete previous PR comments to ensure clean re-runs. - Restored PR commenting functionality with formatted Lacework scan results. - Improved validation of to prevent runtime errors. - Ensured Docker images are properly cleaned up after the scan process. This change addresses feedback regarding missing PR comments and maintains the expected behavior of the workflow. fix(ci): restored ADDITIONAL_PARAMETERS to enable JSON output. fix: add missing shell property to container scan action fix: add winterjung/comment@v1, type: delete
1 parent 5275d96 commit b4fd165

File tree

3 files changed

+68
-100
lines changed

3 files changed

+68
-100
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ repos:
99
rev: v3.1.0
1010
hooks:
1111
- id: prettier
12-
stages: [commit]
12+
stages: [pre-commit]
1313
- repo: https://github.com/pre-commit/pre-commit-hooks
1414
rev: v5.0.0 # Use the ref you want to point at
1515
hooks:

container-scan/README.md

+23-35
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<!-- action-docs-description source="action.yaml" -->
55
## Description
66

7-
GitHub Action for scanning container image for vulnerabilities using Lacework
7+
GitHub Action for scanning container images for vulnerabilities using Lacework.
88
<!-- action-docs-description source="action.yaml" -->
99

1010
<!-- action-docs-usage source="action.yaml" -->
@@ -13,30 +13,42 @@ GitHub Action for scanning container image for vulnerabilities using Lacework
1313
```yaml
1414
- uses: @
1515
with:
16+
skip-checkout:
17+
# Skip repository checkout in this step
18+
#
19+
# Required: false
20+
# Default: false
21+
1622
dockerhub-user:
17-
# username for dockerhub
23+
# DockerHub username
1824
#
1925
# Required: false
2026
# Default: ""
2127

2228
dockerhub-password:
23-
# password for dockerhub
29+
# DockerHub password
2430
#
2531
# Required: false
2632
# Default: ""
2733

28-
docker-config-file:
29-
# Path to the docker config file (defaults to .docker-config.json) Must contain imageName, may contain dockerfile
34+
image-name:
35+
# Docker image name
3036
#
3137
# Required: false
32-
# Default: .docker-config.json
38+
# Default: ""
3339

34-
github-token:
35-
# GitHub token
40+
image-tag:
41+
# Docker image tag
3642
#
3743
# Required: true
3844
# Default: ""
3945

46+
enable-docker-build:
47+
# Enable Docker build
48+
#
49+
# Required: false
50+
# Default: true
51+
4052
lw-account-name:
4153
# Lacework account name
4254
#
@@ -49,41 +61,17 @@ GitHub Action for scanning container image for vulnerabilities using Lacework
4961
# Required: true
5062
# Default: ""
5163

52-
image-name:
53-
# Docker image name
54-
#
55-
# Required: false
56-
# Default: ""
57-
58-
image-tag:
59-
# Docker image tag
64+
github-token:
65+
# GitHub token
6066
#
6167
# Required: true
6268
# Default: ""
6369

64-
image-platform:
65-
# Target platform to build image for (eg. linux/amd64 (default), linux/arm64, etc)
66-
#
67-
# Required: false
68-
# Default: linux/amd64
69-
7070
build-args:
71-
# List of build arguments for docker build as key-value pairs (e.g., KEY=VALUE)
71+
# Docker build arguments
7272
#
7373
# Required: false
7474
# Default: ""
75-
76-
secrets:
77-
# List of secrets for docker build as key-value pairs (e.g., SECRET_KEY=VALUE)
78-
#
79-
# Required: false
80-
# Default: ""
81-
82-
enable-docker-build:
83-
# Docker image tag
84-
#
85-
# Required: false
86-
# Default: true
8775
```
8876
<!-- action-docs-usage source="action.yaml" -->
8977

container-scan/action.yaml

+44-64
Original file line numberDiff line numberDiff line change
@@ -1,116 +1,94 @@
11
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.
34
45
inputs:
6+
skip-checkout:
7+
required: false
8+
default: "false"
9+
description: Skip repository checkout in this step
510
dockerhub-user:
611
required: false
712
default: ""
8-
description: username for dockerhub
13+
description: DockerHub username
914
dockerhub-password:
1015
required: false
1116
default: ""
12-
description: password for dockerhub
13-
docker-config-file:
17+
description: DockerHub password
18+
image-name:
1419
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:
20+
description: Docker image name
21+
image-tag:
1822
required: true
19-
description: GitHub token
23+
description: Docker image tag
24+
enable-docker-build:
25+
required: false
26+
default: true
27+
description: Enable Docker build
2028
lw-account-name:
2129
required: true
2230
description: Lacework account name
2331
lw-access-token:
2432
required: true
2533
description: Lacework access token
26-
image-name:
27-
required: false
28-
description: Docker image name
29-
image-tag:
34+
github-token:
3035
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-
36+
description: GitHub token
3737
build-args:
3838
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
39+
description: Docker build arguments
4940

5041
outputs:
51-
comment-id:
52-
description: Comment ID of the test report
53-
value: ${{ steps.comment-pr.outputs.comment-id }}
42+
image-name:
43+
description: Name of the scanned Docker image.
5444

5545
runs:
5646
using: composite
5747
steps:
5848
- name: Checkout Repository
49+
if: ${{ inputs.skip-checkout != 'true' }}
5950
uses: actions/checkout@v4
6051

61-
- name: Build docker image
52+
- name: Build Docker Image
6253
if: ${{ inputs.enable-docker-build }}
6354
uses: open-turo/actions-security/docker-build@v2
6455
id: docker-build
6556
with:
6657
dockerhub-user: ${{ inputs.dockerhub-user }}
6758
dockerhub-password: ${{ inputs.dockerhub-password }}
68-
github-token: ${{ inputs.github-token }}
6959
image-version: ${{ inputs.image-tag }}
70-
image-platform: ${{ inputs.image-platform }}
71-
load: true
72-
push: false
73-
docker-metadata-tags: |
74-
type=ref,event=branch
75-
type=ref,event=pr
7660
build-args: ${{ inputs.build-args }}
77-
secrets: ${{ inputs.secrets }}
7861

79-
- name: "Determining image name"
80-
shell: bash
81-
id: set_image_name
62+
- name: Determine Image Name
8263
run: |
83-
if [ "${{ inputs.enable-docker-build }}" == "true" ]; then
84-
echo "::set-output name=image_name::${{ steps.docker-build.outputs.image-name }}"
64+
if [ "${{ inputs.enable-docker-build }}" = "true" ]; then
65+
echo "IMAGE_NAME=${{ steps.docker-build.outputs.image-name }}" >> $GITHUB_ENV
8566
else
86-
echo "::set-output name=image_name::${{ inputs.image-name }}"
67+
echo "IMAGE_NAME=${{ inputs.image-name }}" >> $GITHUB_ENV
8768
fi
69+
shell: bash
8870

89-
- name: Scan container image for vulnerabilities using Lacework
71+
- name: Scan Container Image
9072
uses: lacework/lw-scanner-action@v1.4.3
9173
with:
9274
LW_ACCOUNT_NAME: ${{ inputs.lw-account-name }}
9375
LW_ACCESS_TOKEN: ${{ inputs.lw-access-token }}
94-
IMAGE_NAME: ${{ steps.set_image_name.outputs.image_name }}
76+
IMAGE_NAME: ${{ env.IMAGE_NAME }}
9577
IMAGE_TAG: ${{ inputs.image-tag }}
9678
SAVE_RESULTS_IN_LACEWORK: true
97-
RESULTS_IN_GITHUB_SUMMARY: true
98-
PRETTY_OUTPUT: true
79+
ADDITIONAL_PARAMETERS: "-j=true"
9980

100-
- name: Check if Lacework scan results file exist
101-
id: check-results
81+
- name: Check Lacework Scan Results File
10282
run: |
10383
if [ -f results.stdout ]; then
104-
echo "Scan results file (results.stdout) exists"
105-
exit 0
84+
echo "Scan results file (results.stdout) exists."
10685
else
107-
echo "Scan results file (results.stdout) does not exist"
86+
echo "Error: Scan results file (results.stdout) does not exist."
10887
exit 1
10988
fi
11089
shell: bash
11190

112-
- name: Change formatting for PR
113-
if: always()
91+
- name: Format Results for PR
11492
run: |
11593
echo "## Lacework Inline Scanner Results" > pr-results.md
11694
echo "<details><summary>Click to expand</summary>" >> pr-results.md
@@ -120,9 +98,9 @@ runs:
12098
echo "</details>" >> pr-results.md
12199
shell: bash
122100

123-
- name: Check for previous report comment
124-
id: fc
125-
if: github.event_name == 'pull_request' && github.event.pull_request.number != ''
101+
- name: Check for Previous Report Comment
102+
id: find-comment
103+
if: github.event_name == 'pull_request'
126104
uses: peter-evans/find-comment@v3
127105
with:
128106
issue-number: ${{ github.event.pull_request.number }}
@@ -141,12 +119,14 @@ runs:
141119
if: github.event_name == 'pull_request'
142120
uses: thollander/actions-comment-pull-request@v3
143121
with:
144-
filePath: pr-results.md
122+
file-path: pr-results.md
145123
mode: recreate
146-
comment_tag: to_recreate
124+
comment-tag: to_recreate
125+
github-token: ${{ inputs.github-token }}
147126

148-
- name: Cleanup docker image
127+
- name: Cleanup Docker Image
149128
if: always()
150129
run: |
151-
docker image rm ${{ steps.docker-build.outputs.image-name }}:${{ inputs.image-tag }}
130+
echo "Cleaning up image: ${{ env.IMAGE_NAME }}:${{ inputs.image-tag }}"
131+
docker image rm ${{ env.IMAGE_NAME }}:${{ inputs.image-tag }}
152132
shell: bash

0 commit comments

Comments
 (0)