Fix suppression annotation for interface_down not checking host-level rules
Lint / Python (flake8) (push) Successful in 38s
Lint / JS (eslint) (push) Successful in 7s
Security / Python Security (bandit) (push) Successful in 39s
Test / Python Tests (pytest) (push) Successful in 1m5s
Lint / Notify on failure (push) Has been skipped
Lint / Deploy (push) Successful in 4s
Lint / Python (flake8) (push) Successful in 38s
Lint / JS (eslint) (push) Successful in 7s
Security / Python Security (bandit) (push) Successful in 39s
Test / Python Tests (pytest) (push) Successful in 1m5s
Lint / Notify on failure (push) Has been skipped
Lint / Deploy (push) Successful in 4s
monitor.py checks both 'interface' and 'host' suppressions for interface_down events, but _annotate_suppressions only checked 'interface'. A host-level suppression would silently suppress tickets but not mark the table row as suppressed in the UI. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -174,17 +174,26 @@ _PAGE_LIMIT = 200 # max events returned per request
|
|||||||
|
|
||||||
|
|
||||||
def _annotate_suppressions(events: list, suppressions: list) -> None:
|
def _annotate_suppressions(events: list, suppressions: list) -> None:
|
||||||
"""Annotate each event dict in-place with an is_suppressed bool."""
|
"""Annotate each event dict in-place with an is_suppressed bool.
|
||||||
|
|
||||||
|
Mirrors the suppression check order in monitor.py exactly:
|
||||||
|
interface_down → interface OR host
|
||||||
|
unifi_device_* → unifi_device
|
||||||
|
everything else → host
|
||||||
|
"""
|
||||||
for ev in events:
|
for ev in events:
|
||||||
sup_type = (
|
etype = ev.get('event_type', '')
|
||||||
'unifi_device' if ev.get('event_type') == 'unifi_device_offline'
|
name = ev.get('target_name', '')
|
||||||
else 'interface' if ev.get('event_type') == 'interface_down'
|
detail = ev.get('target_detail', '') or ''
|
||||||
else 'host'
|
if etype == 'interface_down':
|
||||||
)
|
ev['is_suppressed'] = (
|
||||||
ev['is_suppressed'] = db.check_suppressed(
|
db.check_suppressed(suppressions, 'interface', name, detail) or
|
||||||
suppressions, sup_type,
|
db.check_suppressed(suppressions, 'host', name)
|
||||||
ev.get('target_name', ''), ev.get('target_detail', '') or '',
|
)
|
||||||
)
|
elif etype == 'unifi_device_offline':
|
||||||
|
ev['is_suppressed'] = db.check_suppressed(suppressions, 'unifi_device', name, detail)
|
||||||
|
else:
|
||||||
|
ev['is_suppressed'] = db.check_suppressed(suppressions, 'host', name, detail)
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user