#!/usr/bin/env python3 """ Process Flow HTML Generator ============================ Generates standalone HTML process flow diagrams. The template is embedded directly in the script - no network access required at runtime. Fetch: https://audittoolbox.com/apps/processflow-generate.py.txt Usage: python processflow-generate.py '{"nodes":[...],"edges":[...]}' # Or pipe JSON: echo '{"nodes":[...],"edges":[...]}' | python processflow-generate.py # Or with a file: python processflow-generate.py < data.json > output.html Output is a standalone HTML file that renders the process flow diagram. JSON Schema: { "nodes": [ { "id": "string", // Unique identifier "title": "string", // Display title "description": "string", // Optional description "x": number, // Optional x position (auto-layout if missing) "y": number, // Optional y position (auto-layout if missing) "risks": [ // Optional array of risks { "id": "string", "name": "string", "controls": [ // Optional array of controls {"id": "string", "name": "string"} ] } ] } ], "edges": [ { "id": "string", // Unique identifier "source": "string", // Source node id "target": "string", // Target node id "label": "string" // Optional edge label } ] } """ import sys import json # Embedded HTML template - the placeholder "__PROCESS_FLOW_JSON__" will be replaced TEMPLATE = r''' Process Flow - Risk & Control Analysis
Click target node's LEFT dot
100%
''' def generate_html(json_data): """Generate HTML with embedded JSON data.""" # Validate JSON try: parsed = json.loads(json_data) if isinstance(json_data, str) else json_data # Re-serialize to ensure valid JSON (compact form) json_str = json.dumps(parsed) except json.JSONDecodeError as e: print(f"Error: Invalid JSON - {e}", file=sys.stderr) sys.exit(1) # Replace placeholder with actual data html = TEMPLATE.replace('"__PROCESS_FLOW_JSON__"', json_str) return html if __name__ == '__main__': # Get JSON from argument or stdin if len(sys.argv) > 1: json_data = sys.argv[1] else: json_data = sys.stdin.read().strip() if not json_data: print(__doc__) sys.exit(0) print(generate_html(json_data))