fix: constrain analysis interpreter discovery to trusted roots#59
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
Cache: Disabled due to Reviews > Disable Cache setting Disabled knowledge base sources:
📝 WalkthroughSummary by CodeRabbit
Walkthrough실행 파일 인접 경로만 런타임 검색 대상으로 제한하고, 분석 엔진 파이썬 후보를 Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
시
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/desktop/src-tauri/src/main.rs`:
- Around line 272-275: Before calling Command::new in run_analysis_engine,
detect the sentinel program string "__bandscope_missing_analysis_python__" and
avoid spawning it to prevent PATH lookup/exec of a malicious binary;
specifically, locate where Command::new(...) is invoked (the tuple with
"__bandscope_missing_analysis_python__") and add a guard: if the program string
== "__bandscope_missing_analysis_python__" then skip spawn/return an appropriate
error/result instead of calling Command::new or spawn.
🪄 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: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 7e24540d-e3b4-445a-82df-e72b6f5394c5
📒 Files selected for processing (1)
apps/desktop/src-tauri/src/main.rs
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai resolve |
✅ Actions performedComments resolved and changes approved. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/desktop/src-tauri/src/main.rs`:
- Around line 273-275: Extract the magic string
"__bandscope_missing_analysis_python__" into a single constant (e.g., const
MISSING_ANALYSIS_PYTHON: &str = "__bandscope_missing_analysis_python__") and
replace the hardcoded occurrences (the
"__bandscope_missing_analysis_python__".into() used alongside
std::env::current_dir() and the other occurrence around lines 484-485) with that
constant converted as needed (e.g., .into() or
PathBuf::from(MISSING_ANALYSIS_PYTHON) where appropriate); ensure all
comparisons/usages reference the new MISSING_ANALYSIS_PYTHON constant so the
sentinel is maintained from one source.
🪄 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: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 28170648-2780-4a29-a42e-c71c1bee8169
📒 Files selected for processing (1)
apps/desktop/src-tauri/src/main.rs
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Stale review — HEAD 0688725 already implements all requested changes: MISSING_ANALYSIS_PYTHON constant at line 35, used at line 275, guard at line 485
Motivation
current_exeandcurrent_dir, which allowed local binary planting (untrusted, writable directories could supply a maliciousanalysis-engine/.venv/bin/python).uvfromPATH, which is unpinned and increases attack surface.uvfallback to reduce arbitrary code execution risk.Description
runtime_search_roots()to only include the executable parent and packaged resource locations instead of walkingcurrent_dirancestors. (apps/desktop/src-tauri/src/main.rs)exists()tois_file()so only regular files are accepted as interpreters. (analysis_command)"uv"PATH fallback; when no trusted interpreter is found the function now returns a sentinel program and empty args so the existing spawn/error handling reports engine-unavailable instead of executing arbitrary PATH binaries.PATH.Testing
cargo fmt -- --check, which succeeded.cargo test/cargo buildunder CI-like environment, but network access tocrates.iois blocked (CONNECT tunnel 403) so tests/build that fetch dependencies could not complete.Codex Task
📝 Walkthrough
개요
main.rs파일의 런타임 검색 경로 및 분석 엔진 위치 지정 로직을 수정했습니다. 검색 범위를 좁혔고 폴백 동작을 단순화했습니다.변경 사항
apps/desktop/src-tauri/src/main.rsruntime_search_roots함수: 실행 파일 부모의 모든 상위 경로 반복 제거, 부모 디렉토리와 관련 리소스 경로만 추가.analysis_command함수: 파이썬 분석 엔진 탐색 시 존재 확인을is_file()확인으로 변경. 폴백 경로에서 복잡한 "uv" 실행 명령을"__bandscope_missing_analysis_python__"자리 표시자와 빈 인수를 사용하는 최소 폴백으로 대체.예상 코드 리뷰 노력
🎯 2 (Simple) | ⏱️ ~12분
시