@rafter-security/cli 0.11.1 → 0.11.3

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.
@@ -3,9 +3,8 @@ import fs from "fs";
3
3
  import os from "os";
4
4
  import path from "path";
5
5
  import { fmt } from "../../utils/formatter.js";
6
- import { RegexScanner } from "../../scanners/regex-scanner.js";
7
- import { BetterleaksScanner } from "../../scanners/betterleaks.js";
8
6
  import { ConfigManager } from "../../core/config-manager.js";
7
+ import { selectEngine, scanFile, scanDirectory } from "./scan.js";
9
8
  const BASELINE_PATH = path.join(os.homedir(), ".rafter", "baseline.json");
10
9
  function loadBaseline() {
11
10
  if (!fs.existsSync(BASELINE_PATH)) {
@@ -55,13 +54,19 @@ function createBaselineCreateCommand() {
55
54
  const cfg = manager.loadWithPolicy();
56
55
  const scanCfg = cfg.agent?.scan;
57
56
  console.error(`Scanning ${resolvedPath} to build baseline...`);
58
- const engine = await selectEngine(opts.engine || "auto");
57
+ // Use the same engine selection and union the scan command uses, so the
58
+ // baseline captures exactly what a later `rafter secrets` would find
59
+ // (sable-qb9g). In `auto` this runs BOTH engines and unions; the old
60
+ // local helpers ran betterleaks-only, so a secret only the patterns
61
+ // engine catches never made it into the baseline.
62
+ const autoUpdate = scanCfg?.autoUpdateBetterleaks !== false;
63
+ const { engine } = await selectEngine(opts.engine || "auto", false, autoUpdate);
59
64
  let results;
60
65
  if (fs.statSync(resolvedPath).isDirectory()) {
61
66
  results = await scanDirectory(resolvedPath, engine, scanCfg);
62
67
  }
63
68
  else {
64
- results = await scanFile(resolvedPath, engine);
69
+ results = await scanFile(resolvedPath, engine, scanCfg);
65
70
  }
66
71
  const now = new Date().toISOString();
67
72
  const entries = [];
@@ -165,49 +170,3 @@ function createBaselineAddCommand() {
165
170
  console.log(fmt.success(`Added to baseline: ${opts.pattern} in ${opts.file}`));
166
171
  });
167
172
  }
168
- // ── helpers ─────────────────────────────────────────────────────────
169
- async function selectEngine(preference) {
170
- if (preference === "patterns")
171
- return "patterns";
172
- if (preference === "betterleaks") {
173
- const b = new BetterleaksScanner();
174
- return (await b.isAvailable()) ? "betterleaks" : "patterns";
175
- }
176
- if (preference !== "auto") {
177
- console.error(`Invalid engine: ${preference}. Valid values: auto, betterleaks, patterns`);
178
- process.exit(2);
179
- }
180
- const b = new BetterleaksScanner();
181
- return (await b.isAvailable()) ? "betterleaks" : "patterns";
182
- }
183
- async function scanFile(filePath, engine) {
184
- if (engine === "betterleaks") {
185
- try {
186
- const b = new BetterleaksScanner();
187
- const r = await b.scanFile(filePath);
188
- return r.matches.length > 0 ? [r] : [];
189
- }
190
- catch {
191
- const s = new RegexScanner();
192
- const r = s.scanFile(filePath);
193
- return r.matches.length > 0 ? [r] : [];
194
- }
195
- }
196
- const s = new RegexScanner();
197
- const r = s.scanFile(filePath);
198
- return r.matches.length > 0 ? [r] : [];
199
- }
200
- async function scanDirectory(dirPath, engine, scanCfg) {
201
- if (engine === "betterleaks") {
202
- try {
203
- const b = new BetterleaksScanner();
204
- return await b.scanDirectory(dirPath);
205
- }
206
- catch {
207
- const s = new RegexScanner();
208
- return s.scanDirectory(dirPath, { excludePaths: scanCfg?.excludePaths });
209
- }
210
- }
211
- const s = new RegexScanner();
212
- return s.scanDirectory(dirPath, { excludePaths: scanCfg?.excludePaths });
213
- }
@@ -981,9 +981,14 @@ function aiderRead() {
981
981
  fs.writeFileSync(configPath, yaml.dump(parsed), "utf-8");
982
982
  },
983
983
  uninstall: () => {
984
- if (fs.existsSync(rafterMdPath)) {
984
+ // Excise only the managed block; any user content in RAFTER.md survives.
985
+ // If the file was ours alone (nothing but the block), remove it.
986
+ // A RAFTER.md with no markers is user-authored — leave it untouched.
987
+ if (fs.existsSync(rafterMdPath) && stripMarkerBlock(rafterMdPath)) {
985
988
  try {
986
- fs.rmSync(rafterMdPath, { force: true });
989
+ if (fs.readFileSync(rafterMdPath, "utf-8").trim() === "") {
990
+ fs.rmSync(rafterMdPath, { force: true });
991
+ }
987
992
  }
988
993
  catch { /* best-effort */ }
989
994
  }
@@ -326,6 +326,10 @@ function outputScanResults(results, opts, context, exitOnFindings = true, suppre
326
326
  // Exit code: findings dominate (1); otherwise an unreadable file is a scan
327
327
  // that could not complete cleanly (2); a clean, complete scan is 0.
328
328
  const scanExitCode = keptResults.length > 0 ? 1 : readErrors.length > 0 ? 2 : 0;
329
+ // Before the format branches, so --json and SARIF runs are recorded too. A
330
+ // clean scan is recorded as well: "we looked on this date and found nothing"
331
+ // is what a postmortem needs.
332
+ logScanToAudit(keptResults, context);
329
333
  if (format === "sarif") {
330
334
  outputSarif(keptResults, scanExitCode);
331
335
  return;
@@ -592,7 +596,7 @@ function diffModeReport(opts) {
592
596
  * scanning. The caller resolves this from `--no-auto-update` and the
593
597
  * `scan.auto_update_betterleaks` config key.
594
598
  */
595
- async function selectEngine(preference, quiet, autoUpdate = true) {
599
+ export async function selectEngine(preference, quiet, autoUpdate = true) {
596
600
  if (preference === "patterns") {
597
601
  return { engine: "patterns", reason: null };
598
602
  }
@@ -682,7 +686,7 @@ export function autoUpdateEnabled(opts, scanCfg) {
682
686
  /**
683
687
  * Scan a file with selected engine
684
688
  */
685
- async function scanFile(filePath, engine, scanCfg, report) {
689
+ export async function scanFile(filePath, engine, scanCfg, report) {
686
690
  const runPatterns = () => {
687
691
  const scanner = new RegexScanner(scanCfg?.customPatterns);
688
692
  const result = scanner.scanFile(filePath);
@@ -729,7 +733,7 @@ function errorText(e) {
729
733
  /**
730
734
  * Scan a directory with selected engine
731
735
  */
732
- async function scanDirectory(dirPath, engine, scanCfg, history, respectGitignore, report) {
736
+ export async function scanDirectory(dirPath, engine, scanCfg, history, respectGitignore, report) {
733
737
  // respectGitignore default is true. Both engines honor it: the patterns
734
738
  // engine via RegexScanner.scanDirectory, betterleaks by scanning only the
735
739
  // files git does not ignore (BetterleaksScanner.scanDirectory, #262).
@@ -884,6 +888,45 @@ async function watchAndScan(watchPath, opts, scanCfg, suppressions = []) {
884
888
  });
885
889
  });
886
890
  }
891
+ /**
892
+ * Record that a scan ran, so `rafter agent audit` has something in it.
893
+ *
894
+ * `rafter secrets` told the user "Run 'rafter agent audit' to see the security
895
+ * log" and the log was always empty, because only command interception ever
896
+ * wrote to it — three of seven beta users followed that hint and hit a dead
897
+ * end, one of them immediately after a correct and useful scan result. The
898
+ * first thing a careful person does with a security finding is look for the
899
+ * record of it.
900
+ *
901
+ * Counts and pattern NAMES only — never a matched value, not even redacted.
902
+ * The audit log is a postmortem artifact that outlives the terminal, so it
903
+ * must not become a second place secrets live.
904
+ */
905
+ function logScanToAudit(results, context) {
906
+ try {
907
+ const totalMatches = results.reduce((n, r) => n + r.matches.length, 0);
908
+ const patterns = [...new Set(results.flatMap((r) => r.matches.map((m) => m.pattern.name)))].sort();
909
+ new AuditLogger().log({
910
+ eventType: "scan_executed",
911
+ securityCheck: {
912
+ passed: totalMatches === 0,
913
+ reason: totalMatches === 0
914
+ ? "Secret scan completed with no findings"
915
+ : `Secret scan found ${totalMatches} secret(s) in ${results.length} file(s)`,
916
+ details: {
917
+ filesWithFindings: results.length,
918
+ totalMatches,
919
+ patterns,
920
+ ...(context ? { context } : {}),
921
+ },
922
+ },
923
+ resolution: { actionTaken: totalMatches === 0 ? "allowed" : "blocked" },
924
+ });
925
+ }
926
+ catch {
927
+ // Never let audit logging break a scan — the scan result is the product.
928
+ }
929
+ }
887
930
  /**
888
931
  * Log watch findings to audit log
889
932
  */
@@ -22,7 +22,10 @@ export function createCiInitCommand() {
22
22
  console.error(`Valid options: ${validPlatforms.join(", ")}`);
23
23
  process.exit(1);
24
24
  }
25
- const includeRemote = !!(opts.includeRemote || opts.withBackend);
25
+ // commander stores `--with-remote` as `opts.withRemote`; `--with-backend`
26
+ // is the deprecated alias. Reading a non-existent `opts.includeRemote`
27
+ // meant `--with-remote` silently dropped the security-audit job (sable-o7vh).
28
+ const includeRemote = !!(opts.withRemote || opts.withBackend);
26
29
  const { content, defaultPath } = generateTemplate(platform, includeRemote);
27
30
  const outputPath = opts.output || defaultPath;
28
31
  const outputDir = path.dirname(outputPath);
@@ -97,6 +97,14 @@ function evaluateToolResponse(payload) {
97
97
  modified = true;
98
98
  }
99
99
  }
100
+ // Scan and redact the error field (sable-t578). A tool that fails and echoes
101
+ // a credential in its error text surfaces it to the user just like output.
102
+ if (typeof tool_response.error === "string" && tool_response.error) {
103
+ if (scanner.hasSecrets(tool_response.error)) {
104
+ redacted.error = scanner.redact(tool_response.error);
105
+ modified = true;
106
+ }
107
+ }
100
108
  if (modified) {
101
109
  const audit = new AuditLogger();
102
110
  const matchCount = countMatches(scanner, tool_response);
@@ -113,6 +121,9 @@ function countMatches(scanner, tool_response) {
113
121
  if (typeof tool_response?.content === "string" && tool_response.content) {
114
122
  count += scanner.scanText(tool_response.content).length;
115
123
  }
124
+ if (typeof tool_response?.error === "string" && tool_response.error) {
125
+ count += scanner.scanText(tool_response.error).length;
126
+ }
116
127
  return count;
117
128
  }
118
129
  // Bound the stdin read so a hung/never-closing stdin can't wedge the hook.
@@ -7,76 +7,97 @@ import path from "path";
7
7
  const execFileAsync = promisify(execFile);
8
8
  /** Per-invocation timeout for the betterleaks subprocess. */
9
9
  const SCAN_TIMEOUT_MS = 60000;
10
+ /** Config env vars betterleaks consults before the target's own .toml, in its order. */
11
+ const CONFIG_PATH_ENV_VARS = ["BETTERLEAKS_CONFIG", "GITLEAKS_CONFIG"];
12
+ const CONFIG_TOML_ENV_VARS = ["BETTERLEAKS_CONFIG_TOML", "GITLEAKS_CONFIG_TOML"];
10
13
  /**
11
- * Budget for the path arguments of one `betterleaks dir` call. Windows caps a
12
- * whole command line at 32,767 characters; elsewhere the limit is far larger.
14
+ * Paths under `dirPath` that a git-aware scan must skip, relative to it: what
15
+ * git ignores (a wholly ignored directory as one `dir/` entry), submodules (a
16
+ * gitlink, mode 160000, in the index) and untracked nested repositories (which
17
+ * `ls-files --others` lists as one `dir/` entry). Git lists no files inside
18
+ * either kind, so the file-list scan this replaced never scanned them. A
19
+ * tracked path that is now a directory on disk is NOT skipped: its files are
20
+ * untracked and get scanned. Returns null when `dirPath` is not inside a git
21
+ * work tree or git is unavailable, so the caller scans the directory whole.
13
22
  */
14
- const ARG_CHARS_PER_CALL = process.platform === "win32" ? 24000 : 500000;
23
+ export function gitSkippedPaths(dirPath) {
24
+ const ls = (...args) => {
25
+ const r = spawnSync("git", ["-C", dirPath, "ls-files", "-z", ...args, "--", "."], {
26
+ encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"], timeout: 30000, maxBuffer: 256 * 1024 * 1024,
27
+ });
28
+ if (r.status !== 0 || typeof r.stdout !== "string")
29
+ return null;
30
+ return r.stdout.split("\0").filter(Boolean);
31
+ };
32
+ const ignored = ls("--others", "--ignored", "--exclude-standard", "--directory");
33
+ const staged = ls("--cached", "--stage");
34
+ const untracked = ls("--others", "--exclude-standard");
35
+ if (ignored === null || staged === null || untracked === null)
36
+ return null;
37
+ // `--stage` lines read "<mode> <object> <stage>\t<path>".
38
+ const submodules = staged.filter((l) => l.startsWith("160000 ")).map((l) => l.slice(l.indexOf("\t") + 1));
39
+ const nestedRepos = untracked.filter((rel) => rel.endsWith("/"));
40
+ return [...ignored, ...submodules, ...nestedRepos];
41
+ }
15
42
  /**
16
- * Maximum number of file paths handed to one `betterleaks dir` invocation.
17
- *
18
- * sable-jiqb — betterleaks' run time scales with the length of the explicit
19
- * file list it is given (measured ~0.2s/file: 50 files ~10s, 300 files ~60s),
20
- * not with the size of the files. A whole git-tracked list on a few-hundred-file
21
- * repo therefore exceeds SCAN_TIMEOUT_MS in a single call and the engine falls
22
- * back to patterns. Capping each call at this many files keeps every invocation
23
- * well under the timeout (~0.2s * 64 ~= 13s, roughly a fifth of the 60s floor,
24
- * leaving headroom on a loaded box); the full tree is covered across as many
25
- * sequential calls as it takes, and their findings are unioned by file.
43
+ * Write `s` as a TOML basic string. JSON escapes every control character
44
+ * TOML forbids raw except DEL (U+007F), which would make the whole config
45
+ * unreadable and drop the scan to the patterns engine.
26
46
  */
27
- export const MAX_FILES_PER_CALL = 64;
28
- /** Config env vars betterleaks consults before the target's own .toml. */
29
- const CONFIG_ENV_VARS = [
30
- "BETTERLEAKS_CONFIG", "GITLEAKS_CONFIG", "BETTERLEAKS_CONFIG_TOML", "GITLEAKS_CONFIG_TOML",
31
- ];
47
+ function tomlString(s) {
48
+ return JSON.stringify(s).replace(/\x7f/g, "\\u007f");
49
+ }
32
50
  /**
33
- * Files under `dirPath` that git does not ignore (tracked, plus untracked and
34
- * not ignored), as absolute paths. Returns null when `dirPath` is not inside a
35
- * git work tree or git is unavailable, so the caller scans the directory whole.
51
+ * A regex (RE2, JS and Python read it alike) matching `p` and everything below
52
+ * it. Only on Windows is `\\` a separator; on POSIX it is an ordinary filename
53
+ * character and stays literal, or an ignored `a\\b` would also skip `a/b`.
36
54
  */
37
- export function gitVisibleFiles(dirPath) {
38
- const r = spawnSync("git", ["-C", dirPath, "ls-files", "-z", "--cached", "--others", "--exclude-standard", "--", "."], { encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"], timeout: 30000, maxBuffer: 256 * 1024 * 1024 });
39
- if (r.status !== 0 || typeof r.stdout !== "string")
40
- return null;
41
- const files = new Set();
42
- for (const rel of r.stdout.split("\0")) {
43
- if (!rel)
44
- continue;
45
- const abs = path.join(dirPath, rel);
46
- try {
47
- // Skip deleted-but-tracked paths, submodule dirs and symlinks (betterleaks
48
- // does not follow symlinks by default either).
49
- if (fs.lstatSync(abs).isFile())
50
- files.add(abs);
51
- }
52
- catch {
53
- // deleted from the work tree
54
- }
55
- }
56
- return [...files];
55
+ function pathPrefixPattern(p) {
56
+ const slashed = (process.platform === "win32" ? p.replace(/\\/g, "/") : p).replace(/\/+$/, "");
57
+ return "^" + slashed.replace(/[\\.+*?()|[\]{}^$]/g, "\\$&") + "(?:/.*)?$";
57
58
  }
58
59
  /**
59
- * Split `paths` into groups that stay within both bounds: at most `maxCount`
60
- * paths per group (sable-jiqb — betterleaks' cost scales with the file count,
61
- * so this is what keeps each invocation under the timeout) and a joined length
62
- * under `budget` chars (the OS command-line cap, the original #262 constraint).
60
+ * The betterleaks config for one git-aware directory scan: the config the scan
61
+ * would otherwise use (`baseToml`, its text; betterleaks' default rules when
62
+ * null) plus a global path allowlist for `skipped`, so one
63
+ * `betterleaks dir <root>` walk passes over those paths without reading them.
64
+ *
65
+ * The base config is copied in, not extended: betterleaks 1.1.x stops
66
+ * following `[extend]` two levels down, so wrapping a repo config that itself
67
+ * extends a shared config (which extends the defaults) silently dropped the
68
+ * default rules. A relative `extend.path` in the copy still resolves as it
69
+ * did, against the working directory. The deprecated `[allowlist]` table is
70
+ * renamed to `[[allowlists]]`, its equivalent, since betterleaks rejects a
71
+ * config that has both.
72
+ *
73
+ * #262 — rafter used to hand betterleaks the git-visible files as path
74
+ * arguments, 64 per call. betterleaks 1.1.x rebuilds its config and detector
75
+ * for every path argument (~0.2s each with the default rules), and its
76
+ * `extend` depth counter is a process global it never resets, so with a config
77
+ * that extends another (`[extend] useDefault = true`) only the first two path
78
+ * arguments of a call got the extended rules: every later file was scanned
79
+ * with the repo's own rules alone. A single walk builds one detector and
80
+ * applies the full rule set to every file.
63
81
  */
64
- function chunkFiles(paths, budget, maxCount) {
65
- const chunks = [];
66
- let cur = [];
67
- let len = 0;
68
- for (const p of paths) {
69
- if (cur.length > 0 && (cur.length >= maxCount || len + p.length + 1 > budget)) {
70
- chunks.push(cur);
71
- cur = [];
72
- len = 0;
73
- }
74
- cur.push(p);
75
- len += p.length + 1;
76
- }
77
- if (cur.length > 0)
78
- chunks.push(cur);
79
- return chunks;
82
+ export function scanConfigToml(dirPath, skipped, baseToml) {
83
+ const patterns = [
84
+ "(?:^|/)\\.git(?:/.*)?$",
85
+ ...skipped.map((rel) => pathPrefixPattern(path.join(dirPath, rel))),
86
+ ];
87
+ const base = baseToml === null
88
+ ? ["[extend]", "useDefault = true"]
89
+ : [baseToml.replace(/^[ \t]*\[[ \t]*allowlist[ \t]*\][ \t]*(#.*)?$/gm, "[[allowlists]]")];
90
+ return [
91
+ "# Generated by rafter for one scan (scanConfigToml, rafter's betterleaks scanner).",
92
+ ...base,
93
+ "",
94
+ "[[allowlists]]",
95
+ 'description = "rafter: paths git ignores"',
96
+ "paths = [",
97
+ ...patterns.map((p) => ` ${tomlString(p)},`),
98
+ "]",
99
+ "",
100
+ ].join("\n");
80
101
  }
81
102
  /** Name why a betterleaks subprocess failed: a timeout reads differently from a crash. */
82
103
  function describeFailure(e) {
@@ -190,8 +211,8 @@ export class BetterleaksScanner {
190
211
  * walks node_modules, build output and local secret stores (.env) alike:
191
212
  * slow enough to hit the timeout on an ordinary checkout, and noisy (#262).
192
213
  * With respectGitignore (the default, matching the patterns engine) and a
193
- * target inside a git work tree, it is handed git's own list of non-ignored
194
- * files instead.
214
+ * target inside a git work tree, it walks the tree once under a generated
215
+ * config that skips what git ignores (see scanConfigToml).
195
216
  */
196
217
  async scanDirectory(dirPath, opts) {
197
218
  const blPath = await this.resolveBinary();
@@ -201,26 +222,36 @@ export class BetterleaksScanner {
201
222
  if (opts?.useGit) {
202
223
  return this.groupByFile(await this.runDir(blPath, "git", [dirPath], []));
203
224
  }
204
- const files = opts?.respectGitignore === false ? null : gitVisibleFiles(dirPath);
205
- if (files === null) {
225
+ const skipped = opts?.respectGitignore === false ? null : gitSkippedPaths(dirPath);
226
+ if (skipped === null) {
206
227
  return this.groupByFile(await this.runDir(blPath, "dir", [dirPath], []));
207
228
  }
208
- // Given file paths instead of a directory, betterleaks no longer finds the
209
- // target's own .betterleaks.toml / .gitleaks.toml, so pass it explicitly
210
- // unless an env var already chooses the config (it outranks the file).
211
- const configArgs = [];
212
- if (!CONFIG_ENV_VARS.some((v) => process.env[v])) {
213
- const cfg = [".betterleaks.toml", ".gitleaks.toml"]
229
+ // Private 0700 dir, atomically created — see scanFile for the TOCTOU rationale (CWE-367).
230
+ const cfgDir = fs.mkdtempSync(path.join(os.tmpdir(), "betterleaks-cfg-"));
231
+ try {
232
+ // The generated config is passed as -c, which outranks every other
233
+ // source, so it carries whichever config betterleaks would have chosen,
234
+ // in betterleaks' own order: env path, env content, the target's file.
235
+ const envPath = CONFIG_PATH_ENV_VARS.map((v) => process.env[v]).find(Boolean);
236
+ const envToml = CONFIG_TOML_ENV_VARS.map((v) => process.env[v]).find(Boolean);
237
+ const repoPath = [".betterleaks.toml", ".gitleaks.toml"]
214
238
  .map((n) => path.join(dirPath, n))
215
239
  .find((p) => fs.existsSync(p));
216
- if (cfg)
217
- configArgs.push("-c", cfg);
240
+ const baseToml = envPath
241
+ ? fs.readFileSync(envPath, "utf-8")
242
+ : envToml ?? (repoPath ? fs.readFileSync(repoPath, "utf-8") : null);
243
+ const cfg = path.join(cfgDir, "scan.toml");
244
+ fs.writeFileSync(cfg, scanConfigToml(dirPath, skipped, baseToml));
245
+ return this.groupByFile(await this.runDir(blPath, "dir", [dirPath], ["-c", cfg]));
218
246
  }
219
- const findings = [];
220
- for (const chunk of chunkFiles(files, ARG_CHARS_PER_CALL, MAX_FILES_PER_CALL)) {
221
- findings.push(...(await this.runDir(blPath, "dir", chunk, configArgs)));
247
+ finally {
248
+ try {
249
+ fs.rmSync(cfgDir, { recursive: true, force: true });
250
+ }
251
+ catch {
252
+ // ignore
253
+ }
222
254
  }
223
- return this.groupByFile(findings);
224
255
  }
225
256
  /** One betterleaks invocation; returns its findings or throws with the cause. */
226
257
  async runDir(blPath, subcommand, targets, extraArgs) {
@@ -82,7 +82,8 @@ export class RegexScanner {
82
82
  ".ruff_cache",
83
83
  "results",
84
84
  ".terraform",
85
- "bower_components"
85
+ "bower_components",
86
+ ".trigger", // Trigger.dev build output (bundled JS + source maps)
86
87
  ];
87
88
  // Merge policy excludePaths into the exclude list
88
89
  if (options?.excludePaths) {
@@ -8,7 +8,7 @@ export const DEFAULT_SECRET_PATTERNS = [
8
8
  name: "AWS Access Key ID",
9
9
  // Negative lookahead excludes the canonical AWS-docs example key
10
10
  // (AKIAIOSFODNN7EXAMPLE and its siblings, which all end in EXAMPLE).
11
- // betterleaks skips these too (sable/#230); matching that keeps the two
11
+ // betterleaks skips these too (#230); matching that keeps the two
12
12
  // engines from disagreeing on a well-known public non-secret.
13
13
  regex: "(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)(?![A-Z0-9]{9}EXAMPLE)[A-Z0-9]{16}",
14
14
  severity: "critical",
@@ -16,7 +16,12 @@ export const DEFAULT_SECRET_PATTERNS = [
16
16
  },
17
17
  {
18
18
  name: "AWS Secret Access Key",
19
- 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}['\"]?",
20
25
  severity: "critical",
21
26
  description: "AWS Secret Access Key detected"
22
27
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rafter-security/cli",
3
- "version": "0.11.1",
3
+ "version": "0.11.3",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -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.11.1
4
+ version: 0.11.3
5
5
  homepage: https://rafter.so
6
6
  metadata:
7
7
  openclaw:
@@ -113,6 +113,7 @@ rafter usage # check API quota
113
113
 
114
114
  Full CLI tree: **Read `docs/cli-reference.md`**. Full digest: `rafter brief commands`.
115
115
 
116
+ **Scan budget:** Remote scans spend the user's quota. `rafter run` scans the **pushed** branch, so re-running without a new push repeats it — run it once per task or before a PR and reuse `rafter get <scan-id>`; while iterating scan only changes (`rafter secrets --staged` / `--diff <ref>`); never loop, retry, or `--watch` from an agent session — exit `3` means quota exhausted, so stop, tell the user, and check `rafter usage`.
116
117
  ## Configuration
117
118
 
118
119
  `rafter run` (the full code scan) needs an API key: