File size: 10,785 Bytes
bcf46c3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
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)