Continued the Detection Quality roadmap.
This commit is contained in:
@@ -15,6 +15,9 @@ from .recommendations import build_recommendations
|
||||
from .syslog_server import listen_udp_syslog
|
||||
from .monitor import monitor_loop
|
||||
from .threat_intel import enrich_ips, is_public_ip
|
||||
from .config import ConfigStore
|
||||
from .replay import replay_events
|
||||
from .stream_profiles import parse_profiles
|
||||
|
||||
|
||||
def _print_json(data: object) -> None:
|
||||
@@ -215,6 +218,15 @@ def run_dashboard(args: argparse.Namespace) -> int:
|
||||
return 0
|
||||
|
||||
|
||||
def replay_history(args: argparse.Namespace) -> int:
|
||||
config = ConfigStore(args.config_file).read()
|
||||
profiles = parse_profiles(config.get("graylog_stream_profiles", []))
|
||||
stream_name = next((str(item.get("title", "")) for item in config.get("graylog_streams", []) if isinstance(item, dict) and item.get("id") == args.stream_id), args.stream_id)
|
||||
result = replay_events(read_events(args.logs), profiles, stream_id=args.stream_id, stream_name=stream_name, bucket_seconds=args.bucket_seconds)
|
||||
_print_json(result)
|
||||
return 0
|
||||
|
||||
|
||||
def build_parser() -> argparse.ArgumentParser:
|
||||
parser = argparse.ArgumentParser(description="Local FortiGate AI/ML inspection tool")
|
||||
subparsers = parser.add_subparsers(required=True)
|
||||
@@ -305,6 +317,13 @@ def build_parser() -> argparse.ArgumentParser:
|
||||
dashboard.add_argument("--config-file", default="state/fgai-config.json", help="Local runtime configuration JSON")
|
||||
dashboard.set_defaults(func=run_dashboard)
|
||||
|
||||
replay = subparsers.add_parser("replay", help="Replay a historical log export against temporary baselines")
|
||||
replay.add_argument("--logs", required=True, help="Historic JSONL or key/value log export")
|
||||
replay.add_argument("--config-file", default="state/fgai-config.json", help="Stream profile configuration")
|
||||
replay.add_argument("--stream-id", default="", help="Apply this configured Graylog stream profile to exported events")
|
||||
replay.add_argument("--bucket-seconds", type=int, default=300, help="Replay baseline bucket size")
|
||||
replay.set_defaults(func=replay_history)
|
||||
|
||||
return parser
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user