[PR #5068] [MERGED] fix(regex): retain warned patterns during import #6612

Closed
opened 2026-10-23 04:12:04 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5068
Author: @SpicyMarinara
Created: 8/15/2026
Status: ✅ Merged
Merged: 8/15/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/5067-import-unsafe-regex-warnings


📝 Commits (5)

  • 8994fc7 fix(regex): retain warned patterns during import
  • 095f6ff fix(i18n): keep regex warning key sorted
  • aab5298 Merge remote-tracking branch 'origin/staging' into fix/5067-import-unsafe-regex-warnings
  • a69dccc Merge remote-tracking branch 'origin/staging' into fix/5067-import-unsafe-regex-warnings
  • aaa219b fix(regex): address import review feedback

📊 Changes

7 files changed (+106 additions, -25 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 packages/client/src/components/characters/CharacterRegexSection.tsx (+14 -6)
📝 packages/client/src/components/panels/PresetsPanel.tsx (+14 -6)
📝 packages/client/src/hooks/use-regex-scripts.ts (+10 -0)
📝 packages/client/src/localization/locales/en.json (+1 -0)
📝 packages/server/src/routes/regex-scripts.routes.ts (+14 -1)
📝 packages/shared/src/schemas/regex.schema.ts (+52 -12)

📄 Description

Linked issue

Closes #5067

Why this change

Regex bundle imports currently treat the conservative ReDoS heuristic as a hard validation failure. That silently loses entries users may need to inspect or repair, and reports otherwise well-formed imports as skipped.

What changed

  • Added a dedicated regex-import validation path that keeps syntactically valid scripts even when the heuristic flags their pattern.
  • Kept normal editor/API creation strict and kept runtime application guarded, so importing a warning does not introduce an event-loop or browser freeze.
  • Updated both global and character-scoped batch import flows to show which retained entry needs attention.
  • Added a user-facing changelog entry.

Validation

  • Run pnpm check
  • Run pnpm localization:check
  • Manually import a bundle containing safe and heuristic-flagged regex scripts
  • Confirm all syntactically valid entries appear and the flagged entry shows a warning
  • Confirm ordinary editor creation still rejects an unsafe pattern

Manual verification notes

Manually verify the global Presets regex importer and a character-scoped regex importer with a mixed safe/flagged bundle. The flagged row should be retained for inspection, while runtime protection continues to prevent it from executing until corrected.

Docs and release impact

No documentation change is needed; the behavior is described under CHANGELOG [Unreleased].

Summary by CodeRabbit

  • Bug Fixes

    • Imported regex scripts with potentially unsafe patterns are now retained for review instead of being skipped.
    • Unsafe imported patterns trigger a warning and remain inactive until made safe.
    • Regex safety checks continue to apply when creating or updating scripts.
  • Improvements

    • Imported regex scripts are now validated and stored consistently across supported import locations.
    • Import warnings are displayed together for easier review.

🔄 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/5068 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 8/15/2026 **Status:** ✅ Merged **Merged:** 8/15/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/5067-import-unsafe-regex-warnings` --- ### 📝 Commits (5) - [`8994fc7`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8994fc74dbfcc91f43fc4da07de2aa140abeb5eb) fix(regex): retain warned patterns during import - [`095f6ff`](https://github.com/Pasta-Devs/Marinara-Engine/commit/095f6ffecc4a98f105c3581d48714a4f7ffff91d) fix(i18n): keep regex warning key sorted - [`aab5298`](https://github.com/Pasta-Devs/Marinara-Engine/commit/aab5298e91859e510a1952372341dc25c8b7d48e) Merge remote-tracking branch 'origin/staging' into fix/5067-import-unsafe-regex-warnings - [`a69dccc`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a69dccc5d50db429d089c70358cb99a20d242ab7) Merge remote-tracking branch 'origin/staging' into fix/5067-import-unsafe-regex-warnings - [`aaa219b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/aaa219b0d9abd1cae13701ad3c493897cc3eb7a8) fix(regex): address import review feedback ### 📊 Changes **7 files changed** (+106 additions, -25 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `packages/client/src/components/characters/CharacterRegexSection.tsx` (+14 -6) 📝 `packages/client/src/components/panels/PresetsPanel.tsx` (+14 -6) 📝 `packages/client/src/hooks/use-regex-scripts.ts` (+10 -0) 📝 `packages/client/src/localization/locales/en.json` (+1 -0) 📝 `packages/server/src/routes/regex-scripts.routes.ts` (+14 -1) 📝 `packages/shared/src/schemas/regex.schema.ts` (+52 -12) </details> ### 📄 Description ## Linked issue Closes #5067 ## Why this change Regex bundle imports currently treat the conservative ReDoS heuristic as a hard validation failure. That silently loses entries users may need to inspect or repair, and reports otherwise well-formed imports as skipped. ## What changed - Added a dedicated regex-import validation path that keeps syntactically valid scripts even when the heuristic flags their pattern. - Kept normal editor/API creation strict and kept runtime application guarded, so importing a warning does not introduce an event-loop or browser freeze. - Updated both global and character-scoped batch import flows to show which retained entry needs attention. - Added a user-facing changelog entry. ## Validation - [ ] Run `pnpm check` - [ ] Run `pnpm localization:check` - [ ] Manually import a bundle containing safe and heuristic-flagged regex scripts - [ ] Confirm all syntactically valid entries appear and the flagged entry shows a warning - [ ] Confirm ordinary editor creation still rejects an unsafe pattern ## Manual verification notes Manually verify the global Presets regex importer and a character-scoped regex importer with a mixed safe/flagged bundle. The flagged row should be retained for inspection, while runtime protection continues to prevent it from executing until corrected. ## Docs and release impact No documentation change is needed; the behavior is described under CHANGELOG `[Unreleased]`. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Imported regex scripts with potentially unsafe patterns are now retained for review instead of being skipped. * Unsafe imported patterns trigger a warning and remain inactive until made safe. * Regex safety checks continue to apply when creating or updating scripts. * **Improvements** * Imported regex scripts are now validated and stored consistently across supported import locations. * Import warnings are displayed together for easier review. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:12:04 +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#6612
No description provided.