fix(validate): keep asset paths relative when rewriting a scenario - #229
Merged
Merged
Conversation
LeadcodeDev
force-pushed
the
fix/geometry-transform-lengths
branch
from
September 21, 2026 23:39
e52dc82 to
f478e84
Compare
LeadcodeDev
force-pushed
the
fix/validate-relative-paths
branch
from
September 21, 2026 23:39
95e7b59 to
1ac44d6
Compare
53 tasks
LeadcodeDev
force-pushed
the
fix/geometry-transform-lengths
branch
from
September 22, 2026 06:09
9f00928 to
6753586
Compare
LeadcodeDev
force-pushed
the
fix/validate-relative-paths
branch
from
September 22, 2026 06:09
bef57d4 to
b62a1cc
Compare
LeadcodeDev
force-pushed
the
fix/geometry-transform-lengths
branch
from
September 22, 2026 08:33
6753586 to
de249ff
Compare
LeadcodeDev
force-pushed
the
fix/validate-relative-paths
branch
from
September 22, 2026 08:33
b62a1cc to
d585af3
Compare
LeadcodeDev
force-pushed
the
fix/geometry-transform-lengths
branch
from
September 22, 2026 08:43
de249ff to
59ba406
Compare
LeadcodeDev
force-pushed
the
fix/validate-relative-paths
branch
from
September 22, 2026 08:43
d585af3 to
4984fbc
Compare
LeadcodeDev
changed the base branch from
fix/geometry-transform-lengths
to
chantier/audit-2026-09
September 22, 2026 08:52
LeadcodeDev
force-pushed
the
fix/validate-relative-paths
branch
from
September 22, 2026 08:58
4984fbc to
5c96bc8
Compare
`loaded.raw` is captured AFTER `rustmotion::assets::rebase_relative_paths(&mut json_value, dir)` runs (crates/rustmotion/src/cli/commands/validation.rs:194-196), which rewrites every `src`/`track` string that names an existing file next to the scenario into a canonicalized ABSOLUTE path (crates/rustmotion/src/assets.rs:62-78). `refuse_fix` (validate.rs:81-109) only guards HTML, `config`/`$`, `include`, and `for-each`/`use` — nothing stops this. So `rustmotion validate --fix scene.json` on a scenario containing `"src": "assets/logo.png"` silently overwrites the source with `"src": "/Users/alice/proj/assets/logo.png"`, which no longer resolves on any other machine or in CI, and pollutes the diff with paths the author never typed. This is the same class of unfaithful write-back that `FixRefusal` exists to prevent. Secondary hazard from the same line: `rustmotion-studio` enables serde_json's `preserve_order` (crates/rustmotion-studio/Cargo.toml:21) while `crates/rustmotion/Cargo.toml:29` does not, so under resolver-2 feature unification a workspace build preserves key order but a standalone `cargo install rustmotion` build alphabetises every object in the rewritten file. Refs #220
LeadcodeDev
force-pushed
the
fix/validate-relative-paths
branch
from
September 22, 2026 09:04
5c96bc8 to
b52ca6c
Compare
LeadcodeDev
added a commit
that referenced
this pull request
Sep 22, 2026
) `loaded.raw` is captured AFTER `rustmotion::assets::rebase_relative_paths(&mut json_value, dir)` runs (crates/rustmotion/src/cli/commands/validation.rs:194-196), which rewrites every `src`/`track` string that names an existing file next to the scenario into a canonicalized ABSOLUTE path (crates/rustmotion/src/assets.rs:62-78). `refuse_fix` (validate.rs:81-109) only guards HTML, `config`/`$`, `include`, and `for-each`/`use` — nothing stops this. So `rustmotion validate --fix scene.json` on a scenario containing `"src": "assets/logo.png"` silently overwrites the source with `"src": "/Users/alice/proj/assets/logo.png"`, which no longer resolves on any other machine or in CI, and pollutes the diff with paths the author never typed. This is the same class of unfaithful write-back that `FixRefusal` exists to prevent. Secondary hazard from the same line: `rustmotion-studio` enables serde_json's `preserve_order` (crates/rustmotion-studio/Cargo.toml:21) while `crates/rustmotion/Cargo.toml:29` does not, so under resolver-2 feature unification a workspace build preserves key order but a standalone `cargo install rustmotion` build alphabetises every object in the rewritten file. Refs #220
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.
Severity Medium, category correctness. Location:
crates/rustmotion/src/cli/commands/validate.rs:146Impact
loaded.rawis captured AFTERrustmotion::assets::rebase_relative_paths(&mut json_value, dir)runs (crates/rustmotion/src/cli/commands/validation.rs:194-196), which rewrites everysrc/trackstring that names an existing file next to the scenario into a canonicalized ABSOLUTE path (crates/rustmotion/src/assets.rs:62-78).refuse_fix(validate.rs:81-109) only guards HTML,config/$,include, andfor-each/use— nothing stops this. Sorustmotion validate --fix scene.jsonon a scenario containing"src": "assets/logo.png"silently overwrites the source with"src": "/Users/alice/proj/assets/logo.png", which no longer resolves on any other machine or in CI, and pollutes the diff with paths the author never typed. This is the same class of unfaithful write-back thatFixRefusalexists to prevent. Secondary hazard from the same line:rustmotion-studioenables serde_json'spreserve_order(crates/rustmotion-studio/Cargo.toml:21) whilecrates/rustmotion/Cargo.toml:29does not, so under resolver-2 feature unification a workspace build preserves key order but a standalonecargo install rustmotionbuild alphabetises every object in the rewritten file.Fix
Keep an un-rebased copy of the post-expansion JSON in
LoadedScenario(e.g.raw_unrebased) and serialise that in--fix; or re-read the file from disk, applyapply_fixesto those bytes, and write that back. Either way, also pinserde_jsonwithfeatures = ["preserve_order"]in therustmotioncrate so--fixnever reorders keys.Evidence the audit read
Part of the September 2026 audit remediation chantier. Refs #220 (RM-16).