diff --git a/deploy/mariadb/init/001-schema.sql b/deploy/mariadb/init/001-schema.sql index e5efc36..0120a6c 100644 --- a/deploy/mariadb/init/001-schema.sql +++ b/deploy/mariadb/init/001-schema.sql @@ -1290,4 +1290,26 @@ VALUES 0, 86400, 0 -); \ No newline at end of file +); + +UPDATE detection_rules +SET description = '' +WHERE description IS NULL; + +UPDATE detection_rules +SET match_field = '' +WHERE match_field IS NULL; + +UPDATE detection_rules +SET match_operator = '' +WHERE match_operator IS NULL; + +UPDATE detection_rules +SET match_value = '' +WHERE match_value IS NULL; + +ALTER TABLE detection_rules +MODIFY description TEXT NULL, +MODIFY match_value TEXT NULL, +MODIFY match_field VARCHAR(64) NOT NULL DEFAULT '', +MODIFY match_operator VARCHAR(16) NOT NULL DEFAULT ''; \ No newline at end of file diff --git a/main.go b/main.go index f175454..5419863 100644 --- a/main.go +++ b/main.go @@ -761,10 +761,21 @@ func main() { func (s *server) listDynamicRules(ctx context.Context) ([]DynamicRule, error) { const q = ` -SELECT id, name, description, severity, channel, event_ids, - match_field, match_operator, match_value, - threshold_count, threshold_window_seconds, suppress_for_seconds, - enabled, created_at, updated_at +SELECT id, + name, + COALESCE(description, ''), + severity, + channel, + event_ids, + COALESCE(match_field, ''), + COALESCE(match_operator, ''), + COALESCE(match_value, ''), + threshold_count, + threshold_window_seconds, + suppress_for_seconds, + enabled, + created_at, + updated_at FROM detection_rules ORDER BY name ASC `