Skip to content

feat(review): cite the rule each security check enforces (Increment 1) - #2

Merged
sandstream merged 1 commit into
mainfrom
feat/rule-citations
Jun 17, 2026
Merged

sandstream merged 1 commit into
mainfrom
feat/rule-citations

Conversation

@sandstream

Copy link
Copy Markdown
Owner

What

Foundation for the consolidation/citation layer discussed for kit review.

  • Adds optional rule?: RuleRef to SecurityCheckResult.
  • New local, deterministic rules catalog src/rules/catalog.ts mapping each kit security check to the rule it enforces (CWE / OWASP Top 10). No network.
  • checkSecurity() decorates findings by name; the citation flows into the kit check JSON automatically (agent-facing) and renders as a [CWE-xxx] tag in the text table (output.ts).
  • Tests for catalog well-formedness + lookup.

Why this is non-duplicative (not a SAST)

This cites kit's OWN deterministic checks (gitignore, secrets, dep-pinning, lockfiles, service exposure), which no SAST covers. kit does not compete with Semgrep/Snyk; it orchestrates them. Checks without a defensible anchor (license, the semgrep engine itself, requirements presence) carry no rule rather than a forced weak mapping.

Maintenance

The catalog is co-located with the checks (add a check, add its mapping). Framework IDs (CWE, OWASP Top 10) are low-churn and pinned by ID. No live lookup, so it does not rot.

Next (separate PRs, as plugins)

  • Wrap Semgrep ASVS rule-packs + a coverage/gap view.
  • Team rule-packs (e.g. a dev-standard plugin) pinned per-project.

Gates: tsc clean, build clean, full suite 2218 green.

🤖 Generated with Claude Code

Foundation for the consolidation/citation layer. Adds an optional `rule: RuleRef`
to SecurityCheckResult and a local, deterministic rules catalog (src/rules/
catalog.ts) mapping each kit security check to the rule it enforces (CWE / OWASP
Top 10). checkSecurity() decorates findings by name; the citation flows into the
`kit check` JSON (agent-facing) automatically and renders as a [CWE-xxx] tag in
the text table.

Deliberately narrow + non-duplicative: this cites kit's OWN deterministic checks
(gitignore, secrets, dep-pinning, lockfiles, service exposure), which no SAST
covers. It is NOT a SAST engine and does not compete with Semgrep/Snyk; kit
orchestrates those. Checks without a defensible anchor (license, semgrep-engine,
requirements presence) carry no rule rather than a forced weak mapping.

Catalog is co-located with the checks (add a check -> add its mapping); framework
IDs are low-churn and pinned, no network lookup. Next: wrap Semgrep ASVS packs +
coverage view (plugin), team rule-packs (plugin).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

✅ Docker image built successfully

  • CLI image: docker.io/sandstream/kit:test

@sandstream sandstream mentioned this pull request Jun 17, 2026
@sandstream

Copy link
Copy Markdown
Owner Author

Superseded by #6 (consolidated into the 1.4.0 release). Closing.

