Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

Q2: annotate the two literal-built RegExp sites for semgrep (patterns come only from module literals)

garrytan169ff7d3812e
diff --git a/src/core/link-extraction.ts b/src/core/link-extraction.ts
index eb2863fdb5..df6790da80 100644
--- a/src/core/link-extraction.ts
+++ b/src/core/link-extraction.ts
@@ -1310,7 +1310,7 @@ const coordinated = (between: string) => {
const [lead, ...gaps] = between.split(INLINE_LINK_RE);
return !lead.trim() && gaps.length > 0 && gaps.every(gap => CONNECTOR_RE.test(gap));
};
-const GLOBAL_VERB_RULES = VERB_RULES.map(r => ({ ...r, re: new RegExp(r.re.source, `${r.re.flags.replace('g', '')}g`) }));
+const GLOBAL_VERB_RULES = VERB_RULES.map(r => ({ ...r, re: new RegExp(r.re.source, `${r.re.flags.replace('g', '')}g`) })); // nosemgrep: javascript.lang.security.audit.detect-non-literal-regexp.detect-non-literal-regexp -- recompiles the module's own literal VERB_RULES patterns
interface Attachment { rule: VerbRule | null; suppressed: string[]; otherLink: boolean }
function attachedVerb(context: string, targetSlug?: string, anchor?: number, explain = false, investorPrior: () => boolean = () => false, targetType?: string | null): Attachment | undefined {
const fromAnchor = targetSlug && anchor !== undefined ? context.indexOf(targetSlug, anchor) : -1;
diff --git a/src/core/link-temporal-evidence.ts b/src/core/link-temporal-evidence.ts
index 7f65ec4be1..e7328c3159 100644
--- a/src/core/link-temporal-evidence.ts
+++ b/src/core/link-temporal-evidence.ts
@@ -69,6 +69,7 @@ const NOT_PERFECT = String.raw`(?<!\b(?:has|have|'s|’s)\s+(?:\w+\s+)?)`;
const OWNED = String.raw`(?:(?:her|his|their|my|the)\s+)?(?:time|stint|tenure|role|job|run)\s+`;
/** Employment start cues; `notJob` guards the "became … at/of" and "took … role at" forms (U4). */
+// nosemgrep: javascript.lang.security.audit.detect-non-literal-regexp.detect-non-literal-regexp -- notJob is only '' or the module-level literal U4_NOT_EMPLOYMENT_ROLE, both fixed at load; no caller input reaches the pattern
const employmentStart = (notJob: string) => new RegExp(String.raw`\b(?:(?:re-?)?join(?:ed|s|ing)?(?:\s+${ROLE}(?:at|as))?|(?:was\s+)?hired\s+(?:by|at|as\s+${ROLE}at)|started\s+(?:at|with|working\s+(?:at|for)|(?:a\s+)?new\s+(?:role|job|position)\s+at)|became\s+${notJob}${ROLE}(?:at|of)|promoted\s+to\s+${ROLE}(?:at|of)|signed\s+on\s+(?:at|with)|named\s+${ROLE}(?:at|of)|accepted\s+(?:an?\s+)?(?:offer|role|position|job)\s+(?:at|with|from)|took\s+(?:an?\s+|the\s+)?${notJob}(?:\w+\s+){0,2}?(?:role|job|position)\s+(?:at|with)|came\s+(?:on\s+board|aboard)\s+(?:at|with)|went\s+to\s+work\s+(?:at|for)|returned\s+to)\s*$`, 'i');
const EMPLOYMENT = {