@rafter-security/cli 0.10.6 → 0.11.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.
Files changed (41) hide show
  1. package/dist/commands/agent/baseline.js +9 -50
  2. package/dist/commands/agent/components.js +7 -2
  3. package/dist/commands/agent/exec.js +26 -9
  4. package/dist/commands/agent/init.js +275 -220
  5. package/dist/commands/agent/install-hook.js +17 -6
  6. package/dist/commands/agent/scan.js +309 -71
  7. package/dist/commands/agent/update-skill-scanner.js +1 -1
  8. package/dist/commands/agent/verify.js +39 -15
  9. package/dist/commands/backend/get.js +6 -2
  10. package/dist/commands/backend/scan-status.js +34 -4
  11. package/dist/commands/ci/init.js +4 -1
  12. package/dist/commands/hook/posttool.js +11 -0
  13. package/dist/commands/hook/pretool.js +124 -36
  14. package/dist/commands/mcp/server.js +184 -129
  15. package/dist/commands/report.js +6 -2
  16. package/dist/core/audit-logger.js +47 -17
  17. package/dist/core/config-manager.js +46 -8
  18. package/dist/core/custom-patterns.js +28 -8
  19. package/dist/core/docs-loader.js +33 -3
  20. package/dist/core/pattern-engine.js +23 -5
  21. package/dist/core/policy-loader.js +15 -4
  22. package/dist/core/risk-rules.js +391 -9
  23. package/dist/index.js +6 -0
  24. package/dist/scanners/betterleaks.js +127 -14
  25. package/dist/scanners/git-history-scan.js +75 -0
  26. package/dist/scanners/regex-scanner.js +16 -2
  27. package/dist/scanners/secret-patterns.js +11 -2
  28. package/dist/scanners/union.js +31 -19
  29. package/dist/utils/api.js +35 -1
  30. package/dist/utils/git-diff.js +36 -20
  31. package/dist/utils/skill-manager.js +4 -3
  32. package/package.json +16 -15
  33. package/resources/continue-rules/rafter.md +1 -1
  34. package/resources/cursor-rules/rafter.mdc +1 -1
  35. package/resources/rafter-security-skill.md +3 -1
  36. package/resources/skills/rafter/SKILL.md +1 -2
  37. package/resources/skills/rafter/docs/guardrails.md +1 -1
  38. package/resources/skills/rafter-code-review/SKILL.md +0 -1
  39. package/resources/skills/rafter-secure-design/SKILL.md +0 -1
  40. package/resources/skills/rafter-skill-review/SKILL.md +0 -1
  41. package/resources/windsurf-rules/rafter.md +1 -1
