Repository navigation
fix: constrain DAG resolution to configured directories - #2424
Merged
Merged
Conversation
📝 WalkthroughWalkthroughDAG storage now searches deterministic configured directories, constrains candidate resolution within those directories, and rejects traversal or symlink escapes. YAML DAG name extraction supplies the input file’s directory as the search path. ChangesDAG path resolution
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant extractDAGName
participant Storage.GetSpec
participant Storage.locateDAG
participant Filesystem
extractDAGName->>Storage.GetSpec: provide file directory as SearchPaths
Storage.GetSpec->>Storage.locateDAG: resolve DAG name or path
Storage.locateDAG->>Filesystem: validate candidate within search directory
Filesystem-->>Storage.locateDAG: existing path or rejection
Storage.locateDAG-->>Storage.GetSpec: DAG path or ErrDAGNotFound
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
yohamta0
marked this pull request as ready for review
July 25, 2026 02:36
yohamta0
marked this pull request as ready for review
July 25, 2026 02:36
yohamta0
marked this pull request as ready for review
July 25, 2026 02:36
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@internal/cmd/helper.go`:
- Around line 192-194: Resolve name to an absolute path before constructing
dagStoreConfig, then use that resolved value consistently for SearchPaths and
the subsequent GetMetadata call. Update the surrounding helper flow so locateDAG
no longer combines filepath.Dir with a relative multi-segment name, while
preserving existing behavior for absolute inputs.
In `@internal/persis/file/dag/store.go`:
- Around line 1040-1066: The locateDAG method currently discards the resolved
path returned by ResolveExistingPathWithinBase and reconstructs it from
candidatePath. Capture and return that first resolved-path value directly when
resolution succeeds, preserving the existing search and error behavior.
🪄 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: CHILL
Plan: Pro Plus
Run ID: 5ae1dc4b-f410-4a03-aec2-7bf104b8311e
📒 Files selected for processing (3)
internal/cmd/helper.gointernal/persis/file/dag/store.gointernal/persis/file/dag/store_test.go
This was referenced Jul 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Root cause
locateDAGreturned separator-containing paths directly and implicitly searched the process working directory. Callers that invoke the API service in process do not pass through the REST filename-validation middleware, so an untrusted path could reach the filesystem resolver.Resolution is now enforced at the shared storage boundary with lexical and symlink-aware containment. This covers REST, MCP, and other callers consistently while preserving explicitly configured search directories needed by local and distributed execution.
Behavior
Existing DAG files can be resolved through paths such as
team/jobs/report.yamlwhen they are beneath the configured DAG directory. Resolution outside approved roots returns DAG-not-found. DAG listing and creation behavior remain unchanged; this PR makes nested paths safe to resolve without expanding the broader DAG identity model.Testing
make fmtinternal/persis/file/dag,internal/cmd,internal/service/mcp, andinternal/service/frontend/api/v1internal/persis/file/dagandinternal/cmdSummary by cubic
Constrain DAG resolution to configured directories and explicit search paths to prevent escapes, while allowing nested paths under approved roots. Normalize stored
SourceFileto the symlink-resolved file path.fileutil.ResolveExistingPathWithinBaseininternal/persis/file/dag; handle YAML extensions inside the containment check.SearchPaths.internal/cmd).SourceFileto matchEvalSymlinks, and make the relative nested-path start case portable.Written for commit bd0d2e9. Summary will update on new commits.
Summary by CodeRabbit