Skip to content

Commit 4500d38

Browse files
committed
Use syft for SBOM when image is nap-waf
1 parent b4a6a0b commit 4500d38

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

.github/workflows/build.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ jobs:
148148
cache-to: type=gha,scope=${{ inputs.image }},mode=max
149149
pull: true
150150
no-cache: ${{ github.event_name != 'pull_request' }}
151-
sbom: ${{ inputs.image != 'plus-waf' }}
151+
sbom: true
152152
provenance: mode=max
153153
build-args: |
154154
NJS_DIR=internal/controller/nginx/modules/src
@@ -161,9 +161,23 @@ jobs:
161161
${{ contains(inputs.image, 'plus') && format('"nginx-repo.key={0}"', secrets.NGINX_KEY) || '' }}
162162
163163
- name: Inspect SBOM and output manifest
164-
if: ${{ inputs.image != 'plus-waf' }}
165164
run: |
165+
if [[ "${{ inputs.image }}" == "plus-waf" ]]; then
166+
# For plus-waf, use syft directly
167+
echo "Generating SBOM for plus-waf using syft..."
168+
169+
# Install syft if not available
170+
if ! command -v syft >/dev/null 2>&1; then
171+
curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin
172+
fi
173+
174+
# Generate SBOM using syft directly for plus-waf (known to work with NAP WAF)
175+
syft localhost:5000/nginx-gateway-fabric/${{ inputs.image }}:${{ steps.meta.outputs.version }} -o spdx-json > sbom-${{ inputs.image }}.json
176+
echo "Generated SBOM using syft for plus-waf (following NGINX IC pattern)"
177+
else
178+
# For other images, use the standard Docker buildx approach
166179
docker buildx imagetools inspect localhost:5000/nginx-gateway-fabric/${{ inputs.image }}:${{ steps.meta.outputs.version }} --format '{{ json (index .SBOM "linux/amd64").SPDX }}' > sbom-${{ inputs.image }}.json
180+
fi
167181
docker buildx imagetools inspect localhost:5000/nginx-gateway-fabric/${{ inputs.image }}:${{ steps.meta.outputs.version }} --raw
168182
169183
- name: Scan SBOM
@@ -174,12 +188,11 @@ jobs:
174188
only-fixed: true
175189
add-cpes-if-none: true
176190
fail-build: false
177-
if: inputs.image != 'plus-waf'
178191

179192
- name: Upload scan result to GitHub Security tab
180193
uses: github/codeql-action/upload-sarif@ce28f5bb42b7a9f2c824e633a3f6ee835bab6858 # v3.29.0
181194
continue-on-error: true
182195
with:
183196
sarif_file: ${{ steps.scan.outputs.sarif }}
184197
category: build-${{ inputs.image }}
185-
if: always() && inputs.image != 'plus-waf'
198+
if: always() && steps.scan.conclusion == 'success'

0 commit comments

Comments
 (0)