Skip to content

sec(editor): add confirmation modal for destructive DDL and DML operations (#608) - #622

Merged
ZhuchkaTriplesix merged 1 commit into
devfrom
issue/608-destructive-sql-confirmation
Aug 26, 2026
Merged

sec(editor): add confirmation modal for destructive DDL and DML operations (#608)#622
ZhuchkaTriplesix merged 1 commit into
devfrom
issue/608-destructive-sql-confirmation

Conversation

@ZhuchkaTriplesix

Copy link
Copy Markdown
Member

Summary

Implements a safety inspection layer and confirmation dialog for destructive SQL statements (DROP DATABASE, DROP SCHEMA, DROP TABLE, DROP VIEW, DROP MATERIALIZED VIEW, TRUNCATE TABLE, and unconditional DELETE FROM) before executing queries in PostgreSQL, MySQL, and SQLite workspaces.

Changes

  1. Destructive SQL Detector (lib/core/database/destructive_sql_detector.dart):
    • Strips SQL comments (--, /* */) and single/dollar-quoted strings to prevent false positives.
    • Splits queries on semicolons and matches destructive DDL and DML patterns.
    • Assigns severity risk levels (CRITICAL, HIGH, MEDIUM).
  2. Confirmation Modal Dialog (lib/features/main_screen/destructive_query_dialog.dart):
    • Displays risk badges, target object descriptions, SQL script preview, copy button, and an acknowledgment checkbox to prevent accidental confirms.
  3. Workspaces Integration:
    • Integrated check into _execute() in PostgresSqlWorkspace, MysqlSqlWorkspace, and SqliteSqlWorkspace.
  4. App Settings & Preferences:
    • Added AppSettings.confirmDestructiveOperations (default: true).
    • Added preference toggle in PreferencesDialog under the SQL editor section.
  5. Testing:
    • Unit tests in test/core/database/destructive_sql_detector_test.dart.
    • Widget tests in test/features/main_screen/destructive_query_dialog_test.dart.

Closes #608

@github-actions github-actions Bot added enhancement New feature or request editor Code/SQL editor labels Aug 26, 2026
@ZhuchkaTriplesix
ZhuchkaTriplesix merged commit f2f60ff into dev Aug 26, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

editor Code/SQL editor enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant