Skip to content

feat(airgap): declarative [air_gap] config in .kit.toml - #85

Merged
sandstream merged 1 commit into
feat/air-gap-threat-data-bundlefrom
feat/air-gap-toml-config
Jun 24, 2026
Merged

sandstream merged 1 commit into
feat/air-gap-threat-data-bundlefrom
feat/air-gap-toml-config

Conversation

@sandstream

Copy link
Copy Markdown
Owner

Fourth step of the no-egress roadmap (#80). The air-gap posture was env-only; this makes it declarative + checked in so an enclave config is reproducible and versioned.

  • New [air_gap] section in the config schema (interface + zod): enabled, npm_registry/pypi_index/github_api/docker_registry, threat_data_dir/threat_data_pubkey.
  • resolveAirGap(config, env) (pure, tested) merges config + env with env taking precedence; airGapTriageEnv() emits the mirror vars to inject.
  • kit scan resolves the posture from config+env (so enabled = true in .kit.toml turns on offline mode without an env var) and reads threat-data dir/pubkey from the resolved settings.
  • runTriage injects config-declared mirror env into the triage subprocess (best-effort; real env still wins) so a .kit.toml mirror is honored without exporting KIT_*.
  • docs/AIR_GAP.md documents the declarative block.
[air_gap]
enabled = true
npm_registry = "https://npm.corp.internal"
threat_data_dir = "/opt/kit/threat-data"
threat_data_pubkey = "/etc/kit/threat-data.pub"

⚠️ Stacked on #84 (→ #83 → #73). Merge order: #73 → #83 → #84 → this.


Generated by Claude Code

Fourth step of the no-egress roadmap (#80). The air-gap posture (mirrors, offline
mode, threat-data bundle) was env-only; this lets it be checked in so an enclave
config is reproducible and versioned.

- New `[air_gap]` section in the config schema (interface + zod): `enabled`,
  `npm_registry`/`pypi_index`/`github_api`/`docker_registry`,
  `threat_data_dir`/`threat_data_pubkey`.
- `resolveAirGap(config, env)` (pure, tested) merges config + env with **env
  taking precedence**; `airGapTriageEnv()` emits the mirror vars to inject.
- `kit scan` resolves the posture from config+env (so `enabled = true` in
  `.kit.toml` turns on offline mode without an env var) and reads the threat-data
  dir/pubkey from the resolved settings.
- `runTriage` injects config-declared mirror env into the triage subprocess
  (best-effort; real env still wins), so a `.kit.toml` mirror is honored without
  exporting `KIT_*`.
- docs/AIR_GAP.md documents the declarative block.

Stacked on the threat-data-bundle branch.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg
@sandstream
sandstream merged commit fecd908 into feat/air-gap-threat-data-bundle Jun 24, 2026
2 checks passed
@sandstream
sandstream deleted the feat/air-gap-toml-config branch June 24, 2026 04:13
sandstream added a commit that referenced this pull request Jun 24, 2026
…#80) (#106)

* feat(scan): offline air-gap mode (KIT_AIRGAP=1) for `kit scan`

Second step of the no-egress roadmap (#80), building on the configurable triage
mirrors. With `KIT_AIRGAP=1`, `kit scan` runs entirely against pre-synced local
databases:

- `airGapScanners()` (pure, tested) drops cloud-only scanners (snyk, semgrep)
  and folds each remaining scanner's offline flags/env in: trivy gains
  `--offline-scan --skip-db-update`, osv-scanner gains `--offline`, grype gets
  `GRYPE_DB_AUTO_UPDATE=false`.
- `isAirGap()` reads the toggle; `cmdScan` applies the plan, injects the offline
  env into each scanner run, and prints which cloud-only scanners were skipped.
- `docs/AIR_GAP.md` §2 documents the toggle + per-scanner behavior and how to
  pre-sync each DB on a connected host.

Local-ruleset support for semgrep offline is a tracked follow-up. No behavior
change when KIT_AIRGAP is unset (transform is a no-op).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg

* feat(airgap): verified offline threat-data bundle for kit scan

Third step of the no-egress roadmap (#80). In an enclave the scanners' vuln DBs
(and the bumblebee catalog) are synced in from a connected host; stale or
tampered threat data silently degrades every verdict. This adds a trust chain
that is FULLY OFFLINE-VERIFIABLE (no Fulcio/Rekor):

- New `src/airgap/threat-data.ts`: a bundle = `manifest.json` (artifacts +
  SHA-256, each with an optional `env` to wire a scanner) + a detached
  `manifest.json.sig` (Ed25519 over the manifest). `verifyThreatData()` verifies
  the signature against a trusted key (KIT_THREAT_DATA_PUBKEY), then SHA-256s
  every artifact, then returns the env wiring. Any failure rejects the whole
  bundle (fail-closed). Manifest paths are validated against `..`/absolute escape.
- `kit scan` (air-gap): when `KIT_THREAT_DATA_DIR` is set it verifies the bundle
  before scanning and REFUSES to run on any failure, else injects the verified
  env so scanners use the local DBs. node:crypto only; deterministic.
- Tests cover signed round-trip, tamper, wrong-key, missing artifact, missing
  manifest/sig, and manifest shape/escape validation.
- docs/AIR_GAP.md documents the bundle format + build steps.

Stacked on the offline-scan-mode branch.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg

* feat(airgap): declarative [air_gap] config in .kit.toml

Fourth step of the no-egress roadmap (#80). The air-gap posture (mirrors, offline
mode, threat-data bundle) was env-only; this lets it be checked in so an enclave
config is reproducible and versioned.

- New `[air_gap]` section in the config schema (interface + zod): `enabled`,
  `npm_registry`/`pypi_index`/`github_api`/`docker_registry`,
  `threat_data_dir`/`threat_data_pubkey`.
- `resolveAirGap(config, env)` (pure, tested) merges config + env with **env
  taking precedence**; `airGapTriageEnv()` emits the mirror vars to inject.
- `kit scan` resolves the posture from config+env (so `enabled = true` in
  `.kit.toml` turns on offline mode without an env var) and reads the threat-data
  dir/pubkey from the resolved settings.
- `runTriage` injects config-declared mirror env into the triage subprocess
  (best-effort; real env still wins), so a `.kit.toml` mirror is honored without
  exporting `KIT_*`.
- docs/AIR_GAP.md documents the declarative block.

Stacked on the threat-data-bundle branch.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg

* feat(airgap): offline provenance verification — `kit verify-provenance`

Closes the headline remaining air-gap gap (#80): verify cosign/SLSA provenance
in a no-egress enclave. kit does NOT reimplement Sigstore — it orchestrates
cosign fully OFFLINE:

  cosign verify-blob --offline --trusted-root <shipped-in trusted_root.json>
    --bundle <b> --certificate-identity <id> --certificate-oidc-issuer <iss> <artifact>

`--offline` uses the bundle's inclusion proof (no Rekor); `--trusted-root` is the
operator-distributed trust anchor (no Fulcio/Rekor egress).

- `src/airgap/provenance.ts`: pure `buildCosignArgs` + `missingField`, and
  `verifyProvenance` (injectable deps) that is **fail-closed** — missing input,
  missing cosign, or any non-zero cosign exit ⇒ NOT verified. kit never prints
  "verified" unless cosign returned success.
- `kit verify-provenance <artifact> --bundle <f> [--trusted-root/--identity/--issuer]`,
  with defaults from `.kit.toml [air_gap].provenance_*` or `KIT_PROVENANCE_*`.
- `[air_gap]` config + resolver gain the three provenance fields.
- docs/AIR_GAP.md §4 rewritten from "known limitation" to the offline flow +
  the operator's trust-root-distribution responsibility (the model you OK'd).

Full suite 1467/0. Stacked on the .kit.toml-config branch.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg

* docs(airgap): document memory classification posture (system-high)

Add §5 to AIR_GAP.md explaining that the memory store inherits the
machine's classification rather than tagging rows individually. Under
system-high a per-row column is redundant, and kit cannot enforce
multi-level separation anyway — that is the OS/MLS reference monitor's
job, not a CLI managing its own SQLite. Documents the operational
posture (whole-DB level, 0o600 handling, purge = delete, capture-time
redaction, procedural spill response) and is explicit that kit does not
claim to separate classification levels internally.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg

* chore(release): 1.27.0 — reconstruct the air-gap stack onto main (#98, #80)

Rebased the full stacked-PR chain (#83 KIT_AIRGAP + #84 signed threat-bundle +
#85 [air_gap] config + #93 offline provenance) onto current main, resolving the
triage.ts conflict (kept both verdictPassed #70 and airGapMirrorEnv #85). The
stack had squash-merged out of order and landed incompletely; this makes the
no-egress enclave story actually present on main. 33 airgap+triage tests green.

Closes #98

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
sandstream added a commit that referenced this pull request Jun 24, 2026
…/air_gap config → 1.28.0 (#107)

#105: GuardDog (DataDog OSS) as the local-first replacement for the dropped cloud
Socket scanner (#103). Opt-in via KIT_GUARDDOG=1 (needs semgrep + verify is heavy);
otherwise a skip with the enable hint. Pure classifyGuardDog is fail-closed —
zero-issues-with-rule-errors (e.g. missing semgrep) is a warn (UNVERIFIED), never
a false pass; real indicators always fail. mise-resolved (pipx:guarddog), triaged
100/100 before adding.

Also fixes: [scan] + [air_gap] were valid config sections (zod, #65/#85) but missing
from KNOWN_SECTIONS, so they warned as "unknown section" on every command.

Closes #105

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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.

2 participants