@sandstream
sandstream merged commit a57691e into main Jun 17, 2026
16 checks passed
@sandstream
sandstream deleted the feat/rule-citations branch June 20, 2026 05:36
sandstream pushed a commit that referenced this pull request Jun 29, 2026
Decision lifecycle for the curated shared tier (memory design gap #2).
Append-only: a change is a NEW entry that supersedes/reverses an old id;
`active` stays implicit (absent field) so pre-lifecycle entries are
byte-identical and diffs stay clean.

- shared.ts: SharedEntry/ShareInput gain status/supersedes/reverses;
  shareEntry persists them only when non-default. New pure helpers
  effectiveStatus (explicit status wins, else referenced-by-later ⇒
  superseded/reversed; reverses outranks), activeShared, formatAge.
- commands/memory.ts: `kit memory share --supersedes/--reverses/--status`
  (validates the referenced id exists); `kit memory area`/`search` badge
  superseded/reversed entries + show the chain and age; area --json carries
  the effective status.
- hook.ts: SessionStart recovery surfaces only ACTIVE durable decisions
  (recentDecisions → activeShared) with age, so a resume sees the decision
  HEAD, not a graveyard.

Surfacing shows facts (status, age, supersedes-chain); the relevance call
stays human (zero-LLM, deterministic). Tests cover supersede/reverse
resolution, reverses>supersedes precedence, explicit-status, the active
filter, age bucketing, and recovery exclusion of superseded decisions.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg
sandstream pushed a commit that referenced this pull request Jul 4, 2026
install-gate (fix #1 residuals):
- broaden the leading env-assignment strip to /^[^\s=]+=/ so a
  special-char name (env 'a:b=1' npm i evil) can no longer become argv[0]
  and hide the install entirely;
- SOURCE_ENV_RE now also catches YARN_NPM_REGISTRY_SERVER,
  NPM_CONFIG_USERCONFIG/GLOBALCONFIG, PIP_CONFIG_FILE (indirect
  config-file redirects) and scoped npm_config_@scope:registry.

publish.yml (fix #2 residual):
- require the imported .asc to contain EXACTLY ONE primary key, so an
  attacker can't append a second key to the (pushable) pubkey file and
  have git verify-tag accept a rogue-key-signed tag (gpg --verify exits 0
  on any good sig in the keyring).

2222 tests pass; lint clean; publish.yml valid YAML.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DbF4MFePXWNCd4dxBQvqH2
sandstream pushed a commit that referenced this pull request Jul 5, 2026
…found false green)

Adversarial verify found the mandate was a false green: KIT_REQUIRE_HARDWARE_IDENTITY
was enforced ONLY in `kit policy sign`, while audit-chain entries, shared-memory notes,
and revocations kept signing with the same-UID-readable file key — and `init` still minted
a file key that coexists. So a mandate operator got a green light over a key an attacker
could still read and use. Fixed so NO file-key signature escapes under the mandate.

- Universal backstop: signWithIdentity() (the file-key primitive) now FAILS CLOSED under
  KIT_REQUIRE_HARDWARE_IDENTITY — every caller that reaches it (revocations, elevation,
  any un-routed signer) refuses the file key. mandate.js is a zero-import module so
  identity.ts can guard without an import cycle.
- loadOrCreateIdentity refuses to MINT a file key under the mandate (Finding #4: no
  coexisting same-UID key to steal).
- Routed the audit-chain signer (audit.ts) and shared-memory signer (memory/shared.ts)
  through the keystore: a `command` backend now signs them via hardware, and under a
  mandate with only a file key they fall back to KEYLESS (chain still protects them)
  rather than emitting a forbidden file-key signature. Also unifies the signing kid.
- Command signer no longer receives kit's env wholesale (Finding #3): minimal allowlist
  (PATH/HOME/KIT_SIGN_ALGO), so KIT_* secrets/vault tokens aren't exposed to the signer
  subprocess — the comment now matches the code.
- Honesty (Findings #2/#6): the command backend and `kit identity keystore` no longer
  claim "hardware-rooted" (kit can't attest the operator's command fronts a secure
  element) — labeled "external key — operator-fronted" with an explicit caveat.

Regression tests: comprehensive-mandate suite (signWithIdentity / loadOrCreate /
recordRevocation fail closed; audit falls back to keyless) + signer env-isolation.
Full suite green (2261 tests).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DbF4MFePXWNCd4dxBQvqH2
sandstream added a commit that referenced this pull request Jul 9, 2026
…age --standard (#270)

Generic evidence-map engine (standard.ts) + two verified descriptors: OWASP LLM
Top 10 2025 (LLM01-10, 5 auto/3 gap/2 na) and NIST SSDF 800-218 practices 218A
profiles (PO/PS/PW/RV, 9 auto/1 gap/1 na). kit coverage --standard=asvs|llm-top10|
ssdf (default asvs unchanged), --json + --verify for all three. Control IDs
source-run-verified before mapping; search-index caveat carried into each
disclaimer; no invented clause numbers. STANDARDS.md §2 #1/#2 -> §1. 2580/2580.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant