tenjin-cli 0.1.0-alpha.16 → 0.1.0-alpha.17

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 (110) hide show
  1. package/README.md +2 -0
  2. package/dist/chunk-2G2WLVHB.js +102 -0
  3. package/dist/chunk-2G2WLVHB.js.map +1 -0
  4. package/dist/chunk-2I4QTOLB.js +11 -0
  5. package/dist/chunk-2I4QTOLB.js.map +1 -0
  6. package/dist/{chunk-HVRC33OL.js → chunk-2JGT3KDW.js} +4 -6
  7. package/dist/{chunk-HVRC33OL.js.map → chunk-2JGT3KDW.js.map} +1 -1
  8. package/dist/chunk-35M3VITA.js +102 -0
  9. package/dist/chunk-35M3VITA.js.map +1 -0
  10. package/dist/{chunk-5X4SZ5BF.js → chunk-5QHHRMRA.js} +4 -4
  11. package/dist/{chunk-BFFM2WFK.js → chunk-5UDD5VSY.js} +2 -2
  12. package/dist/{chunk-BFFM2WFK.js.map → chunk-5UDD5VSY.js.map} +1 -1
  13. package/dist/{chunk-OIM4HLN6.js → chunk-7QKHZQKW.js} +295 -20
  14. package/dist/chunk-7QKHZQKW.js.map +1 -0
  15. package/dist/{chunk-BBVUVBUO.js → chunk-AR7U7BRG.js} +44 -7
  16. package/dist/{chunk-BBVUVBUO.js.map → chunk-AR7U7BRG.js.map} +1 -1
  17. package/dist/{chunk-DMZZLPZN.js → chunk-AUKDYPPX.js} +14 -89
  18. package/dist/chunk-AUKDYPPX.js.map +1 -0
  19. package/dist/{chunk-PZEN5PHN.js → chunk-J5INH7WB.js} +17 -3
  20. package/dist/chunk-J5INH7WB.js.map +1 -0
  21. package/dist/{chunk-7WEQQJLG.js → chunk-JLEF5WHM.js} +66 -2
  22. package/dist/chunk-JLEF5WHM.js.map +1 -0
  23. package/dist/{chunk-GULLJQXA.js → chunk-KK4YGYTV.js} +127 -17
  24. package/dist/chunk-KK4YGYTV.js.map +1 -0
  25. package/dist/{chunk-YEETV6IW.js → chunk-KUBEYXSO.js} +10 -12
  26. package/dist/{chunk-YEETV6IW.js.map → chunk-KUBEYXSO.js.map} +1 -1
  27. package/dist/{chunk-2U5ZVEV3.js → chunk-LJ4DMVFI.js} +5 -5
  28. package/dist/{chunk-3AJS6LLN.js → chunk-MRGADYDD.js} +7 -7
  29. package/dist/{chunk-25TJPVBF.js → chunk-O4ZNKFRU.js} +28 -15
  30. package/dist/chunk-O4ZNKFRU.js.map +1 -0
  31. package/dist/{chunk-OJLYNM4Z.js → chunk-PDA2BVFY.js} +77 -19
  32. package/dist/chunk-PDA2BVFY.js.map +1 -0
  33. package/dist/{chunk-L3PVMIYQ.js → chunk-QDD2RN7G.js} +29 -119
  34. package/dist/chunk-QDD2RN7G.js.map +1 -0
  35. package/dist/chunk-S2NRVRPF.js +171 -0
  36. package/dist/chunk-S2NRVRPF.js.map +1 -0
  37. package/dist/chunk-TGLKKLQG.js +11 -0
  38. package/dist/chunk-TGLKKLQG.js.map +1 -0
  39. package/dist/chunk-TP4D47BY.js +127 -0
  40. package/dist/chunk-TP4D47BY.js.map +1 -0
  41. package/dist/{chunk-WH7OWT6G.js → chunk-U2DZISAH.js} +2 -8
  42. package/dist/chunk-U2DZISAH.js.map +1 -0
  43. package/dist/{chunk-USS336NF.js → chunk-WGQVJM56.js} +5 -5
  44. package/dist/chunk-WGQVJM56.js.map +1 -0
  45. package/dist/{chunk-YJHHCWM3.js → chunk-WLMJE3GJ.js} +3 -3
  46. package/dist/{chunk-U5DXNFJC.js → chunk-WS4JA6TC.js} +3 -3
  47. package/dist/{chunk-SKAHDQH7.js → chunk-XZOEUYMX.js} +6 -7
  48. package/dist/{chunk-SKAHDQH7.js.map → chunk-XZOEUYMX.js.map} +1 -1
  49. package/dist/{cli-M3XCSOU6.js → cli-VHYYYYXM.js} +43 -29
  50. package/dist/{cli-M3XCSOU6.js.map → cli-VHYYYYXM.js.map} +1 -1
  51. package/dist/{config-MXOX7XDR.js → config-5ADBAAXU.js} +11 -10
  52. package/dist/{doctor-LU4YIZWM.js → doctor-Q35VQW3S.js} +108 -21
  53. package/dist/doctor-Q35VQW3S.js.map +1 -0
  54. package/dist/{fund-A54P2QFK.js → fund-GDDPL2BB.js} +11 -10
  55. package/dist/{fund-A54P2QFK.js.map → fund-GDDPL2BB.js.map} +1 -1
  56. package/dist/hook-command-PBERPRE3.js +763 -0
  57. package/dist/hook-command-PBERPRE3.js.map +1 -0
  58. package/dist/index.js +2 -2
  59. package/dist/{install-XUM2XSHW.js → install-OKDKGUXM.js} +21 -14
  60. package/dist/{install-wallet-QIOFORTX.js → install-wallet-SI4LZ73K.js} +10 -9
  61. package/dist/{install-wallet-QIOFORTX.js.map → install-wallet-SI4LZ73K.js.map} +1 -1
  62. package/dist/{mcp-HJC2PLRV.js → mcp-XX3WRQEZ.js} +63 -31
  63. package/dist/{mcp-HJC2PLRV.js.map → mcp-XX3WRQEZ.js.map} +1 -1
  64. package/dist/{pay-SBXZEPEP.js → pay-3SYKHKWJ.js} +15 -13
  65. package/dist/{redact-46ZHF2NH.js → redact-6W23GGJC.js} +4 -6
  66. package/dist/{send-ASD2ZXJD.js → send-LQRKTEJT.js} +10 -9
  67. package/dist/{send-ASD2ZXJD.js.map → send-LQRKTEJT.js.map} +1 -1
  68. package/dist/{skill-placement-NFVHY6A3.js → skill-placement-JMDPSKE6.js} +12 -13
  69. package/dist/{skill-placement-NFVHY6A3.js.map → skill-placement-JMDPSKE6.js.map} +1 -1
  70. package/dist/{status-T2SDB57A.js → status-FFC6FO72.js} +8 -7
  71. package/dist/{status-T2SDB57A.js.map → status-FFC6FO72.js.map} +1 -1
  72. package/dist/{status-line-CGPUSDMC.js → status-line-SAXSU6CR.js} +19 -3
  73. package/dist/status-line-SAXSU6CR.js.map +1 -0
  74. package/dist/{status-line-wiring-BYPHTYZE.js → status-line-wiring-L2WYIYBM.js} +5 -6
  75. package/dist/tenjin-daemon.mjs +384 -23
  76. package/dist/{uninstall-FKYZHAM3.js → uninstall-OACH27UV.js} +18 -15
  77. package/dist/{uninstall-FKYZHAM3.js.map → uninstall-OACH27UV.js.map} +1 -1
  78. package/dist/{update-ANJ2AOTN.js → update-4W6EKLGZ.js} +6 -7
  79. package/dist/{update-ANJ2AOTN.js.map → update-4W6EKLGZ.js.map} +1 -1
  80. package/dist/{wallet-PWAHVKWW.js → wallet-BMEXRR3P.js} +10 -9
  81. package/docs/agent-permissions.md +16 -8
  82. package/docs/safety-model.md +1 -1
  83. package/package.json +1 -1
  84. package/dist/chunk-25TJPVBF.js.map +0 -1
  85. package/dist/chunk-7WEQQJLG.js.map +0 -1
  86. package/dist/chunk-DMZZLPZN.js.map +0 -1
  87. package/dist/chunk-GULLJQXA.js.map +0 -1
  88. package/dist/chunk-L3PVMIYQ.js.map +0 -1
  89. package/dist/chunk-OCBHUHWB.js +0 -69
  90. package/dist/chunk-OCBHUHWB.js.map +0 -1
  91. package/dist/chunk-OIM4HLN6.js.map +0 -1
  92. package/dist/chunk-OJLYNM4Z.js.map +0 -1
  93. package/dist/chunk-PZEN5PHN.js.map +0 -1
  94. package/dist/chunk-USS336NF.js.map +0 -1
  95. package/dist/chunk-WH7OWT6G.js.map +0 -1
  96. package/dist/doctor-LU4YIZWM.js.map +0 -1
  97. package/dist/hook-command-U6KWPEDQ.js +0 -377
  98. package/dist/hook-command-U6KWPEDQ.js.map +0 -1
  99. package/dist/status-line-CGPUSDMC.js.map +0 -1
  100. /package/dist/{chunk-5X4SZ5BF.js.map → chunk-5QHHRMRA.js.map} +0 -0
  101. /package/dist/{chunk-2U5ZVEV3.js.map → chunk-LJ4DMVFI.js.map} +0 -0
  102. /package/dist/{chunk-3AJS6LLN.js.map → chunk-MRGADYDD.js.map} +0 -0
  103. /package/dist/{chunk-YJHHCWM3.js.map → chunk-WLMJE3GJ.js.map} +0 -0
  104. /package/dist/{chunk-U5DXNFJC.js.map → chunk-WS4JA6TC.js.map} +0 -0
  105. /package/dist/{config-MXOX7XDR.js.map → config-5ADBAAXU.js.map} +0 -0
  106. /package/dist/{install-XUM2XSHW.js.map → install-OKDKGUXM.js.map} +0 -0
  107. /package/dist/{pay-SBXZEPEP.js.map → pay-3SYKHKWJ.js.map} +0 -0
  108. /package/dist/{redact-46ZHF2NH.js.map → redact-6W23GGJC.js.map} +0 -0
  109. /package/dist/{status-line-wiring-BYPHTYZE.js.map → status-line-wiring-L2WYIYBM.js.map} +0 -0
  110. /package/dist/{wallet-PWAHVKWW.js.map → wallet-BMEXRR3P.js.map} +0 -0
