@bugb-technologies/bravos 1.4.1 → 1.4.2
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 +52 -219
- package/dist/cli.js +41 -15
- package/dist/guardlink.js +4 -3
- package/dist/hooks.js +27 -5
- package/dist/install-proof-tool.js +5 -7
- package/dist/setup.js +11 -2
- package/dist/start/index.js +10 -2
- package/docs/UPGRADING.md +30 -0
- package/hooks/lib/briefing.mjs +5 -1
- package/hooks/lib/nightly-tools.sh +8 -2
- package/hooks/lib/replay.mjs +18 -7
- package/package.json +3 -2
- package/skills/bravos-env/SKILL.md +2 -2
- package/skills/bravos-env/scope.example.yaml +2 -2
- package/skills/bravos-prove/SKILL.md +5 -5
- package/skills/bravos-templatize/SKILL.md +2 -2
- package/skills/bravos-templatize/operator-guidance.md +4 -4
package/README.md
CHANGED
|
@@ -1,238 +1,71 @@
|
|
|
1
1
|
# Bravos
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Shift-left security that runs with every commit and pull request.**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Bravos makes the coding agent you already use work your threat model, code graph, SAST and authorized pentests, then gates every pull request and keeps a test that guards each fix.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
npm install -g @bugb-technologies/bravos
|
|
9
|
-
```
|
|
7
|
+
## The loop
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
Keep the threat model in the code with GuardLink → trace reachability with the code graph → investigate SAST findings → prove exposures with authorized pentests through cert-x-gen (`cxg`) → gate pull requests locally and in CI → replay a test after each fix.
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
Skills, hooks and MCP integration bring this loop into your coding agent, including Claude Code and Codex. A static finding is a lead; a test run supplies evidence. Pentests require a target you own and authorization; local targets use loopback by default.
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
## Install
|
|
16
14
|
|
|
17
|
-
**
|
|
15
|
+
Requires **Node.js 20 or newer**.
|
|
18
16
|
|
|
19
17
|
```bash
|
|
20
|
-
|
|
18
|
+
npm install -g @bugb-technologies/bravos
|
|
19
|
+
bravos start
|
|
21
20
|
```
|
|
22
21
|
|
|
23
|
-
|
|
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.
|
|
22
|
+
`bravos start` guides you through licence, tools, repository and agent setup, PR checks and scheduled upkeep. It shows the changes before you choose Apply, then tells you what to type in your agent. Bravos never starts an agent itself.
|
|
36
23
|
|
|
37
|
-
|
|
24
|
+
For manual setup, run `bravos init` in your repository to write skills, hooks and MCP wiring. `bravos setup` installs the analyzer and code graph (Team); `bravos setup --tools -y` also installs missing or incompatible GuardLink and cxg tools.
|
|
38
25
|
|
|
39
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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`.
|
|
45
|
-
- `bravos doctor`: check that the installed pieces and the underlying CLIs are present and healthy.
|
|
46
|
-
- `bravos watch`: a live, read-only view of the repo's security work for a second terminal pane beside any agent (below).
|
|
26
|
+
## Core commands
|
|
47
27
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
| Skill | What it does |
|
|
28
|
+
| Command | Purpose |
|
|
51
29
|
|---|---|
|
|
52
|
-
| `bravos` |
|
|
53
|
-
| `bravos
|
|
54
|
-
| `bravos
|
|
55
|
-
| `bravos
|
|
56
|
-
| `bravos
|
|
57
|
-
| `bravos
|
|
58
|
-
| `bravos
|
|
59
|
-
| `bravos
|
|
60
|
-
| `bravos
|
|
61
|
-
| `bravos
|
|
62
|
-
| `bravos-schedule` | Recurring upkeep: an in-session `/loop`, the nightly workflow, or a cloud task you create. Never live tests. |
|
|
63
|
-
| `bravos-cicd` | Audits and writes the security workflows; fixes broken guardlink calls and script-injection risks. |
|
|
64
|
-
| `bravos-report` | Writes the assessment, one finding, a retest or an executive brief from the evidence `bravos report data` gathers, checks it with `bravos report check`, and exports it to md, txt, html and pdf. |
|
|
65
|
-
|
|
66
|
-
## Plans and the licence
|
|
67
|
-
|
|
68
|
-
Bravos is free for one person researching one repository, and licensed per developer for a team.
|
|
69
|
-
|
|
70
|
-
| Plan | What it gives |
|
|
71
|
-
|---|---|
|
|
72
|
-
| **Free (researcher)** — no licence | bravos-context, bravos-annotate, bravos-templatize, bravos-env, bravos-prove, bravos-recheck, bravos-report and `bravos watch`, in one repository |
|
|
73
|
-
| **Team** (Solo is one seat) | everything above plus the pre-PR gate and autopilot, the CI and nightly workflows, scheduled upkeep, multi-repository workspaces, campaigns, SAST and the code graph |
|
|
74
|
-
|
|
75
|
-
`bravos licence` says which plan this machine is on, where the licence is and what it unlocks; the same line opens every session's briefing (`Plan: …`), `bravos doctor`, `bravos next` and the `bravos watch` header. `bravos account activate` signs you in once in the browser and writes the licence — a 30-day Team trial with no card when the account has no plan — and `bravos account import <file>` installs one downloaded from [account.bugb.io/dashboard/license](https://account.bugb.io/dashboard/license). A paid command or flag used without a licence explains what it would do and how to start the trial, and writes nothing; a paid hook (the pre-PR gate, autopilot) stands down with one line and never blocks a pull request; a paid skill stops at its first step and says so. The licence is a signed token verified offline (`BRAVOS_LICENCE`, or `licence.jwt` under `$BRAVOS_HOME`, default `~/.bravos`); after expiry it keeps working for min(14 days, a quarter of the term) and says so. Seats are counted in the account portal, not on the machine.
|
|
76
|
-
|
|
77
|
-
## Several repositories, one app: `bravos workspace`
|
|
78
|
-
|
|
79
|
-
For microservices, clone the services side by side in one folder and link them:
|
|
80
|
-
|
|
81
|
-
```bash
|
|
82
|
-
bravos workspace create platform \
|
|
83
|
-
--member ./gateway=gateway@http://127.0.0.1:8080 \
|
|
84
|
-
--member ./orders=orders@http://127.0.0.1:8081 \
|
|
85
|
-
--member ./billing=billing@http://127.0.0.1:8082
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
That one command:
|
|
89
|
-
- creates a bravos workspace, the source of truth for members, services and URLs;
|
|
90
|
-
- runs `guardlink link-project`, so each repo's `.guardlink/workspace.yaml` names its siblings;
|
|
91
|
-
- runs `bravos init` (or `sync`) in each service, and installs bravos in the shared folder, the **app folder**;
|
|
92
|
-
- writes a snapshot to `.bravos/workspace/` in each of them (gitignored, since its paths are machine-local).
|
|
93
|
-
|
|
94
|
-
`add`, `remove`, `target NAME SERVICE=URL`, `show [NAME] [--json]` and `sync` keep all three in step. Members can live anywhere, but only the app folder lets the code graph link services: `bravos graph build <app folder> --scip no-exec` connects one service's HTTP, gRPC, GraphQL or OpenAPI client call to another's handler.
|
|
95
|
-
|
|
96
|
-
**In a service repo:**
|
|
97
|
-
- the briefing names the app, the other services, and the calls into and out of this one;
|
|
98
|
-
- `bravos watch` gets a SERVICES panel, and `s` shows every service and cross-service edge.
|
|
99
|
-
|
|
100
|
-
**At the app folder:**
|
|
101
|
-
- the briefing lists each service's open, high and confirmed exposures and coverage;
|
|
102
|
-
- `bravos report data --workspace` gathers one report across services, with ids prefixed by service (`orders:EXP-3`) and cross-service calls as `EDGE-n`.
|
|
103
|
-
|
|
104
|
-
Declare each call to another service as `@flows #<this>-<x> -> #<other>-<y> via http|grpc|queue`, with plain ids prefixed by service. guardlink merge, bravos export and cxg chaining all read this form. guardlink's dotted `#repo.tag` form is not chained by cxg.
|
|
105
|
-
|
|
106
|
-
## Reports: `bravos report` and the bravos-report skill
|
|
107
|
-
|
|
108
|
-
Ask the agent to "write the assessment report" (or a single finding, a retest, an executive brief) and the bravos-report skill does it in three steps:
|
|
109
|
-
|
|
110
|
-
1. `bravos report data` (free, no model) gathers every fact a report may cite into `.bravos/reports/<id>/evidence.json`:
|
|
111
|
-
- the threat model, and the hypothesis and boundary ledgers;
|
|
112
|
-
- each cxg run under `.guardlink/pentest-findings/`;
|
|
113
|
-
- SAST, the code graph, intent, scope and proving;
|
|
114
|
-
- tool versions.
|
|
115
|
-
|
|
116
|
-
Each fact gets an id (`EXP-n`, `LED-…`, `RUN-n/F-n`, `SAST-n`). Each exposure gets an evidence level computed from that evidence: reproduced at runtime, control held at runtime, established by code or configuration review, or suspected, awaiting validation. Token-shaped strings are redacted as they are read.
|
|
117
|
-
2. **The agent writes `report.md`** from the skill's templates. The full assessment follows the eight-section reading order (executive assessment, scope and limitations, system and threat context, coverage and approach, principal attack narratives, findings, remediation roadmap, retest and appendices). Every finding is self-contained, with:
|
|
118
|
-
- prerequisites;
|
|
119
|
-
- expected and observed behaviour;
|
|
120
|
-
- reproduction;
|
|
121
|
-
- root cause;
|
|
122
|
-
- impact (demonstrated, supported, uncertain);
|
|
123
|
-
- a severity rationale and a priority;
|
|
124
|
-
- remediation and verification.
|
|
125
|
-
|
|
126
|
-
Every proof claim cites its evidence ids.
|
|
127
|
-
3. **`bravos report check` fails the report** when any of these is wrong:
|
|
128
|
-
- a section is missing or out of order, or a finding lacks a field;
|
|
129
|
-
- a label is stronger than its cited evidence supports, or a cited id is unknown;
|
|
130
|
-
- a percentage has no denominator, or a CVSS score has no vector;
|
|
131
|
-
- something looks like a secret.
|
|
132
|
-
|
|
133
|
-
`bravos report export <id> --format md,txt,html,pdf` renders the checked report beside `report.md`:
|
|
134
|
-
- **html:** a branded page with no script and no external request, and a print stylesheet;
|
|
135
|
-
- **txt:** 80 columns;
|
|
136
|
-
- **pdf:** printed by an installed Chrome, Edge, Brave or Chromium (or Playwright's Chromium) in headless mode, with a throwaway profile. Set `BRAVOS_PDF_BROWSER` to choose one.
|
|
137
|
-
|
|
138
|
-
`bravos report list` shows the reports. Reports quote evidence, so `.bravos/reports/` carries its own `.gitignore`; sharing an export is a deliberate act. `bravos watch` shows the newest report in a REPORT panel: findings by evidence level and severity, check verdict, exports, and commits since. `p` shows its findings and executive section; `o` opens the pdf or html.
|
|
139
|
-
|
|
140
|
-
## Answering bravos's questions: `bravos review`
|
|
141
|
-
|
|
142
|
-
bravos-context no longer pastes thirty questions into chat. By default it assumes you are researching software you do not own: it drafts the intent from upstream's own docs (with links) and asks only the scope decisions — configuration baseline, single organisation or multi-tenant, attackers in scope, and intended-looking behaviours upstream leaves undocumented — which `intent.md` records as Assumptions that severities are rated against; say it is your product for the owner interview. It writes its suggestions to `.guardlink/intent-draft.json` and runs `bravos review intent`, which opens a bravos-branded page served from your machine only (loopback, a random token, answers capped and validated). Every card comes pre-filled with bravos's suggestion, its reason and its source; facts are folded away; decisions are marked "needs your call" and Confirm stays off until each one is clicked, so nobody rubber-stamps them. `intent.md` records each item as accepted as suggested, edited, chosen or draft, with names. Each person's answers are saved to `.guardlink/intent-answers/<name>.json`. Teammates run `bravos review intent` after pulling, or open the page with `--no-serve` and send the downloaded file, and the answers travel through git like any other change. `bravos review intent --summary` prints who agreed and who disagreed, for the agent to settle; `intent.md` marks each item confirmed only by the people who agreed to it. On Claude Code, `--share` renders the page for a private claude.ai artifact with a shared database instead; the agent says first that this puts your security intent on claude.ai.
|
|
143
|
-
|
|
144
|
-
## Autopilot
|
|
145
|
-
|
|
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.
|
|
30
|
+
| `bravos start` | Guided setup. |
|
|
31
|
+
| `bravos init` | Install skills, hooks and MCP wiring in a repository. |
|
|
32
|
+
| `bravos sync` | Refresh installed skills and wiring after an upgrade. |
|
|
33
|
+
| `bravos setup` | Install the tools Bravos drives. |
|
|
34
|
+
| `bravos graph build .` | Index the repository for code graph questions. |
|
|
35
|
+
| `bravos sast run` | Run static analysis against the repository. |
|
|
36
|
+
| `bravos doctor` | Check installed tools and configuration. |
|
|
37
|
+
| `bravos next` | Show setup progress and the next step. |
|
|
38
|
+
| `bravos watch` | Watch security work live in a second terminal pane. |
|
|
39
|
+
| `bravos guide` | Read the guide by role, task or skill. |
|
|
147
40
|
|
|
148
|
-
|
|
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
|
-
|
|
152
|
-
## User-level install and one copy of each skill
|
|
153
|
-
|
|
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.
|
|
155
|
-
|
|
156
|
-
`bravos sync --link-skills` replaces a repo's `.agents/skills` with a link to `.claude/skills`, so each skill exists once; tools that read both folders, such as Warp, otherwise show every skill twice. It removes only bravos's own unchanged copies and refuses, removing nothing, when anything else is there.
|
|
157
|
-
|
|
158
|
-
## Uninstall
|
|
159
|
-
|
|
160
|
-
`bravos uninstall` removes bravos from the current repository: every file its lock records that is unchanged, its hook entries in `.claude/settings.json`, `.codex/hooks.json` and `.agents/hooks.json`, its `pre_pr` entry in `.guardlink/config.json`, and `.bravos/`. `bravos uninstall --global` does the same for the user-level install, including the `~/.agents/skills/bravos*` links. Edited files are kept and listed unless `--force`; `--dry-run` lists everything first. It never removes guardlink's own files, a reviewed `scope.yaml`, or MCP entries, which may predate bravos; it lists them.
|
|
161
|
-
|
|
162
|
-
## A live view: `bravos watch`
|
|
163
|
-
|
|
164
|
-
`bravos watch` runs in a second terminal pane beside any agent (Claude Code, Codex, omp, opencode, Antigravity) and shows the repo's security work as it changes. A row of tiles (open, high, confirmed, tested, coverage, stale, setup, graph resolution, SAST) sits under a header bar, and bordered panels below it show:
|
|
165
|
-
|
|
166
|
-
- **Setup**: the nine steps with a progress bar, and the next one with its command.
|
|
167
|
-
- **Threat model**: a severity bar (one glyph per severity, so it reads without colour), the hypothesis ledger (confirmed, refuted, retest, untested), boundary claims held or broken, coverage, annotations, stale claims, drift, orphans, accepted risks and tickets, with sparklines of open exposures and coverage over the session.
|
|
168
|
-
- **Test next**: `guardlink hypothesis next` with severity badges, asset, state and file.
|
|
169
|
-
- **Top threats and assets**, ranked with bars.
|
|
170
|
-
- **Code graph**: currency, files, callables and calls, call resolution per language (with a warning below 50%, where "not reached" is weak evidence), entry points by kind, route access levels, how many declared exposures a test reaches, hot files that change open exposures, accepted risks. A commit leaves the checkout without a graph until it is rebuilt, because bravos keys the graph to the commit; the panel says so and gives the command.
|
|
171
|
-
- **SAST**, **branch and team** (ahead and behind the base, uncommitted files and how many lack annotations, recent commits, PRs, autopilot, pre-PR and CI hooks, intent, proving, review answers, a skills-version mismatch), the **model's size** (`guardlink status`), and **activity**.
|
|
172
|
-
|
|
173
|
-
It redraws within a couple of seconds of a file change (`fs.watch`, debounced; one snapshot at a time), re-reads boundaries, the model's size and PRs every `--interval` seconds (default 60), and asks the code graph again every `--graph-interval` seconds (default 300). Read-only and free: no model, nothing written to the repo. Autopilot logs each nudge to `.bravos/watch/events.jsonl`, a local log with its own `.gitignore`, capped at 500 lines.
|
|
174
|
-
|
|
175
|
-
Three columns from 150 wide, two from 110, one column from 80 (a split pane), a compact list below that (`--compact` forces it); the panels scroll when the terminal is shorter than they are. Keys: `n` copies the next command, `r` opens the intent review page, `d` writes guardlink's dashboard to a temp file and opens it, `g` asks the code graph a question (`bravos graph <q>`), `t` shows test-next and stale claims in full, `i` shows the recorded intent (`.guardlink/intent.md`, with who answered the review), `u` refreshes everything now, `j`/`k` (or the arrows, space, `G`) scroll, `?` the guide, `q` quits. Overlays (`t`, `i`, `?`, a graph answer) wrap to the terminal and scroll with the same keys; any other key closes them. `--once` prints one frame (and is what happens when stdout is not a terminal), `--json` one snapshot (`bravos.watch/v1`). `c` switches the colours between dark, light and neutral. `NO_COLOR` or `BRAVOS_WATCH_COLOR=off` prints it plain; on a live terminal bravos asks it for its background colour and picks the light or dark palette (see `BRAVOS_THEME` below).
|
|
176
|
-
|
|
177
|
-
## Getting started: `bravos next`
|
|
178
|
-
|
|
179
|
-
`bravos next` (free, in a shell) is the setup score for a repo, in the order the steps build on each other: the code graph first (a machine step every later skill reads), then what the app intends, annotation coverage, SAST (which reads the annotations), how findings are proven and a test target, then the gates (autopilot, the pre-PR gate, CI — cheap, fine to switch on early). It shows what each unlocks and the exact command for the next one; bravos assumes a licensed bravos-cli. The same line is in the banner (`Next: … → …`, and `setup n/9` on the status line) and in the briefing every harness hands the agent, together with a few coaching rules: offer a few starts once in the first reply, suggest the next bravos step at natural moments (annotate after security edits, the ship check before a PR, a recheck after a fix), plain words first, never nag. Ask "help me get started" for a guided tour. `BRAVOS_COACH=off` keeps only the Setup line.
|
|
180
|
-
|
|
181
|
-
## The guide
|
|
182
|
-
|
|
183
|
-
`bravos guide` prints how to use bravos by role (developer, security engineer, team lead, new to the repo, CI owner), by task, skill by skill, how to read a finding, the hard safety rules and what each harness gets. It runs no model. `bravos guide <topic>` prints one topic (`start`, `roles`, `tasks`, `skills`, `states`, `safety`, `harnesses`, `all`); `--harness codex|omp` shows skills in that harness's syntax. The same text is in [docs/GUIDE.md](docs/GUIDE.md).
|
|
184
|
-
|
|
185
|
-
## Session start: a briefing for the model, a banner for you
|
|
186
|
-
|
|
187
|
-
The session-start hook prints one JSON object. Its `additionalContext` is the briefing: open exposures by severity, coverage, confirmed findings, what to test next, stale claims, tickets, work in flight and the intent state, sent to the model on every start, resume, clear and compact. On a fresh start only (`source: startup`, or a manual run), its `systemMessage` carries a banner for the human, which the model does not see: the bravos logo, repo and branch, the counts, the top three threats (or the confirmed findings to fix now) beside a three-step quick start chosen from the repo's state, and a short introduction to bravos while `.guardlink/intent.md` is missing. It is plain text within 80 columns. The registered command carries `--harness claude` or `--harness codex` so the quick start prints `/bravos-…` or `$bravos-…`; `bravos sync` replaces the older entry without the flag, and Codex asks you to trust the changed hook once in `/hooks`. Set `BRAVOS_BANNER=off` to hide the banner; the briefing is unchanged. The banner is drawn in bravos's brand colours; `NO_COLOR` or `BRAVOS_BANNER_COLOR=off` prints it plain. Colours follow the terminal's background: `BRAVOS_THEME=light|dark|neutral` picks them, otherwise `COLORFGBG`, the choice saved by `bravos start`, then `neutral`, whose colours read on light and dark backgrounds alike (`bravos doctor` says which and why). Codex lists a hook's message as a warning (behind F2), so Codex gets a two-line summary instead of the art. opencode finds the skills through its skill tool but lists only its own `/commands` and runs no hooks, so when opencode is in use (`.opencode/`, `opencode.json`, or `opencode` on PATH) bravos also writes one `.opencode/commands/<skill>.md` per skill (so `/bravos`, `/bravos-ship` and the rest appear), `.opencode/plugins/bravos.js` (an opencode 2.x plugin that adds the briefing to the system prompt of each request), and guardlink under `mcp` in `opencode.json`. Antigravity (`agy`) reads `.agents/hooks.json`; bravos adds a `bravos` SessionStart group there that hands the briefing to the model, since Antigravity documents no way for a hook to show text to you.
|
|
188
|
-
|
|
189
|
-
omp runs neither Claude Code's nor Codex's hooks, so when omp is in use (a `.omp/` folder, or `omp` on PATH) `bravos init` and `sync` also write `.omp/extensions/bravos.js`, which omp loads by itself: it shows the same banner above the editor at session start and hands the briefing to the model, hidden, with the first prompt. In none of these harnesses do you need to type a command for the briefing; `/bravos` is for deciding the next step. Anywhere else, the bravos skill runs `node .bravos/hooks/session-start.mjs --briefing`, which prints the briefing as plain text.
|
|
190
|
-
|
|
191
|
-
## The pre-PR gate
|
|
192
|
-
|
|
193
|
-
With `--pre-pr-hook`, every `gh pr create` and `gh pr ready` an agent runs first passes the bravos-ship gate: `guardlink validate`, `guardlink lint --since <merge-base>` with no errors, every new unmitigated exposure from `guardlink diff <merge-base> --json` disclosed in the PR body by both its threat and asset id (on `gh pr ready` the body is read with `gh pr view`), and no `@confirmed` claim from `guardlink ci -f json` on a changed file unless that file carries a `@ticket` for it. An exposure paired with `@audit` stays listed by design and is reported, not blocked forever. A gate input that fails or does not parse blocks as "unknown", including `gh pr view` on `gh pr ready`; the gate allows, and says why, in exactly two cases: guardlink is not on PATH, or no merge base with the default branch is found. It runs from the repository's top level whatever directory the agent is in. Before a PR exists, run `node .bravos/hooks/pre-pr.mjs --check` (the line `--pre-pr-hook` lists under `pre_pr` for guardlink's agent block): it blocks on lint errors and confirmed claims on changed files, and prints the new exposures the PR body must disclose. The whole gate shares a 150 s deadline inside the hook's 180 s timeout. Set `BRAVOS_PRE_PR=off` in your own environment to disable it.
|
|
194
|
-
|
|
195
|
-
## Workflows (`bravos init --ci`)
|
|
196
|
-
|
|
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).
|
|
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.
|
|
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.
|
|
200
|
-
|
|
201
|
-
## Install as a plugin (after 1.0)
|
|
202
|
-
|
|
203
|
-
The repo also renders a plugin for each harness from the same `skills/` and `hooks/`: `plugin/` for Claude Code (served by `.claude-plugin/marketplace.json`) and `plugin-codex/` for Codex (`.agents/plugins/marketplace.json`). Regenerate both with `npm run build:plugin`; a test fails when either drifts from the source. A plugin marketplace is served from a repository customers can read, and this one is private, so the marketplace route (a small public repo holding only the built plugins, then `claude plugin marketplace add …` / `claude plugin install bravos@bravos`) comes after 1.0; until then `bravos init` is the way in for every harness.
|
|
204
|
-
|
|
205
|
-
Each plugin carries the skills, the session-start briefing (from the plugin's own copy of the hook) and the guardlink MCP entry. cxg and the code-graph server are left out because they fail to start on machines without them; `bravos init` adds them per repo when they are installed. The Codex build renders skill paths repo-relative (`.agents/skills/<name>`), so the scripts a skill runs (for example bravos-annotate's slice picker) resolve once `bravos init --agent codex` has written `.agents/skills/` into the repo. The pre-PR gate and the workflows come from `bravos init` for both harnesses. Use the plugin or `bravos init`'s session-start hook, not both, or the briefing prints twice.
|
|
206
|
-
|
|
207
|
-
## How bravos works with the model
|
|
208
|
-
|
|
209
|
-
Claude Code and Codex are already strong; bravos is an add-on, never a cap. Every budget in a skill
|
|
210
|
-
(files per slice, templates per run, rounds per campaign) is a default the agent may exceed when the
|
|
211
|
-
work needs it, saying why in one line. Only the safety rules are hard: no request to a non-loopback
|
|
212
|
-
host without a committed, reviewed `scope.yaml` and your typed authorization; destructive probe
|
|
213
|
-
classes only on a disposable loopback target; never `@accepts`, `@entitles` or a hand-written
|
|
214
|
-
`@confirmed`; never launch an external agent CLI; never invent credentials; never call anything clean
|
|
215
|
-
unless a gate exited 0.
|
|
216
|
-
|
|
217
|
-
**Effort** (`low | medium | high | max`) is one dial every skill reads: from your request ("annotate at
|
|
218
|
-
high"), else a `bravos effort: <level>` line in `AGENTS.md` / `CLAUDE.md`, else medium. Run
|
|
219
|
-
`bravos --help` for what each level means per skill.
|
|
220
|
-
|
|
221
|
-
**bravos-campaign** reaches a goal over many rounds — `/bravos-campaign coverage 100% at max, rest 10m`
|
|
222
|
-
in Claude Code, `$bravos-campaign test every open exposure` in Codex — with disjoint batches, one
|
|
223
|
-
subagent per batch, a gate per batch, a rest between rounds, and a stop when the goal is met.
|
|
224
|
-
|
|
225
|
-
## Intent-aware annotation
|
|
226
|
-
|
|
227
|
-
Code patterns alone over-rate features and miss business-logic flaws. `bravos-context` reads the
|
|
228
|
-
repo, drafts answers, and asks you a short interview: what the product is for, who the roles are,
|
|
229
|
-
what data and actions matter most, what must never happen, and what looks dangerous but is
|
|
230
|
-
intended. Answers go into `.guardlink/intent.md` (each item `— confirmed by <name>` or `— draft`)
|
|
231
|
-
and into the threat model as actors, assets, boundaries and one `#inv-…` threat per invariant.
|
|
232
|
-
bravos-annotate then adds a logic pass over user journeys, rates each exposure by impact × reach
|
|
233
|
-
× ease with the reason in the description, and writes an "intended?" `@audit` for you to answer
|
|
234
|
-
rather than claiming a by-design feature as a critical flaw.
|
|
41
|
+
## Skills
|
|
235
42
|
|
|
236
|
-
|
|
43
|
+
Invoke skills in your agent: `/bravos` in Claude Code or `$bravos` in Codex.
|
|
237
44
|
|
|
238
|
-
|
|
45
|
+
| Skill | Purpose |
|
|
46
|
+
|---|---|
|
|
47
|
+
| `bravos` | Start here: read the security picture and route to the next step. |
|
|
48
|
+
| `bravos-context` | Record software intent, actors, assets and boundaries before judging code. |
|
|
49
|
+
| `bravos-annotate` | Keep the GuardLink threat model accurate and growing, with evidence and lint gates. |
|
|
50
|
+
| `bravos-codegraph` | Ask one bounded question about routes, sinks, reachability or blast radius. |
|
|
51
|
+
| `bravos-sast` | Run licensed static analysis, join findings to claims and reachability, and gate new findings. |
|
|
52
|
+
| `bravos-templatize` | Turn open exposures into correct, testable cxg templates. |
|
|
53
|
+
| `bravos-env` | Prepare a target you own with reviewed scope and your authorization; loopback by default. |
|
|
54
|
+
| `bravos-prove` | Prove a claim or replay it after a fix against an authorized target. |
|
|
55
|
+
| `bravos-recheck` | Recheck stale findings, replay retest kits and confirm a fix held. |
|
|
56
|
+
| `bravos-ship` | Gate a PR on valid claims and new exposures; block confirmed exploitable claims on changed paths without a ticket. |
|
|
57
|
+
| `bravos-cicd` | Audit and write security CI: PR gate, nightly annotation and optional SAST. |
|
|
58
|
+
| `bravos-report` | Write and export an evidence-bound white-box VAPT report. |
|
|
59
|
+
| `bravos-campaign` | Work toward a security goal over multiple rounds, then stop. |
|
|
60
|
+
| `bravos-schedule` | Set up recurring upkeep through a session loop, nightly workflow or cloud task. |
|
|
61
|
+
| `bravos-resync` | Carry annotation work from an unmerged branch onto the base and reverify it. |
|
|
62
|
+
|
|
63
|
+
## Plans & licence
|
|
64
|
+
|
|
65
|
+
**Free:** one person researching one repository, including the threat-model and authorized testing loop. **Team** (Solo is one seat) adds PR gates, autopilot, CI, scheduled upkeep, workspaces, campaigns, SAST and the code graph. `bravos account activate` starts a 30-day Team trial with no card when your account has no plan; `bravos licence` shows your plan.
|
|
66
|
+
|
|
67
|
+
Bravos is proprietary software of BugB Technologies, free on the Free plan and licensed per developer for Team features. See [LICENSE](LICENSE) for terms; third-party components keep their own licences.
|
|
68
|
+
|
|
69
|
+
## Learn more
|
|
70
|
+
|
|
71
|
+
Visit [Bravos](https://bugb.io/bravos) for the product and plans. Run `bravos guide` for detailed setup, workflows, safety rules and harness guidance, or `bravos --help` for command options. The guide is also shipped with the npm package at `docs/GUIDE.md`, and what changes between versions is in [docs/UPGRADING.md](docs/UPGRADING.md).
|
package/dist/cli.js
CHANGED
|
@@ -27,7 +27,7 @@ import * as graph from './codegraph.js';
|
|
|
27
27
|
import { askGraph } from './watch.js';
|
|
28
28
|
import { plan as setupPlan, runSast, runSetup } from './setup.js';
|
|
29
29
|
import { licenceDocument, licenceLib, licenceLines, requireFeature } from './licence.js';
|
|
30
|
-
import { migrateFromOldName, reportMigration } from './migrate.js';
|
|
30
|
+
import { migrateFromOldName, OLD_DIR, reportMigration } from './migrate.js';
|
|
31
31
|
import { listBundledSkills } from './skills.js';
|
|
32
32
|
import { installSkills, linkSkillRoots, mirrorGuardlinkSkills, skillRootsLinked } from './install.js';
|
|
33
33
|
import { readLock, sha256, writeLock } from './lock.js';
|
|
@@ -47,12 +47,12 @@ function parseWorkflows(value) {
|
|
|
47
47
|
}
|
|
48
48
|
const GUARDLINK_HINT = 'guardlink: not found on PATH — run bravos setup --tools -y';
|
|
49
49
|
// Antigravity reads the shared .agents/ root; opencode and omp get their own files on top of a skills root.
|
|
50
|
-
const AGENT_MAP = { claude: 'claude', codex: 'agents', agy: '
|
|
50
|
+
const AGENT_MAP = { claude: 'claude', codex: 'agents', agy: 'agy', opencode: 'opencode', omp: 'omp' };
|
|
51
51
|
// @comment -- "Parses --agent <claude,codex>; codex maps to the .agents harness and anything else is a usage error."
|
|
52
52
|
function parseAgents(value) {
|
|
53
53
|
const out = [];
|
|
54
54
|
// 'all' is every harness bravos knows: both skill roots plus the opencode and omp files.
|
|
55
|
-
const raws = value.split(',').map((s) => s.trim()).flatMap((r) => (r === 'all' ? ['claude', 'codex', 'opencode', 'omp'] : [r]));
|
|
55
|
+
const raws = value.split(',').map((s) => s.trim()).flatMap((r) => (r === 'all' ? ['claude', 'codex', 'agy', 'opencode', 'omp'] : [r]));
|
|
56
56
|
for (const raw of raws) {
|
|
57
57
|
const h = AGENT_MAP[raw];
|
|
58
58
|
if (!h)
|
|
@@ -86,21 +86,43 @@ function gitignoreWarnings(root, paths, env) {
|
|
|
86
86
|
return dirs.map((d) => `warning: ${d}/ is gitignored in this repo; files under it will not reach teammates via git`);
|
|
87
87
|
}
|
|
88
88
|
// @comment -- "Runs the install pipeline (detect, guardlink init unless sync, skills, hook, lock, MCP) and pushes summary lines as it goes, so a mid-way BravosError still leaves the summary so far in `lines`."
|
|
89
|
+
// @comment -- "Names any agent settings file that still runs a hook script from the old name's folder (.joseph/hooks), which the migration removes: an agent not selected with --agent keeps its own settings, so its sessions would start a script that is gone. Read-only; an unreadable file is skipped."
|
|
90
|
+
function oldHookReferences(root) {
|
|
91
|
+
const files = [['.claude/settings.json', 'claude'], ['.codex/hooks.json', 'codex'], ['.agents/hooks.json', 'agy']];
|
|
92
|
+
const out = [];
|
|
93
|
+
for (const [rel, agent] of files) {
|
|
94
|
+
try {
|
|
95
|
+
if (readFileSync(join(root, rel), 'utf8').includes(`${OLD_DIR}/hooks/`)) {
|
|
96
|
+
out.push(`Hooks: ${rel} still runs the old ${OLD_DIR}/hooks scripts, which are gone; run bravos sync --agent ${agent} to replace them, or remove those entries.`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
/* not there */
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return out;
|
|
104
|
+
}
|
|
89
105
|
function pipeline(root, io, opts, withGuardlink, lines) {
|
|
90
106
|
const dryRun = !!opts.dryRun;
|
|
91
107
|
if (dryRun)
|
|
92
108
|
lines.push('dry-run: nothing written');
|
|
109
|
+
// @comment -- "The move from the old name runs whatever --agent selects: it removes only old-name files the old lock vouches for and moves the data folders, and creates nothing for an agent that was not chosen. bravos start always passes --agent, so skipping it there would leave every old install unmigrated."
|
|
93
110
|
reportMigration(migrateFromOldName(root, { dryRun, ownSkills: listBundledSkills(io.skillsDir).map((s) => s.name) }), lines);
|
|
94
111
|
const detected = detectHarnesses(root);
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
const
|
|
112
|
+
// @comment -- "Explicit --agent limits agent-specific writes, independent of detection and shared skill roots. Antigravity and Codex share .agents/skills but have separate hook registrations; omp/opencode alone use that skills root without installing Codex."
|
|
113
|
+
const explicit = opts.agent !== undefined;
|
|
114
|
+
const chosen = opts.agent?.flatMap((a) => a === 'claude' ? ['claude'] : a === 'agents' || a === 'agy' ? ['agents'] : []);
|
|
115
|
+
const harnesses = explicit ? [...new Set(chosen?.length ? chosen : ['agents'])] : detected.harnesses;
|
|
116
|
+
const defaulted = !explicit && detected.defaulted;
|
|
117
|
+
const codex = explicit ? opts.agent.includes('agents') : harnesses.includes('agents');
|
|
118
|
+
const agy = explicit ? opts.agent.includes('agy') : harnesses.includes('agents');
|
|
119
|
+
const hookHarnesses = harnesses.filter((h) => h === 'claude' || codex);
|
|
98
120
|
const forceOpencode = !!opts.agent?.includes('opencode');
|
|
99
121
|
const forceOmp = !!opts.agent?.includes('omp');
|
|
100
122
|
lines.push(`Harnesses: ${harnesses.join(', ')}${defaulted ? ' (default: no evidence found)' : ''}`);
|
|
101
123
|
let guardlinkPending = false;
|
|
102
124
|
if (withGuardlink) {
|
|
103
|
-
const g = ensureGuardlink(root,
|
|
125
|
+
const g = ensureGuardlink(root, hookHarnesses, {
|
|
104
126
|
mode: opts.guardlinkMode,
|
|
105
127
|
skip: opts.guardlinkInit === false,
|
|
106
128
|
dryRun,
|
|
@@ -174,14 +196,14 @@ function pipeline(root, io, opts, withGuardlink, lines) {
|
|
|
174
196
|
for (const s of mirror.skipped)
|
|
175
197
|
lines.push(` skipped ${s.path} — ${s.reason}`);
|
|
176
198
|
}
|
|
177
|
-
const cursor = writeCursorPointer(root, harnesses, { force: opts.force, dryRun });
|
|
199
|
+
const cursor = explicit ? { status: 'absent' } : writeCursorPointer(root, harnesses, { force: opts.force, dryRun });
|
|
178
200
|
if (cursor.status === 'skipped')
|
|
179
201
|
lines.push(`Cursor: skipped ${cursor.path} — ${cursor.reason}`);
|
|
180
202
|
else if (cursor.status === 'no-skills')
|
|
181
203
|
lines.push(`Cursor: ${cursor.path} not written — no skills root was installed for it to point at`);
|
|
182
204
|
else if (cursor.status !== 'absent')
|
|
183
205
|
lines.push(`Cursor: ${cursor.path} ${cursor.status}`);
|
|
184
|
-
const omp = writeOmpExtension(root, io.env, { force: opts.force, dryRun, always: forceOmp });
|
|
206
|
+
const omp = explicit && !forceOmp ? { status: 'absent' } : writeOmpExtension(root, io.env, { force: opts.force, dryRun, always: forceOmp });
|
|
185
207
|
if (omp.status === 'skipped')
|
|
186
208
|
lines.push(`omp: skipped ${omp.path} — ${omp.reason}`);
|
|
187
209
|
else if (omp.status !== 'absent')
|
|
@@ -198,7 +220,7 @@ function pipeline(root, io, opts, withGuardlink, lines) {
|
|
|
198
220
|
// Autopilot is the pre-PR gate plus the end-of-turn check.
|
|
199
221
|
if (opts.autopilot)
|
|
200
222
|
opts.prePrHook = true;
|
|
201
|
-
const hook = installHook(root,
|
|
223
|
+
const hook = installHook(root, hookHarnesses, { hooksDir: io.hooksDir, dryRun, antigravity: agy, prePr: !!opts.prePrHook, autopilot: !!opts.autopilot });
|
|
202
224
|
if (!dryRun) {
|
|
203
225
|
const lock = readLock(root);
|
|
204
226
|
for (const rel of hook.copied)
|
|
@@ -207,6 +229,9 @@ function pipeline(root, io, opts, withGuardlink, lines) {
|
|
|
207
229
|
}
|
|
208
230
|
for (const r of hook.registered)
|
|
209
231
|
lines.push(`Hooks: ${r.file} ${r.changed ? 'registered' : 'already registered'}`);
|
|
232
|
+
// An agent left out of --agent keeps its own settings, which may still run the old-name hook the migration moved.
|
|
233
|
+
for (const w of oldHookReferences(root))
|
|
234
|
+
lines.push(w);
|
|
210
235
|
const guardlinkWritten = [];
|
|
211
236
|
if (opts.prePrHook) {
|
|
212
237
|
const p = registerPrePr(root, { dryRun });
|
|
@@ -234,15 +259,16 @@ function pipeline(root, io, opts, withGuardlink, lines) {
|
|
|
234
259
|
}
|
|
235
260
|
const { selected, deferred } = selectServers(io.env);
|
|
236
261
|
// opencode lists skills only through its skill tool and runs no hooks: commands, a plugin and MCP.
|
|
237
|
-
const oc = writeOpencode(root, io.env, selected, { force: opts.force, dryRun, skillsDir: io.skillsDir, always: forceOpencode });
|
|
262
|
+
const oc = explicit && !forceOpencode ? { status: 'absent' } : writeOpencode(root, io.env, selected, { force: opts.force, dryRun, skillsDir: io.skillsDir, always: forceOpencode });
|
|
238
263
|
if (oc.status === 'done') {
|
|
239
264
|
lines.push(`opencode: ${oc.written.length} written, ${oc.unchanged.length} unchanged, ${oc.skipped.length} skipped (plugin, /bravos commands)${oc.mcpAdded.length ? `; ${OPENCODE_CONFIG} mcp added ${oc.mcpAdded.join(', ')}` : ''}${oc.mcpUpdated?.length ? `; ${OPENCODE_CONFIG} mcp refreshed ${oc.mcpUpdated.join(', ')}` : ''}`);
|
|
240
265
|
for (const s of oc.skipped)
|
|
241
266
|
lines.push(` skipped ${s.path} — ${s.reason}`);
|
|
242
267
|
}
|
|
243
268
|
const mcpLine = (m) => lines.push(`MCP: ${m.path} added ${names(m.added)}; kept ${names(m.kept)}${m.updated?.length ? `; refreshed ${names(m.updated)} (it pointed at another bravos install or graph store)` : ''}`);
|
|
244
|
-
|
|
245
|
-
|
|
269
|
+
if (!explicit || harnesses.includes('claude'))
|
|
270
|
+
mcpLine(mergeMcpJson(root, selected, { dryRun }));
|
|
271
|
+
if (codex)
|
|
246
272
|
mcpLine(mergeCodexConfig(root, selected, { dryRun }));
|
|
247
273
|
if (deferred.length) {
|
|
248
274
|
const tools = runDoctor(root, io.env).tools;
|
|
@@ -279,7 +305,7 @@ function pipeline(root, io, opts, withGuardlink, lines) {
|
|
|
279
305
|
lines.push('autopilot on: an end-of-turn check (Stop hook) sends the agent back once when changed code lacks annotations, sits under a confirmed or stale claim, or adds exposures; the pre-PR gate checks every gh pr create / gh pr ready.');
|
|
280
306
|
lines.push('autopilot: the first time proving comes up, the agent asks you once how you want it handled and records your answer in .guardlink/proving.md. BRAVOS_AUTOPILOT=off pauses the check.');
|
|
281
307
|
}
|
|
282
|
-
if (
|
|
308
|
+
if (codex)
|
|
283
309
|
lines.push('In Codex run /hooks once to trust .codex/hooks.json');
|
|
284
310
|
// A user-level install of another version silently replaces these skills in Claude Code, so a
|
|
285
311
|
// repo sync brings an existing one up to date too (never creates one; a dry run only reports;
|
|
@@ -381,7 +407,7 @@ export function buildProgram(io, result) {
|
|
|
381
407
|
.description('First install: detect agents, run guardlink init if needed, install skills, hooks and MCP wiring.')
|
|
382
408
|
.addHelpText('after', INIT_HELP)
|
|
383
409
|
.option('--agent <list>', 'comma-separated agents: claude,codex,agy,opencode,omp, or all', parseAgents)
|
|
384
|
-
.addOption(new Option('--guardlink-mode <mode>', 'guardlink annotation mode').choices(['inline', 'external'])
|
|
410
|
+
.addOption(new Option('--guardlink-mode <mode>', 'guardlink annotation mode (default: GuardLink chooses)').choices(['inline', 'external']))
|
|
385
411
|
.option('--no-guardlink-init', 'do not run guardlink init')
|
|
386
412
|
.option('--force', 'overwrite edited or authored skill files')
|
|
387
413
|
.option('--pre-pr-hook', 'also register the PreToolUse gate that checks gh pr create / gh pr ready')
|
package/dist/guardlink.js
CHANGED
|
@@ -24,7 +24,7 @@ export function whichBin(name, env = process.env) {
|
|
|
24
24
|
return null;
|
|
25
25
|
}
|
|
26
26
|
/** Runs `guardlink init` (argv array, no shell) only when `<root>/.guardlink` is absent. */
|
|
27
|
-
// @comment -- "Runs guardlink init (argv array, no shell) only when <root>/.guardlink is absent, and reports what it did or would do with the argv it used."
|
|
27
|
+
// @comment -- "Runs guardlink init (argv array, no shell) only when <root>/.guardlink is absent, and reports what it did or would do with the argv it used. Annotation mode is left to GuardLink unless explicitly selected."
|
|
28
28
|
export function ensureGuardlink(root, harnesses, opts = {}) {
|
|
29
29
|
if (existsSync(join(root, '.guardlink')))
|
|
30
30
|
return { status: 'present' };
|
|
@@ -33,9 +33,10 @@ export function ensureGuardlink(root, harnesses, opts = {}) {
|
|
|
33
33
|
const env = opts.env ?? process.env;
|
|
34
34
|
const command = [
|
|
35
35
|
'guardlink', 'init',
|
|
36
|
-
'--agent', harnesses.map((h) => AGENT_ID[h]).join(','),
|
|
37
|
-
'--mode', opts.mode ?? 'inline',
|
|
36
|
+
'--agent', harnesses.map((h) => AGENT_ID[h]).join(',') || 'none',
|
|
38
37
|
];
|
|
38
|
+
if (opts.mode)
|
|
39
|
+
command.push('--mode', opts.mode);
|
|
39
40
|
if (opts.dryRun)
|
|
40
41
|
return { status: 'dry-run', command };
|
|
41
42
|
if (!whichBin('guardlink', env))
|
package/dist/hooks.js
CHANGED
|
@@ -62,7 +62,7 @@ function listFiles(dir) {
|
|
|
62
62
|
return out;
|
|
63
63
|
}
|
|
64
64
|
// @comment -- "Reads and validates one harness settings file and decides which of bravos's hook groups must be appended and which superseded bravos commands removed; writes nothing so every file can be validated before any write."
|
|
65
|
-
function planRegistration(root, rel, regs) {
|
|
65
|
+
function planRegistration(root, rel, regs, drops = []) {
|
|
66
66
|
const abs = join(root, rel);
|
|
67
67
|
let doc = {};
|
|
68
68
|
if (existsSync(abs)) {
|
|
@@ -106,6 +106,23 @@ function planRegistration(root, rel, regs) {
|
|
|
106
106
|
hooks[reg.event] = [...groups, reg.group];
|
|
107
107
|
changed = true;
|
|
108
108
|
}
|
|
109
|
+
// @comment -- "Old-name commands for hooks this sync does not register again (the pre-PR gate or autopilot under the old name) point at scripts the migration removed; drop them from this agent's settings, and any group they leave empty. Only exact old-name commands are touched."
|
|
110
|
+
for (const { event, commands } of drops) {
|
|
111
|
+
if (!Array.isArray(hooks[event]))
|
|
112
|
+
continue;
|
|
113
|
+
const gone = new Set(commands);
|
|
114
|
+
const before = JSON.stringify(hooks[event]);
|
|
115
|
+
const groups = hooks[event]
|
|
116
|
+
.map((g) => (isObject(g) && Array.isArray(g.hooks) ? { ...g, hooks: g.hooks.filter((h) => !(isObject(h) && typeof h.command === 'string' && gone.has(h.command))) } : g))
|
|
117
|
+
.filter((g) => !(isObject(g) && Array.isArray(g.hooks) && g.hooks.length === 0));
|
|
118
|
+
if (JSON.stringify(groups) === before)
|
|
119
|
+
continue;
|
|
120
|
+
if (groups.length)
|
|
121
|
+
hooks[event] = groups;
|
|
122
|
+
else
|
|
123
|
+
delete hooks[event];
|
|
124
|
+
changed = true;
|
|
125
|
+
}
|
|
109
126
|
if (changed)
|
|
110
127
|
doc.hooks = hooks;
|
|
111
128
|
return { file: rel, changed, doc };
|
|
@@ -162,13 +179,18 @@ export function installHook(root, harnesses, opts = {}) {
|
|
|
162
179
|
const src = opts.hooksDir ?? packageHooksDir();
|
|
163
180
|
const files = listFiles(src).map((abs) => relative(src, abs).split('\\').join('/')).sort();
|
|
164
181
|
const copied = files.map((f) => `.bravos/hooks/${f}`);
|
|
182
|
+
const withPrePr = (opts.prePr || opts.autopilot) && !opts.globalHome;
|
|
183
|
+
const withAutopilot = opts.autopilot && !opts.globalHome;
|
|
165
184
|
const plans = [...new Set(harnesses)].map((h) => planRegistration(root, SETTINGS_FILE[h], [
|
|
166
185
|
sessionStart(h, opts.globalHome),
|
|
167
|
-
...(
|
|
168
|
-
...(
|
|
186
|
+
...(withPrePr ? [PRE_PR] : []),
|
|
187
|
+
...(withAutopilot ? [AUTOPILOT] : []),
|
|
188
|
+
], [
|
|
189
|
+
...(withPrePr ? [] : [{ event: 'PreToolUse', commands: [OLD_HOOK_COMMANDS.prePr] }]),
|
|
190
|
+
...(withAutopilot ? [] : [{ event: 'Stop', commands: [OLD_HOOK_COMMANDS.autopilot] }]),
|
|
169
191
|
]));
|
|
170
|
-
// Antigravity
|
|
171
|
-
if (harnesses.includes('agents') && !opts.globalHome)
|
|
192
|
+
// @comment -- "Antigravity may share skills with Codex, but explicit selection controls its hook independently. Legacy callers retain detection-based registration."
|
|
193
|
+
if ((opts.antigravity ?? harnesses.includes('agents')) && !opts.globalHome)
|
|
172
194
|
plans.push(planAgy(root));
|
|
173
195
|
if (!opts.dryRun) {
|
|
174
196
|
for (const f of files) {
|
|
@@ -14,8 +14,8 @@ export function proofToolAction(name, pins = PROOF_TOOL_PINS) {
|
|
|
14
14
|
? `build GuardLink from ${repository} at ${revision} with git and npm, then install its packed CLI globally`
|
|
15
15
|
: `npm install --global guardlink@${version}`;
|
|
16
16
|
return revision
|
|
17
|
-
? `cargo install --locked --force --git ${repository} --rev ${revision} cert-x-gen
|
|
18
|
-
: `cargo install --locked --force --version =${version} cert-x-gen
|
|
17
|
+
? `cargo install --locked --force --git ${repository} --rev ${revision} cert-x-gen `
|
|
18
|
+
: `cargo install --locked --force --version =${version} cert-x-gen `;
|
|
19
19
|
}
|
|
20
20
|
const prerequisites = {
|
|
21
21
|
git: 'install Git and make git available on PATH',
|
|
@@ -57,7 +57,7 @@ export function installProofTool(name, env, echo, pins = PROOF_TOOL_PINS) {
|
|
|
57
57
|
cargo: 'Check cargo and rustc, the native linker, network access and the Cargo install root.',
|
|
58
58
|
git: 'Check Git and network access to the public upstream repository.',
|
|
59
59
|
npm: 'Check Node and npm, registry access, tar for grammar assets and permission to the global prefix.',
|
|
60
|
-
cxg: 'Check cxg
|
|
60
|
+
cxg: 'Check that cxg runs and that its Python environment is writable.',
|
|
61
61
|
};
|
|
62
62
|
throw new BravosError(name + ' setup failed during ' + step + ' (' + detail + '). ' + hints[command] + ' Retry with bravos setup --tools -y.');
|
|
63
63
|
}
|
|
@@ -105,10 +105,8 @@ export function installProofTool(name, env, echo, pins = PROOF_TOOL_PINS) {
|
|
|
105
105
|
const destination = name === 'guardlink' ? 'the bin directory under npm prefix --global' : 'the bin directory under your Cargo install root (normally ~/.cargo/bin)';
|
|
106
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
107
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
invoke('cxg', ['--disable-update-check', 'pentest', 'update'], work, 'synchronizing the embedded pentest pipeline');
|
|
111
|
-
}
|
|
108
|
+
// Bravos drives cxg only through `cxg scan`, whose first probe run installs or refreshes cxg's
|
|
109
|
+
// embedded pipeline itself; no `cxg pentest` command is run here.
|
|
112
110
|
return found;
|
|
113
111
|
}
|
|
114
112
|
finally {
|
package/dist/setup.js
CHANGED
|
@@ -152,8 +152,17 @@ export async function runSast(root, env, opts = {}) {
|
|
|
152
152
|
}
|
|
153
153
|
writeFileSync(join(runDir, 'meta.json'), JSON.stringify({ sha, base: null, scope: opts.scope?.length ? opts.scope.join(',') : 'all', exit: r.status, at: new Date().toISOString(), analyzer: bin, codegraph }, null, 2) + '\n');
|
|
154
154
|
const lines = [`SAST run ${run}: bravos-cli exited ${r.status ?? 'by signal'} (0 clean at the level, 1 findings, 3 licence refused or analysis failed, 4 a stage failed)`, ` report: ${join(runDir, 'report.json')}`, ...notes];
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
// @comment -- "Keep analyzer diagnostics in the gitignored run folder with owner-only permissions, including warnings on exit 0/1. Failure summaries show both ends so trailing progress cannot hide the cause; spawn errors have no stderr."
|
|
156
|
+
if (r.stderr) {
|
|
157
|
+
const stderrPath = join(runDir, 'analyzer.stderr.log');
|
|
158
|
+
writeFileSync(stderrPath, r.stderr, { mode: 0o600 });
|
|
159
|
+
lines.push(` analyzer stderr: ${stderrPath}`);
|
|
160
|
+
}
|
|
161
|
+
if (r.status !== 0 && r.status !== 1) {
|
|
162
|
+
const detail = (r.stderr?.trim() || r.error?.message || r.stdout?.trim() || `terminated by ${r.signal ?? 'unknown signal'}`).split('\n');
|
|
163
|
+
const summary = detail.length > 20 ? [...detail.slice(0, 10), '… (full stderr in the run log)', ...detail.slice(-10)] : detail;
|
|
164
|
+
lines.push(` analyzer failed: ${summary.map((line) => line.slice(0, 1000)).join('\n ')}`);
|
|
165
|
+
}
|
|
157
166
|
lines.push(' next: bravos sast candidates');
|
|
158
167
|
return { dir: runDir, exit: r.status, lines };
|
|
159
168
|
}
|
package/dist/start/index.js
CHANGED
|
@@ -231,10 +231,18 @@ async function flow(opts, d) {
|
|
|
231
231
|
s.proving = 'none';
|
|
232
232
|
return;
|
|
233
233
|
}
|
|
234
|
+
// @comment -- "Automatic replay needs an origin default grant. Detect a missing or dangling pointer before offering consent, and show the repair without changing Git configuration."
|
|
235
|
+
const defaultRef = d.exec('git', ['symbolic-ref', '--quiet', 'refs/remotes/origin/HEAD'], { cwd: s.repo });
|
|
236
|
+
const autoReady = defaultRef.code === 0 && !!defaultRef.out.trim()
|
|
237
|
+
&& d.exec('git', ['rev-parse', '--verify', `${defaultRef.out.trim()}^{commit}`], { cwd: s.repo }).code === 0;
|
|
238
|
+
if (!autoReady)
|
|
239
|
+
p.warn('Automatic proving is unavailable: origin/HEAD is missing or unresolved. Fetch the default branch, then run git remote set-head origin --auto (or git remote set-head origin <branch>), and run bravos start --again. Use Ask me every time for a local clone.');
|
|
234
240
|
const choices = [
|
|
235
241
|
{ value: 'ask', label: 'Ask me every time before testing', recommended: true },
|
|
236
|
-
|
|
237
|
-
|
|
242
|
+
...(autoReady ? [
|
|
243
|
+
{ value: 'auto', label: 'Test my local app as I build', hint: 'includes scoped tests written by this agent' },
|
|
244
|
+
{ value: 'auto-reviewed', label: 'Automatically replay reviewed kits only', hint: 'uses the tested kit version on the default branch' },
|
|
245
|
+
] : []),
|
|
238
246
|
...(s.schedule !== 'none' && s.nightlyAgent !== 'copilot' ? [{ value: 'schedule', label: 'Only in the scheduled run' }] : []),
|
|
239
247
|
{ value: 'none', label: 'Never test, just annotate' },
|
|
240
248
|
];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Upgrading Bravos
|
|
2
|
+
|
|
3
|
+
After `npm install -g @bugb-technologies/bravos`, run **`bravos setup --tools -y`** once on each machine and **`bravos sync`** in each repository. The notes below say what else changes, newest first.
|
|
4
|
+
|
|
5
|
+
## 1.4.2
|
|
6
|
+
|
|
7
|
+
- **Bravos tests only with `cxg scan`.** It never runs `cxg pentest run`, `cxg scan --pentest` or cxg's model generation; every probe is written and reviewed in your agent's session. Electron apps run through `cxg scan --target-type electron` with `--app-cmd` or `--app-binary`, and Tauri's in-process proof through `--tauri-prove`. Test logins still use `cxg pentest auth`.
|
|
8
|
+
- **Setup no longer runs `cxg pentest install` or `update`.** The first `cxg scan` that runs a probe installs or refreshes cxg's pipeline itself. Browser probes still need cxg's Python requirements and Playwright Chromium where they run.
|
|
9
|
+
- **A probe that needs no login** declares `@requires_identities: {}` (or `@requires_auth_count: 0`); without it, cxg expects one captured login and refuses the probe.
|
|
10
|
+
- **`--agent` is exact.** Only the agents you name get hooks and files; Cursor, omp and opencode files are left alone unless selected. Leave `--agent` out to keep detecting them.
|
|
11
|
+
- **New repositories use GuardLink's default annotation mode**, which is external `.gal` sidecars, unless you pass `--guardlink-mode inline`. Existing repositories keep theirs.
|
|
12
|
+
- **Old `joseph` installs migrate** under `bravos start` and `bravos sync --agent …` too. Dead old-name hook entries are dropped from the agents you select; an agent you did not select that still runs the old `.joseph/hooks` scripts is named, with the command that fixes it.
|
|
13
|
+
- **SAST failures show their cause**, and the analyzer's full error output stays in the run's folder under `.bravos/sast/`.
|
|
14
|
+
- **Testing a clone of someone else's project:** a one-time loopback test (`run-once`, with your typed authorization) may use a policy and scope committed only in your clone.
|
|
15
|
+
|
|
16
|
+
## 1.4.1
|
|
17
|
+
|
|
18
|
+
- `bravos setup` fetches analyzer 0.6.2 (Team plan), whose reachability matches the code graph and whose own GuardLink pin is 2.6.0.
|
|
19
|
+
- `bravos sast run` starts only with the GuardLink `bravos setup --tools -y` installs on PATH, so SAST and the rest of Bravos read the threat model with the same GuardLink.
|
|
20
|
+
|
|
21
|
+
## 1.4.0
|
|
22
|
+
|
|
23
|
+
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.
|
|
24
|
+
|
|
25
|
+
1. **`bravos setup --tools -y`** installs GuardLink 2.6.0 and cxg 1.8.0, the first releases with the interfaces 1.4 uses; `bravos doctor` shows both as ready.
|
|
26
|
+
2. **`bravos sync`** 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.
|
|
27
|
+
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.
|
|
28
|
+
4. **Test kits written before 1.4** are reported as needing review and `bind`, and are not run until bound (bravos-templatize does it).
|
|
29
|
+
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.
|
|
30
|
+
6. Teammates **without a licence** see that autopilot and the pre-PR gate are installed but locked for them, with the trial command, instead of "on".
|
package/hooks/lib/briefing.mjs
CHANGED
|
@@ -170,6 +170,7 @@ export function buildBriefing(inputs) {
|
|
|
170
170
|
tail.push(p.status === 'set'
|
|
171
171
|
? `Proving: ${p.choice}${p.target ? ` on ${p.target}` : ''}${p.generation ? ', model-API probes allowed' : ''} (${p.by}, ${p.date}, .guardlink/proving.md)`
|
|
172
172
|
: 'Proving: not set — when proving comes up, ask the person once how they want it handled and record it (bravos-prove)');
|
|
173
|
+
if (p.status === 'set' && p.choice === 'auto' && i.defaultBranch === null) tail.push('Proving blocked: origin/HEAD is missing or unresolved. Fetch the default branch and run git remote set-head origin --auto (or git remote set-head origin <branch>); on a local clone, use an ask policy with run-once.');
|
|
173
174
|
}
|
|
174
175
|
if (i.shadow) {
|
|
175
176
|
tail.push(i.shadow.userNewer
|
|
@@ -335,13 +336,15 @@ export async function collect(root, env, { deadlineMs = 20000, nextCount = 3 } =
|
|
|
335
336
|
const base = ref || 'origin/main';
|
|
336
337
|
const name = branch && branch !== 'HEAD' ? branch : null;
|
|
337
338
|
const later = (args) => git(args, budget());
|
|
338
|
-
const [diff, behind, stranded] = await Promise.all([
|
|
339
|
+
const [diff, behind, stranded, defaultHead] = await Promise.all([
|
|
339
340
|
later(['diff', '--name-only', `${base}...HEAD`]),
|
|
340
341
|
gitStaleness(later, base),
|
|
341
342
|
strandedBranches(later, base, { current: name }),
|
|
343
|
+
ref ? later(['rev-parse', '--verify', `${ref}^{commit}`]) : null,
|
|
342
344
|
]);
|
|
343
345
|
return {
|
|
344
346
|
sha: sha ?? 'unknown',
|
|
347
|
+
defaultBranch: defaultHead ? ref : null,
|
|
345
348
|
base,
|
|
346
349
|
branch: name,
|
|
347
350
|
changedFiles: diff ? diff.split('\n').filter(Boolean) : [],
|
|
@@ -395,6 +398,7 @@ export async function collect(root, env, { deadlineMs = 20000, nextCount = 3 } =
|
|
|
395
398
|
repo: basename(root),
|
|
396
399
|
sha: facts.sha,
|
|
397
400
|
base: facts.base,
|
|
401
|
+
defaultBranch: facts.defaultBranch,
|
|
398
402
|
branch: facts.branch,
|
|
399
403
|
stale: facts.stale,
|
|
400
404
|
stranded: facts.stranded,
|
|
@@ -38,8 +38,14 @@ if ! test -x "$install_root/bin/cxg"; then
|
|
|
38
38
|
fi
|
|
39
39
|
export PATH="$install_root/bin:$PATH"
|
|
40
40
|
echo "$install_root/bin" >> "$GITHUB_PATH"
|
|
41
|
-
cxg
|
|
41
|
+
# Bravos runs cxg only through `cxg scan`: the first scan installs or refreshes cxg's embedded pipeline
|
|
42
|
+
# itself. The replay runner needs that pipeline's Python dependencies, taken from the cxg source the
|
|
43
|
+
# pinned binary was built from (its tag, or the pinned revision).
|
|
42
44
|
if test "$role" = replay; then
|
|
43
|
-
|
|
45
|
+
cxg_ref=${cxg_revision:-v$cxg_version}
|
|
46
|
+
requirements="$RUNNER_TEMP/cxg-requirements.txt"
|
|
47
|
+
curl --fail --silent --show-error --location --proto '=https' \
|
|
48
|
+
"https://raw.githubusercontent.com/Bugb-Technologies/cert-x-gen/$cxg_ref/pentest/requirements.txt" -o "$requirements"
|
|
49
|
+
"$CXG_PYTHON" -m pip install -r "$requirements"
|
|
44
50
|
"$CXG_PYTHON" -m playwright install --with-deps chromium
|
|
45
51
|
fi
|
package/hooks/lib/replay.mjs
CHANGED
|
@@ -47,13 +47,18 @@ function jsonTool(root, cmd, args) {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
// A named choice on this checkout can revoke permission immediately. Local edits never expand a committed grant.
|
|
50
|
-
function committedFile(root, file) {
|
|
50
|
+
function committedFile(root, file, defaultGrant = true) {
|
|
51
51
|
const path = localFile(root, file);
|
|
52
52
|
const current = readFileSync(path, 'utf8');
|
|
53
|
-
//
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
// @comment -- "Automatic and scheduled grants are bounded by the default branch. A typed loopback run-once authorization may use a tester's locally committed policy and scope on an upstream clone; dirty grants still fail the HEAD check."
|
|
54
|
+
if (defaultGrant && [POLICY, SCOPE].includes(file)) {
|
|
55
|
+
const remoteDefault = spawnSync('git', ['symbolic-ref', '--quiet', 'refs/remotes/origin/HEAD'], { cwd: root, encoding: 'utf8' });
|
|
56
|
+
if (remoteDefault.status === 0) {
|
|
57
|
+
const grant = spawnSync('git', ['show', `${remoteDefault.stdout.trim()}:${file}`], { cwd: root, encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 });
|
|
58
|
+
if (grant.status !== 0 || grant.stdout !== current) {
|
|
59
|
+
throw new Error(`${file} is missing from or differs from the default branch's recorded grant. On a clone, commit a local ask policy and scope, then use run-once with typed authorization.`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
57
62
|
}
|
|
58
63
|
if (git(root, ['show', `HEAD:${file}`]) !== current) throw new Error(`${file} differs from its reviewed commit.`);
|
|
59
64
|
return current;
|
|
@@ -194,12 +199,14 @@ function authority(root, mode, env) {
|
|
|
194
199
|
if (mode === 'run' && spawnSync('git', ['symbolic-ref', '--quiet', 'refs/remotes/origin/HEAD'], { cwd: root, encoding: 'utf8' }).status !== 0) {
|
|
195
200
|
throw new Error('Automatic replay needs the proving policy on a reviewed default branch, and this repository has no origin default (git remote set-head origin --auto). Without one, use run-once with the person\'s typed authorization.');
|
|
196
201
|
}
|
|
197
|
-
const
|
|
202
|
+
const runOnceTarget = mode === 'run-once' && env.BRAVOS_SCAN_TARGET ? new URL(env.BRAVOS_SCAN_TARGET) : null;
|
|
203
|
+
const localGrant = runOnceTarget !== null && loopback(runOnceTarget.hostname);
|
|
204
|
+
const policy = committedFile(root, POLICY, !localGrant);
|
|
198
205
|
const required = { run: 'auto', 'run-once': 'ask', scheduled: 'schedule' }[mode];
|
|
199
206
|
if (!/^—\s*confirmed by\s+[^,\n]+,\s*\S+/mi.test(policy) || policyValue(policy, 'choice') !== required) {
|
|
200
207
|
throw new Error(`Replay requires a confirmed ${required} proving policy: .guardlink/proving.md with choice: ${required} and a "— confirmed by <name>, <date>" line, recorded with bravos-prove and merged to the default branch.`);
|
|
201
208
|
}
|
|
202
|
-
const scopeText = committedFile(root, SCOPE);
|
|
209
|
+
const scopeText = committedFile(root, SCOPE, !localGrant);
|
|
203
210
|
const scope = parseScope(root, scopeText);
|
|
204
211
|
const named = policyValue(policy, 'target');
|
|
205
212
|
const raw = mode === 'run' ? named : env.BRAVOS_SCAN_TARGET;
|
|
@@ -492,6 +499,10 @@ export function replay(root, mode, names, env = process.env) {
|
|
|
492
499
|
const receipt = executeKit(root, mode, env, auth, permit, name, dir, runId);
|
|
493
500
|
receipts.push(receipt);
|
|
494
501
|
output(`${receipt.kitId}: ${receipt.observed || 'inconclusive or not run'}; ${receipt.recorded ? 'recorded in GuardLink' : 'no current claim recorded'}${receipt.reason ? ' (' + receipt.reason + ')' : ''} (CXG exit ${receipt.exit}).`, env);
|
|
502
|
+
// @comment -- "A recorded engine confirmation prompts deliberate regression curation; raw evidence and identity state stay private, and replay never writes a security test automatically."
|
|
503
|
+
if (receipt.recorded && receipt.observed === 'confirmed') {
|
|
504
|
+
output(`Offer to promote ${receipt.kit} into security/ (or the configured security_tests_dir) as a curated regression test. Review its scope, oracle and portability with the person first; keep credentials and raw evidence out of Git.`, env);
|
|
505
|
+
}
|
|
495
506
|
if (mode === 'scheduled' && env.GITHUB_STEP_SUMMARY) {
|
|
496
507
|
const details = `Receipt ${receipt.id}, class ${receipt.vulnClass}, claim ${receipt.claimKey}, ${receipt.build}; ` +
|
|
497
508
|
`${receipt.statuses.join(', ') || 'no HTTP status summary'}. Kit ${receipt.kitSha256}, build ${receipt.worktreeSha256}, evidence ${receipt.evidenceDigest}.\n`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bugb-technologies/bravos",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"description": "Skills pack and installer that make Claude Code and Codex power users of guardlink (threat-model-as-code) and cert-x-gen (pentest-as-code).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"security",
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
"skills",
|
|
24
24
|
"hooks",
|
|
25
25
|
"templates",
|
|
26
|
-
"docs/GUIDE.md"
|
|
26
|
+
"docs/GUIDE.md",
|
|
27
|
+
"docs/UPGRADING.md"
|
|
27
28
|
],
|
|
28
29
|
"engines": {
|
|
29
30
|
"node": ">=20"
|
|
@@ -14,9 +14,9 @@ description: "Bring up a test target the user owns and prepare it for an authori
|
|
|
14
14
|
|
|
15
15
|
1. Read the current proving choice before target contact, login or auth verification. Use the owned local app named in the standing authorization or the target explicitly authorized for this invocation. The default is a loopback address (`127.0.0.1`, `localhost`, `[::1]`). Start it with the repo's own tooling (its compose file, dev server script or desktop build) and wait until it answers. In a bravos workspace each service has its own target: take the URLs from `bravos workspace show` (set a missing one with `bravos workspace target <name> <service>=http://127.0.0.1:<port>`), bring up every service the test crosses, and list every service host in the reviewed scope's `host_allowlist`.
|
|
16
16
|
2. On loopback, a recorded proving preference (`.guardlink/proving.md`, `choice: auto`) is the person's go-ahead for its target: use the recorded target and start command. If the setup wizard left them empty, inspect the repository’s documented development command and listening address. When these match the app the person authorized, record the actual target and start command alongside their original words. Commit the policy and scope before automatic replay. Ask only if the target or authority is ambiguous. If the user names a non-loopback target, stop and get two things before going on: the host listed in a committed `scope.yaml` that has been through a reviewed PR, and the human's authorization typed by them in this session in their own words. Without both, the target is out of scope; say so and stay on loopback.
|
|
17
|
-
3. Write the scope. Copy `{{SKILL_DIR}}/scope.example.yaml` to `.guardlink/scope.yaml`,
|
|
17
|
+
3. Write the scope. Copy `{{SKILL_DIR}}/scope.example.yaml` to `.guardlink/scope.yaml`, then narrow `url_allowlist` to the routes under test. `method_allowlist` is a strict bound: cxg refuses every method it does not list, even with `--destructive-ok`, so a test that needs PUT, PATCH or DELETE needs the target's owner to add them in the reviewed PR; never add them yourself. Leave that field for the human to fill. Commit it and ship it as a PR for review before any non-loopback run.
|
|
18
18
|
4. Seed test data with the repo's own fixtures, seed scripts or admin endpoints: the roles and users the threats need, such as two users of different tenants for an ownership check. Name any test that needs production-like data as such, and run it only where that data is synthetic.
|
|
19
|
-
5. Get a session. On loopback, do it yourself: create the test accounts through the app's own signup, seed script or admin endpoint, write their
|
|
19
|
+
5. Get a session. On loopback, do it yourself: create the test accounts through the app's own signup, seed script or admin endpoint, write their login identity and secret to a gitignored file under `.bravos/`, and log in with `cxg pentest auth --target <url> --profile <name> --creds-file <file> --login-path <login route>`, one profile per identity a check needs. For a bearer-token API, check `cxg pentest auth --help` for dynamic-login support. Add `--login-user-field username` and `--login-pass-field password` when names differ (dotted paths support nested JSON), `--login-encoding form` for URL-encoded login, or `--login-body` for extra JSON fields; credential paths override those fields. Omit `--login-token-source` to discover the token by shape from the login response and save an `Authorization: Bearer` header profile; steer discovery only when needed with `--login-token-source json:/access_token` or `--login-token-source header:Authorization`. Capture each identity separately; probes use these profiles instead of minting their own tokens. For SSO, MFA or other browser-only login, drive signup and login in your own browser tool and capture the session interactively with `cxg pentest auth --target <url> --profile <name>`. For an authorized non-loopback target, ask the human to capture the session in their own browser with the same command, or to paste a storage state you import with `cxg pentest auth import --storage-state <file> --profile <name> --target <url>`; CI uses the import with a session the human exported once.
|
|
20
20
|
6. Verify the target URL and scope against the current recorded policy before sending any request. For a fresh local build or launch from this repository, capture the matching worktree witness at that time with `bravos hook replay build <loopback-url>`. Pass that output to bravos-prove in BRAVOS_REPLAY_BUILD, recording the actual target and revision. A hash computed beside a previously running app does not establish which code it serves. If a remote or already-running service cannot be tied to this build, report observations without updating the current claim. Confirm each required session is live with `cxg pentest auth verify --profile <name>` before handing the target on, so a run never spends its budget unauthenticated.
|
|
21
21
|
7. Record the target URL, the profile names, the scope path and whether the target is loopback, and hand them to bravos-prove.
|
|
22
22
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
# bravos starter scope for cxg
|
|
1
|
+
# bravos starter scope for cxg scan — loopback only.
|
|
2
2
|
#
|
|
3
3
|
# Copy to .guardlink/scope.yaml, commit it, and get it reviewed in a PR before any run.
|
|
4
|
-
#
|
|
4
|
+
# cxg reads it through `cxg scan --scope-file`; each field below is explained where it is set.
|
|
5
5
|
#
|
|
6
6
|
# This starter allows only the read-mostly methods, a small budget, and no disposable-host
|
|
7
7
|
# grants, so destructive probe classes stay limited to a loopback target. Widening any of
|
|
@@ -13,17 +13,17 @@ description: "Prove a new or changed GuardLink claim, or replay it after a fix,
|
|
|
13
13
|
## Do
|
|
14
14
|
|
|
15
15
|
1. Check the preconditions from bravos-env before any traffic: authorization for this run, a target that answers, `.guardlink/scope.yaml` committed, each profile passing `cxg pentest auth verify --profile <name>`, and for any non-loopback target both a reviewed scope and the human's authorization typed in this session. If one is missing, stop and hand back to bravos-env. Read the effort: the user's words ("at high"), else a `bravos effort: <level>` line in `AGENTS.md` / `CLAUDE.md`, else medium. It sets a starting budget, not a limit; go beyond it when the work needs it and say why in one line. Starting budget — low: replay a matching kit; medium: also author the first missing test in this session; high: include affected callers and controls; max: cover the testable in-scope queue. A higher effort does not authorize spending on an external model.
|
|
16
|
-
2. Order what to test, then read how the person wants proving handled. With the code graph (its MCP tools, or `bravos graph <question> --json` — same answers; see bravos-codegraph) (briefing `Code graph:` says `current`): `codegraph_untested_exposures` and `codegraph_untested_reach` rank untested exposures by reach; test the ones intent.md's Assumptions put in scope first, least privileged entry point first, and report exposures only an out-of-scope attacker reaches instead of running them. Without the graph, say "code graph unavailable; using guardlink hypothesis next order" and use that queue. Within that order, an exposure with a reachable SAST finding joined to it (`bravos sast candidates`) goes before one without, and its route goes into the run notes; with no SAST report or SAST unavailable, skip this. Then, for how the person wants proving handled: the briefing's `Proving:` line, from `.guardlink/proving.md`. If it is not set, ask them once, with a suggestion drawn from the repo (for example, "you have a docker-compose; I'd prove automatically on 127.0.0.1:8080"): prove automatically on their loopback target whenever new or changed exposures appear, ask each time, on a schedule (bravos-schedule's nightly), or not now; and whether cxg may generate probes through a model API, which spends money. Record their answer in `.guardlink/proving.md`: lines `choice: auto|ask|schedule|none`, `target: <loopback url>`, `start: <start command>`, `generation: yes|no`, their words quoted verbatim, and `— confirmed by <their name>, <date>`. Then follow it: `auto` proceeds on that target with their quoted words as the attestation and, with `generation: yes`, the spend approved; `ask` asks now; `schedule` hands to bravos-schedule; `none` stops here and says so. When they change their mind, rewrite the file with their new words.
|
|
16
|
+
2. Order what to test, then read how the person wants proving handled. With the code graph (its MCP tools, or `bravos graph <question> --json` — same answers; see bravos-codegraph) (briefing `Code graph:` says `current`): `codegraph_untested_exposures` and `codegraph_untested_reach` rank untested exposures by reach; test the ones intent.md's Assumptions put in scope first, least privileged entry point first, and report exposures only an out-of-scope attacker reaches instead of running them. Without the graph, say "code graph unavailable; using guardlink hypothesis next order" and use that queue. Within that order, an exposure with a reachable SAST finding joined to it (`bravos sast candidates`) goes before one without, and its route goes into the run notes; with no SAST report or SAST unavailable, skip this. Then, for how the person wants proving handled: the briefing's `Proving:` line, from `.guardlink/proving.md`. If it is not set, ask them once, with a suggestion drawn from the repo (for example, "you have a docker-compose; I'd prove automatically on 127.0.0.1:8080"): prove automatically on their loopback target whenever new or changed exposures appear, ask each time, on a schedule (bravos-schedule's nightly), or not now; and whether cxg may generate probes through a model API, which spends money. Record their answer in `.guardlink/proving.md`: lines `choice: auto|ask|schedule|none`, `target: <loopback url>`, `start: <start command>`, `generation: yes|no`, their words quoted verbatim, and `— confirmed by <their name>, <date>`. Before offering or following `auto`, check that `git symbolic-ref --quiet refs/remotes/origin/HEAD` names an existing commit. If missing, warn: fetch the default branch, then `git remote set-head origin --auto` (or `git remote set-head origin <branch>`); use `ask` meanwhile. Then follow it: `auto` proceeds on that target with their quoted words as the attestation and, with `generation: yes`, the spend approved; `ask` asks now; `schedule` hands to bravos-schedule; `none` stops here and says so. When they change their mind, rewrite the file with their new words.
|
|
17
17
|
3. Read the affected claim from `guardlink hypothesis list --json`. Include a declared mitigation awaiting its first test and a previously confirmed claim now marked retest. Match its key to the logical source location in `guardlink sarif . --profile pentest -o whitebox/findings.sarif`; external annotations also have a physical declaration in a .gal file. Keep both locations. Record the tested source revision or worktree, application build, identity roles and intended oracle.
|
|
18
|
-
4. For a web claim, use its bound JavaScript kit in .guardlink/cxg-replay/. For a missing or mismatched kit, follow bravos-templatize in this session. A matching kit exercises the intended operation and includes a positive control for a claimed defense. Validate the kit and review its scope. Honor the recorded kit policy and the person’s stated limits. An automatic reviewed-only policy requires identical bound test bytes on the default branch
|
|
18
|
+
4. For a web claim, use its bound JavaScript kit in .guardlink/cxg-replay/. For a missing or mismatched kit, follow bravos-templatize in this session. A matching kit exercises the intended operation and includes a positive control for a claimed defense. Validate the kit and review its scope. Honor the recorded kit policy and the person’s stated limits. An automatic reviewed-only policy requires identical bound test bytes on the default branch. On a clone whose upstream has no testing policy, use `ask` with locally committed policy and scope and typed authorization for loopback `run-once`. The earlier wizard’s “only replay tests I approved” choice retains that restriction.
|
|
19
19
|
5. Pass the build witness that bravos-env captured at launch in BRAVOS_REPLAY_BUILD. Without fresh build provenance, retain the observation and leave the current-code claim pending. Under a recorded automatic loopback policy, run `bravos hook replay run <kit.js>`. For a one-time approved run under an ask policy, use `bravos hook replay run-once <kit.js>` with the target in BRAVOS_SCAN_TARGET and the person's exact words in BRAVOS_REPLAY_ATTESTATION for that invocation. Keep private identity state outside Git. A scheduled-only policy hands the kit to bravos-schedule. A disabled policy leaves the claim pending. The helper selects one file through plain CXG scan with model authoring disabled. Only evidence tied to the exact claim, tested source and kit is eligible for writeback.
|
|
20
20
|
6. Read the individual native CXG execution and ledger result. A reproduced exploit needs an engine-adjudicated confirmation. A held control needs observed denial and a working positive control. Missing roles, ambiguous tests, incomplete imports, a different target build or stale inputs stay pending with the reason. Exit 4 can include both a refusal and valid results from other probes. An ordinary scanner's template-reported match is a lead for a runtime test. Keep private HTTP and auth material out of reports and commits.
|
|
21
|
-
7. For workspaces, bind each hop to its own service URL and authorized scope.
|
|
22
|
-
8. Report which claims were confirmed or refuted, which still need testing and which were actually recorded. Keep the run ID and
|
|
21
|
+
7. For workspaces, bind each hop to its own service URL and authorized scope. Every run is plain `cxg scan`, through the replay helper or directly with the same scope, attestation and identities: for Electron add `--target-type electron` with `--app-cmd` or `--app-binary` and the verified desktop profile; for Tauri's in-process proof add `--tauri-prove`. Ordinary network or local CLI scanner templates use the scanner contract and produce leads. Probes are written in this session by bravos-templatize, never generated by cxg. Use the reviewed scope, approved target and identities, and keep the native evidence separate. For an independently stamped result, the GuardLink import is `guardlink hypothesis confirm --from-scan <native-report.json> --write`; check every intended claim key and tested anchor, import only an uncontested exact match, and reread the ledger. A missing key, changed build or failed write is unrecorded. Boundary outcomes use GuardLink's boundary ledger.
|
|
22
|
+
8. Report which claims were confirmed or refuted, which still need testing and which were actually recorded. After a recorded engine confirmation, offer to promote the verified kit into `security/` (or `.guardlink/config.json`'s `security_tests_dir`) as a curated regression test. With the person's agreement, review its scope, stable oracle and runner, then retain only portable test code; keep credentials and raw run evidence outside Git. Confirmation alone never promotes a kit. Keep the run ID and replay kit for bravos-recheck.
|
|
23
23
|
|
|
24
24
|
## Never
|
|
25
25
|
|
|
26
|
-
-
|
|
26
|
+
- Run `cxg pentest run`, `cxg scan --pentest` or any of cxg's model generation (its ai command, or an AI provider flag): Bravos tests only with `cxg scan`, and the probes it runs are the ones written and reviewed in this session.
|
|
27
27
|
- Run against a host outside the committed scope, or without the human's typed authorization when the target is not loopback.
|
|
28
28
|
- Write `--attestation` text the human did not type, here or in `.guardlink/proving.md`.
|
|
29
29
|
- Record a proving preference the person did not state, or read one as covering more than it says: it never covers a non-loopback target or a destructive class.
|
|
@@ -17,7 +17,7 @@ description: "Turn the threat model's open exposures into correct, testable cxg
|
|
|
17
17
|
3. Find the request that reaches each sink before you write its template. With the code graph (its MCP tools, or `bravos graph <question> --json` — same answers; see bravos-codegraph) (the briefing's `Code graph:` line says `current`, or `diverged` until a `no-exec` rebuild, bravos-codegraph step 2): `codegraph_call_chain` from the entry points (`codegraph_entry_points`, `codegraph_routes`) to the claim's symbol gives the route or RPC method, its handler and the parameters that flow into the sink; `codegraph_auth_boundary` on that route gives the identity the request needs (anonymous, a signed-in tenant, admin). Target that route with those parameters and the matching auth profile, put the chain (entry → … → sink) in the template's notes, and when several entry points reach the sink template the least privileged first. When `codegraph_entry_reach` says no entry point reaches it at high confidence, write no template: record "unreachable from any entry point per code graph" in the README and hand the claim to bravos-annotate to re-rate. Read `verdict` and `confidence` first; `unknown` or `insufficient_resolution` is not determined, never unreachable. Without the graph, trace the route from the handler by reading the code and say "code graph unavailable; traced by reading". A SAST finding joined to the claim (`bravos sast candidates`) gives its `route`, `entryPoint` and taint path too; use it alongside the graph's chain, and note it in the template. SAST findings not in the threat model go to bravos-annotate first, since templates come from claims. With no SAST report or SAST unavailable, carry on without it.
|
|
18
18
|
4. Write the templates under `.guardlink/cxg-templates/`, one per threat, following the engine contract and evidence shape the method gives. Keep every check non-destructive and scoped to confirming its one threat. Scanner templates (YAML, Python, shell) go there; JavaScript probes (`async function cxgProbe(cxg)`, `--contract probe`) go under `.guardlink/cxg-replay/` instead, because `cxg scan --template-dir` runs any probe it finds under cxg's default scope, not `.guardlink/scope.yaml`. In a probe, reach the target only through `cxg.fetch*` with well-formed arguments: cxg refuses at run time a probe that uses WebSocket, XMLHttpRequest, EventSource, `navigator.sendBeacon`, dynamic `import()`, or script or `innerHTML` injection, and `cxg template validate` does not catch it.
|
|
19
19
|
5. Validate: `cxg template validate .guardlink/cxg-templates/ --recursive --json`, and the same for `.guardlink/cxg-replay/`. It exits 1 when any template fails; a banner line can precede the JSON, so read from the first `{` or `[`. Fix each error and rerun until it reports none.
|
|
20
|
-
6. Record repo context for
|
|
20
|
+
6. Record repo context for the probes you write. Copy `{{SKILL_DIR}}/operator-guidance.md` to `.guardlink/operator-guidance.md` if it is not there, and fill each section from the code: framework, auth shape, test identities, known false positives, out-of-bounds routes. Read it before writing each kit; cxg never generates probes for this repository.
|
|
21
21
|
7. For a first test or regression kit, write a single JavaScript probe in .guardlink/cxg-replay/. Include an exact `// @guardlink_threat: threat@logical/file:line`, `// @attach_scheme: path`, the required identity names, and a precise test with a positive control. Run `bravos hook replay bind <kit.js>` before executing it. The binding command associates the kit with the key of the current GuardLink exposure. Review that mapping when the claim is edited or moved. Leave native CXG identity stamps to the engine.
|
|
22
22
|
8. Apply the oracle rule: a vulnerability class cxg cannot judge from a response has no oracle. Record it in `.guardlink/cxg-templates/README.md` as unsupported, with the threat id and why, instead of writing a template that pretends to prove it. An invariant threat (`#inv-…`, from intent.md) maps to the cxg class that can judge it: another user's or tenant's data → `idor`; a role or permission gained → `privilege_escalation`; a field the caller should not set → `mass_assignment`; a check bypassed by concurrent requests → `race_condition`; a workflow step skipped or reordered → `business_logic`. Record each invariant's class in the README.
|
|
23
23
|
9. Commit the templates, the README and the filled guidance together, and hand the template ids and threat ids to bravos-prove.
|
|
@@ -45,4 +45,4 @@ description: "Turn the threat model's open exposures into correct, testable cxg
|
|
|
45
45
|
## Go deeper
|
|
46
46
|
|
|
47
47
|
- `{{SKILLS_ROOT}}/guardlink-translate/SKILL.md` — the translate method and the engine contract.
|
|
48
|
-
- `{{SKILL_DIR}}/operator-guidance.md` — what
|
|
48
|
+
- `{{SKILL_DIR}}/operator-guidance.md` — what a probe for this repo needs to know: routing, auth shape, identities, false positives, bounds.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# Operator guidance for
|
|
1
|
+
# Operator guidance for probes (this repository)
|
|
2
2
|
|
|
3
|
-
Copy to `.guardlink/operator-guidance.md
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Copy to `.guardlink/operator-guidance.md` and fill in each section from what the code actually does.
|
|
4
|
+
The agent reads it before writing each JavaScript probe that `cxg scan` runs, so keep it factual and
|
|
5
|
+
short. cxg never generates probes for this repository.
|
|
6
6
|
|
|
7
7
|
## Framework and routing
|
|
8
8
|
<!-- e.g. Express 4 with routers mounted in src/server.ts; Next.js app router under app/api -->
|