fix
This commit is contained in:
@@ -36,6 +36,23 @@ def _stream_titles(config: dict[str, object]) -> dict[str, str]:
|
||||
}
|
||||
|
||||
|
||||
def _public_runtime_config(config: dict[str, object]) -> dict[str, object]:
|
||||
public = {
|
||||
key: value
|
||||
for key, value in config.items()
|
||||
if key not in {"graylog_mcp_token", "abuseipdb_api_key", "virustotal_api_key"}
|
||||
}
|
||||
public["graylog_mcp_token_configured"] = bool(config.get("graylog_mcp_token"))
|
||||
public["abuseipdb_api_key_configured"] = bool(config.get("abuseipdb_api_key"))
|
||||
public["virustotal_api_key_configured"] = bool(config.get("virustotal_api_key"))
|
||||
public["enabled_streams"] = sum(
|
||||
1
|
||||
for item in config.get("graylog_streams", [])
|
||||
if isinstance(item, dict) and item.get("enabled")
|
||||
)
|
||||
return public
|
||||
|
||||
|
||||
def _stream_name(stream_id: str, stream_titles: dict[str, str], profile: object | None = None) -> str:
|
||||
return stream_titles.get(stream_id) or getattr(profile, "name", "") or stream_id
|
||||
|
||||
@@ -136,7 +153,7 @@ def build_status(
|
||||
config_store = ConfigStore(config_path) if config_path else None
|
||||
config_exists = bool(config_store and config_store.path.exists())
|
||||
runtime_values = config_store.read() if config_exists and config_store else {}
|
||||
runtime_config = config_store.public() if config_store else {}
|
||||
runtime_config = _public_runtime_config(runtime_values) if config_store else {}
|
||||
stream_profiles = parse_profiles(runtime_values.get("graylog_stream_profiles", []))
|
||||
stream_titles = _stream_titles(runtime_values)
|
||||
events = read_events(log_path) if Path(log_path).exists() else []
|
||||
@@ -517,7 +534,7 @@ def write_status(status: dict[str, object], output: str) -> None:
|
||||
tmp_path.replace(output_path)
|
||||
|
||||
|
||||
def write_refreshing_status(output: str, *, cache_path: str | None = None, call_timeout_seconds: int = 0, poll_timeout_seconds: int = 0) -> None:
|
||||
def write_refreshing_status(output: str, *, cache_path: str | None = None, call_timeout_seconds: int = 0, poll_timeout_seconds: int = 0, runtime_values: dict[str, object] | None = None) -> None:
|
||||
output_path = Path(output)
|
||||
now = int(time.time())
|
||||
try:
|
||||
@@ -538,6 +555,9 @@ def write_refreshing_status(output: str, *, cache_path: str | None = None, call_
|
||||
current["generated_at"] = now
|
||||
current["stale"] = False
|
||||
current["stale_reason"] = ""
|
||||
if runtime_values is not None:
|
||||
current["configuration"] = _public_runtime_config(runtime_values)
|
||||
current["stream_coverage"] = _stream_coverage(runtime_values, {}, {"streams": []}, [], _stream_titles(runtime_values))
|
||||
capabilities = current.setdefault("capabilities", {})
|
||||
if isinstance(capabilities, dict):
|
||||
previous_events = previous_mcp.get("events_fetched", 0) if isinstance(previous_mcp, dict) else 0
|
||||
@@ -595,7 +615,7 @@ def monitor_loop(
|
||||
mcp_call_timeout = max(1, int(runtime.get("graylog_mcp_call_timeout_seconds", 8) or 8))
|
||||
mcp_poll_timeout = max(60, int(runtime.get("graylog_mcp_poll_timeout_seconds", 120) or 120))
|
||||
if runtime.get("log_source") == "graylog_mcp":
|
||||
write_refreshing_status(output, cache_path=status_cache_path, call_timeout_seconds=mcp_call_timeout, poll_timeout_seconds=mcp_poll_timeout)
|
||||
write_refreshing_status(output, cache_path=status_cache_path, call_timeout_seconds=mcp_call_timeout, poll_timeout_seconds=mcp_poll_timeout, runtime_values=runtime)
|
||||
try:
|
||||
status = build_status(
|
||||
log_path, policy_path=policy_path, anomaly_limit=anomaly_limit,
|
||||
|
||||
Reference in New Issue
Block a user