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 = "

Samsara assessment

SYNTHETIC DEMO — no real collection performed.

" if data["synthetic"] else "

Samsara assessment

IMPORTED INVENTORY — source assertions not independently verified.

" if not data['synthetic'] and data['server'].get('collection_source') == 'Local Linux read-only collection': content = '

Samsara assessment

LOCAL LINUX 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"

Summary

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']}

" content += '

Important software

Workload name hints and application services; use unverified.

Scheduled jobs and scripts

Configured schedules do not confirm execution.

' for title, value in [("Server overview", data["server"]), ("Collection timestamp", data["collected_at"]), ("Inventory", data["inventory"]), ("Dependencies and risk findings", assessment["findings"]), ("Collection checks / missing evidence", data["checks"])]: content += f"

{title}

{escape(json.dumps(value, indent=2))}
" content += "

Recommended manual verification

" Path(path).write_text('Samsara' + content + '', encoding="utf-8")