Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
chore(sync): justify the isPathSafe containment join for semgrep (it is the guard)
garrytan432e058e30fc
diff --git a/src/core/sync-git.ts b/src/core/sync-git.tsindex d038e0ea03..3ef268d2cf 100644--- a/src/core/sync-git.ts+++ b/src/core/sync-git.ts@@ -627,6 +627,7 @@ export function isWithinRoot(*/export function isPathSafe(filePath: string, gitRoot: string): boolean {try {+ // nosemgrep: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal -- this is the containment guard: join normalizes the realpath'd parent plus basename, and isWithinRoot below rejects any result outside gitRootconst real = lstatSync(filePath).isSymbolicLink() ? realpathSync(filePath) : join(realpathSync(dirname(filePath)), basename(filePath));return isWithinRoot(real, realpathSync(gitRoot));} catch {