Spaces:
Paused
Paused
| import sys | |
| sys.stdout.reconfigure(encoding='utf-8') | |
| import os, json, urllib.request, ssl, time, re, glob | |
| ctx = ssl.create_default_context() | |
| ctx.check_hostname = False | |
| ctx.verify_mode = ssl.CERT_NONE | |
| print("=" * 60) | |
| print("SECTION 1: LINES OF CODE") | |
| print("=" * 60) | |
| counts = {"py": 0, "ts_js": 0, "html": 0} | |
| skip = {"node_modules", ".git", "__pycache__", "dist", ".next"} | |
| for root, dirs, files in os.walk("."): | |
| dirs[:] = [d for d in dirs if d not in skip] | |
| for f in files: | |
| path = os.path.join(root, f) | |
| try: | |
| lines = sum(1 for _ in open(path, encoding="utf-8", errors="ignore")) | |
| except: | |
| continue | |
| if f.endswith(".py"): | |
| counts["py"] += lines | |
| elif f.endswith((".ts", ".tsx", ".js", ".jsx")): | |
| counts["ts_js"] += lines | |
| elif f.endswith(".html"): | |
| counts["html"] += lines | |
| total = counts["py"] + counts["ts_js"] + counts["html"] | |
| print(f" Python: {counts['py']} lines") | |
| print(f" TS/JS: {counts['ts_js']} lines") | |
| print(f" HTML: {counts['html']} lines") | |
| print(f" Total: {total} lines") | |
| print() | |
| print("=" * 60) | |
| print("SECTION 2: DEPENDENCIES") | |
| print("=" * 60) | |
| print("\n--- Python (requirements.txt) ---") | |
| try: | |
| with open("requirements.txt") as f: | |
| print(f.read()) | |
| except: | |
| print(" [NOT FOUND]") | |
| print("--- Node (opticparse-js/package.json) ---") | |
| try: | |
| with open("opticparse-js/package.json") as f: | |
| pkg = json.load(f) | |
| print(" Dependencies:", list(pkg.get("dependencies", {}).keys())) | |
| print(" Scripts:", json.dumps(pkg.get("scripts", {}), indent=4)) | |
| except: | |
| print(" [NOT FOUND]") | |
| print("\n--- Dashboard (dashboard/package.json) ---") | |
| try: | |
| with open("dashboard/package.json") as f: | |
| pkg = json.load(f) | |
| print(" Dependencies:", list(pkg.get("dependencies", {}).keys())) | |
| except: | |
| print(" [NOT FOUND]") | |
| print() | |
| print("=" * 60) | |
| print("SECTION 3: FILE EXISTENCE CHECK") | |
| print("=" * 60) | |
| files_to_check = [ | |
| ".env", | |
| "dashboard/.env", | |
| "dashboard/.env.production", | |
| "render.yaml", | |
| "Dockerfile", | |
| "opticparse-js/package.json", | |
| "docs/index.html", | |
| "docs/privacy.html", | |
| "docs/terms.html", | |
| "docs/sitemap.xml", | |
| "docs/robots.txt", | |
| "supabase/migrations/001_initial_schema.sql", | |
| "supabase/migrations/002_rls_watches_monitors.sql", | |
| ] | |
| for f in files_to_check: | |
| status = "[OK]" if os.path.exists(f) else "[MISSING]" | |
| print(f" {status} {f}") | |
| print() | |
| print("=" * 60) | |
| print("SECTION 4: ENVIRONMENT VARIABLE NAMES") | |
| print("=" * 60) | |
| for envfile in [".env", "dashboard/.env.production"]: | |
| print(f"\n--- {envfile} ---") | |
| try: | |
| with open(envfile) as f: | |
| for line in f: | |
| line = line.strip() | |
| if line and not line.startswith("#") and "=" in line: | |
| key = line.split("=", 1)[0].strip() | |
| print(f" {key}") | |
| except: | |
| print(" [NOT FOUND]") | |
| print("\n--- render.yaml envVars ---") | |
| try: | |
| with open("render.yaml") as f: | |
| content = f.read() | |
| for line in content.split("\n"): | |
| if "key:" in line: | |
| print(f" {line.strip()}") | |
| except: | |
| print(" [NOT FOUND]") | |
| print() | |
| print("=" * 60) | |
| print("SECTION 5: LIVE ENDPOINT VERIFICATION") | |
| print("=" * 60) | |
| PYTHON = "https://opticparse-python-sg.onrender.com" | |
| NODE = "https://opticparse-1opticparse-node-sg.onrender.com" | |
| endpoints = [ | |
| ("GET", f"{PYTHON}/health", None), | |
| ("GET", f"{NODE}/health", None), | |
| ("POST", f"{PYTHON}/gateway/keys/generate", | |
| json.dumps({"user_id": "snapshot-test"}).encode()), | |
| ("POST", f"{NODE}/api/phish-detect", | |
| json.dumps({"url": "https://example.com"}).encode()), | |
| ("GET", f"{PYTHON}/gateway/usage/snapshot-test", None), | |
| ] | |
| for method, url, data in endpoints: | |
| try: | |
| start = time.time() | |
| req = urllib.request.Request( | |
| url, method=method, data=data, | |
| headers={"Content-Type": "application/json"} | |
| ) | |
| res = urllib.request.urlopen(req, context=ctx, timeout=60) | |
| elapsed = time.time() - start | |
| body = res.read().decode("utf-8", errors="ignore")[:200] | |
| print(f" [OK] {method} {url.split('.com')[1]} -> {res.status} ({elapsed:.1f}s)") | |
| print(f" Response: {body[:120]}") | |
| except urllib.error.HTTPError as e: | |
| print(f" [WARN] {method} {url.split('.com')[1]} -> {e.code}") | |
| except Exception as e: | |
| print(f" [FAIL] {method} {url.split('.com')[1]} -> {str(e)[:80]}") | |
| print() | |
| print("=" * 60) | |
| print("SECTION 6: SECURITY AUDIT") | |
| print("=" * 60) | |
| patterns = [ | |
| (r"eyJhbGci[A-Za-z0-9._-]{50,}", "Hardcoded JWT"), | |
| (r"sk-[A-Za-z0-9]{20,}", "OpenAI key in source"), | |
| (r"service_role", "Service role key reference"), | |
| ] | |
| issues = [] | |
| scanned = 0 | |
| for root, dirs, files in os.walk("."): | |
| dirs[:] = [d for d in dirs if d not in skip] | |
| for f in files: | |
| if f.endswith((".js", ".jsx", ".ts", ".tsx", ".py", ".html")): | |
| path = os.path.join(root, f) | |
| try: | |
| with open(path, "r", encoding="utf-8", errors="ignore") as file: | |
| content = file.read() | |
| scanned += 1 | |
| for pattern, name in patterns: | |
| if re.search(pattern, content): | |
| issues.append(f"{path}: {name}") | |
| except: | |
| pass | |
| if issues: | |
| print(" Issues found:") | |
| for i in issues: | |
| print(f" - {i}") | |
| else: | |
| print(" No hardcoded secrets in source files") | |
| print(f" {scanned} files scanned") | |
| print() | |
| print("=" * 60) | |
| print("SECTION 7: DATABASE & RLS STATUS") | |
| print("=" * 60) | |
| anon_key = "" | |
| try: | |
| with open("dashboard/.env.production") as f: | |
| for line in f: | |
| if "VITE_SUPABASE_ANON_KEY" in line: | |
| anon_key = line.split("=", 1)[1].strip().strip('"').strip("'") | |
| except: | |
| pass | |
| SUPABASE_URL = "https://xxmvhvxeglsjbewlouqg.supabase.co" | |
| try: | |
| req = urllib.request.Request( | |
| f"{SUPABASE_URL}/auth/v1/settings", | |
| headers={"apikey": anon_key, "Authorization": f"Bearer {anon_key}"} | |
| ) | |
| urllib.request.urlopen(req, context=ctx) | |
| print(" [OK] Supabase anon key: VALID") | |
| except: | |
| print(" [FAIL] Supabase anon key: INVALID") | |
| try: | |
| req = urllib.request.Request( | |
| f"{SUPABASE_URL}/rest/v1/users?select=*", | |
| headers={"apikey": anon_key, "Authorization": f"Bearer {anon_key}"} | |
| ) | |
| res = urllib.request.urlopen(req, context=ctx) | |
| data = json.loads(res.read()) | |
| if len(data) == 0: | |
| print(" [OK] RLS on users table: ENFORCED (0 rows returned)") | |
| else: | |
| print(f" [FAIL] RLS BREACH: {len(data)} users exposed") | |
| except Exception as e: | |
| print(f" [OK] RLS on users table: ENFORCED (blocked)") | |
| print() | |
| print("=" * 60) | |
| print("SECTION 8: LANDING PAGE CONTENT AUDIT") | |
| print("=" * 60) | |
| try: | |
| with open("docs/index.html", "r", encoding="utf-8") as f: | |
| content = f.read() | |
| checks = { | |
| "No GPT-4o claim": "GPT-4o" not in content, | |
| "Privacy policy linked": "privacy" in content.lower(), | |
| "Terms of service linked": "terms" in content.lower(), | |
| "opticparse.com domain": "opticparse.com" in content, | |
| "Dashboard link present": "dashboard.opticparse.com" in content, | |
| "PhishVision mentioned": "PhishVision" in content, | |
| "LemonSqueezy URL": "lemonsqueezy.com" in content, | |
| "Copyright 2026": "2026" in content, | |
| "Google verification present": "google-site-verification" in content, | |
| } | |
| for check, result in checks.items(): | |
| status = "[OK]" if result else "[FAIL]" | |
| print(f" {status} {check}") | |
| except Exception as e: | |
| print(f" [ERROR] {e}") | |
| print() | |
| print("=" * 60) | |
| print("SECTION 9: DASHBOARD BUILD STATUS") | |
| print("=" * 60) | |
| dash_checks = { | |
| "dashboard/src/App.jsx exists": os.path.exists("dashboard/src/App.jsx"), | |
| "dashboard/package.json exists": os.path.exists("dashboard/package.json"), | |
| "dashboard/.env.production exists": os.path.exists("dashboard/.env.production"), | |
| "dashboard/dist exists (built)": os.path.exists("dashboard/dist"), | |
| "dashboard/public/_redirects exists": os.path.exists("dashboard/public/_redirects"), | |
| } | |
| for check, result in dash_checks.items(): | |
| status = "[OK]" if result else "[MISSING]" | |
| print(f" {status} {check}") | |
| print() | |
| try: | |
| with open("dashboard/src/App.jsx", "r", encoding="utf-8") as f: | |
| dcontent = f.read() | |
| dchecks = { | |
| "OpticParse section present": "OpticParse" in dcontent, | |
| "PhishVision section present": "PhishVision" in dcontent, | |
| "Copy button implemented": "clipboard" in dcontent.lower() or "copy" in dcontent.lower(), | |
| "Regenerate button implemented": "regenerate" in dcontent.lower() or "Regenerate" in dcontent, | |
| "API key display present": "apiKey" in dcontent or "api_key" in dcontent, | |
| "Usage stats present": "usage" in dcontent.lower(), | |
| "Both product endpoints shown": "vision-scrape" in dcontent and "phish-detect" in dcontent, | |
| } | |
| for check, result in dchecks.items(): | |
| status = "[OK]" if result else "[MISSING]" | |
| print(f" {status} {check}") | |
| except Exception as e: | |
| print(f" [ERROR] {e}") | |
| print() | |
| print("=" * 60) | |
| print("SECTION 10: RENDER & DOCKER CONFIG") | |
| print("=" * 60) | |
| print("\n--- render.yaml ---") | |
| try: | |
| with open("render.yaml") as f: | |
| print(f.read()) | |
| except: | |
| print(" [NOT FOUND]") | |
| print("--- Dockerfile ---") | |
| try: | |
| with open("Dockerfile") as f: | |
| print(f.read()) | |
| except: | |
| print(" [NOT FOUND]") | |
| print() | |
| print("=" * 60) | |
| print("SECTION 11: MIGRATIONS") | |
| print("=" * 60) | |
| migrations = sorted(glob.glob("supabase/migrations/*.sql")) | |
| if migrations: | |
| for m in migrations: | |
| print(f"\n--- {m} ---") | |
| with open(m, encoding="utf-8") as f: | |
| print(f.read()[:500]) | |
| else: | |
| print(" No migration files found") | |
| print() | |
| print("=" * 60) | |
| print("SECTION 12: WHAT IS MISSING") | |
| print("=" * 60) | |
| missing = [ | |
| ("Indian Bank Account", "No bank account — blocks real payments via Lemon Squeezy"), | |
| ("LemonSqueezy Live Mode", "Stuck in test mode — no real revenue possible"), | |
| ("MCA Incorporation", "Not incorporated — blocks government grants"), | |
| ("DPIIT Recognition", "Needs incorporation first"), | |
| ("Twitter/X Account", "No social media presence yet"), | |
| ("First Blog Post", "No content marketing yet"), | |
| ("Grant Applications", "None submitted yet (OpenAI, AWS, Azure)"), | |
| ("Google Analytics", "Only Cloudflare analytics currently"), | |
| ("ProductHunt Listing", "Not prepared yet"), | |
| ("Accelerator Applications", "Antler India, YC, 100X.VC — not applied"), | |
| ] | |
| for item, reason in missing: | |
| print(f" [TODO] {item}: {reason}") | |
| print() | |
| print("=" * 60) | |
| print("SNAPSHOT COMPLETE") | |
| print("=" * 60) | |