docs(production): standardiserad produktionsberedskap och gap-analys

Lägger docs/production-readiness.md och siax/production-gaps.json enligt SIAX Master Definition of Done. Underlag: git-, kod- och live-evidens 2026-11-11. Nivån är evidensbaserad, inte ett leveransgodkännande.
This commit is contained in:
2026-11-10 09:15:21 +01:00
parent 0fda8cae48
commit 2bee8eb778
6135 changed files with 4 additions and 1718997 deletions
-56
View File
@@ -1,56 +0,0 @@
name: Bug report
description: Report something that is broken or behaving incorrectly
labels: ["bug"]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to report a bug.
**Do not report security vulnerabilities here.** Use our [security policy](https://github.com/erp-mafia/accounted/security/policy) instead.
- type: textarea
id: what-happened
attributes:
label: What happened?
description: A clear description of the bug.
validations:
required: true
- type: textarea
id: steps
attributes:
label: Steps to reproduce
placeholder: |
1. Go to ...
2. Click ...
3. See error
validations:
required: true
- type: textarea
id: expected
attributes:
label: Expected behavior
description: What you expected to happen instead.
validations:
required: true
- type: dropdown
id: deployment
attributes:
label: Deployment
options:
- Hosted (app.gnubok.se)
- Self-hosted (Docker)
- Local development
validations:
required: true
- type: input
id: environment
attributes:
label: Browser and OS
placeholder: "e.g. Chrome 138 on macOS 15"
- type: textarea
id: logs
attributes:
label: Relevant logs or screenshots
description: |
Paste any error messages or attach screenshots.
Remember to redact personal data, organization numbers, and financial details before posting.
-8
View File
@@ -1,8 +0,0 @@
blank_issues_enabled: false
contact_links:
- name: Documentation
url: https://docs.gnubok.se
about: User guides and API reference.
- name: Security vulnerability
url: https://github.com/erp-mafia/accounted/security/policy
about: Report security issues privately, never in a public issue.
@@ -1,30 +0,0 @@
name: Feature request
description: Suggest a new feature or improvement
labels: ["enhancement"]
body:
- type: textarea
id: problem
attributes:
label: What problem does this solve?
description: Describe the problem or friction you are running into, not just the solution.
validations:
required: true
- type: textarea
id: solution
attributes:
label: Proposed solution
description: What would you like to see happen?
validations:
required: true
- type: textarea
id: alternatives
attributes:
label: Alternatives considered
description: Other approaches you have considered, or how you work around this today.
- type: textarea
id: context
attributes:
label: Additional context
description: |
Anything else that helps us understand the request. For accounting features, a reference
to the relevant Swedish rule or an example from another tool (e.g. Fortnox) is very helpful.
-13
View File
@@ -1,13 +0,0 @@
# What and why
<!-- What does this PR change, and why? Link related issues with "Closes #123". -->
## Checklist
- [ ] Title follows [Conventional Commits](https://www.conventionalcommits.org/) (`feat:`, `fix:`, `refactor:`, `test:`, `docs:`)
- [ ] `npm run lint`, `npm test`, and `npm run build` pass locally
- [ ] New or changed logic in `lib/` or `app/api/` has tests
- [ ] New or changed UI strings exist in both `messages/sv.json` and `messages/en.json`
- [ ] Migrations (if any) are new files in `supabase/migrations/`; no edits to already-shipped migrations
- [ ] Core builds with zero extensions enabled (no imports from `@/extensions/` in core code)
- [ ] Commits are signed off (`git commit -s`, see [DCO](../DCO))
-43
View File
@@ -1,43 +0,0 @@
name: Set up core toolchain
description: >-
Node, dependencies, and a zero-extension registry: the prologue every
core-build job needs before it can lint, build, or test. The caller must check
the repository out first, because a local composite action cannot be resolved
until the workspace containing it exists.
runs:
using: composite
steps:
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6
with:
node-version: 20
# Restore-only, deliberately never `save`. A cache written from a
# pull_request run is scoped to that PR's ref, so no other run can ever read
# it: PR-side saves are pure quota burn. Fourteen dead 284 MB copies (4 GB,
# 40% of the repo quota) accumulated in a single day the last time a naive
# `cache: npm` was left on, which is why test-pg-real.yml still runs
# uncached. The entries read here are written on main by ci-cache.yml, and
# default-branch entries are restorable from every PR.
- name: Restore npm cache
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
with:
path: ~/.npm
key: npm-${{ runner.os }}-node20-${{ hashFiles('package-lock.json') }}
restore-keys: |
npm-${{ runner.os }}-node20-
- name: Install dependencies
shell: bash
run: npm ci
# CI builds core with zero extensions enabled: that property is the entire
# reason this workflow exists, so every job that compiles or runs code needs
# the registry regenerated from an empty config first.
- name: Reset extensions config
shell: bash
run: echo '{"extensions":[]}' > extensions.config.json
- name: Generate extension registry
shell: bash
run: npm run setup:extensions
-19
View File
@@ -1,19 +0,0 @@
# Security-updates-only posture: open-pull-requests-limit: 0 disables scheduled
# version-bump PRs while keeping Dependabot security PRs, and `ignore` applies
# to both kinds.
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "weekly"
open-pull-requests-limit: 0
cooldown:
default-days: 7
ignore:
# @anthropic-ai/bedrock-sdk 0.30.0+ broke invoice OCR and the assistant in
# prod (empty Bedrock streams, 2026-07 outage; see DECISIONS.md). The
# dependency is pinned to 0.29.1 in package.json; a bump must be a
# deliberate, verified change, never an automated PR.
- dependency-name: "@anthropic-ai/bedrock-sdk"
versions: [">=0.30.0"]
-54
View File
@@ -1,54 +0,0 @@
name: CI cache warm
# The save half of the npm cache that .github/actions/setup-core restores.
#
# It has to live in its own main-branch workflow. GitHub scopes a cache entry to
# the ref that wrote it, with one exception: entries written on the default
# branch are readable from every branch and PR. core-build.yml runs on
# pull_request only, so anything it saved would be readable by exactly one PR
# and dead the moment that PR merged. That is not hypothetical here: a naive
# `cache: npm` on the pg-real workflow once put fourteen 284 MB copies (4 GB,
# 40% of the repo quota) on disk in a day, none of them ever restorable.
#
# So: main saves, PRs restore-only. Keyed on the lockfile hash, so this runs
# only when dependencies actually move and each entry is read many times before
# it is replaced.
on:
push:
branches: [main]
paths:
- package-lock.json
- package.json
workflow_dispatch: {}
concurrency:
group: ci-cache
cancel-in-progress: true
permissions:
contents: read
jobs:
warm:
name: Warm npm cache
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6
with:
node-version: 20
# Populates ~/.npm. `npm ci` deletes node_modules first, so this measures
# a cold install the same way a PR job will.
- run: npm ci
# A no-op when the key already exists, which is the intent: one entry per
# lockfile state, not one per push.
- name: Save npm cache
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
with:
path: ~/.npm
key: npm-${{ runner.os }}-node20-${{ hashFiles('package-lock.json') }}
-71
View File
@@ -1,71 +0,0 @@
name: CodeQL
# Semantic code scanning. The repo already had `security-events: write` and
# uploaded Trivy SARIF, but Trivy only reports known CVEs in dependencies and
# base images: nothing analysed the application's own code. For a multi-tenant
# accounting SaaS holding personnummer, bank data and money, that was the gap.
#
# Two languages:
# javascript-typescript - the app itself (injection, path traversal, unsafe
# deserialization, missing authorization checks, hardcoded credentials).
# actions - GitHub's own workflow analysis. It overlaps zizmor.yml without
# replacing it: CodeQL follows dataflow into composite actions, zizmor knows
# Actions-specific misconfigurations CodeQL has no notion of. Two cheap
# scanners with different blind spots beat one.
#
# The default query suite is used deliberately. `security-extended` finds more
# but roughly doubles the runtime, and this already runs on every PR; revisit
# once the default suite's findings are triaged.
on:
pull_request:
branches: [main]
push:
branches: [main]
schedule:
# Weekly. CodeQL ships new queries continuously, so an unchanged repo can
# still acquire findings.
- cron: '19 3 * * 1'
workflow_dispatch: {}
permissions:
contents: read
concurrency:
group: codeql-${{ github.ref }}
cancel-in-progress: true
jobs:
analyze:
name: Analyze (${{ matrix.language }})
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: read
# Required to upload the analysis results.
security-events: write
# Required by the `actions` language pack to read workflow metadata.
actions: read
strategy:
# A failure in one language should not hide the other's results.
fail-fast: false
matrix:
language: [javascript-typescript, actions]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- name: Initialize CodeQL
uses: github/codeql-action/init@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4
with:
languages: ${{ matrix.language }}
# No build step. javascript-typescript and actions are both interpreted
# languages to CodeQL, extracted straight from source, so `npm ci` and
# `next build` would add minutes and change nothing about the database.
- name: Perform CodeQL analysis
uses: github/codeql-action/analyze@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4
with:
category: /language:${{ matrix.language }}
-44
View File
@@ -1,44 +0,0 @@
name: "compliance: review (advisory)"
# Lightweight LLM-only review on every PR. ~90s, no Docker scanners.
# Posts a sticky comment with reasoned findings across all 5 frameworks.
# The nightly compliance-swarm.yml (mode: audit) provides the deeper
# scanner-backed coverage.
on:
pull_request:
types: [opened, synchronize, reopened]
permissions:
contents: read
pull-requests: write
concurrency:
group: compliance-review-${{ github.ref }}
cancel-in-progress: true
jobs:
review:
name: Compliance review (advisory)
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
fetch-depth: 0
- uses: erp-mafia/compliancemaxx@248cebcf90867fa813a8c0a2bc66cca70a56db3a # v2
with:
base: ${{ github.event.pull_request.base.sha }}
fail-on-findings: false # advisory while bedding in
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: eu-north-1
# Pin the review model explicitly. compliancemaxx falls back to
# `eu.anthropic.claude-sonnet-4-6` when this is unset
# (packages/cli/src/llm/bedrock.ts), so leaving it out silently kept
# this workflow a generation behind the rest of the repo after the
# Sonnet 5 migration (#1218). Keep in sync with
# swedish-compliance-review.yml and lib/agent/composer/client.ts.
COMPLIANCE_BEDROCK_MODEL: eu.anthropic.claude-sonnet-5
-61
View File
@@ -1,61 +0,0 @@
name: "compliance: full swarm"
# Full hybrid audit: deterministic scanners + LLM-driven deep_audit checks
# (RoPA drift, AGPL §13 evaluation, IDOR/access-control reasoning, ISMS clause
# review, change-management bypass detection).
#
# Triggers:
# - Nightly cron at 02:00 UTC
# - workflow_dispatch (run anytime)
# - PRs labeled `compliance:full-audit`
on:
schedule:
- cron: '0 2 * * *'
workflow_dispatch:
inputs:
reason:
description: 'Why are you running this manually?'
required: false
default: ''
pull_request:
types: [labeled]
permissions:
contents: read
pull-requests: write
security-events: write
concurrency:
group: compliance-swarm-${{ github.ref }}
cancel-in-progress: false
jobs:
swarm:
name: Full hybrid audit
if: |
github.event_name != 'pull_request'
|| github.event.label.name == 'compliance:full-audit'
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
fetch-depth: 0
- uses: erp-mafia/compliancemaxx@248cebcf90867fa813a8c0a2bc66cca70a56db3a # v2
with:
mode: audit # v2 name; was `swarm` in v1
llm-provider: bedrock
fail-on-findings: false # observational while bedding in
env:
AWS_REGION: eu-north-1
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# Pin the audit model explicitly rather than leaving this commented
# out. compliancemaxx defaults to `eu.anthropic.claude-sonnet-4-6`
# when it is unset (packages/cli/src/llm/bedrock.ts), which quietly
# kept the nightly audit a generation behind after #1218. Keep in
# sync with compliance-pr.yml and lib/agent/composer/client.ts.
COMPLIANCE_BEDROCK_MODEL: eu.anthropic.claude-sonnet-5
-184
View File
@@ -1,184 +0,0 @@
name: Core Build (no extensions)
# Split out of a single serial job that took 7m43s wall-clock: npm ci 24s, lint
# ratchet 1m29s, build 2m00s, unit tests 3m31s, ratchets ~10s. None of those
# stages needed the previous one's output, so they were serial only by
# accident. Running them as independent jobs (and sharding the 897-file unit
# suite four ways) puts the critical path on `build` at roughly 2m30s.
#
# The prologue each job needs is in .github/actions/setup-core.
on: [pull_request]
# Six concurrent jobs per push makes stale runs far more expensive than they
# were when this was one job, and a superseded push has nothing worth finishing.
concurrency:
group: core-build-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
checks:
name: Checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
# Nothing here pushes, so leaving the token in .git/config only widens
# what a compromised dependency in the build could reach.
persist-credentials: false
- uses: ./.github/actions/setup-core
- name: Verify skill bodies are in sync with the seed migration
# Fails if a .claude/skills/**/SKILL.md changed without regenerating the
# seed migration (npm run skills:generate). Keeps prod skill content from
# silently drifting out of sync. No DB needed: reads files + manifest.
run: npm run skills:check
- name: Verify taxonomy registry is in sync with the element lists
# Fails if dev_docs/bokslut/taxonomi/** changed without regenerating
# lib/bokslut/ixbrl/taxonomy/generated/ (npm run taxonomy:generate).
# The iXBRL generator emits facts strictly from the generated registry,
# so drift here means filings tagged against a stale concept set.
run: npm run taxonomy:check
- name: Verify the accounted-api agent skill is in sync with the registry
# Fails if a v1 endpoint / registry schema / overlay changed without
# regenerating skills/accounted-api (npm run apiskill:generate). The
# skill is the installable API reference for external coding agents;
# drift here means agents integrate against stale endpoint contracts.
run: npm run apiskill:check
- name: Lint ratchet (no new ESLint errors)
# `npm run lint` was never wired into CI, so ~60 legacy errors
# accumulated. This ratchet (sibling of check:guards) fails only when
# a PR ADDS an error beyond scripts/checks/eslint-baseline.json; the
# baseline ratchets down as legacy errors get fixed.
run: npm run check:lint
- name: Typecheck ratchet (no new TypeScript errors)
# `npm test` does not typecheck: vitest transpiles and discards types,
# so a type error passes all 18 000 tests and only surfaces in the
# build. That happened twice on 2026-08-27. This also covers __tests__
# files, which the Next.js build never compiles, so it is not merely a
# faster copy of the build job.
#
# Baselined per FILE in scripts/checks/typecheck-baseline.json (539
# legacy errors across 83 files, all in test files) and ratchets down.
# Per-file rather than per-error-code on purpose: a code-keyed budget
# would let a real regression hide behind a legacy fix elsewhere.
run: npm run check:types
- name: Antipattern ratchet (no new MFA-bypassing routes / naive öre-rounding)
# Fails only if a PR ADDS a route that hand-rolls supabase.auth.getUser()
# instead of the MFA-enforcing guard, or a new Math.round(x*100)/100.
# Baseline lives in scripts/checks/antipatterns-baseline.json and ratchets
# down as the A1 (route auth) and D1 (rounding) migrations land.
run: npm run check:guards
- name: Validate konteringspaket catalogue
# The system booking templates are data files under packs/ rather than
# rows frozen inside a migration. This gate is what makes that safe: it
# checks the schema, that every BAS account actually exists in the 2026
# chart, and that each pack BALANCES when applied through the real
# applyTemplate(). PR #1321 shipped seeded reference data that
# contradicted the engine; that class of bug is structurally valid and
# only a semantic check catches it.
run: npm run validate:packs
- name: Validate community registry
# registry/ is the public source of truth for gnubok.se/community/registry
# and takes entries by PR from outside the team. The gate checks the
# frontmatter the website build consumes, and rejects JSX/import/export
# in entry bodies: the site renders bodies through MDX, which would
# execute those at build time.
run: npm run validate:registry
- name: Check no core imports from extensions
run: |
VIOLATIONS=$(grep -r "from '@/extensions/" lib/ app/api/ components/ --include="*.ts" --include="*.tsx" \
| grep -v "app/api/extensions/" \
| grep -v "components/extensions/" \
| grep -v "lib/extensions/_generated/" \
| grep -v "lib/extensions/loader.ts" || true)
if [ -n "$VIOLATIONS" ]; then
echo "ERROR: Core code imports from @/extensions/:"
echo "$VIOLATIONS"
exit 1
fi
build:
name: Build (zero extensions)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
# Nothing here pushes, so leaving the token in .git/config only widens
# what a compromised dependency in the build could reach.
persist-credentials: false
- uses: ./.github/actions/setup-core
- run: npm run build
env:
# The Next.js build worker OOMs on the runner's default Node heap
# since 2026-08-19 (bundle growth crossed the default old-space
# ceiling; the first branch containing the whole day's merges was the
# first to hit it). Public-repo runners have 16 GB, give the build 8.
NODE_OPTIONS: --max-old-space-size=8192
test:
# 897 unit test files (11,341 tests) take 3m31s in one process. Measured
# locally, four shards split them 225/224/224/224 with the slowest at 64s,
# which puts this comfortably under the build job so it stops being the
# critical path. Vitest hard-errors when the shard count exceeds the
# resolved file count, which is nowhere near a concern at this size.
name: Unit tests (${{ matrix.shard }}/4)
runs-on: ubuntu-latest
strategy:
# One shard failing should not hide failures in the other three: a red PR
# is more useful when it lists every broken test, not just the first.
fail-fast: false
matrix:
shard: [1, 2, 3, 4]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
# Nothing here pushes, so leaving the token in .git/config only widens
# what a compromised dependency in the build could reach.
persist-credentials: false
- uses: ./.github/actions/setup-core
# Via env rather than interpolated straight into the shell body: the value
# is a static matrix integer and harmless, but keeping every `run:` free of
# ${{ }} is the rule that makes the template-injection audit meaningful.
- run: npm test -- --shard="$SHARD/4"
env:
SHARD: ${{ matrix.shard }}
core-build:
# One stable check name covering all six jobs above, so the PR checks list
# (and any future required-status-check rule) has a single thing to read
# rather than a shard-numbered matrix. `needs` alone would not be enough:
# a needed job that is skipped or cancelled does not fail its dependents,
# so the results are asserted explicitly.
name: Core Build
if: always()
needs: [checks, build, test]
runs-on: ubuntu-latest
steps:
- name: Assert every core job succeeded
env:
CHECKS: ${{ needs.checks.result }}
BUILD: ${{ needs.build.result }}
TEST: ${{ needs.test.result }}
run: |
set -euo pipefail
echo "checks=$CHECKS build=$BUILD test=$TEST"
failed=0
for r in "$CHECKS" "$BUILD" "$TEST"; do
[ "$r" = "success" ] || failed=1
done
if [ "$failed" -ne 0 ]; then
echo "::error::One or more core-build jobs did not succeed"
exit 1
fi
-142
View File
@@ -1,142 +0,0 @@
name: Scheduled Image Vulnerability Scan
# The build pipeline (docker-publish.yml) builds and publishes the image but
# does NOT fail on CVEs: it stays green so deploys are deterministic. This
# workflow is the actual vulnerability gate: it re-scans the published `latest`
# image and fails (notifying repo admins) plus raises a Security-tab alert on a
# fixable CRITICAL/HIGH CVE, prompting a dependency or base-image bump.
#
# It fires on three triggers:
# 1. workflow_run: the moment "Build and Push Docker Image" completes, so a
# freshly published image is gated within the scan's own duration (minutes)
# rather than waiting up to 24h for the cron. This is what shrinks the
# vulnerable-image exposure window after every publish.
# 2. schedule (daily): catches CVEs newly disclosed against an already-
# published image even when nothing was republished.
# 3. workflow_dispatch: run on demand from the Actions tab after a patch to
# confirm clean.
#
# Severity gate policy (both jobs): only fixable CRITICAL/HIGH CVEs may fail a
# run; LOW/MEDIUM findings must never turn a run red. Every sarif-format Trivy
# step MUST keep `limit-severities-for-sarif: true`, otherwise trivy-action
# unsets TRIVY_SEVERITY for SARIF output and the gate silently widens to all
# severities (that exact misconfiguration shipped once; see the scan step).
#
# The `sca` job is the dependency-level counterpart of the image scan: a daily
# Trivy filesystem scan of the npm lockfile. It exists because Dependabot was
# deliberately removed (PR #1084) and two HIGH Next.js CVEs then sat
# undetected until a manual check; this job is the automated SCA alerting
# that replaces it.
#
# NOTE: GitHub only runs `schedule` and `workflow_run` triggers from the default
# branch, so both start firing once this is merged to main.
on:
workflow_run:
workflows: ['Build and Push Docker Image']
types: [completed]
schedule:
# 06:17 UTC daily: off the hour to dodge cron congestion on GitHub.
- cron: '17 6 * * *'
workflow_dispatch: {}
env:
REGISTRY: ghcr.io
IMAGE_NAME: erp-mafia/gnubok
jobs:
scan:
runs-on: ubuntu-latest
# workflow_run fires even when the publish FAILED: there's no new image to
# gate in that case, so skip. schedule/workflow_dispatch carry no
# workflow_run payload, so the `!= 'workflow_run'` arm lets them through.
if: >-
github.event_name != 'workflow_run' ||
github.event.workflow_run.conclusion == 'success'
permissions:
contents: read
# Pull the published image from GHCR.
packages: read
# SARIF upload to the repo's "Security" tab.
security-events: write
steps:
- name: Log in to GHCR
uses: docker/login-action@abd2ef45e78c5afb21d64d4ca52ee8550d9572c7 # v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Scan published image with Trivy
uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
with:
image-ref: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
# Block on fixable CRITICAL/HIGH: the same policy the build pipeline
# used to enforce inline. It is safe to block here: a red scheduled
# run is a "go patch" notification, not a blocked deploy. ignore-unfixed
# keeps it actionable (only CVEs we can resolve by rebuilding fail).
severity: CRITICAL,HIGH
exit-code: '1'
ignore-unfixed: true
format: sarif
output: trivy-results.sarif
# Without this, trivy-action unsets TRIVY_SEVERITY when format is
# sarif (entrypoint.sh: "Building SARIF report with all severities"),
# silently discarding the CRITICAL,HIGH filter above. The exit code
# then fires on any fixable CVE down to LOW, which is not the policy
# documented here and turns routine low-severity noise into a red run.
limit-severities-for-sarif: true
- name: Upload Trivy results to GitHub Security tab
# if: always() so findings still reach the Security tab even though the
# scan step above failed the run. Same category as docker-publish.yml so
# the two analyses share one alert set instead of duplicating.
if: always()
uses: github/codeql-action/upload-sarif@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4
with:
sarif_file: trivy-results.sarif
category: trivy
sca:
runs-on: ubuntu-latest
# The lockfile does not change when an image is published, so the
# workflow_run trigger is irrelevant here: run on the daily schedule and
# on manual dispatch only.
if: github.event_name != 'workflow_run'
permissions:
contents: read
# SARIF upload to the repo's "Security" tab.
security-events: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- name: Scan npm lockfile with Trivy
uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
with:
# Filesystem scan: picks up package-lock.json and reports known CVEs
# in the resolved dependency tree, including transitive pins. Same
# gate policy as the image scan above: fail only on fixable
# CRITICAL/HIGH, and keep limit-severities-for-sarif set (see the
# header comment for why dropping it silently widens the gate).
scan-type: fs
scan-ref: .
scanners: vuln
severity: CRITICAL,HIGH
exit-code: '1'
ignore-unfixed: true
format: sarif
output: trivy-sca.sarif
limit-severities-for-sarif: true
- name: Upload Trivy SCA results to GitHub Security tab
# if: always() so findings reach the Security tab even when the scan
# step failed the run. Distinct category from the image scan so
# dependency alerts and image alerts stay separately traceable.
if: always()
uses: github/codeql-action/upload-sarif@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4
with:
sarif_file: trivy-sca.sarif
category: trivy-sca
-320
View File
@@ -1,320 +0,0 @@
name: Build and Push Docker Image
# Builds each platform on its own native runner, then stitches the two into one
# manifest list.
#
# This was a single amd64 job emulating arm64 through QEMU and took ~31 minutes:
# QEMU translates every Arm instruction into x86, so the arm64 half ran several
# times slower than the amd64 half it shared a runner with. GitHub's free
# `ubuntu-24.04-arm` runners (public repos) remove the emulation entirely, and
# the two halves now run concurrently on their own hardware.
#
# The cost is a second job. A native single-platform build cannot produce a
# multi-platform manifest by itself, so each build pushes an untagged,
# digest-addressed image and `merge` composes the tag list from those digests
# with `imagetools create`. Tagging, signing, and scanning all belong to `merge`,
# because the digest consumers actually resolve is the manifest list's, not
# either platform's.
#
# workflow_dispatch is deliberate: it makes this runnable from a branch before
# merge. On a non-default branch the is_default_branch guard below disables the
# `latest` tag, so a dispatch run publishes only the immutable commit-sha tag and
# cannot move what production pulls.
on:
push:
branches: [main]
tags: ['v*.*.*']
workflow_dispatch: {}
env:
REGISTRY: ghcr.io
IMAGE_NAME: erp-mafia/gnubok
jobs:
build:
name: Build ${{ matrix.platform }}
runs-on: ${{ matrix.runner }}
strategy:
# Publishing one architecture and silently dropping the other is worse
# than publishing neither: the merge below needs both digests.
fail-fast: true
matrix:
include:
- platform: linux/amd64
arch: amd64
runner: ubuntu-latest
- platform: linux/arm64
arch: arm64
runner: ubuntu-24.04-arm
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
# The build pushes to GHCR via docker/login-action, never over git, so
# the git credential is dead weight inside a Docker build context.
persist-credentials: false
- name: Log in to GHCR
uses: docker/login-action@abd2ef45e78c5afb21d64d4ca52ee8550d9572c7 # v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Labels only. Tags are applied once, to the manifest list, in `merge`.
- name: Extract metadata
id: meta
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4
# No setup-qemu-action. That was the whole point: each runner now builds
# its own architecture natively.
- name: Build and push by digest
id: build
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7
with:
context: .
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
EXTENSIONS_PRESET=self-hosted
# SBOM (software bill of materials) + SLSA provenance are attached as
# OCI attestations, queryable via `docker buildx imagetools inspect`.
provenance: mode=max
sbom: true
# push-by-digest publishes without a tag; `merge` collects the digests
# and builds the tag list from them. name-canonical records the
# repository name in the config so the merged manifest resolves.
outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
# Layer cache lives in GHCR, not the GitHub Actions cache. Two
# platforms x mode=max is ~7 GB, which alone ate 70% of the repo's
# 10 GB Actions cache quota and, because buildx refreshes every blob's
# access time on each run, never aged out under LRU: it starved the
# other workflows' caches instead. GHCR storage is free for public
# repos and off that quota. mode=max is kept deliberately: mode=min
# would drop the deps/builder stages and make every push redo
# `npm ci` + `next build`.
#
# The cache tag is now per-architecture. Each runner builds a single
# platform, so a shared tag would leave the two jobs racing to
# overwrite a cache manifest describing layers the other cannot use.
#
# A stable cache tag is safe here: this workflow runs only on main,
# on v*.*.* tags (cut from main), and on manual dispatch, so there is
# no untrusted ref that could poison the layers.
#
# image-manifest=true,oci-mediatypes=true is required by GHCR, which
# rejects buildkit's default cache manifest media type.
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-${{ matrix.arch }}
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-${{ matrix.arch }},mode=max,image-manifest=true,oci-mediatypes=true
- name: Verify NEXT_PUBLIC_* sentinels survived the build
# The image is generic: it is built with sentinel values
# (__NEXT_PUBLIC_SELF_HOSTED__) that docker-entrypoint.sh seds into
# .next at container start. That only works if the sentinel is still IN
# the build output. Writing `process.env.NEXT_PUBLIC_X === 'true'` in
# source lets the minifier fold the comparison and delete the branch,
# erasing the sentinel: the flag is then permanently false and no
# operator setting can change it. That shipped once and left every
# Docker self-host running with the entitlement paywall live, invisibly,
# because dev and the Vercel build both have real env values and never
# reproduce it.
#
# This runs in the per-platform build, not in `merge`, for two reasons.
# It is the only place each architecture is actually checked: `docker
# run` against the manifest list resolves the runner's own platform, so
# a merge-job check would silently exempt arm64. And it lands BEFORE any
# tag exists, so a folded sentinel fails the matrix (fail-fast) and
# `merge` never runs: `latest` cannot move onto a build whose flags can
# no longer be configured. The digest image pushed above stays untagged
# and unreferenced.
#
# check:guards catches the source pattern on every PR; this is the
# end-to-end proof against the built artifact, which is the only place
# the failure is observable.
env:
DIGEST: ${{ steps.build.outputs.digest }}
run: |
set -euo pipefail
IMAGE="${REGISTRY}/${IMAGE_NAME}@${DIGEST}"
MISSING=""
for VAR in NEXT_PUBLIC_SELF_HOSTED NEXT_PUBLIC_REQUIRE_MFA; do
if docker run --rm --entrypoint sh "$IMAGE" -c \
"grep -rq '__${VAR}__' /opt/gnubok-template/.next"; then
echo "ok: __${VAR}__ present in build output"
else
MISSING="${MISSING} ${VAR}"
fi
done
if [ -n "$MISSING" ]; then
echo "::error::Sentinel(s) missing from the build output:${MISSING}."
echo "::error::Read these flags via lib/env/public-flags (flagEnabled/isSelfHosted)."
echo "::error::An in-place comparison is constant-folded away, leaving the flag stuck off."
exit 1
fi
# Digests reach `merge` as artifact filenames: the file content is
# irrelevant, only the name carries information.
- name: Export digest
env:
DIGEST: ${{ steps.build.outputs.digest }}
run: |
set -euo pipefail
mkdir -p /tmp/digests
touch "/tmp/digests/${DIGEST#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: digests-${{ matrix.arch }}
path: /tmp/digests/*
# A silently empty artifact would surface later as an imagetools
# invocation with no source digests, which is a much worse error.
if-no-files-found: error
retention-days: 1
merge:
name: Merge, sign and scan
runs-on: ubuntu-latest
needs: build
permissions:
contents: read
packages: write
# OIDC token used by cosign keyless signing.
id-token: write
# SARIF upload to the repo's "Security" tab from the Trivy scan.
security-events: write
steps:
- name: Download digests
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true
- name: Log in to GHCR
uses: docker/login-action@abd2ef45e78c5afb21d64d4ca52ee8550d9572c7 # v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4
- name: Extract metadata
id: meta
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# On main: push `latest` + commit-sha tags.
# On v*.*.* tags: push semver tags (1.2.3, 1.2, 1) for production pinning.
# A workflow_dispatch run from a branch gets the sha tag only, because
# is_default_branch gates `latest`.
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=sha,prefix=
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Create and push manifest list
working-directory: /tmp/digests
run: |
set -euo pipefail
docker buildx imagetools create \
$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf "${REGISTRY}/${IMAGE_NAME}@sha256:%s " *)
# Cosign and Trivy must address the manifest list, not either platform's
# image: the list digest is what `docker pull` resolves for consumers, so
# it is the thing worth signing and the thing worth scanning.
- name: Resolve manifest list digest
id: manifest
env:
VERSION: ${{ steps.meta.outputs.version }}
run: |
set -euo pipefail
DIGEST=$(docker buildx imagetools inspect \
"${REGISTRY}/${IMAGE_NAME}:${VERSION}" \
--format '{{json .Manifest}}' | jq -r '.digest')
echo "Resolved ${REGISTRY}/${IMAGE_NAME}:${VERSION} -> ${DIGEST}"
echo "digest=${DIGEST}" >> "$GITHUB_OUTPUT"
- name: Verify both platforms are present
# A merge that quietly produced a single-arch manifest would ship a
# broken image to every arm64 self-hoster, and nothing downstream checks
# architecture. Assert it here while the digest is still in hand.
env:
DIGEST: ${{ steps.manifest.outputs.digest }}
run: |
set -euo pipefail
PLATFORMS=$(docker buildx imagetools inspect \
"${REGISTRY}/${IMAGE_NAME}@${DIGEST}" --raw \
| jq -r '[.manifests[]
| select(.platform != null)
| select(.platform.os != "unknown")
| "\(.platform.os)/\(.platform.architecture)"]
| sort | unique | join(",")')
echo "Manifest platforms: ${PLATFORMS}"
[ "$PLATFORMS" = "linux/amd64,linux/arm64" ] || {
echo "::error::Expected linux/amd64,linux/arm64 but got ${PLATFORMS}"
exit 1
}
- name: Install cosign
uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2
- name: Sign the image (keyless OIDC)
env:
DIGEST: ${{ steps.manifest.outputs.digest }}
run: |
set -euo pipefail
cosign sign --yes "${REGISTRY}/${IMAGE_NAME}@${DIGEST}"
- name: Scan image with Trivy (report-only)
id: trivy
# Decoupled from the publish gate on purpose: this pipeline must stay
# green so builds are deterministic. The image is already pushed and
# signed above, so failing here would only redden the run: it would not
# unship a vulnerable image. exit-code:0 + continue-on-error keep CVEs
# (and even a Trivy/DB outage) from failing the build; findings still
# flow to the Security tab below. The real blocking gate is
# docker-image-scan.yml, which re-scans the published image and fails
# (notifying admins) on a fixable CRITICAL/HIGH CVE. It runs on a
# workflow_run trigger the moment THIS workflow completes (so the gap
# between publish and the blocking scan is the scan's own duration
# (minutes), not a 24h cron window) plus a daily cron as a safety net.
# Accepted residual risk: an image is live for that short scan window
# before the gate fires; see docs/SELF-HOSTING.md / the risk register.
continue-on-error: true
uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
with:
image-ref: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ steps.manifest.outputs.digest }}
severity: CRITICAL,HIGH
exit-code: '0'
ignore-unfixed: true
format: sarif
output: trivy-results.sarif
- name: Upload Trivy results to GitHub Security tab
# if: always(), evidence must reach the Security tab regardless of the
# scan step's exit status. With the previous `outcome == 'success'` guard,
# a Trivy/DB outage that errored the scan would silently drop findings.
# Kept non-fatal (continue-on-error) so a missing SARIF or a Security-tab
# hiccup can't redden an otherwise-good publish.
if: always()
continue-on-error: true
uses: github/codeql-action/upload-sarif@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4
with:
sarif_file: trivy-results.sarif
category: trivy
-194
View File
@@ -1,194 +0,0 @@
name: Publish MCP bridges to npm
# Publishes the two stdio-to-HTTP MCP bridges, packages/accounted-mcp and
# packages/gnubok-mcp, to the public npm registry.
#
# The trigger is a version bump, not a git tag: a push to main that touches a
# packages/*/package.json runs one job per package, and each job publishes only
# if the version in its package.json is not already on the registry. A package
# whose version did not change is skipped, so a merge that bumps one bridge
# never republishes the other, and re-running a finished workflow is a no-op.
#
# Auth is the repository secret NPM_TOKEN, an npm granular access token with
# publish rights on both packages. A run without the secret fails at its first
# step with a message naming it, rather than inside `npm publish` with an opaque
# ENEEDAUTH. A token rather than OIDC trusted publishing because accounted-mcp
# has never been published, and npm cannot bind a trusted publisher to a package
# that does not exist yet.
#
# --provenance attaches a Sigstore attestation that ties the tarball to this
# workflow run and commit; id-token: write exists for that. The registry rejects
# the attestation unless package.json `repository.url` matches this repository,
# which is why both package.jsons point at erp-mafia/accounted.
#
# workflow_dispatch runs the same job on demand, optionally for one package (the
# other package's job is skipped by the Select step), and with dry_run to
# exercise the version gate and `npm publish --dry-run` without touching the
# registry. Dispatching from a branch is the way to test this file
# before merging it.
on:
push:
branches: [main]
paths:
- 'packages/*/package.json'
workflow_dispatch:
inputs:
package:
description: Package to publish
type: choice
options: [all, accounted-mcp, gnubok-mcp]
default: all
dry_run:
description: Pack and validate only, do not publish
type: boolean
default: false
permissions:
contents: read
# A dispatch overlapping a push could race to publish the same version; the
# loser would only fail with a confusing E403. Queue instead of cancelling.
concurrency:
group: npm-publish
cancel-in-progress: false
jobs:
publish:
name: Publish ${{ matrix.package }}
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
# OIDC token for the --provenance attestation.
id-token: write
strategy:
# The packages are independent: a failure in one must not cancel the other.
fail-fast: false
matrix:
# Static on purpose: both packages always get a job. On push the
# version gate skips the one that did not change; on dispatch the
# Select step skips the one that was not requested. A matrix built
# from the dispatch input would put workflow input text into an
# expression, which is the shape injection scanners flag.
package: [accounted-mcp, gnubok-mcp]
env:
DRY_RUN: ${{ inputs.dry_run == true }}
PACKAGE_DIR: packages/${{ matrix.package }}
steps:
- name: Select package
id: select
env:
REQUESTED: ${{ github.event_name == 'push' && 'all' || inputs.package }}
PACKAGE: ${{ matrix.package }}
run: |
set -euo pipefail
if [ "$REQUESTED" = "all" ] || [ "$REQUESTED" = "$PACKAGE" ]; then
echo "run=true" >> "$GITHUB_OUTPUT"
else
echo "Skipping $PACKAGE: dispatch requested $REQUESTED."
echo "run=false" >> "$GITHUB_OUTPUT"
fi
- name: Require the NPM_TOKEN secret
# Before checkout, so a missing secret is the first line of the log.
# Only the presence of the secret is checked here; the token itself is
# exposed to the publish step alone.
if: steps.select.outputs.run == 'true'
env:
NPM_TOKEN_SET: ${{ secrets.NPM_TOKEN != '' }}
run: |
set -euo pipefail
if [ "$DRY_RUN" = "true" ]; then
echo "Dry run: NPM_TOKEN is not required."
exit 0
fi
if [ "$NPM_TOKEN_SET" != "true" ]; then
echo "::error::Repository secret NPM_TOKEN is not set. Create an npm granular access token with read and write access to accounted-mcp and gnubok-mcp (see the Releasing section in packages/*/README.md) and add it under Settings > Secrets and variables > Actions as NPM_TOKEN."
exit 1
fi
echo "NPM_TOKEN is set."
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
if: steps.select.outputs.run == 'true'
with:
# Nothing here pushes over git; the only credential this job needs is
# the npm token, and that never touches the checkout.
persist-credentials: false
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6
if: steps.select.outputs.run == 'true'
with:
node-version: 22
# Writes an .npmrc that reads the auth token from NODE_AUTH_TOKEN.
registry-url: https://registry.npmjs.org
- name: Compare package.json version with the registry
id: gate
if: steps.select.outputs.run == 'true'
working-directory: ${{ env.PACKAGE_DIR }}
run: |
set -euo pipefail
NAME=$(node -p "require('./package.json').name")
VERSION=$(node -p "require('./package.json').version")
# `npm view` exits 1 with an E404 body when the package has never
# been published. That is the first-release case and counts as
# "nothing on the registry". Any other failure (network, registry
# outage, bad token) is an error: assuming "not published" there
# would only move the failure into `npm publish`.
set +e
VIEW=$(npm view "$NAME" versions --json 2>&1)
STATUS=$?
set -e
if [ "$STATUS" -ne 0 ]; then
if grep -q 'E404' <<< "$VIEW"; then
echo "$NAME has never been published (E404): $VERSION would be its first release."
VIEW='[]'
else
echo "::error::npm view $NAME failed (exit $STATUS)."
echo "$VIEW"
exit 1
fi
fi
# `npm view <name> versions --json` prints a bare string, not a
# one-element array, when exactly one version exists.
ON_REGISTRY=$(VIEW="$VIEW" VERSION="$VERSION" node -e '
const raw = JSON.parse(process.env.VIEW);
const list = Array.isArray(raw) ? raw : [raw];
console.error("Versions on registry: " + (list.length ? list.join(", ") : "(none)"));
process.stdout.write(list.includes(process.env.VERSION) ? "yes" : "no");
')
if [ "$ON_REGISTRY" = "yes" ]; then
echo "Skipping: $NAME@$VERSION is already on the registry."
echo "publish=false" >> "$GITHUB_OUTPUT"
echo "- \`$NAME@$VERSION\`: already on the registry, skipped" >> "$GITHUB_STEP_SUMMARY"
else
echo "Publishing: $NAME@$VERSION is not on the registry."
echo "publish=true" >> "$GITHUB_OUTPUT"
fi
echo "name=$NAME" >> "$GITHUB_OUTPUT"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Publish to npm
if: steps.select.outputs.run == 'true' && steps.gate.outputs.publish == 'true'
working-directory: ${{ env.PACKAGE_DIR }}
env:
# The only step that sees the token.
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NAME: ${{ steps.gate.outputs.name }}
VERSION: ${{ steps.gate.outputs.version }}
run: |
set -euo pipefail
if [ "$DRY_RUN" = "true" ]; then
# --dry-run packs and validates but never contacts the registry, so
# it also runs without a token.
npm publish --dry-run --access public
echo "- \`$NAME@$VERSION\`: dry run, not published" >> "$GITHUB_STEP_SUMMARY"
exit 0
fi
npm publish --provenance --access public
echo "- \`$NAME@$VERSION\`: published, https://www.npmjs.com/package/$NAME/v/$VERSION" >> "$GITHUB_STEP_SUMMARY"
-97
View File
@@ -1,97 +0,0 @@
name: PR Agent
# AI pull-request review (PR-Agent, the original open-source reviewer: repo id
# 662766482, same repo the qodo-ai/Codium-ai names redirect to). Replaces the
# Greptile bot that went silent after #682.
#
# Supply-chain hardening:
# * Pinned to an immutable commit SHA (v0.36.0), NOT a movable tag, because the
# repo now sits under a recently-created, unverified org (The-PR-Agent).
# * Runs on a DEDICATED, minimal IAM key (bedrock:InvokeModel only) supplied via
# PR_AGENT_AWS_* secrets: never the app's general AWS credentials. A leaked
# PR-Agent key can do nothing but invoke the one Bedrock model.
#
# Scope: ONLY /review runs automatically. /describe and /improve are disabled so
# the bot never overwrites hand-written PR descriptions. Users can still invoke
# any command interactively by commenting e.g. "/describe" or "/improve" on a PR.
on:
pull_request:
types: [opened, reopened, ready_for_review, synchronize]
issue_comment:
types: [created, edited]
# One run per PR *per event type*; a new push (pull_request:synchronize) cancels
# a superseded review. The event_name suffix is critical: without it, the
# pull_request and issue_comment triggers share a group, so a bot comment
# (Vercel/Supabase/compliance preview bots fire within ~2s of opening a PR)
# queues an issue_comment run that cancel-in-progress kills the real review with,
# before the job-level `if: sender.type != 'Bot'` ever gets to skip it. Keeping the
# groups separate lets comment runs cancel only each other (all skipped, harmless)
# and never the open/push review.
concurrency:
group: pr-agent-${{ github.event.pull_request.number || github.event.issue.number }}-${{ github.event_name }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: write
issues: write
jobs:
pr_agent:
# Skip bot-authored events (vercel/supabase/etc.) to avoid feedback loops.
if: ${{ github.event.sender.type != 'Bot' }}
runs-on: ubuntu-latest
name: The PR Agent
steps:
- name: The PR Agent
# Pinned to the v0.36.0 commit SHA (immutable): do not switch to @v0.36.0.
uses: The-PR-Agent/pr-agent@8e4d32e5497defd43c023a404f73560c62728961 # v0.39.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# ── DEDICATED Bedrock IAM key (bedrock:InvokeModel only): NOT the
# app's AWS_* secrets. litellm reads AWS_REGION_NAME; AWS_REGION is
# set too for safety. Create these three repo/org secrets:
# PR_AGENT_AWS_ACCESS_KEY_ID, PR_AGENT_AWS_SECRET_ACCESS_KEY,
# PR_AGENT_AWS_REGION (an EU region, e.g. eu-west-1).
AWS_ACCESS_KEY_ID: ${{ secrets.PR_AGENT_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.PR_AGENT_AWS_SECRET_ACCESS_KEY }}
AWS_REGION_NAME: ${{ secrets.PR_AGENT_AWS_REGION }}
AWS_REGION: ${{ secrets.PR_AGENT_AWS_REGION }}
# ── Model: Claude Sonnet 5 via the EU Bedrock inference profile. The
# strong and weak slots both point at it: this account has no larger
# model enabled, so a second id would only be the same model under
# another name. custom_model_max_tokens is required because this id
# is not in PR-Agent's built-in map.
CONFIG.MODEL: "bedrock/eu.anthropic.claude-sonnet-5"
CONFIG.MODEL_WEAK: "bedrock/eu.anthropic.claude-sonnet-5"
# Emptied explicitly. This block previously said it set no fallback
# list, but "unset" is not "none": PR-Agent's own default is
# ["gpt-5.6-terra"], visible in the resolved config it logs on every
# run. Only AWS credentials reach this container, so that fallback
# could never have authenticated, but a silent third-party model in
# the path of every PR diff should be absent by intent, not by a
# missing key.
CONFIG.FALLBACK_MODELS: "[]"
CONFIG.CUSTOM_MODEL_MAX_TOKENS: "1000000"
# Input window PR-Agent prunes the diff to fit. Default (~32k) truncated
# large PRs; raise it so the whole diff is reviewed (Sonnet 5 = 1M ctx).
# 64000 was tuned against Sonnet 4.6's tokenizer. Sonnet 5 tokenizes the
# same text into roughly 30% more tokens, so that budget silently held
# ~30% less real diff after #1218; 96000 restores parity with headroom.
CONFIG.MAX_MODEL_TOKENS: "96000"
LITELLM.DROP_PARAMS: "true"
# ── pr_actions = which GitHub PR *event actions* trigger the bot
# (NOT a command list). Default omits 'synchronize', so pushes are
# skipped; we add it so every push is reviewed too.
GITHUB_ACTION_CONFIG.PR_ACTIONS: '["opened", "reopened", "ready_for_review", "review_requested", "synchronize"]'
# ── Which commands actually run on a handled event. Only review:
# describe/improve off so the bot never rewrites the PR body or
# pushes code suggestions.
GITHUB_ACTION_CONFIG.AUTO_REVIEW: "true"
GITHUB_ACTION_CONFIG.AUTO_DESCRIBE: "false"
GITHUB_ACTION_CONFIG.AUTO_IMPROVE: "false"
@@ -1,51 +0,0 @@
name: Compliance diff
# Stage 1 of the fork-safe compliance review (see swedish-compliance-review.yml).
#
# This runs on the untrusted PR head, but is SAFE because it has NO secrets and
# only a read-only token: it computes the diff and uploads it as an artifact.
# It never runs project code (no `npm install`, no `node`): only git plumbing,
# which does not execute repository hooks. The privileged half (model call +
# comment) lives in stage 2, which never checks out fork code.
on:
pull_request:
types: [opened, synchronize, reopened]
permissions:
contents: read
jobs:
prepare:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Compute diff vs base
# Pass GitHub context via env, never interpolate ${{ }} into the shell
# body: expression substitution happens before bash parses the script,
# so a value with shell metacharacters would be a code-execution sink.
env:
BASE_REF: ${{ github.base_ref }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
set -euo pipefail
# Full fetch (not --depth=1): the PR branch may be behind base, and a
# shallow base can leave merge-base with no reachable common ancestor.
# checkout above uses fetch-depth: 0, so HEAD already has full history.
git fetch origin "$BASE_REF"
MERGE_BASE=$(git merge-base "origin/$BASE_REF" HEAD)
git diff "$MERGE_BASE" HEAD > diff.patch
git diff --name-only "$MERGE_BASE" HEAD > files.txt
printf '%s\n' "$PR_NUMBER" > pr-number.txt
- name: Upload diff artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: compliance-input
path: |
diff.patch
files.txt
pr-number.txt
retention-days: 1
@@ -1,126 +0,0 @@
name: Swedish Accounting Compliance Review
# Stage 2 of the fork-safe compliance review (stage 1 is swedish-compliance-diff.yml).
#
# SECURITY: this is the privileged half: it has the AWS Bedrock secrets and a
# write token. It is triggered by `workflow_run` (NOT pull_request_target) and
# checks out ONLY the base repo, so it never executes fork PR code. The untrusted
# input (the PR diff) arrives as a downloaded artifact and is fed to the model
# as DATA: never run. This is the pattern GitHub recommends instead of
# `pull_request_target` + checking out the PR head.
on:
workflow_run:
# Must match the `name:` field in swedish-compliance-diff.yml exactly.
# A rename there silently stops this trigger from firing on all subsequent PRs.
workflows: ["Compliance diff"]
types: [completed]
permissions:
contents: read
actions: read # required to download the artifact from the triggering run
pull-requests: write # required to post the review comment
jobs:
review:
runs-on: ubuntu-latest
timeout-minutes: 10
# Only act on PR-triggered diffs that actually produced an artifact.
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
steps:
# Base repo only: the TRUSTED copy of the script and .claude/skills/.
# persist-credentials: false, no later step needs git push creds, so don't
# leave the token in .git/config for the steps that handle untrusted input.
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6
with:
node-version: 20
- name: Download diff artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: compliance-input
# Unpacked OUTSIDE the checkout, not into the workspace root.
#
# This artifact is built from a fork's PR head, so its contents are
# attacker-influenced. Extracted over the workspace, an entry named
# `scripts/swedish-compliance-review.mjs` would overwrite the trusted
# script this job is about to run, with the AWS secrets and a write
# token already in scope. Stage 1 only ever writes three fixed
# filenames, and its workflow definition comes from the base repo even
# for fork PRs, so that is not reachable today: this keeps it
# unreachable if stage 1 ever grows a filename derived from PR
# content. Flagged by CodeQL as actions/artifact-poisoning.
path: ${{ runner.temp }}/compliance-input
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Resolve PR number
id: pr
run: |
set -euo pipefail
NUM=$(cat "$RUNNER_TEMP/compliance-input/pr-number.txt")
# Guard: pr-number.txt must be a plain integer (artifact is untrusted input).
if ! [[ "$NUM" =~ ^[0-9]+$ ]]; then
echo "Refusing to continue: pr-number.txt is not a number" >&2
exit 1
fi
echo "number=$NUM" >> "$GITHUB_OUTPUT"
- name: Install Anthropic Bedrock SDK
# Installed ONE DIRECTORY ABOVE the checkout on purpose. Running this
# inside the repo makes npm re-resolve the whole dependency tree from
# package.json (--no-package-lock throws away the pinned resolutions),
# and that re-resolution dies on an unrelated floating peer conflict
# (@hookform/resolvers -> valibot), which silently killed this review on
# every PR. Out of tree npm resolves this one package and nothing else,
# so an unrelated peer conflict can never take the compliance gate down
# again. Node still finds it: ESM bare specifiers walk up the parent
# directories' node_modules. NODE_PATH is not an alternative here, the
# ESM loader ignores it (CommonJS only).
# Version tracks the exact package.json pin: 0.32.0 broke Bedrock
# streaming in prod (DECISIONS.md 2026-07-08) and check:guards enforces
# 0.29.1 repo-wide, so this job must not be the one place running an
# unvetted build. Pinned exact + --ignore-scripts because this is the
# privileged job (write token in env): no floating @latest, and no
# dependency lifecycle scripts may execute here.
run: npm install --prefix "$GITHUB_WORKSPACE/.." --no-save --no-package-lock --ignore-scripts @anthropic-ai/bedrock-sdk@0.29.1
- name: Run compliance review
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION || 'eu-north-1' }}
REVIEW_MODEL: eu.anthropic.claude-sonnet-5
# Two-stage mode: read the diff from the artifact instead of git-diffing.
DIFF_FILE: ${{ runner.temp }}/compliance-input/diff.patch
FILES_FILE: ${{ runner.temp }}/compliance-input/files.txt
run: node scripts/swedish-compliance-review.mjs
- name: Assert review produced output
# This job once produced no compliance signal for 10 consecutive PR
# runs (the in-tree npm install died on an unrelated peer conflict, see
# the install step above) and nobody noticed: workflow_run-triggered
# jobs do not appear on the PR checks list, so a red or silently empty
# run is invisible from the PR. Fail loudly whenever the review script
# finishes without writing a non-empty review.md, so "no output" can
# never again pass as a green run.
run: |
set -euo pipefail
if [ ! -s review.md ]; then
echo "::error::Compliance review produced no output (review.md missing or empty)"
exit 1
fi
- name: Find previous compliance comment
uses: peter-evans/find-comment@b30e6a3c0ed37e7c023ccd3f1db5c6c0b0c23aad # v4.0.0
id: find-comment
with:
issue-number: ${{ steps.pr.outputs.number }}
comment-author: 'github-actions[bot]'
body-includes: '<!-- swedish-compliance-review-bot -->'
- name: Post or update PR comment
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5
with:
issue-number: ${{ steps.pr.outputs.number }}
comment-id: ${{ steps.find-comment.outputs.comment-id }}
body-path: review.md
edit-mode: replace
-299
View File
@@ -1,299 +0,0 @@
name: pg-real tests
on: [pull_request]
# Neither job writes anything back: they read the repo, stand up a throwaway
# Postgres, and run tests. Without this block both inherit the repository's
# default token permissions, which are broader than that.
permissions:
contents: read
concurrency:
group: pg-real-${{ github.ref }}
cancel-in-progress: true
jobs:
coverage-gate:
# Enforces the database.md rule: a migration touching a trigger/RPC/RLS/
# DEFERRABLE must come with a *.pg.test.ts change. Previously instruction-
# only. Escape hatch: `-- pg-test: covered-by <path>` / `-- pg-test: skip
# (<reason>)` comments inside the migration.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
# Full history so the merge-base with the PR base branch exists.
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6
with:
node-version: 20
- name: Require pg-real coverage for trigger/RPC/RLS migrations
env:
PG_GATE_BASE: origin/${{ github.base_ref }}
run: node scripts/check-pg-test-coverage.mjs
# Proves that an EXISTING database survives the PR's migrations, which the
# pg-real job below cannot: it applies every migration to an empty database,
# so a NOT NULL, a CHECK, a unique index or a backfill passes trivially
# against zero rows and can still fail (or silently corrupt) on production.
#
# Shape: schema at the merge-base -> seed real rows -> apply ONLY the new
# migrations -> assert the rows are intact. A PR that adds no migration skips
# straight past the apply step and costs one cheap no-op run.
pg-upgrade:
runs-on: ubuntu-latest
services:
postgres:
image: supabase/postgres:15.8.1.060
env:
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U postgres"
--health-interval 5s
--health-timeout 5s
--health-retries 20
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/postgres
PGPASSWORD: postgres
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
# Full history so the merge-base with the PR base branch exists.
fetch-depth: 0
persist-credentials: false
- name: Install psql client
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends postgresql-client
- name: Identify the migrations this PR adds
id: newmig
env:
BASE_REF: origin/${{ github.base_ref }}
run: |
set -euo pipefail
MERGE_BASE=$(git merge-base "$BASE_REF" HEAD)
echo "merge_base=$MERGE_BASE" >> "$GITHUB_OUTPUT"
echo "Merge base: $MERGE_BASE"
# Migrations present at HEAD but not at the merge base. Uses the git
# tree, not the filesystem, so a rebase or a merge commit cannot make
# an already-shipped migration look new.
git ls-tree -r --name-only HEAD -- supabase/migrations \
| grep '\.sql$' | sort > /tmp/head-migrations.txt
git ls-tree -r --name-only "$MERGE_BASE" -- supabase/migrations \
| grep '\.sql$' | sort > /tmp/base-migrations.txt
comm -23 /tmp/head-migrations.txt /tmp/base-migrations.txt > /tmp/new-migrations.txt
COUNT=$(wc -l < /tmp/new-migrations.txt | tr -d ' ')
echo "count=$COUNT" >> "$GITHUB_OUTPUT"
echo "New migrations ($COUNT):"
cat /tmp/new-migrations.txt
- name: Bootstrap storage schema
if: steps.newmig.outputs.count != '0'
run: psql "$DATABASE_URL" -v ON_ERROR_STOP=1 -q -f tests/pg/bootstrap.sql
- name: Apply the schema as it stands at the merge base
if: steps.newmig.outputs.count != '0'
env:
MERGE_BASE: ${{ steps.newmig.outputs.merge_base }}
run: |
set -euo pipefail
# Read each migration out of the merge-base tree rather than the
# working tree: a PR that EDITS a shipped migration (forbidden, but
# this job must not be the thing that hides it) still gets the
# original applied here, so the edit shows up as a failure below.
while read -r f; do
echo "Applying (base) $f"
git show "$MERGE_BASE:$f" | psql "$DATABASE_URL" -v ON_ERROR_STOP=1 -q
done < /tmp/base-migrations.txt
- name: Seed a real company with posted verifikat
if: steps.newmig.outputs.count != '0'
run: psql "$DATABASE_URL" -v ON_ERROR_STOP=1 -q -f tests/pg/upgrade/seed.sql
- name: Apply ONLY the new migrations, against existing data
if: steps.newmig.outputs.count != '0'
run: |
set -euo pipefail
while read -r f; do
echo "Applying (new) $f"
psql "$DATABASE_URL" -v ON_ERROR_STOP=1 -q -f "$f"
done < /tmp/new-migrations.txt
- name: Assert the existing data survived
if: steps.newmig.outputs.count != '0'
run: psql "$DATABASE_URL" -v ON_ERROR_STOP=1 -f tests/pg/upgrade/assert.sql
- name: No migrations in this PR
if: steps.newmig.outputs.count == '0'
run: echo "This PR adds no migration; nothing to upgrade-test."
pg-real:
runs-on: ubuntu-latest
services:
postgres:
# Supabase image ships the auth schema, auth.uid(), and the extensions
# (uuid-ossp, pg_cron, btree_gist, vector) this repo's migrations need.
# Plain postgres:15 would require manual bootstrap SQL.
image: supabase/postgres:15.8.1.060
env:
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U postgres"
--health-interval 5s
--health-timeout 5s
--health-retries 20
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/postgres
PGPASSWORD: postgres
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
# Deliberately no `cache: npm` here. This workflow runs on pull_request
# only, so the cache is never written on main, and GitHub scopes caches
# by ref: every PR uploaded its own 284 MB copy under an identical key
# that no other PR could ever restore. Fourteen dead copies (4 GB, 40% of
# the repo quota) accumulated in a single day. If this is ever worth
# caching again, it has to be actions/cache/save on main plus
# actions/cache/restore here, which is the only shape that gets hits.
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6
with:
node-version: 20
- run: npm ci
- name: Install psql client
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends postgresql-client
- name: Bootstrap storage schema
# The supabase/postgres image ships a partial storage schema; the rest
# is provisioned by the storage-api service at runtime, which we do
# not run in CI. This aligns the schema with what migrations expect.
run: psql "$DATABASE_URL" -v ON_ERROR_STOP=1 -q -f tests/pg/bootstrap.sql
- name: Apply migrations
run: |
set -euo pipefail
shopt -s nullglob
files=(supabase/migrations/*.sql)
if [ ${#files[@]} -eq 0 ]; then
echo "No migration files found"
exit 1
fi
for f in "${files[@]}"; do
echo "Applying $f"
psql "$DATABASE_URL" -v ON_ERROR_STOP=1 -q -f "$f"
done
- run: npm run test:pg
tool-pg:
# MCP tools driven through a REAL supabase-js client against a REAL
# PostgREST. This is NOT a duplicate of the pg-real job: that one holds a
# `pg` Pool and writes SQL, which cannot see the half of a tool that
# PostgREST resolves (the .select() column strings, the resource embeds,
# the or=(...) grammar). Before this job, all 100 files in
# extensions/general/mcp-server/__tests__ faked supabase and nothing in CI
# exercised that surface.
runs-on: ubuntu-latest
services:
postgres:
image: supabase/postgres:15.8.1.060
env:
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U postgres"
--health-interval 5s
--health-timeout 5s
--health-retries 20
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/postgres
TOOL_PG_DATABASE_URL: postgresql://postgres:postgres@localhost:5432/postgres
TOOL_PG_REST_URL: http://127.0.0.1:3000
PGPASSWORD: postgres
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6
with:
node-version: 20
- run: npm ci
- name: Install psql client
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends postgresql-client
- name: Bootstrap storage schema
run: psql "$DATABASE_URL" -v ON_ERROR_STOP=1 -q -f tests/pg/bootstrap.sql
- name: Default privileges for the supabase roles
# Without these PostgREST answers every request with 42501, because the
# grants have to exist before the migrations create ~400 tables.
run: |
psql "$DATABASE_URL" -v ON_ERROR_STOP=1 -q -c "
GRANT USAGE ON SCHEMA public TO postgres, anon, authenticated, service_role;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO postgres, anon, authenticated, service_role;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON ROUTINES TO postgres, anon, authenticated, service_role;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON SEQUENCES TO postgres, anon, authenticated, service_role;
"
- name: Apply migrations
run: |
set -euo pipefail
shopt -s nullglob
files=(supabase/migrations/*.sql)
if [ ${#files[@]} -eq 0 ]; then echo "No migration files found"; exit 1; fi
for f in "${files[@]}"; do
psql "$DATABASE_URL" -v ON_ERROR_STOP=1 -q -f "$f"
done
- name: Grant on everything the migrations created
run: |
psql "$DATABASE_URL" -v ON_ERROR_STOP=1 -q -c "
GRANT ALL ON ALL TABLES IN SCHEMA public TO postgres, anon, authenticated, service_role;
GRANT ALL ON ALL ROUTINES IN SCHEMA public TO postgres, anon, authenticated, service_role;
GRANT ALL ON ALL SEQUENCES IN SCHEMA public TO postgres, anon, authenticated, service_role;
"
- name: Start PostgREST
# Deliberately `docker run --network host` rather than a service
# container. Service containers on a non-containerized job are reachable
# from the runner on localhost, but NOT from each other by name, and
# PostgREST has to reach Postgres. Host networking sidesteps that.
run: |
docker run -d --name postgrest --network host \
-e PGRST_DB_URI="postgres://postgres:postgres@127.0.0.1:5432/postgres" \
-e PGRST_DB_SCHEMAS=public \
-e PGRST_DB_ANON_ROLE=anon \
-e PGRST_JWT_SECRET="super-secret-jwt-token-with-at-least-32-characters-long" \
-e PGRST_DB_MAX_ROWS=100000 \
-e PGRST_SERVER_PORT=3000 \
postgrest/postgrest:v12.2.3
for _ in $(seq 1 60); do
if curl -sf -o /dev/null "http://127.0.0.1:3000/" ; then break; fi
sleep 1
done
curl -sf -o /dev/null "http://127.0.0.1:3000/" || (docker logs postgrest && exit 1)
- run: npm run test:tools
-81
View File
@@ -1,81 +0,0 @@
name: Workflow audit (zizmor)
# Static analysis for the workflows themselves. Every other scanner in this repo
# looks at application code or container contents; nothing looked at CI, which is
# where the credentials live.
#
# The motivating incident is concrete: in March 2026 attackers exploited a
# pull_request_target misconfiguration in aquasecurity/trivy-action (an action
# this repo uses in three places) to exfiltrate org and repo secrets, then used
# them to backdoor LiteLLM on PyPI. zizmor's dangerous-triggers and
# unpinned-uses audits cover exactly that class.
#
# Installed from PyPI at a pinned version rather than via zizmorcore/zizmor-action:
# a workflow whose job is to check the supply chain should not widen it.
on:
pull_request:
push:
branches: [main]
schedule:
# Weekly, off the hour to dodge cron congestion on GitHub. New audits ship
# regularly, so a repo that stopped changing can still start failing here.
- cron: '41 5 * * 1'
workflow_dispatch: {}
permissions:
contents: read
concurrency:
group: zizmor-${{ github.ref }}
cancel-in-progress: true
jobs:
audit:
name: Audit workflows
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
# SARIF upload to the repo's "Security" tab.
security-events: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
# pipx is preinstalled on GitHub's ubuntu runners. Exact pin, because an
# unpinned install here would be the same mistake this workflow exists to
# catch.
- name: Install zizmor
run: pipx install zizmor==1.28.0
- name: Audit workflows (SARIF)
env:
# Lets zizmor run its online audits (resolving `uses:` refs against
# the forge) instead of falling back to offline-only checks.
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# zizmor suppresses its findings-based exit codes under --format=sarif,
# so this step reports and never gates. The gate is the separate step
# below, which is why the audit is run twice.
run: zizmor --format=sarif . > zizmor.sarif
- name: Upload zizmor results to GitHub Security tab
# if: always() so findings still reach the Security tab when the gate
# below fails the run. Distinct category from the Trivy uploads so
# workflow findings stay separately traceable.
if: always()
uses: github/codeql-action/upload-sarif@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4
with:
sarif_file: zizmor.sarif
category: zizmor
- name: Gate on high-severity, high-confidence findings
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Deliberately narrower than the SARIF report above. Everything zizmor
# finds is visible in the Security tab; only findings it is confident are
# high severity block a merge. Tighten by lowering --min-severity once
# the backlog is clear.
run: zizmor --min-severity=high --min-confidence=high --format=plain .
-30
View File
@@ -1,30 +0,0 @@
# zizmor configuration. See .github/workflows/zizmor.yml for why this repo
# audits its own CI.
#
# Suppressions here are reviewed exceptions, not a backlog. Anything added needs
# a reason that says why the generic rule does not apply, so the Security tab
# stays worth reading.
rules:
dangerous-triggers:
ignore:
# zizmor's position is that `workflow_run` is almost always used
# insecurely, and it is right in general: the usual mistake is triggering
# on a fork's build and then checking out that fork's code with secrets in
# scope. Both uses below are the opposite pattern, and both are the
# documented fix for the trigger they replaced.
#
# Stage 2 of the fork-safe compliance review. It holds the AWS secrets and
# a write token, and it checks out ONLY the base repo: fork code never
# executes here. The untrusted PR diff arrives as a downloaded artifact
# and is passed to the model as data. This is precisely what GitHub
# recommends instead of `pull_request_target` + checking out the PR head,
# which is what this workflow used to be.
- swedish-compliance-review.yml
# Re-scans an image that has already been published to GHCR. It checks out
# no source at all and only fires on `conclusion == 'success'` of a
# workflow that itself runs only on main and release tags, so there is no
# untrusted input and no fork ref in reach. The trigger exists to shrink
# the window between publishing an image and gating it from up to 24h
# (the cron) down to the scan's own duration.
- docker-image-scan.yml