Skip to content

fix(transient): scope bruno- lookup to transient base, not full path - #8273

Merged
sid-bruno merged 1 commit into
usebruno:mainfrom
chirag-bruno:fix/transient-path-username-collision
Jun 18, 2026
Merged

sid-bruno merged 1 commit into
usebruno:mainfrom
chirag-bruno:fix/transient-path-username-collision

Conversation

@chirag-bruno

@chirag-bruno chirag-bruno commented Jun 15, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

JIRA

findCollectionPathByItemPath scanned every segment of the file path for a bruno- prefix to find the transient collection directory. For users whose username starts with bruno- (e.g. bruno-alice), the home-directory segment matched first and the function tried to read metadata.json from the wrong directory.

Scope the lookup to the first path segment under the transient base (<userData>/tmp/transient), which by construction is the actual transient collection directory. No user-controlled path component above the base can collide.

Test plan

  • On a machine where the OS username starts with `bruno-`, create a transient/scratch request and confirm it opens correctly.
  • Regular (non-transient) collections still resolve via the existing watcher-paths fallback.

Summary by CodeRabbit

  • Bug Fixes
    • Improved transient collection path resolution logic to more reliably identify and process collection directories, including better handling of edge cases.

@coderabbitai

coderabbitai Bot commented Jun 15, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

In findCollectionPathByItemPath, the transient directory name derivation is changed from splitting filePath and finding the first segment prefixed with bruno- to computing the relative path from transientBase to filePath and taking its first segment. A null guard is added when derivation fails.

Changes

Transient Path Detection Fix

Layer / File(s) Summary
Transient dir name extraction via path.relative
packages/bruno-electron/src/ipc/collection.js
findCollectionPathByItemPath now uses path.relative(transientBase, filePath).split(...)[0] to extract the transient subdirectory name, returning null when derivation fails, and constructs transientDirPath from transientBase + that segment instead of scanning for a bruno- prefixed segment in the full filePath.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

Possibly related PRs

  • usebruno/bruno#7184: Directly modifies the same findCollectionPathByItemPath function and transient path logic in packages/bruno-electron/src/ipc/collection.js, relocating the transient base to app data and updating related path derivation.

Suggested reviewers

  • helloanoop
  • lohit-bruno
  • naman-bruno

Poem

A bruno- prefix, once the guide,
Now path.relative steers the ride. 🗺️
First segment taken, clean and right,
null returned when paths aren't tight.
No more string-scan through the dark —
transientBase finds its mark! ✅

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: fixing the scope of bruno- prefix lookup to transient base instead of the full path, which matches the core bug fix in the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/bruno-electron/src/ipc/collection.js`:
- Around line 126-131: The transient directory name extraction in the
isTransientPath block is vulnerable to path traversal because the validation
only blocks empty strings but not path traversal sequences like `..` or `.`.
After extracting transientDirName via the split operation, add validation to
ensure it does not equal `..` or `.` and optionally verify that the computed
transientDirPath is actually a direct child of transientBase by checking that
path.relative(transientBase, transientDirPath) does not contain path separators,
preventing directory escape attacks.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6b96ba3c-2c8d-443f-9aeb-5b9d3ebcb3b1

📥 Commits

Reviewing files that changed from the base of the PR and between b73bf9d and abd2503.

📒 Files selected for processing (1)
  • packages/bruno-electron/src/ipc/collection.js

The previous logic scanned every segment of the file path for a 'bruno-'
prefix, which incorrectly matched usernames like 'bruno-alice' in the
user's home directory. Scope the lookup to the first segment under the
transient base so only the actual transient collection directory is
matched.
@chirag-bruno
chirag-bruno force-pushed the fix/transient-path-username-collision branch from abd2503 to a421351 Compare June 17, 2026 09:45
@sid-bruno
sid-bruno merged commit 5345cb7 into usebruno:main Jun 18, 2026
18 of 19 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Jun 26, 2026
2 of 5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants