[PR #2177] [MERGED] Validate persona import image bytes #5456

Closed
opened 2026-10-22 04:16:29 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/2177
Author: @Promansis
Created: 6/4/2026
Status: ✅ Merged
Merged: 6/4/2026
Merged by: @Promansis

Base: refactor ← Head: fix/issue-2173-verify-persona-image-bytes


📝 Commits (3)

  • c412486 Validate persona import image bytes
  • be3fd78 Allow SVG media file copies
  • 5c0fcb3 Use valid avatar bytes in duplicate test

📊 Changes

8 files changed (+204 additions, -55 deletions)

View changed files

📝 src-tauri/src/commands/storage/avatars.rs (+1 -1)
📝 src-tauri/src/commands/storage/characters.rs (+9 -3)
📝 src-tauri/src/commands/storage/imports/bulk_imports.rs (+26 -7)
📝 src-tauri/src/commands/storage/imports/marinara_assets.rs (+3 -1)
📝 src-tauri/src/commands/storage/imports/marinara_tests.rs (+7 -14)
📝 src-tauri/src/commands/storage/imports/service_tests.rs (+11 -3)
📝 src-tauri/src/commands/storage/media_uploads.rs (+135 -1)
📝 src-tauri/src/commands/storage/sprites.rs (+12 -25)

📄 Description

Linked issue

Closes #2173

Why this change

  • Persona image upload/import paths could persist decoded or copied bytes based on MIME/header or extension alone, allowing non-image bytes to be stored under managed image paths.

What changed

  • Added shared Rust storage validation for decoded/copied image bytes before managed image writes.
  • Reused the validated decoder for sprite upload/import payloads.
  • Skipped malformed optional imported sprites instead of corrupting storage.
  • Updated affected Rust fixtures to use real tiny PNG bytes where tests expect successful image imports.

Refactor impact

Primary owner:

Tauri/Rust storage, imports, and catalog media assets.

Impact areas reviewed:

  • Persona/character avatar upload helpers in media_uploads.rs
  • Sprite upload and native import restoration paths
  • Bulk persona avatar import fixtures and rollback coverage

Boundary notes:

Rust storage/import boundary only. No React UI, engine, shared API wrapper, or remote runtime routing changes.

Pressure points touched:

Import modules and managed media helpers only; no src-tauri/src/lib.rs command registration changes.

Validation

  • Matching validation command passes locally (for example pnpm typecheck, pnpm build, pnpm check:architecture, pnpm check:docs, or full pnpm check when warranted)
  • Full pnpm check passes before PR push/handoff
  • Human/manual validation completed by contributor or reviewer

Manual verification notes

  • cargo check --manifest-path src-tauri/Cargo.toml
  • cargo test --manifest-path src-tauri/Cargo.toml decode_image_payload_rejects_declared_image_with_non_image_bytes
  • cargo test --manifest-path src-tauri/Cargo.toml persist_image_file_copy_rejects_extension_with_non_image_bytes
  • cargo test --manifest-path src-tauri/Cargo.toml native_marinara_character_import_skips_malformed_optional_sprite
  • cargo test --manifest-path src-tauri/Cargo.toml bulk_upload_reports_partial_failures_and_returns_refreshed_list
  • cargo test --manifest-path src-tauri/Cargo.toml import_st_character_rolls_back_character_and_avatar_when_embedded_lorebook_fails
  • cargo test --manifest-path src-tauri/Cargo.toml import_persona_avatar_file_rolls_back_avatar_when_persona_write_fails

Feature Discoverability

Check exactly one:

  • Updated src/features/shell/discovery/ because this PR adds or materially changes a user-discoverable feature, workflow, setting, mode, panel, import path, agent, media capability, or advanced tool.
  • N/A because this PR is only a bugfix, refactor, test, docs, internal wiring, visual polish, copy edit, or compatibility fix and does not add a new thing users need to find.

Reason:

Bugfix for existing persona/image import validation behavior.

Docs and release impact

  • No docs changes needed
  • Updated README.md
  • Updated CONTRIBUTING.md
  • Updated docs/developer/
  • Updated repo skills or AGENTS.md
  • Confirmed this PR does not restore old staging/package-workspace/release claims

UI evidence

N/A - Rust storage/import validation only.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/2177 **Author:** [@Promansis](https://github.com/Promansis) **Created:** 6/4/2026 **Status:** ✅ Merged **Merged:** 6/4/2026 **Merged by:** [@Promansis](https://github.com/Promansis) **Base:** `refactor` ← **Head:** `fix/issue-2173-verify-persona-image-bytes` --- ### 📝 Commits (3) - [`c412486`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c412486108fe30a26f1b73f1e9ea507415fe52f8) Validate persona import image bytes - [`be3fd78`](https://github.com/Pasta-Devs/Marinara-Engine/commit/be3fd782c9b099424ab2c875690977b949c85de0) Allow SVG media file copies - [`5c0fcb3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5c0fcb3dc7a3226b9830f222ab3a93d240fc9958) Use valid avatar bytes in duplicate test ### 📊 Changes **8 files changed** (+204 additions, -55 deletions) <details> <summary>View changed files</summary> 📝 `src-tauri/src/commands/storage/avatars.rs` (+1 -1) 📝 `src-tauri/src/commands/storage/characters.rs` (+9 -3) 📝 `src-tauri/src/commands/storage/imports/bulk_imports.rs` (+26 -7) 📝 `src-tauri/src/commands/storage/imports/marinara_assets.rs` (+3 -1) 📝 `src-tauri/src/commands/storage/imports/marinara_tests.rs` (+7 -14) 📝 `src-tauri/src/commands/storage/imports/service_tests.rs` (+11 -3) 📝 `src-tauri/src/commands/storage/media_uploads.rs` (+135 -1) 📝 `src-tauri/src/commands/storage/sprites.rs` (+12 -25) </details> ### 📄 Description ## Linked issue Closes #2173 ## Why this change - Persona image upload/import paths could persist decoded or copied bytes based on MIME/header or extension alone, allowing non-image bytes to be stored under managed image paths. ## What changed - Added shared Rust storage validation for decoded/copied image bytes before managed image writes. - Reused the validated decoder for sprite upload/import payloads. - Skipped malformed optional imported sprites instead of corrupting storage. - Updated affected Rust fixtures to use real tiny PNG bytes where tests expect successful image imports. ## Refactor impact Primary owner: Tauri/Rust storage, imports, and catalog media assets. Impact areas reviewed: - Persona/character avatar upload helpers in `media_uploads.rs` - Sprite upload and native import restoration paths - Bulk persona avatar import fixtures and rollback coverage Boundary notes: Rust storage/import boundary only. No React UI, engine, shared API wrapper, or remote runtime routing changes. Pressure points touched: Import modules and managed media helpers only; no `src-tauri/src/lib.rs` command registration changes. ## Validation - [x] Matching validation command passes locally (for example `pnpm typecheck`, `pnpm build`, `pnpm check:architecture`, `pnpm check:docs`, or full `pnpm check` when warranted) - [ ] Full `pnpm check` passes before PR push/handoff - [ ] Human/manual validation completed by contributor or reviewer ### Manual verification notes - `cargo check --manifest-path src-tauri/Cargo.toml` - `cargo test --manifest-path src-tauri/Cargo.toml decode_image_payload_rejects_declared_image_with_non_image_bytes` - `cargo test --manifest-path src-tauri/Cargo.toml persist_image_file_copy_rejects_extension_with_non_image_bytes` - `cargo test --manifest-path src-tauri/Cargo.toml native_marinara_character_import_skips_malformed_optional_sprite` - `cargo test --manifest-path src-tauri/Cargo.toml bulk_upload_reports_partial_failures_and_returns_refreshed_list` - `cargo test --manifest-path src-tauri/Cargo.toml import_st_character_rolls_back_character_and_avatar_when_embedded_lorebook_fails` - `cargo test --manifest-path src-tauri/Cargo.toml import_persona_avatar_file_rolls_back_avatar_when_persona_write_fails` ## Feature Discoverability Check exactly one: - [ ] Updated `src/features/shell/discovery/` because this PR adds or materially changes a user-discoverable feature, workflow, setting, mode, panel, import path, agent, media capability, or advanced tool. - [x] N/A because this PR is only a bugfix, refactor, test, docs, internal wiring, visual polish, copy edit, or compatibility fix and does not add a new thing users need to find. Reason: Bugfix for existing persona/image import validation behavior. ## Docs and release impact - [x] No docs changes needed - [ ] Updated `README.md` - [ ] Updated `CONTRIBUTING.md` - [ ] Updated `docs/developer/` - [ ] Updated repo skills or `AGENTS.md` - [x] Confirmed this PR does not restore old staging/package-workspace/release claims ## UI evidence N/A - Rust storage/import validation only. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:16:29 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#5456
No description provided.