fix: use meta.json worldName for maptool uploads#403
Merged
Conversation
When users zip the contents of a grad_meh export directory directly (meta.json and sat/ at the zip root), the world name was derived from the temp extraction directory's basename, producing names like "ocap-maptool-uploads-1517127726-1777287006640" instead of "stratis". Read worldName from meta.json upfront so the authoritative value is used for the output directory and job ID before the pipeline runs.
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the map tool import handler to read world metadata from a meta.json file instead of deriving the world name from the directory. Feedback highlights a potential visibility issue with the new ReadGradMehMeta function and a critical path traversal vulnerability where the user-provided world name is used without validation.
Prevent path traversal when meta.json's worldName is used to construct the output directory under mapsDir. Restrict to [a-z0-9_-] and reject path separators and traversal segments.
b435c62 to
d7c579f
Compare
Member
Author
|
Addressed gemini-code-assist review:
|
Merging this branch will decrease overall coverage
Coverage by fileChanged files (no unit tests)
Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code. |
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
ocap-maptool-uploads-1517127726-1777287006640instead of the actual world name (e.g.stratis) when users zipped the contents of a grad_meh export directory rather than the directory itself.handler_maptool.goderivedworldNamefrom the basename of the extraction directory viaWorldNameFromDir. Whenmeta.jsonandsat/sit at the zip root,FindGradMehDirreturns the temp extraction dir, whose basename is the temp-dir name. That name was then used to createmapsDir/<worldName>and the job ID before the pipeline'sparse_gradmehstage correctedjob.WorldNamefrommeta.json.meta.jsonupfront in the handler viaReadGradMehMetaand submit the authoritative worldName to the job manager.Test plan
stratis/folder — saved asstratis(regression check)meta.json+sat/at the root — saved asstratis(the bug case)meta.json— returns a clear 400 error