Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
chore(semgrep): justify the two path joins the scan flags (contained storage sibling, regex-filtered readdir entry)
garrytan8fa9c52eb130
diff --git a/src/core/storage/local.ts b/src/core/storage/local.tsindex b309fc75e5..a7cef5614f 100644--- a/src/core/storage/local.ts+++ b/src/core/storage/local.ts@@ -34,6 +34,7 @@ export class LocalStorage implements StorageBackend {async uploadFile(path: string, filePath: string, _mime?: string, sha256?: string): Promise<void> {const full = this.contained(path);mkdirSync(dirname(full), { recursive: true });+ // nosemgrep: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal -- full is contained() under the storage root; the partial is its sibling named from its basename and random hexconst partial = join(dirname(full), `.${basename(full)}.${randomBytes(6).toString('hex')}.partial`);const hash = createHash('sha256');try {diff --git a/src/core/workspace-push.ts b/src/core/workspace-push.tsindex 3808c27505..a8f2815b85 100644--- a/src/core/workspace-push.ts+++ b/src/core/workspace-push.ts@@ -610,6 +610,7 @@ function classifyPushStatusFiles(): Array<PushStatusEntry | 'gone' | 'unreadablereturn legacy ? [legacy] : existsSync(pushStatusPath()) ? ['unreadable'] : [];}return names.map((n) => {+ // nosemgrep: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal -- n is a readdirSync(dir) entry that matched PUSH_STATUS_FILE_REconst entry = parsePushStatusFile(join(dir, n));if (!entry) return 'unreadable';// A record whose workspace no longer exists is a ghost: it can never be