Skip to content

Harden asset sheet crop output paths#9

Open
lzh886 wants to merge 2 commits into
CodingFeng101:mainfrom
lzh886:main
Open

Harden asset sheet crop output paths#9
lzh886 wants to merge 2 commits into
CodingFeng101:mainfrom
lzh886:main

Conversation

@lzh886

@lzh886 lzh886 commented Jun 23, 2026

Copy link
Copy Markdown

No description provided.

Copilot AI review requested due to automatic review settings June 23, 2026 11:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens the slice_asset_sheet.py utility by validating crop IDs and centralizing output-path construction to reduce the risk of writing cropped PNGs outside the intended output directory.

Changes:

  • Add SAFE_ID validation and a safe_output_path() helper to constrain output filenames.
  • Route crop saving through safe_output_path() instead of directly interpolating item["id"] into the path.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +17 to +21
output_dir = output_dir.resolve()
path = (output_dir / f"{item_id}.png").resolve()
if output_dir != path.parent and output_dir not in path.parents:
raise ValueError(f"output path escapes output_dir: {item_id!r}")
return path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants