


























@@ -47,6 +47,33 @@ const MINTLIFY_LANGUAGE_CODES = new Set([
4747"hu",
4848]);
494950+const POISON_TEXT_PATTERNS = [
51+{
52+pattern: /\banalysis\s+to=functions\./iu,
53+message: "Leaked tool-call channel marker.",
54+},
55+{
56+pattern: /\b(?:commentary|final)\s+to=functions\./iu,
57+message: "Leaked tool-call channel marker.",
58+},
59+{
60+pattern: /\bfunctions\.(?:read|write|exec|search|run)\b/iu,
61+message: "Leaked internal tool name.",
62+},
63+{
64+pattern: /\b[A-Za-z_\u3400-\u9fff][\w\u3400-\u9fff-]*_input=\{/u,
65+message: "Leaked tool-call input payload.",
66+},
67+{
68+pattern: /\/home\/runner\/work\//u,
69+message: "Leaked GitHub Actions workspace path.",
70+},
71+{
72+pattern: /彩神马争霸/u,
73+message: "Known spam/gambling text from a poisoned translation.",
74+},
75+];
76+5077function parseArgs(argv) {
5178const roots = [];
5279let jsonOut = "";
@@ -133,8 +160,40 @@ function checkMintlifyMdxStructure(filePath, raw) {
133160}));
134161}
135162163+function lineColumnForIndex(raw, offset) {
164+const prefix = raw.slice(0, offset);
165+const lines = prefix.split(/\r?\n/u);
166+return {
167+line: lines.length,
168+column: lines.at(-1).length + 1,
169+};
170+}
171+172+function checkPoisonText(filePath, raw) {
173+const errors = [];
174+for (const { pattern, message } of POISON_TEXT_PATTERNS) {
175+const match = pattern.exec(raw);
176+if (!match) {
177+continue;
178+}
179+const location = lineColumnForIndex(raw, match.index);
180+errors.push({
181+type: "poison-text",
182+file: filePath,
183+line: location.line,
184+column: location.column,
185+ message,
186+});
187+}
188+return errors;
189+}
190+136191async function checkMdxFile(filePath) {
137192const raw = fs.readFileSync(filePath, "utf8");
193+const poisonErrors = checkPoisonText(filePath, raw);
194+if (poisonErrors.length > 0) {
195+return poisonErrors;
196+}
138197const structureErrors = checkMintlifyMdxStructure(filePath, raw);
139198if (structureErrors.length > 0) {
140199return structureErrors;
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。