Repository navigation
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueCodeRabbit Verify
|
Reviewer's GuideThe PR prevents Unix glob results from being rewritten into different filesystem paths by making Sequence diagram for platform-aware glob result handlingsequenceDiagram
participant Caller
participant GlobExpansion
participant CapabilityWalk
participant strip_base
participant JinjaAdapter
Caller->>GlobExpansion: glob_paths(pattern, base)
GlobExpansion->>CapabilityWalk: process_glob_entry()
CapabilityWalk-->>GlobExpansion: validated matched path
GlobExpansion->>strip_base: strip_base(base, path)
alt Unix
strip_base-->>GlobExpansion: exact matched spelling
else Windows
strip_base-->>GlobExpansion: path with / separators
end
GlobExpansion-->>Caller: glob result
Caller->>JinjaAdapter: glob()
JinjaAdapter-->>Caller: accept safe path or InvalidOperation for backslash
Flow diagram for preserving Unix backslash filenamesflowchart TD
A[Matched glob entry] --> B[Capability metadata validation]
B --> C{Platform}
C -->|Unix| D[strip_base returns exact spelling]
C -->|Windows| E[strip_base replaces backslash with /]
D --> F{Jinja glob adapter?}
E --> F
F -->|Unix backslash filename| G[Reject with InvalidOperation]
F -->|Portable shell-safe path| H[Expose to template]
D --> I[Direct glob_paths caller receives matched filename]
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
@coderabbitai please assess the implementation in this PR for completeness and correctness against the original issue: |
|
Tip For best results, initiate chat on the files or code changes. Analysis chain
Acceptance-criteria assessment
Correctness and regression coverage
Verification and remaining actionI inspected CI results for the exact reviewed revision. Linux CI reports 4,950 tests passed, with seven skipped. The focused regressions all passed. Doctests and Windows build/test checks also passed. Formatting, lint, typecheck, Markdown, diagram validation, and documentation coverage passed; documentation coverage is 98.23%. I did not run repository code in the inspection sandbox. Resolve the CodeScene duplication failure before declaring all gates complete. The check identifies Keep the security claim scoped to representation preservation. The You are interacting with an AI system. |
Cover the reported defect where strip_base rewrote literal Unix backslashes in matched filenames into directory separators. The three direct-query cases fail before the fix: a backslash filename beside a directory-shaped decoy, a backslash-spelled '..' component, and an absolute match with no injected base. The Jinja adapter and manifest-loading cases prove that a preserved backslash is rejected as shell-sensitive rather than accepted under a different identity. Co-Authored-By: Claude Code <noreply@anthropic.com>
strip_base rewrote every backslash in a matched path to '/'. On Unix a backslash is an ordinary filename character, so the returned string no longer named the file the capability metadata check had validated, and a name such as `part\..\other.txt` became the parent-directory traversal `part/../other.txt`. Split the normalisation on the same cfg(unix) boundary as normalize.rs: non-Unix targets keep the portable '/' rendering, while Unix returns the checked spelling unchanged. The Jinja adapter's unchanged shell-inert allowlist now rejects such a filename instead of accepting the rewritten path, and direct Rust callers receive the exact matched name. Update the design, developer, and user documentation to state the platform-aware separator contract and the filename identity guarantee. Co-Authored-By: Claude Code <noreply@anthropic.com>
The module-size lint caps a Rust source file at 400 lines. Documenting the platform-aware separator contract pushed glob/mod.rs to 405, so relocate strip_base beside the pattern-side separator normalisation it mirrors. Both files are now well below the cap, and the matched-path and pattern rules stay together under one cfg(unix) boundary. No behaviour change: the focused glob suites pass unchanged. Co-Authored-By: Claude Code <noreply@anthropic.com>
The literal-backslash mixed-set case repeated the body of the existing shell-punctuation case verbatim apart from the fixture name, which CodeScene scored as code duplication and reported as a failed advisory gate on the pull request (10.00 -> 9.39). Both cases are the same contract, so they become rows of one rstest table keyed by the unsafe filename. Coverage is unchanged: the expansion still fails as a whole for shell punctuation and for a preserved literal backslash. Co-Authored-By: Claude Code <noreply@anthropic.com>
425f47f to
9351102
Compare
Summary
strip_baserebased every matched glob path with an unconditionalreplace('\\', "/"). On Unix a backslash is an ordinary filename character,not a separator, so the returned string could name a different file from the
one the capability metadata check had just validated. A name such as
part\..\other.txtwas rewritten into the parent-directory traversalpart/../other.txt, which the checked filesystem path never contained.Changes
cfg(unix), mirroring the platform split alreadyused for pattern normalization in
normalize.rs. Windows still renders\as
/for the portable spelling callers expect; Unix returns the exactspelling the walk validated.
literal-prefix capability scope, and the Jinja adapter's shell-inert
allowlist are unchanged. A Unix backslash filename still reaches the
template adapter and is rejected there, rather than being rewritten into an
accepted path; direct
glob_pathscallers stay responsible for quoting.strip_baseintonormalize.rsso both sides of the separator policylive together and
glob/mod.rsstays inside the 400-line module cap.glob_pathsAPI(literal backslash filename, injected traversal, absolute match), the Jinja
adapter (rejection of representative shell-sensitive names, including
backslash forms), and manifest loading (preserve, then reject).
and user guides.
Closes #990
Verification
All deterministic gates pass on
269a77bcb:make check-fmt,make lint(cargo doc, clippy, Whitaker, ruff, pylint, df12 lints, ambrleaks, yamllint,
actionlint),
make typecheck,make doc-coverage(98.23%),make test(4950 nextest cases plus doctests),
make markdownlint, andmake nixie.coderabbit review --agenton the same revision returned no findings acrossthe ten changed files.
References
🤖 Generated with Claude Code
Summary by Sourcery
Preserve Unix backslashes in glob results while maintaining platform-appropriate normalization and shell-safety checks.
Bug Fixes:
Enhancements:
Documentation:
Tests: