Skip to content
Open
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
34 changes: 17 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,46 +16,46 @@ jobs:
strategy:
matrix:
node-version: [20.17.0, 22.x]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 10.12.2

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Run linter
run: pnpm run lint

- name: Run tests
run: pnpm run test:coverage

- name: Build package
run: pnpm run build

- name: Upload coverage to Codecov
if: matrix.node-version == '20.17.0'
uses: codecov/codecov-action@v3
Expand All @@ -68,28 +68,28 @@ jobs:
security:
name: Security Audit
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.17.0

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 10.12.2

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Run pnpm audit
run: pnpm audit --audit-level=moderate
continue-on-error: true

- name: Check for dependency updates
run: pnpm outdated
continue-on-error: true
continue-on-error: true
145 changes: 133 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,55 +4,176 @@ on:
release:
types: [published]

# SECURITY: Limit permissions at workflow level
permissions:
contents: read

jobs:
# ==========================================
# Job 1: Publish to NPM
# ==========================================
publish:
name: Publish to NPM
runs-on: ubuntu-latest
environment: production
permissions:
contents: read
id-token: write
id-token: write

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: main
ref: main

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.17.0
registry-url: 'https://registry.npmjs.org'

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 10.12.2

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Run tests
run: pnpm test

- name: Build package
run: pnpm run build

- name: Publish to NPM
run: pnpm publish --access public --no-git-checks --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

# ==========================================
# Job 2: Build binaries for all platforms
# ==========================================
build-binaries:
name: Build Binary (${{ matrix.platform }}-${{ matrix.arch }})
runs-on: ${{ matrix.os }}
# SECURITY: Only grant write permission where needed
permissions:
contents: write
attestations: write # SECURITY: For artifact attestation
id-token: write # SECURITY: For OIDC signing

strategy:
matrix:
include:
- os: ubuntu-latest
platform: linux
arch: x64
- os: macos-latest
platform: darwin
arch: arm64
- os: macos-13
platform: darwin
arch: x64
- os: windows-latest
platform: win32
arch: x64

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 10.12.2

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- name: Install dependencies
run: pnpm install --frozen-lockfile

# SECURITY: Run audit before building
- name: Security audit
run: pnpm audit --audit-level=high
continue-on-error: true
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

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

The workflow uses continue-on-error: true for the security audit step, which means the build will proceed even if high-severity vulnerabilities are found. This undermines the security guarantees mentioned in the PR description. Consider either removing continue-on-error or at least adding a follow-up step that reviews the audit results and blocks the release if critical vulnerabilities are found.

Suggested change
continue-on-error: true

Copilot uses AI. Check for mistakes.

- name: Build TypeScript
run: pnpm build

- name: Bundle CLI for SEA
run: pnpm build:cli:bundle

- name: Prepare SEA blob
run: pnpm build:sea:prepare

- name: Build binary
run: pnpm build:sea

- name: Rename binary (Unix)
if: matrix.platform != 'win32'
run: mv shield-${{ matrix.platform }}-* shield-${{ matrix.platform }}-${{ matrix.arch }}
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

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

The binary renaming step uses a wildcard pattern shield-${{ matrix.platform }}-* which could match multiple files if there are leftover artifacts from previous builds. This could lead to unintended files being renamed. Consider using the exact filename pattern shield-${{ matrix.platform }}-${{ matrix.arch }} or adding a cleanup step before the build to ensure a clean workspace.

Suggested change
run: mv shield-${{ matrix.platform }}-* shield-${{ matrix.platform }}-${{ matrix.arch }}
shell: bash
run: |
set -euo pipefail
shopt -s nullglob
files=(shield-${{ matrix.platform }}-*)
if [ "${#files[@]}" -ne 1 ]; then
echo "Error: Expected exactly one built binary matching 'shield-${{ matrix.platform }}-*', found ${#files[@]}: ${files[*]-}" >&2
exit 1
fi
mv "${files[0]}" "shield-${{ matrix.platform }}-${{ matrix.arch }}"

Copilot uses AI. Check for mistakes.

- name: Rename binary (Windows)
if: matrix.platform == 'win32'
shell: bash
run: mv shield.exe shield-windows-${{ matrix.arch }}.exe

# SECURITY: Generate SHA256 checksum for integrity verification
- name: Generate checksum (Unix)
if: matrix.platform != 'win32'
run: |
shasum -a 256 shield-${{ matrix.platform }}-${{ matrix.arch }} > shield-${{ matrix.platform }}-${{ matrix.arch }}.sha256
cat shield-${{ matrix.platform }}-${{ matrix.arch }}.sha256

- name: Generate checksum (Windows)
if: matrix.platform == 'win32'
shell: pwsh
run: |
$hash = Get-FileHash -Algorithm SHA256 shield-windows-${{ matrix.arch }}.exe
"$($hash.Hash.ToLower()) shield-windows-${{ matrix.arch }}.exe" | Out-File -Encoding utf8 shield-windows-${{ matrix.arch }}.exe.sha256
Get-Content shield-windows-${{ matrix.arch }}.exe.sha256

# SECURITY: Generate artifact attestation (proves binary was built by this workflow)
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v2
with:
subject-path: 'shield-*'

- name: Upload binary and checksum to Release
uses: softprops/action-gh-release@v2
with:
files: |
shield-${{ matrix.platform }}-${{ matrix.arch }}${{ matrix.platform == 'win32' && '.exe' || '' }}
shield-${{ matrix.platform }}-${{ matrix.arch }}${{ matrix.platform == 'win32' && '.exe' || '' }}.sha256
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14 changes: 13 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,16 @@ coverage/
*.tmp
*.temp
.tmp/
.temp/
.temp/

# SEA build artifacts
sea-prep.blob
shield-*
shield.exe
dist/cli.bundled.js

# Example build artifacts
examples/rust/target/
examples/rust/Cargo.lock
examples/*/shield
examples/*/shield.exe
Loading
Loading