Skip to content

feat(audit): posture-audit subcommand using chant audit engine - #1

Merged
lex00 merged 2 commits into
mainfrom
feat/audit-cycle
Jun 19, 2026
Merged

lex00 merged 2 commits into
mainfrom
feat/audit-cycle

Conversation

@lex00

@lex00 lex00 commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds github-warden audit subcommand that runs chant's full audit pipeline (fetchRepoFiles → classifyFiles → auditFiles → buildReportModel) over all repos declared in the governance config
  • Uses the warden App installation token, giving read access to private repos that public-only audit tools cannot reach
  • Promotes @intentius/chant and all audit-lexicon packages (aws, azure, docker, forgejo, gcp, github, gitlab, helm, k8s) from devDependencies to runtime dependencies, mirroring blacklight's dependency set
  • All chant imports in the engine are lazy (dynamic import()) to avoid Node.js stripping .ts source files at module load time

New files

  • src/audit/engine.tsauditRepos(repoUrls, token, opts) with lazy-loaded pipeline, DETECTORS + CHECKS wiring copied from blacklight
  • src/audit/summary.tsrenderPostureSummary + shouldFail (mirrors --fail-on merge-worthy semantics)
  • src/audit/engine.test.ts — 21 tests covering pipeline execution over fixture repo, aggregation, error isolation, token pass-through, shouldFail, summary rendering, and parseAuditArgs

CLI

github-warden audit --config governance.yml --token-env GH_TOKEN [--fail-on merge-worthy|any|none]

Exit 4 when findings exceed --fail-on threshold; 0 otherwise.

Test plan

  • npx tsc --noEmit clean
  • npm test — 216 tests pass (195 existing + 21 new)
  • node bin/github-warden.js audit --help — correct help text
  • node bin/github-warden.js --help — shows audit subcommand in top-level help
  • CI green on push

lex00 added 2 commits June 19, 2026 00:41
Adds `github-warden audit` — a DETECT-AND-REPORT command that runs chant's
full audit pipeline (fetchRepoFiles → classifyFiles → auditFiles →
buildReportModel) over all repos declared in the governance config.

The warden App installation token is used for fetching, giving it access to
private repos that public-only audit tools cannot reach.

- Promotes @intentius/chant and all audit-lexicon packages to runtime deps
- src/audit/engine.ts: lazy-loaded pipeline (no top-level chant .ts imports),
  DETECTORS + CHECKS mirroring blacklight, auditRepos() with concurrency
- src/audit/summary.ts: renderPostureSummary + shouldFail (--fail-on semantics)
- src/cli.ts: audit subcommand, parseAuditArgs, runAudit, printAuditUsage;
  exit 4 when findings exceed --fail-on threshold
- src/audit/engine.test.ts: 21 tests covering pipeline, shouldFail, summary
  rendering, token pass-through, and parseAuditArgs
Narrow the posture audit to GitHub posture only. warden governs GitHub,
so multi-domain IaC auditing (aws/azure/k8s/docker/gcp/helm/gitlab/forgejo)
belongs to the separate blacklight app. The engine now wires only the
github CI lexicon (path-detected .github/workflows/*, github postSynthChecks).

Drop the 8 non-github lexicon dependencies; keep @intentius/chant and
@intentius/chant-lexicon-github.

Bundle the CLI with esbuild so chant's .ts source is transpiled and inlined
at build time. This fixes ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING when
running dist/cli.js under plain Node. chant packages export .ts by default,
which only worked under vitest's transpiler. Convert the engine's dynamic
chant imports to static top-level imports so esbuild inlines them.
@lex00
lex00 force-pushed the feat/audit-cycle branch from 244ea09 to 4474285 Compare June 19, 2026 06:56
@lex00
lex00 merged commit a0699d5 into main Jun 19, 2026
2 checks passed
@lex00
lex00 deleted the feat/audit-cycle branch June 19, 2026 07:00
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