Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mentat-test
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
713
Mentat
mentat-test
Commits
7ce9324f
Commit
7ce9324f
authored
3 years ago
by
Rajmund Hruška
Browse files
Options
Downloads
Patches
Plain Diff
Fix: Discard event if any filtering rule is matched. (Redmine issue:
#6227
)
parent
a9126154
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/mentat/reports/event.py
+9
-3
9 additions, 3 deletions
lib/mentat/reports/event.py
lib/mentat/reports/test_event.py
+6
-3
6 additions, 3 deletions
lib/mentat/reports/test_event.py
with
15 additions
and
6 deletions
lib/mentat/reports/event.py
+
9
−
3
View file @
7ce9324f
...
...
@@ -488,7 +488,7 @@ class EventReporter(BaseReporter):
filter_list
=
self
.
settings_dict
[
group
].
setup_filters
(
self
.
filter_parser
,
self
.
filter_compiler
)
match
=
self
.
filter_event
(
filter_list
,
event
)
if
match
:
self
.
logger
.
debug
(
"
Event matched filtering rule
'
%s
'
of group %s
"
,
match
,
group
)
self
.
logger
.
debug
(
"
Event matched filtering rule
'
%s
'
of group %s
.
"
,
match
,
group
)
fltlog
[
match
]
=
fltlog
.
get
(
match
,
0
)
+
1
else
:
filtered_groups
.
append
(
group
)
...
...
@@ -527,9 +527,15 @@ class EventReporter(BaseReporter):
if
main_group
not
in
groups
:
return
[],
[],
fltlog
groups
,
fltlog
=
self
.
_filter_groups
(
groups
,
event
,
fltlog
)
filtered_groups
,
fltlog
=
self
.
_filter_groups
(
groups
,
event
,
fltlog
)
# If any filtering rule of at least one of the groups was matched then this event shall not be reported to anyone.
if
filtered_groups
!=
groups
:
self
.
logger
.
debug
(
"
Discarding event with ID
'
%s
'
from reports.
"
,
event
[
'
ID
'
])
return
[],
[],
fltlog
fallback_groups
,
fltlog
=
self
.
_filter_groups
(
fallback_groups
,
event
,
fltlog
)
return
groups
,
fallback_groups
,
fltlog
return
filtered_
groups
,
fallback_groups
,
fltlog
def
filter_events
(
self
,
main_group
,
events
):
"""
...
...
This diff is collapsed.
Click to expand it.
lib/mentat/reports/test_event.py
+
6
−
3
View file @
7ce9324f
...
...
@@ -308,10 +308,13 @@ class TestMentatReportsEvent(unittest.TestCase):
for
events
in
aggr
.
values
():
self
.
assertEqual
(
len
(
events
),
2
)
self
.
reporter
.
logger
.
assert_has_calls
([
call
.
debug
(
"
Event matched filtering rule
'
%s
'
of group %s
"
,
'
FLT1
'
,
'
abuse@cesnet.cz
'
),
call
.
debug
(
"
Event matched filtering rule
'
%s
'
of group %s.
"
,
'
FLT1
'
,
'
abuse@cesnet.cz
'
),
call
.
debug
(
"
Discarding event with ID
'
%s
'
from reports.
"
,
'
msg01
'
),
call
.
debug
(
'
Event matched filtering rules, all sources filtered
'
),
call
.
debug
(
"
Event matched filtering rule
'
%s
'
of group %s
"
,
'
FLT3
'
,
'
abuse@cesnet.cz
'
),
call
.
debug
(
"
Event matched filtering rule
'
%s
'
of group %s
"
,
'
FLT2
'
,
'
abuse@cesnet.cz
'
)
call
.
debug
(
"
Event matched filtering rule
'
%s
'
of group %s.
"
,
'
FLT3
'
,
'
abuse@cesnet.cz
'
),
call
.
debug
(
"
Discarding event with ID
'
%s
'
from reports.
"
,
'
msg02
'
),
call
.
debug
(
"
Event matched filtering rule
'
%s
'
of group %s.
"
,
'
FLT2
'
,
'
abuse@cesnet.cz
'
),
call
.
debug
(
"
Discarding event with ID
'
%s
'
from reports.
"
,
'
msg02
'
)
])
self
.
sqlstorage
.
session
.
commit
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment