@conveno/cli 0.2.0-rc.5 → 0.2.0-rc.7
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/README.md +22 -30
- package/dist/acp-9pRRszwU.js +82 -0
- package/dist/agy-relay-C-nqvieJ.js +137 -0
- package/dist/args-C7Agak9f.js +321 -0
- package/dist/bin.js +2 -2
- package/dist/{ctx-CDLE-2f2.js → ctx-tYftvhz_.js} +2 -3
- package/dist/daemon.js +410 -1423
- package/dist/daemonError-DNAKEyRT.js +66 -0
- package/dist/{dist-TrWRppjR.js → dist-D2hMvcZu.js} +592 -1216
- package/dist/dist-D9Gu-mQm.js +547 -0
- package/dist/dist-DOGlDbRb.js +504 -0
- package/dist/{dist-BPPOKmbH.js → dist-DOKVrSIw.js} +39 -148
- package/dist/dist-Dd31Fg0h.js +671 -0
- package/dist/{dist-CEJ2-wxh.js → dist-ftx5RNCp.js} +4 -17
- package/dist/{dist-E3XvoT1Q.js → dist-iFaY42Bs.js} +1 -1
- package/dist/{doctor-CzIGTeNT.js → doctor-BYa-MApu.js} +109 -102
- package/dist/fmt-C2SsP5Y0.js +96 -0
- package/dist/{hook-CLB_muZS.js → hook-CQeSn-w4.js} +7 -5
- package/dist/hook-entry-BXmSN--S.js +2490 -0
- package/dist/hook-entry-CgiSN-Oj.js +1 -0
- package/dist/main-seh-HPZO.js +971 -0
- package/dist/pick-DoyocW55.js +9 -0
- package/dist/{run-CYH0CRbp.js → run-B-WfNtCX.js} +627 -1998
- package/dist/{runtime-B1Pb9Qqg.js → runtime-Bnjh9BQ8.js} +119 -210
- package/dist/{dist-C8JRuLiZ.js → toml-patch-DGzVRdd1.js} +20 -1890
- package/dist/watch-Dr2RdyGo.js +185 -0
- package/package.json +15 -15
- package/dist/acp-BD7Oaerg.js +0 -142
- package/dist/args-BRB8QEQM.js +0 -554
- package/dist/dist-DcmKjrmu.js +0 -271
- package/dist/hook-entry-BlvSoNMm.js +0 -1289
- package/dist/hook-entry-CRDh36pe.js +0 -1
- package/dist/main-CsCsyq2G.js +0 -1645
package/dist/dist-DcmKjrmu.js
DELETED
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
// ../redact/dist/index.js
|
|
2
|
-
/**
|
|
3
|
-
* Redaction rules for transcript text. Each rule names the secret kind (the text that replaces a
|
|
4
|
-
* match is `[redacted:<kind>]`) and cites where its format comes from.
|
|
5
|
-
*
|
|
6
|
-
* Every pattern is written to run in linear time: repetition is bounded, character classes that
|
|
7
|
-
* follow each other are disjoint, and no group is repeated inside a repeated group. `redact.test.ts`
|
|
8
|
-
* runs adversarial inputs against all of them.
|
|
9
|
-
*/
|
|
10
|
-
const MARK = (kind) => `[redacted:${kind}]`;
|
|
11
|
-
/** Specific vendor token formats. They run first, so a generic rule never sees a half-redacted token. */
|
|
12
|
-
const TOKEN_RULES = [
|
|
13
|
-
{
|
|
14
|
-
kind: "aws-access-key",
|
|
15
|
-
source: "gitleaks aws-access-token; AWS IAM unique ID prefixes (docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html)",
|
|
16
|
-
pattern: /\b(?:A3T[A-Z0-9]|AKIA|ASIA|ABIA|ACCA|AIDA|AROA)[A-Z2-7]{16}\b/g
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
kind: "github-token",
|
|
20
|
-
source: "GitHub token formats (github.blog/engineering/platform-security/behind-githubs-new-authentication-token-formats); gitleaks github-pat, github-oauth, github-app-token, github-fine-grained-pat",
|
|
21
|
-
pattern: /\b(?:gh[pousr]_[A-Za-z0-9]{36,251}|github_pat_[A-Za-z0-9_]{22,255})\b/g
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
kind: "gitlab-token",
|
|
25
|
-
source: "gitleaks gitlab-pat, gitlab-runner-registration-token; docs.gitlab.com/user/profile/personal_access_tokens",
|
|
26
|
-
pattern: /\b(?:glpat|glptt|glrt|gldt|glcbt|glsoat|glft|glimt|glagent)-[A-Za-z0-9_-]{20,64}\b/g
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
kind: "anthropic-key",
|
|
30
|
-
source: "Anthropic API keys start with sk-ant- (docs.anthropic.com/en/api/getting-started); gitleaks anthropic-api-key, anthropic-admin-api-key",
|
|
31
|
-
pattern: /\bsk-ant-[a-z]{2,10}\d{0,3}-[A-Za-z0-9_-]{20,300}/g
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
kind: "openai-key",
|
|
35
|
-
source: "OpenAI keys sk-, sk-proj-, sk-svcacct-, sk-admin- (platform.openai.com/docs/api-reference/authentication); gitleaks openai-api-key, which matches the T3BlbkFJ marker",
|
|
36
|
-
pattern: /\b(?:sk-(?:proj|svcacct|admin)-[A-Za-z0-9_-]{20,300}|sk-[A-Za-z0-9]{20}T3BlbkFJ[A-Za-z0-9]{20}|sk-[A-Za-z0-9]{40,64})(?![A-Za-z0-9_-])/g
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
kind: "google-key",
|
|
40
|
-
source: "gitleaks gcp-api-key (AIza), GCP OAuth client secret (GOCSPX-), Google OAuth 2.0 access tokens (ya29.) (developers.google.com/identity/protocols/oauth2)",
|
|
41
|
-
pattern: /\b(?:AIza[A-Za-z0-9_-]{35}|GOCSPX-[A-Za-z0-9_-]{28}|ya29\.[A-Za-z0-9_-]{30,400})(?![A-Za-z0-9_-])/g
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
kind: "xai-key",
|
|
45
|
-
source: "xAI API keys start with xai- (docs.x.ai/developers/rest-api-reference/management/auth; reference/docs/grok)",
|
|
46
|
-
pattern: /\bxai-[A-Za-z0-9]{20,200}(?![A-Za-z0-9])/g
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
kind: "stripe-key",
|
|
50
|
-
source: "Stripe secret and restricted keys, webhook secrets (docs.stripe.com/keys, docs.stripe.com/webhooks); gitleaks stripe-access-token",
|
|
51
|
-
pattern: /\b(?:[sr]k_(?:test|live|prod)_[A-Za-z0-9]{10,99}|whsec_[A-Za-z0-9]{24,99})\b/g
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
kind: "npm-token",
|
|
55
|
-
source: "npm granular access tokens, npm_ plus 36 characters (github.blog/changelog/2021-09-23-npm-new-access-token-prefix); gitleaks npm-access-token",
|
|
56
|
-
pattern: /\bnpm_[A-Za-z0-9]{36}\b/g
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
kind: "pypi-token",
|
|
60
|
-
source: "PyPI API tokens, pypi-AgE prefix (pypi.org/help/#apitoken); gitleaks pypi-upload-token",
|
|
61
|
-
pattern: /\bpypi-AgE[A-Za-z0-9_-]{50,300}/g
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
kind: "slack-token",
|
|
65
|
-
source: "Slack token prefixes xox[abposr]- and xapp- (api.slack.com/authentication/token-types); gitleaks slack-bot-token, slack-user-token, slack-app-token, slack-webhook-url",
|
|
66
|
-
pattern: /\b(?:xox[abposr]-[A-Za-z0-9-]{10,200}|xapp-\d-[A-Za-z0-9]{6,20}-\d{8,16}-[A-Za-z0-9]{20,100}|https:\/\/hooks\.slack\.com\/(?:services|workflows|triggers)\/[A-Za-z0-9/_-]{20,120})/g
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
kind: "sendgrid-key",
|
|
70
|
-
source: "SendGrid API keys, SG. plus 22 and 43 characters (gitleaks sendgrid-api-token)",
|
|
71
|
-
pattern: /\bSG\.[A-Za-z0-9_-]{22}\.[A-Za-z0-9_-]{43}\b/g
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
kind: "huggingface-token",
|
|
75
|
-
source: "Hugging Face user access tokens, hf_ prefix (huggingface.co/docs/hub/security-tokens); gitleaks huggingface-access-token",
|
|
76
|
-
pattern: /\bhf_[A-Za-z]{34}\b/g
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
kind: "jwt",
|
|
80
|
-
source: "RFC 7519 JSON Web Token: base64url header and payload both start with eyJ, the encoding of '{\"'; gitleaks jwt",
|
|
81
|
-
pattern: /\beyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g
|
|
82
|
-
}
|
|
83
|
-
];
|
|
84
|
-
/** Where a credential travels in a request. */
|
|
85
|
-
const HEADER_RULES = [
|
|
86
|
-
{
|
|
87
|
-
kind: "bearer-token",
|
|
88
|
-
source: "RFC 6750 section 2.1 (Bearer scheme in the Authorization header)",
|
|
89
|
-
pattern: /\b(Bearer\s{1,20})[A-Za-z0-9._~+/-]{16,2048}=*/gi,
|
|
90
|
-
replace: (g) => `${g[0] ?? ""}${MARK("bearer-token")}`
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
kind: "basic-auth",
|
|
94
|
-
source: "RFC 7617 (Basic scheme in the Authorization header)",
|
|
95
|
-
pattern: /\b(Authorization\s{0,20}[:=]\s{0,20}["']?Basic\s{1,20})[A-Za-z0-9+/]{8,2048}={0,2}/gi,
|
|
96
|
-
replace: (g) => `${g[0] ?? ""}${MARK("basic-auth")}`
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
kind: "url-credentials",
|
|
100
|
-
source: "RFC 3986 section 3.2.1 (userinfo in a URI)",
|
|
101
|
-
pattern: /\b([A-Za-z][A-Za-z0-9+.-]{1,20}:\/\/)[^\s:/@"'<>]{1,100}:[^\s/@"'<>]{1,200}@/g,
|
|
102
|
-
replace: (g) => `${g[0] ?? ""}${MARK("url-credentials")}@`
|
|
103
|
-
}
|
|
104
|
-
];
|
|
105
|
-
/**
|
|
106
|
-
* Words that mark a variable, key or flag as holding a secret. `PWD` and a bare `KEY` or `AUTH`
|
|
107
|
-
* are left out on purpose: `PWD` is the working directory, `AUTHOR` and `sort_key` are not secrets.
|
|
108
|
-
*/
|
|
109
|
-
const SECRET_WORD = "(?:SECRET|TOKEN(?!S)|PASSWORD|PASSWD|PASSPHRASE|API[_-]?KEY|APIKEY|ACCESS[_-]?KEY|PRIVATE[_-]?KEY|CREDENTIALS?)";
|
|
110
|
-
/** Words that make the bare, unlabelled string next to them worth a look. */
|
|
111
|
-
const KEYWORD = "(?:secret|token|password|passwd|passphrase|api[_ -]?key|credential|private[_ -]?key|bearer|authorization)";
|
|
112
|
-
/** A value that is code, a placeholder or a reference, not a literal secret. */
|
|
113
|
-
const NOT_LITERAL = /^(?:\$|<|\{\{|%|\[redacted:|process\.env|os\.environ|env\.|getenv|null$|none$|undefined$|true$|false$|string$|your[_-]|example|changeme$|xxx|\*{3}|\.{3})/i;
|
|
114
|
-
const ASSIGNMENT_RULES = [{
|
|
115
|
-
kind: "secret-assignment",
|
|
116
|
-
source: "KEY=value and key: value forms of .env files and JSON, for names such as SECRET, TOKEN, PASSWORD, API_KEY (12factor.net/config; gitleaks generic-api-key)",
|
|
117
|
-
pattern: new RegExp(`(?<![A-Za-z0-9_.-])([A-Za-z0-9_.-]{0,40}${SECRET_WORD}(?:_?(?:KEY|VALUE))?)(["']?\\s{0,20}[=:]\\s{0,20})(?:(["'\`])((?:(?!\\3)[^\\n\\\\]|\\\\.){4,300})\\3|([^\\s"'\`,;\\[\\](){}<>$]{6,300}))`, "gi"),
|
|
118
|
-
replace: (g) => {
|
|
119
|
-
const [key, sep, quote, quoted, bare] = g;
|
|
120
|
-
const value = quoted ?? bare ?? "";
|
|
121
|
-
if (NOT_LITERAL.test(value)) return null;
|
|
122
|
-
if (quoted === void 0 && /^[a-z]{1,15}$/.test(value)) return null;
|
|
123
|
-
const q = quote ?? "";
|
|
124
|
-
return `${key}${sep}${q}${MARK("secret-assignment")}${q}`;
|
|
125
|
-
}
|
|
126
|
-
}, {
|
|
127
|
-
kind: "cli-secret",
|
|
128
|
-
source: "Command-line flags such as --password, --token, --api-key followed by a value",
|
|
129
|
-
pattern: /(--(?:[A-Za-z0-9]+-){0,3}(?:password|passwd|token|secret|api-key|apikey|access-key|private-key)(?:-[A-Za-z0-9]+){0,2})(\s{1,20})(?!-)([^\s"'`[\](){}<>$]{6,300})/gi,
|
|
130
|
-
replace: (g) => {
|
|
131
|
-
const [flag, space, value] = g;
|
|
132
|
-
if (NOT_LITERAL.test(value ?? "")) return null;
|
|
133
|
-
return `${flag}${space}${MARK("cli-secret")}`;
|
|
134
|
-
}
|
|
135
|
-
}];
|
|
136
|
-
const entropy = (s) => {
|
|
137
|
-
const counts = /* @__PURE__ */ new Map();
|
|
138
|
-
for (const ch of s) counts.set(ch, (counts.get(ch) ?? 0) + 1);
|
|
139
|
-
let h = 0;
|
|
140
|
-
for (const n of counts.values()) {
|
|
141
|
-
const p = n / s.length;
|
|
142
|
-
h -= p * Math.log2(p);
|
|
143
|
-
}
|
|
144
|
-
return h;
|
|
145
|
-
};
|
|
146
|
-
const HASH_LENGTHS = /* @__PURE__ */ new Set([
|
|
147
|
-
32,
|
|
148
|
-
40,
|
|
149
|
-
56,
|
|
150
|
-
64,
|
|
151
|
-
96,
|
|
152
|
-
128
|
|
153
|
-
]);
|
|
154
|
-
/**
|
|
155
|
-
* Last resort: a long base64 or hex string a few characters after a word such as `token` or
|
|
156
|
-
* `password`. It must look random (high entropy, digits and letters mixed). A hex string of a
|
|
157
|
-
* common hash length (a git SHA, an MD5, a SHA-256) is kept unless the keyword is right beside it.
|
|
158
|
-
*/
|
|
159
|
-
const ENTROPY_RULE = {
|
|
160
|
-
kind: "high-entropy",
|
|
161
|
-
source: "Shannon entropy check used by gitleaks (entropy) and trufflehog, applied only near a secret-like keyword to stay conservative",
|
|
162
|
-
pattern: new RegExp(`(${KEYWORD})([^\\n]{0,30}?)(?<![A-Za-z0-9+/_=-])([A-Za-z0-9+/_=-]{32,512})(?![A-Za-z0-9+/_=-])`, "gi"),
|
|
163
|
-
replace: (g) => {
|
|
164
|
-
const [word, gap, candidate] = g;
|
|
165
|
-
if (candidate === void 0) return null;
|
|
166
|
-
const hex = /^[0-9a-fA-F]+$/.test(candidate);
|
|
167
|
-
const tight = (gap ?? "").length <= 4;
|
|
168
|
-
if (hex && HASH_LENGTHS.has(candidate.length) && !tight) return null;
|
|
169
|
-
if (!/\d/.test(candidate) || !/[A-Za-z]/.test(candidate)) return null;
|
|
170
|
-
if (/^[A-Za-z]+(?:[_-][A-Za-z]+)+$/.test(candidate)) return null;
|
|
171
|
-
if (entropy(candidate) < (hex ? 3 : 3.8)) return null;
|
|
172
|
-
return `${word}${gap}${MARK("high-entropy")}`;
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
const BEGIN = /-----BEGIN [A-Z0-9 ]{0,40}PRIVATE KEY(?: BLOCK)?-----/g;
|
|
176
|
-
const FOOTER = /-----END [A-Z0-9 ]{0,40}PRIVATE KEY(?: BLOCK)?-----/g;
|
|
177
|
-
const BASE64_START = /[A-Za-z0-9+/=]/;
|
|
178
|
-
const BASE64_LINE = /^[A-Za-z0-9+/=]{1,100}\r?$/;
|
|
179
|
-
/** Longest key block (BEGIN line to END line) that is redacted whole. A 4096-bit RSA key is about 3.2 KB. */
|
|
180
|
-
const MAX_KEY_BLOCK = 16384;
|
|
181
|
-
/** Where a block with no footer in reach ends: the base64 lines that follow its header. */
|
|
182
|
-
function bodyEnd(text, from) {
|
|
183
|
-
const limit = Math.min(text.length, from + MAX_KEY_BLOCK);
|
|
184
|
-
let pos = from;
|
|
185
|
-
if (text[pos] === "\r") pos++;
|
|
186
|
-
if (text[pos] === "\n") pos++;
|
|
187
|
-
for (;;) {
|
|
188
|
-
if (!BASE64_START.test(text[pos] ?? "")) return pos;
|
|
189
|
-
const nl = text.slice(pos, limit).indexOf("\n");
|
|
190
|
-
const eol = nl === -1 ? limit : pos + nl;
|
|
191
|
-
if (eol <= pos || !BASE64_LINE.test(text.slice(pos, eol))) return pos;
|
|
192
|
-
pos = eol < text.length ? eol + 1 : eol;
|
|
193
|
-
if (pos >= limit) return pos;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* PEM private key blocks, including a block whose end was cut off. Footers are collected in one
|
|
198
|
-
* pass and the cursor only moves forward, so many unmatched BEGIN lines cannot make it quadratic.
|
|
199
|
-
*/
|
|
200
|
-
function redactPrivateKeys(text) {
|
|
201
|
-
if (!text.includes("-----BEGIN ")) return {
|
|
202
|
-
text,
|
|
203
|
-
count: 0
|
|
204
|
-
};
|
|
205
|
-
const footers = [];
|
|
206
|
-
FOOTER.lastIndex = 0;
|
|
207
|
-
for (let f = FOOTER.exec(text); f !== null; f = FOOTER.exec(text)) footers.push({
|
|
208
|
-
at: f.index,
|
|
209
|
-
end: f.index + f[0].length
|
|
210
|
-
});
|
|
211
|
-
let out = "";
|
|
212
|
-
let last = 0;
|
|
213
|
-
let count = 0;
|
|
214
|
-
let fi = 0;
|
|
215
|
-
BEGIN.lastIndex = 0;
|
|
216
|
-
for (let m = BEGIN.exec(text); m !== null; m = BEGIN.exec(text)) {
|
|
217
|
-
const bodyStart = m.index + m[0].length;
|
|
218
|
-
while (fi < footers.length && footers[fi].at < bodyStart) fi++;
|
|
219
|
-
const footer = footers[fi];
|
|
220
|
-
const stop = footer && footer.at - bodyStart <= MAX_KEY_BLOCK ? footer.end : bodyEnd(text, bodyStart);
|
|
221
|
-
out += text.slice(last, m.index) + MARK("private-key");
|
|
222
|
-
last = stop;
|
|
223
|
-
count++;
|
|
224
|
-
BEGIN.lastIndex = stop;
|
|
225
|
-
}
|
|
226
|
-
return {
|
|
227
|
-
text: out + text.slice(last),
|
|
228
|
-
count
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
/** Order matters: specific token formats first, then headers and URLs, then assignments, then the fallback. */
|
|
232
|
-
const PIPELINE = [
|
|
233
|
-
...TOKEN_RULES,
|
|
234
|
-
...HEADER_RULES,
|
|
235
|
-
...ASSIGNMENT_RULES,
|
|
236
|
-
ENTROPY_RULE
|
|
237
|
-
];
|
|
238
|
-
function apply(text, rule, findings) {
|
|
239
|
-
return text.replace(rule.pattern, (match, ...args) => {
|
|
240
|
-
const groups = args.slice(0, -2);
|
|
241
|
-
const next = rule.replace ? rule.replace(groups) : `[redacted:${rule.kind}]`;
|
|
242
|
-
if (next === null) return match;
|
|
243
|
-
findings[rule.kind] = (findings[rule.kind] ?? 0) + 1;
|
|
244
|
-
return next;
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* Replace secrets in transcript text with `[redacted:<kind>]` and report what was found. Pure,
|
|
249
|
-
* synchronous and linear in the length of the text. Safe to run twice: a marker is never matched
|
|
250
|
-
* again.
|
|
251
|
-
*
|
|
252
|
-
* Redaction is best effort. It catches known token formats, credentials in headers and URLs,
|
|
253
|
-
* secret-named assignments and long random strings next to secret-like words. It cannot know a
|
|
254
|
-
* password written in prose or a secret with no recognisable shape.
|
|
255
|
-
*/
|
|
256
|
-
function redactWithReport(input) {
|
|
257
|
-
const findings = {};
|
|
258
|
-
const keys = redactPrivateKeys(input);
|
|
259
|
-
let text = keys.text;
|
|
260
|
-
if (keys.count > 0) findings["private-key"] = keys.count;
|
|
261
|
-
for (const rule of PIPELINE) text = apply(text, rule, findings);
|
|
262
|
-
return {
|
|
263
|
-
text,
|
|
264
|
-
findings
|
|
265
|
-
};
|
|
266
|
-
}
|
|
267
|
-
/** `redactWithReport(input).text`. */
|
|
268
|
-
function redact(input) {
|
|
269
|
-
return redactWithReport(input).text;
|
|
270
|
-
}
|
|
271
|
-
export { redactWithReport as n, redact as t };
|