|
| 1 | +name: Create SBOM files |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + upload_url: |
| 7 | + description: "Release assets upload URL" |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + tag: |
| 11 | + description: "The git tag to generate SBOM for - used in scheduled runs" |
| 12 | + required: false |
| 13 | + type: string |
| 14 | + |
| 15 | +jobs: |
| 16 | + create-sbom: |
| 17 | + runs-on: [self-hosted, Linux, X64] |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: Determine release tag and version |
| 21 | + id: vars |
| 22 | + # Uses inputs.tag for scheduled runs, otherwise github.ref_name. |
| 23 | + run: | |
| 24 | + TAG_NAME=${{ inputs.tag || github.ref_name }} |
| 25 | + VERSION=${TAG_NAME#v} |
| 26 | + echo "TAG_NAME=$TAG_NAME" >> $GITHUB_OUTPUT |
| 27 | + echo "VERSION=$VERSION" >> $GITHUB_OUTPUT |
| 28 | +
|
| 29 | + - name: Checkout |
| 30 | + uses: actions/checkout@v4 |
| 31 | + with: |
| 32 | + ref: ${{ steps.vars.outputs.TAG_NAME }} |
| 33 | + submodules: recursive |
| 34 | + |
| 35 | + - name: Create SBOM with Trivy |
| 36 | + uses: aquasecurity/[email protected] |
| 37 | + with: |
| 38 | + scan-type: 'fs' |
| 39 | + format: 'spdx-json' |
| 40 | + output: "defguard-gateway-${{ steps.vars.outputs.VERSION }}.sbom.json" |
| 41 | + scan-ref: '.' |
| 42 | + severity: "CRITICAL,HIGH,MEDIUM,LOW" |
| 43 | + scanners: "vuln" |
| 44 | + |
| 45 | + - name: Create docker image SBOM with Trivy |
| 46 | + uses: aquasecurity/[email protected] |
| 47 | + with: |
| 48 | + image-ref: "ghcr.io/defguard/gateway:${{ steps.vars.outputs.VERSION }}" |
| 49 | + scan-type: 'image' |
| 50 | + format: 'spdx-json' |
| 51 | + output: "defguard-gateway-${{ steps.vars.outputs.VERSION }}-docker.sbom.json" |
| 52 | + severity: "CRITICAL,HIGH,MEDIUM,LOW" |
| 53 | + scanners: "vuln" |
| 54 | + |
| 55 | + - name: Create security advisory file with Trivy |
| 56 | + uses: aquasecurity/[email protected] |
| 57 | + with: |
| 58 | + scan-type: 'fs' |
| 59 | + format: 'json' |
| 60 | + output: "defguard-gateway-${{ steps.vars.outputs.VERSION }}.advisories.json" |
| 61 | + scan-ref: '.' |
| 62 | + severity: "CRITICAL,HIGH,MEDIUM,LOW" |
| 63 | + scanners: "vuln" |
| 64 | + |
| 65 | + - name: Create docker image security advisory file with Trivy |
| 66 | + uses: aquasecurity/[email protected] |
| 67 | + with: |
| 68 | + image-ref: "ghcr.io/defguard/gateway:${{ steps.vars.outputs.VERSION }}" |
| 69 | + scan-type: 'image' |
| 70 | + format: 'json' |
| 71 | + output: "defguard-gateway-${{ steps.vars.outputs.VERSION }}-docker.advisories.json" |
| 72 | + severity: "CRITICAL,HIGH,MEDIUM,LOW" |
| 73 | + scanners: "vuln" |
| 74 | + |
| 75 | + - name: Upload SBOMs and advisories |
| 76 | + uses: shogo82148/actions-upload-release-asset@v1 |
| 77 | + env: |
| 78 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 79 | + with: |
| 80 | + upload_url: ${{ inputs.upload_url }} |
| 81 | + asset_path: "defguard-*.json" |
| 82 | + asset_content_type: application/octet-stream |
| 83 | + overwrite: true |
0 commit comments