@phren/cli 0.3.76 → 0.3.77
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/dist/bridge/approval-summary.js +12 -1
- package/dist/bridge/changes.d.ts +7 -0
- package/dist/bridge/changes.js +15 -3
- package/dist/bridge-hook.mjs +75 -69
- package/package.json +1 -1
|
@@ -33,11 +33,22 @@ export function redactApproval(value) {
|
|
|
33
33
|
})
|
|
34
34
|
.replace(/\bAuthorization\s*:\s*Bearer\s+(\S+)/gi, (_whole, token) => `Authorization: Bearer …${/["']$/.test(token) ? token.slice(-1) : ""}`)
|
|
35
35
|
.replace(/(^|\s)(--(?:token|password|secret|api-key|access-token))(?:\s+|=)(?:"[^"]*"|'[^']*'|\S+)/gi, "$1$2 …")
|
|
36
|
+
// HTTP basic auth: curl -u name:password, wget/http --user. The name goes too; it is half of the credential.
|
|
37
|
+
.replace(/(\b(?:curl|wget|https?|httpie|xh)\b[^\n]*?\s(?:-u|--user|--proxy-user)(?:=|\s+))(?:"[^"]*"|'[^']*'|\S+)/gi, "$1…")
|
|
38
|
+
// Other Authorization schemes, and the headers that carry a key, token or session, up to the closing quote.
|
|
39
|
+
.replace(/(Authorization:\s*(?!Bearer\s)[A-Za-z]+\s+)[^\s"']+/gi, "$1…")
|
|
40
|
+
.replace(/(\b(?:proxy-authorization|cookie|set-cookie|x-api-key|api-key|apikey|x-auth-token|x-[a-z-]*(?:token|key|secret)[a-z-]*):\s*)[^"'\n]+/gi, "$1…")
|
|
41
|
+
// sshpass -p and registry logins take the password as the next word.
|
|
42
|
+
.replace(/(\bsshpass\b[^\n]*?\s-p\s*)(?:"[^"]*"|'[^']*'|\S+)/gi, "$1…")
|
|
43
|
+
.replace(/(\b(?:docker|podman|helm|npm)\s+login\b[^\n]*?\s-p(?:=|\s+))(?:"[^"]*"|'[^']*'|\S+)/gi, "$1…")
|
|
44
|
+
// Form and query fields inside a quoted body: -d 'user=a&password=b'.
|
|
45
|
+
.replace(/(\b(?:password|passwd|pwd|pass|secret|token|api[_-]?key|access[_-]?token|client[_-]?secret|auth)=)[^&\s"']+/gi, "$1…")
|
|
36
46
|
// -p is a password only for MySQL-style clients (-pSECRET); elsewhere it is
|
|
37
47
|
// mkdir -p, ssh -p 22, git log -p, claude -p.
|
|
38
48
|
.replace(/(\b(?:mysql|mysqldump|mysqladmin|mariadb)\b[^\n]*?\s-p)(?:"[^"]*"|'[^']*'|\S+)/gi, "$1…")
|
|
39
49
|
// Environment assignments only: a word after a separator, not a --flag=value.
|
|
40
|
-
|
|
50
|
+
// An & counts when it follows a space or another &, not inside a=1&b=2.
|
|
51
|
+
.replace(/(^|[\s;|(]|(?<![^\s&])&)([A-Za-z_][A-Za-z0-9_]*)=(?:"[^"]*"|'[^']*'|[^\s;]+)/g, "$1$2=…")
|
|
41
52
|
.replace(/\b(?:gh[po]_[A-Za-z0-9_]+|github_pat_[A-Za-z0-9_]+|sk-[A-Za-z0-9_-]+|xox[abp]-[A-Za-z0-9-]+|AKIA[0-9A-Z]{16}|eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+|[A-Fa-f0-9]{32,}|[A-Za-z0-9_-]{32,})\b/g, "…");
|
|
42
53
|
}
|
|
43
54
|
export function shortApproval(value) {
|
package/dist/bridge/changes.d.ts
CHANGED
|
@@ -16,6 +16,13 @@ export declare const changedFileSchema: z.ZodObject<{
|
|
|
16
16
|
}, z.core.$strip>;
|
|
17
17
|
export type ChangedFile = z.infer<typeof changedFileSchema>;
|
|
18
18
|
export declare const secretName: (file: string) => boolean;
|
|
19
|
+
/** A patch that holds anything credential-shaped (a key block, a known token
|
|
20
|
+
* format, a password assignment) is withheld whole, as the Hook's logs are:
|
|
21
|
+
* the phone shows the file as redacted rather than a half-scrubbed diff. */
|
|
22
|
+
/** Lockfile integrity hashes and embedded data are long base64 by nature, so
|
|
23
|
+
* the detector's shape-only base64 rule would withhold every lockfile diff;
|
|
24
|
+
* the known formats and name-based rules still apply. */
|
|
25
|
+
export declare const secretPatch: (patch: string) => boolean;
|
|
19
26
|
/** Tools whose filesystem changes are captured around the lifecycle callback. */
|
|
20
27
|
export declare const SHELL_TOOLS: Set<string>;
|
|
21
28
|
export declare function capturesChanges(tool: string, input: Json): boolean;
|
package/dist/bridge/changes.js
CHANGED
|
@@ -10,6 +10,7 @@ import { z } from "zod";
|
|
|
10
10
|
import { ProcessPool } from "./limits.js";
|
|
11
11
|
import { phrenStoreRoot } from "./transcripts.js";
|
|
12
12
|
import { countGit, countTick } from "./metrics.js";
|
|
13
|
+
import { scanForSecrets } from "../content/secrets.js";
|
|
13
14
|
const exec = promisify(execFile);
|
|
14
15
|
/** One file a shell command changed, with the patch between the working
|
|
15
16
|
* tree before the call and after it. `root` is the repository; `path` is
|
|
@@ -17,7 +18,14 @@ const exec = promisify(execFile);
|
|
|
17
18
|
export const changedFileSchema = z.object({ root: z.string(), path: z.string(), status: z.string(), patch: z.string(),
|
|
18
19
|
added: z.number().int().nonnegative(), removed: z.number().int().nonnegative(), redacted: z.boolean().optional(), binary: z.boolean().optional(), truncated: z.boolean().optional() });
|
|
19
20
|
const changeRowSchema = z.object({ toolUseId: z.string(), files: z.array(changedFileSchema) });
|
|
20
|
-
export const secretName = (file) => /^(?:\.env(?:\..*)?|.*\.(?:pem|key|p12|pfx|keychain-db|tfstate)|
|
|
21
|
+
export const secretName = (file) => /^(?:\.env(?:\..*)?|.*\.env|.*\.(?:pem|key|p8|p12|pfx|jks|keystore|keychain-db|tfstate|tfvars|ovpn)|id_(?:rsa|dsa|ecdsa|ed25519)(?:[_.].*)?|(?:.*\.)?credentials(?:\.json)?|\.credentials|\.git-credentials|\.netrc|\.npmrc|\.pypirc|\.pgpass|kubeconfig)$/i.test(path.basename(file));
|
|
22
|
+
/** A patch that holds anything credential-shaped (a key block, a known token
|
|
23
|
+
* format, a password assignment) is withheld whole, as the Hook's logs are:
|
|
24
|
+
* the phone shows the file as redacted rather than a half-scrubbed diff. */
|
|
25
|
+
/** Lockfile integrity hashes and embedded data are long base64 by nature, so
|
|
26
|
+
* the detector's shape-only base64 rule would withhold every lockfile diff;
|
|
27
|
+
* the known formats and name-based rules still apply. */
|
|
28
|
+
export const secretPatch = (patch) => scanForSecrets(patch.replace(/(?=[A-Za-z0-9+/]*[+/])[A-Za-z0-9+/]{40,}={0,2}/g, "")) !== null;
|
|
21
29
|
/** Two Git jobs at a time: one repository's tree read (shared by every call
|
|
22
30
|
* waiting for it), one call's diff, or a repository lookup. Each holds its slot
|
|
23
31
|
* for all of its Git processes, so under load jobs finish in turn rather than
|
|
@@ -219,7 +227,7 @@ async function treeDiff(root, before, after, env, signal) {
|
|
|
219
227
|
const specs = [...new Set([original, file])].map(name => `:(literal)${name}`);
|
|
220
228
|
const counts = (await git(root, [...NO_DIFF, "--numstat", before, after, "--", ...specs], env, signal)).split("\t");
|
|
221
229
|
const binary = counts[0] === "-" || counts[1] === "-";
|
|
222
|
-
|
|
230
|
+
let redacted = secretName(original) || secretName(file) || binary;
|
|
223
231
|
let overflowed = false;
|
|
224
232
|
let patch = redacted ? "" : await git(root, [...NO_DIFF, before, after, "--", ...specs], env, signal).catch(error => {
|
|
225
233
|
// One patch past Git's output buffer is shown truncated, not as a failed capture.
|
|
@@ -229,6 +237,10 @@ async function treeDiff(root, before, after, env, signal) {
|
|
|
229
237
|
overflowed = true;
|
|
230
238
|
return String(failure.stdout ?? "");
|
|
231
239
|
});
|
|
240
|
+
if (patch && secretPatch(patch)) {
|
|
241
|
+
patch = "";
|
|
242
|
+
redacted = true;
|
|
243
|
+
}
|
|
232
244
|
const truncated = overflowed || patch.length > 200_000;
|
|
233
245
|
if (truncated)
|
|
234
246
|
patch = patch.slice(0, 200_000) + "\n… (truncated)\n";
|
|
@@ -647,7 +659,7 @@ export class ToolChanges {
|
|
|
647
659
|
try {
|
|
648
660
|
const row = changeRowSchema.parse(JSON.parse(line));
|
|
649
661
|
// Also sanitize old records made before patch redaction existed.
|
|
650
|
-
entry.files.set(row.toolUseId, row.files.map(file => secretName(file.path) || file.redacted || /^(?:Binary files |GIT binary patch)/m.test(file.patch)
|
|
662
|
+
entry.files.set(row.toolUseId, row.files.map(file => secretName(file.path) || file.redacted || /^(?:Binary files |GIT binary patch)/m.test(file.patch) || secretPatch(file.patch)
|
|
651
663
|
? { ...file, patch: "", redacted: true } : file));
|
|
652
664
|
}
|
|
653
665
|
catch { /* Torn or invalid rows are not transcript events. */ }
|
package/dist/bridge-hook.mjs
CHANGED
|
@@ -29469,6 +29469,68 @@ var init_projects = __esm({
|
|
|
29469
29469
|
}
|
|
29470
29470
|
});
|
|
29471
29471
|
|
|
29472
|
+
// src/content/secrets.ts
|
|
29473
|
+
function looksLikePlaceholderSecret(value2) {
|
|
29474
|
+
const v2 = value2.trim().replace(/^['"`]+|['"`]+$/g, "").trim();
|
|
29475
|
+
if (!v2) return true;
|
|
29476
|
+
if (/^(?:<[^<>]*>|\{\{[^{}]*\}\}|\$\{[^{}]*\}|%[^%]*%|__.+__|\$[A-Za-z_][A-Za-z0-9_]*)$/.test(v2)) return true;
|
|
29477
|
+
if (/^(?:[*.]{3,}|[xX]{4,}|0{8,})$/.test(v2)) return true;
|
|
29478
|
+
if (/^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)+$/.test(v2)) return true;
|
|
29479
|
+
if (/^(?:changeme|change[_-]?me|placeholder|redacted|example|dummy|sample|fake|todo|fixme|none|null|undefined|secret|pass|passwd|password|token|apikey|api[_-]?key)$/i.test(v2)) return true;
|
|
29480
|
+
if (/^(?:your|my|the|some)[_-][a-z0-9_-]*$/i.test(v2)) return true;
|
|
29481
|
+
if (/[_-]?goes[_-]?here$/i.test(v2)) return true;
|
|
29482
|
+
return false;
|
|
29483
|
+
}
|
|
29484
|
+
function firstRealSecretValue(text7, re2) {
|
|
29485
|
+
for (const match of text7.matchAll(re2)) {
|
|
29486
|
+
const value2 = match[1];
|
|
29487
|
+
if (value2 && !looksLikePlaceholderSecret(value2)) return value2;
|
|
29488
|
+
}
|
|
29489
|
+
return null;
|
|
29490
|
+
}
|
|
29491
|
+
function scanForSecrets(text7) {
|
|
29492
|
+
if (/AKIA[0-9A-Z]{16}/.test(text7)) return "AWS access key";
|
|
29493
|
+
if (/(?:aws[_-]?secret|AWS_SECRET)[_-]?(?:access[_-]?)?key[_-]?(?:id)?['":=\s]+[A-Za-z0-9/+=]{40}/i.test(text7)) return "AWS secret access key";
|
|
29494
|
+
if (/eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/.test(text7)) return "JWT token";
|
|
29495
|
+
if (/github_pat_[A-Za-z0-9_]{22,}/.test(text7)) return "GitHub fine-grained token";
|
|
29496
|
+
if (/\bAIza[0-9A-Za-z_-]{35}\b/.test(text7)) return "Google API key";
|
|
29497
|
+
if (/https:\/\/hooks\.slack\.com\/services\/T[A-Za-z0-9]+\/B[A-Za-z0-9]+\/[A-Za-z0-9]+/.test(text7)) return "Slack webhook URL";
|
|
29498
|
+
if (!/^[0-9a-f]{40}$/.test(text7) && /(?=[A-Za-z0-9+/]*[+/])(?=[A-Za-z+/]*[0-9])[A-Za-z0-9+/]{40,}={0,2}/.test(text7.replace(/[0-9a-f]{40}/g, ""))) return "long base64 secret";
|
|
29499
|
+
if (/(mongodb|postgres|mysql|redis):\/\/[^@\s]+:[^@\s]+@/i.test(text7)) return "connection string with credentials";
|
|
29500
|
+
if (/-----BEGIN (?:[A-Z0-9 ]+ )?PRIVATE KEY-----/.test(text7)) return "SSH private key";
|
|
29501
|
+
if (/sk-ant-api\d{2}-[A-Za-z0-9_\-]{10,}/.test(text7)) return "Anthropic API key";
|
|
29502
|
+
if (/sk-proj-[A-Za-z0-9_\-]{30,}/.test(text7)) return "OpenAI API key";
|
|
29503
|
+
if (/ghp_[A-Za-z0-9]{36}/.test(text7)) return "GitHub personal access token";
|
|
29504
|
+
if (/gho_[A-Za-z0-9]{36}/.test(text7)) return "GitHub OAuth token";
|
|
29505
|
+
if (/gh[pousr]_[A-Za-z0-9]{36}/.test(text7)) return "GitHub token";
|
|
29506
|
+
if (/xoxb-[0-9]+-[A-Za-z0-9-]+/.test(text7)) return "Slack bot token";
|
|
29507
|
+
if (/xoxp-[0-9]+-[A-Za-z0-9-]+/.test(text7)) return "Slack user token";
|
|
29508
|
+
if (/sk_live_[A-Za-z0-9]{24,}/.test(text7)) return "Stripe secret key";
|
|
29509
|
+
if (/pk_live_[A-Za-z0-9]{24,}/.test(text7)) return "Stripe publishable key";
|
|
29510
|
+
if (/npm_[A-Za-z0-9]{36}/.test(text7)) return "npm access token";
|
|
29511
|
+
if (/"private_key_id"\s*:\s*"[^"]{20,}"/.test(text7)) return "GCP service account key";
|
|
29512
|
+
if (firstRealSecretValue(text7, URL_CREDENTIALS_RE)) return "URL with embedded credentials";
|
|
29513
|
+
if (firstRealSecretValue(text7, BEARER_RE)) return "bearer token";
|
|
29514
|
+
if (firstRealSecretValue(text7, NPM_AUTH_TOKEN_RE)) return "registry auth token";
|
|
29515
|
+
if (firstRealSecretValue(text7, NAMED_SECRET_RE)) return "API key or secret";
|
|
29516
|
+
return null;
|
|
29517
|
+
}
|
|
29518
|
+
function redactSecretsForLog(text7) {
|
|
29519
|
+
const secretType = scanForSecrets(text7);
|
|
29520
|
+
if (!secretType) return text7;
|
|
29521
|
+
return `[redacted: withheld, contained ${secretType}]`;
|
|
29522
|
+
}
|
|
29523
|
+
var NAMED_SECRET_RE, BEARER_RE, NPM_AUTH_TOKEN_RE, URL_CREDENTIALS_RE;
|
|
29524
|
+
var init_secrets = __esm({
|
|
29525
|
+
"src/content/secrets.ts"() {
|
|
29526
|
+
"use strict";
|
|
29527
|
+
NAMED_SECRET_RE = /['"]?(?:api_?key|secret|token|password)['"]?\s*[=:]\s*['"]?([a-zA-Z0-9_\-.]{20,})/gi;
|
|
29528
|
+
BEARER_RE = /\bauthorization['"]?\s*[=:]\s*['"]?\s*bearer\s+([A-Za-z0-9\-._~+/]{20,}=*)/gi;
|
|
29529
|
+
NPM_AUTH_TOKEN_RE = /_auth(?:Token)?\s*=\s*['"]?([A-Za-z0-9\-._~+/]{16,}=*)/gi;
|
|
29530
|
+
URL_CREDENTIALS_RE = /\bhttps?:\/\/[^/\s:@]+:([^/\s:@]+)@[^\s]+/gi;
|
|
29531
|
+
}
|
|
29532
|
+
});
|
|
29533
|
+
|
|
29472
29534
|
// src/bridge/changes.ts
|
|
29473
29535
|
import { execFile as execFile2 } from "node:child_process";
|
|
29474
29536
|
import { randomBytes } from "node:crypto";
|
|
@@ -29547,7 +29609,7 @@ async function treeDiff(root, before, after2, env, signal) {
|
|
|
29547
29609
|
const specs = [.../* @__PURE__ */ new Set([original, file5])].map((name2) => `:(literal)${name2}`);
|
|
29548
29610
|
const counts = (await git2(root, [...NO_DIFF, "--numstat", before, after2, "--", ...specs], env, signal)).split(" ");
|
|
29549
29611
|
const binary = counts[0] === "-" || counts[1] === "-";
|
|
29550
|
-
|
|
29612
|
+
let redacted = secretName(original) || secretName(file5) || binary;
|
|
29551
29613
|
let overflowed = false;
|
|
29552
29614
|
let patch = redacted ? "" : await git2(root, [...NO_DIFF, before, after2, "--", ...specs], env, signal).catch((error62) => {
|
|
29553
29615
|
const failure2 = error62;
|
|
@@ -29555,6 +29617,10 @@ async function treeDiff(root, before, after2, env, signal) {
|
|
|
29555
29617
|
overflowed = true;
|
|
29556
29618
|
return String(failure2.stdout ?? "");
|
|
29557
29619
|
});
|
|
29620
|
+
if (patch && secretPatch(patch)) {
|
|
29621
|
+
patch = "";
|
|
29622
|
+
redacted = true;
|
|
29623
|
+
}
|
|
29558
29624
|
const truncated = overflowed || patch.length > 2e5;
|
|
29559
29625
|
if (truncated) patch = patch.slice(0, 2e5) + "\n\u2026 (truncated)\n";
|
|
29560
29626
|
const added = Number(counts[0]) || 0, removed = Number(counts[1]) || 0;
|
|
@@ -29626,7 +29692,7 @@ function outputCallIds(raw, source) {
|
|
|
29626
29692
|
if (!Array.isArray(content)) return [];
|
|
29627
29693
|
return content.flatMap((block) => block && typeof block === "object" && block.type === "tool_result" ? ids(block.tool_use_id) : []);
|
|
29628
29694
|
}
|
|
29629
|
-
var exec2, changedFileSchema, changeRowSchema, secretName, capturePool, SHELL_TOOLS, NAMED, FILE_TOOLS, CaptureTimeout, failedRepository, Scratch, SCRATCH_AGE, REPOSITORY_TTL, NO_DIFF, CLAIM_RETENTION, PENDING_FOR, BUDGET, DAY, ToolChanges;
|
|
29695
|
+
var exec2, changedFileSchema, changeRowSchema, secretName, secretPatch, capturePool, SHELL_TOOLS, NAMED, FILE_TOOLS, CaptureTimeout, failedRepository, Scratch, SCRATCH_AGE, REPOSITORY_TTL, NO_DIFF, CLAIM_RETENTION, PENDING_FOR, BUDGET, DAY, ToolChanges;
|
|
29630
29696
|
var init_changes = __esm({
|
|
29631
29697
|
"src/bridge/changes.ts"() {
|
|
29632
29698
|
"use strict";
|
|
@@ -29637,6 +29703,7 @@ var init_changes = __esm({
|
|
|
29637
29703
|
init_limits();
|
|
29638
29704
|
init_transcripts();
|
|
29639
29705
|
init_metrics();
|
|
29706
|
+
init_secrets();
|
|
29640
29707
|
exec2 = promisify2(execFile2);
|
|
29641
29708
|
changedFileSchema = external_exports.object({
|
|
29642
29709
|
root: external_exports.string(),
|
|
@@ -29650,7 +29717,8 @@ var init_changes = __esm({
|
|
|
29650
29717
|
truncated: external_exports.boolean().optional()
|
|
29651
29718
|
});
|
|
29652
29719
|
changeRowSchema = external_exports.object({ toolUseId: external_exports.string(), files: external_exports.array(changedFileSchema) });
|
|
29653
|
-
secretName = (file5) => /^(?:\.env(?:\..*)?|.*\.(?:pem|key|p12|pfx|keychain-db|tfstate)|
|
|
29720
|
+
secretName = (file5) => /^(?:\.env(?:\..*)?|.*\.env|.*\.(?:pem|key|p8|p12|pfx|jks|keystore|keychain-db|tfstate|tfvars|ovpn)|id_(?:rsa|dsa|ecdsa|ed25519)(?:[_.].*)?|(?:.*\.)?credentials(?:\.json)?|\.credentials|\.git-credentials|\.netrc|\.npmrc|\.pypirc|\.pgpass|kubeconfig)$/i.test(path19.basename(file5));
|
|
29721
|
+
secretPatch = (patch) => scanForSecrets(patch.replace(/(?=[A-Za-z0-9+/]*[+/])[A-Za-z0-9+/]{40,}={0,2}/g, "")) !== null;
|
|
29654
29722
|
capturePool = new ProcessPool(2);
|
|
29655
29723
|
SHELL_TOOLS = /* @__PURE__ */ new Set(["Bash", "bash", "shell", "Shell", "exec_command", "shell_command", "local_shell", "write_stdin"]);
|
|
29656
29724
|
NAMED = /(?<![\w@:/])(?:~\/|\.\/|\/)[\w.@+~-]+(?:\/[\w.@+~-]+)*/g;
|
|
@@ -30051,7 +30119,7 @@ var init_changes = __esm({
|
|
|
30051
30119
|
if (!line) continue;
|
|
30052
30120
|
try {
|
|
30053
30121
|
const row = changeRowSchema.parse(JSON.parse(line));
|
|
30054
|
-
entry2.files.set(row.toolUseId, row.files.map((file6) => secretName(file6.path) || file6.redacted || /^(?:Binary files |GIT binary patch)/m.test(file6.patch) ? { ...file6, patch: "", redacted: true } : file6));
|
|
30122
|
+
entry2.files.set(row.toolUseId, row.files.map((file6) => secretName(file6.path) || file6.redacted || /^(?:Binary files |GIT binary patch)/m.test(file6.patch) || secretPatch(file6.patch) ? { ...file6, patch: "", redacted: true } : file6));
|
|
30055
30123
|
} catch {
|
|
30056
30124
|
}
|
|
30057
30125
|
}
|
|
@@ -39521,7 +39589,7 @@ var init_package_metadata = __esm({
|
|
|
39521
39589
|
__dirname = path41.dirname(fileURLToPath3(import.meta.url));
|
|
39522
39590
|
ROOT = path41.join(__dirname, "..");
|
|
39523
39591
|
PACKAGE_JSON_PATH = path41.join(ROOT, "package.json");
|
|
39524
|
-
BUNDLED_VERSION = true ? "0.3.
|
|
39592
|
+
BUNDLED_VERSION = true ? "0.3.77" : "0.0.0";
|
|
39525
39593
|
PACKAGE_JSON = readPackageJson();
|
|
39526
39594
|
PACKAGE_NAME = PACKAGE_JSON.name || "phren";
|
|
39527
39595
|
VERSION = PACKAGE_JSON.version || BUNDLED_VERSION;
|
|
@@ -39596,68 +39664,6 @@ var init_management_preset = __esm({
|
|
|
39596
39664
|
}
|
|
39597
39665
|
});
|
|
39598
39666
|
|
|
39599
|
-
// src/content/secrets.ts
|
|
39600
|
-
function looksLikePlaceholderSecret(value2) {
|
|
39601
|
-
const v2 = value2.trim().replace(/^['"`]+|['"`]+$/g, "").trim();
|
|
39602
|
-
if (!v2) return true;
|
|
39603
|
-
if (/^(?:<[^<>]*>|\{\{[^{}]*\}\}|\$\{[^{}]*\}|%[^%]*%|__.+__|\$[A-Za-z_][A-Za-z0-9_]*)$/.test(v2)) return true;
|
|
39604
|
-
if (/^(?:[*.]{3,}|[xX]{4,}|0{8,})$/.test(v2)) return true;
|
|
39605
|
-
if (/^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)+$/.test(v2)) return true;
|
|
39606
|
-
if (/^(?:changeme|change[_-]?me|placeholder|redacted|example|dummy|sample|fake|todo|fixme|none|null|undefined|secret|pass|passwd|password|token|apikey|api[_-]?key)$/i.test(v2)) return true;
|
|
39607
|
-
if (/^(?:your|my|the|some)[_-][a-z0-9_-]*$/i.test(v2)) return true;
|
|
39608
|
-
if (/[_-]?goes[_-]?here$/i.test(v2)) return true;
|
|
39609
|
-
return false;
|
|
39610
|
-
}
|
|
39611
|
-
function firstRealSecretValue(text7, re2) {
|
|
39612
|
-
for (const match of text7.matchAll(re2)) {
|
|
39613
|
-
const value2 = match[1];
|
|
39614
|
-
if (value2 && !looksLikePlaceholderSecret(value2)) return value2;
|
|
39615
|
-
}
|
|
39616
|
-
return null;
|
|
39617
|
-
}
|
|
39618
|
-
function scanForSecrets(text7) {
|
|
39619
|
-
if (/AKIA[0-9A-Z]{16}/.test(text7)) return "AWS access key";
|
|
39620
|
-
if (/(?:aws[_-]?secret|AWS_SECRET)[_-]?(?:access[_-]?)?key[_-]?(?:id)?['":=\s]+[A-Za-z0-9/+=]{40}/i.test(text7)) return "AWS secret access key";
|
|
39621
|
-
if (/eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/.test(text7)) return "JWT token";
|
|
39622
|
-
if (/github_pat_[A-Za-z0-9_]{22,}/.test(text7)) return "GitHub fine-grained token";
|
|
39623
|
-
if (/\bAIza[0-9A-Za-z_-]{35}\b/.test(text7)) return "Google API key";
|
|
39624
|
-
if (/https:\/\/hooks\.slack\.com\/services\/T[A-Za-z0-9]+\/B[A-Za-z0-9]+\/[A-Za-z0-9]+/.test(text7)) return "Slack webhook URL";
|
|
39625
|
-
if (!/^[0-9a-f]{40}$/.test(text7) && /(?=[A-Za-z0-9+/]*[+/])(?=[A-Za-z+/]*[0-9])[A-Za-z0-9+/]{40,}={0,2}/.test(text7.replace(/[0-9a-f]{40}/g, ""))) return "long base64 secret";
|
|
39626
|
-
if (/(mongodb|postgres|mysql|redis):\/\/[^@\s]+:[^@\s]+@/i.test(text7)) return "connection string with credentials";
|
|
39627
|
-
if (/-----BEGIN (?:[A-Z0-9 ]+ )?PRIVATE KEY-----/.test(text7)) return "SSH private key";
|
|
39628
|
-
if (/sk-ant-api\d{2}-[A-Za-z0-9_\-]{10,}/.test(text7)) return "Anthropic API key";
|
|
39629
|
-
if (/sk-proj-[A-Za-z0-9_\-]{30,}/.test(text7)) return "OpenAI API key";
|
|
39630
|
-
if (/ghp_[A-Za-z0-9]{36}/.test(text7)) return "GitHub personal access token";
|
|
39631
|
-
if (/gho_[A-Za-z0-9]{36}/.test(text7)) return "GitHub OAuth token";
|
|
39632
|
-
if (/gh[pousr]_[A-Za-z0-9]{36}/.test(text7)) return "GitHub token";
|
|
39633
|
-
if (/xoxb-[0-9]+-[A-Za-z0-9-]+/.test(text7)) return "Slack bot token";
|
|
39634
|
-
if (/xoxp-[0-9]+-[A-Za-z0-9-]+/.test(text7)) return "Slack user token";
|
|
39635
|
-
if (/sk_live_[A-Za-z0-9]{24,}/.test(text7)) return "Stripe secret key";
|
|
39636
|
-
if (/pk_live_[A-Za-z0-9]{24,}/.test(text7)) return "Stripe publishable key";
|
|
39637
|
-
if (/npm_[A-Za-z0-9]{36}/.test(text7)) return "npm access token";
|
|
39638
|
-
if (/"private_key_id"\s*:\s*"[^"]{20,}"/.test(text7)) return "GCP service account key";
|
|
39639
|
-
if (firstRealSecretValue(text7, URL_CREDENTIALS_RE)) return "URL with embedded credentials";
|
|
39640
|
-
if (firstRealSecretValue(text7, BEARER_RE)) return "bearer token";
|
|
39641
|
-
if (firstRealSecretValue(text7, NPM_AUTH_TOKEN_RE)) return "registry auth token";
|
|
39642
|
-
if (firstRealSecretValue(text7, NAMED_SECRET_RE)) return "API key or secret";
|
|
39643
|
-
return null;
|
|
39644
|
-
}
|
|
39645
|
-
function redactSecretsForLog(text7) {
|
|
39646
|
-
const secretType = scanForSecrets(text7);
|
|
39647
|
-
if (!secretType) return text7;
|
|
39648
|
-
return `[redacted: withheld, contained ${secretType}]`;
|
|
39649
|
-
}
|
|
39650
|
-
var NAMED_SECRET_RE, BEARER_RE, NPM_AUTH_TOKEN_RE, URL_CREDENTIALS_RE;
|
|
39651
|
-
var init_secrets = __esm({
|
|
39652
|
-
"src/content/secrets.ts"() {
|
|
39653
|
-
"use strict";
|
|
39654
|
-
NAMED_SECRET_RE = /['"]?(?:api_?key|secret|token|password)['"]?\s*[=:]\s*['"]?([a-zA-Z0-9_\-.]{20,})/gi;
|
|
39655
|
-
BEARER_RE = /\bauthorization['"]?\s*[=:]\s*['"]?\s*bearer\s+([A-Za-z0-9\-._~+/]{20,}=*)/gi;
|
|
39656
|
-
NPM_AUTH_TOKEN_RE = /_auth(?:Token)?\s*=\s*['"]?([A-Za-z0-9\-._~+/]{16,}=*)/gi;
|
|
39657
|
-
URL_CREDENTIALS_RE = /\bhttps?:\/\/[^/\s:@]+:([^/\s:@]+)@[^\s]+/gi;
|
|
39658
|
-
}
|
|
39659
|
-
});
|
|
39660
|
-
|
|
39661
39667
|
// src/hooks.ts
|
|
39662
39668
|
import * as fs17 from "fs";
|
|
39663
39669
|
import { createHmac } from "crypto";
|
|
@@ -54028,7 +54034,7 @@ function redactApproval(value2) {
|
|
|
54028
54034
|
} catch {
|
|
54029
54035
|
return "\u2026";
|
|
54030
54036
|
}
|
|
54031
|
-
}).replace(/\bAuthorization\s*:\s*Bearer\s+(\S+)/gi, (_whole, token2) => `Authorization: Bearer \u2026${/["']$/.test(token2) ? token2.slice(-1) : ""}`).replace(/(^|\s)(--(?:token|password|secret|api-key|access-token))(?:\s+|=)(?:"[^"]*"|'[^']*'|\S+)/gi, "$1$2 \u2026").replace(/(\b(?:mysql|mysqldump|mysqladmin|mariadb)\b[^\n]*?\s-p)(?:"[^"]*"|'[^']*'|\S+)/gi, "$1\u2026").replace(/(^|[\s
|
|
54037
|
+
}).replace(/\bAuthorization\s*:\s*Bearer\s+(\S+)/gi, (_whole, token2) => `Authorization: Bearer \u2026${/["']$/.test(token2) ? token2.slice(-1) : ""}`).replace(/(^|\s)(--(?:token|password|secret|api-key|access-token))(?:\s+|=)(?:"[^"]*"|'[^']*'|\S+)/gi, "$1$2 \u2026").replace(/(\b(?:curl|wget|https?|httpie|xh)\b[^\n]*?\s(?:-u|--user|--proxy-user)(?:=|\s+))(?:"[^"]*"|'[^']*'|\S+)/gi, "$1\u2026").replace(/(Authorization:\s*(?!Bearer\s)[A-Za-z]+\s+)[^\s"']+/gi, "$1\u2026").replace(/(\b(?:proxy-authorization|cookie|set-cookie|x-api-key|api-key|apikey|x-auth-token|x-[a-z-]*(?:token|key|secret)[a-z-]*):\s*)[^"'\n]+/gi, "$1\u2026").replace(/(\bsshpass\b[^\n]*?\s-p\s*)(?:"[^"]*"|'[^']*'|\S+)/gi, "$1\u2026").replace(/(\b(?:docker|podman|helm|npm)\s+login\b[^\n]*?\s-p(?:=|\s+))(?:"[^"]*"|'[^']*'|\S+)/gi, "$1\u2026").replace(/(\b(?:password|passwd|pwd|pass|secret|token|api[_-]?key|access[_-]?token|client[_-]?secret|auth)=)[^&\s"']+/gi, "$1\u2026").replace(/(\b(?:mysql|mysqldump|mysqladmin|mariadb)\b[^\n]*?\s-p)(?:"[^"]*"|'[^']*'|\S+)/gi, "$1\u2026").replace(/(^|[\s;|(]|(?<![^\s&])&)([A-Za-z_][A-Za-z0-9_]*)=(?:"[^"]*"|'[^']*'|[^\s;]+)/g, "$1$2=\u2026").replace(/\b(?:gh[po]_[A-Za-z0-9_]+|github_pat_[A-Za-z0-9_]+|sk-[A-Za-z0-9_-]+|xox[abp]-[A-Za-z0-9-]+|AKIA[0-9A-Z]{16}|eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+|[A-Fa-f0-9]{32,}|[A-Za-z0-9_-]{32,})\b/g, "\u2026");
|
|
54032
54038
|
}
|
|
54033
54039
|
function shortApproval(value2) {
|
|
54034
54040
|
const line = oneLine(redactApproval(value2));
|
|
@@ -92958,7 +92964,7 @@ async function main() {
|
|
|
92958
92964
|
return askpass2(args[1]);
|
|
92959
92965
|
}
|
|
92960
92966
|
const { runBridge: runBridge2 } = await Promise.resolve().then(() => (init_command(), command_exports));
|
|
92961
|
-
return runBridge2(args, "0.3.
|
|
92967
|
+
return runBridge2(args, "0.3.77");
|
|
92962
92968
|
}
|
|
92963
92969
|
main().then((code) => {
|
|
92964
92970
|
process.exitCode = code;
|