From cdf4c283d612acc61effd5c751d5fb32de2a307b Mon Sep 17 00:00:00 2001 From: Keenan Brock Date: Tue, 19 Jan 2021 11:08:46 -0500 Subject: [PATCH] events use string regular expressions before, events expressions are stored in yaml as regular expressions. now, they are stored as a string with an opening/closing slash. Those are treated as regular expressions. --- app/models/event_stream.rb | 4 ++-- spec/models/ems_event_spec.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/event_stream.rb b/app/models/event_stream.rb index 9a52ab4b54b..1bf14a2488f 100644 --- a/app/models/event_stream.rb +++ b/app/models/event_stream.rb @@ -62,13 +62,13 @@ def self.group_and_level(event_type) group = egroups.detect do |_, value| GROUP_LEVELS - .detect { |lvl| value[lvl]&.any? { |typ| typ.kind_of?(String) && typ == event_type } } + .detect { |lvl| value[lvl]&.any? { |typ| !typ.starts_with?("/") && typ == event_type } } .tap { |level_found| level = level_found || level } end&.first group ||= egroups.detect do |_, value| GROUP_LEVELS - .detect { |lvl| value[lvl]&.any? { |typ| typ.kind_of?(Regexp) && typ.match(event_type) } } + .detect { |lvl| value[lvl]&.any? { |typ| typ.starts_with?("/") && Regexp.new(typ[1..-2]).match?(event_type) } } .tap { |level_found| level = level_found || level } end&.first diff --git a/spec/models/ems_event_spec.rb b/spec/models/ems_event_spec.rb index 02944408b5b..7eb1d61d482 100644 --- a/spec/models/ems_event_spec.rb +++ b/spec/models/ems_event_spec.rb @@ -411,7 +411,7 @@ end let(:provider_event) { 'SomeSpecialProviderEvent' } - let(:provider_regex) { /Some.+Event/ } + let(:provider_regex) { "/Some.+Event/" } it 'returns the provider event if configured' do expect(described_class.event_groups[:addition][:critical]).to include('CloneTaskEvent')