verify_s6.py
1.88 KB
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
import subprocess
r = subprocess.run(
["curl", "-s", "http://127.0.0.1:5000/chat", "--connect-timeout", "5", "--max-time", "10"],
capture_output=True, text=True, timeout=15
)
html = r.stdout
bugs = []
# Check key elements
for elem in ["msgList", "msgInput", "sendBtn", "convList", "emptyState"]:
search = 'id="' + elem + '"'
if search not in html:
bugs.append("MISSING ELEMENT: id=" + elem)
else:
print("OK: id=" + elem + " found")
# Check key JS functions
for fn in ["sendMessage", "handleKeyDown", "loadMessages", "selectConversation", "renderMsg"]:
if ("function " + fn) in html or (fn + "(") in html:
print("OK: " + fn + " found")
else:
bugs.append("MISSING FUNCTION: " + fn)
# Check for onclick backslash (dangerous pattern)
import re
onclick_matches = re.findall(r'onclick="[^"]*\\\\[^"]*"', html)
if onclick_matches:
bugs.append("DANGEROUS ONCLICK: " + str(len(onclick_matches)) + " matches")
else:
print("OK: No dangerous onclick patterns")
# Check for triple-escape style bug
if 'style=' in html:
style_sections = re.findall(r'style=[^>]+', html)
for s in style_sections:
if s.count('\\\\') >= 3:
bugs.append("STYLE BACKSLASH BUG: " + s[:50])
break
else:
print("OK: No style backslash bug")
# Check S6 specific features
for feat in ["EventSource", "typing-dots", "msg-list", "input-area", "stream", "msg-bubble"]:
if feat in html:
print("OK: feature " + feat + " present")
else:
print("WARN: feature " + feat + " missing")
if bugs:
print("\nBUGS FOUND:")
for b in bugs:
print(" " + b)
else:
print("\nVERIFY: ALL CLEAN")
# Check HTTP status
r2 = subprocess.run(
["curl", "-s", "-o", "/dev/null", "-w", "%{http_code}", "http://127.0.0.1:5000/chat"],
capture_output=True, text=True, timeout=10
)
print("HTTP status: " + r2.stdout.strip())