Skip to content

Commit f16034d

Browse files
authored
Merge branch 'main' into feat/trivy-allow-failure
2 parents 78021b7 + de1ca19 commit f16034d

4 files changed

Lines changed: 52 additions & 6 deletions

File tree

action-templates/actions/action-maven-build/action.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ outputs:
1414
artifact-name:
1515
description: "Name of the artifact upload"
1616
value: ${{steps.artifact-name.outputs.artifact-name}}
17+
cyclone-artifact-id:
18+
description: "ID of the sbom artifact"
19+
value: ${{steps.upload-sbom-artifact.outputs.artifact-id}}
20+
cyclone-path:
21+
description: "path of the sbom"
22+
value: ${{steps.artifact-name.outputs.cyclone-path}}
1723

1824
runs:
1925
using: "composite"
@@ -36,7 +42,11 @@ runs:
3642
shell: bash
3743
- id: artifact-name
3844
name: Set output variable $GITHUB_OUTPUT
39-
run: echo "artifact-name=${{hashFiles(format('./{0}/pom.xml', inputs.app-path))}}" >> "$GITHUB_OUTPUT"
45+
env:
46+
APP_PATH: ${{inputs.app-path}}
47+
run: |
48+
echo "artifact-name=${{hashFiles(format('./{0}/pom.xml', inputs.app-path))}}" >> "$GITHUB_OUTPUT"
49+
echo "cyclone-path=$APP_PATH/target/classes/META-INF/sbom/application.cdx.json" >> "$GITHUB_OUTPUT"
4050
shell: bash
4151
- id: upload-artifact
4252
name: Upload artifact
@@ -45,3 +55,11 @@ runs:
4555
name: ${{steps.artifact-name.outputs.artifact-name}}
4656
path: "**/target"
4757
retention-days: 5
58+
- id: upload-sbom-artifact
59+
name: upload-sbom-artifact
60+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
61+
with:
62+
name: ${{inputs.app-path}}
63+
path: "${{inputs.app-path}}/target/classes/META-INF/sbom/application.cdx.json"
64+
retention-days: 5
65+
archive: false

action-templates/actions/action-npm-build/action.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ outputs:
2626
artifact-name:
2727
description: "Name of the artifact upload"
2828
value: ${{steps.artifact-name.outputs.artifact-name}}
29-
29+
cyclone-artifact-id:
30+
description: "ID of the sbom artifact"
31+
value: ${{steps.upload-sbom-artifact.outputs.artifact-id}}
32+
cyclone-path:
33+
value: ${{steps.artifact-name.outputs.cyclone-path}}
34+
description: "path of the sbom"
3035
runs:
3136
using: "composite"
3237
steps:
@@ -61,11 +66,22 @@ runs:
6166
shell: bash
6267
- id: artifact-name
6368
name: Sets output variable $GITHUB_OUTPUT
64-
run: echo "artifact-name=${{hashFiles(format('./{0}/package.json', inputs.app-path))}}" >> "$GITHUB_OUTPUT"
69+
env:
70+
APP_PATH: ${{inputs.app-path}}
71+
run: |
72+
echo "artifact-name=${{hashFiles(format('./{0}/package.json', inputs.app-path))}}" >> "$GITHUB_OUTPUT"
73+
echo "cyclone-path=$APP_PATH/dist/application.cdx.json" >> "$GITHUB_OUTPUT"
6574
shell: bash
6675
- name: Upload artifact
6776
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
6877
with:
6978
name: ${{steps.artifact-name.outputs.artifact-name}}
7079
path: "**/dist"
7180
retention-days: 5
81+
- id: upload-sbom-artifact
82+
name: upload-sbom-artifact
83+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
84+
with:
85+
path: "${{inputs.app-path}}/dist/application.cdx.json"
86+
retention-days: 5
87+
archive: false

action-templates/actions/action-trivy/action.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,19 @@ inputs:
1515
required: false
1616
default: "false"
1717
path:
18-
description: "Path to scan with Trivy"
18+
description: "Path to scan with Trivy. For scan-type=sbom, this must point to a specific SBOM file (e.g. sbom.cdx.json), not a directory."
1919
required: false
2020
default: "."
21+
scan-type:
22+
description: "scan type, e.g. fs or sbom"
23+
required: false
24+
default: "fs"
2125

2226
runs:
2327
using: "composite"
2428
steps:
2529
- name: Checkout repository
30+
if: inputs.scan-type == 'fs'
2631
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
2732
with:
2833
fetch-depth: 0 # Required for vitepress lastUpdated
@@ -32,8 +37,8 @@ runs:
3237
env:
3338
TRIVY_INCLUDE_DEV_DEPS: "true"
3439
with:
35-
scan-type: "fs"
36-
scan-ref: ${{ inputs.path }}
40+
scan-type: "${{ inputs.scan-type }}"
41+
scan-ref: "${{ inputs.path }}"
3742
format: "json"
3843
exit-code: ${{ inputs.allow-failure == 'true' && '0' || '1' }}
3944
timeout: "${{ inputs.timeout }}"

docs/actions.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,8 @@ Executes the following steps:
428428
Output parameters:
429429

430430
1. `artifact-name`: Name of the uploaded artifact
431+
2. `cyclone-artifact-id`: ID of the sbom artifact
432+
3. `cyclone-path`: path of the sbom
431433

432434
Workflows using that action need the following permissions:
433435

@@ -533,6 +535,8 @@ Executes the following steps:
533535
Output parameters:
534536

535537
1. `artifact-name`: Name of the uploaded artifact
538+
2. `cyclone-artifact-id`: ID of the sbom artifact
539+
3. `cyclone-path`: path of the sbom
536540

537541
Workflows using that action need the following permissions:
538542

@@ -674,6 +678,9 @@ Workflows using that action need the following permissions:
674678
# If the action should succeed even if Trivy fails
675679
# Default: false
676680
allow-failure: "false"
681+
# scan type, e.g. fs or sbom
682+
# defualt: fs
683+
scan-type: fs
677684
# Path to scan with Trivy
678685
# Default: .
679686
path: "."

0 commit comments

Comments
 (0)