Skip to content

fix(upload): skip .git, node_modules and secret files before folder upload - #644

Merged
madara88645 merged 2 commits into
mainfrom
fix/upload-skip-ignored-dirs
Oct 21, 2026
Merged

madara88645 merged 2 commits into
mainfrom
fix/upload-skip-ignored-dirs

Conversation

@madara88645

Copy link
Copy Markdown
Owner

What / why

Folder uploads ("Browse Folder") sent every file under the selected directory, .git/ and node_modules/ included. Real projects hit two failures:

  • The backend's normalize_uploaded_filename (app/utils/security.py) rejects the whole upload with HTTP 400 if any path segment is .git, .ssh, .aws, .npmrc, .pypirc or .netrc, or starts with .env. So uploading any folder that contains .git (or a .env.example file) failed.
  • getTotalUploadSize counted node_modules, .git, .venv and similar folders toward the 25 MB client limit, so ordinary JS and Python repos were often rejected as "too large".

This PR changes the frontend only. The backend and its validators are untouched.

How

  • New pure helper explorer/src/utils/uploadFilter.js exports shouldSkipUploadPath(relativePath). It turns backslashes into slashes and checks every segment, including the top folder that webkitRelativePath adds. A file is skipped when:
    • one of its directory segments is in IGNORED_DIRS from analyst/analyzer.py (.git, node_modules, site-packages, venv, env, .venv, __pycache__). The list is mirrored exactly and matched case-sensitively, like the analyzer, so the analysis does not change. _JS_IGNORED_DIRS (dist, build, ...) is not mirrored: it is only used for JS import resolution, and the analyzer still analyzes files in those folders.
    • any segment matches the backend's sensitive-name rule (case-insensitive, like the backend). This also covers a .git file, as in git submodules.
    • the basename looks like a private key (id_rsa, id_dsa, id_ecdsa, id_ed25519, *.pem, *.key), so these key files never leave the browser.
  • ProjectUpload.uploadFiles() applies the filter before the size check and before building FormData.
    • If nothing is left, it shows the existing Upload failed: No analyzable code found… error and does not call the backend.
    • If files were skipped and the upload succeeds, an info toast says Skipped N files (.git, node_modules, .env and similar) — they aren't analyzed.
    • A single .zip upload is sent unchanged, exactly as before.

How verified

  • npx vitest run src/utils/uploadFilter.test.js src/components/ProjectUpload.test.jsx: 33 passed.
    • Helper tests cover nested node_modules, the top-folder prefix, .env.local, case-insensitivity, backslashes, a submodule .git file, a normal src file kept, .gitignore kept, and build//dist/ kept.
    • Component tests check that skipped files are not in FormData, that they don't count toward the size limit, that no fetch happens when everything is skipped, and that no skip toast fires when nothing was skipped.
  • With the old ProjectUpload.jsx put back, the new component tests fail, so they catch the bug.
  • npx eslint on the changed files: clean.
  • Not checked in a running app or browser. The full suite and build run in CI.

Out of scope / follow-ups

  • Folder drag-and-drop very likely doesn't upload folder contents. handleDrop sends e.dataTransfer.files. The WICG Entries API spec treats a dropped directory as one File-kind item ("If it is accessed via getAsFile() a zero-length File is returned"). Its contents are only reachable through webkitGetAsEntry() plus repeated readEntries() calls. Not tested in a browser. Needs its own PR.
  • Zip uploads of real repos still fail on the server. Every zip member goes through normalize_uploaded_filename, so a zip that contains .git/ or .env.example is rejected as "Unsafe zip file detected". The backend also extracts every uploaded .zip, not just a lone one. So a folder that contains a nested fixture zip with such members still fails. Fixing either is a backend change and needs owner approval.
  • The client still doesn't check the backend's 10,000-file cap.

🤖 Generated with Claude Code

madara88645 and others added 2 commits October 21, 2026 09:49
…pload

Folder uploads sent every file under the selected directory. The backend
rejects the whole request when any path segment is .git, .env*, .ssh,
.aws, .npmrc, .pypirc or .netrc, and node_modules/.git/.venv pushed
normal repos over the 25 MB client limit, so most real projects failed.

Filter folder uploads in the browser before the size check and FormData:
- folders in analyst/analyzer.py IGNORED_DIRS (mirrored exactly, so the
  analysis result is unchanged)
- segments normalize_uploaded_filename refuses, matched case-insensitively
- private-key-like files (id_rsa, id_ed25519, *.pem, *.key)

If nothing is left, show the existing empty-graph error without calling
the backend; on success, mention how many files were skipped. A single
.zip upload is sent unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assert the skipped-files toast does not fire when nothing was skipped,
and that a .git file (as in a git submodule) is skipped like the backend
rejects it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
vibegraph Ready Ready Preview Oct 21, 2026 9:04am UTC

This branch was successfully deployed

1 active deployment
Preview — 5f368fef Deployed Oct 21, 2026 by vercel[bot]
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.

1 participant