update
This commit is contained in:
@@ -3,6 +3,7 @@ from __future__ import annotations
|
||||
import argparse
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from .llm import ollama_summary
|
||||
from .logs import read_events, summarize_events
|
||||
@@ -70,6 +71,28 @@ def suggest_blocks(args: argparse.Namespace) -> int:
|
||||
return 0
|
||||
|
||||
|
||||
def test_connection(args: argparse.Namespace) -> int:
|
||||
client = FortiGateClient.from_env()
|
||||
status = client.system_status()
|
||||
results = status.get("results", status)
|
||||
print("FortiGate API connection OK")
|
||||
_print_json(results)
|
||||
return 0
|
||||
|
||||
|
||||
def fetch_policies(args: argparse.Namespace) -> int:
|
||||
client = FortiGateClient.from_env()
|
||||
policies = client.firewall_policies()
|
||||
if args.output:
|
||||
output = Path(args.output)
|
||||
output.parent.mkdir(parents=True, exist_ok=True)
|
||||
output.write_text(json.dumps(policies, indent=2, sort_keys=True), encoding="utf-8")
|
||||
print(f"Wrote {output}")
|
||||
else:
|
||||
_print_json(policies)
|
||||
return 0
|
||||
|
||||
|
||||
def build_parser() -> argparse.ArgumentParser:
|
||||
parser = argparse.ArgumentParser(description="Local FortiGate AI/ML inspection tool")
|
||||
subparsers = parser.add_subparsers(required=True)
|
||||
@@ -98,6 +121,13 @@ def build_parser() -> argparse.ArgumentParser:
|
||||
blocks.add_argument("--expiry-minutes", type=int, default=60)
|
||||
blocks.set_defaults(func=suggest_blocks)
|
||||
|
||||
connection = subparsers.add_parser("test-connection", help="Test FortiGate REST API credentials")
|
||||
connection.set_defaults(func=test_connection)
|
||||
|
||||
fetch = subparsers.add_parser("fetch-policies", help="Fetch firewall policies through the FortiGate REST API")
|
||||
fetch.add_argument("--output", help="Write JSON response to this file")
|
||||
fetch.set_defaults(func=fetch_policies)
|
||||
|
||||
return parser
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user