[PR #2417] [MERGED] Disable imported extensions so profile import never auto-runs their JS #5593

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

📋 Pull Request Information

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

Base: refactor ← Head: fix/profile-import-extensions-disabled


📝 Commits (1)

  • 6003ace Disable imported extensions so profile import never auto-runs their JS

📊 Changes

2 files changed (+18 additions, -0 deletions)

View changed files

📝 src-tauri/src/commands/storage/profile.rs (+17 -0)
📝 src-tauri/src/commands/storage/profile/legacy.rs (+1 -0)

📄 Description

Linked issue

Closes #2366

Why this change

  • Profile import wrote imported extensions rows verbatim, so an exported extension carrying enabled: true (with arbitrary JS) was restored enabled. CustomThemeInjector then executed that imported JavaScript on the next render with no user opt-in — arbitrary-JS auto-run on import. (#2382 only sanitized theme/extension CSS; the enabled: true passthrough was untouched.)

What changed

  • src-tauri/src/commands/storage/profile.rs: added disable_imported_extension_rows, a pub(super) helper that forces every imported extension row's enabled to false, and call it in profile_collections_import_plan for the extensions collection (mirrors the connection-secret redaction special-case in the same loop). The JS/CSS payload and all other fields are preserved — only enabled is overwritten.
  • src-tauri/src/commands/storage/profile/legacy.rs: the legacy SQLite/fileStorage import path gets the same extensions arm via super::disable_imported_extension_rows, so both import plans stay consistent.
  • Imported extensions now require one explicit toggle in Settings to re-activate.

Refactor impact

Primary owner: Rust storage (imports)

Impact areas reviewed:

  • src-tauri/src/commands/storage/profile.rs (profile_collections_import_plan + new helper)
  • src-tauri/src/commands/storage/profile/legacy.rs (legacy import per-collection match)

Boundary notes:

  • None. Confined to the Rust import normalization layer; no contract/schema change (extensions contract stays EMPTY_DEFAULTS — the gate belongs in the import path). No TS touched.

Pressure points touched:

  • Import modules (profile.rs, profile/legacy.rs).

Validation

  • Matching validation command passes locally
  • Full pnpm check passes before PR push/handoff
  • Human/manual validation completed by contributor or reviewer

Manual verification notes

  • cargo test --manifest-path src-tauri/Cargo.toml -p marinara-engine (profile import) — a local-only test confirmed an imported extension carrying enabled: true comes back enabled: false with its js payload preserved.
  • cargo clippy --manifest-path src-tauri/Cargo.toml --workspace --all-targets -- -D warnings — clean.

Feature Discoverability

  • Updated src/features/shell/discovery/
  • N/A because this PR is a security hardening fix at the import boundary.

Reason:

  • No new discoverable surface; existing extensions UI unchanged (imported ones just start disabled).

Docs and release impact

  • No docs changes needed

🔄 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/2417 **Author:** [@Romuromylus](https://github.com/Romuromylus) **Created:** 6/6/2026 **Status:** ✅ Merged **Merged:** 6/6/2026 **Merged by:** [@Romuromylus](https://github.com/Romuromylus) **Base:** `refactor` ← **Head:** `fix/profile-import-extensions-disabled` --- ### 📝 Commits (1) - [`6003ace`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6003acecb74bdbf5b9c992c9d639930f1d5495ad) Disable imported extensions so profile import never auto-runs their JS ### 📊 Changes **2 files changed** (+18 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `src-tauri/src/commands/storage/profile.rs` (+17 -0) 📝 `src-tauri/src/commands/storage/profile/legacy.rs` (+1 -0) </details> ### 📄 Description ## Linked issue Closes #2366 ## Why this change - Profile import wrote imported `extensions` rows verbatim, so an exported extension carrying `enabled: true` (with arbitrary JS) was restored enabled. `CustomThemeInjector` then executed that imported JavaScript on the next render with no user opt-in — arbitrary-JS auto-run on import. (#2382 only sanitized theme/extension CSS; the `enabled: true` passthrough was untouched.) ## What changed - `src-tauri/src/commands/storage/profile.rs`: added `disable_imported_extension_rows`, a `pub(super)` helper that forces every imported extension row's `enabled` to `false`, and call it in `profile_collections_import_plan` for the `extensions` collection (mirrors the connection-secret redaction special-case in the same loop). The JS/CSS payload and all other fields are preserved — only `enabled` is overwritten. - `src-tauri/src/commands/storage/profile/legacy.rs`: the legacy SQLite/fileStorage import path gets the same `extensions` arm via `super::disable_imported_extension_rows`, so both import plans stay consistent. - Imported extensions now require one explicit toggle in Settings to re-activate. ## Refactor impact Primary owner: Rust storage (imports) Impact areas reviewed: - `src-tauri/src/commands/storage/profile.rs` (`profile_collections_import_plan` + new helper) - `src-tauri/src/commands/storage/profile/legacy.rs` (legacy import per-collection match) Boundary notes: - None. Confined to the Rust import normalization layer; no contract/schema change (extensions contract stays `EMPTY_DEFAULTS` — the gate belongs in the import path). No TS touched. Pressure points touched: - Import modules (`profile.rs`, `profile/legacy.rs`). ## Validation - [x] Matching validation command passes locally - [ ] Full `pnpm check` passes before PR push/handoff - [ ] Human/manual validation completed by contributor or reviewer ### Manual verification notes - `cargo test --manifest-path src-tauri/Cargo.toml -p marinara-engine` (profile import) — a local-only test confirmed an imported extension carrying `enabled: true` comes back `enabled: false` with its `js` payload preserved. - `cargo clippy --manifest-path src-tauri/Cargo.toml --workspace --all-targets -- -D warnings` — clean. ## Feature Discoverability - [ ] Updated `src/features/shell/discovery/` - [x] N/A because this PR is a security hardening fix at the import boundary. Reason: - No new discoverable surface; existing extensions UI unchanged (imported ones just start disabled). ## Docs and release impact - [x] No docs changes needed --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:17:39 +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#5593
No description provided.