mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 02:54:31 +00:00
test(perf): reduce guardrail and media test overhead
This commit is contained in:
@@ -10,6 +10,8 @@ type QuoteScanState = {
|
||||
quote: QuoteChar | null;
|
||||
escaped: boolean;
|
||||
};
|
||||
const WEAK_RANDOM_SAME_LINE_PATTERN =
|
||||
/(?:Date\.now[^\r\n]*Math\.random|Math\.random[^\r\n]*Date\.now)/u;
|
||||
|
||||
function shouldSkip(relativePath: string): boolean {
|
||||
return shouldSkipGuardrailRuntimeSource(relativePath);
|
||||
@@ -223,15 +225,8 @@ describe("temp path guard", () => {
|
||||
if (hasDynamicTmpdirJoin(file.source)) {
|
||||
offenders.push(relativePath);
|
||||
}
|
||||
if (file.source.includes("Date.now") && file.source.includes("Math.random")) {
|
||||
const lines = file.source.split(/\r?\n/);
|
||||
for (let idx = 0; idx < lines.length; idx += 1) {
|
||||
const line = lines[idx] ?? "";
|
||||
if (!line.includes("Date.now") || !line.includes("Math.random")) {
|
||||
continue;
|
||||
}
|
||||
weakRandomMatches.push(`${relativePath}:${idx + 1}`);
|
||||
}
|
||||
if (WEAK_RANDOM_SAME_LINE_PATTERN.test(file.source)) {
|
||||
weakRandomMatches.push(relativePath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user