import html import json from pathlib import Path from samsara.analyzers.summary import summarize MANUAL_STEPS = ["Confirm application and business owners and obtain retirement approval.", "Review historical monitoring, DNS, load balancers, backups and firewall logs.", "Validate service accounts, scheduled workloads and SMB/NFS/Samba consumers with owners.", "Resolve failed or missing checks and verify rollback and retention requirements."] def export_json(path, data, assessment): Path(path).write_text(json.dumps({"inventory_result": data, "assessment": assessment}, indent=2), encoding="utf-8") def export_html(path, data, assessment): escape = lambda value: html.escape(str(value)) content = "
SYNTHETIC DEMO — no real collection performed.
" if data["synthetic"] else "IMPORTED INVENTORY — source assertions not independently verified.
" if not data['synthetic'] and data['server'].get('collection_source') == 'Local Linux read-only collection': content = 'LOCAL LINUX INVENTORY — read-only snapshot of the execution host.
' if not data['synthetic'] and data['server'].get('collection_source') == 'Local Windows read-only collection': content = 'LOCAL WINDOWS INVENTORY — read-only snapshot of the execution host.
' content += "Heuristic requiring administrator review. This report does not authorize retirement.
" summary = summarize(data, assessment) content += f"Retirement risk estimate: {escape(summary['risk_level'])} ({summary['risk_score']}/100). Higher scores mean more retirement concerns.
" content += f"OS type: {escape(summary['os_type'])}
Version: {escape(summary['version'])}
Incomplete or missing checks: {summary['incomplete']}
Workload name hints and application services; use unverified.
Configured schedules do not confirm execution.
{escape(json.dumps(value, indent=2))}"
content += "