@bugb-technologies/bravos 1.3.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -10
- package/dist/ci.js +11 -3
- package/dist/cli.js +16 -6
- package/dist/doctor.js +2 -2
- package/dist/guide.js +2 -2
- package/dist/help.js +10 -14
- package/dist/install-proof-tool.js +117 -0
- package/dist/proof-tools.js +29 -0
- package/dist/report/check.js +4 -1
- package/dist/report/data.js +81 -149
- package/dist/report/markdown.js +1 -1
- package/dist/report/redact.js +16 -0
- package/dist/report/runs.js +169 -0
- package/dist/setup.js +43 -19
- package/dist/start/answers.js +5 -3
- package/dist/start/index.js +28 -14
- package/dist/versions.js +5 -4
- package/docs/GUIDE.md +2 -2
- package/hooks/lib/autopilot.mjs +155 -37
- package/hooks/lib/briefing.mjs +9 -3
- package/hooks/lib/nightly-stage.mjs +66 -0
- package/hooks/lib/nightly-tools.sh +45 -0
- package/hooks/lib/pre-pr.mjs +88 -17
- package/hooks/lib/proof-tool-pins.json +12 -0
- package/hooks/lib/replay.mjs +579 -0
- package/hooks/lib/setup.mjs +15 -6
- package/hooks/lib/snapshot.mjs +75 -9
- package/package.json +1 -1
- package/skills/bravos/SKILL.md +1 -1
- package/skills/bravos-annotate/SKILL.md +6 -5
- package/skills/bravos-annotate/scripts/slice.mjs +15 -8
- package/skills/bravos-cicd/SKILL.md +1 -1
- package/skills/bravos-env/SKILL.md +3 -3
- package/skills/bravos-prove/SKILL.md +11 -15
- package/skills/bravos-recheck/SKILL.md +3 -3
- package/skills/bravos-report/SKILL.md +1 -1
- package/skills/bravos-schedule/SKILL.md +1 -1
- package/skills/bravos-ship/SKILL.md +1 -1
- package/skills/bravos-templatize/SKILL.md +3 -3
- package/templates/workflows/bravos-nightly-claude.yml +131 -74
- package/templates/workflows/bravos-nightly-codex.yml +130 -73
- package/templates/workflows/bravos-pr-gate.yml +88 -14
package/README.md
CHANGED
|
@@ -22,12 +22,24 @@ mv ~/.local/bin/bravos ~/.local/bin/bravos-py
|
|
|
22
22
|
|
|
23
23
|
Or remove it (`pipx uninstall bravos` or `uv tool uninstall bravos`). `which -a bravos` should then show npm's copy first (its real path ends in `node_modules/@bugb-technologies/bravos/dist/cli.js`).
|
|
24
24
|
|
|
25
|
+
## Upgrading to 1.4
|
|
26
|
+
|
|
27
|
+
1.4 adds continuous proof: autopilot reviews changed code in already-annotated files, the active agent writes a test bound to the claim it affects, and Bravos replays it through cxg and records the result in GuardLink. After `npm install -g @bugb-technologies/bravos`:
|
|
28
|
+
|
|
29
|
+
1. **`bravos setup --tools -y`** installs GuardLink 2.6.0 and cxg 1.8.0, the first releases with the interfaces 1.4 uses, and refreshes cxg's pentest pipeline; `bravos doctor` shows both as ready. Browser replay also needs cxg's Python requirements and Playwright Chromium, which setup names.
|
|
30
|
+
2. **`bravos sync`** in each repository refreshes the skills and hooks and keeps the hooks you already turned on. It tells you when the workflows are older than this version; **`bravos sync --ci`** refreshes the ones you have, keeping their schedule, and adds none.
|
|
31
|
+
3. **Scheduled proving** in the nightly needs `choice: schedule` in `.guardlink/proving.md`, with a `— confirmed by <name>, <date>` line, merged to the default branch (bravos-prove records it). Until then the job summary says why scheduled proof is off.
|
|
32
|
+
4. **Test kits written before 1.4** are reported as needing review and `bind` and are not run until bound (bravos-templatize does it).
|
|
33
|
+
5. **Automatic local testing** starts once a `target: http://localhost:<port>/` line for your app is merged to the default branch, and needs an `origin` remote; without one, tests run only once each, with your typed authorization.
|
|
34
|
+
6. Teammates **without a licence** now see that autopilot and the pre-PR gate are installed but locked for them, with the trial command, instead of "on".
|
|
35
|
+
7. **1.4.1:** `bravos setup` fetches analyzer 0.6.2 (Team plan), whose reachability matches the code graph and whose own GuardLink pin is 2.6.0. `bravos sast run` now starts only with the GuardLink step 1 installs on PATH, so SAST and the rest of Bravos read the threat model with the same GuardLink.
|
|
36
|
+
|
|
25
37
|
## Commands
|
|
26
38
|
|
|
27
39
|
- `bravos start [dir]`: the guided first run described above. `--again`, `--yes`, `--preset annotate|pr|everything`.
|
|
28
40
|
- `bravos init`: write skills, MCP wiring and the session-start hook into the current repo. `--agent claude,codex` picks the harnesses instead of detecting them. `--pre-pr-hook` also registers the PreToolUse gate on `gh pr create` / `gh pr ready` and lists it under `pre_pr` in `.guardlink/config.json`, so guardlink's agent block names it after `guardlink sync`; `--ci` also writes the GitHub Actions workflows (`--workflows pr-gate,nightly-claude,nightly-codex` picks which, and `nightly-copilot` adds the GitHub Copilot nightly, which is never written unless named; `--schedule weekday|daily|weekly` sets how often the nightly runs; either implies `--ci`); `--scope` writes the loopback-only cxg scope starter to `.guardlink/scope.yaml` when no scope file exists (never overwritten). A repo with a `.cursor/` folder also gets `.cursor/rules/bravos.mdc`, a pointer to the skills.
|
|
29
41
|
- `bravos sync`: refresh the installed skills and wiring to match this version of bravos; it also adds the cxg and codegraph MCP servers once they are installed (bravos's own committed MCP config carries guardlink only). The codegraph server is registered by its full path with the graph store as `BRAVOS_CODEGRAPH_DIR`, so the MCP tools read the graphs `bravos graph build` writes; after a `bravos setup` that stages a new bundle, `sync` refreshes that one entry, and keeps every other existing entry as it is.
|
|
30
|
-
- `bravos setup`: puts the binaries bravos drives on this machine. The analyzer (`bravos-cli`, SAST) and the code graph (`codegraph-build`, `codegraph-mcp`) are signed bundles fetched through the account portal on the Team plan — the portal verifies the licence, the CLI verifies each file's Ed25519 signature before it unpacks, and nothing under `$BRAVOS_HOME` changes until every check has passed; `--tools -y`
|
|
42
|
+
- `bravos setup`: puts the binaries bravos drives on this machine. The analyzer (`bravos-cli`, SAST) and the code graph (`codegraph-build`, `codegraph-mcp`) are signed bundles fetched through the account portal on the Team plan — the portal verifies the licence, the CLI verifies each file's Ed25519 signature before it unpacks, and nothing under `$BRAVOS_HOME` changes until every check has passed; `--tools -y` keeps compatible tools and installs missing or incompatible ones. Until the corresponding public releases are available, it builds GuardLink and CXG from the pinned upstream revisions in `hooks/lib/proof-tool-pins.json`. `--check` reports, `--dry-run` says what would happen.
|
|
31
43
|
- `bravos graph`: `graph build [DIR]` indexes a repository (`--scip no-exec` by default, so no repository code runs); `graph <question> [args] --json` asks it — the same answers as the `codegraph_` MCP tools, through a one-call MCP session on stdio; `graph --json` lists every question this machine's binary answers.
|
|
32
44
|
- `bravos sast run`: analyzes the repository with the staged analyzer into `.bravos/sast/<run>/` (not committed), which `bravos sast status` and `candidates` read. Takes the same `--agent`, `--pre-pr-hook`, `--ci` and `--scope` options as `init`, and never runs `guardlink init`.
|
|
33
45
|
- `bravos doctor`: check that the installed pieces and the underlying CLIs are present and healthy.
|
|
@@ -131,17 +143,12 @@ bravos-context no longer pastes thirty questions into chat. By default it assume
|
|
|
131
143
|
|
|
132
144
|
## Autopilot
|
|
133
145
|
|
|
134
|
-
`bravos init --autopilot` (or `sync --autopilot`) is for teams who would rather not ask. It registers an end-of-turn check, a Stop hook in Claude Code and Codex, plus the pre-PR gate.
|
|
135
|
-
- a file with no GuardLink annotation;
|
|
136
|
-
- a confirmed or stale claim on a changed file;
|
|
137
|
-
- open exposures on changed files.
|
|
138
|
-
|
|
139
|
-
It runs only guardlink's two fast calls (`unannotated` and `ci`, a few seconds even on a large repo); lint and diff stay in the pre-PR gate.
|
|
140
|
-
|
|
141
|
-
Each finding is raised once per session, and a missing tool or a timeout lets the turn finish.
|
|
146
|
+
`bravos init --autopilot` (or `sync --autopilot`) is for teams who would rather not ask. It registers an end-of-turn check, a Stop hook in Claude Code and Codex, plus the pre-PR gate. The agent reviews changes inside existing files as well as newly added code. It checks affected exposures and declared controls against GuardLink’s hypothesis ledger. A changed claim with prior evidence can need a retest even while its control remains documented.
|
|
142
147
|
|
|
143
148
|
How new exposures get proven is the team's call, not a fixed rule. The first time proving comes up, the agent asks once: prove automatically on your loopback target, ask each time, on a schedule, or not now; and whether cxg may generate probes through a model API. It records the person's words in `.guardlink/proving.md`, which every briefing shows and which a PR that changes it must mention. Non-loopback targets still need a reviewed scope and typed authorization each time. `BRAVOS_AUTOPILOT=off` pauses the check.
|
|
144
149
|
|
|
150
|
+
For a web claim, the coding agent authors one JavaScript probe with GuardLink’s translate method. It runs `bravos hook replay bind <kit.js>` to bind the test to the current exposure. At a verified fresh launch from the local worktree, `bravos hook replay build <loopback-url>` prints a build witness. Pass that JSON in `BRAVOS_REPLAY_BUILD` to the replay for that same launch. The normal automatic path is `bravos hook replay run <kit.js>`; a one-off run under an ask policy uses `run-once` with the exact target and current authorization. The helper executes the selected test through plain `cxg scan` with authoring disabled. A qualified result on the bound local build is recorded in GuardLink; remote or unidentified builds produce observations only. Raw run evidence stays outside Git. `bravos doctor` and `bravos setup --check` check the GuardLink and CXG command interfaces needed for this path.
|
|
151
|
+
|
|
145
152
|
## User-level install and one copy of each skill
|
|
146
153
|
|
|
147
154
|
`bravos init --global` (and `bravos sync --global` after an upgrade) installs bravos for your user rather than a repo: the skills once in `~/.claude/skills`, linked from `~/.agents/skills` for Codex and other shared-root agents, the session-start hook in `~/.bravos/hooks` registered in `~/.claude/settings.json` and `~/.codex/hooks.json`, and guardlink MCP in `~/.codex/config.toml`. The user hook is quiet in any repo that has its own bravos hook or no `.guardlink/`, so it briefs only repos with a threat model that bravos is not installed in. It is personal: teammates get bravos through `bravos init` in the repo. Because Claude Code prefers personal skills over a repo's, `bravos sync` in any repo also brings an existing user-level install to the same version, so an older personal copy never stands in for the repo's; it never creates one, and `BRAVOS_SYNC_GLOBAL=off` keeps the two separate.
|
|
@@ -188,7 +195,7 @@ With `--pre-pr-hook`, every `gh pr create` and `gh pr ready` an agent runs first
|
|
|
188
195
|
## Workflows (`bravos init --ci`)
|
|
189
196
|
|
|
190
197
|
- `bravos-pr-gate.yml`: the bravos-ship gate on every pull request, with the same rulings as the pre-PR hook (lint errors, undisclosed new exposure by id, a confirmed claim on a changed file without a `@ticket`; a gate input that fails is "unknown" and fails the job). guardlink and jq only, no model, no secret. Uploads guardlink's SARIF to code scanning (skipped for fork PRs).
|
|
191
|
-
- `bravos-nightly-claude.yml` / `bravos-nightly-codex.yml`: a coding agent covers the next slice of unannotated files, the lint gate checks it, and the job opens one small PR. Keep the one for your harness.
|
|
198
|
+
- `bravos-nightly-claude.yml` / `bravos-nightly-codex.yml`: a coding agent covers the next slice of unannotated files, the lint gate checks it, and the job opens one small PR. Keep the one for your harness. When the team has enabled scheduled proving, the job also replays eligible, bound JS kits on its reviewed target. Set BRAVOS_SCAN_TARGET and configure any test identity secrets that the kits require.
|
|
192
199
|
- `bravos-nightly-copilot.yml` + `copilot-setup-steps.yml` (only with `--workflows nightly-copilot`): for teams on GitHub Copilot. The scheduled job opens one issue and assigns it to Copilot's cloud agent, which annotates the next slice on the team's Copilot plan and opens the pull request; the PR gate checks it. Needs the repo secret `COPILOT_ASSIGN_TOKEN` (a Copilot user's personal access token: GitHub assigns Copilot only with a user's token) and `BRAVOS_LICENCE` as an Agents secret.
|
|
193
200
|
|
|
194
201
|
## Install as a plugin (after 1.0)
|
package/dist/ci.js
CHANGED
|
@@ -23,7 +23,7 @@ export function withCadence(content, cadence) {
|
|
|
23
23
|
return content.replace(/^(\s*- cron: )'[^']*'/m, `$1'${CRON[cadence]}'`);
|
|
24
24
|
}
|
|
25
25
|
// @comment -- "Copies each bundled templates/workflows/*.yml into .github/workflows/; an existing workflow is replaced only if bravos wrote it (lock hash or marker) unless --force, and the lock records each file written."
|
|
26
|
-
// @comment -- "Only the workflows named in `only`
|
|
26
|
+
// @comment -- "Only the workflows named in `only` are written; without it, init writes the defaults and a sync (installedOnly) refreshes only the bravos workflows already installed. `cadence` rewrites the nightly's cron line before the file is hashed and locked; without it a refresh keeps the cron the installed nightly already has."
|
|
27
27
|
export function writeWorkflows(root, opts = {}) {
|
|
28
28
|
const src = join(opts.templates ?? templatesDir(), 'workflows');
|
|
29
29
|
const report = { written: [], updated: [], unchanged: [], skipped: [] };
|
|
@@ -32,7 +32,12 @@ export function writeWorkflows(root, opts = {}) {
|
|
|
32
32
|
const lock = readLock(root);
|
|
33
33
|
const record = {};
|
|
34
34
|
const installed = (w) => WORKFLOW_FILES[w].some((f) => lock.files[`.github/workflows/${f}`] !== undefined);
|
|
35
|
-
|
|
35
|
+
// A sync refreshes the bravos workflows the repo already has; it never adds one nobody chose (a Codex nightly
|
|
36
|
+
// with no OPENAI_API_KEY fails every night). With none installed yet, --ci writes the defaults, as init does.
|
|
37
|
+
const anyInstalled = WORKFLOW_NAMES.some(installed);
|
|
38
|
+
const wanted = opts.only ?? (opts.installedOnly && anyInstalled
|
|
39
|
+
? WORKFLOW_NAMES.filter(installed)
|
|
40
|
+
: WORKFLOW_NAMES.filter((w) => !OPT_IN_WORKFLOWS.includes(w) || installed(w)));
|
|
36
41
|
const files = new Set(wanted.flatMap((w) => WORKFLOW_FILES[w]));
|
|
37
42
|
for (const name of readdirSync(src).filter((n) => n.endsWith('.yml')).sort()) {
|
|
38
43
|
if (!files.has(name))
|
|
@@ -40,7 +45,10 @@ export function writeWorkflows(root, opts = {}) {
|
|
|
40
45
|
const path = `.github/workflows/${name}`;
|
|
41
46
|
const abs = join(root, path);
|
|
42
47
|
const raw = readFileSync(join(src, name), 'utf8');
|
|
43
|
-
|
|
48
|
+
// A refresh keeps the schedule the repo already runs unless --schedule names a new one.
|
|
49
|
+
const existingCron = !opts.cadence && name.startsWith('bravos-nightly-') && existsSync(abs) ? /^\s*- cron: '([^']*)'/m.exec(readFileSync(abs, 'utf8'))?.[1] : undefined;
|
|
50
|
+
const content = Buffer.from(opts.cadence && name.startsWith('bravos-nightly-') ? withCadence(raw, opts.cadence)
|
|
51
|
+
: existingCron ? raw.replace(/^(\s*- cron: )'[^']*'/m, `$1'${existingCron}'`) : raw);
|
|
44
52
|
const hash = sha256(content);
|
|
45
53
|
let status = 'written';
|
|
46
54
|
if (existsSync(abs)) {
|
package/dist/cli.js
CHANGED
|
@@ -3,6 +3,7 @@ import { execFileSync } from 'node:child_process';
|
|
|
3
3
|
import { existsSync, mkdirSync, readFileSync, realpathSync, rmSync } from 'node:fs';
|
|
4
4
|
import { resolve, join } from 'node:path';
|
|
5
5
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
6
|
+
import { checkProofTool, formatProofTool } from './proof-tools.js';
|
|
6
7
|
import { DOCTOR_HELP, INIT_HELP, PROGRAM_HELP, SYNC_HELP } from './help.js';
|
|
7
8
|
import { Command, CommanderError, InvalidArgumentError, Option } from 'commander';
|
|
8
9
|
import { CADENCES, CRON, WORKFLOW_NAMES, writeWorkflows } from './ci.js';
|
|
@@ -44,7 +45,7 @@ function parseWorkflows(value) {
|
|
|
44
45
|
}
|
|
45
46
|
return out;
|
|
46
47
|
}
|
|
47
|
-
const GUARDLINK_HINT = 'guardlink: not found on PATH —
|
|
48
|
+
const GUARDLINK_HINT = 'guardlink: not found on PATH — run bravos setup --tools -y';
|
|
48
49
|
// Antigravity reads the shared .agents/ root; opencode and omp get their own files on top of a skills root.
|
|
49
50
|
const AGENT_MAP = { claude: 'claude', codex: 'agents', agy: 'agents', opencode: 'opencode', omp: 'omp' };
|
|
50
51
|
// @comment -- "Parses --agent <claude,codex>; codex maps to the .agents harness and anything else is a usage error."
|
|
@@ -251,7 +252,7 @@ function pipeline(root, io, opts, withGuardlink, lines) {
|
|
|
251
252
|
}
|
|
252
253
|
let workflowWritten = [];
|
|
253
254
|
if (opts.ci || opts.workflows || opts.schedule) {
|
|
254
|
-
const wf = writeWorkflows(root, { force: opts.force, dryRun, only: opts.workflows, cadence: opts.schedule });
|
|
255
|
+
const wf = writeWorkflows(root, { force: opts.force, dryRun, only: opts.workflows, cadence: opts.schedule, installedOnly: !withGuardlink });
|
|
255
256
|
if (opts.schedule)
|
|
256
257
|
lines.push(`Nightly schedule: ${opts.schedule} (cron ${CRON[opts.schedule]}, UTC)`);
|
|
257
258
|
lines.push(`Workflows: ${wf.written.length} written, ${wf.updated.length} updated, ${wf.unchanged.length} unchanged, ${wf.skipped.length} skipped`);
|
|
@@ -259,6 +260,12 @@ function pipeline(root, io, opts, withGuardlink, lines) {
|
|
|
259
260
|
lines.push(` skipped ${s.path} — ${s.reason}`);
|
|
260
261
|
workflowWritten = [...wf.written, ...wf.updated];
|
|
261
262
|
}
|
|
263
|
+
else if (!withGuardlink) {
|
|
264
|
+
// A plain sync leaves workflows alone, but says when the installed ones are older than this bravos.
|
|
265
|
+
const stale = writeWorkflows(root, { dryRun: true, installedOnly: true }).updated;
|
|
266
|
+
if (stale.length)
|
|
267
|
+
lines.push(`Workflows: ${stale.length} bravos workflow(s) are older than this bravos (${stale.join(', ')}); run bravos sync --ci to refresh them.`);
|
|
268
|
+
}
|
|
262
269
|
const cursorWritten = cursor.status === 'written' || cursor.status === 'updated' ? [cursor.path] : [];
|
|
263
270
|
const ompWritten = omp.status === 'written' || omp.status === 'updated' ? [omp.path] : [];
|
|
264
271
|
const ocWritten = oc.status === 'done' ? [...oc.written, ...(oc.mcpAdded.length ? [OPENCODE_CONFIG] : [])] : [];
|
|
@@ -539,17 +546,18 @@ export function buildProgram(io, result) {
|
|
|
539
546
|
}
|
|
540
547
|
lines.push(JSON.stringify(opts.json ? a : a.result, null, 2));
|
|
541
548
|
}));
|
|
542
|
-
// @comment -- "bravos hook <name> runs one of the
|
|
549
|
+
// @comment -- "bravos hook <name> runs one of the scripts this install ships (session-start, pre-pr, autopilot, replay) with the given arguments and stdin passed through; plugin skills use it where the repository has no .bravos/hooks/ copy. Only allowlisted entry points run; the script's own exit code is returned."
|
|
543
550
|
program
|
|
544
551
|
.command('hook <name> [args...]')
|
|
545
|
-
.description('Run one of bravos\'s hook scripts from this install (session-start, pre-pr, autopilot), e.g. `bravos hook session-start --briefing` or `bravos hook pre-pr --check`: what plugin installs use where the repository has no .bravos/hooks/.')
|
|
552
|
+
.description('Run one of bravos\'s hook scripts from this install (session-start, pre-pr, autopilot, replay), e.g. `bravos hook session-start --briefing` or `bravos hook pre-pr --check`: what plugin installs use where the repository has no .bravos/hooks/.')
|
|
546
553
|
.allowUnknownOption()
|
|
547
554
|
.helpOption(false)
|
|
548
555
|
.action((name, args) => guarded((lines) => {
|
|
549
|
-
const known = ['session-start', 'pre-pr', 'autopilot'];
|
|
556
|
+
const known = ['session-start', 'pre-pr', 'autopilot', 'replay'];
|
|
550
557
|
if (!known.includes(name))
|
|
551
558
|
throw new BravosError(`unknown hook '${name}'; use ${known.join(', ')}`);
|
|
552
|
-
const
|
|
559
|
+
const script = name === 'replay' ? 'lib/replay.mjs' : `${name}.mjs`;
|
|
560
|
+
const r = spawnSync(process.execPath, [pathJoin(hooksDir(), script), ...args], { env: io.env, encoding: 'utf8', stdio: ['inherit', 'pipe', 'pipe'], maxBuffer: 16 * 1024 * 1024 });
|
|
553
561
|
if (r.stdout)
|
|
554
562
|
lines.push(r.stdout.replace(/\n$/, ''));
|
|
555
563
|
if (r.stderr)
|
|
@@ -625,6 +633,8 @@ export function buildProgram(io, result) {
|
|
|
625
633
|
const L = await licenceLib();
|
|
626
634
|
const v = L.status(io.env);
|
|
627
635
|
lines.push(formatDoctor(withLicence(runDoctor(dirArg(dir), io.env), L.planLine(v), v.licensed)));
|
|
636
|
+
for (const name of ['guardlink', 'cxg'])
|
|
637
|
+
lines.push(formatProofTool(checkProofTool(name, io.env)));
|
|
628
638
|
}));
|
|
629
639
|
program
|
|
630
640
|
.command('uninstall [dir]')
|
package/dist/doctor.js
CHANGED
|
@@ -8,8 +8,8 @@ import { AUTOPILOT_COMMAND, HOOK_COMMANDS, LEGACY_HOOK_COMMAND, PRE_PR_COMMAND,
|
|
|
8
8
|
import { skillsRoot } from './skills.js';
|
|
9
9
|
import { resolveTheme } from './palette.js';
|
|
10
10
|
const TOOLS = [
|
|
11
|
-
{ name: 'guardlink', hint: '
|
|
12
|
-
{ name: 'cxg', hint: '
|
|
11
|
+
{ name: 'guardlink', hint: 'bravos setup --tools -y installs a compatible GuardLink' },
|
|
12
|
+
{ name: 'cxg', hint: 'bravos setup --tools -y installs a compatible CXG' },
|
|
13
13
|
{ name: 'codegraph-mcp', hint: 'bravos setup --codegraph fetches codegraph-build and codegraph-mcp (Team plan); then bravos graph build .' },
|
|
14
14
|
{ name: 'bravos-cli', hint: 'the SAST analyzer: bravos setup --analyzer fetches it (Team plan; bravos account activate starts a trial)' },
|
|
15
15
|
];
|
package/dist/guide.js
CHANGED
|
@@ -51,7 +51,7 @@ export const GUIDE_TOPICS = [
|
|
|
51
51
|
{
|
|
52
52
|
name: 'Hands-off: autopilot',
|
|
53
53
|
body: [
|
|
54
|
-
'bravos init --autopilot (or sync --autopilot) makes upkeep happen without anyone asking. At
|
|
54
|
+
'bravos init --autopilot (or sync --autopilot) makes upkeep happen without anyone asking. At turn end the agent reviews changed code, including edits inside annotated files. It follows the recorded proving preference for affected claims. The pre-PR gate runs on every gh pr create.',
|
|
55
55
|
'Proving follows your choice, not a fixed rule: the first time it comes up the agent asks you once — prove automatically on your loopback target, ask each time, on a schedule, or not now — and records your words in .guardlink/proving.md. Say "ask me first" or "stop auto-proving" at any time to change it. Non-loopback targets still need a reviewed scope and your typed authorization every time.',
|
|
56
56
|
],
|
|
57
57
|
},
|
|
@@ -101,7 +101,7 @@ export const GUIDE_TOPICS = [
|
|
|
101
101
|
name: 'CI owner',
|
|
102
102
|
skills: ['bravos-cicd', 'bravos-schedule'],
|
|
103
103
|
body: [
|
|
104
|
-
'bravos init --ci writes the PR gate and nightly workflows. bravos-cicd audits existing workflows: broken guardlink calls, script injection from pull-request text, missing SARIF upload. The
|
|
104
|
+
'bravos init --ci writes the PR gate and nightly workflows. bravos-cicd audits existing workflows: broken guardlink calls, script injection from pull-request text, missing SARIF upload. The Claude and Codex nightlies can replay committed, bound kits when scheduled testing is authorized. The Copilot job assigns an annotation task.',
|
|
105
105
|
],
|
|
106
106
|
},
|
|
107
107
|
],
|
package/dist/help.js
CHANGED
|
@@ -138,8 +138,8 @@ Session start
|
|
|
138
138
|
Autopilot (hands-off): bravos init --autopilot
|
|
139
139
|
For teams who would rather not ask. At the end of every turn a check (a Stop hook in
|
|
140
140
|
Claude Code and Codex, a few seconds) sends the agent back once when the turn's changes
|
|
141
|
-
|
|
142
|
-
|
|
141
|
+
add or change source behavior or affect a claim due for testing. The check names
|
|
142
|
+
the affected files and skill; the pre-PR gate runs on every
|
|
143
143
|
gh pr create / gh pr ready. Each finding is raised once per session; a missing tool or a
|
|
144
144
|
timeout lets the turn finish; BRAVOS_AUTOPILOT=off pauses it.
|
|
145
145
|
Proving is the team's choice, not a rule: the first time it comes up the agent asks once
|
|
@@ -243,9 +243,8 @@ Flags in depth
|
|
|
243
243
|
them up to date without the flag.
|
|
244
244
|
--autopilot
|
|
245
245
|
Upkeep without being asked. Registers an end-of-turn check (a Stop hook, Claude Code
|
|
246
|
-
and Codex)
|
|
247
|
-
|
|
248
|
-
on changed files; and the pre-PR gate (implies --pre-pr-hook), which also lints. New
|
|
246
|
+
and Codex) to review changed code in annotated and new files, plus affected claims due
|
|
247
|
+
for testing. Also registers the pre-PR gate (implies --pre-pr-hook), which also lints. New
|
|
249
248
|
exposures are handled as you choose: the first time proving comes up the agent asks
|
|
250
249
|
you once (prove automatically on your loopback target, ask each time, on a schedule,
|
|
251
250
|
or not now; and whether cxg may generate probes through a model API) and records your
|
|
@@ -282,13 +281,10 @@ Flags in depth
|
|
|
282
281
|
bravos-nightly-claude.yml Weekdays 03:17 UTC: Claude Code annotates the next slice
|
|
283
282
|
bravos-nightly-codex.yml (or Codex does), the lint gate checks it, one PR opens.
|
|
284
283
|
Keep the one for your harness and delete the other.
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
scope's host_allowlist; optional vars.BRAVOS_SCAN_AUTH +
|
|
290
|
-
secrets.BRAVOS_AUTH_STATE import a login. Otherwise it
|
|
291
|
-
skips with a notice.
|
|
284
|
+
Scheduled proof replays committed, bound JS kits under the
|
|
285
|
+
current scheduled choice and reviewed scope. Configure
|
|
286
|
+
BRAVOS_SCAN_TARGET, BRAVOS_APP_START for a local build,
|
|
287
|
+
and BRAVOS_SCAN_AUTH plus private session state for roles.
|
|
292
288
|
Needs repository secret CLAUDE_CODE_OAUTH_TOKEN (Claude Code on your Claude plan; run
|
|
293
289
|
'claude setup-token' once) or OPENAI_API_KEY (Codex), and Settings > Actions >
|
|
294
290
|
"Allow GitHub Actions to create and approve pull requests". Workflows you wrote or
|
|
@@ -347,8 +343,8 @@ Examples
|
|
|
347
343
|
export const DOCTOR_HELP = `
|
|
348
344
|
What doctor reports (read-only; writes nothing, starts nothing)
|
|
349
345
|
Tools on PATH, with an install hint for each one missing:
|
|
350
|
-
guardlink
|
|
351
|
-
cxg
|
|
346
|
+
guardlink bravos setup --tools -y
|
|
347
|
+
cxg bravos setup --tools -y
|
|
352
348
|
codegraph-mcp bravos setup --codegraph (Team plan)
|
|
353
349
|
bravos-cli bravos setup --analyzer (Team plan); the licence is BRAVOS_LICENCE or
|
|
354
350
|
licence.jwt in $BRAVOS_HOME, ~/.bravos or ~/.bugb
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import { mkdtempSync, rmSync } from 'node:fs';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
4
|
+
import { basename, delimiter, isAbsolute, join, resolve } from 'node:path';
|
|
5
|
+
import { whichBin } from './guardlink.js';
|
|
6
|
+
import { checkProofTool } from './proof-tools.js';
|
|
7
|
+
import { BravosError } from './types.js';
|
|
8
|
+
import { PROOF_TOOL_PINS } from './versions.js';
|
|
9
|
+
// @comment -- "What setup would run for one tool, in words: the released npm or crates.io version, or a source build when the pin names a revision. Pins default to the shipped file; tests pass their own to cover both paths."
|
|
10
|
+
export function proofToolAction(name, pins = PROOF_TOOL_PINS) {
|
|
11
|
+
const { repository, revision, version } = pins[name];
|
|
12
|
+
if (name === 'guardlink')
|
|
13
|
+
return revision
|
|
14
|
+
? `build GuardLink from ${repository} at ${revision} with git and npm, then install its packed CLI globally`
|
|
15
|
+
: `npm install --global guardlink@${version}`;
|
|
16
|
+
return revision
|
|
17
|
+
? `cargo install --locked --force --git ${repository} --rev ${revision} cert-x-gen and update its pentest pipeline`
|
|
18
|
+
: `cargo install --locked --force --version =${version} cert-x-gen and update its pentest pipeline`;
|
|
19
|
+
}
|
|
20
|
+
const prerequisites = {
|
|
21
|
+
git: 'install Git and make git available on PATH',
|
|
22
|
+
npm: 'install Node.js 20 or newer with npm and make npm available on PATH',
|
|
23
|
+
tar: 'install tar for the pinned GuardLink grammar build',
|
|
24
|
+
cargo: 'install the Rust toolchain (cargo and rustc) and a native linker',
|
|
25
|
+
};
|
|
26
|
+
// @comment -- "Use fixed package-manager argv in a private scratch directory, outside the customer repository. Ignore inherited Git working-tree overrides and relative PATH entries, so the checkout cannot supply a .cargo/config.toml, .npmrc, Git config or executable for the install."
|
|
27
|
+
export function installProofTool(name, env, echo, pins = PROOF_TOOL_PINS) {
|
|
28
|
+
const pin = pins[name];
|
|
29
|
+
const installEnv = {
|
|
30
|
+
...env,
|
|
31
|
+
PATH: (env.PATH ?? '').split(delimiter).filter(isAbsolute).join(delimiter),
|
|
32
|
+
GIT_TERMINAL_PROMPT: '0',
|
|
33
|
+
};
|
|
34
|
+
for (const key of ['GIT_DIR', 'GIT_WORK_TREE', 'GIT_INDEX_FILE', 'GIT_OBJECT_DIRECTORY', 'GIT_COMMON_DIR', 'INIT_CWD', 'npm_config_local_prefix'])
|
|
35
|
+
delete installEnv[key];
|
|
36
|
+
for (const key of ['CARGO_INSTALL_ROOT', 'CARGO_HOME', 'CARGO_TARGET_DIR', 'NPM_CONFIG_PREFIX', 'npm_config_prefix']) {
|
|
37
|
+
if (installEnv[key] && !isAbsolute(installEnv[key]))
|
|
38
|
+
installEnv[key] = resolve(installEnv[key]);
|
|
39
|
+
}
|
|
40
|
+
const needed = name === 'guardlink' ? (pin.revision ? ['git', 'npm', 'tar'] : ['npm']) : ['cargo'];
|
|
41
|
+
const executables = new Map();
|
|
42
|
+
for (const command of needed) {
|
|
43
|
+
const path = whichBin(command, installEnv);
|
|
44
|
+
if (!path)
|
|
45
|
+
throw new BravosError(`${name} requires ${command}: ${prerequisites[command]}. Then run bravos setup --tools -y again.`);
|
|
46
|
+
executables.set(command, path);
|
|
47
|
+
}
|
|
48
|
+
const work = mkdtempSync(join(tmpdir(), 'bravos-tools-'));
|
|
49
|
+
function invoke(command, args, cwd, step) {
|
|
50
|
+
const result = spawnSync(executables.get(command) ?? command, args, {
|
|
51
|
+
cwd, env: installEnv, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: 32 * 1024 * 1024, timeout: 30 * 60 * 1000,
|
|
52
|
+
});
|
|
53
|
+
if (result.error || result.status !== 0) {
|
|
54
|
+
// npm/git/cargo diagnostics can include registry credentials. Name the operation so it can be retried directly.
|
|
55
|
+
const detail = result.error ? result.error.code ?? 'spawn failed' : `exit ${result.status ?? 'signal'}`;
|
|
56
|
+
const hints = {
|
|
57
|
+
cargo: 'Check cargo and rustc, the native linker, network access and the Cargo install root.',
|
|
58
|
+
git: 'Check Git and network access to the public upstream repository.',
|
|
59
|
+
npm: 'Check Node and npm, registry access, tar for grammar assets and permission to the global prefix.',
|
|
60
|
+
cxg: 'Check cxg pentest status for an existing source-managed pipeline.',
|
|
61
|
+
};
|
|
62
|
+
throw new BravosError(name + ' setup failed during ' + step + ' (' + detail + '). ' + hints[command] + ' Retry with bravos setup --tools -y.');
|
|
63
|
+
}
|
|
64
|
+
return result.stdout.trim();
|
|
65
|
+
}
|
|
66
|
+
try {
|
|
67
|
+
echo(`${name}: ${proofToolAction(name)}`);
|
|
68
|
+
if (name === 'guardlink') {
|
|
69
|
+
if (pin.revision) {
|
|
70
|
+
const src = join(work, 'guardlink');
|
|
71
|
+
invoke('git', ['init', '--quiet', src], work, 'initializing the temporary Git checkout');
|
|
72
|
+
invoke('git', ['fetch', '--quiet', '--depth=1', pin.repository, pin.revision], src, 'fetching the pinned GuardLink commit');
|
|
73
|
+
invoke('git', ['checkout', '--quiet', '--detach', 'FETCH_HEAD'], src, 'checking out GuardLink');
|
|
74
|
+
if (invoke('git', ['rev-parse', 'HEAD'], src, 'verifying the source revision') !== pin.revision) {
|
|
75
|
+
throw new BravosError('GuardLink fetched a different Git revision; installation stopped.');
|
|
76
|
+
}
|
|
77
|
+
invoke('npm', ['ci', '--include=dev', '--no-audit', '--no-fund'], src, 'installing locked GuardLink build dependencies');
|
|
78
|
+
invoke('npm', ['run', 'build'], src, 'building the CLI and grammar assets');
|
|
79
|
+
const result = invoke('npm', ['pack', '--ignore-scripts', '--json', '--pack-destination', work], src, 'packing GuardLink');
|
|
80
|
+
let packed;
|
|
81
|
+
try {
|
|
82
|
+
packed = JSON.parse(result);
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
throw new BravosError('npm pack returned an unreadable tarball manifest.');
|
|
86
|
+
}
|
|
87
|
+
const file = packed?.[0]?.filename;
|
|
88
|
+
if (typeof file !== 'string' || file !== basename(file) || !file.endsWith('.tgz') || packed.length !== 1) {
|
|
89
|
+
throw new BravosError('npm pack did not return one GuardLink tarball.');
|
|
90
|
+
}
|
|
91
|
+
invoke('npm', ['install', '--global', join(work, file)], work, 'installing the packed CLI in the npm global prefix');
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
invoke('npm', ['install', '--global', `guardlink@${pin.version}`], work, 'installing the pinned GuardLink npm release');
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
const args = pin.revision ? ['--git', pin.repository, '--rev', pin.revision] : ['--version', '=' + pin.version];
|
|
99
|
+
invoke('cargo', ['install', '--locked', '--force', ...args, 'cert-x-gen'], work, 'building and installing the pinned CXG binary');
|
|
100
|
+
}
|
|
101
|
+
// Check the user's PATH again after installation, before invoking any post-install command on the selected binary.
|
|
102
|
+
const found = whichBin(name, installEnv);
|
|
103
|
+
const status = checkProofTool(name, installEnv);
|
|
104
|
+
if (!found || status.status !== 'ready') {
|
|
105
|
+
const destination = name === 'guardlink' ? 'the bin directory under npm prefix --global' : 'the bin directory under your Cargo install root (normally ~/.cargo/bin)';
|
|
106
|
+
throw new BravosError(`${name} was installed but ${found ?? 'no executable'} is selected on PATH (${status.status}). Put ${destination} first, check which -a ${name}, then run bravos setup --check.`);
|
|
107
|
+
}
|
|
108
|
+
if (name === 'cxg') {
|
|
109
|
+
executables.set('cxg', found);
|
|
110
|
+
invoke('cxg', ['--disable-update-check', 'pentest', 'update'], work, 'synchronizing the embedded pentest pipeline');
|
|
111
|
+
}
|
|
112
|
+
return found;
|
|
113
|
+
}
|
|
114
|
+
finally {
|
|
115
|
+
rmSync(work, { recursive: true, force: true });
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { whichBin } from './guardlink.js';
|
|
4
|
+
// @comment -- "Checks the CLI interface in the executable that will run. Release and development binaries can have identical version strings. Only fixed help arguments are passed, with no shell, bounded output and a deadline (10 s: a cold start on a busy machine can take several); no URL, credentials or template is supplied."
|
|
5
|
+
export function checkProofTool(name, env, timeoutMs = 10000) {
|
|
6
|
+
const guardlink = name === 'guardlink';
|
|
7
|
+
const capability = guardlink ? 'in-session probe translation' : 'plain scan of supplied JS probes with zero model calls';
|
|
8
|
+
const binary = whichBin(name, env);
|
|
9
|
+
if (!binary)
|
|
10
|
+
return { name, capability, status: 'missing' };
|
|
11
|
+
const args = guardlink ? ['translate', '--help'] : ['--disable-update-check', 'scan', '--help'];
|
|
12
|
+
const help = spawnSync(resolve(binary), args, { env, encoding: 'utf8', timeout: timeoutMs, maxBuffer: 512 * 1024, stdio: ['ignore', 'pipe', 'pipe'] });
|
|
13
|
+
if (help.error || help.status !== 0)
|
|
14
|
+
return { name, capability, status: 'unavailable' };
|
|
15
|
+
const flags = guardlink ? ['--stdout', '--contract', '--threat'] : ['--no-author', '--templates', '--scope-file', '--auth-dir', '--session-dir'];
|
|
16
|
+
const supported = flags.every((flag) => new RegExp('(?:^|\\s)' + flag + '(?=\\s|,|$)', 'm').test(help.stdout))
|
|
17
|
+
&& (guardlink || /supplied JS probe/i.test(help.stdout));
|
|
18
|
+
return { name, capability, status: supported ? 'ready' : 'incompatible' };
|
|
19
|
+
}
|
|
20
|
+
export function formatProofTool(check) {
|
|
21
|
+
const what = check.name + ' · ' + check.capability;
|
|
22
|
+
if (check.status === 'ready')
|
|
23
|
+
return '✔ ' + what;
|
|
24
|
+
if (check.status === 'missing')
|
|
25
|
+
return '✘ ' + what + ' — tool missing';
|
|
26
|
+
if (check.status === 'unavailable')
|
|
27
|
+
return '✘ ' + what + ' — could not read command help';
|
|
28
|
+
return '✘ ' + what + ' — install a build supporting this interface and check which executable is first on PATH';
|
|
29
|
+
}
|
package/dist/report/check.js
CHANGED
|
@@ -35,7 +35,7 @@ const STATUS_FIELDS = ['Status', 'Evidence'];
|
|
|
35
35
|
export const RETEST_FIELDS = ['Retested build', 'Replay', 'Result', 'Bypass variants', 'Legitimate behaviour'];
|
|
36
36
|
const SEVERITIES = ['critical', 'high', 'medium', 'low', 'informational', 'info'];
|
|
37
37
|
/** Ids a report may cite: EXP-n, LED-<hex>, SAST-n, CTL-n, BND-n, ACC-n, RUN-n and RUN-n/F|X|H|N-m, EDGE-n and UNR-n; in a workspace report each may carry its service as a prefix (orders:EXP-3). */
|
|
38
|
-
export const ID_RE = /(?<![\w:-])(?:[a-z0-9][a-z0-9._-]{0,40}:)?(?:RUN-\d+(?:\/[FXHN]-\d+)?|(?:EXP|SAST|CTL|BND|ACC|EDGE|UNR)-\d+|LED-[a-f0-9]{8})\b/g;
|
|
38
|
+
export const ID_RE = /(?<![\w:-])(?:[a-z0-9][a-z0-9._-]{0,40}:)?(?:RUN-\d+(?:\/[FXHN]-\d+)?|(?:EXP|SAST|CTL|BND|ACC|EDGE|UNR)-\d+|LED-[a-f0-9]{8}(?:-\d+)?)\b/g;
|
|
39
39
|
const FINDING_HEADING = /^(#{2,4})\s+(F-\d{2,3})\s*(?:—|–|-|:)\s*(.+?)\s*$/;
|
|
40
40
|
const norm = (h) => h.replace(/^\d+\.\s*/, '').trim().toLowerCase();
|
|
41
41
|
/** The value of a `**Label:**` / `**Label**:` / `- **Label:**` line, or a `| Label | value |` table row, within lines; null when absent. */
|
|
@@ -135,6 +135,9 @@ export function checkReport(md, bundle, kind) {
|
|
|
135
135
|
err('evidence-ids', `${id} says "${LEVEL_LABEL[level]}" but cites no evidence id on a Status or Evidence line`, statusLines[0]?.line ?? at);
|
|
136
136
|
else if (!evidenceIds.some((x) => supports.get(x)?.includes(level)))
|
|
137
137
|
err('evidence-level', `${id} says "${LEVEL_LABEL[level]}" but none of ${evidenceIds.join(', ')} supports it; use the level the bundle computed`, statusLines[0]?.line ?? at);
|
|
138
|
+
else if (kind !== 'retest' && evidenceIds.some(x => /(?:^|:)EXP-\d+$/.test(x) && !supports.get(x)?.includes(level))) {
|
|
139
|
+
err('evidence-level', `${id} claims an evidence level that the cited exposure does not support on the assessed revision`, statusLines[0]?.line ?? at);
|
|
140
|
+
}
|
|
138
141
|
}
|
|
139
142
|
const sev = field(block, 'Severity');
|
|
140
143
|
const sevWord = sev ? (sev.value.toLowerCase().match(/[a-z]+/)?.[0] ?? '') : '';
|