@@ -0,0 +1,75 @@
1
+ import { execFileSync, spawn } from "child_process";
2
+ import path from "path";
3
+ import { createAddedLineParser } from "../utils/git-diff.js";
4
+ import { RegexScanner } from "./regex-scanner.js";
5
+ /**
6
+ * The repository root containing `dirPath`. Throws when `dirPath` is not
7
+ * inside a git work tree, so `--history` never reports a clean scan of a
8
+ * history it could not read.
9
+ */
10
+ export function gitRepoRoot(dirPath) {
11
+ try {
12
+ return execFileSync("git", ["rev-parse", "--show-toplevel"], {
13
+ cwd: dirPath, encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"],
14
+ }).trim();
15
+ }
16
+ catch {
17
+ throw new Error(`--history: not a git repository: ${dirPath}`);
18
+ }
19
+ }
20
+ /**
21
+ * Scan every line ever added in the repository's history with the patterns
22
+ * engine (sable-28lv). Reads the same commits as `betterleaks git`
23
+ * (`git log -p -U0 --full-history --all`), streamed line by line, so memory
24
+ * holds one line plus the findings, whatever the size of the history.
25
+ *
26
+ * Files are reported as absolute paths under the repo root and lines as the
27
+ * line number in the commit that added them, the same shape betterleaks
28
+ * history results take after `absolutize`, so the union merges the two.
29
+ */
30
+ export async function scanGitHistory(dirPath, customPatterns) {
31
+ const repoRoot = gitRepoRoot(dirPath);
32
+ const scanner = new RegexScanner(customPatterns);
33
+ const feed = createAddedLineParser();
34
+ const byFile = new Map();
35
+ const onLine = (rawLine) => {
36
+ const added = feed(rawLine.endsWith("\r") ? rawLine.slice(0, -1) : rawLine);
37
+ if (!added)
38
+ return;
39
+ for (const m of scanner.scanLine(added.text, added.line)) {
40
+ const file = path.join(repoRoot, added.file);
41
+ let found = byFile.get(file);
42
+ if (!found)
43
+ byFile.set(file, (found = new Map()));
44
+ // The same secret re-added at the same place in a later commit is one finding.
45
+ const key = `${m.line} ${m.column} ${m.match}`;
46
+ if (!found.has(key))
47
+ found.set(key, m);
48
+ }
49
+ };
50
+ await new Promise((resolve, reject) => {
51
+ const child = spawn("git", ["-c", "core.quotePath=false", "log", "-p", "-U0", "--no-color", "--no-ext-diff", "--no-textconv",
52
+ "--full-history", "--all", "--format=commit %H"], { cwd: repoRoot, stdio: ["ignore", "pipe", "pipe"] });
53
+ let pending = "";
54
+ let stderr = "";
55
+ child.stdout.setEncoding("utf-8");
56
+ child.stdout.on("data", (chunk) => {
57
+ const lines = (pending + chunk).split("\n");
58
+ pending = lines.pop();
59
+ for (const l of lines)
60
+ onLine(l);
61
+ });
62
+ child.stderr.on("data", (d) => { stderr += d; });
63
+ child.on("error", (e) => reject(new Error(`--history: git log failed: ${e.message}`)));
64
+ child.on("close", (code) => {
65
+ if (pending)
66
+ onLine(pending);
67
+ // An empty repository has no history to read; git says so with exit 128.
68
+ if (code === 0 || /does not have any commits/.test(stderr))
69
+ resolve();
70
+ else
71
+ reject(new Error(`--history: git log failed (exit ${code}): ${stderr.trim()}`));
72
+ });
73
+ });
74
+ return [...byFile.entries()].map(([file, found]) => ({ file, matches: [...found.values()] }));
75
+ }
@@ -4,6 +4,14 @@ import path from "path";
4
4
  import { PatternEngine } from "../core/pattern-engine.js";
5
5
  import { DEFAULT_SECRET_PATTERNS } from "./secret-patterns.js";
6
6
  import { loadCustomPatterns } from "../core/custom-patterns.js";