@@ -1,9 +1,12 @@
1
1
  import { createRequire as __tenjinCreateRequire } from 'node:module'; const require = __tenjinCreateRequire(import.meta.url);
2
2
 
3
+ // src/lib/redact.ts
4
+ import { createHash } from "node:crypto";
5
+
3
6
  // src/lib/redact-rules.json
4
7
  var redact_rules_default = {
5
8
  schemaVersion: 1,
6
- note: "One rule table for every redaction surface in the CLI (src/lib/redact.ts), kept as data so the tenjin server-side ingest gate can vendor it verbatim. Every row is one detector: `id` is the stable finding `check`, `tier` is the finding severity, `match` is a JS regex or the name of an algorithmic detector a consumer must implement, `excerpt` is the masked-excerpt policy (never the secret), `skip` names a suppression predicate. `scopes` says where the row applies: `publish` (reported on the public marketplace), `team` (reported on a team shelf), `query` (its matches are replaced by the excerpt in hook queries by `mask()`; regex rows only). Precision first, as gitleaks and GitHub push protection do: a block row fires on a vendor prefix or an unambiguous shape, the generic `secret-assignment` row needs a secret-named word plus `=` or `:`, and entropy is never a trigger for a query. Table order is mask() order (the assignment row runs first, see its description). Several entries may share an `id`; they are one detector expressed as more than one pattern. Patterns adapted from gitleaks are MIT and attributed in NOTICE.md.",
9
+ note: "One rule table for every redaction surface in the CLI (src/lib/redact.ts), kept as data so the tenjin server-side ingest gate can vendor it verbatim. Every row is one detector: `id` is the stable finding `check`, `tier` is the finding severity, `match` is a JS regex or the name of an algorithmic detector a consumer must implement, `excerpt` is the masked-excerpt policy (never the secret), `skip` names a suppression predicate. `scopes` says where the row applies: `publish` (reported on the public marketplace), `team` (reported on a team shelf), `query` (its matches are replaced by the excerpt in hook queries and router packets by `mask()`; regex rows, plus the `hex64`, `pemBlock` and `bip39` algorithm rows). Precision first, as gitleaks and GitHub push protection do: a block row fires on a vendor prefix or an unambiguous shape, the generic `secret-assignment` row needs a secret-named word plus `=` or `:`, and entropy is never a trigger for a query. Table order is mask() order (the assignment row runs first, see its description). Several entries may share an `id`; they are one detector expressed as more than one pattern. Patterns adapted from gitleaks are MIT and attributed in NOTICE.md.",
7
10
  publicHexConstants: [
8
11
  {
9
12
  value: "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
@@ -65,7 +68,7 @@ var redact_rules_default = {
65
68
  id: "secret-assignment",
66
69
  tier: "warn",
67
70
  scopes: ["query", "publish", "team"],
68
- description: 'Secret-named assignment (API_KEY=, password:, token=) with a literal value. NOT the JSON-quoted form ("password": "..."): reading a quote after the name turned ordinary config keys into findings ({"credentials": "include"}, {"max_tokens": 128000}, {"tokenizer": "cl100k_base"}), and a JSON key is an identifier the shelf ranks on (owner decision, review round 6). The separator class is [ \\t] rather than \\s so a heading line (`## Token:`) never swallows the next line when mask() runs over whole text. FIRST IN THE TABLE ON PURPOSE: mask() applies rows in table order, and a value that is itself a vendor token (`OPENAI_API_KEY=sk-...`) must be taken whole by this row, name kept, before a vendor row could leave a stub for this row to re-match.',
71
+ description: 'Secret-named assignment (API_KEY=, password:, token=) with a literal value. The JSON-quoted form ("password": "...") is the third row, not a quote read here: reading a quote after this name turned ordinary config keys into findings ({"credentials": "include"}, {"max_tokens": 128000}, {"tokenizer": "cl100k_base"}, review round 6). The separator class is [ \\t] rather than \\s so a heading line (`## Token:`) never swallows the next line when mask() runs over whole text. FIRST IN THE TABLE ON PURPOSE: mask() applies rows in table order, and a value that is itself a vendor token (`OPENAI_API_KEY=sk-...`) must be taken whole by this row, name kept, before a vendor row could leave a stub for this row to re-match.',
69
72
  source: "tenjin",
70
73
  match: {
71
74
  kind: "regex",
@@ -99,6 +102,25 @@ var redact_rules_default = {
99
102
  handler: "nonLiteralValue"
100
103
  }
101
104
  },
105
+ {
106
+ id: "secret-assignment",
107
+ tier: "warn",
108
+ scopes: ["query", "publish", "team"],
109
+ description: 'Quoted secret name before `:` or `=` with a quoted value ("password": "...", \'api_key\' = \'...\'), the JSON and YAML form of the first row (tenjin-agent#296). Narrower than the first row on purpose, so the review-round-6 config keys stay clean: the name must END in the secret word (no `max_tokens`, `tokenizer`, `passwordHash`), and the value must be quoted and carry a letter and a digit (no `128000`, no `"include"`). A letters-only quoted password is an accepted miss.',
110
+ source: "tenjin (tenjin-agent#296)",
111
+ match: {
112
+ kind: "regex",
113
+ pattern: `(?<=["'])([A-Za-z0-9_-]*(?:API[_-]?KEY|SECRET|ACCESS[_-]?KEY|SUBSCRIPTION[_-]?KEY|PRIVATE[_-]?KEY|PASSW(?:OR)?D|TOKEN|CREDENTIALS?|AUTH[_-]?TOKEN))["'][ \\t]*[:=][ \\t]*("(?=[^"]*\\d)(?=[^"]*[A-Za-z])[^"]{6,}"|'(?=[^']*\\d)(?=[^']*[A-Za-z])[^']{6,}')`,
114
+ flags: "gi"
115
+ },
116
+ excerpt: {
117
+ kind: "custom",
118
+ handler: "labeledValue"
119
+ },
120
+ skip: {
121
+ handler: "nonLiteralValue"
122
+ }
123
+ },
102
124
  {
103
125
  id: "aws-access-key",
104
126
  tier: "block",
@@ -521,6 +543,146 @@ var redact_rules_default = {
521
543
  handler: "placeholderGroup1"
522
544
  }
523
545
  },
546
+ {
547
+ id: "basic-auth-header",
548
+ tier: "warn",
549
+ scopes: ["query", "publish"],
550
+ description: "Authorization: Basic header: the base64 of user:password, under the entropy floor and on no vendor prefix (tenjin-agent#296). The header name is a bounded lookbehind behind a shape lookahead, so the mask keeps it, replaces the credential alone, and a whitespace run stays linear.",
551
+ source: "tenjin (tenjin-agent#296)",
552
+ match: {
553
+ kind: "regex",
554
+ pattern: "(?=[A-Za-z0-9+/]{8})(?<=\\bAuthorization:[ \\t]{0,16}Basic[ \\t]{1,16})[A-Za-z0-9+/]{8,}={0,2}(?![A-Za-z0-9+/=])",
555
+ flags: "gi"
556
+ },
557
+ excerpt: {
558
+ kind: "mask",
559
+ keep: 0
560
+ }
561
+ },
562
+ {
563
+ id: "curl-user-credential",
564
+ tier: "warn",
565
+ scopes: ["query", "publish"],
566
+ description: "curl -u / --user user:password on one command (tenjin-agent#296): the password is masked and the command and user kept. Anchored on `curl` within 200 characters of the flag on the same pipeline segment, so `docker run -u 1000:1000` never matches. A `$VAR`, a placeholder or a bare lowercase word is skipped as the assignment row skips it.",
567
+ source: "tenjin (tenjin-agent#296)",
568
+ match: {
569
+ kind: "regex",
570
+ pattern: `(\\bcurl\\b[^\\n|;&]{0,200}?[ \\t](?:-u|--user)(?:[ \\t]+|=)["']?[^\\s:"']{1,64}):([^\\s"']+)`,
571
+ flags: "g"
572
+ },
573
+ excerpt: {
574
+ kind: "custom",
575
+ handler: "labeledValue"
576
+ },
577
+ skip: {
578
+ handler: "nonLiteralValue"
579
+ }
580
+ },
581
+ {
582
+ id: "url-query-credential",
583
+ tier: "warn",
584
+ scopes: ["query", "publish"],
585
+ description: "Credential-named query parameter on a URL (?key=, &api_key=, ?token=, ?sig=, ?password=): the value is masked and the name kept. The value class stops at `&`, `#`, whitespace, quotes and brackets, so a value another row already replaced with `[redacted \u2026]` is not masked twice.",
586
+ source: "tenjin (tenjin-agent#388)",
587
+ match: {
588
+ kind: "regex",
589
+ pattern: `([?&](?:key|apikey|api_key|api-key|token|access_token|auth|secret|client_secret|sig|signature|password|pwd))=([^&#\\s"'<>\\[\\]]+)`,
590
+ flags: "gi"
591
+ },
592
+ excerpt: {
593
+ kind: "custom",
594
+ handler: "labeledValue"
595
+ }
596
+ },
597
+ {
598
+ id: "url-path-credential",
599
+ tier: "warn",
600
+ scopes: ["query", "publish"],
601
+ description: "A path segment of 24 or more [A-Za-z0-9_-] characters that mixes letters and digits, on an http(s) URL: the shape a webhook secret or a signed-link token takes. A CDN hash or a content id in a path masks too; in a query that costs one routing offer. Four exclusions, each from a measured miss: a segment with two hyphenated words (an article slug), a 40-hex git commit after a git path marker (/commit/, /commits/, /blob/, /tree/, /raw/, /compare/) or on a git host (github.com, gitlab.com, bitbucket.org, codeberg.org), since elsewhere a 40-hex segment is a node key (https://<name>.quiknode.pro/<40 hex>/), a 0x-prefixed 64-hex (the hex64 row already calls a 64-hex inside a URL a hash), a UUID, and a URL character class that stops at quotes, brackets and commas, so one match never spans two URLs in a JSON string. The segment must be whole (a `.` or `%` inside it is a filename or an encoded slug, not a token). The shape lookahead runs before the scheme lookbehind, and the lookbehind is bounded, so a line of short segments stays linear.",
602
+ source: "tenjin (tenjin-agent#388)",
603
+ match: {
604
+ kind: "regex",
605
+ pattern: "\\/(?=[\\w-]{24})(?<=\\bhttps?:\\/\\/[^\\s?#\"'`<>()\\[\\]{},]{1,2048}\\/)(?=[\\w-]*[A-Za-z])(?=[\\w-]*\\d)(?![\\w-]*?(?<![A-Za-z])[A-Za-z]{3,}-[A-Za-z]{3})(?!(?:0x[0-9a-f]{64}|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(?![\\w-]))(?!(?=[0-9a-f]{40}(?![\\w-]))(?<=\\/(?:commit|commits|blob|tree|raw|compare)\\/|\\bhttps?:\\/\\/(?:www\\.)?(?:github\\.com|gitlab\\.com|bitbucket\\.org|codeberg\\.org)\\/[^\\s?#\"'`<>()\\[\\]{},]{0,2048}))[\\w-]{24,}(?=[.;:!]*(?:[\\/?#\\s\"'<>(),\\[\\]{}`]|$))",
606
+ flags: "gi"
607
+ },
608
+ excerpt: {
609
+ kind: "mask",
610
+ keep: 1
611
+ }
612
+ },
613
+ {
614
+ id: "bare-hex-key",
615
+ tier: "warn",
616
+ scopes: ["query", "publish"],
617
+ description: "64 hex with no 0x, the shape a private key takes when a tool exports it bare (tenjin-agent#388). A hash label within two tokens before it (tx, txn, txid, hash, sha, sha256, hmac, digest, commit, id, checksum, sig, signature, across markdown emphasis) or an http(s) URL around it makes it a hash and it is kept, the same downgrade the 0x form has. A 128-hex run (sha512) is not a 64-hex run and never matches.",
618
+ source: "tenjin (tenjin-agent#388)",
619
+ match: {
620
+ kind: "regex",
621
+ pattern: "(?<![0-9A-Za-z])[0-9a-fA-F]{64}(?![0-9A-Za-z])",
622
+ flags: "g"
623
+ },
624
+ excerpt: {
625
+ kind: "mask",
626
+ keep: 0
627
+ },
628
+ skip: {
629
+ handler: "hashLabelled"
630
+ }
631
+ },
632
+ {
633
+ id: "bare-hex-key",
634
+ tier: "warn",
635
+ scopes: ["query", "publish"],
636
+ description: "A 64-hex key split into two 32-hex halves by one space or one newline, with an optional 0x on the first half. Bounded to exactly two adjacent halves: a third 32-hex run before or after (a list of MD5 sums) keeps the whole list as written, and a hash label keeps it as for the row above.",
637
+ source: "tenjin (tenjin-agent#388)",
638
+ match: {
639
+ kind: "regex",
640
+ pattern: "(?<![0-9A-Za-z])(?<![0-9a-fA-F]{32}[ \\n])(?:0x)?[0-9a-fA-F]{32}[ \\n][0-9a-fA-F]{32}(?![0-9A-Za-z])(?![ \\n][0-9a-fA-F]{32})",
641
+ flags: "g"
642
+ },
643
+ excerpt: {
644
+ kind: "mask",
645
+ keep: 0
646
+ },
647
+ skip: {
648
+ handler: "hashLabelled"
649
+ }
650
+ },
651
+ {
652
+ id: "solana-secret-key",
653
+ tier: "warn",
654
+ scopes: ["query", "publish"],
655
+ description: "An 87 or 88 character base58 run: a Solana keypair's 64-byte secret key as a wallet exports it (tenjin-agent#388). A transaction signature has the same shape, so a tx or sig label before it or an http(s) URL around it keeps it, as for bare-hex-key. A 32-byte public key is 43 or 44 characters and never matches.",
656
+ source: "tenjin (tenjin-agent#388)",
657
+ match: {
658
+ kind: "regex",
659
+ pattern: "(?<![1-9A-HJ-NP-Za-km-z])[1-9A-HJ-NP-Za-km-z]{87,88}(?![1-9A-HJ-NP-Za-km-z])",
660
+ flags: "g"
661
+ },
662
+ excerpt: {
663
+ kind: "mask",
664
+ keep: 0
665
+ },
666
+ skip: {
667
+ handler: "hashLabelled"
668
+ }
669
+ },
670
+ {
671
+ id: "solana-secret-key",
672
+ tier: "warn",
673
+ scopes: ["query", "publish"],
674
+ description: "A JSON array of exactly 64 integers from 0 to 255: the solana-keygen keypair file.",
675
+ source: "tenjin (tenjin-agent#388)",
676
+ match: {
677
+ kind: "regex",
678
+ pattern: "\\[\\s*(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\s*,\\s*){63}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\s*\\]",
679
+ flags: "g"
680
+ },
681
+ excerpt: {
682
+ kind: "mask",
683
+ keep: 1
684
+ }
685
+ },
524
686
  {
525
687
  id: "wallet-address",
526
688
  tier: "warn",
@@ -798,7 +960,7 @@ var redact_rules_default = {
798
960
  {
799
961
  id: "raw-private-key",
800
962
  tier: "block",
801
- scopes: ["publish", "team"],
963
+ scopes: ["query", "publish", "team"],
802
964
  description: "0x + 64 hex with no hash context. Demoted to the warn detector hex32-value when a hash/identifier label precedes it (within two intervening tokens, across markdown and quote punctuation), when it sits inside an http(s) URL, or when it is one of the publicHexConstants below. An unlabeled bare 64-hex stays block: that is the floor.",
803
965
  source: "blockrun-mcp (wallet-key leak scanner)",
804
966
  match: {
@@ -813,7 +975,7 @@ var redact_rules_default = {
813
975
  {
814
976
  id: "pem-private-key",
815
977
  tier: "block",
816
- scopes: ["publish", "team"],
978
+ scopes: ["query", "publish", "team"],
817
979
  description: "PEM private-key armor (-----BEGIN ... PRIVATE KEY-----), RSA/EC/OPENSSH/PGP variants.",
818
980
  source: "gitleaks:private-key",
819
981
  match: {
@@ -828,8 +990,8 @@ var redact_rules_default = {
828
990
  {
829
991
  id: "bip39-seed-phrase",
830
992
  tier: "block",
831
- scopes: ["publish", "team"],
832
- description: "Twelve or more consecutive BIP-39 English wordlist words separated only by spaces or tabs: a wallet recovery phrase.",
993
+ scopes: ["query", "publish", "team"],
994
+ description: 'Twelve or more consecutive BIP-39 English wordlist words separated only by whitespace or quote characters, so a quoted `.env` value (MNEMONIC="abandon ... about") counts (tenjin-agent#296): a wallet recovery phrase.',
833
995
  source: "tenjin; wordlist from BIP-0039 (see NOTICE.md)",
834
996
  match: {
835
997
  kind: "algorithm",
@@ -917,22 +1079,56 @@ function mask(text) {
917
1079
  let out = text.replace(/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g, "");
918
1080
  for (const detector of MASK_DETECTORS) {
919
1081
  out = out.replace(detector.re, (...args) => {
920
- const m = args;
1082
+ const tail = typeof args.at(-1) === "object" ? 3 : 2;
1083
+ const m = Object.assign(args.slice(0, -tail), {
1084
+ index: args.at(-tail),
1085
+ input: args.at(-tail + 1)
1086
+ });
921
1087
  return detector.skip?.(m) === true ? m[0] : detector.excerpt(m);
922
1088
  });
923
1089
  }
924
- return out;
1090
+ if (MASKED_ALGORITHMS.has("hex64") || MASKED_ALGORITHMS.has("bip39")) {
1091
+ out = out.split("\n").map(maskLineSpans).join("\n");
1092
+ }
1093
+ if (MASKED_ALGORITHMS.has("bip39")) out = maskLooseMnemonics(out);
1094
+ return MASKED_ALGORITHMS.has("pemBlock") ? maskPemBlocks(out) : out;
925
1095
  }
926
- function maskRules() {
927
- return CORPUS.rules.filter((r) => r.scopes.includes("query") && r.match.kind === "regex").map((r) => ({
928
- pattern: r.match.pattern ?? "",
929
- flags: r.match.flags ?? "g",
930
- keep: r.excerpt.kind === "mask" ? r.excerpt.keep ?? 0 : 0
931
- }));
1096
+ function maskLineSpans(line) {
1097
+ const lines = [line];
1098
+ const spans = [
1099
+ ...MASKED_ALGORITHMS.has("hex64") ? scanHex64(lines) : [],
1100
+ ...MASKED_ALGORITHMS.has("bip39") ? scanSeedPhrases(lines) : []
1101
+ ].filter((f) => f.check !== "hex32-value").filter(
1102
+ (f) => f.check !== "bip39-seed-phrase" || line.slice(f.span[0], f.span[1]).split(/[\s"'`]+/).length <= SEED_PHRASE_MAX_WORDS
1103
+ ).sort((a, b) => a.span[0] - b.span[0]);
1104
+ if (spans.length === 0) return line;
1105
+ const parts = [];
1106
+ let cursor = 0;
1107
+ for (const f of spans) {
1108
+ if (f.span[0] < cursor) continue;
1109
+ parts.push(line.slice(cursor, f.span[0]), f.excerpt);
1110
+ cursor = f.span[1];
1111
+ }
1112
+ parts.push(line.slice(cursor));
1113
+ return parts.join("");
1114
+ }
1115
+ function maskPemBlocks(text) {
1116
+ let out = "";
1117
+ let rest = text;
1118
+ for (; ; ) {
1119
+ const begin = PEM_BEGIN.exec(rest);
1120
+ if (begin === null) return out + rest;
1121
+ const body = begin.index + begin[0].length;
1122
+ const end = PEM_END.exec(rest.slice(body));
1123
+ const stop = end === null ? rest.length : body + end.index + end[0].length;
1124
+ out += rest.slice(0, begin.index) + maskKeeping(rest.slice(begin.index, stop), begin[0].length);
1125
+ rest = rest.slice(stop);
1126
+ }
932
1127
  }
933
1128
  var SCOPES = /* @__PURE__ */ new Set(["query", "publish", "team"]);
934
1129
  var CORPUS = redact_rules_default;
935
1130
  var ALGORITHMS = /* @__PURE__ */ new Set(["hex64", "pemBlock", "bip39", "envDump", "entropy", "longVerbatim"]);
1131
+ var MASKABLE_ALGORITHMS = /* @__PURE__ */ new Set(["hex64", "pemBlock", "bip39"]);
936
1132
  var EXCERPT_HANDLERS = {
937
1133
  googleKey: (m) => maskKeeping(m[0], m[0].startsWith("AIza") ? 4 : 7),
938
1134
  dbConnectionUri: (m) => `${m[1]}://${m[2]}:[redacted]@${m[4]}`,
@@ -945,7 +1141,8 @@ var SKIP_HANDLERS = {
945
1141
  placeholderGroup1: (m) => isPlaceholder(m[1] ?? ""),
946
1142
  nonLiteralValue: skipNonLiteralValue,
947
1143
  placeholderUsername: (m) => PLACEHOLDER_USERNAME.test(m[1] ?? m[2] ?? ""),
948
- reservedExampleEmail: (m) => RESERVED_EXAMPLE_DOMAIN.test(m[0])
1144
+ reservedExampleEmail: (m) => RESERVED_EXAMPLE_DOMAIN.test(m[0]),
1145
+ hashLabelled: isLabelledHash
949
1146
  };
950
1147
  function validateScopes(rule) {
951
1148
  if (!Array.isArray(rule.scopes) || rule.scopes.length === 0) {
@@ -964,9 +1161,10 @@ function validateScopes(rule) {
964
1161
  if (rule.tier === "block" && !rule.scopes.includes("team")) {
965
1162
  throw new Error(`redact-rules.json: block rule ${rule.id} must be scoped to team as well`);
966
1163
  }
967
- if (rule.scopes.includes("query") && rule.match.kind !== "regex") {
1164
+ const maskable = rule.match.kind === "regex" || rule.match.kind === "algorithm" && MASKABLE_ALGORITHMS.has(rule.match.algorithm ?? "");
1165
+ if (rule.scopes.includes("query") && !maskable) {
968
1166
  throw new Error(
969
- `redact-rules.json: rule ${rule.id} is masked in queries but is not a regex row`
1167
+ `redact-rules.json: rule ${rule.id} is masked in queries but mask() cannot apply it`
970
1168
  );
971
1169
  }
972
1170
  }
@@ -1050,6 +1248,9 @@ function compileExcerpt(rule) {
1050
1248
  validateCorpus(CORPUS.rules);
1051
1249
  var LINE_DETECTORS = compileLineDetectors(CORPUS.rules);
1052
1250
  var MASK_DETECTORS = LINE_DETECTORS.filter((d) => d.scopes.has("query"));
1251
+ var MASKED_ALGORITHMS = new Set(
1252
+ CORPUS.rules.filter((r) => r.match.kind === "algorithm" && r.scopes.includes("query")).map((r) => r.match.algorithm ?? "")
1253
+ );
1053
1254
  function scanLineDetectors(lines) {
1054
1255
  const out = [];
1055
1256
  for (let i = 0; i < lines.length; i++) {
@@ -1173,7 +1374,18 @@ function isHashContext(line, matchIndex, match) {
1173
1374
  const prefix = /(\S*)$/.exec(before)?.[1] ?? "";
1174
1375
  return /^https?:\/\//.test(line.slice(matchIndex - prefix.length));
1175
1376
  }
1377
+ var BARE_HASH_LABEL_RE = /(?:^|[^a-z0-9])(?:tx|txn|txid|hash|sha\d*|hmac|digest|commit|id|checksum|sig|signature)(?:[\s:=/,._*'"`‘’“”-]*[A-Za-z0-9_]{1,12}){0,2}[\s:=/,._*'"`‘’“”-]*$/i;
1378
+ function isLabelledHash(m) {
1379
+ const input = m.input;
1380
+ const from = Math.max(0, m.index - LABEL_LOOKBACK);
1381
+ const before = input.slice(from, m.index);
1382
+ const labelWindow = from === 0 ? before : before.replace(/^[A-Za-z0-9]+/, "");
1383
+ if (BARE_HASH_LABEL_RE.test(labelWindow)) return true;
1384
+ const prefix = /(\S*)$/.exec(before)?.[1] ?? "";
1385
+ return /^https?:\/\//.test(input.slice(m.index - prefix.length));
1386
+ }
1176
1387
  var PEM_BEGIN = /-----BEGIN[ A-Z0-9]*PRIVATE KEY(?: BLOCK)?-----/;
1388
+ var PEM_END = /-----END[ A-Z0-9]*PRIVATE KEY(?: BLOCK)?-----/;
1177
1389
  function scanPemBlocks(lines) {
1178
1390
  const out = [];
1179
1391
  for (let i = 0; i < lines.length; i++) {
@@ -1194,9 +1406,73 @@ function scanPemBlocks(lines) {
1194
1406
  }
1195
1407
  var BIP39_WORDS = new Set(bip39_wordlist_default.words.split(" "));
1196
1408
  var SEED_PHRASE_MIN_WORDS = 12;
1409
+ var SEED_PHRASE_MAX_WORDS = 24;
1410
+ var SEED_PHRASE_SIZES = [24, 21, 18, 15, 12];
1411
+ var BIP39_INDEX = new Map(
1412
+ bip39_wordlist_default.words.split(" ").map((word, index) => [word, index])
1413
+ );
1414
+ var LOOSE_SEPARATOR = /^[\s,"'`]+$/;
1415
+ function maskLooseMnemonics(text) {
1416
+ const tokens = [...text.matchAll(/[A-Za-z]+/g)].map((m) => ({
1417
+ word: m[0].toLowerCase(),
1418
+ start: m.index,
1419
+ end: m.index + m[0].length
1420
+ }));
1421
+ const checked = /* @__PURE__ */ new Map();
1422
+ const valid = (window) => {
1423
+ const key = window.join(" ");
1424
+ let result = checked.get(key);
1425
+ if (result === void 0) checked.set(key, result = isMnemonic(window));
1426
+ return result;
1427
+ };
1428
+ const parts = [];
1429
+ let cursor = 0;
1430
+ let i = 0;
1431
+ while (i < tokens.length) {
1432
+ let j = i;
1433
+ while (j < tokens.length && BIP39_INDEX.has(tokens[j].word) && (j === i || LOOSE_SEPARATOR.test(text.slice(tokens[j - 1].end, tokens[j].start)))) {
1434
+ j++;
1435
+ }
1436
+ if (j === i) {
1437
+ i++;
1438
+ continue;
1439
+ }
1440
+ let k = i;
1441
+ while (k + SEED_PHRASE_MIN_WORDS <= j) {
1442
+ const size = SEED_PHRASE_SIZES.find(
1443
+ (n) => k + n <= j && valid(tokens.slice(k, k + n).map((t) => t.word))
1444
+ );
1445
+ if (size === void 0) {
1446
+ k++;
1447
+ continue;
1448
+ }
1449
+ parts.push(
1450
+ text.slice(cursor, tokens[k].start),
1451
+ `[redacted ${size}-word BIP-39 recovery phrase]`
1452
+ );
1453
+ cursor = tokens[k + size - 1].end;
1454
+ k += size;
1455
+ }
1456
+ i = j;
1457
+ }
1458
+ parts.push(text.slice(cursor));
1459
+ return parts.join("");
1460
+ }
1461
+ function isMnemonic(words) {
1462
+ let bits = 0n;
1463
+ for (const word of words) bits = bits << 11n | BigInt(BIP39_INDEX.get(word) ?? 0);
1464
+ const checksumBits = BigInt(words.length / 3);
1465
+ const entropyBytes = (words.length * 11 - words.length / 3) / 8;
1466
+ const entropy = Buffer.from(
1467
+ (bits >> checksumBits).toString(16).padStart(entropyBytes * 2, "0"),
1468
+ "hex"
1469
+ );
1470
+ const expected = BigInt(createHash("sha256").update(entropy).digest()[0]) >> 8n - checksumBits;
1471
+ return (bits & (1n << checksumBits) - 1n) === expected;
1472
+ }
1197
1473
  function scanSeedPhrases(lines) {
1198
1474
  const out = [];
1199
- const token = /\S+/g;
1475
+ const token = /[^\s"'`]+/g;
1200
1476
  for (let i = 0; i < lines.length; i++) {
1201
1477
  const line = lines[i] ?? "";
1202
1478
  token.lastIndex = 0;
@@ -1398,8 +1674,7 @@ function dedupeAndSort(findings2) {
1398
1674
  export {
1399
1675
  findings,
1400
1676
  mask,
1401
- maskRules,
1402
1677
  EMITTED_CHECKS,
1403
1678
  checksFor
1404
1679
  };
1405
- //# sourceMappingURL=chunk-OIM4HLN6.js.map
1680
+ //# sourceMappingURL=chunk-7QKHZQKW.js.map