Skip to content

Commit 392484f

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
1 parent 5275d96 commit 392484f

File tree

3 files changed

+59
-134
lines changed

3 files changed

+59
-134
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

+35-98
Original file line numberDiff line numberDiff line change
@@ -1,152 +1,89 @@
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
10+
511
dockerhub-user:
612
required: false
713
default: ""
8-
description: username for dockerhub
14+
description: DockerHub username
915
dockerhub-password:
1016
required: false
1117
default: ""
12-
description: password for dockerhub
13-
docker-config-file:
18+
description: DockerHub password
19+
image-name:
1420
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:
1823
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
2029
lw-account-name:
2130
required: true
2231
description: Lacework account name
2332
lw-access-token:
2433
required: true
2534
description: Lacework access token
26-
image-name:
27-
required: false
28-
description: Docker image name
29-
image-tag:
35+
github-token:
3036
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
3738
build-args:
3839
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
4941

5042
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.
5445

5546
runs:
5647
using: composite
5748
steps:
5849
- name: Checkout Repository
50+
if: ${{ inputs.skip-checkout != 'true' }}
5951
uses: actions/checkout@v4
6052

61-
- name: Build docker image
53+
- name: Build Docker Image
6254
if: ${{ inputs.enable-docker-build }}
6355
uses: open-turo/actions-security/docker-build@v2
6456
id: docker-build
6557
with:
6658
dockerhub-user: ${{ inputs.dockerhub-user }}
6759
dockerhub-password: ${{ inputs.dockerhub-password }}
68-
github-token: ${{ inputs.github-token }}
6960
image-version: ${{ inputs.image-tag }}
70-
image-platform: ${{ inputs.image-platform }}
7161
load: true
7262
push: false
73-
docker-metadata-tags: |
74-
type=ref,event=branch
75-
type=ref,event=pr
7663
build-args: ${{ inputs.build-args }}
77-
secrets: ${{ inputs.secrets }}
7864

79-
- name: "Determining image name"
80-
shell: bash
81-
id: set_image_name
65+
- name: Determine Image Name
8266
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
8569
else
86-
echo "::set-output name=image_name::${{ inputs.image-name }}"
70+
echo "IMAGE_NAME=${{ inputs.image-name }}" >> $GITHUB_ENV
8771
fi
72+
shell: bash
8873

89-
- name: Scan container image for vulnerabilities using Lacework
74+
- name: Scan Container Image
9075
uses: lacework/lw-scanner-action@v1.4.3
9176
with:
9277
LW_ACCOUNT_NAME: ${{ inputs.lw-account-name }}
9378
LW_ACCESS_TOKEN: ${{ inputs.lw-access-token }}
94-
IMAGE_NAME: ${{ steps.set_image_name.outputs.image_name }}
79+
IMAGE_NAME: ${{ env.IMAGE_NAME }}
9580
IMAGE_TAG: ${{ inputs.image-tag }}
9681
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"
14783

148-
- name: Cleanup docker image
84+
- name: Cleanup Docker Image
14985
if: always()
15086
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 }}
15289
shell: bash

0 commit comments

Comments
 (0)