@yagni-app/code-staging 0.3.0-staging.1079.1 → 0.3.0-staging.1081.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Heuristic secret redaction for Guardian storage events (YAG-510).
3
+ *
4
+ * Applied client-side, BEFORE anything leaves the machine, to both the
5
+ * command and the Guardian rationale (which routinely quotes the command) —
6
+ * and only on the raw storage tier; the base tier never transmits either.
7
+ *
8
+ * Honest scope: this catches the obvious, well-known secret shapes. A secret
9
+ * in a novel shape gets through — which is why raw-tier storage is an
10
+ * explicit-consent, per-workspace opt-in and never a default.
11
+ *
12
+ * Pure, no external deps (bundling constraint — see execPolicy.ts header).
13
+ */
14
+ const REDACTED = "[REDACTED]";
15
+ /** Exactly 40 hex chars = a git SHA; keep those readable for analysis. */
16
+ function isGitSha(token) {
17
+ return /^[0-9a-f]{40}$/i.test(token);
18
+ }
19
+ const RULES = [
20
+ // Known token shapes (provider-prefixed credentials).
21
+ { re: /\bAKIA[0-9A-Z]{16}\b/g },
22
+ { re: /\bgh[pousr]_[A-Za-z0-9_]{20,}\b/g },
23
+ { re: /\bgithub_pat_[A-Za-z0-9_]{20,}\b/g },
24
+ { re: /\bsk-[A-Za-z0-9_-]{16,}\b/g },
25
+ { re: /\bxox[bpsaro]-[A-Za-z0-9-]{10,}\b/g },
26
+ { re: /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{4,}(?:\.[A-Za-z0-9_-]+)?\b/g }, // JWT
27
+ { re: /\bglsa_[A-Za-z0-9_]{20,}\b/g },
28
+ { re: /\b(?:fly|glpat|npm)_[A-Za-z0-9_-]{16,}\b/g },
29
+ // Authorization headers: keep the scheme, redact the credential.
30
+ { re: /\b(Authorization:\s*(?:Bearer|Basic|Token)\s+)[^\s"']+/gi, keepGroup1: true },
31
+ // key=value / --key value / --key=value with a secret-shaped key.
32
+ {
33
+ re: /((?:--?[A-Za-z0-9_-]*)?(?:password|passwd|secret|token|api[_-]?key|auth)[A-Za-z0-9_-]*\s*[=\s]\s*)[^\s"']+/gi,
34
+ keepGroup1: true,
35
+ },
36
+ // user:pass@ in URLs — redact the password only.
37
+ { re: /(\/\/[^\s/:@"']+:)[^\s@"']+(?=@)/g, keepGroup1: true },
38
+ ];
39
+ /** High-entropy runs: 32+ base64/hex chars — except exact git SHAs. */
40
+ const LONG_RUN_RE = /[A-Za-z0-9+/=_-]{32,}/g;
41
+ /**
42
+ * Redact known secret shapes from a command or rationale string. Structure
43
+ * is preserved (only matched values become [REDACTED]) so the redacted text
44
+ * stays analyzable.
45
+ */
46
+ export function redactCommand(text) {
47
+ let out = text;
48
+ for (const rule of RULES) {
49
+ out = out.replace(rule.re, (match, g1) => rule.keepGroup1 && typeof g1 === "string" ? `${g1}${REDACTED}` : REDACTED);
50
+ }
51
+ out = out.replace(LONG_RUN_RE, (match) => {
52
+ if (isGitSha(match))
53
+ return match;
54
+ if (match === REDACTED.slice(1, -1))
55
+ return match;
56
+ // Plain long words (paths, flags already handled above) that are all
57
+ // lowercase letters are more likely English than entropy; keep them.
58
+ if (/^[a-z]+$/.test(match) || /^[A-Z]+$/.test(match))
59
+ return match;
60
+ return REDACTED;
61
+ });
62
+ return out;
63
+ }
64
+ //# sourceMappingURL=redact.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yagni-app/code-staging",
3
- "version": "0.3.0-staging.1079.1",
3
+ "version": "0.3.0-staging.1081.1",
4
4
  "description": "YAGNI Code: a terminal coding agent that already knows your company. One YAGNI login routes the model and grounds the agent in your team's context.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "author": "YAGNI, Inc. <jack@yagni.app> (https://yagni.app)",
@@ -38,5 +38,5 @@
38
38
  "@earendil-works/pi-tui": "0.84.1",
39
39
  "typebox": "^1.3.11"
40
40
  },
41
- "yagniSourceSha": "a542e64e336db6c91e55455e9eb5d4cb584e012b"
41
+ "yagniSourceSha": "dd068fdb7b8bcb1207ff4f2fe803bf26b2e3eec3"
42
42
  }