Skip to content
Merged
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
67 changes: 25 additions & 42 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,20 @@ permissions:
contents: read

jobs:
semantic-release:
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
pull-requests: write
outputs:
release-version: ${{ steps.semantic.outputs.release-version }}
new-release-published: ${{ steps.semantic.outputs.new-release-published }}
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
with:
egress-policy: audit

# Mint a GitHub App installation token for the Flanksource App so
# semantic-release can push the release tag and create the GitHub Release.
# The default GITHUB_TOKEN is blocked from these writes by org policy.
- name: Generate GitHub App token
id: app-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
app-id: ${{ secrets.FLANKSOURCE_APP_ID }}
private-key: ${{ secrets.FLANKSOURCE_APP_SECRET }}

- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
token: ${{ steps.app-token.outputs.token }}
- uses: codfish/semantic-release-action@b621d34fabe0940f031e89b6ebfea28322892a10 # v3.5.0
id: semantic
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
# Releases go through the shared Flanksource workflow rather than a
# repo-local semantic-release job. The previous codfish/semantic-release-action
# was blocked by GitHub for a ToS violation on 2026-06-25, which failed every
# release from then on while resolving actions ("Repository access blocked").
create-release:
permissions: {}
uses: flanksource/action-workflows/.github/workflows/create-release.yml@5d7f5f3616936fd703e58c5ee7e4527dc9f6adcc # main
secrets:
token: ${{ secrets.FLANKBOT }}

bump-clients:
runs-on: ubuntu-latest
needs: [semantic-release]
if: needs.semantic-release.outputs.new-release-published == 'true'
needs: [create-release]
if: needs.create-release.outputs.published == 'true'
strategy:
matrix:
repos: ["duty"]
Expand Down Expand Up @@ -76,7 +53,7 @@ jobs:
run: |
# Sleep to let index refresh
sleep 60
go get github.com/flanksource/commons@v${{ needs.semantic-release.outputs.release-version }}
go get github.com/flanksource/commons@v${{ needs.create-release.outputs.version }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Pass release outputs through environment variables before shell execution.

The reusable workflow outputs are inserted into generated shell source. If those values are ever attacker-controlled or insufficiently constrained, shell metacharacters can execute commands in release jobs.

  • .github/workflows/release.yml#L56-L56: expose version as a step environment variable and use "github.com/flanksource/commons@v${COMMONS_VERSION}".
  • .github/workflows/release.yml#L123-L123: expose version as an environment variable and use VERSION="$RELEASE_VERSION".
  • .github/workflows/release.yml#L161-L161: expose tag as an environment variable and use gh release upload "$RELEASE_TAG" ....
Proposed pattern
+        env:
+          COMMONS_VERSION: ${{ needs.create-release.outputs.version }}
         run: |
-          go get github.com/flanksource/commons@v${{ needs.create-release.outputs.version }}
+          go get "github.com/flanksource/commons@v${COMMONS_VERSION}"

         env:
           GOOS: ${{ matrix.goos }}
           GOARCH: ${{ matrix.goarch }}
+          RELEASE_VERSION: ${{ needs.create-release.outputs.version }}
-        run: make -C cmd/hx build VERSION=${{ needs.create-release.outputs.version }}
+        run: make -C cmd/hx build VERSION="$RELEASE_VERSION"

         env:
           GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
           GH_REPO: ${{ github.repository }}
-        run: gh release upload "${{ needs.create-release.outputs.tag }}" dist/hx_* --clobber
+          RELEASE_TAG: ${{ needs.create-release.outputs.tag }}
+        run: gh release upload "$RELEASE_TAG" dist/hx_* --clobber
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
go get github.com/flanksource/commons@v${{ needs.create-release.outputs.version }}
env:
COMMONS_VERSION: ${{ needs.create-release.outputs.version }}
run: |
go get "github.com/flanksource/commons@v${COMMONS_VERSION}"
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
RELEASE_VERSION: ${{ needs.create-release.outputs.version }}
run: make -C cmd/hx build VERSION="$RELEASE_VERSION"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
RELEASE_TAG: ${{ needs.create-release.outputs.tag }}
run: gh release upload "$RELEASE_TAG" dist/hx_* --clobber
🧰 Tools
🪛 zizmor (1.26.1)

[info] 56-56: code injection via template expansion (template-injection): may expand into attacker-controllable code

(template-injection)

📍 Affects 1 file
  • .github/workflows/release.yml#L56-L56 (this comment)
  • .github/workflows/release.yml#L123-L123
  • .github/workflows/release.yml#L161-L161
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/release.yml at line 56, Pass release outputs through step
environment variables instead of interpolating them into shell source: at
.github/workflows/release.yml lines 56-56, expose version as COMMONS_VERSION and
use it in the commons dependency; at lines 123-123, expose version as
RELEASE_VERSION and assign VERSION from that variable; at lines 161-161, expose
tag as RELEASE_TAG and quote it in the gh release upload command.

Source: Linters/SAST tools

go mod tidy
if [ -d "hack/generate-schemas" ]; then
cd hack/generate-schemas && go mod tidy
Expand All @@ -87,8 +64,8 @@ jobs:
uses: peter-evans/create-pull-request@6d6857d36972b65feb161a90e484f2984215f83e # v6.0.5
with:
branch: "bump-duty-auto-pr"
commit-message: "chore: bump duty to v${{ needs.semantic-release.outputs.release-version }}"
title: "chore: bump duty to v${{ needs.semantic-release.outputs.release-version }}"
commit-message: "chore: bump duty to v${{ needs.create-release.outputs.version }}"
title: "chore: bump duty to v${{ needs.create-release.outputs.version }}"
token: ${{ secrets.FLANKBOT }}
labels: dependencies

Expand All @@ -103,8 +80,8 @@ jobs:

hx-binaries:
runs-on: ${{ matrix.os }}
needs: [semantic-release]
if: needs.semantic-release.outputs.new-release-published == 'true'
needs: [create-release]
if: needs.create-release.outputs.published == 'true'
strategy:
matrix:
include:
Expand Down Expand Up @@ -136,8 +113,14 @@ jobs:
with:
go-version: v1.25.x

# GOOS/GOARCH have to be exported: cmd/hx/Makefile derives the binary's
# .exe suffix from $(GOOS), so without them the Windows build writes `hx`
# rather than the `hx.exe` the rename step below expects.
- name: Build hx
run: make -C cmd/hx build VERSION=${{ needs.semantic-release.outputs.release-version }}
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: make -C cmd/hx build VERSION=${{ needs.create-release.outputs.version }}

- name: Rename binary (unix)
if: matrix.goos != 'windows'
Expand All @@ -155,7 +138,7 @@ jobs:

hx-upload-release:
runs-on: ubuntu-latest
needs: [semantic-release, hx-binaries]
needs: [create-release, hx-binaries]
permissions:
contents: write
steps:
Expand All @@ -175,4 +158,4 @@ jobs:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
run: gh release upload "v${{ needs.semantic-release.outputs.release-version }}" dist/hx_* --clobber
run: gh release upload "${{ needs.create-release.outputs.tag }}" dist/hx_* --clobber
Loading