fix anon
This commit is contained in:
@@ -5,6 +5,7 @@ from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
from fgai.config import ConfigStore
|
||||
from fgai.feedback import FeedbackStore
|
||||
from fgai.history import StatusSnapshotStore
|
||||
from fgai.history import FieldDiscoveryStore
|
||||
from fgai.monitor import add_llm_assessment, build_status, cached_status_with_error, monitor_cycle_timeout_seconds, write_refreshing_status, write_status
|
||||
@@ -38,6 +39,27 @@ class MonitorTests(unittest.TestCase):
|
||||
self.assertFalse(status["status_cache"]["served_from_cache"])
|
||||
self.assertGreaterEqual(len(status["anomalies"]), 1)
|
||||
|
||||
def test_entity_scope_feedback_suppresses_anomaly_in_build_status(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
log_path = Path(tmp) / "fg.log"
|
||||
log_path.write_text(
|
||||
"\n".join(
|
||||
[
|
||||
'type=utm subtype=ips srcip=8.8.8.8 dstip=10.0.0.10 service=https action=blocked severity=critical',
|
||||
'type=utm subtype=ips srcip=8.8.8.8 dstip=10.0.0.10 service=https action=blocked severity=critical',
|
||||
'type=utm subtype=ips srcip=8.8.8.8 dstip=10.0.0.10 service=https action=blocked severity=critical',
|
||||
]
|
||||
),
|
||||
encoding="utf-8",
|
||||
)
|
||||
feedback_store = FeedbackStore(str(Path(tmp) / "feedback.json"))
|
||||
feedback_store.add({"scope": "entity", "entity": "8.8.8.8", "status": "false_positive", "expires_at": 9999999999})
|
||||
|
||||
with patch("fgai.monitor.FeedbackStore", return_value=feedback_store):
|
||||
status = build_status(str(log_path), incident_path=str(Path(tmp) / "incidents.json"))
|
||||
|
||||
self.assertNotIn("8.8.8.8", [item["subject"] for item in status["anomalies"]])
|
||||
|
||||
def test_write_status_creates_parent_directory(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
output = Path(tmp) / "state" / "status.json"
|
||||
|
||||
Reference in New Issue
Block a user