@raibitsi/tiresias 1.0.0 → 1.1.0
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/CHANGELOG.md +199 -0
- package/README.md +50 -27
- package/dist/background.js +6 -3
- package/dist/browsecli.js +4 -3
- package/dist/cdp.js +22 -1
- package/dist/cli.js +82 -29
- package/dist/config.js +32 -26
- package/dist/confirm.js +16 -7
- package/dist/cooldown.js +65 -34
- package/dist/dailylog.js +11 -5
- package/dist/engine.js +5 -4
- package/dist/envelope.js +20 -2
- package/dist/fetcher.js +5 -0
- package/dist/filereply.js +7 -1
- package/dist/files.js +4 -4
- package/dist/formflow.js +21 -3
- package/dist/forms.js +257 -34
- package/dist/getactions.js +99 -0
- package/dist/history.js +8 -5
- package/dist/hook.js +2 -0
- package/dist/hosts.js +15 -13
- package/dist/inside.js +2 -2
- package/dist/inspect.js +4 -1
- package/dist/keys.js +420 -18
- package/dist/mcp.js +10 -10
- package/dist/needs.js +9 -5
- package/dist/parentwatch.js +6 -16
- package/dist/pdf.js +4 -1
- package/dist/pdfchild.js +0 -2
- package/dist/pdfproc.js +26 -11
- package/dist/pdfwatch.js +14 -0
- package/dist/pipeline.js +25 -8
- package/dist/profiles.js +3 -3
- package/dist/queue.js +15 -7
- package/dist/reader.js +43 -18
- package/dist/receipts.js +2 -2
- package/dist/render.js +103 -24
- package/dist/resume.js +17 -8
- package/dist/rules.js +29 -7
- package/dist/safebrowsing.js +3 -3
- package/dist/safety.js +9 -3
- package/dist/sandbox.js +1 -1
- package/dist/saved.js +108 -60
- package/dist/savedlock.js +208 -0
- package/dist/settings.js +7 -3
- package/dist/shelf.js +1 -1
- package/dist/sites.js +9 -4
- package/dist/slips.js +43 -1
- package/dist/store.js +119 -25
- package/dist/tabs.js +1 -1
- package/dist/textview.js +10 -0
- package/dist/translate.js +22 -2
- package/dist/types.js +2 -2
- package/dist/watchflow.js +1 -2
- package/dist/work.js +4 -2
- package/package.json +2 -1
package/dist/forms.js
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
// whole: more than 100 fields (too_many_fields), one visible name used by two different fields
|
|
17
17
|
// (duplicate_names), a listing or a default value too large to show exactly (too_large).
|
|
18
18
|
import { createHash } from "node:crypto";
|
|
19
|
+
import { listsFor, stripAccents } from "./shieldphrases.js";
|
|
19
20
|
import { MAX_URL } from "./types.js";
|
|
20
21
|
export const MAX_FORMS = 20; // per page; the rest are counted (forms_omitted)
|
|
21
22
|
export const MAX_FIELDS = 100; // per form; a form with more is listed but never sent (too_many_fields)
|
|
@@ -41,9 +42,9 @@ const ORDER = ["login_or_password", "captcha", "payment", "file_upload", "nested
|
|
|
41
42
|
export const NOT_ALLOWED_TEXT = {
|
|
42
43
|
unknown_control: "This form has a field of a kind Tiresias does not know (an input type outside the standard ones), so it does not send the form.",
|
|
43
44
|
nested_control: "This form has a field inside another control (a button, a list of options, a template), which Tiresias cannot list or check as a field, so it does not send the form.",
|
|
44
|
-
login_or_password: "This form asks for a password or a login code. Tiresias never handles logins or passwords: a person has to sign in themselves.",
|
|
45
|
+
login_or_password: "This form asks for sign-in, a password or a login code. Tiresias never handles logins or passwords: a person has to sign in themselves.",
|
|
45
46
|
file_upload: "This form uploads files (a file field or multipart encoding). Tiresias does not send files.",
|
|
46
|
-
payment: "This form looks like a payment form (card number, security code, expiry, IBAN or routing number). This version of Tiresias never pays.",
|
|
47
|
+
payment: "This form looks like a payment or purchase form (a payment action, card number, security code, expiry, IBAN or routing number). This version of Tiresias never pays.",
|
|
47
48
|
captcha: "This form has a CAPTCHA or bot check. A person has to fill it in; Tiresias never solves one.",
|
|
48
49
|
bad_action: "This form sends to something that is not an http or https address, so Tiresias does not use it.",
|
|
49
50
|
bad_method: "This form uses a method other than GET or POST, so Tiresias does not use it.",
|
|
@@ -100,6 +101,9 @@ const cut = (s, n) => {
|
|
|
100
101
|
const t = norm(s).slice(0, n);
|
|
101
102
|
return t || undefined;
|
|
102
103
|
};
|
|
104
|
+
// Characters that render as nothing (zero-width, soft hyphen, bidi marks, variation selectors and the
|
|
105
|
+
// like) are removed before any text is judged (round 90).
|
|
106
|
+
const invisible = (t) => t.replace(/[\p{Cf}\p{Default_Ignorable_Code_Point}]/gu, "");
|
|
103
107
|
// THE text normalization of the form guard (round 93, one path for every text it judges): invisible and
|
|
104
108
|
// format characters removed, NFKC (fullwidth letters, ligatures, compatibility digits), case-folded
|
|
105
109
|
// (upper then lower, so "ß" is "ss" and the long s is "s"), invisible characters removed again.
|
|
@@ -120,9 +124,11 @@ function tokens(text) {
|
|
|
120
124
|
const base = invisible(text).normalize("NFKC");
|
|
121
125
|
const folded = fold(base);
|
|
122
126
|
const camel = fold(base.replace(/(\p{Ll})(\p{Lu})/gu, "$1 $2"));
|
|
127
|
+
const runs = [folded, camel].map((s) => s.split(/[^a-z0-9]+/).filter(Boolean));
|
|
123
128
|
return {
|
|
124
|
-
words:
|
|
129
|
+
words: runs.flat(),
|
|
125
130
|
chunks: folded.split(/\s+/).map((c) => c.replace(/[^a-z0-9]/g, "")).filter(Boolean),
|
|
131
|
+
runs,
|
|
126
132
|
};
|
|
127
133
|
}
|
|
128
134
|
// "data" is an <object>'s address (Codex round 79: a CAPTCHA embedded that way was not refused).
|
|
@@ -136,7 +142,7 @@ const OPAQUE = new Set(["button", "select", "textarea", "template", "script", "s
|
|
|
136
142
|
// The input types Tiresias knows; any other refuses the form (round 87: it was read as text).
|
|
137
143
|
const KNOWN_INPUTS = new Set([...TEXT_TYPES, "hidden", "checkbox", "radio", "submit", "image", "reset", "button", "password", "file"]);
|
|
138
144
|
const MAX_AUDIT_TEXT = 1024 * 1024; // all texts the audit reads in one form
|
|
139
|
-
//
|
|
145
|
+
// The existing safety markers, single words and phrases alike. A phrase also matches with its words run
|
|
140
146
|
// together in any way ("sign in code" is also "signin code", "sign incode" and "signincode").
|
|
141
147
|
const MARKER_PHRASES = [
|
|
142
148
|
["payment", ["card number", "card num", "card no", "credit card", "debit card", "cc num", "cc number", "cc exp", "cc expiry", "cc csc", "cc cvv", "cc cvc",
|
|
@@ -144,6 +150,164 @@ const MARKER_PHRASES = [
|
|
|
144
150
|
["login_or_password", ["password", "pass code", "passphrase", "login code", "sign in code", "one time", "otp", "verification code", "2fa", "two factor", "authenticator", "pin code"]],
|
|
145
151
|
["captcha", ["captcha", "turnstile", "not a robot", "not robot", "are you a human", "are you human"]],
|
|
146
152
|
];
|
|
153
|
+
// Actions use whole words only, never chunks or skeletons: "display", "buyer", "designing" and
|
|
154
|
+
// "blog in" are ordinary text. Inflections are explicit so unrelated longer words stay harmless.
|
|
155
|
+
const ACTION_WORDS = [
|
|
156
|
+
["payment", ["pay", "pays", "paying", "paid", "payment", "payments", "purchase", "purchases", "purchased", "purchasing", "buy", "buys", "buying", "bought", "checkout", "checkouts", "placeorder"]],
|
|
157
|
+
["login_or_password", ["login", "logins", "signin", "signins"]],
|
|
158
|
+
];
|
|
159
|
+
// Preserve the original ASCII-token phrase checks on every text that feeds the word bag,
|
|
160
|
+
// including the whole subtree with text nodes spaced apart.
|
|
161
|
+
const LEGACY_ACTION_PHRASES = [
|
|
162
|
+
...["check", "checks", "checked", "checking"].map((w) => ["payment", w, "out"]),
|
|
163
|
+
...["place", "places", "placed", "placing"].flatMap((w) => ["order", "orders"].map((o) => ["payment", w, o])),
|
|
164
|
+
...["log", "logs", "logged", "logging", "sign", "signs", "signed", "signing"].map((w) => ["login_or_password", w, "in"]),
|
|
165
|
+
];
|
|
166
|
+
// New phrases require ordered Unicode words in one attribute or block, in either inline
|
|
167
|
+
// tokenisation. Separate attributes or blocks cannot form a new phrase.
|
|
168
|
+
const ACTION_PHRASES = [
|
|
169
|
+
...LEGACY_ACTION_PHRASES,
|
|
170
|
+
...["confirm", "confirms", "confirmed", "confirming", "complete", "completes", "completed", "completing",
|
|
171
|
+
"submit", "submits", "submitted", "submitting", "finish", "finishes", "finished", "finishing",
|
|
172
|
+
"finalize", "finalizes", "finalized", "finalizing", "finalise", "finalises", "finalised", "finalising"]
|
|
173
|
+
.flatMap((w) => ["order", "orders", "purchase", "purchases", "payment", "payments"].map((o) => ["payment", w, o])),
|
|
174
|
+
["payment", "order", "now"],
|
|
175
|
+
];
|
|
176
|
+
// Closed, language-specific grammar; at most two of these may separate phrase parts.
|
|
177
|
+
const FILLERS = {
|
|
178
|
+
en: ["your", "my", "the", "this", "our", "their", "me"],
|
|
179
|
+
es: ["mi", "tu", "su", "el", "la", "los", "las", "mis", "tus", "sus", "este", "esta"],
|
|
180
|
+
fr: ["ma", "mon", "mes", "votre", "vos", "notre", "nos", "la", "le", "les", "ce", "cette"],
|
|
181
|
+
de: ["meine", "meinen", "mein", "ihre", "ihren", "ihr", "die", "der", "das", "deine", "deinen", "dein"],
|
|
182
|
+
pt: ["meu", "minha", "seu", "sua", "o", "a", "os", "as", "este", "esta"],
|
|
183
|
+
it: ["mio", "mia", "tuo", "tua", "suo", "sua", "il", "lo", "la", "un", "una"],
|
|
184
|
+
nl: ["mijn", "je", "jouw", "uw", "de", "het", "dit", "deze"],
|
|
185
|
+
ru: ["мой", "моя", "мои", "мою", "ваш", "ваша", "ваши", "вашу", "свой", "свою", "этот"],
|
|
186
|
+
zh: ["我的", "您的", "你的"], ja: ["私の", "あなたの"], ko: ["내", "나의", "귀하의"],
|
|
187
|
+
ar: ["هذا", "هذه"], hi: ["मेरा", "मेरे", "अपना", "अपने", "आपका", "आपके", "की"],
|
|
188
|
+
};
|
|
189
|
+
// Only complete control labels accept these complements, never arbitrary trailing text.
|
|
190
|
+
const COMPLEMENTS = {
|
|
191
|
+
en: [["with email", "to account"], []], es: [["con email", "con correo", "a cuenta"], []],
|
|
192
|
+
fr: [["avec email", "par email", "a compte"], ["par carte"]],
|
|
193
|
+
de: [["mit email", "mit e mail", "in konto"], []], pt: [["com email", "com e mail", "na conta"], []],
|
|
194
|
+
it: [["con email", "con e mail", "al account"], []], nl: [["met email", "met e mail", "op account"], []],
|
|
195
|
+
ru: [["по почте", "в аккаунт"], []], ar: [["إلى حسابك", "الى حسابك", "بالبريد"], []],
|
|
196
|
+
};
|
|
197
|
+
const OTHER_ACTIONS = {
|
|
198
|
+
en: { anywhere: [[], []], submit: [["log in", "sign in"], ["order"]], now: ["now"] },
|
|
199
|
+
es: { anywhere: [["iniciar sesion", "inicia sesion", "inicie sesion"],
|
|
200
|
+
["pagar", "pague", "comprar", "finalizar compra", "finalizar pedido", "realizar pedido", "hacer pedido", "confirmar pedido", "tramitar pedido"]],
|
|
201
|
+
submit: [["acceder", "accede", "acceda"], ["paga", "compra", "compre"]], now: ["ahora"] },
|
|
202
|
+
fr: { anywhere: [["se connecter", "me connecter", "connectez vous", "ouvrir une session"],
|
|
203
|
+
["payez", "acheter", "achetez", "passer a la caisse", "passer commande", "valider la commande", "confirmer la commande"]],
|
|
204
|
+
submit: [["connexion"], ["payer", "achat", "commander"]], now: ["maintenant"] },
|
|
205
|
+
de: { anywhere: [["einloggen", "einloggen sie sich"],
|
|
206
|
+
["bezahlen", "kaufen", "kaufe", "zur kasse", "bestellung aufgeben", "jetzt bestellen", "bestellung bestatigen"]],
|
|
207
|
+
submit: [["anmelden", "anmeldung"], ["zahlen", "kauf", "bestellen", "zahlungspflichtig bestellen"]], now: ["jetzt"] },
|
|
208
|
+
pt: { anywhere: [["iniciar sessao", "iniciar sessao de utilizador", "fazer login", "entrar na conta"],
|
|
209
|
+
["pagar", "pague", "comprar", "finalizar compra", "finalizar pedido", "fazer pedido", "efetuar pedido", "confirmar pedido", "concluir pedido"]],
|
|
210
|
+
submit: [["entrar"], ["compre", "compra"]], now: ["agora"] },
|
|
211
|
+
it: { anywhere: [["effettua l accesso", "inizia sessione"],
|
|
212
|
+
["pagare", "acquista", "acquistare", "acquisto", "comprare", "procedi al pagamento", "vai alla cassa", "effettua ordine", "effettua l ordine", "conferma ordine"]],
|
|
213
|
+
submit: [["accedi", "accedere"], ["paga", "compra", "ordina"]], now: ["ora", "adesso"] },
|
|
214
|
+
nl: { anywhere: [["inloggen", "log in", "meld je aan"],
|
|
215
|
+
["betalen", "betaal", "kopen", "aankoop", "afrekenen", "bestelling plaatsen", "plaats bestelling", "bestelling bevestigen"]],
|
|
216
|
+
submit: [["aanmelden", "aanmelding"], ["koop", "bestel"]], now: ["nu"] },
|
|
217
|
+
ru: { anywhere: [["вход в систему", "авторизоваться"],
|
|
218
|
+
["оплатить", "оплата", "платить", "купить", "покупка", "оформить покупку", "оформить заказ", "разместить заказ", "подтвердить заказ", "заказать"]],
|
|
219
|
+
submit: [["войти", "вход"], ["приобрести"]], now: ["сейчас"] },
|
|
220
|
+
zh: { anywhere: [["登录", "登錄", "登入"],
|
|
221
|
+
["支付", "付款", "购买", "購買", "结账", "結帳", "結賬", "结算", "結算", "下单", "下單", "提交订单", "提交訂單", "确认订单", "確認訂單"]],
|
|
222
|
+
submit: [[], ["买", "買", "订购", "訂購"]], now: ["现在", "現在", "立即"] },
|
|
223
|
+
ja: { anywhere: [["ログイン", "サインイン"],
|
|
224
|
+
["支払う", "支払い", "お支払", "購入", "買う", "チェックアウト", "レジに進む", "注文する", "注文を確定", "注文を送信", "注文確定", "注文を完了する"]],
|
|
225
|
+
submit: [[], []], now: ["今すぐ"] },
|
|
226
|
+
ko: { anywhere: [["로그인", "로그인하기"],
|
|
227
|
+
["결제", "지불", "구매", "구입", "체크아웃", "주문하기", "주문 제출", "주문 확정", "주문 완료"]],
|
|
228
|
+
submit: [[], ["사기"]], now: ["지금"] },
|
|
229
|
+
ar: { anywhere: [["تسجيل الدخول", "تسجيل دخول"],
|
|
230
|
+
["ادفع", "إدفع", "شراء", "اشتر", "اشتري", "اشترى", "إتمام الشراء", "اتمام الشراء", "تقديم الطلب", "إرسال الطلب", "ارسال الطلب", "تأكيد الطلب"]],
|
|
231
|
+
submit: [["الدخول"], ["دفع", "الدفع", "اطلب"]], now: ["الآن", "الان"] },
|
|
232
|
+
hi: { anywhere: [["साइन इन", "लॉग इन", "लाग इन", "लॉगिन", "प्रवेश करें"],
|
|
233
|
+
["भुगतान", "खरीदें", "खरीदना", "खरीदारी", "चेकआउट", "चेक आउट", "ऑर्डर दें", "आर्डर दें", "ऑर्डर करें", "ऑर्डर पक्का करें", "ऑर्डर पुष्टि करें"]],
|
|
234
|
+
submit: [[], []], now: ["अभी"] },
|
|
235
|
+
};
|
|
236
|
+
const NO_ACTION_EDGES = new Set(["zh", "ja", "ko"]);
|
|
237
|
+
const LATIN_ACTIONS = new Set(["es", "fr", "de", "pt", "it", "nl"]);
|
|
238
|
+
const WORD_SEP = "[^\\p{L}\\p{M}\\p{N}]+";
|
|
239
|
+
const actionBody = (phrase, language) => {
|
|
240
|
+
const fillers = language ? FILLERS[language] : undefined;
|
|
241
|
+
const sep = fillers?.length ? `${WORD_SEP}(?:(?:${fillers.join("|")})${WORD_SEP}){0,2}` : WORD_SEP;
|
|
242
|
+
const words = fold(phrase).split(" ");
|
|
243
|
+
// Existing phrases include determiners ("confirmer la commande"). Treat those
|
|
244
|
+
// as fillers too, so the same zero-to-two bound applies to every spelling.
|
|
245
|
+
return words.filter((w, i) => i === 0 || i === words.length - 1 || !fillers?.includes(w)).join(sep);
|
|
246
|
+
};
|
|
247
|
+
const actionPattern = (language, phrase) => {
|
|
248
|
+
const body = actionBody(phrase, language);
|
|
249
|
+
return new RegExp(NO_ACTION_EDGES.has(language) ? body : `(?<![\\p{L}\\p{M}\\p{N}])${body}(?![\\p{L}\\p{M}\\p{N}])`, "u");
|
|
250
|
+
};
|
|
251
|
+
const OTHER_ACTION_PATTERNS = new Map(Object.entries(OTHER_ACTIONS).map(([language, { anywhere, submit, now }]) => {
|
|
252
|
+
const sep = NO_ACTION_EDGES.has(language) ? "\\s*" : WORD_SEP;
|
|
253
|
+
const when = now.map(w => actionBody(w)).join("|");
|
|
254
|
+
return [language, {
|
|
255
|
+
anywhere: anywhere.map((phrases) => phrases.map((p) => actionPattern(language, p))),
|
|
256
|
+
submit: submit.map((words, group) => words.map((w) => {
|
|
257
|
+
const complement = (COMPLEMENTS[language]?.[group] ?? []).map(p => actionBody(p, language)).join("|");
|
|
258
|
+
const action = `${actionBody(w)}${complement ? `(?:${sep}(?:${complement}))?` : ""}`;
|
|
259
|
+
return new RegExp(`^(?:(?:${when})${sep})?${action}(?:${sep}(?:${when}))?$`, "u");
|
|
260
|
+
})),
|
|
261
|
+
}];
|
|
262
|
+
}));
|
|
263
|
+
// One first-word lookup per token; each candidate has a constant, bounded gap.
|
|
264
|
+
function phraseIndex(phrases) {
|
|
265
|
+
const index = new Map();
|
|
266
|
+
for (const [code, first, second] of phrases) {
|
|
267
|
+
if (!index.has(first))
|
|
268
|
+
index.set(first, new Map());
|
|
269
|
+
index.get(first).set(second, code);
|
|
270
|
+
}
|
|
271
|
+
return index;
|
|
272
|
+
}
|
|
273
|
+
const LEGACY_INDEX = phraseIndex(LEGACY_ACTION_PHRASES);
|
|
274
|
+
const ACTION_INDEX = phraseIndex(ACTION_PHRASES);
|
|
275
|
+
const EN_FILLERS = new Set(FILLERS.en);
|
|
276
|
+
function phraseRefusals(run, index, b, gaps = false) {
|
|
277
|
+
for (let i = 0; i + 1 < run.length; i++) {
|
|
278
|
+
const ends = index.get(run[i]);
|
|
279
|
+
if (!ends)
|
|
280
|
+
continue;
|
|
281
|
+
for (let j = i + 1; j < run.length && j <= i + (gaps ? 3 : 1); j++) {
|
|
282
|
+
const code = ends.get(run[j]);
|
|
283
|
+
if (code)
|
|
284
|
+
b.np(code);
|
|
285
|
+
if (!EN_FILLERS.has(run[j]))
|
|
286
|
+
break;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
function otherActionRefusals(text, b, submit = false) {
|
|
291
|
+
const folded = norm(fold(text));
|
|
292
|
+
for (const language of ["en", ...listsFor(folded)]) {
|
|
293
|
+
const value = LATIN_ACTIONS.has(language) ? stripAccents(folded) : folded;
|
|
294
|
+
const patterns = OTHER_ACTION_PATTERNS.get(language);
|
|
295
|
+
const groups = submit ? patterns.submit : patterns.anywhere;
|
|
296
|
+
if (groups[0].some((re) => re.test(value)))
|
|
297
|
+
b.np("login_or_password");
|
|
298
|
+
if (groups[1].some((re) => re.test(value)))
|
|
299
|
+
b.np("payment");
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
function actionRefusals(text, b) {
|
|
303
|
+
const base = invisible(text).normalize("NFKC");
|
|
304
|
+
const runs = [fold(base), fold(base.replace(/(\p{Ll})(\p{Lu})/gu, "$1 $2"))]
|
|
305
|
+
.map((s) => s.split(/[^\p{L}\p{M}\p{N}]+/u).filter(Boolean));
|
|
306
|
+
for (const run of runs) {
|
|
307
|
+
phraseRefusals(run, ACTION_INDEX, b, true);
|
|
308
|
+
}
|
|
309
|
+
otherActionRefusals(text, b);
|
|
310
|
+
}
|
|
147
311
|
// Every marker's run-together form, searched inside every chunk (round 94, coordinator's decision): a
|
|
148
312
|
// marker anywhere inside a word counts ("recaptcha", "mypassword", "footpath" for "otp").
|
|
149
313
|
// Markers whose run-together form has SHORT_MARKER characters or more are found inside skeletons (across
|
|
@@ -165,9 +329,6 @@ const joinings = (ws) => {
|
|
|
165
329
|
// phrase also matches with some of its words run together ("signin" + "code").
|
|
166
330
|
const MARKERS = MARKER_PHRASES.flatMap(([code, ps]) => ps.flatMap((p) => joinings(p.split(" ")).map((w) => [code, w])));
|
|
167
331
|
const ID_LISTS = ["aria-labelledby", "aria-describedby", "aria-details", "aria-errormessage", "aria-owns"];
|
|
168
|
-
// Characters that render as nothing (zero-width, soft hyphen, bidi marks, variation selectors and the
|
|
169
|
-
// like) are removed before any text is judged (round 90).
|
|
170
|
-
const invisible = (t) => t.replace(/[\p{Cf}\p{Default_Ignorable_Code_Point}]/gu, "");
|
|
171
332
|
const MAX_REFS = 50; // ids in one reference attribute, and labels for one id; more refuses (round 89)
|
|
172
333
|
// Elements that break a line of text. Anything else (custom elements included) is inline, as in a browser.
|
|
173
334
|
const BLOCK = new Set([
|
|
@@ -175,6 +336,24 @@ const BLOCK = new Set([
|
|
|
175
336
|
"figure", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "header", "hgroup", "hr", "input", "legend", "li", "main", "menu", "nav", "ol",
|
|
176
337
|
"optgroup", "option", "p", "pre", "section", "select", "summary", "table", "tbody", "td", "textarea", "tfoot", "th", "thead", "tr", "ul",
|
|
177
338
|
]);
|
|
339
|
+
function judgeText(text, cache) {
|
|
340
|
+
const old = cache.get(text);
|
|
341
|
+
if (old)
|
|
342
|
+
return old;
|
|
343
|
+
const { words, chunks, runs } = tokens(text);
|
|
344
|
+
const basic = new Set(), actions = new Set(), submit = new Set();
|
|
345
|
+
for (const run of runs)
|
|
346
|
+
phraseRefusals(run, LEGACY_INDEX, { np: c => basic.add(c) });
|
|
347
|
+
for (const c of new Set(chunks))
|
|
348
|
+
for (const [code, inside] of MARKER_SHORT)
|
|
349
|
+
if (c.includes(inside))
|
|
350
|
+
basic.add(code);
|
|
351
|
+
actionRefusals(text, { np: c => actions.add(c) });
|
|
352
|
+
otherActionRefusals(text, { np: c => submit.add(c) }, true);
|
|
353
|
+
const value = { words: [...new Set(words)], skeleton: skeleton(text), card: hasCardNumber(text), basic, actions, submit };
|
|
354
|
+
cache.set(text, value);
|
|
355
|
+
return value;
|
|
356
|
+
}
|
|
178
357
|
function auditForm(form, b, ctx) {
|
|
179
358
|
let used = 0;
|
|
180
359
|
let nodes = 0;
|
|
@@ -184,30 +363,37 @@ function auditForm(form, b, ctx) {
|
|
|
184
363
|
b.np("too_large");
|
|
185
364
|
};
|
|
186
365
|
const bag = new Set(); // every word the form and everything tied to it says
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
// for the MARKERS check) and its card digits
|
|
191
|
-
const judge = (text, skel) => {
|
|
366
|
+
const skeletons = new Set();
|
|
367
|
+
// Charge every read even on a cache hit: sharing classification never grants extra budget.
|
|
368
|
+
const charged = (text) => {
|
|
192
369
|
used += text.length;
|
|
193
|
-
if (used > MAX_AUDIT_TEXT)
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
for (const w of words)
|
|
197
|
-
bag.add(w);
|
|
198
|
-
for (const c of chunks) {
|
|
199
|
-
if (chunkSeen.has(c))
|
|
200
|
-
continue;
|
|
201
|
-
chunkSeen.add(c);
|
|
202
|
-
for (const [code, inside] of MARKER_SHORT)
|
|
203
|
-
if (c.includes(inside))
|
|
204
|
-
b.np(code);
|
|
370
|
+
if (used > MAX_AUDIT_TEXT) {
|
|
371
|
+
tooLarge();
|
|
372
|
+
return undefined;
|
|
205
373
|
}
|
|
374
|
+
return judgeText(text, ctx.texts);
|
|
375
|
+
};
|
|
376
|
+
const judge = (text, skel) => {
|
|
377
|
+
const value = charged(text);
|
|
378
|
+
if (!value)
|
|
379
|
+
return;
|
|
380
|
+
for (const w of value.words)
|
|
381
|
+
bag.add(w);
|
|
382
|
+
for (const c of value.basic)
|
|
383
|
+
b.np(c);
|
|
206
384
|
if (!skel)
|
|
207
385
|
return;
|
|
208
|
-
|
|
386
|
+
for (const c of value.actions)
|
|
387
|
+
b.np(c);
|
|
388
|
+
if (value.card)
|
|
209
389
|
b.np("payment");
|
|
210
|
-
skeletons.
|
|
390
|
+
skeletons.add(value.skeleton);
|
|
391
|
+
};
|
|
392
|
+
const submitText = (text) => {
|
|
393
|
+
const value = charged(text);
|
|
394
|
+
if (value)
|
|
395
|
+
for (const c of value.submit)
|
|
396
|
+
b.np(c);
|
|
211
397
|
};
|
|
212
398
|
// each attribute value is its own text (round 93: never joined); each element's attributes are judged
|
|
213
399
|
// exactly once, whether reached as an ancestor or in a walk (round 96: twice spent the budget twice)
|
|
@@ -216,8 +402,14 @@ function auditForm(form, b, ctx) {
|
|
|
216
402
|
if (attrSeen.has(n))
|
|
217
403
|
return;
|
|
218
404
|
attrSeen.add(n);
|
|
219
|
-
|
|
405
|
+
const c = n.attribs ?? {};
|
|
406
|
+
for (const v of Object.values(c))
|
|
220
407
|
judge(v, true);
|
|
408
|
+
if (n.name === "input" && ["submit", "button", "image"].includes((c.type ?? "").trim().toLowerCase())) {
|
|
409
|
+
for (const v of [c.value, c.alt])
|
|
410
|
+
if (v !== undefined)
|
|
411
|
+
submitText(v);
|
|
412
|
+
}
|
|
221
413
|
};
|
|
222
414
|
const units = [];
|
|
223
415
|
const queued = new Set();
|
|
@@ -311,25 +503,39 @@ function auditForm(form, b, ctx) {
|
|
|
311
503
|
// in the page's own text, which split a word or a card number)
|
|
312
504
|
const blocks = [];
|
|
313
505
|
let cur = "";
|
|
506
|
+
let curSpaced = "";
|
|
507
|
+
let buttonText;
|
|
314
508
|
let size = 0;
|
|
315
509
|
const endBlock = () => {
|
|
316
510
|
if (cur)
|
|
317
|
-
blocks.push(cur);
|
|
511
|
+
blocks.push({ joined: cur, spaced: curSpaced });
|
|
318
512
|
cur = "";
|
|
513
|
+
curSpaced = "";
|
|
319
514
|
};
|
|
320
515
|
const work = [{ n: root, inside: false }];
|
|
321
516
|
while (work.length && !stop) {
|
|
322
517
|
const it = work.pop();
|
|
518
|
+
if ("buttonEnd" in it) {
|
|
519
|
+
submitText(buttonText.joined);
|
|
520
|
+
submitText(buttonText.spaced);
|
|
521
|
+
buttonText = undefined;
|
|
522
|
+
continue;
|
|
523
|
+
}
|
|
323
524
|
if ("sep" in it) {
|
|
324
525
|
endBlock();
|
|
325
526
|
continue;
|
|
326
527
|
}
|
|
327
528
|
const { n: x, inside } = it; // the kept subtrees are the union found above, so no new budget is needed
|
|
328
529
|
if (x.type === "text") {
|
|
329
|
-
if (
|
|
530
|
+
if (charged(x.data ?? "")?.card)
|
|
330
531
|
b.np("payment");
|
|
331
532
|
spaced += (x.data ?? "") + " ";
|
|
332
533
|
cur += x.data ?? "";
|
|
534
|
+
curSpaced += (x.data ?? "") + " ";
|
|
535
|
+
if (buttonText) {
|
|
536
|
+
buttonText.joined += x.data ?? "";
|
|
537
|
+
buttonText.spaced += (x.data ?? "") + " ";
|
|
538
|
+
}
|
|
333
539
|
size += (x.data ?? "").length;
|
|
334
540
|
if (spaced.length + size > MAX_AUDIT_TEXT)
|
|
335
541
|
return tooLarge();
|
|
@@ -349,6 +555,12 @@ function auditForm(form, b, ctx) {
|
|
|
349
555
|
b.np("unknown_control");
|
|
350
556
|
attrs(x); // every attribute value: titles, labels, placeholders, values...
|
|
351
557
|
block = BLOCK.has(nm);
|
|
558
|
+
// Capture a button's entire text in the same bounded walk. Nested controls already
|
|
559
|
+
// fail closed; do not copy their text into multiple nested accumulators.
|
|
560
|
+
if (nm === "button" && !buttonText) {
|
|
561
|
+
buttonText = { joined: "", spaced: "" };
|
|
562
|
+
work.push({ buttonEnd: true });
|
|
563
|
+
}
|
|
352
564
|
}
|
|
353
565
|
if (block) {
|
|
354
566
|
endBlock();
|
|
@@ -365,19 +577,29 @@ function auditForm(form, b, ctx) {
|
|
|
365
577
|
// each block of inline-joined text is one text: its skeleton and its card digits (round 95: a card
|
|
366
578
|
// number split across inline elements). Any white space in a block, line breaks, tabs and CR included,
|
|
367
579
|
// is ordinary spacing (round 96).
|
|
368
|
-
for (const piece of blocks)
|
|
369
|
-
judge(piece.replace(/\s+/g, " "), true);
|
|
580
|
+
for (const piece of blocks) {
|
|
581
|
+
judge(piece.joined.replace(/\s+/g, " "), true);
|
|
582
|
+
if (piece.spaced !== piece.joined) {
|
|
583
|
+
const value = charged(piece.spaced);
|
|
584
|
+
if (value)
|
|
585
|
+
for (const c of value.actions)
|
|
586
|
+
b.np(c);
|
|
587
|
+
}
|
|
588
|
+
}
|
|
370
589
|
}
|
|
371
590
|
if (stop)
|
|
372
591
|
return;
|
|
373
592
|
// EVERY marker of SHORT_MARKER characters or more, and every many-word marker with its words apart: a word
|
|
374
593
|
// (or run-together piece) of SHORT_MARKER letters or more counts when it is inside any skeleton
|
|
375
594
|
// ("SeCuRiTy Code" as "securitycode"; "mySeCuRiTy" and "code"), a shorter one only as a whole word
|
|
376
|
-
const all = skeletons.join("|");
|
|
595
|
+
const all = [...skeletons].join("|");
|
|
377
596
|
const has = (w) => bag.has(w) || (w.length >= SHORT_MARKER && all.includes(w));
|
|
378
597
|
for (const [code, need] of MARKERS)
|
|
379
598
|
if (need.every(has))
|
|
380
599
|
b.np(code);
|
|
600
|
+
for (const [code, words] of ACTION_WORDS)
|
|
601
|
+
if (words.some((w) => bag.has(w)))
|
|
602
|
+
b.np(code);
|
|
381
603
|
}
|
|
382
604
|
// ONE set of per-element refusals (Codex round 85: the whole-form scan had its own, shorter copy). Used by
|
|
383
605
|
// the whole-form scan, which visits every element, and by the field walk. Label-based payment checks stay
|
|
@@ -386,7 +608,7 @@ function elementRefusals(name, c, b) {
|
|
|
386
608
|
if (captchaMarker(c) || EMBEDDED.has(name))
|
|
387
609
|
b.np("captcha");
|
|
388
610
|
const auto = (c.autocomplete ?? "").toLowerCase().split(/\s+/);
|
|
389
|
-
if (auto.some((x) => x === "current-password" || x === "new-password" || x === "one-time-code"))
|
|
611
|
+
if (auto.some((x) => x === "username" || x === "current-password" || x === "new-password" || x === "one-time-code"))
|
|
390
612
|
b.np("login_or_password");
|
|
391
613
|
if (auto.some((x) => x.startsWith("cc-")))
|
|
392
614
|
b.np("payment");
|
|
@@ -586,11 +808,12 @@ export function extractForms(doc, pageUrl, flattened = false) {
|
|
|
586
808
|
labelCache.set(n, (t = textOf(n, budget)));
|
|
587
809
|
return t;
|
|
588
810
|
};
|
|
811
|
+
const texts = new Map();
|
|
589
812
|
const forms = formNodes.slice(0, MAX_FORMS).map((f, i) => {
|
|
590
813
|
const ancestors = [];
|
|
591
814
|
for (let x = formUp.get(f) ?? null; x; x = x.up)
|
|
592
815
|
ancestors.push(x.n);
|
|
593
|
-
const form = readForm(f, i + 1, pageUrl, base, labelFor, labelText, budget, { ids, labelsFor, ancestors, span });
|
|
816
|
+
const form = readForm(f, i + 1, pageUrl, base, labelFor, labelText, budget, { ids, labelsFor, ancestors, span, texts });
|
|
594
817
|
// Flattening may have changed a control's owner or its ancestors: never submit a partial form.
|
|
595
818
|
if (flattened && !form.not_allowed)
|
|
596
819
|
form.not_allowed = "too_large";
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Known GET form targets are policy, not a guess about what an arbitrary GET does.
|
|
3
|
+
import { loadChoice } from "./config.js";
|
|
4
|
+
import { Refused } from "./errors.js";
|
|
5
|
+
import { cachePath, homeDir, isPrivate, readJson, writeJson } from "./store.js";
|
|
6
|
+
import { normalizePath } from "./rules.js";
|
|
7
|
+
import { callContext } from "./context.js";
|
|
8
|
+
import { claimSlip, claimedStillValid } from "./slips.js";
|
|
9
|
+
const shared = { seen: new Set(), full: false };
|
|
10
|
+
const MAX_SEEN = 4096;
|
|
11
|
+
// A denial comparison, never a URL to send or a permission-slip scope. Reuse the robots path
|
|
12
|
+
// normalizer for unreserved octets and escape case, then fold ambiguous server routing spellings
|
|
13
|
+
// conservatively: repeated decoding, separators, path parameters, Unicode, case and dot segments.
|
|
14
|
+
// At a fixed point, keep only Unicode letters and digits per segment, dropping empty segments.
|
|
15
|
+
// URL already handles IDNA, IP spellings, host case and default ports. No DNS alias guessing.
|
|
16
|
+
export function getActionTarget(u) {
|
|
17
|
+
const host = new URL(u.origin);
|
|
18
|
+
host.hostname = host.hostname.replace(/\.+$/, "");
|
|
19
|
+
let path = normalizePath(u.pathname);
|
|
20
|
+
// Repeat the whole fold: NFKC itself can introduce a fresh percent escape.
|
|
21
|
+
// Bound nested encoding work; the wildcard is a denial key for the entire origin.
|
|
22
|
+
for (let i = 0; i < 64; i++) {
|
|
23
|
+
let next = path.replace(/(?:%[0-9a-f]{2})+/gi, (s) => {
|
|
24
|
+
try {
|
|
25
|
+
return decodeURIComponent(s);
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return s.replace(/%([0-7][0-9a-f])/gi, (_, h) => String.fromCharCode(parseInt(h, 16)));
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
// URL parsers remove these controls before resolving dot segments and escapes.
|
|
32
|
+
next = next.replace(/[\t\n\r]/g, "");
|
|
33
|
+
next = next.normalize("NFKC").toLowerCase().replace(/\\/g, "/").split(/[?#\0]/)[0];
|
|
34
|
+
const parts = [];
|
|
35
|
+
for (const part of next.split("/")) {
|
|
36
|
+
const seg = part.split(";")[0].replace(/ +$/, "");
|
|
37
|
+
if (seg === "..")
|
|
38
|
+
parts.pop();
|
|
39
|
+
// Keep dots until nested escapes can expose a dot segment, such as .%2509.
|
|
40
|
+
else if (seg && seg !== ".")
|
|
41
|
+
parts.push(/%[0-9a-f]{2}/i.test(seg) ? seg : seg.replace(/[. ]+$/, ""));
|
|
42
|
+
}
|
|
43
|
+
next = "/" + parts.filter(Boolean).join("/");
|
|
44
|
+
if (next === path) {
|
|
45
|
+
// Preserve the origin wildcard, including when a denial key is folded again.
|
|
46
|
+
if (next === "/*")
|
|
47
|
+
return `${host.origin}/*`;
|
|
48
|
+
next = "/" + next.split("/").map((seg) => seg.replace(/[^\p{L}\p{N}]/gu, "")).filter(Boolean).join("/");
|
|
49
|
+
if (next === path)
|
|
50
|
+
return `${host.origin}${next}`;
|
|
51
|
+
// Removing punctuation can join Unicode letters that then compose under NFKC.
|
|
52
|
+
// Converge again within the same bound so the final denial key stays idempotent.
|
|
53
|
+
}
|
|
54
|
+
path = next;
|
|
55
|
+
}
|
|
56
|
+
return `${host.origin}/*`;
|
|
57
|
+
}
|
|
58
|
+
// Inputs are already folded, so a renderer folds its request only once.
|
|
59
|
+
export function getActionTargetsMatch(a, b) {
|
|
60
|
+
return a === b || ((a.endsWith("/*") || b.endsWith("/*")) && new URL(a).origin === new URL(b).origin);
|
|
61
|
+
}
|
|
62
|
+
const actionKey = (u) => `get-form:${getActionTarget(u)}`;
|
|
63
|
+
function observations() {
|
|
64
|
+
if (!isPrivate())
|
|
65
|
+
return shared;
|
|
66
|
+
const ctx = callContext.getStore();
|
|
67
|
+
// A caller without a call scope must never put private observations in shared memory.
|
|
68
|
+
return ctx ? (ctx.getActions ??= { seen: new Set(), full: false }) : undefined;
|
|
69
|
+
}
|
|
70
|
+
const memoryKey = (key) => `${homeDir()}\0${key}`;
|
|
71
|
+
export function noteGetActions(forms = [], keep = false) {
|
|
72
|
+
const state = observations();
|
|
73
|
+
for (const f of forms) {
|
|
74
|
+
if (f.method !== "GET" || !f.action)
|
|
75
|
+
continue;
|
|
76
|
+
const key = actionKey(new URL(f.action));
|
|
77
|
+
if (state && state.seen.size < MAX_SEEN)
|
|
78
|
+
state.seen.add(memoryKey(key));
|
|
79
|
+
else if (state)
|
|
80
|
+
state.full = true; // never forget a known target when the in-memory policy fills up
|
|
81
|
+
if (keep && !isPrivate() && !callContext.getStore()?.readOnly)
|
|
82
|
+
writeJson(cachePath(key), { get_form_action: true, fetched_at: new Date().toISOString() });
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
export function guardGetAction(u) {
|
|
86
|
+
if (loadChoice("get_form_actions") !== "slip")
|
|
87
|
+
return;
|
|
88
|
+
const target = getActionTarget(u);
|
|
89
|
+
const key = `get-form:${target}`;
|
|
90
|
+
const state = callContext.getStore()?.getActions;
|
|
91
|
+
const wildcard = `get-form:${new URL(target).origin}/*`;
|
|
92
|
+
const known = key === wildcard || [state, shared].some((s) => s?.full || s?.seen.has(memoryKey(key)) || s?.seen.has(memoryKey(wildcard))) ||
|
|
93
|
+
[key, wildcard].some((k) => readJson(cachePath(k))?.get_form_action === true);
|
|
94
|
+
if (!known)
|
|
95
|
+
return;
|
|
96
|
+
const claim = claimSlip("submit_form", u.href, "get_form_action");
|
|
97
|
+
if ("refused" in claim || !claimedStillValid(claim, "submit_form", u.href))
|
|
98
|
+
throw new Refused("This GET needs a current submit_form permission slip: its target matches an observed form action, or the observation limit was reached. Nothing was sent.");
|
|
99
|
+
}
|
package/dist/history.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// Tiresias is missing (W-12, needs.ts).
|
|
5
5
|
import { appendLine, listLogs, pageLog, parseSince, utcDay } from "./store.js";
|
|
6
6
|
import { LANG_SET } from "./lang.js";
|
|
7
|
+
const KEY_EVENTS = new Set(["signing_key_rotated", "signing_key_rotation_finished", "slip_key_rotated"]);
|
|
7
8
|
// Bounds on what one record may hold, so a single line can never outgrow a history page.
|
|
8
9
|
const MAX_AGENT = 200;
|
|
9
10
|
const MAX_PURPOSE = 1000;
|
|
@@ -18,7 +19,7 @@ const FLAGS = new Set(["phishing_list", "web_risk"]);
|
|
|
18
19
|
const SLIP_ID = /^[A-Za-z0-9_-]{24}$/;
|
|
19
20
|
const FILE_KINDS = new Set(["program", "script", "shortcut", "addon", "archive", "office", "image", "media", "unknown"]);
|
|
20
21
|
const SCANS = new Set(["bad", "clean", "unknown", "failed"]);
|
|
21
|
-
const SETTINGS = new Set(["saving", "rendering", "translator", "scanner", "anchoring", "anchor_calendars", "safe_browsing", "ports", "spacing_seconds", "never_visit", "hand_off", "confirmations"]);
|
|
22
|
+
const SETTINGS = new Set(["private_spacing", "hook_secrets", "saving", "rendering", "translator", "scanner", "anchoring", "anchor_calendars", "safe_browsing", "ports", "spacing_seconds", "never_visit", "hand_off", "confirmations"]);
|
|
22
23
|
const CHANGES = new Set(["looser", "stricter", "never_ask", "ask_again"]);
|
|
23
24
|
const BYS = new Set(["terminal", "not_terminal"]);
|
|
24
25
|
const HOWS = new Set(["phrase", "never_ask", "not_needed"]);
|
|
@@ -51,7 +52,7 @@ export function bound(e) {
|
|
|
51
52
|
drop("llms_txt");
|
|
52
53
|
if (e.ticket !== undefined && !(typeof e.ticket === "string" && TICKETS.has(e.ticket)))
|
|
53
54
|
drop("ticket");
|
|
54
|
-
if (e.source !== undefined && e.source !== "provided_by_person")
|
|
55
|
+
if (e.source !== undefined && e.source !== "provided_by_person" && e.source !== "provided_by_agent")
|
|
55
56
|
drop("source");
|
|
56
57
|
if (e.cache !== undefined && !(typeof e.cache === "string" && CACHE.has(e.cache)))
|
|
57
58
|
drop("cache");
|
|
@@ -79,8 +80,10 @@ export function bound(e) {
|
|
|
79
80
|
drop("by");
|
|
80
81
|
if (e.confirmed !== undefined && !(typeof e.confirmed === "string" && HOWS.has(e.confirmed)))
|
|
81
82
|
drop("confirmed");
|
|
82
|
-
if (e.event !== undefined && e.event
|
|
83
|
+
if (e.event !== undefined && !(e.event === "memory_ceiling" || (typeof e.event === "string" && KEY_EVENTS.has(e.event))))
|
|
83
84
|
drop("event");
|
|
85
|
+
if (e.revoked !== undefined && !(Number.isSafeInteger(e.revoked) && e.revoked >= 0 && e.revoked <= 100_000))
|
|
86
|
+
drop("revoked");
|
|
84
87
|
if (e.memory_mb !== undefined && !(Number.isSafeInteger(e.memory_mb) && e.memory_mb >= 1 && e.memory_mb <= 65536))
|
|
85
88
|
drop("memory_mb");
|
|
86
89
|
if (over)
|
|
@@ -92,7 +95,7 @@ export function record(e) {
|
|
|
92
95
|
const t = Date.parse(out.time);
|
|
93
96
|
appendLine(`history/${utcDay(Number.isNaN(t) ? Date.now() : t)}.jsonl`, out);
|
|
94
97
|
}
|
|
95
|
-
export async function query(f) {
|
|
98
|
+
export async function query(f, scan = {}) {
|
|
96
99
|
const since = parseSince(f.since);
|
|
97
100
|
const site = f.site?.toLowerCase().replace(/^www\./, "");
|
|
98
101
|
return pageLog(listLogs("history").map((f) => f.rel), (e) => {
|
|
@@ -115,5 +118,5 @@ export async function query(f) {
|
|
|
115
118
|
}
|
|
116
119
|
bound(e); // filters match the stored values; only what is returned is cut
|
|
117
120
|
return true;
|
|
118
|
-
}, f.page ?? 1);
|
|
121
|
+
}, f.page ?? 1, 40_000, scan);
|
|
119
122
|
}
|
package/dist/hook.js
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
// answered, or within 200 ms of Tiresias being gone. Tiresias also kills the group at the cap, on cancellation
|
|
8
8
|
// and once it has the answer, so a hook that starts helpers leaves nothing running. Its output is capped; its
|
|
9
9
|
// standard error is ignored. Hooks are never run on Windows (no process groups to kill).
|
|
10
|
+
import { loadChoice } from "./config.js";
|
|
10
11
|
import { spawn } from "node:child_process";
|
|
11
12
|
import { fileURLToPath } from "node:url";
|
|
12
13
|
import { currentSignal } from "./safety.js";
|
|
@@ -48,6 +49,7 @@ export function runHook(command, extra, timeoutMs, maxOut, input) {
|
|
|
48
49
|
const cap = maxOut === 4096 ? [] : [`max=${maxOut}`]; // the runner's default is the scanner's 4 KB
|
|
49
50
|
child = spawn(process.execPath, [runner, String(process.pid), String(timeoutMs), ...cap, command[0], ...command.slice(1), ...extra], {
|
|
50
51
|
// Always its own group: the runner kills its WHOLE group, which must never be ours.
|
|
52
|
+
env: loadChoice("hook_secrets") === "inherit" ? { ...process.env } : Object.fromEntries(Object.entries(process.env).filter(([k]) => !/^TIRESIAS_.*(?:KEY|SECRET|TOKEN|PASSWORD|CREDENTIAL)/i.test(k))),
|
|
51
53
|
shell: false, stdio: ["pipe", "pipe", "ignore"], detached: true, windowsHide: true,
|
|
52
54
|
});
|
|
53
55
|
}
|