Skip to content

fix: update file path handling in RegexScannerDriver to use POSIX format. This change ensures consistent path representation across different operating systems.#29

Open
NotWrench wants to merge 3 commits into
vercel-labs:mainfrom
NotWrench:main

Conversation

@NotWrench
Copy link
Copy Markdown

@NotWrench NotWrench commented May 5, 2026

On Windows, fast-glob returns paths with backslashes (packages\api\src...). Deepsec stores paths as repo-relative POSIX strings and assertSafeFilePath() rejects \ before reading/writing data//files/.json. The first matcher that touched file records (auth-bypass) hit that and crashed.

What changed

After globbing, paths are normalized with path.replace(/\/g, "/") (or equivalent) before they are stored in the per-pattern cache and used for:

path.join(root, relPath) reads (still correct on Windows),
readFileRecord / writeFileRecord and any code that enforces POSIX filePath invariants.
No behavior change on Unix: paths already use /.

How to verify

From a Windows checkout of a real monorepo:

pnpm deepsec scan --project-id <id> (or equivalent).
Confirm the scan completes past regex matchers that upsert file records (e.g. auth-bypass), with no Invalid filePath: contains backslash error.

Verification

  • pnpm test
  • pnpm test:unit
  • pnpm knip
  • pnpm lint

…mat. This change ensures consistent path representation across different operating systems.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 5, 2026

@NotWrench is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

@NotWrench NotWrench marked this pull request as draft May 5, 2026 03:19
…ded global setup for E2E tests and updated path functions to use POSIX format for consistent behavior across different operating systems.
@NotWrench NotWrench marked this pull request as ready for review May 5, 2026 03:36
Copy link
Copy Markdown

@divyamagrawal06 divyamagrawal06 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reproduced on Windows in another repo: pnpm deepsec scan crashed at missing-auth with Invalid filePath: contains backslash.
This PR’s scanner normalization (glob output \ → /) matches the root cause and should unblock that path.

// "\"), so normalize once here before anything reads or writes records.
const files = rawFiles.map((f) => f.replaceAll("\\", "/"));
globCache.set(key, files);
const posixPaths = files.map((p) => p.replace(/\\/g, "/"));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge conflict resolution left three references to a renamed variable files (now rawFiles), causing a ReferenceError that crashes every scan.

Fix on Vercel

@TKlerx
Copy link
Copy Markdown

TKlerx commented May 7, 2026

Any update on this? Would be nice to have it in main so people (including me) can use this on Windows :)
Sorry if I am being too pushy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants