feat(audit): posture-audit subcommand using chant audit engine - #1
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
github-warden auditsubcommand that runs chant's full audit pipeline (fetchRepoFiles → classifyFiles → auditFiles → buildReportModel) over all repos declared in the governance config@intentius/chantand all audit-lexicon packages (aws,azure,docker,forgejo,gcp,github,gitlab,helm,k8s) from devDependencies to runtime dependencies, mirroring blacklight's dependency setimport()) to avoid Node.js stripping.tssource files at module load timeNew files
src/audit/engine.ts—auditRepos(repoUrls, token, opts)with lazy-loaded pipeline, DETECTORS + CHECKS wiring copied from blacklightsrc/audit/summary.ts—renderPostureSummary+shouldFail(mirrors--fail-on merge-worthysemantics)src/audit/engine.test.ts— 21 tests covering pipeline execution over fixture repo, aggregation, error isolation, token pass-through,shouldFail, summary rendering, andparseAuditArgsCLI
Exit 4 when findings exceed
--fail-onthreshold; 0 otherwise.Test plan
npx tsc --noEmitcleannpm test— 216 tests pass (195 existing + 21 new)node bin/github-warden.js audit --help— correct help textnode bin/github-warden.js --help— showsauditsubcommand in top-level help