@12-apps/messaging 1.3.0 → 1.5.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/README.md +155 -0
- package/dist/chunk-RXJNLPY4.js +560 -0
- package/dist/chunk-RXJNLPY4.js.map +1 -0
- package/dist/inbound-guard/index.d.ts +254 -0
- package/dist/inbound-guard/index.js +913 -0
- package/dist/inbound-guard/index.js.map +1 -0
- package/dist/whatsapp/index.js +22 -536
- package/dist/whatsapp/index.js.map +1 -1
- package/dist/whatsapp-web/index.d.ts +369 -0
- package/dist/whatsapp-web/index.js +588 -0
- package/dist/whatsapp-web/index.js.map +1 -0
- package/package.json +9 -1
- package/src/inbound-guard/classification.ts +143 -0
- package/src/inbound-guard/decode.ts +128 -0
- package/src/inbound-guard/index.ts +55 -0
- package/src/inbound-guard/normalize.ts +164 -0
- package/src/inbound-guard/rules-infra.ts +200 -0
- package/src/inbound-guard/rules-phrases.ts +167 -0
- package/src/inbound-guard/rules-types.ts +61 -0
- package/src/inbound-guard/rules.ts +89 -0
- package/src/inbound-guard/screen.ts +165 -0
- package/src/inbound-guard/wrap.ts +163 -0
- package/src/whatsapp-web/adapter.ts +62 -0
- package/src/whatsapp-web/auth-state.ts +92 -0
- package/src/whatsapp-web/baileys-port.ts +146 -0
- package/src/whatsapp-web/envelope.ts +87 -0
- package/src/whatsapp-web/index.ts +36 -0
- package/src/whatsapp-web/media.ts +78 -0
- package/src/whatsapp-web/normalize.ts +183 -0
- package/src/whatsapp-web/session.ts +306 -0
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `normalizeInbound` — the one view of an untrusted message every later step
|
|
3
|
+
* reads. It removes what renders as nothing (zero-width, bidi and control
|
|
4
|
+
* characters, Unicode tags), applies NFKC (full-width and styled letters
|
|
5
|
+
* become plain ones), folds Cyrillic and Greek look-alikes inside words that
|
|
6
|
+
* are spoofing Latin, and decodes obvious encoded runs into extra views the
|
|
7
|
+
* screen also scans. Pure: no I/O, no clock, no randomness.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { decodeRuns, decodeTagRuns, type DecodedRun } from "./decode";
|
|
11
|
+
|
|
12
|
+
export type { DecodedRun, EncodingKind } from "./decode";
|
|
13
|
+
|
|
14
|
+
/** How deep a decoded run is itself decoded (base64 inside base64). */
|
|
15
|
+
const MAX_DECODE_DEPTH = 2;
|
|
16
|
+
|
|
17
|
+
export interface NormalizedInbound {
|
|
18
|
+
/** The message exactly as received. */
|
|
19
|
+
readonly original: string;
|
|
20
|
+
/** Invisibles stripped, NFKC, look-alikes folded, line breaks unified. What an agent may be shown. */
|
|
21
|
+
readonly text: string;
|
|
22
|
+
/** `text` lower-cased, accents removed, whitespace collapsed. What the rules match. */
|
|
23
|
+
readonly folded: string;
|
|
24
|
+
/** Encoded runs that decode to text, at any depth up to two. */
|
|
25
|
+
readonly decoded: readonly DecodedRun[];
|
|
26
|
+
/** Invisible characters removed that have no innocent reading (emoji joiners are not counted). */
|
|
27
|
+
readonly invisibles: number;
|
|
28
|
+
/** Words written with look-alike letters from another script, or styled letters. */
|
|
29
|
+
readonly lookAlikes: number;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Letters drawn like a Latin one (after UTS #39's confusables), each pair
|
|
33
|
+
// written as the look-alike followed by its Latin twin.
|
|
34
|
+
const LOOK_ALIKE_PAIRS = [
|
|
35
|
+
// Cyrillic
|
|
36
|
+
"аa еe оo рp сc уy хx іi јj ѕs ԁd һh ӏl ԛq ԝw кk АA ВB ЕE КK МM НH ОO РP СC ТT ХX УY ІI ЈJ ЅS ԚQ ԜW",
|
|
37
|
+
// Greek
|
|
38
|
+
"αa οo ιi νv ρp τt υu χx κk ΑA ΒB ΕE ΖZ ΗH ΙI ΚK ΜM ΝN ΟO ΡP ΤT ΥY ΧX",
|
|
39
|
+
// Latin small capitals and IPA
|
|
40
|
+
"ıi ɪi ᴉi ɩi ȷj ɑa ɡg ɢg ʜh ɴn ʀr ʏy ʟl ᴀa ʙb ᴄc ᴅd ᴇe ᴊj ᴋk ᴍm ᴏo ᴘp ꜱs ᴛt ᴜu ᴠv ᴡw ᴢz",
|
|
41
|
+
// Armenian
|
|
42
|
+
"օo սu ոn հh ցg զq աw ՕO ՍU",
|
|
43
|
+
// Cherokee
|
|
44
|
+
"ᎪA ᏴB ᏟC ᎠD ᎬE ᏀG ᎻH ᎫJ ᏦK ᏞL ᎷM ᏢP ᎡR ᏚS ᎢT ᏙV ᏔW ᏃZ Ꭵi",
|
|
45
|
+
].join(" ");
|
|
46
|
+
const LOOK_ALIKE = new Map(
|
|
47
|
+
LOOK_ALIKE_PAIRS.split(" ").map((pair) => [...pair] as [string, string]),
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
const NUMERIC_ENTITY = /&#(x[0-9a-f]{1,6}|\d{1,7});/gi;
|
|
51
|
+
const NAMED_ENTITY: Readonly<Record<string, string>> = {
|
|
52
|
+
"<": "<",
|
|
53
|
+
">": ">",
|
|
54
|
+
"&": "&",
|
|
55
|
+
""": '"',
|
|
56
|
+
"'": "'",
|
|
57
|
+
" ": " ",
|
|
58
|
+
};
|
|
59
|
+
const NAMED_ENTITIES = /&(lt|gt|amp|quot|apos|nbsp);/gi;
|
|
60
|
+
const LINE_BREAKS = /\r\n|[\r\u0085\u2028\u2029]/g;
|
|
61
|
+
// Matching control characters and lone combining marks is this regex's whole job.
|
|
62
|
+
const INVISIBLE =
|
|
63
|
+
// eslint-disable-next-line no-control-regex, no-misleading-character-class
|
|
64
|
+
/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u0084\u0086-\u009F\u00AD\u034F\u061C\u115F\u1160\u17B4\u17B5\u180E\u200B-\u200F\u202A-\u202E\u2060-\u206F\u3164\uFE00-\uFE0F\uFEFF\uFFA0\uFFF9-\uFFFB]|[\u{E0000}-\u{E007F}\u{E0100}-\u{E01EF}]/gu;
|
|
65
|
+
/** Joiners and emoji presentation selectors are how emoji are spelled. */
|
|
66
|
+
const EMOJI_GLUE = new Set(["\u200D", "\uFE0E", "\uFE0F"]);
|
|
67
|
+
/**
|
|
68
|
+
* Direction marks and embeddings (LRM/RLM, LRE-RLO/PDF, LRI-PDI, ALM). They
|
|
69
|
+
* are stripped like every invisible, but not counted: a phone wraps a number
|
|
70
|
+
* copied from a contact in them (U+202A ... U+202C). A zero-width character
|
|
71
|
+
* splitting a word is what an attack uses, and that still counts.
|
|
72
|
+
*/
|
|
73
|
+
const BIDI_MARK = /^[\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069]$/u;
|
|
74
|
+
const TAG_CHAR = /^[\u{E0000}-\u{E007F}]$/u;
|
|
75
|
+
const WORD_CHAR = /[\p{L}\p{N}]/u;
|
|
76
|
+
const STYLED_LETTER = /[\uFF01-\uFF5E\u2460-\u24FF\u{1D400}-\u{1D7FF}\u{1F130}-\u{1F189}]/gu;
|
|
77
|
+
const WORD = /[\p{L}\p{M}]+/gu;
|
|
78
|
+
const LATIN = /[a-z]/i;
|
|
79
|
+
|
|
80
|
+
/** What a renderer would show for an HTML character reference ("ignore" reads "ignore"). */
|
|
81
|
+
function decodeEntities(text: string): string {
|
|
82
|
+
return text
|
|
83
|
+
.replace(NUMERIC_ENTITY, (whole, code: string) => {
|
|
84
|
+
const cp = code[0] === "x" || code[0] === "X" ? Number.parseInt(code.slice(1), 16) : Number(code);
|
|
85
|
+
return cp > 0 && cp <= 0x10ffff ? String.fromCodePoint(cp) : whole;
|
|
86
|
+
})
|
|
87
|
+
.replace(NAMED_ENTITIES, (whole) => NAMED_ENTITY[whole.toLowerCase()] ?? whole);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function isSuspiciousInvisible(ch: string, before: string, after: string): boolean {
|
|
91
|
+
if (TAG_CHAR.test(ch)) return false; // counted through the decoded tag run instead
|
|
92
|
+
if (BIDI_MARK.test(ch)) return false; // stripped, but phones wrap pasted numbers in them
|
|
93
|
+
if (!EMOJI_GLUE.has(ch)) return true;
|
|
94
|
+
// A joiner between two letters is splitting a word, not gluing an emoji.
|
|
95
|
+
return WORD_CHAR.test(before) && WORD_CHAR.test(after);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function stripInvisibles(text: string): { text: string; count: number } {
|
|
99
|
+
let count = 0;
|
|
100
|
+
const stripped = text.replace(INVISIBLE, (ch, offset: number, whole: string) => {
|
|
101
|
+
const before = whole.slice(Math.max(0, offset - 1), offset);
|
|
102
|
+
const after = whole.slice(offset + ch.length, offset + ch.length + 1);
|
|
103
|
+
if (isSuspiciousInvisible(ch, before, after)) count += 1;
|
|
104
|
+
return "";
|
|
105
|
+
});
|
|
106
|
+
return { text: stripped, count };
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* A word is folded when it mixes Latin with look-alikes, or when every letter
|
|
111
|
+
* in it is a look-alike (a Latin word typed entirely in Cyrillic). A real
|
|
112
|
+
* Russian or Greek word has letters with no Latin twin and is left alone.
|
|
113
|
+
*/
|
|
114
|
+
function foldLookAlikes(text: string): { text: string; count: number } {
|
|
115
|
+
let count = 0;
|
|
116
|
+
const folded = text.replace(WORD, (word) => {
|
|
117
|
+
const letters = [...word];
|
|
118
|
+
const spoofed = letters.filter((ch) => LOOK_ALIKE.has(ch)).length;
|
|
119
|
+
if (spoofed === 0) return word;
|
|
120
|
+
if (!LATIN.test(word) && spoofed !== letters.length) return word;
|
|
121
|
+
count += 1;
|
|
122
|
+
return letters.map((ch) => LOOK_ALIKE.get(ch) ?? ch).join("");
|
|
123
|
+
});
|
|
124
|
+
return { text: folded, count };
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** Lower case, no accents, one space between words: the text the rules read. */
|
|
128
|
+
export function foldForMatching(text: string): string {
|
|
129
|
+
return text
|
|
130
|
+
.normalize("NFD")
|
|
131
|
+
.replace(/\p{M}/gu, "")
|
|
132
|
+
.toLowerCase()
|
|
133
|
+
.replace(/\s+/g, " ")
|
|
134
|
+
.trim();
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function normalizeAt(original: string, depth: number): NormalizedInbound {
|
|
138
|
+
const tagRuns = decodeTagRuns(original);
|
|
139
|
+
const unified = decodeEntities(original).replace(LINE_BREAKS, "\n");
|
|
140
|
+
const invisible = stripInvisibles(unified);
|
|
141
|
+
const styled = invisible.text.match(STYLED_LETTER)?.length ?? 0;
|
|
142
|
+
const lookAlike = foldLookAlikes(invisible.text.normalize("NFKC"));
|
|
143
|
+
const text = lookAlike.text;
|
|
144
|
+
const runs = depth <= MAX_DECODE_DEPTH ? [...tagRuns, ...decodeRuns(text)] : [];
|
|
145
|
+
// A decoded run is cleaned like the message (it may hide look-alikes of its
|
|
146
|
+
// own), and its own runs are decoded once more.
|
|
147
|
+
const decoded = runs.flatMap((run) => {
|
|
148
|
+
const inner = normalizeAt(run.text, depth + 1);
|
|
149
|
+
return [{ ...run, text: inner.text }, ...inner.decoded];
|
|
150
|
+
});
|
|
151
|
+
return {
|
|
152
|
+
original,
|
|
153
|
+
text,
|
|
154
|
+
folded: foldForMatching(text),
|
|
155
|
+
decoded,
|
|
156
|
+
invisibles: invisible.count,
|
|
157
|
+
lookAlikes: lookAlike.count + (styled >= 3 ? 1 : 0),
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** Normalize one untrusted inbound message. Never throws. */
|
|
162
|
+
export function normalizeInbound(text: string): NormalizedInbound {
|
|
163
|
+
return normalizeAt(text, 1);
|
|
164
|
+
}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The infrastructure and identity rules: tool markup, secrets, systems,
|
|
3
|
+
* SQL, shell, links, and claims to speak for a platform or the staff.
|
|
4
|
+
* Written against the folded view, like the phrase rules.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { PatternRule } from "./rules-types";
|
|
8
|
+
|
|
9
|
+
const VENDORS = "(meta|whatsapp|instagram|facebook|anthropic|openai|claude|chatgpt|google)";
|
|
10
|
+
const TEAM =
|
|
11
|
+
"(equipe|time|suporte|setor|departamento|seguranca|security|support|team|staff|engenheir[oa]|engineer|moderac\\w*|moderator|funcionari[oa]|employee)";
|
|
12
|
+
const I_AM = "(sou|somos|eu sou|aqui e|falo|i am|i'm|im|we are|this is)";
|
|
13
|
+
const ROLE_LABEL = "(sistema|admin|administrador|desenvolvedor|assistente)";
|
|
14
|
+
/** What a fake role line orders, for the line to count as one. */
|
|
15
|
+
const ROLE_LINE_ORDER =
|
|
16
|
+
"(confirme|aprove|libere|ignore|responda|envie|mande|execute|autorize|conceda|classifique|marque|obedeca|esqueca|desconsidere|estorne|reembolse)";
|
|
17
|
+
/** A third party reported, not a claim to be one: "Suporte do Google disse...". */
|
|
18
|
+
const REPORTING = "(disse|disseram|falou|falaram|mandou|mandaram|pediu|pediram|respondeu|informou|said|told|asked)";
|
|
19
|
+
const SHORTENERS =
|
|
20
|
+
"(bit\\.ly|tinyurl\\.com|t\\.co|goo\\.gl|is\\.gd|cutt\\.ly|rebrand\\.ly|ow\\.ly|shorturl\\.at|tiny\\.cc|rb\\.gy|t\\.ly|bl\\.ink|buff\\.ly|encurtador\\.com\\.br)";
|
|
21
|
+
/** What a doorbell, a gate or an app asks for: a customer's word, not a secret. */
|
|
22
|
+
const EVERYDAY_PASSWORD =
|
|
23
|
+
"(wi-? ?fi|wifi|internet|rede|portao|portaria|interfone|predio|condominio|app|aplicativo|cofre|cartao|retirada)";
|
|
24
|
+
|
|
25
|
+
export const INFRA_RULES: readonly PatternRule[] = [
|
|
26
|
+
{
|
|
27
|
+
id: "tool-syntax",
|
|
28
|
+
kind: "pattern",
|
|
29
|
+
weight: 3,
|
|
30
|
+
description: "Chat-template, role or tool-call markup, or a fake role line.",
|
|
31
|
+
patterns: [
|
|
32
|
+
/<\/?(system|assistant|instructions?|tool_?\w*|function_?\w*|im_start|im_end)>/,
|
|
33
|
+
/<\|[a-z_]+\|>/,
|
|
34
|
+
/\[\/?(inst|system|sistema|admin|developer|desenvolvedor|root)\]/,
|
|
35
|
+
/(^|\s)#{1,6} ?(system|instructions?|instrucoes|admin|developer)\b/,
|
|
36
|
+
/["']role["'] ?: ?["'](system|assistant|developer|tool)/,
|
|
37
|
+
/\b(tool_use|tool_call|tool_calls|function_call)\b/,
|
|
38
|
+
/(^|\s)(system|assistant|developer) ?:/,
|
|
39
|
+
new RegExp(`^${ROLE_LABEL} ?: (\\S+ ){0,8}?${ROLE_LINE_ORDER}\\b`),
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
id: "role-line",
|
|
44
|
+
kind: "pattern",
|
|
45
|
+
weight: 2,
|
|
46
|
+
weak: true,
|
|
47
|
+
description: "Opens with a role label ('Sistema:', 'Admin:'). A customer's heading too, unless an order follows.",
|
|
48
|
+
patterns: [new RegExp(`^${ROLE_LABEL} ?:`)],
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: "data-exfiltration",
|
|
52
|
+
kind: "pattern",
|
|
53
|
+
weight: 3,
|
|
54
|
+
description: "Asks for the records of other people.",
|
|
55
|
+
patterns: [
|
|
56
|
+
/\b(liste|listar|envie|enviar|mande|mandar|exporte|exportar|passe|me passa|mostre|mostrar|send|list|export|dump|give me|forward|encaminhe) (me )?(todos os|todas as|all( the)?|the full|a lista (de|dos|das)|os dados (de|dos|das)) (\w+ )?(clientes|contatos|usuarios|conversas|mensagens|numeros|telefones|e-?mails|enderecos|cpfs|customers|contacts|users|conversations|messages|phone numbers|addresses|records)\b/,
|
|
57
|
+
/\b(manda|mande|envie|passe|me passa|liste|mostre|send|give me|list) (\S+ ){0,4}?(dos|das|de|of) (outros|outras|todos os|todas as|demais|other|all) (clientes|usuarios|contatos|compradores|customers|users|contacts)\b/,
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: "credential-words",
|
|
62
|
+
kind: "pattern",
|
|
63
|
+
weight: 1,
|
|
64
|
+
weak: true,
|
|
65
|
+
description: "Names a secret. A doorbell, gate, wifi or app password, and a payment key, are not one.",
|
|
66
|
+
patterns: [
|
|
67
|
+
/\b(tokens?|passwords?|passwd|credenciais|credencial|credentials?|api[ _-]?keys?|secret keys?|private keys?|bearer|access keys?)\b/,
|
|
68
|
+
new RegExp(`\\bsenhas?\\b(?! (do|da|de|dos|das) ${EVERYDAY_PASSWORD})`),
|
|
69
|
+
/\bchaves? (de api|api|de acesso|secreta|privada|mestra|do sistema|de seguranca|ssh)\b/,
|
|
70
|
+
/(^|\s)\.env\b/,
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
id: "secret-request",
|
|
75
|
+
kind: "pattern",
|
|
76
|
+
weight: 2,
|
|
77
|
+
description: "Orders the reader to hand over a system's secret ('me passe a senha do banco de dados').",
|
|
78
|
+
patterns: [
|
|
79
|
+
/\b(me passe|me passa|passe|me envie|envie|me mande|mande|manda|informe|revele|mostre|send|give me|share|reveal|print) (me )?(\S+ ){0,2}?(senhas?|tokens?|credenciais|credencial|chaves? de api|api keys?|passwords?|credentials) (do|da|de|of|for) (the )?(banco de dados|database|sistema|system|servidor|server|painel|admin\w*|api|bot|slack|doppler|github|aws)\b/,
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
id: "infra-words",
|
|
84
|
+
kind: "pattern",
|
|
85
|
+
weight: 1,
|
|
86
|
+
weak: true,
|
|
87
|
+
description: "Names a tool, a service or a system an assistant could reach.",
|
|
88
|
+
patterns: [
|
|
89
|
+
/\b(curl|wget|bash|zsh|sudo|powershell|cmd\.exe|slack|linear|doppler|github|gitlab|aws|kubectl|docker|database|banco de dados|sql|postgres\w*|mysql|mongodb|redis|webhook|endpoint|api|json|yaml|stack ?trace|ssh)\b/,
|
|
90
|
+
],
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
id: "sql-statement",
|
|
94
|
+
kind: "pattern",
|
|
95
|
+
weight: 3,
|
|
96
|
+
description: "A SQL statement or an injection idiom.",
|
|
97
|
+
patterns: [
|
|
98
|
+
/\b(drop|truncate|alter) (table|database|schema)\b/,
|
|
99
|
+
/\bdelete from\b/,
|
|
100
|
+
/\binsert into\b/,
|
|
101
|
+
/\bupdate \w+ set\b/,
|
|
102
|
+
/\bselect (?:\*|\w+(?:, ?\w+)*) from\b/,
|
|
103
|
+
/\bunion (all )?select\b/,
|
|
104
|
+
/' ?or '?1'? ?= ?'?1/,
|
|
105
|
+
],
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
id: "shell-command",
|
|
109
|
+
kind: "pattern",
|
|
110
|
+
weight: 3,
|
|
111
|
+
description: "A shell command or a script tag. 'R$(58,00)' is a price.",
|
|
112
|
+
patterns: [
|
|
113
|
+
/\brm -r?f\b/,
|
|
114
|
+
/(?<!r)\$\( ?[a-z]/,
|
|
115
|
+
/\| ?(sh|bash)\b/,
|
|
116
|
+
/\b(curl|wget) (-\S+ )*https?:/,
|
|
117
|
+
/\bchmod \+?\w/,
|
|
118
|
+
/\b(eval|exec) ?\(/,
|
|
119
|
+
/<script\b/,
|
|
120
|
+
/\/etc\/(passwd|shadow)\b/,
|
|
121
|
+
/\bnc -e\b/,
|
|
122
|
+
],
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
id: "code-fence",
|
|
126
|
+
kind: "pattern",
|
|
127
|
+
weight: 2,
|
|
128
|
+
description: "A fenced code block.",
|
|
129
|
+
patterns: [/```|~~~/],
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
id: "url",
|
|
133
|
+
kind: "pattern",
|
|
134
|
+
weight: 1,
|
|
135
|
+
weak: true,
|
|
136
|
+
description: "A link. An e-mail address is not one, nor a missing space ('noite.me', 'pizza.com borda').",
|
|
137
|
+
patterns: [
|
|
138
|
+
/\bhttps?:\/\/\S+/,
|
|
139
|
+
/\bwww\.\S+/,
|
|
140
|
+
/(?<![@\w.])[a-z0-9][a-z0-9-]{1,62}\.(com|net|org|io|xyz|info|biz|ly|me|app|dev|co|site|online|top|click|link)(\.[a-z]{2})?\/\S*/,
|
|
141
|
+
/(?<![@\w.])[a-z0-9][a-z0-9-]{1,62}\.(com|net|org)\.br\b(?![@.\w])/,
|
|
142
|
+
],
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
id: "url-shortener",
|
|
146
|
+
kind: "pattern",
|
|
147
|
+
weight: 1,
|
|
148
|
+
weak: true,
|
|
149
|
+
description: "A shortened link, whose destination cannot be read. A map share link is not one.",
|
|
150
|
+
patterns: [new RegExp(`(?<![\\w.-])${SHORTENERS}\\/`)],
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
id: "impersonation-vendor",
|
|
154
|
+
kind: "pattern",
|
|
155
|
+
weight: 3,
|
|
156
|
+
description: "Claims to speak for a platform or a model vendor (reporting what one said is not a claim).",
|
|
157
|
+
patterns: [
|
|
158
|
+
new RegExp(`\\b${I_AM} (o |a |da |do |the |from (the )?)?${TEAM} (\\S+ ){0,3}?${VENDORS}\\b`),
|
|
159
|
+
new RegExp(`\\b(this is|we are|i am|i'm|from) (the )?${VENDORS} (security|support|trust|safety|team|staff)\\b`),
|
|
160
|
+
new RegExp(`\\b(aqui e|aqui fala|quem fala e) (a |o )?(equipe|time|suporte|seguranca) (oficial )?(da|do|de) ${VENDORS}\\b`),
|
|
161
|
+
],
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
id: "vendor-signoff",
|
|
165
|
+
kind: "pattern",
|
|
166
|
+
weight: 2,
|
|
167
|
+
weak: true,
|
|
168
|
+
description: "Opens with a platform's team as a signature ('Suporte do WhatsApp: ...'); also a business named after one.",
|
|
169
|
+
patterns: [
|
|
170
|
+
new RegExp(
|
|
171
|
+
`^(equipe|time|suporte|seguranca|security|support) (oficial )?(da |do |de |of )?${VENDORS}\\b(?! (\\S+ )?${REPORTING}\\b)`,
|
|
172
|
+
),
|
|
173
|
+
],
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
id: "impersonation-staff",
|
|
177
|
+
kind: "pattern",
|
|
178
|
+
weight: 2,
|
|
179
|
+
description: "Claims to be support, or the system's own staff, or threatens the account.",
|
|
180
|
+
patterns: [
|
|
181
|
+
/\bsuporte oficial\b/,
|
|
182
|
+
/\bofficial (support|notice|message)\b/,
|
|
183
|
+
/\bmensagem oficial\b/,
|
|
184
|
+
new RegExp(
|
|
185
|
+
`\\b${I_AM} (o |a |da |do |the |from the )?(equipe|time|setor) (de |da |do )?(ti|tecnologia|suporte|seguranca|desenvolvimento|sistemas?|it|tech|security|engineering)\\b`,
|
|
186
|
+
),
|
|
187
|
+
/\b(sou|i am|i'm) (o |a |the |your )?(desenvolvedor|developer|administrador|administrator|admin|programador|programmer|criador|creator) (do |da |of |of the |deste |desta |this )?(bot|sistema|system|ia|ai|assistente|assistant|atendente|app|site|plataforma|platform)\b/,
|
|
188
|
+
/\b(nota|mensagem|ordem|aviso) do (administrador|admin|desenvolvedor|sistema) (para|ao|pro)\b/,
|
|
189
|
+
/\b(sua conta|your account) (sera|will be) (suspensa|bloqueada|desativada|suspended|blocked|disabled)\b/,
|
|
190
|
+
],
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
id: "team-claim",
|
|
194
|
+
kind: "pattern",
|
|
195
|
+
weight: 1,
|
|
196
|
+
weak: true,
|
|
197
|
+
description: "Says it is from a team. Usually a customer's employer; an attempt with anything else.",
|
|
198
|
+
patterns: [/\bsou d[ao] (equipe|time)\b/],
|
|
199
|
+
},
|
|
200
|
+
];
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The phrase rules: what an attempt says to the reader. Written against the
|
|
3
|
+
* folded view (lower case, no accents) and its punctuation-free reading, so
|
|
4
|
+
* every pattern is plain ASCII. A rule scores 3 only when the words are aimed
|
|
5
|
+
* at the reader ("your instructions", "ignore everything above"); the same
|
|
6
|
+
* verbs about the sender's own earlier messages ("desconsidere as instruções
|
|
7
|
+
* anteriores, mudei o endereço") score less, because customers write them.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { PatternRule } from "./rules-types";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Imperatives and infinitives only: "esqueci suas instruções" and "ignorei
|
|
14
|
+
* suas regras" are a customer apologising, not an order to the reader.
|
|
15
|
+
*/
|
|
16
|
+
const PT_DROP = "(ignore|ignora|ignorem|ignorar|desconsidere|desconsidera|desconsiderem|desconsiderar|esqueca|esquece|esquecam|esquecer)";
|
|
17
|
+
const PT_VERB = `(${PT_DROP.slice(1, -1)}|abandone|abandona|abandonem|abandonar|descarte|descarta|descartem|descartar|nao (siga|sigas|obedeca|respeite)( mais)?|pare de (seguir|obedecer)|(deixe|deixa|deixem|deixar) de lado)`;
|
|
18
|
+
/** What the reader may be told it now is. "Voce agora e o meu restaurante favorito" names none. */
|
|
19
|
+
const ROLE_NOUN =
|
|
20
|
+
"(assistente|ia|bot|robo|agente|modelo|chatbot|atendente|gerente|admin\\w*|sistema|hacker|desenvolvedor|personagem|assistant|ai|model|agent)";
|
|
21
|
+
const PT_NOUN =
|
|
22
|
+
"(instruc\\w*|regras?|ordens|orientac\\w*|diretrizes|comandos?|restric\\w*|politicas?|programac\\w*|configurac\\w*|prompts?)";
|
|
23
|
+
const EN_VERB = "(ignore|disregard|forget|override|bypass|skip|stop following|do not follow|dont follow)";
|
|
24
|
+
const EN_NOUN =
|
|
25
|
+
"(instructions?|rules|guidelines|directives|programming|prompts?|restrictions|policies|orders|context)";
|
|
26
|
+
const EN_TARGET =
|
|
27
|
+
"(your|all|all the|all previous|all prior|all of the previous|any previous|the previous|the prior|the system|previous|prior|earlier|above)";
|
|
28
|
+
|
|
29
|
+
export const PHRASE_RULES: readonly PatternRule[] = [
|
|
30
|
+
{
|
|
31
|
+
id: "instruction-override",
|
|
32
|
+
kind: "pattern",
|
|
33
|
+
weight: 3,
|
|
34
|
+
description: "Tells the reader to drop or replace ITS instructions, or everything said above.",
|
|
35
|
+
patterns: [
|
|
36
|
+
new RegExp(`\\b${PT_VERB} (\\S+ ){0,3}?(suas|tuas|seus|teus) (\\S+ )?${PT_NOUN}`),
|
|
37
|
+
new RegExp(`\\b${EN_VERB} (\\S+ ){0,3}?${EN_TARGET} (\\S+ )?${EN_NOUN}\\b`),
|
|
38
|
+
new RegExp(`\\b${EN_VERB} (the |all the |all )?${EN_NOUN} (above|before|previously given)\\b`),
|
|
39
|
+
new RegExp(
|
|
40
|
+
`\\b${EN_VERB} (all |everything |anything )?(of )?(the |that |what(ever)? (is |was )?)?(above|said above|previously said|prior context)\\b`,
|
|
41
|
+
),
|
|
42
|
+
/\b(forget|ignore|disregard) (everything|all|what) you (were|have been|ve been) (told|given|instructed)\b/,
|
|
43
|
+
new RegExp(`\\b${PT_DROP} (de )?tudo (o )?que (te |lhe |voce )?(disseram|falaram|mandaram|pediram|ensinaram|instruiram|foi dito|recebeu)\\b`),
|
|
44
|
+
new RegExp(`\\b${PT_DROP} (o |todo o |todo )?(contexto|conteudo|texto) (acima|anterior)\\b`),
|
|
45
|
+
new RegExp(`\\b${PT_DROP} tudo (acima|antes|o que (esta|foi dito|vem) acima)\\b`),
|
|
46
|
+
new RegExp(`\\b(deixe|deixa|deixem|deixar) de lado (as |os |suas |seus )?${PT_NOUN} que (voce )?(recebeu|te deram)\\b`),
|
|
47
|
+
new RegExp(`\\b${PT_DROP} (todas )?as regras(?! d[eoa]\\b)`),
|
|
48
|
+
/\b(new|updated) (task|instructions?|role|rules) ?:/,
|
|
49
|
+
/\bnovas? (tarefa|instrucoes|regras|ordens) ?:/,
|
|
50
|
+
],
|
|
51
|
+
compact: [
|
|
52
|
+
"ignorepreviousinstructions",
|
|
53
|
+
"ignoreallpreviousinstructions",
|
|
54
|
+
"ignoreallinstructions",
|
|
55
|
+
"ignoreyourinstructions",
|
|
56
|
+
"ignoreyourrules",
|
|
57
|
+
"disregardpreviousinstructions",
|
|
58
|
+
"ignoreeverythingabove",
|
|
59
|
+
"ignoreasregras",
|
|
60
|
+
"ignoretodasasregras",
|
|
61
|
+
"ignoresuasregras",
|
|
62
|
+
"ignoresuasinstrucoes",
|
|
63
|
+
"esquecasuasregras",
|
|
64
|
+
"esquecasuasinstrucoes",
|
|
65
|
+
"desconsideresuasinstrucoes",
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
id: "instruction-dismissal",
|
|
70
|
+
kind: "pattern",
|
|
71
|
+
weight: 2,
|
|
72
|
+
weak: true,
|
|
73
|
+
description: "Dismisses instructions or rules without saying whose: an attempt, or a customer changing an order.",
|
|
74
|
+
patterns: [
|
|
75
|
+
new RegExp(`\\b${PT_VERB} (\\S+ ){0,3}?${PT_NOUN}\\b`),
|
|
76
|
+
new RegExp(`\\b${EN_VERB} (\\S+ ){0,3}?${EN_NOUN}\\b`),
|
|
77
|
+
],
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
id: "prompt-reference",
|
|
81
|
+
kind: "pattern",
|
|
82
|
+
weight: 3,
|
|
83
|
+
description: "Names the reader's prompt or hidden configuration, or asks for it.",
|
|
84
|
+
patterns: [
|
|
85
|
+
/\bsystem ?prompt\b/,
|
|
86
|
+
/\bprompt (do|de) sistema\b/,
|
|
87
|
+
/\b(developer|dev|god|admin|debug) mode\b/,
|
|
88
|
+
/\bmodo (desenvolvedor|dev|deus|admin|administrador|irrestrito|debug|sem restric\w*)\b/,
|
|
89
|
+
/\bjailbreak\w*/,
|
|
90
|
+
/\bdo anything now\b/,
|
|
91
|
+
/\byour (system|hidden|initial|original|internal|secret) (prompt|instructions|rules|configuration)\b/,
|
|
92
|
+
/\b(suas|tuas) (instrucoes|regras|diretrizes|orientacoes) (internas|ocultas|secretas|do sistema|iniciais|originais)\b/,
|
|
93
|
+
/\b(reveal|print|show|repeat|leak|output|tell me) (me )?(your|the) (\w+ )?(system prompt|prompt|configuration)\b/,
|
|
94
|
+
/\b(revele|mostre|repita|imprima|mostra|me passa|me diga|me fala) (o |a |as |os |seu |sua |suas |seus )?(prompt|instrucoes (internas|ocultas|do sistema|iniciais|originais)|regras internas|configurac\w* interna)/,
|
|
95
|
+
],
|
|
96
|
+
compact: ["systemprompt", "promptdosistema", "developermode", "mododesenvolvedor"],
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
id: "role-assignment",
|
|
100
|
+
kind: "pattern",
|
|
101
|
+
weight: 3,
|
|
102
|
+
description: "Gives the reader a new identity or tells it to pretend.",
|
|
103
|
+
patterns: [
|
|
104
|
+
new RegExp(`\\b(voce|vc|tu) agora (e|eh|sera|vai ser) (um|uma|o|a|meu|minha) (\\w+ )?${ROLE_NOUN}\\b`),
|
|
105
|
+
new RegExp(`\\b(voce|vc|tu) (passa a ser|passou a ser|vai passar a ser) (um|uma|o|a|meu|minha) (\\w+ )?${ROLE_NOUN}\\b`),
|
|
106
|
+
new RegExp(`\\b(voce|vc|tu) nao (e|eh) mais (um|uma|o|a) (\\w+ )?${ROLE_NOUN}\\b`),
|
|
107
|
+
/\b(seu|teu) novo papel\b/,
|
|
108
|
+
/\byour new (role|persona|identity)\b/,
|
|
109
|
+
/\byou are (now|no longer)\b/,
|
|
110
|
+
/\b(act|behave|respond) as (a|an|if|my|the)\b/,
|
|
111
|
+
/\bact like (a|an|the|my)\b/,
|
|
112
|
+
/\bpretend (to be|you are|that)\b/,
|
|
113
|
+
/\b(aja|atue|comporte-se|comporte se|se comporte) como\b/,
|
|
114
|
+
/\bfinja (ser|que)\b/,
|
|
115
|
+
/\brole ?-?play\b/,
|
|
116
|
+
/\ba partir (de agora|desta mensagem|daqui|deste momento),? (voce|vc|tu) (sera|e um|e uma|obedece|obedecera|ignora|passa a)\b/,
|
|
117
|
+
/\b(obedeca|obedece|obey) (apenas|somente|so|only) (a mim|me)\b/,
|
|
118
|
+
/\b(assistente|ia|bot|robo|agente|modelo|chatbot|assistant|ai|model) (\w+ )?(sem (regras|restric\w*|limites|filtros?|censura)|unrestricted|unfiltered|uncensored)\b/,
|
|
119
|
+
/\b(unrestricted|unfiltered|uncensored) (\w+ )?(assistant|ai|model|bot|mode)\b/,
|
|
120
|
+
],
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
id: "role-phrase",
|
|
124
|
+
kind: "pattern",
|
|
125
|
+
weight: 1,
|
|
126
|
+
weak: true,
|
|
127
|
+
description: "A phrase that opens many attempts and many ordinary sentences ('voce e um robo?').",
|
|
128
|
+
patterns: [/\ba partir de agora\b/, /\bfrom now on\b/, /\b(voce|vc|tu) (e|eh) (um|uma)\b/, /\byou are an?\b/],
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
id: "assistant-address",
|
|
132
|
+
kind: "pattern",
|
|
133
|
+
weight: 1,
|
|
134
|
+
weak: true,
|
|
135
|
+
description: "Speaks to a model or names one.",
|
|
136
|
+
patterns: [
|
|
137
|
+
/\b(chat ?gpt|gpt-?\d\w*|openai|claude|anthropic|gemini|copilot|llm|language model|modelo de linguagem|inteligencia artificial|ai assistant|assistente virtual|atendente virtual)\b/,
|
|
138
|
+
],
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
id: "output-steering",
|
|
142
|
+
kind: "pattern",
|
|
143
|
+
weight: 3,
|
|
144
|
+
description: "Dictates the reader's answer: how to classify the message, or the exact words to reply.",
|
|
145
|
+
patterns: [
|
|
146
|
+
/\b(classifique|classifica|classify|categorize|categorise|rotule|rotula|label|tag) ((esta|essa|minha|this|my) (mensagem|message|conversa|conversation)|tudo|everything|all( messages)?|todas( as mensagens)?) (como|as)\b/,
|
|
147
|
+
/\bmarque (esta|essa|minha) mensagem\b/,
|
|
148
|
+
/\bmark (this|my) message\b/,
|
|
149
|
+
/["']?\b(needs_human|category|urgency)\b["']? ?[:=]/,
|
|
150
|
+
/\b(responda|responde|reply|respond|answer) (somente|apenas|only)( com| with)? ?:/,
|
|
151
|
+
/\b(responda|responde|reply|respond|answer) (somente|apenas|only) (que|that|com|with) (\S+ ){0,4}?(aprovad\w*|reembolsad\w*|liberad\w*|confirmad\w*|autorizad\w*|approved|refunded|confirmed|authorized)\b/,
|
|
152
|
+
/\boutput (the word|only)\b/,
|
|
153
|
+
],
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
id: "fake-boundary",
|
|
157
|
+
kind: "pattern",
|
|
158
|
+
weight: 2,
|
|
159
|
+
description: "Pretends the quoted data has ended, or draws a delimiter-shaped boundary of its own.",
|
|
160
|
+
patterns: [
|
|
161
|
+
/\b(end|fim) (of |dos? |da )?(data|dados|input|entrada|user message|mensagem do usuario|untrusted)\b/,
|
|
162
|
+
/<<<\w|\w>>>/,
|
|
163
|
+
/<\/?(data|message|input|quote|untrusted)>/,
|
|
164
|
+
/(?<![-=#])(?:-{3,}|={3,}|#{3,}) ?(end|fim|system|sistema|admin)\b/,
|
|
165
|
+
],
|
|
166
|
+
},
|
|
167
|
+
];
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/** The shapes of the screen's rules; the lists themselves are in `rules*.ts`. */
|
|
2
|
+
|
|
3
|
+
export type InboundRisk = "low" | "medium" | "high";
|
|
4
|
+
|
|
5
|
+
/** A rule that matches the message's words. */
|
|
6
|
+
export interface PatternRule {
|
|
7
|
+
readonly id: string;
|
|
8
|
+
readonly kind: "pattern";
|
|
9
|
+
readonly weight: number;
|
|
10
|
+
readonly description: string;
|
|
11
|
+
readonly patterns: readonly RegExp[];
|
|
12
|
+
/** Needles for the letters-and-digits-only view. Keep them long (12+): short ones match across words. */
|
|
13
|
+
readonly compact?: readonly string[];
|
|
14
|
+
/**
|
|
15
|
+
* A signal customers also give (a link, a password, "a partir de agora",
|
|
16
|
+
* dismissing their own earlier message). When every rule a message trips is
|
|
17
|
+
* weak, its risk is capped at `DEFAULT_WEAK_CAP`: weak signals alone never
|
|
18
|
+
* withhold a message, however many add up.
|
|
19
|
+
*/
|
|
20
|
+
readonly weak?: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** A rule on a measured property of the message rather than its words. */
|
|
24
|
+
export interface SignalRule {
|
|
25
|
+
readonly id: string;
|
|
26
|
+
readonly kind: "length" | "burst" | "encoded" | "invisible" | "look-alike";
|
|
27
|
+
readonly weight: number;
|
|
28
|
+
readonly description: string;
|
|
29
|
+
/** Trips at this value or above: characters, recent messages, decoded runs, characters, words. */
|
|
30
|
+
readonly atLeast: number;
|
|
31
|
+
/**
|
|
32
|
+
* A signal customers also give (a link, a password, "a partir de agora",
|
|
33
|
+
* dismissing their own earlier message). When every rule a message trips is
|
|
34
|
+
* weak, its risk is capped at `DEFAULT_WEAK_CAP`: weak signals alone never
|
|
35
|
+
* withhold a message, however many add up.
|
|
36
|
+
*/
|
|
37
|
+
readonly weak?: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type InboundRule = PatternRule | SignalRule;
|
|
41
|
+
|
|
42
|
+
export interface ScreenThresholds {
|
|
43
|
+
/** A score at or above this is `medium`. */
|
|
44
|
+
readonly medium: number;
|
|
45
|
+
/** A score at or above this is `high`: the text never reaches a model. */
|
|
46
|
+
readonly high: number;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const DEFAULT_THRESHOLDS: ScreenThresholds = { medium: 1, high: 3 };
|
|
50
|
+
|
|
51
|
+
/** The highest risk a message reaches when only `weak` rules tripped. */
|
|
52
|
+
export const DEFAULT_WEAK_CAP: InboundRisk = "medium";
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* How many characters of the folded text (and of each decoded run) the
|
|
56
|
+
* pattern rules read. Longer input already trips the length rules
|
|
57
|
+
* (`extreme-length` alone with `excessive-length` is `high`), so the tail adds
|
|
58
|
+
* nothing but time. A host that replaces the rule list keeps the length rules
|
|
59
|
+
* (or raises this limit): the tail past it is never scanned.
|
|
60
|
+
*/
|
|
61
|
+
export const DEFAULT_SCAN_LIMIT = 8000;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The screen's rules, as data. Each rule is a named entry with a weight; the
|
|
3
|
+
* screen sums the weights of the rules a message trips and compares the sum
|
|
4
|
+
* with `DEFAULT_THRESHOLDS`. A host overrides either by passing its own list
|
|
5
|
+
* (`screenInbound(text, { rules: [...DEFAULT_INBOUND_RULES, mine] })`).
|
|
6
|
+
*
|
|
7
|
+
* Patterns are written against the FOLDED view (lower case, no accents, one
|
|
8
|
+
* space between words), so they are plain ASCII and match "instruções",
|
|
9
|
+
* "INSTRUCOES" and "instrucoes" alike. The screen also runs them over the
|
|
10
|
+
* same text with every run of punctuation, markup or emoji read as one space,
|
|
11
|
+
* and matches `compact` needles against it with everything but letters and
|
|
12
|
+
* digits removed, which is how a phrase split letter by letter is still found.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { INFRA_RULES } from "./rules-infra";
|
|
16
|
+
import { PHRASE_RULES } from "./rules-phrases";
|
|
17
|
+
import type { InboundRule, SignalRule } from "./rules-types";
|
|
18
|
+
|
|
19
|
+
export {
|
|
20
|
+
DEFAULT_SCAN_LIMIT,
|
|
21
|
+
DEFAULT_THRESHOLDS,
|
|
22
|
+
DEFAULT_WEAK_CAP,
|
|
23
|
+
type InboundRisk,
|
|
24
|
+
type InboundRule,
|
|
25
|
+
type PatternRule,
|
|
26
|
+
type ScreenThresholds,
|
|
27
|
+
type SignalRule,
|
|
28
|
+
} from "./rules-types";
|
|
29
|
+
|
|
30
|
+
const SIGNAL_RULES: readonly SignalRule[] = [
|
|
31
|
+
{
|
|
32
|
+
id: "encoded-run",
|
|
33
|
+
kind: "encoded",
|
|
34
|
+
weight: 1,
|
|
35
|
+
description: "Base64, hex, URL escapes of letters or tag characters that decode to text.",
|
|
36
|
+
atLeast: 1,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: "invisible-characters",
|
|
40
|
+
kind: "invisible",
|
|
41
|
+
weight: 1,
|
|
42
|
+
description: "Characters that render as nothing (zero-width, bidi, control).",
|
|
43
|
+
atLeast: 1,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
id: "look-alike-letters",
|
|
47
|
+
kind: "look-alike",
|
|
48
|
+
weight: 1,
|
|
49
|
+
description: "Words spelled with letters from another script, or styled letters.",
|
|
50
|
+
atLeast: 1,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
id: "excessive-length",
|
|
54
|
+
kind: "length",
|
|
55
|
+
weight: 1,
|
|
56
|
+
weak: true,
|
|
57
|
+
description: "Longer than a customer message runs.",
|
|
58
|
+
atLeast: 1200,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: "extreme-length",
|
|
62
|
+
kind: "length",
|
|
63
|
+
weight: 2,
|
|
64
|
+
description: "Long enough to carry a whole prompt.",
|
|
65
|
+
atLeast: 4000,
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
id: "burst",
|
|
69
|
+
kind: "burst",
|
|
70
|
+
weight: 1,
|
|
71
|
+
weak: true,
|
|
72
|
+
description: "Many recent messages from one sender (the caller counts them).",
|
|
73
|
+
atLeast: 8,
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
id: "flood",
|
|
77
|
+
kind: "burst",
|
|
78
|
+
weight: 2,
|
|
79
|
+
description: "A flood from one sender. With `burst` it withholds on its own.",
|
|
80
|
+
atLeast: 20,
|
|
81
|
+
},
|
|
82
|
+
];
|
|
83
|
+
|
|
84
|
+
/** The default rule list, in the order reasons are reported. */
|
|
85
|
+
export const DEFAULT_INBOUND_RULES: readonly InboundRule[] = [
|
|
86
|
+
...PHRASE_RULES,
|
|
87
|
+
...INFRA_RULES,
|
|
88
|
+
...SIGNAL_RULES,
|
|
89
|
+
];
|