Skip to content

fix(snapshot): hash storage ids for file paths#315

Open
OnlyYu1996 wants to merge 1 commit into
CortexLM:mainfrom
OnlyYu1996:fix-snapshot-storage-id-traversal
Open

fix(snapshot): hash storage ids for file paths#315
OnlyYu1996 wants to merge 1 commit into
CortexLM:mainfrom
OnlyYu1996:fix-snapshot-storage-id-traversal

Conversation

@OnlyYu1996
Copy link
Copy Markdown

Fixes PlatformNetwork/bounty-challenge#53119.

Snapshot IDs and session IDs were previously interpolated directly into snapshot_meta filenames. Path components in those IDs could therefore influence the filesystem path used by snapshot and revert-history reads/writes.

This PR stores snapshots and revert histories under deterministic SHA-256-derived filenames instead of raw IDs, while still allowing safe legacy filenames to be read/deleted for backward compatibility. IDs containing separators or traversal components never get a legacy fallback path.

Validation:

  • cargo +1.90.0 fmt --package cortex-snapshot --check
  • cargo +1.90.0 test -p cortex-snapshot path_components -- --nocapture
  • cargo +1.90.0 test -p cortex-snapshot
  • git diff --check

Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant