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
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
schema: spec-driven
created: 2026-11-01
13 changes: 13 additions & 0 deletions openspec/changes/2526-the-five-defect-fixes-merged-on/design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Design

## Decisions

- **Place each guardrail in the single surface that best fits its defect class.**: Each surface has existing content that the guardrail extends, and the defect class matches the surface scope. Placing all five in one surface would dilute the relevance.
- **Write guardrails as sentences in the existing numbered items and sections, not as new sections.**: The items already hold rules of the same class. A new section would fragment the rule set and add no structure a reader needs.
- **Create a new capability `hardening-surface-guardrails` for the spec delta.**: No existing capability covers the declared hardening surfaces. The guardrails are project-level rules that constrain future code, which is observable behavior that a spec delta must record.

## Rejected alternatives

- **Write all five guardrails as Semgrep rules in src/devops_cli/review/rules/.**: The five defect classes are architectural and process lessons, not code patterns that a Semgrep rule can express. The rules directory holds code-pattern rules with passing tests.
- **Place all five guardrails in SECURITY.md.**: The Loki CVE pin (#2470) is a dependency-management process rule, not a security rule. CONTRIBUTING.md already holds process rules for contributors.
- **Set skip_specs to true because the change only edits documents.**: The guardrails are declared hardening surfaces that the audit workflow checks. Adding a guardrail changes what the audit reports, which is observable behavior. The change carries a spec delta.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Proposal

## Why

#2526: five defect PRs merged on 2026-10-28 added no root-cause guardrail to a declared hardening surface. The audit workflow found each one, but its intake step crashed before filing the finding. This change adds the missing guardrails so the defect classes do not return.

## What Changes

- Add a frozen-lockfile guardrail to SECURITY.md item 7 for tool adapter execution (#2446).
- Add a CVE-check guardrail to CONTRIBUTING.md section 1 for pinned sub-chart versions (#2470).
- Add a userinfo-exclusion guardrail to SECURITY.md item 1 for display strings (#2488).
- Add a one-time-resolution guardrail to SECURITY.md item 2 for NetworkPolicy and scrape targets (#2521).
- Add an automountServiceAccountToken guardrail to SECURITY.md item 5 for pods (#2522).
- The change fits one pull request.

## Capabilities

### New Capabilities

- `hardening-surface-guardrails`: guardrail_per_defect, guardrail_names_defect_class, guardrail_in_best_fit_surface

### Modified Capabilities

None.

## Impact

- Documents: `SECURITY.md`, `CONTRIBUTING.md`

## Feasibility

- The audit workflow .github/workflows/defect-pr-hardening-audit.yml confirms the premise: it runs `uv run devops pr hardening-report --pr <number> --fail-on-missing` and the five PRs are reported as unhardened.
- SECURITY.md exists with numbered items 1 through 11. Items 1, 2, 5 and 7 hold the rules that the four guardrails extend.
- CONTRIBUTING.md exists with sections 1 through 6. Section 1 holds the development philosophy and process rules that the Loki CVE guardrail extends.
- The change adds sentences to existing numbered items and sections. It creates no file and changes no code under src/.
- First checks the implementation runs: `grep -n 'frozen' SECURITY.md` to confirm item 7 context; `grep -n 'sub-chart\|CVE' CONTRIBUTING.md` to confirm the dependency section context.

## Existing Tool Considered

No open, maintained tool or library covers the need of writing prose guardrails into project documents. The project writes its own guardrail text into its declared surfaces. The cost is the tokens to write, keep and fix five guardrail entries across two documents, and the elapsed time for a person to review each entry.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## Purpose
The root-cause guardrails that each defect fix records in a declared hardening surface, so the defect class does not return.

## ADDED Requirements

### Requirement: guardrail_per_defect
Each defect fix SHALL record its root-cause lesson in at least one declared hardening surface.

#### Scenario: guardrail_text_present_in_surface
- **WHEN** a test reads the declared hardening surfaces for a defect PR's guardrail
- **THEN** the guardrail text is present in at least one surface, naming the defect class and the prevention rule

### Requirement: guardrail_names_defect_class
Each guardrail entry SHALL name the defect class it prevents and the rule that prevents it.

#### Scenario: guardrail_text_is_specific
- **WHEN** a test reads a guardrail entry in its surface
- **THEN** the entry contains the defect class name and the prevention rule text

### Requirement: guardrail_in_best_fit_surface
Each guardrail SHALL appear in exactly one declared surface that best fits its defect class.

#### Scenario: single_surface_per_guardrail
- **WHEN** a test searches all declared surfaces for a guardrail's defect class name
- **THEN** the defect class name appears in exactly one surface
21 changes: 21 additions & 0 deletions openspec/changes/2526-the-five-defect-fixes-merged-on/tasks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Tasks

## 1. Add four guardrails to SECURITY.md

Reads: none. Changes: `SECURITY.md`.

- [ ] 1.1 A grep for each of the four guardrail phrases in SECURITY.md fails before the change and passes after: `grep -q 'frozen lockfile' SECURITY.md && grep -q 'userinfo' SECURITY.md && grep -q 'one time, through the egress check' SECURITY.md && grep -q 'automountServiceAccountToken' SECURITY.md`, and verify that `grep -q 'frozen lockfile' SECURITY.md && grep -q 'userinfo' SECURITY.md && grep -q 'one time, through the egress check' SECURITY.md && grep -q 'automountServiceAccountToken' SECURITY.md` fails on the base
- [ ] 1.2 Add a sentence to item 7 (Review Tool Execution) stating that a scan command that runs a tool adapter MUST use the frozen lockfile (`--frozen`) so the audit is reproducible and not affected by lockfile drift. Add a sentence to item 1 (Zero Secret Leakage) stating that a display string that names a server MUST use only the origin (scheme, host, port) of the URL it called and MUST never include the userinfo component. Add a sentence to item 2 (Strict Egress and SSRF Protection) stating that a NetworkPolicy or scrape target that names a host MUST resolve it one time, through the egress check, at connect time and MUST NOT cache the resolution. Add a sentence to item 5 (Least Privilege Runtime) stating that a pod that does not call the Kubernetes API MUST set `automountServiceAccountToken: false` so it holds no service account token, and verify that `grep -q 'frozen lockfile' SECURITY.md && grep -q 'userinfo' SECURITY.md && grep -q 'one time, through the egress check' SECURITY.md && grep -q 'automountServiceAccountToken' SECURITY.md` passes
- [ ] 1.3 SECURITY.md, run `uv run devops docs generate --sync-readme`, and verify that `uv run devops ci docs` passes

## 2. Add one guardrail to CONTRIBUTING.md

Reads: none. Changes: `CONTRIBUTING.md`.

- [ ] 2.1 A grep for the CVE-check guardrail phrase in CONTRIBUTING.md fails before the change and passes after: `grep -q 'known CVE' CONTRIBUTING.md`, and verify that `grep -q 'known CVE' CONTRIBUTING.md` fails on the base
- [ ] 2.2 Add a sentence to section 1 (Development Philosophy and Core Invariants) stating that a pull request that pins a Helm sub-chart version MUST check that version against known CVEs before merge, and MUST name the CVE identifier in the pull request body when a CVE is found and accepted, and verify that `grep -q 'known CVE' CONTRIBUTING.md` passes
- [ ] 2.3 CONTRIBUTING.md, run `uv run devops docs generate --sync-readme`, and verify that `uv run devops ci docs` passes

## Workflow follow-up

- Pending a person: review the diff in tuicr (tuicr -r <base>..HEAD).
Loading