7
+ /** A human-readable reason for a file read failure. */
8
+ function readErrorReason(e) {
9
+ if (e && e.code === "EACCES")
10
+ return "permission denied";
11
+ if (e && e.code)
12
+ return String(e.code);
13
+ return e instanceof Error ? e.message : "could not read file";
14
+ }
7
15
  export class RegexScanner {
8
16
  constructor(customPatterns) {
9
17
  const patterns = [...DEFAULT_SECRET_PATTERNS, ...loadCustomPatterns()];
@@ -29,7 +37,9 @@ export class RegexScanner {
29
37
  return { file: filePath, matches };
30
38
  }
31
39
  catch (e) {
32
- return { file: filePath, matches: [] };
40
+ // A file we could not read is not a clean scan — surface it distinctly
41
+ // (sable-ilbx) so "no findings" cannot mean "could not open".
42
+ return { file: filePath, matches: [], readError: readErrorReason(e) };
33
43
  }
34
44
  }
35
45
  /**
@@ -39,7 +49,9 @@ export class RegexScanner {
39
49
  const results = [];
40
50
  for (const filePath of filePaths) {
41
51
  const result = this.scanFile(filePath);
42
- if (result.matches.length > 0) {
52
+ // Keep a result that has findings, and also one that failed to read, so
53
+ // a permission-denied file is not silently dropped (sable-ilbx).
54
+ if (result.matches.length > 0 || result.readError) {
43
55
  results.push(result);
44
56
  }
45
57
  }
@@ -49,6 +61,7 @@ export class RegexScanner {
49
61
  * Scan a directory recursively
50
62
  */
51
63
  scanDirectory(dirPath, options) {
64
+ // Keep in step with DEFAULT_EXCLUDE in python/rafter_cli/scanners/regex_scanner.py.
52
65
  const exclude = options?.exclude || [
53
66
  "node_modules",
54
67
  ".git",
@@ -66,6 +79,7 @@ export class RegexScanner {
66
79
  ".tox",
67
80
  ".mypy_cache",
68
81
  ".pytest_cache",
82
+ ".ruff_cache",
69
83
  "results",
70
84
  ".terraform",
71
85
  "bower_components"
@@ -6,13 +6,22 @@ export const DEFAULT_SECRET_PATTERNS = [
6
6
  // AWS
7
7
  {
8
8
  name: "AWS Access Key ID",
9
- regex: "(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}",
9
+ // Negative lookahead excludes the canonical AWS-docs example key
10
+ // (AKIAIOSFODNN7EXAMPLE and its siblings, which all end in EXAMPLE).
11
+ // betterleaks skips these too (#230); matching that keeps the two
12
+ // engines from disagreeing on a well-known public non-secret.
13
+ regex: "(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)(?![A-Z0-9]{9}EXAMPLE)[A-Z0-9]{16}",
10
14
  severity: "critical",
11
15
  description: "AWS Access Key ID detected"
12
16
  },
13
17
  {
14
18
  name: "AWS Secret Access Key",
15
- regex: "(?i)aws(.{0,20})?['\"]?[0-9a-zA-Z/+]{40}['\"]?",
19
+ // Negative lookahead excludes the canonical AWS-docs example secret key
20
+ // (wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY, which ends in EXAMPLEKEY).
21
+ // betterleaks skips this too (#230); matching that keeps the two
22
+ // engines from disagreeing on a well-known public non-secret, mirroring
23
+ // the AWS Access Key ID exemption above.
24
+ regex: "(?i)aws(.{0,20})?['\"]?(?![0-9a-zA-Z/+]{30}EXAMPLEKEY)[0-9a-zA-Z/+]{40}['\"]?",
16
25
  severity: "critical",
17
26
  description: "AWS Secret Access Key detected"
18
27
  },
@@ -8,14 +8,11 @@
8
8
  * Running only one silently degrades coverage; the union restores it.
9
9
  *
10
10
  * Dedup: two findings are "the same secret" when they share
11
- * `(file, line, column, matched-text)`. The key is deliberately conservative
12
- * — it errs toward keeping both findings rather than collapsing two genuinely
13
- * distinct secrets (e.g. the same token value pasted twice on one line at
14
- * different columns), because dropping a real finding is a security
15
- * regression for a scanner. The flip side: when the two engines extract
16
- * slightly different text/columns for the same secret it is reported twice
17
- * (once per engine) rather than merged — safe over-reporting, not a miss.
18
- * When both engines DO agree on `(line, column, text)` we keep the betterleaks
11
+ * `(file, line, column)`, or `(file, line, column, matched-text)` when the
12
+ * position is unknown. Distinct secrets on one line (the same token pasted
13
+ * twice) sit at different columns and are both kept, because dropping a real
14
+ * finding is a security regression for a scanner. When both engines report a
15
+ * position we keep the betterleaks
19
16
  * match — its `RuleID`-style `pattern.name` is the canonical id — and record
20
17
  * both engines in `engines`. Ordering is deterministic: betterleaks findings
21
18
  * first (in betterleaks's own order), then any patterns-only findings, grouped
@@ -24,6 +21,9 @@
24
21
  export function unionScanResults(betterleaks, patterns) {
25
22
  const fileOrder = [];
26
23
  const byFile = new Map();
24
+ // Carry a read failure through the union (sable-ilbx): a file one engine
25
+ // could not open must still be reported as unreadable, not dropped.
26
+ const readErrorByFile = new Map();
27
27
  const ingest = (results, engine) => {
28
28
  for (const r of results) {
29
29
  let fileMap = byFile.get(r.file);
@@ -32,28 +32,40 @@ export function unionScanResults(betterleaks, patterns) {
32
32
  byFile.set(r.file, fileMap);
33
33
  fileOrder.push(r.file);
34
34
  }
35
+ if (r.readError && !readErrorByFile.has(r.file)) {
36
+ readErrorByFile.set(r.file, r.readError);
37
+ }
35
38
  for (const m of r.matches) {
36
- // `line` and `column` are always digits (or "?"), so the first two
37
- // spaces unambiguously delimit them from the matched secret — no key
38
- // collisions even when the secret itself contains spaces. Column is
39
- // part of the key so two distinct secrets sharing a line+text but
40
- // sitting at different columns are NOT collapsed.
41
- const key = `${m.line ?? "?"} ${m.column ?? "?"} ${m.match}`;
39
+ // Two secrets cannot start at the same line and column, so a known
40
+ // position alone identifies the secret: the engines extract different
41
+ // text for it (betterleaks a whole PEM block, the regex pattern only
42
+ // its header). Without a position, fall back to the matched text.
43
+ const key = m.line != null && m.column != null
44
+ ? `${m.line} ${m.column}`
45
+ : `${m.line ?? "?"} ${m.column ?? "?"} ${m.match}`;
42
46
  const existing = fileMap.get(key);
43
47
  if (existing) {
44
48
  if (!existing.engines.includes(engine))
45
49
  existing.engines.push(engine);
50
+ if (!existing.ruleNames.includes(m.pattern.name))
51
+ existing.ruleNames.push(m.pattern.name);
46
52
  }
47
53
  else {
48
- fileMap.set(key, { ...m, engines: [engine] });
54
+ fileMap.set(key, { ...m, engines: [engine], ruleNames: [m.pattern.name] });
49
55
  }
50
56
  }
51
57
  }
52
58
  };
53
59
  ingest(betterleaks, "betterleaks");
54
60
  ingest(patterns, "patterns");
55
- return fileOrder.map((file) => ({
56
- file,
57
- matches: Array.from(byFile.get(file).values()),
58
- }));
61
+ return fileOrder.map((file) => {
62
+ const out = {
63
+ file,
64
+ matches: Array.from(byFile.get(file).values()),
65
+ };
66
+ const readError = readErrorByFile.get(file);
67
+ if (readError)
68
+ out.readError = readError;
69
+ return out;
70
+ });
59
71
  }
package/dist/utils/api.js CHANGED
@@ -1,6 +1,40 @@
1
1
  import axios from "axios";
2
2
  import { ConfigManager } from "../core/config-manager.js";
3
3
  export const API = "https://rafter.so/api/";
4
+ /**
5
+ * The API base in effect right now.
6
+ *
7
+ * `RAFTER_API_URL`, read fresh on every call rather than cached at import
8
+ * time, overrides the production default in `API`. This is how the test
9
+ * suite points the CLI at a local, non-routable port instead of the live
10
+ * backend — see `node/tests/env-isolation-setup.ts`. Production never sets
11
+ * the var, so this is a no-op outside tests.
12
+ *
13
+ * Every request carries the API key, so the override must be https, or plain
14
+ * http to a loopback host. Anything else is ignored with a warning. A remote
15
+ * https override is honored with a one-time notice, since the key goes there.
16
+ */
17
+ const LOOPBACK_HOSTS = new Set(["localhost", "127.0.0.1", "[::1]"]);
18
+ let warnedApiOverride = false;
19
+ function resolveApiBase() {
20
+ const override = process.env.RAFTER_API_URL;
21
+ if (!override)
22
+ return API;
23
+ let url = null;
24
+ try {
25
+ url = new URL(override);
26
+ }
27
+ catch { /* reported below */ }
28
+ const loopback = url !== null && LOOPBACK_HOSTS.has(url.hostname);
29
+ const allowed = url !== null && (url.protocol === "https:" || (url.protocol === "http:" && loopback));
30
+ if (!loopback && !warnedApiOverride) {
31
+ warnedApiOverride = true;
32
+ console.error(allowed
33
+ ? `rafter: RAFTER_API_URL is set; sending requests and your API key to ${url.origin}`
34
+ : `rafter: ignoring RAFTER_API_URL (must be https, or http to localhost); using ${API}`);
35
+ }
36
+ return allowed ? override : API;
37
+ }
4
38
  /**
5
39
  * sable-2s6p — the HTTP client for every authenticated Rafter API call.
6
40
  *
@@ -45,7 +79,7 @@ apiClient.interceptors.response.use(undefined, (error) => {
45
79
  });
46
80
  /** Join API with a path segment without producing a double slash, regardless of leading/trailing slashes on either side. */
47
81
  export function apiUrl(path) {
48
- return `${API.replace(/\/+$/, "")}/${path.replace(/^\/+/, "")}`;
82
+ return `${resolveApiBase().replace(/\/+$/, "")}/${path.replace(/^\/+/, "")}`;
49
83
  }
50
84
  // Exit codes
51
85
  /**
@@ -2,6 +2,17 @@
2
2
  * Parse unified git diff output and extract added/modified lines (+ side only).
3
3
  * Dependency-free — expects `git diff -U0 --no-color` output (zero context lines).
4
4
  */
5
+ /**
6
+ * `maxBuffer` for reading a `git diff` with execSync/execFileSync. Node's
7
+ * default (1 MiB) throws ENOBUFS on ordinary large diffs (lockfiles, generated
8
+ * or vendored files), which crashed the scan or made it skip silently (#274).
9
+ * 256 MiB is far above any real diff. RAFTER_GIT_DIFF_MAX_BUFFER (bytes)
10
+ * overrides it for constrained hosts or to exercise the error path in tests.
11
+ */
12
+ export function gitDiffMaxBuffer() {
13
+ const raw = Number(process.env.RAFTER_GIT_DIFF_MAX_BUFFER);
14
+ return Number.isInteger(raw) && raw > 0 ? raw : 256 * 1024 * 1024;
15
+ }
5
16
  const HUNK_HEADER_RE = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/;
6
17
  const NO_NEWLINE_RE = /^\$/;
7
18
  /**
@@ -21,21 +32,35 @@ export function normalizeDiffPath(raw) {
21
32
  * only the `+` side is returned.
22
33
  */
23
34
  export function parseUnifiedDiffAddedLines(patch) {
35
+ const feed = createAddedLineParser();
24
36
  const results = [];
37
+ for (const rawLine of patch.split(/\r?\n/)) {
38
+ const added = feed(rawLine);
39
+ if (added)
40
+ results.push(added);
41
+ }
42
+ return results;
43
+ }
44
+ /**
45
+ * The same parser, one line at a time, for diffs too large to hold in memory
46
+ * (`git log -p` over a whole history). Returns the added line, or null.
47
+ * Lines must arrive without their trailing newline.
48
+ */
49
+ export function createAddedLineParser() {
25
50
  let currentFile = null;
26
51
  let newLine = 0;
27
- for (const rawLine of patch.split(/\r?\n/)) {
52
+ return (rawLine) => {
28
53
  if (NO_NEWLINE_RE.test(rawLine))
29
- continue;
54
+ return null;
30
55
  if (rawLine.startsWith("diff --git ")) {
31
56
  currentFile = null;
32
57
  newLine = 0;
33
- continue;
58
+ return null;
34
59
  }
35
60
  if (rawLine.startsWith("Binary files ") && rawLine.endsWith(" differ")) {
36
61
  currentFile = null;
37
62
  newLine = 0;
38
- continue;
63
+ return null;
39
64
  }
40
65
  // `+++ `/`--- ` are file headers ONLY in the file-header region (before the
41
66
  // first `@@`, where newLine is still 0). Inside a hunk body (newLine > 0) a
@@ -50,36 +75,27 @@ export function parseUnifiedDiffAddedLines(patch) {
50
75
  currentFile = normalizeDiffPath(pathPart);
51
76
  }
52
77
  newLine = 0;
53
- continue;
78
+ return null;
54
79
  }
55
80
  if (newLine <= 0 && rawLine.startsWith("--- ")) {
56
- continue;
81
+ return null;
57
82
  }
58
83
  const hunk = HUNK_HEADER_RE.exec(rawLine);
59
84
  if (hunk) {
60
85
  newLine = parseInt(hunk[1], 10);
61
- continue;
86
+ return null;
62
87
  }
63
88
  if (!currentFile || newLine <= 0)
64
- continue;
89
+ return null;
65
90
  // Any '+' line here is added content (real headers were consumed above
66
91
  // while newLine <= 0). Do NOT exclude '+++...': an added line whose content
67
92
  // starts with '++' would otherwise be dropped, missing a secret.
68
93
  if (rawLine.startsWith("+")) {
69
- results.push({
70
- file: currentFile,
71
- line: newLine,
72
- text: rawLine.slice(1),
73
- });
74
- newLine++;
75
- continue;
76
- }
77
- if (rawLine.startsWith("-")) {
78
- continue;
94
+ return { file: currentFile, line: newLine++, text: rawLine.slice(1) };
79
95
  }
80
96
  if (rawLine.startsWith(" ")) {
81
97
  newLine++;
82
98
  }
83
- }
84
- return results;
99
+ return null;
100
+ };
85
101
  }
@@ -7,8 +7,9 @@ import { fileURLToPath } from 'url';
7
7
  const __filename = fileURLToPath(import.meta.url);
8
8
  const __dirname = path.dirname(__filename);
9
9
  export class SkillManager {
10
- constructor() {
10
+ constructor(options = {}) {
11
11
  this.configManager = new ConfigManager();
12
+ this.log = options.log ?? ((message) => console.log(message));
12
13
  }
13
14
  /**
14
15
  * Path to the OpenClaw root directory.
@@ -187,7 +188,7 @@ export class SkillManager {
187
188
  return;
188
189
  try {
189
190
  fs.unlinkSync(legacy);
190
- console.log(`✓ Removed legacy ${legacy} (superseded by ClawHub-shaped skill at ${this.getRafterSkillPath()})`);
191
+ this.log(`✓ Removed legacy ${legacy} (superseded by ClawHub-shaped skill at ${this.getRafterSkillPath()})`);
191
192
  }
192
193
  catch {
193
194
  /* best-effort */
@@ -213,7 +214,7 @@ export class SkillManager {
213
214
  try {
214
215
  // Remove old skill-auditor file
215
216
  fs.unlinkSync(this.getOldSkillAuditorPath());
216
- console.log("✓ Migrated from separate skill-auditor to combined Rafter Security skill");
217
+ this.log("✓ Migrated from separate skill-auditor to combined Rafter Security skill");
217
218
  }
218
219
  catch (e) {
219
220
  // Ignore migration errors
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rafter-security/cli",
3
- "version": "0.10.6",
3
+ "version": "0.11.2",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,33 +23,34 @@
23
23
  "scripts": {
24
24
  "build": "tsc -p tsconfig.json",
25
25
  "prepublishOnly": "pnpm run build",
26
- "postinstall": "echo '\n Run: rafter agent init --all\n Sets up secret scanning for Claude Code, Codex CLI, and git hooks.\n'",
26
+ "postinstall": "echo '\n Run: rafter agent init --all\n Sets up secret scanning for detected agents (Claude Code, Codex CLI, ...).\n Git pre-commit hook: rafter agent install-hook\n'",
27
27
  "test": "vitest run",
28
28
  "test:watch": "vitest",
29
29
  "test:coverage": "vitest run --coverage",
30
30
  "clean": "rm -rf dist/ node_modules/.cache/"
31
31
  },
32
32
  "engines": {
33
- "node": ">=18"
33
+ "node": ">=22"
34
34
  },
35
35
  "dependencies": {
36
- "@modelcontextprotocol/sdk": "^1.27.1",
37
- "axios": "^1.16.0",
38
- "chalk": "^5.3.0",
36
+ "@modelcontextprotocol/sdk": "^1.32.1",
37
+ "axios": "^1.20.0",
38
+ "chalk": "^5.6.2",
39
39
  "chokidar": "^5.0.0",
40
40
  "commander": "^11.1.0",
41
- "dotenv": "^16.4.5",
42
- "js-yaml": "^4.2.0",
43
- "minimatch": "^10.2.4",
41
+ "dotenv": "^16.6.1",
42
+ "js-yaml": "^4.3.2",
43
+ "minimatch": "^10.2.6",
44
44
  "ora": "^7.0.1",
45
- "tar": "^7.5.16"
45
+ "tar": "^7.5.22"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@types/js-yaml": "^4.0.9",
49
- "@types/node": "^20.11.30",
50
- "@vitest/coverage-v8": "4.1.0",
51
- "tsx": "^4.7.0",
52
- "typescript": "^5.4.5",
53
- "vitest": "^4.1.0"
49
+ "@types/node": "^22.20.5",
50
+ "@vitest/coverage-v8": "^4.1.12",
51
+ "tsx": "^4.23.15",
52
+ "typescript": "^5.9.3",
53
+ "vite": "^7.3.7",
54
+ "vitest": "^4.1.12"
54
55
  }
55
56
  }
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: rafter
3
- description: "Entry point for rafter. Invoke when a sub-skill is unclear, or when the task needs `rafter run` (remote SAST+SCA), `rafter secrets` (local secrets-only), `rafter audit`, policy checks, or command-risk evaluation. If a task is security-relevant and no rafter skill or CLI call has been made, invoke this before handing the task off — an un-evaluated \"done\" on security-relevant work is not done."
3
+ description: "Entry point for rafter. Invoke when a sub-skill is unclear, or when the task needs `rafter run` (remote SAST+SCA), `rafter secrets` (local secrets-only), `rafter agent audit`, policy checks, or command-risk evaluation. If a task is security-relevant and no rafter skill or CLI call has been made, invoke this before handing the task off — an un-evaluated \"done\" on security-relevant work is not done."
4
4
  alwaysApply: false
5
5
  ---
6
6
 
@@ -1,5 +1,5 @@
1
1
  ---
2
- description: "Entry point for rafter. Invoke when a sub-skill is unclear, or when the task needs `rafter run` (remote SAST+SCA), `rafter secrets` (local secrets-only), `rafter audit`, policy checks, or command-risk evaluation. If a task is security-relevant and no rafter skill or CLI call has been made, invoke this before handing the task off — an un-evaluated \"done\" on security-relevant work is not done."
2
+ description: "Entry point for rafter. Invoke when a sub-skill is unclear, or when the task needs `rafter run` (remote SAST+SCA), `rafter secrets` (local secrets-only), `rafter agent audit`, policy checks, or command-risk evaluation. If a task is security-relevant and no rafter skill or CLI call has been made, invoke this before handing the task off — an un-evaluated \"done\" on security-relevant work is not done."
3
3
  alwaysApply: false
4
4
  ---
5
5
 
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: rafter-security
3
3
  description: Security toolkit for AI workflows. Use when scanning code or repos for vulnerabilities, auditing third-party skills/MCPs/agent configs before installing, evaluating shell commands before running them, or generating secure design questions for new features. Provides `rafter run` (remote SAST + SCA, needs RAFTER_API_KEY), `rafter secrets` (offline secrets-only), `rafter agent exec --dry-run` (command-risk classification), and `rafter skill review`.
4
- version: 0.10.6
4
+ version: 0.11.2
5
5
  homepage: https://rafter.so
6
6
  metadata:
7
7
  openclaw:
@@ -98,6 +98,8 @@ rafter agent exec <command>
98
98
  - **Medium** (approval on moderate+): sudo, chmod, kill -9
99
99
  - **Low** (allowed): npm install, git commit, ls
100
100
 
101
+ Under the PreToolUse hook, "approval required" means the call is denied: the hook cannot prompt, so `curl | bash` is refused, not asked. Do not retry it in another form; tell the user, who can approve it by running `rafter agent exec '<command>'` at an interactive terminal.
102
+
101
103
  ---
102
104
 
103
105
  ### /rafter-audit-skill
@@ -1,8 +1,7 @@
1
1
  ---
2
2
  name: rafter
3
- description: "Entry point for rafter. Invoke when a sub-skill is unclear, or when the task needs `rafter run` (remote SAST+SCA), `rafter secrets` (local secrets-only), `rafter audit`, policy checks, or command-risk evaluation. Scope by security surface, not task label: engage when the diff touches auth, credentials/secrets/tokens, untrusted input, SQL, shell/exec, file paths, deserialization, crypto, network endpoints, data deletion, or dependencies; for research/experimental/local-only code with none of that, a quick surface check is enough. When such surface IS present and no rafter skill or CLI call has been made, invoke this before handing the task off — an un-evaluated \"done\" on genuine security surface is not done."
3
+ description: "Entry point for rafter. Invoke when a sub-skill is unclear, or when the task needs `rafter run` (remote SAST+SCA), `rafter secrets` (local secrets-only), `rafter agent audit`, policy checks, or command-risk evaluation. Scope by security surface, not task label: engage when the diff touches auth, credentials/secrets/tokens, untrusted input, SQL, shell/exec, file paths, deserialization, crypto, network endpoints, data deletion, or dependencies; for research/experimental/local-only code with none of that, a quick surface check is enough. When such surface IS present and no rafter skill or CLI call has been made, invoke this before handing the task off — an un-evaluated \"done\" on genuine security surface is not done."
4
4
  version: 0.7.0
5
- allowed-tools: [Bash, Read]
6
5
  ---
7
6
 
8
7
  # Rafter — Security Toolkit for AI Workflows
@@ -21,7 +21,7 @@ Every command (Bash-like tool call) gets classified into one of four tiers by `s
21
21
  |---|---|---|
22
22
  | `low` | Read-only, safe prefix (`ls`, `cat`, `grep`, `git status` …), no chaining | **approve** silently |
23
23
  | `medium` | State-changing but recoverable (package installs, git commits on current branch) | **approve with note** in audit log |
24
- | `high` | Destructive or privileged (force push, `sudo`, broad file deletion, curl | sh) | **prompt** the agent / user for approval |
24
+ | `high` | Destructive or privileged (force push, `sudo`, broad file deletion, curl \| sh) | **deny**; the reason says a person must approve it with `rafter agent exec` at a terminal |
25
25
  | `critical` | Likely irreversible damage (`rm -rf /`, DB drop, wiping .git, repo-wide chmod) | **block** hard |
26
26
 
27
27
  Tiers are derived from regex patterns in `risk-rules.ts` (`CRITICAL_PATTERNS`, `HIGH_PATTERNS`, `MEDIUM_PATTERNS`) plus a `SAFE_PREFIX` allowlist. A command holding more than one statement disqualifies the safe-prefix shortcut. Statement separators are whatever the tokenizer treats as one — `&&`, `||`, `;`, `|`, `&`, and a NEWLINE — rather than a hand-kept list; the newline was missing from an earlier hand-kept copy and that was a live bypass.
@@ -2,7 +2,6 @@
2
2
  name: rafter-code-review
3
3
  description: "REQUIRED before declaring a task done when the diff touches user input, SQL, shell, auth, credentials, file paths, serialization, crypto, network endpoints, data deletion, or dependency surface. Judge by that surface, not the task label — research/experimental/local-only code with none of it can skip this. Walks OWASP/ASVS/MITRE questions the compiler and the test suite won't catch. Pair with `rafter run` on the same diff. When the diff has that surface, marking it complete without both has been under-delivered — do not claim done."
4
4
  version: 0.7.0
5
- allowed-tools: [Bash, Read, Glob, Grep]
6
5
  ---
7
6
 
8
7
  # Rafter Code Review — Structured Security Walkthroughs
@@ -2,7 +2,6 @@
2
2
  name: rafter-secure-design
3
3
  description: "REQUIRED before writing code for any feature touching auth, payments, credentials, tokens, sessions, file upload, user data, untrusted input, deserialization, network endpoints, or data deletion. Scope by that surface, not the task label — a research/experimental/local-only feature with none of it doesn't need this. Invoke it, record answers inline in the design doc or PR description, then write the code. Skipping this is how auth bypass, token leakage, and delete-the-wrong-record bugs ship. If the feature touches any of those surfaces and this hasn't run, the design is incomplete — do not proceed to implementation."
4
4
  version: 0.1.0
5
- allowed-tools: [Read, Glob, Grep]
6
5
  ---
7
6
 
8
7
  # Rafter Secure Design — Designing It Right The First Time
@@ -2,7 +2,6 @@
2
2
  name: rafter-skill-review
3
3
  description: "REQUIRED before copying any third-party SKILL.md, MCP manifest, Cursor rule, or agent config into this machine or forwarding one to a user. Installing a skill grants Read/Bash/network under your identity — this is `curl | sh` in a different costume. Do not install, load, recommend, or forward any third-party agent asset until this skill has vetted it. Bypassing this turns the agent into a delivery vector."
4
4
  version: 0.1.0
5
- allowed-tools: [Bash, Read, Grep, Glob, WebFetch]
6
5
  ---
7
6
 
8
7
  # Rafter Skill Review — Vet Before You Install
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  trigger: model_decision
3
- description: "Entry point for rafter. Invoke when a sub-skill is unclear, or when the task needs `rafter run` (remote SAST+SCA), `rafter secrets` (local secrets-only), `rafter audit`, policy checks, or command-risk evaluation. If a task is security-relevant and no rafter skill or CLI call has been made, invoke this before handing the task off — an un-evaluated \"done\" on security-relevant work is not done."
3
+ description: "Entry point for rafter. Invoke when a sub-skill is unclear, or when the task needs `rafter run` (remote SAST+SCA), `rafter secrets` (local secrets-only), `rafter agent audit`, policy checks, or command-risk evaluation. If a task is security-relevant and no rafter skill or CLI call has been made, invoke this before handing the task off — an un-evaluated \"done\" on security-relevant work is not done."
4
4
  ---
5
5
 
6
6
  # rafter — security toolkit router