Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/actions/install-packages/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: Install Packages
description: Install necessary packages inside the CI

runs:
using: "composite"
steps:
- run: sudo apt update && sudo apt install libunwind-dev libunwind8 -y
shell: bash
45 changes: 45 additions & 0 deletions .github/workflows/dtrack-sbom.workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Dtrack SBOM publish

env:
NODE_VERSION: "24"

on:
release:
types:
- released
- prereleased
Comment on lines +6 to +10

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Release workflow skips normal publish events

The workflow subscribes only to release event types released and prereleased, so a standard release creation (published action) never triggers this job. That means publishing a normal release will not generate or upload an SBOM, defeating the purpose of the workflow unless the release is first flagged as a prerelease and later promoted. Consider including the published type so SBOMs are produced for regular release publishes.

Useful? React with 👍 / 👎.


jobs:
publish-sbom-to-dtrack:
name: Publish SBOM to Dependency-Track
runs-on: ubuntu-24.04
steps:
- name: Checkout project
uses: actions/checkout@v6

- name: Install additional libraries
uses: ./.github/actions/install-packages

- name: Node version ${{ env.NODE_VERSION }}
uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}

- run: npm install
- name: Create SBOM with CycloneDX
run: npx @cyclonedx/cyclonedx-npm -o bom.xml --of=XML

- name: Get the current project version from package.json
id: get-version
run: |
echo "version=$(jq -r .version package.json)" >> $GITHUB_OUTPUT

- name: Publish SBOM to Dependency-Track
uses: DependencyTrack/gh-upload-sbom@v3
with:
serverhostname: ${{ secrets.DEPENDENCYTRACK_HOSTNAME }}
apikey: ${{ secrets.DEPENDENCYTRACK_APIKEY }}
projectname: 'Kuzzle SDK JavaScript'
projectversion: '${{ steps.get-version.outputs.version }}'
bomfilename: "./bom.xml"
autocreate: true
Comment on lines 14 to 45

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI about 2 months ago

To fix this issue, add a permissions block defining the minimal privilege set required for this workflow. According to the types of actions in the workflow (checking out the code, installing packages, running commands, uploading artifacts, and publishing to Dependency-Track), the only operation that might require the GITHUB_TOKEN is the actions/checkout step, which by default requires read access to repository contents. None of the other steps (including publishing to Dependency-Track) use the token. Thus, setting permissions: contents: read at the job level for publish-sbom-to-dtrack is appropriate and aligns with least privilege principles. You need to edit the workflow YAML to add this block under the job definition, directly above runs-on:.

Suggested changeset 1
.github/workflows/dtrack-sbom.workflow.yaml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/dtrack-sbom.workflow.yaml b/.github/workflows/dtrack-sbom.workflow.yaml
--- a/.github/workflows/dtrack-sbom.workflow.yaml
+++ b/.github/workflows/dtrack-sbom.workflow.yaml
@@ -12,6 +12,8 @@
 jobs:
   publish-sbom-to-dtrack:
     name: Publish SBOM to Dependency-Track
+    permissions:
+      contents: read
     runs-on: ubuntu-24.04
     steps:
       - name: Checkout project
EOF
@@ -12,6 +12,8 @@
jobs:
publish-sbom-to-dtrack:
name: Publish SBOM to Dependency-Track
permissions:
contents: read
runs-on: ubuntu-24.04
steps:
- name: Checkout project
Copilot is powered by AI and may make mistakes. Always verify output.