Add analysis tab and JSON outputs
This commit is contained in:
parent
8dcf2035aa
commit
9cf27ecb2f
3 changed files with 130 additions and 22 deletions
|
@ -138,6 +138,10 @@ def check_missing_domains(json_output: bool = typer.Option(False, "--json", help
|
|||
|
||||
missing = sorted(db_domains - config_domains)
|
||||
|
||||
ANALYSIS_DIR.mkdir(parents=True, exist_ok=True)
|
||||
out_path = ANALYSIS_DIR / "missing_domains.json"
|
||||
out_path.write_text(json.dumps(missing, indent=2))
|
||||
|
||||
if json_output:
|
||||
typer.echo(json.dumps(missing))
|
||||
else:
|
||||
|
@ -189,14 +193,19 @@ def suggest_cache(
|
|||
rows = [r for r in cur.fetchall() if r[0] in no_cache]
|
||||
conn.close()
|
||||
|
||||
result = [
|
||||
{"host": host, "path": path, "misses": count} for host, path, count in rows
|
||||
]
|
||||
|
||||
ANALYSIS_DIR.mkdir(parents=True, exist_ok=True)
|
||||
out_path = ANALYSIS_DIR / "cache_suggestions.json"
|
||||
out_path.write_text(json.dumps(result, indent=2))
|
||||
|
||||
if json_output:
|
||||
result = [
|
||||
{"host": host, "path": path, "misses": count} for host, path, count in rows
|
||||
]
|
||||
typer.echo(json.dumps(result))
|
||||
else:
|
||||
for host, path, count in rows:
|
||||
typer.echo(f"{host} {path} {count}")
|
||||
for item in result:
|
||||
typer.echo(f"{item['host']} {item['path']} {item['misses']}")
|
||||
|
||||
|
||||
@app.command("detect-threats")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue