@rafter-security/cli 0.7.7 → 0.8.0
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 +27 -681
- package/dist/commands/agent/baseline.js +15 -15
- package/dist/commands/agent/components.js +282 -138
- package/dist/commands/agent/index.js +2 -2
- package/dist/commands/agent/init.js +564 -174
- package/dist/commands/agent/scan.js +76 -47
- package/dist/commands/agent/status.js +19 -10
- package/dist/commands/agent/update-betterleaks.js +39 -0
- package/dist/commands/agent/verify.js +230 -29
- package/dist/commands/brief.js +13 -45
- package/dist/commands/completion.js +15 -15
- package/dist/commands/issues/from-scan.js +6 -3
- package/dist/commands/mcp/server.js +11 -11
- package/dist/core/config-manager.js +6 -0
- package/dist/core/custom-patterns.js +86 -4
- package/dist/core/policy-loader.js +60 -1
- package/dist/scanners/{gitleaks.js → betterleaks.js} +49 -61
- package/dist/scanners/regex-scanner.js +4 -5
- package/dist/scanners/secret-patterns.js +1 -1
- package/dist/utils/binary-manager.js +205 -109
- package/dist/utils/skill-manager.js +96 -16
- package/package.json +1 -1
- package/resources/agents/rafter.md +81 -0
- package/resources/continue-rules/rafter-code-review.md +15 -0
- package/resources/continue-rules/rafter-secure-design.md +15 -0
- package/resources/continue-rules/rafter-skill-review.md +15 -0
- package/resources/continue-rules/rafter.md +16 -0
- package/resources/cursor-rules/rafter-code-review.mdc +14 -0
- package/resources/cursor-rules/rafter-secure-design.mdc +14 -0
- package/resources/cursor-rules/rafter-skill-review.mdc +14 -0
- package/resources/cursor-rules/rafter.mdc +15 -0
- package/resources/rafter-security-skill.md +18 -10
- package/resources/skills/rafter/SKILL.md +1 -1
- package/resources/skills/rafter/docs/cli-reference.md +5 -5
- package/resources/windsurf-rules/rafter-code-review.md +14 -0
- package/resources/windsurf-rules/rafter-secure-design.md +14 -0
- package/resources/windsurf-rules/rafter-skill-review.md +14 -0
- package/resources/windsurf-rules/rafter.md +15 -0
- package/dist/commands/agent/update-gitleaks.js +0 -40
|
@@ -1,21 +1,34 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
2
|
import { BinaryManager } from "../../utils/binary-manager.js";
|
|
3
3
|
import { SkillManager } from "../../utils/skill-manager.js";
|
|
4
|
+
import { spawnSync } from "child_process";
|
|
4
5
|
import fs from "fs";
|
|
5
6
|
import path from "path";
|
|
6
7
|
import os from "os";
|
|
8
|
+
import yaml from "js-yaml";
|
|
7
9
|
import { fmt } from "../../utils/formatter.js";
|
|
8
|
-
async function
|
|
10
|
+
async function checkBetterleaks() {
|
|
9
11
|
const binaryManager = new BinaryManager();
|
|
10
|
-
const name = "
|
|
12
|
+
const name = "Betterleaks";
|
|
11
13
|
// Check PATH first (e.g. Homebrew), then fall back to ~/.rafter/bin
|
|
12
|
-
const pathBinary = binaryManager.
|
|
13
|
-
const hasBinary = pathBinary !== null || binaryManager.
|
|
14
|
+
const pathBinary = binaryManager.findBetterleaksOnPath();
|
|
15
|
+
const hasBinary = pathBinary !== null || binaryManager.isBetterleaksInstalled();
|
|
14
16
|
if (!hasBinary) {
|
|
15
|
-
|
|
17
|
+
// Soft-degrade if a legacy gitleaks install is still present — the user
|
|
18
|
+
// upgraded rafter but hasn't rerun `agent init --with-betterleaks` yet.
|
|
19
|
+
const legacy = binaryManager.findLegacyGitleaks();
|
|
20
|
+
if (legacy) {
|
|
21
|
+
return {
|
|
22
|
+
name,
|
|
23
|
+
passed: false,
|
|
24
|
+
optional: true,
|
|
25
|
+
detail: `Not installed; found legacy gitleaks at ${legacy}. Run: rafter agent update-betterleaks`,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
return { name, passed: false, detail: `Not found on PATH or at ${binaryManager.getBetterleaksPath()}` };
|
|
16
29
|
}
|
|
17
|
-
const binaryPath = pathBinary ?? binaryManager.
|
|
18
|
-
const { ok, stdout, stderr } = await binaryManager.
|
|
30
|
+
const binaryPath = pathBinary ?? binaryManager.getBetterleaksPath();
|
|
31
|
+
const { ok, stdout, stderr } = await binaryManager.verifyBetterleaksVerbose(binaryPath);
|
|
19
32
|
if (!ok) {
|
|
20
33
|
const diag = await binaryManager.collectBinaryDiagnostics(binaryPath);
|
|
21
34
|
return { name, passed: false, detail: `Binary found at ${binaryPath} but failed to execute\n${stdout ? ` stdout: ${stdout}\n` : ""}${stderr ? ` stderr: ${stderr}\n` : ""}${diag}` };
|
|
@@ -51,8 +64,10 @@ function checkClaudeCode() {
|
|
|
51
64
|
}
|
|
52
65
|
try {
|
|
53
66
|
const settings = JSON.parse(fs.readFileSync(settingsPath, "utf-8"));
|
|
67
|
+
// Substring match — Python install writes an absolute path
|
|
68
|
+
// (/home/foo/bin/rafter hook pretool), Node writes the bare command.
|
|
54
69
|
const hooks = settings?.hooks?.PreToolUse || [];
|
|
55
|
-
const hasRafterHook = hooks.some((entry) => (entry.hooks || []).some((h) => h
|
|
70
|
+
const hasRafterHook = hooks.some((entry) => (entry.hooks || []).some((h) => String(h?.command ?? "").includes("rafter hook pretool")));
|
|
56
71
|
if (!hasRafterHook) {
|
|
57
72
|
return { name, passed: false, optional: true, detail: "Rafter hooks not installed — run 'rafter agent init --with-claude-code'" };
|
|
58
73
|
}
|
|
@@ -69,6 +84,16 @@ function checkOpenClaw() {
|
|
|
69
84
|
return { name, passed: false, optional: true, detail: `Not detected — run 'rafter agent init --with-openclaw' to enable` };
|
|
70
85
|
}
|
|
71
86
|
if (!skillManager.isRafterSkillInstalled()) {
|
|
87
|
+
// rf-zgwj: surface the legacy install path so users on rafter ≤ 0.7.7
|
|
88
|
+
// know they need to re-run to migrate.
|
|
89
|
+
if (skillManager.hasLegacyRafterSkill()) {
|
|
90
|
+
return {
|
|
91
|
+
name,
|
|
92
|
+
passed: false,
|
|
93
|
+
optional: true,
|
|
94
|
+
detail: `Legacy skill at ${skillManager.getLegacyRafterSkillPath()} (not loaded by OpenClaw) — re-run 'rafter agent init --with-openclaw' to migrate to ${skillManager.getRafterSkillPath()}`,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
72
97
|
return { name, passed: false, optional: true, detail: `Rafter skill not installed — run 'rafter agent init --with-openclaw'` };
|
|
73
98
|
}
|
|
74
99
|
const version = skillManager.getInstalledVersion();
|
|
@@ -156,46 +181,222 @@ function checkWindsurf() {
|
|
|
156
181
|
return { name, passed: false, optional: true, detail: `Cannot read config: ${e}` };
|
|
157
182
|
}
|
|
158
183
|
}
|
|
184
|
+
function checkContinueDev() {
|
|
185
|
+
const name = "Continue.dev";
|
|
186
|
+
const homeDir = os.homedir();
|
|
187
|
+
const continueDir = path.join(homeDir, ".continue");
|
|
188
|
+
if (!fs.existsSync(continueDir)) {
|
|
189
|
+
return { name, passed: false, optional: true, detail: `Not detected — run 'rafter agent init --with-continue' to enable` };
|
|
190
|
+
}
|
|
191
|
+
const configPath = path.join(continueDir, "config.json");
|
|
192
|
+
if (!fs.existsSync(configPath)) {
|
|
193
|
+
return { name, passed: false, optional: true, detail: `MCP config not found: ${configPath} — run 'rafter agent init --with-continue'` };
|
|
194
|
+
}
|
|
195
|
+
try {
|
|
196
|
+
const cfg = JSON.parse(fs.readFileSync(configPath, "utf-8"));
|
|
197
|
+
const servers = cfg?.mcpServers;
|
|
198
|
+
let hasRafter = false;
|
|
199
|
+
if (Array.isArray(servers))
|
|
200
|
+
hasRafter = servers.some((s) => s?.name === "rafter");
|
|
201
|
+
else if (servers && typeof servers === "object")
|
|
202
|
+
hasRafter = !!servers.rafter;
|
|
203
|
+
if (!hasRafter) {
|
|
204
|
+
return { name, passed: false, optional: true, detail: "Rafter MCP server not configured — run 'rafter agent init --with-continue'" };
|
|
205
|
+
}
|
|
206
|
+
return { name, passed: true, detail: "MCP server configured" };
|
|
207
|
+
}
|
|
208
|
+
catch (e) {
|
|
209
|
+
return { name, passed: false, optional: true, detail: `Cannot read config: ${e}` };
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
function checkAider() {
|
|
213
|
+
// Aider has no platform dir of its own; presence of ~/.aider.conf.yml or
|
|
214
|
+
// a project-local .aider.conf.yml is the install signal. We check the
|
|
215
|
+
// user-scope file plus the cwd file (rf-du2o ships at --local scope too).
|
|
216
|
+
const name = "Aider";
|
|
217
|
+
const home = os.homedir();
|
|
218
|
+
const userConf = path.join(home, ".aider.conf.yml");
|
|
219
|
+
const projectConf = path.join(process.cwd(), ".aider.conf.yml");
|
|
220
|
+
const userRafterMd = path.join(home, "RAFTER.md");
|
|
221
|
+
const projectRafterMd = path.join(process.cwd(), "RAFTER.md");
|
|
222
|
+
// Pick whichever scope has a config file; prefer cwd.
|
|
223
|
+
const conf = fs.existsSync(projectConf) ? projectConf
|
|
224
|
+
: fs.existsSync(userConf) ? userConf
|
|
225
|
+
: null;
|
|
226
|
+
if (!conf) {
|
|
227
|
+
return { name, passed: false, optional: true, detail: `Not detected — run 'rafter agent init --with-aider' to enable` };
|
|
228
|
+
}
|
|
229
|
+
let raw = "";
|
|
230
|
+
try {
|
|
231
|
+
raw = fs.readFileSync(conf, "utf-8");
|
|
232
|
+
}
|
|
233
|
+
catch (e) {
|
|
234
|
+
return { name, passed: false, optional: true, detail: `Cannot read config: ${e}` };
|
|
235
|
+
}
|
|
236
|
+
let parsed = {};
|
|
237
|
+
try {
|
|
238
|
+
const loaded = yaml.load(raw);
|
|
239
|
+
if (loaded && typeof loaded === "object" && !Array.isArray(loaded)) {
|
|
240
|
+
parsed = loaded;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
catch {
|
|
244
|
+
// Unparseable — fall back to substring check
|
|
245
|
+
const hasReadEntry = /\bRAFTER\.md\b/.test(raw);
|
|
246
|
+
if (!hasReadEntry) {
|
|
247
|
+
return { name, passed: false, optional: true, detail: "RAFTER.md not in read: list — run 'rafter agent init --with-aider'" };
|
|
248
|
+
}
|
|
249
|
+
return { name, passed: true, detail: "RAFTER.md in read: list (config not strict-YAML)" };
|
|
250
|
+
}
|
|
251
|
+
const reads = Array.isArray(parsed.read) ? parsed.read.map(String)
|
|
252
|
+
: typeof parsed.read === "string" ? [parsed.read] : [];
|
|
253
|
+
if (!reads.includes("RAFTER.md")) {
|
|
254
|
+
return { name, passed: false, optional: true, detail: `RAFTER.md not in read: list (${conf}) — run 'rafter agent init --with-aider'` };
|
|
255
|
+
}
|
|
256
|
+
const rafterMd = conf === projectConf ? projectRafterMd : userRafterMd;
|
|
257
|
+
if (!fs.existsSync(rafterMd)) {
|
|
258
|
+
return { name, passed: false, optional: true, detail: `RAFTER.md missing at ${rafterMd} — run 'rafter agent init --with-aider'` };
|
|
259
|
+
}
|
|
260
|
+
return { name, passed: true, detail: `RAFTER.md + read: entry in ${conf}` };
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Probe the Claude Code hook integration end-to-end (rf-65zg).
|
|
264
|
+
*
|
|
265
|
+
* Synthesizes a stdin payload that mimics Claude's PreToolUse hook contract
|
|
266
|
+
* with a known-dangerous test command, invokes `rafter hook pretool` (the
|
|
267
|
+
* command Claude would invoke), and asserts ~/.rafter/audit.jsonl received
|
|
268
|
+
* a `command_intercepted` entry for the probe command.
|
|
269
|
+
*
|
|
270
|
+
* Catches the rf-luk-style "wrote file but the command never fires the
|
|
271
|
+
* audit log" failure without needing to drive Claude Code itself.
|
|
272
|
+
*/
|
|
273
|
+
function probeClaudeCode() {
|
|
274
|
+
const name = "Claude Code (probe)";
|
|
275
|
+
const home = os.homedir();
|
|
276
|
+
const settingsPath = path.join(home, ".claude", "settings.json");
|
|
277
|
+
if (!fs.existsSync(settingsPath)) {
|
|
278
|
+
return { name, passed: false, optional: true, detail: "Not installed — skip" };
|
|
279
|
+
}
|
|
280
|
+
// Use a unique sentinel command per probe run so we don't collide with
|
|
281
|
+
// real-world audit entries.
|
|
282
|
+
const sentinel = `rafter-probe-${process.pid}-${Date.now()}`;
|
|
283
|
+
const probeCommand = `rm -rf /tmp/${sentinel}`;
|
|
284
|
+
const stdinPayload = JSON.stringify({
|
|
285
|
+
session_id: sentinel,
|
|
286
|
+
transcript_path: "",
|
|
287
|
+
cwd: process.cwd(),
|
|
288
|
+
permission_mode: "default",
|
|
289
|
+
hook_event_name: "PreToolUse",
|
|
290
|
+
tool_name: "Bash",
|
|
291
|
+
tool_input: { command: probeCommand },
|
|
292
|
+
});
|
|
293
|
+
const auditPath = path.join(home, ".rafter", "audit.jsonl");
|
|
294
|
+
const sizeBefore = fs.existsSync(auditPath) ? fs.statSync(auditPath).size : 0;
|
|
295
|
+
// Resolve the rafter binary the same way Claude Code would: `rafter hook
|
|
296
|
+
// pretool` on PATH. Fall back to argv[0] if PATH lookup fails.
|
|
297
|
+
const result = spawnSync(process.execPath, [process.argv[1], "hook", "pretool"], {
|
|
298
|
+
input: stdinPayload,
|
|
299
|
+
encoding: "utf-8",
|
|
300
|
+
timeout: 10000,
|
|
301
|
+
});
|
|
302
|
+
if (result.error) {
|
|
303
|
+
return { name, passed: false, detail: `rafter hook pretool failed to spawn: ${result.error.message}` };
|
|
304
|
+
}
|
|
305
|
+
if (!fs.existsSync(auditPath)) {
|
|
306
|
+
return { name, passed: false, detail: `Hook ran but ${auditPath} was not created (exit=${result.status})` };
|
|
307
|
+
}
|
|
308
|
+
const newContent = fs.readFileSync(auditPath, "utf-8").slice(sizeBefore);
|
|
309
|
+
const lines = newContent.split("\n").filter((l) => l.trim().length > 0);
|
|
310
|
+
const hit = lines.some((line) => {
|
|
311
|
+
try {
|
|
312
|
+
const entry = JSON.parse(line);
|
|
313
|
+
const cmd = String(entry?.action?.command ?? entry?.command ?? "");
|
|
314
|
+
return entry?.eventType === "command_intercepted" && cmd.includes(sentinel);
|
|
315
|
+
}
|
|
316
|
+
catch {
|
|
317
|
+
return false;
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
if (!hit) {
|
|
321
|
+
return {
|
|
322
|
+
name,
|
|
323
|
+
passed: false,
|
|
324
|
+
detail: `Probe ran (exit=${result.status}) but no command_intercepted entry for sentinel "${sentinel}" landed in ${auditPath}`,
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
return { name, passed: true, detail: `Probe fired → command_intercepted recorded in ${auditPath}` };
|
|
328
|
+
}
|
|
159
329
|
export function createVerifyCommand() {
|
|
160
330
|
return new Command("verify")
|
|
161
331
|
.description("Check agent security integration status")
|
|
162
|
-
.
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
332
|
+
.option("--json", "Emit results as JSON (one object per check + summary)")
|
|
333
|
+
.option("--probe", "Runtime probe: invoke rafter hook commands with synthetic platform-format payloads and assert ~/.rafter/audit.jsonl recorded the interception. Catches the 'wrote file but never fires' failure mode (rf-65zg).")
|
|
334
|
+
.action(async (opts) => {
|
|
335
|
+
const json = !!opts.json;
|
|
336
|
+
if (!json) {
|
|
337
|
+
console.log(fmt.header("Rafter Agent Verify"));
|
|
338
|
+
console.log(fmt.divider());
|
|
339
|
+
console.log();
|
|
340
|
+
}
|
|
166
341
|
const results = [
|
|
167
342
|
checkConfig(),
|
|
168
|
-
await
|
|
343
|
+
await checkBetterleaks(),
|
|
169
344
|
checkClaudeCode(),
|
|
170
345
|
checkOpenClaw(),
|
|
171
346
|
checkCodex(),
|
|
172
347
|
checkGemini(),
|
|
173
348
|
checkCursor(),
|
|
174
349
|
checkWindsurf(),
|
|
350
|
+
checkContinueDev(),
|
|
351
|
+
checkAider(),
|
|
175
352
|
];
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
else if (r.optional) {
|
|
181
|
-
console.log(fmt.warning(`${r.name}: ${r.detail}`));
|
|
182
|
-
}
|
|
183
|
-
else {
|
|
184
|
-
console.log(fmt.error(`${r.name}: FAIL — ${r.detail}`));
|
|
185
|
-
}
|
|
353
|
+
if (opts.probe) {
|
|
354
|
+
// Only Claude Code has a probe today (rf-65zg). Codex/Cursor/Gemini
|
|
355
|
+
// hook payloads can be added in follow-ups.
|
|
356
|
+
results.push(probeClaudeCode());
|
|
186
357
|
}
|
|
187
|
-
console.log();
|
|
188
358
|
const hardFailed = results.filter((r) => !r.passed && !r.optional);
|
|
189
359
|
const warned = results.filter((r) => !r.passed && r.optional);
|
|
190
360
|
const passed = results.filter((r) => r.passed);
|
|
191
|
-
if (
|
|
192
|
-
const
|
|
193
|
-
|
|
361
|
+
if (json) {
|
|
362
|
+
const payload = {
|
|
363
|
+
checks: results.map((r) => ({
|
|
364
|
+
name: r.name,
|
|
365
|
+
status: r.passed ? "pass" : r.optional ? "warn" : "fail",
|
|
366
|
+
detail: r.detail,
|
|
367
|
+
})),
|
|
368
|
+
summary: {
|
|
369
|
+
passed: passed.length,
|
|
370
|
+
warned: warned.length,
|
|
371
|
+
failed: hardFailed.length,
|
|
372
|
+
total: results.length,
|
|
373
|
+
probe: !!opts.probe,
|
|
374
|
+
},
|
|
375
|
+
};
|
|
376
|
+
process.stdout.write(JSON.stringify(payload) + "\n");
|
|
194
377
|
}
|
|
195
378
|
else {
|
|
196
|
-
|
|
379
|
+
for (const r of results) {
|
|
380
|
+
if (r.passed) {
|
|
381
|
+
console.log(fmt.success(`${r.name}: ${r.detail}`));
|
|
382
|
+
}
|
|
383
|
+
else if (r.optional) {
|
|
384
|
+
console.log(fmt.warning(`${r.name}: ${r.detail}`));
|
|
385
|
+
}
|
|
386
|
+
else {
|
|
387
|
+
console.log(fmt.error(`${r.name}: FAIL — ${r.detail}`));
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
console.log();
|
|
391
|
+
if (hardFailed.length === 0) {
|
|
392
|
+
const warnNote = warned.length > 0 ? ` (${warned.length} optional check${warned.length > 1 ? "s" : ""} not configured)` : "";
|
|
393
|
+
console.log(fmt.success(`${passed.length}/${results.length} core checks passed${warnNote}`));
|
|
394
|
+
}
|
|
395
|
+
else {
|
|
396
|
+
console.log(fmt.error(`${passed.length}/${results.length} checks passed — ${hardFailed.length} failed`));
|
|
397
|
+
}
|
|
398
|
+
console.log();
|
|
197
399
|
}
|
|
198
|
-
console.log();
|
|
199
400
|
if (hardFailed.length > 0) {
|
|
200
401
|
process.exit(1);
|
|
201
402
|
}
|
package/dist/commands/brief.js
CHANGED
|
@@ -125,43 +125,6 @@ function buildTopics() {
|
|
|
125
125
|
description: "Setup instructions for unsupported / generic agents",
|
|
126
126
|
render: () => renderPlatformSetup("generic"),
|
|
127
127
|
},
|
|
128
|
-
pricing: {
|
|
129
|
-
description: "What's free, what's paid, and the philosophy behind it",
|
|
130
|
-
render: () => [
|
|
131
|
-
"# Rafter Pricing",
|
|
132
|
-
"",
|
|
133
|
-
"**Free forever for individuals and open source. No account required. No telemetry.**",
|
|
134
|
-
"",
|
|
135
|
-
"## What's Free",
|
|
136
|
-
"",
|
|
137
|
-
"All local agent security features are free with no limits:",
|
|
138
|
-
"",
|
|
139
|
-
"- Secret scanning (21+ patterns, Gitleaks integration)",
|
|
140
|
-
"- Pre-commit hooks (local and global)",
|
|
141
|
-
"- Command interception with risk-tiered approval",
|
|
142
|
-
"- Skill/extension auditing",
|
|
143
|
-
"- Audit logging",
|
|
144
|
-
"- MCP server for tool integration",
|
|
145
|
-
"- CI/CD pipeline generation",
|
|
146
|
-
"- All supported agent integrations (Claude Code, Codex, Gemini, Cursor, Windsurf, Aider, OpenClaw, Continue.dev)",
|
|
147
|
-
"",
|
|
148
|
-
"No API key. No sign-up. No telemetry. No data collection. No network access required.",
|
|
149
|
-
"Everything runs locally on your machine. MIT licensed.",
|
|
150
|
-
"",
|
|
151
|
-
"## Remote Code Analysis (API)",
|
|
152
|
-
"",
|
|
153
|
-
"Remote SAST/SCA scanning via the Rafter API has a free tier.",
|
|
154
|
-
"Sign up at rafter.so for an API key. Enterprise plans offer higher",
|
|
155
|
-
"limits, dashboards, policy management, and compliance reporting.",
|
|
156
|
-
"",
|
|
157
|
-
"## Philosophy",
|
|
158
|
-
"",
|
|
159
|
-
"Security tooling should be free for the people writing code.",
|
|
160
|
-
"Generous free tiers drive bottom-up adoption. Enterprise value",
|
|
161
|
-
"comes from dashboards, policy, and compliance — not from gating",
|
|
162
|
-
"the tools developers use every day.",
|
|
163
|
-
].join("\n"),
|
|
164
|
-
},
|
|
165
128
|
...Object.fromEntries(RAFTER_SUBDOCS.map(({ slug, desc }) => [
|
|
166
129
|
slug,
|
|
167
130
|
{
|
|
@@ -323,7 +286,9 @@ Add to Windsurf's MCP config (\`~/.codeium/windsurf/mcp_config.json\`):
|
|
|
323
286
|
\`\`\``,
|
|
324
287
|
aider: `# Rafter Setup — Aider
|
|
325
288
|
|
|
326
|
-
Aider
|
|
289
|
+
Aider has no plugin/hook system and no native MCP support. Its only intercept
|
|
290
|
+
for persistent context is the \`read:\` flag in \`.aider.conf.yml\`, which
|
|
291
|
+
injects read-only files into every session.
|
|
327
292
|
|
|
328
293
|
## Automated Setup
|
|
329
294
|
|
|
@@ -331,18 +296,21 @@ Aider uses MCP for tool integration.
|
|
|
331
296
|
rafter agent init --with-aider
|
|
332
297
|
\`\`\`
|
|
333
298
|
|
|
299
|
+
This writes \`RAFTER.md\` at the workspace root and adds it to \`read:\` in
|
|
300
|
+
\`.aider.conf.yml\`.
|
|
301
|
+
|
|
334
302
|
## Manual Setup
|
|
335
303
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
\`\`\`
|
|
304
|
+
1. Create \`RAFTER.md\` at the workspace root with rafter's security context.
|
|
305
|
+
2. Add to \`.aider.conf.yml\`:
|
|
306
|
+
\`\`\`yaml
|
|
307
|
+
read:
|
|
308
|
+
- RAFTER.md
|
|
309
|
+
\`\`\`
|
|
342
310
|
|
|
343
311
|
## Supplementing with Brief
|
|
344
312
|
|
|
345
|
-
Aider doesn't have persistent memory
|
|
313
|
+
Aider doesn't have persistent memory beyond \`read:\`, so run before each session:
|
|
346
314
|
\`\`\`bash
|
|
347
315
|
rafter brief commands # quick command reference
|
|
348
316
|
\`\`\``,
|
|
@@ -15,7 +15,7 @@ _rafter_completions() {
|
|
|
15
15
|
return 0
|
|
16
16
|
;;
|
|
17
17
|
agent)
|
|
18
|
-
COMPREPLY=( $(compgen -W "scan init audit config exec audit-skill install-hook verify status update-
|
|
18
|
+
COMPREPLY=( $(compgen -W "scan init audit config exec audit-skill install-hook verify status update-betterleaks baseline --help" -- "\${cur}") )
|
|
19
19
|
return 0
|
|
20
20
|
;;
|
|
21
21
|
brief)
|
|
@@ -66,7 +66,7 @@ _rafter_completions() {
|
|
|
66
66
|
;;
|
|
67
67
|
init)
|
|
68
68
|
if [[ "\${COMP_WORDS[1]}" == "agent" ]]; then
|
|
69
|
-
COMPREPLY=( $(compgen -W "--risk-level --with-openclaw --with-claude-code --with-codex --with-gemini --with-aider --with-cursor --with-windsurf --with-continue --with-
|
|
69
|
+
COMPREPLY=( $(compgen -W "--risk-level --with-openclaw --with-claude-code --with-codex --with-gemini --with-aider --with-cursor --with-windsurf --with-continue --with-betterleaks --all --help" -- "\${cur}") )
|
|
70
70
|
elif [[ "\${COMP_WORDS[1]}" == "ci" ]]; then
|
|
71
71
|
COMPREPLY=( $(compgen -W "--platform --output --with-remote --with-backend --help" -- "\${cur}") )
|
|
72
72
|
fi
|
|
@@ -106,7 +106,7 @@ _rafter() {
|
|
|
106
106
|
'install-hook:Install git hook (pre-commit or pre-push)'
|
|
107
107
|
'verify:Check integration status'
|
|
108
108
|
'status:Show agent status'
|
|
109
|
-
'update-
|
|
109
|
+
'update-betterleaks:Update betterleaks binary'
|
|
110
110
|
'baseline:Manage findings baseline'
|
|
111
111
|
)
|
|
112
112
|
|
|
@@ -166,7 +166,7 @@ _rafter() {
|
|
|
166
166
|
'--json[Output as JSON]' \\
|
|
167
167
|
'--staged[Scan only staged files]' \\
|
|
168
168
|
'--diff[Scan files changed since ref]:ref:' \\
|
|
169
|
-
'--engine[Scanner engine]:engine:(
|
|
169
|
+
'--engine[Scanner engine]:engine:(betterleaks patterns)' \\
|
|
170
170
|
'1:path:_files'
|
|
171
171
|
;;
|
|
172
172
|
init)
|
|
@@ -180,7 +180,7 @@ _rafter() {
|
|
|
180
180
|
'--with-cursor[Install Cursor integration]' \\
|
|
181
181
|
'--with-windsurf[Install Windsurf integration]' \\
|
|
182
182
|
'--with-continue[Install Continue.dev integration]' \\
|
|
183
|
-
'--with-
|
|
183
|
+
'--with-betterleaks[Download Betterleaks binary]' \\
|
|
184
184
|
'--all[Install all detected integrations]'
|
|
185
185
|
;;
|
|
186
186
|
audit)
|
|
@@ -314,21 +314,21 @@ complete -c rafter -n '__fish_seen_subcommand_from usage' -s k -l api-key -d 'AP
|
|
|
314
314
|
complete -c rafter -n '__fish_seen_subcommand_from brief' -a 'security scanning commands setup setup/claude-code setup/codex setup/gemini setup/cursor setup/windsurf setup/aider setup/openclaw setup/continue setup/generic all' -d 'Topic'
|
|
315
315
|
|
|
316
316
|
# agent subcommands
|
|
317
|
-
complete -c rafter -n '__fish_seen_subcommand_from agent; and not __fish_seen_subcommand_from scan init audit config exec audit-skill install-hook verify status update-
|
|
318
|
-
complete -c rafter -n '__fish_seen_subcommand_from agent; and not __fish_seen_subcommand_from scan init audit config exec audit-skill install-hook verify status update-
|
|
319
|
-
complete -c rafter -n '__fish_seen_subcommand_from agent; and not __fish_seen_subcommand_from scan init audit config exec audit-skill install-hook verify status update-
|
|
320
|
-
complete -c rafter -n '__fish_seen_subcommand_from agent; and not __fish_seen_subcommand_from scan init audit config exec audit-skill install-hook verify status update-
|
|
321
|
-
complete -c rafter -n '__fish_seen_subcommand_from agent; and not __fish_seen_subcommand_from scan init audit config exec audit-skill install-hook verify status update-
|
|
322
|
-
complete -c rafter -n '__fish_seen_subcommand_from agent; and not __fish_seen_subcommand_from scan init audit config exec audit-skill install-hook verify status update-
|
|
323
|
-
complete -c rafter -n '__fish_seen_subcommand_from agent; and not __fish_seen_subcommand_from scan init audit config exec audit-skill install-hook verify status update-
|
|
324
|
-
complete -c rafter -n '__fish_seen_subcommand_from agent; and not __fish_seen_subcommand_from scan init audit config exec audit-skill install-hook verify status update-
|
|
317
|
+
complete -c rafter -n '__fish_seen_subcommand_from agent; and not __fish_seen_subcommand_from scan init audit config exec audit-skill install-hook verify status update-betterleaks baseline' -a scan -d 'Scan files for secrets'
|
|
318
|
+
complete -c rafter -n '__fish_seen_subcommand_from agent; and not __fish_seen_subcommand_from scan init audit config exec audit-skill install-hook verify status update-betterleaks baseline' -a init -d 'Initialize agent security'
|
|
319
|
+
complete -c rafter -n '__fish_seen_subcommand_from agent; and not __fish_seen_subcommand_from scan init audit config exec audit-skill install-hook verify status update-betterleaks baseline' -a audit -d 'View audit log'
|
|
320
|
+
complete -c rafter -n '__fish_seen_subcommand_from agent; and not __fish_seen_subcommand_from scan init audit config exec audit-skill install-hook verify status update-betterleaks baseline' -a config -d 'Manage configuration'
|
|
321
|
+
complete -c rafter -n '__fish_seen_subcommand_from agent; and not __fish_seen_subcommand_from scan init audit config exec audit-skill install-hook verify status update-betterleaks baseline' -a exec -d 'Execute with security'
|
|
322
|
+
complete -c rafter -n '__fish_seen_subcommand_from agent; and not __fish_seen_subcommand_from scan init audit config exec audit-skill install-hook verify status update-betterleaks baseline' -a audit-skill -d 'Audit a skill file'
|
|
323
|
+
complete -c rafter -n '__fish_seen_subcommand_from agent; and not __fish_seen_subcommand_from scan init audit config exec audit-skill install-hook verify status update-betterleaks baseline' -a install-hook -d 'Install pre-commit hook'
|
|
324
|
+
complete -c rafter -n '__fish_seen_subcommand_from agent; and not __fish_seen_subcommand_from scan init audit config exec audit-skill install-hook verify status update-betterleaks baseline' -a verify -d 'Check integration status'
|
|
325
325
|
|
|
326
326
|
# agent scan options
|
|
327
327
|
complete -c rafter -n '__fish_seen_subcommand_from agent; and __fish_seen_subcommand_from scan' -s q -l quiet -d 'Only output if secrets found'
|
|
328
328
|
complete -c rafter -n '__fish_seen_subcommand_from agent; and __fish_seen_subcommand_from scan' -l json -d 'Output as JSON'
|
|
329
329
|
complete -c rafter -n '__fish_seen_subcommand_from agent; and __fish_seen_subcommand_from scan' -l staged -d 'Scan only staged files'
|
|
330
330
|
complete -c rafter -n '__fish_seen_subcommand_from agent; and __fish_seen_subcommand_from scan' -l diff -d 'Scan changed since ref' -r
|
|
331
|
-
complete -c rafter -n '__fish_seen_subcommand_from agent; and __fish_seen_subcommand_from scan' -l engine -d 'Scanner engine' -ra '
|
|
331
|
+
complete -c rafter -n '__fish_seen_subcommand_from agent; and __fish_seen_subcommand_from scan' -l engine -d 'Scanner engine' -ra 'betterleaks patterns'
|
|
332
332
|
|
|
333
333
|
# agent init options
|
|
334
334
|
complete -c rafter -n '__fish_seen_subcommand_from agent; and __fish_seen_subcommand_from init' -l risk-level -d 'Risk level' -ra 'minimal moderate aggressive'
|
|
@@ -340,7 +340,7 @@ complete -c rafter -n '__fish_seen_subcommand_from agent; and __fish_seen_subcom
|
|
|
340
340
|
complete -c rafter -n '__fish_seen_subcommand_from agent; and __fish_seen_subcommand_from init' -l with-cursor -d 'Install Cursor'
|
|
341
341
|
complete -c rafter -n '__fish_seen_subcommand_from agent; and __fish_seen_subcommand_from init' -l with-windsurf -d 'Install Windsurf'
|
|
342
342
|
complete -c rafter -n '__fish_seen_subcommand_from agent; and __fish_seen_subcommand_from init' -l with-continue -d 'Install Continue.dev'
|
|
343
|
-
complete -c rafter -n '__fish_seen_subcommand_from agent; and __fish_seen_subcommand_from init' -l with-
|
|
343
|
+
complete -c rafter -n '__fish_seen_subcommand_from agent; and __fish_seen_subcommand_from init' -l with-betterleaks -d 'Install Betterleaks'
|
|
344
344
|
complete -c rafter -n '__fish_seen_subcommand_from agent; and __fish_seen_subcommand_from init' -l all -d 'Install all detected'
|
|
345
345
|
|
|
346
346
|
# agent audit options
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Supports both:
|
|
5
5
|
* - Backend scans: --scan-id <id> (fetches from Rafter API)
|
|
6
|
-
* - Local scans: --from-local <path> (reads JSON file from `rafter
|
|
6
|
+
* - Local scans: --from-local <path> (reads JSON file from `rafter secrets --format json`)
|
|
7
7
|
*/
|
|
8
8
|
import { Command } from "commander";
|
|
9
9
|
import fs from "fs";
|
|
@@ -18,7 +18,7 @@ export function createFromScanCommand() {
|
|
|
18
18
|
return new Command("from-scan")
|
|
19
19
|
.description("Create GitHub issues from scan results")
|
|
20
20
|
.option("--scan-id <id>", "Backend scan ID to create issues from")
|
|
21
|
-
.option("--from-local <path>", "Path to local scan JSON (from rafter
|
|
21
|
+
.option("--from-local <path>", "Path to local scan JSON (from rafter secrets --format json)")
|
|
22
22
|
.option("-r, --repo <repo>", "Target GitHub repo (org/repo)")
|
|
23
23
|
.option("-k, --api-key <key>", "Rafter API key (for --scan-id)")
|
|
24
24
|
.option("--no-dedup", "Skip deduplication check")
|
|
@@ -132,7 +132,10 @@ async function draftsFromBackendScan(scanId, apiKey) {
|
|
|
132
132
|
}
|
|
133
133
|
function draftsFromLocalScan(filePath) {
|
|
134
134
|
const raw = fs.readFileSync(filePath, "utf-8");
|
|
135
|
-
const
|
|
135
|
+
const parsed = JSON.parse(raw);
|
|
136
|
+
// New shape: { _note, scan_mode, triage_applied, results: [...] }
|
|
137
|
+
// Legacy shape (pre-0.7.8): bare array. Accept both for forward-compat reading.
|
|
138
|
+
const results = Array.isArray(parsed) ? parsed : (parsed?.results ?? []);
|
|
136
139
|
const drafts = [];
|
|
137
140
|
for (const result of results) {
|
|
138
141
|
for (const match of result.matches) {
|
|
@@ -3,7 +3,7 @@ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
|
3
3
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
4
|
import { CallToolRequestSchema, ListToolsRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
5
5
|
import { RegexScanner } from "../../scanners/regex-scanner.js";
|
|
6
|
-
import {
|
|
6
|
+
import { BetterleaksScanner } from "../../scanners/betterleaks.js";
|
|
7
7
|
import { CommandInterceptor } from "../../core/command-interceptor.js";
|
|
8
8
|
import { AuditLogger } from "../../core/audit-logger.js";
|
|
9
9
|
import { ConfigManager } from "../../core/config-manager.js";
|
|
@@ -42,8 +42,8 @@ export function createServer() {
|
|
|
42
42
|
path: { type: "string", description: "File or directory path to scan" },
|
|
43
43
|
engine: {
|
|
44
44
|
type: "string",
|
|
45
|
-
enum: ["auto", "
|
|
46
|
-
description: "Scan engine: auto (default),
|
|
45
|
+
enum: ["auto", "betterleaks", "patterns"],
|
|
46
|
+
description: "Scan engine: auto (default), betterleaks, or patterns.",
|
|
47
47
|
},
|
|
48
48
|
},
|
|
49
49
|
required: ["path"],
|
|
@@ -118,20 +118,20 @@ export function createServer() {
|
|
|
118
118
|
case "scan_secrets": {
|
|
119
119
|
const scanPath = args?.path;
|
|
120
120
|
const engine = args?.engine || "auto";
|
|
121
|
-
if (engine === "
|
|
122
|
-
const
|
|
123
|
-
if (await
|
|
121
|
+
if (engine === "betterleaks" || engine === "auto") {
|
|
122
|
+
const bl = new BetterleaksScanner();
|
|
123
|
+
if (await bl.isAvailable()) {
|
|
124
124
|
try {
|
|
125
|
-
const results = await
|
|
125
|
+
const results = await bl.scanDirectory(scanPath);
|
|
126
126
|
return textResult(formatScanResults(results));
|
|
127
127
|
}
|
|
128
128
|
catch {
|
|
129
|
-
if (engine === "
|
|
130
|
-
return errorResult("
|
|
129
|
+
if (engine === "betterleaks")
|
|
130
|
+
return errorResult("Betterleaks scan failed");
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
else if (engine === "
|
|
134
|
-
return errorResult("
|
|
133
|
+
else if (engine === "betterleaks") {
|
|
134
|
+
return errorResult("Betterleaks not installed");
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
const scanner = new RegexScanner();
|
|
@@ -254,6 +254,12 @@ export class ConfigManager {
|
|
|
254
254
|
config.agent.scan.customPatterns = policy.scan.customPatterns;
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
|
+
// Ignore rules — top-level policy key, applied per finding at scan time
|
|
258
|
+
if (policy.ignore && config.agent) {
|
|
259
|
+
if (!config.agent.scan)
|
|
260
|
+
config.agent.scan = {};
|
|
261
|
+
config.agent.scan.ignore = policy.ignore;
|
|
262
|
+
}
|
|
257
263
|
// Audit settings
|
|
258
264
|
if (policy.audit && config.agent) {
|
|
259
265
|
if (policy.audit.retentionDays != null) {
|