fix: default project root to workspace instead of user.dir in LocalFilesystemSpec - #2466
fix: default project root to workspace instead of user.dir in LocalFilesystemSpec#2466waterWang wants to merge 1 commit into
Conversation
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
oss-maintainer
left a comment
There was a problem hiding this comment.
Code Review — PR #2466
fix: default project root to workspace instead of user.dir in LocalFilesystemSpec
Fixes #2065
Summary
Changes the default fallback for LocalFilesystemSpec.toFilesystem() from System.getProperty("user.dir") (JVM working directory) to the agent workspace directory, preventing unintended file system exposure in non-CLI deployments.
Analysis
This is a clean, minimal security fix:
Paths.get(System.getProperty("user.dir"))→workspace- Removes unused
import java.nio.file.Paths - Updates all Javadoc references to match
The change correctly addresses the root cause: in web applications or embedded agents, the JVM working directory is unrelated to the agent's intended workspace and could expose sensitive files (source code, configs) through the read-only lower layer of OverlayFilesystem.
Observations
- ✅ Correct security fix — eliminates unintended file system exposure
- ✅ Minimal diff (4 additions, 5 deletions) — no unnecessary changes
- ✅ Javadoc updated consistently
- ✅ CLI users can still use
.project(Path)explicitly for the old behavior - ❌ CI failed — Spotless formatting in
LocalFilesystemSpec.java. The diff shows a trailing blank line issue. Runmvn spotless:applyto fix.
Required Action
@waterWang Please run mvn spotless:apply in the agentscope-harness module and push the fix.
Verdict
Request Changes — logic is correct and important security fix, but Spotless formatting must be fixed before merge.
Fixes #2065
Problem
LocalFilesystemSpec.toFilesystem()falls back toSystem.getProperty("user.dir")whenprojectis not explicitly set. In non-CLI scenarios (web applications, embedded agents), this exposes the JVM's working directory as the read-only lower layer of the OverlayFilesystem, allowing the agent to read source code, config files, and other sensitive files it should not have access to.Root cause
Paths.get(System.getProperty("user.dir"))intoFilesystem()— the JVM working directory is unrelated to the agent's intended workspace in non-CLI deployments.Fix
effectiveProjecttoworkspace(the agent workspace root, same as the upper layer) instead ofSystem.getProperty("user.dir")whenprojectis nullimport java.nio.file.PathsCLI users who need their project directory as the lower layer should continue to call
.project(Path)explicitly.