1단계=스코어카드 티저 / 2단계=풀 전문리포트+다운로드 — 구성 분리
Browse files
app.py
CHANGED
|
@@ -1,10 +1,9 @@
|
|
| 1 |
# -*- coding: utf-8 -*-
|
| 2 |
-
"""치토스(CHITOS) 인스턴트 스캔 — 공개 UI(얇은 클라이언트).
|
| 3 |
-
|
| 4 |
-
2단계 인증: 회사/조직 도메인 메일로 가입한
|
| 5 |
-
진단 대상과 일치하면 심화 진단 승인(별도 코드 발송 없음).
|
| 6 |
서비스: 퀀트ID(QuantID) · 엔진: 치토스(CHITOS)."""
|
| 7 |
-
import os, html, json
|
| 8 |
from urllib.parse import urlparse
|
| 9 |
import requests
|
| 10 |
import gradio as gr
|
|
@@ -16,8 +15,12 @@ HFTOKEN = os.environ.get("HF_TOKEN", "")
|
|
| 16 |
CONSULT = os.environ.get("CHITOS_CONSULT_ENDPOINT", "")
|
| 17 |
_eng_client = None
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
def _engine():
|
| 20 |
-
global _eng_client
|
| 21 |
global _eng_client
|
| 22 |
if _eng_client is None and ENGINE:
|
| 23 |
try:
|
|
@@ -26,9 +29,6 @@ def _engine():
|
|
| 26 |
_eng_client = Client(ENGINE, hf_token=HFTOKEN or None)
|
| 27 |
return _eng_client
|
| 28 |
|
| 29 |
-
GCOL = {"A+": "#067647", "A": "#067647", "B": "#2563eb", "C": "#b54708", "D": "#b54708", "F": "#b42318"}
|
| 30 |
-
SEV = {"hi": ("#b42318", "#fef3f2", "높음"), "mid": ("#b54708", "#fffaeb", "보완"), "low": ("#8a6d00", "#fdfce8", "낮음")}
|
| 31 |
-
|
| 32 |
|
| 33 |
def _api(path, payload):
|
| 34 |
c = _engine()
|
|
@@ -48,13 +48,13 @@ def _domain(u):
|
|
| 48 |
return (urlparse(u).hostname or "").replace("www.", "")
|
| 49 |
|
| 50 |
|
| 51 |
-
def
|
| 52 |
-
|
| 53 |
-
col = GCOL.get(
|
| 54 |
-
return ('<div style="flex:1;text-align:center;border:1px solid #e4e9ef;border-radius:14px;padding:
|
| 55 |
-
'<div style="font-size:
|
| 56 |
-
'<div style="font-size:
|
| 57 |
-
'<div style="font-size:
|
| 58 |
|
| 59 |
|
| 60 |
def _cards(items, empty):
|
|
@@ -70,8 +70,8 @@ def _cards(items, empty):
|
|
| 70 |
|
| 71 |
def _traffic(matrix):
|
| 72 |
rows = ""
|
| 73 |
-
for name, code in matrix.items():
|
| 74 |
-
ok = code
|
| 75 |
dot = "#16a34a" if ok else ("#dc2626" if code in ("403", "401", "429", "차단") else "#9ca3af")
|
| 76 |
txt = "정상" if ok else ("차단" if code in ("403", "401", "429", "차단") else code)
|
| 77 |
rows += ('<div style="display:flex;align-items:center;gap:9px;padding:6px 10px;border:1px solid #eef1f6;border-radius:8px">'
|
|
@@ -86,122 +86,194 @@ def _note(msg, sev="ok"):
|
|
| 86 |
return '<div style="border:1px solid #e4e9ef;border-left:4px solid %s;background:%s;border-radius:9px;padding:11px 14px;font-family:sans-serif;color:#374151">%s</div>' % (c, bg, msg)
|
| 87 |
|
| 88 |
|
| 89 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
if d.get("error"):
|
| 91 |
return _note("⚠ " + html.escape(d["error"]), "hi")
|
| 92 |
if d.get("blocked"):
|
| 93 |
-
return ('<div style="font-family:sans-serif;max-width:
|
| 94 |
-
'<h3 style="color:#067647">🛡
|
| 95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
meta = d.get("meta", {})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
good = "".join('<span style="display:inline-block;background:#ecfdf3;color:#067647;border-radius:999px;padding:3px 11px;font-size:12px;margin:3px 4px 0 0">✓ %s</span>' % html.escape(str(g)) for g in d.get("good", [])) or "—"
|
|
|
|
| 98 |
deep_html = ""
|
| 99 |
-
if
|
| 100 |
-
dp = d["deep"]
|
| 101 |
es = dp.get("email_sec", {})
|
| 102 |
-
def _pill(ok, t):
|
| 103 |
-
c = "#16a34a" if ok else "#dc2626"
|
| 104 |
-
|
| 105 |
-
|
|
|
|
| 106 |
incon = ""
|
| 107 |
if len(dp.get("phones", [])) > 1 or len(dp.get("addrs", [])) > 1 or len(dp.get("bizno", [])) > 1:
|
| 108 |
-
|
| 109 |
-
if len(dp.get("phones", [])) > 1:
|
| 110 |
-
|
| 111 |
-
if len(dp.get("
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
<div style="font-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
|
| 159 |
|
| 160 |
_SPIN = """<div style="text-align:center;padding:40px 0;font-family:sans-serif">
|
| 161 |
<div style="width:46px;height:46px;border:5px solid #ede9fe;border-top-color:#6d28d9;border-radius:50%;margin:0 auto;animation:chspin .8s linear infinite"></div>
|
| 162 |
<div style="margin-top:16px;color:#6d28d9;font-weight:700">치토스가 점검 중입니다...</div>
|
| 163 |
-
<div style="margin-top:4px;color:#9ca3af;font-size:12px">보안 · SEO · AI 가시성을 읽는 중 (약 10~
|
| 164 |
<style>@keyframes chspin{to{transform:rotate(360deg)}}</style></div>"""
|
| 165 |
|
|
|
|
| 166 |
def _loading():
|
| 167 |
-
return _SPIN
|
|
|
|
| 168 |
|
| 169 |
def free_scan(url):
|
| 170 |
if not (url or "").strip():
|
| 171 |
return _note("진단할 주소를 입력하세요. 예: example.com", "mid")
|
| 172 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
| 173 |
|
| 174 |
|
| 175 |
def deep_scan(url, profile: gr.OAuthProfile | None = None, oauth_token: gr.OAuthToken | None = None):
|
| 176 |
if profile is None or oauth_token is None:
|
| 177 |
-
return _note('먼저 위의 <b>"Hugging Face
|
| 178 |
if not (url or "").strip():
|
| 179 |
-
return _note("진단할 주소를 입력하세요.", "mid")
|
| 180 |
try:
|
| 181 |
-
|
| 182 |
-
email = (me.get("email") or "").lower()
|
| 183 |
except Exception:
|
| 184 |
email = ""
|
| 185 |
if not email:
|
| 186 |
-
return _note("로그인 계정의
|
| 187 |
edom = email.split("@")[-1]
|
| 188 |
tdom = _domain(url)
|
| 189 |
if edom != tdom and not tdom.endswith("." + edom) and not edom.endswith("." + tdom):
|
| 190 |
-
return _note("도메인 소유 확인 실패. 진단 대상(<b>%s</b>)의 도메인 이메일로 가입한 HF 계정으로 로그인해야 합니다. 현재 계정
|
| 191 |
d = _api("/deep", {"url": url})
|
| 192 |
-
|
| 193 |
-
|
|
|
|
|
|
|
| 194 |
|
| 195 |
|
| 196 |
def consult(name, company, email, phone, msg):
|
| 197 |
if not (name and email):
|
| 198 |
return _note("이름과 이메일은 필수입니다.", "mid")
|
| 199 |
if not CONSULT:
|
| 200 |
-
return _note("상담 접수처가 아직 설정되지 않았습니다.
|
| 201 |
try:
|
| 202 |
-
rr = requests.post(CONSULT, json={"이름": name, "회사": company or "-", "이메일": email,
|
| 203 |
-
|
| 204 |
-
return _note("상담 신청이 접수됐습니다. 퀀트ID(QuantID)에서 곧 연락드립니다. 감사합니다.", "ok") if rr.status_code < 300 else _note("접수 중 문제가 발생했습니다. 다시 시도해 주세요.", "mid")
|
| 205 |
except Exception:
|
| 206 |
return _note("접수 연결 실패. 잠시 후 다시 시도해 주세요.", "mid")
|
| 207 |
|
|
@@ -209,24 +281,26 @@ def consult(name, company, email, phone, msg):
|
|
| 209 |
CSS = "#title{text-align:center}.gradio-container{max-width:980px!important;margin:0 auto}"
|
| 210 |
with gr.Blocks(title="CHITOS 인스턴트 스캔", css=CSS, theme=gr.themes.Soft(primary_hue="purple")) as demo:
|
| 211 |
gr.HTML('<div id="title" style="padding:10px 0 4px"><div style="font-size:13px;letter-spacing:5px;color:#8b5cf6;font-weight:800">C H I T O S</div>'
|
| 212 |
-
'<h1 style="margin:6px 0;color:#2e1065">보안 · AI가시성 진단</h1>'
|
| 213 |
-
'<div style="color:#6b7280">① 무료 즉시
|
| 214 |
with gr.Tabs():
|
| 215 |
with gr.Tab("① 무료 즉시 진단 (FREE)"):
|
| 216 |
-
gr.HTML('<div style="color:#4b5563;font-size:13px;margin:4px 0 8px">주소만 넣으세요. 공격 없이(읽기전용) 보안
|
| 217 |
with gr.Row():
|
| 218 |
u1 = gr.Textbox(label="", placeholder="example.com", scale=4, container=False)
|
| 219 |
b1 = gr.Button("무료 진단", variant="primary", scale=1)
|
| 220 |
o1 = gr.HTML()
|
| 221 |
-
b1.click(
|
|
|
|
| 222 |
with gr.Tab("② 도메인 인증 심화 진단"):
|
| 223 |
gr.HTML('<div style="color:#4b5563;font-size:13px;margin:4px 0 8px"><b>회사/조직 도메인 이메일로 가입한 Hugging Face 계정</b>으로 로그인하세요. '
|
| 224 |
-
'
|
| 225 |
gr.LoginButton()
|
| 226 |
u2 = gr.Textbox(label="진단할 주소", placeholder="example.com")
|
| 227 |
b2 = gr.Button("인증 후 심화 진단", variant="primary")
|
|
|
|
| 228 |
o2 = gr.HTML()
|
| 229 |
-
b2.click(_loading, None, o2).then(deep_scan, inputs=u2, outputs=o2)
|
| 230 |
with gr.Tab("③ 정밀 진단 상담"):
|
| 231 |
gr.HTML('<div style="color:#4b5563;font-size:13px;margin:4px 0 8px">금융보안원 17종 에이전트 보안·소스 코드 취약점·능동 점검 등 <b>정밀 진단</b> 상담 신청.</div>')
|
| 232 |
with gr.Row():
|
|
|
|
| 1 |
# -*- coding: utf-8 -*-
|
| 2 |
+
"""치토스(CHITOS) 인스턴트 스캔 — 공개 UI(얇은 클라이언트) + 전문 리포트 생성.
|
| 3 |
+
로직·채점은 비공개 엔진(치토스 서버)에서 수행 → 이 공개 소스엔 방법이 없습니다.
|
| 4 |
+
2단계 인증: 회사/조직 도메인 메일로 가입한 HF 계정 로그인 → 이메일 도메인 일치 시 심화.
|
|
|
|
| 5 |
서비스: 퀀트ID(QuantID) · 엔진: 치토스(CHITOS)."""
|
| 6 |
+
import os, html, json, tempfile, datetime
|
| 7 |
from urllib.parse import urlparse
|
| 8 |
import requests
|
| 9 |
import gradio as gr
|
|
|
|
| 15 |
CONSULT = os.environ.get("CHITOS_CONSULT_ENDPOINT", "")
|
| 16 |
_eng_client = None
|
| 17 |
|
| 18 |
+
GCOL = {"A+": "#067647", "A": "#067647", "B": "#2563eb", "C": "#b54708", "D": "#b54708", "F": "#b42318", "-": "#9ca3af"}
|
| 19 |
+
SEV = {"hi": ("#b42318", "#fef3f2", "높음"), "mid": ("#b54708", "#fffaeb", "보완"), "low": ("#8a6d00", "#fdfce8", "낮음")}
|
| 20 |
+
SEVRANK = {"hi": 0, "mid": 1, "low": 2}
|
| 21 |
+
|
| 22 |
+
|
| 23 |
def _engine():
|
|
|
|
| 24 |
global _eng_client
|
| 25 |
if _eng_client is None and ENGINE:
|
| 26 |
try:
|
|
|
|
| 29 |
_eng_client = Client(ENGINE, hf_token=HFTOKEN or None)
|
| 30 |
return _eng_client
|
| 31 |
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
def _api(path, payload):
|
| 34 |
c = _engine()
|
|
|
|
| 48 |
return (urlparse(u).hostname or "").replace("www.", "")
|
| 49 |
|
| 50 |
|
| 51 |
+
def _badge(g, label, sub):
|
| 52 |
+
L, s = g[0], g[1]
|
| 53 |
+
col = GCOL.get(L, "#b54708")
|
| 54 |
+
return ('<div style="flex:1;text-align:center;border:1px solid #e4e9ef;border-radius:14px;padding:16px">'
|
| 55 |
+
'<div style="font-size:12.5px;color:#6b7280;font-weight:700">%s</div>'
|
| 56 |
+
'<div style="font-size:46px;font-weight:900;line-height:1;color:%s;margin:5px 0">%s</div>'
|
| 57 |
+
'<div style="font-size:11px;color:#9ca3af">%s/100 · %s</div></div>') % (label, col, L, s, sub)
|
| 58 |
|
| 59 |
|
| 60 |
def _cards(items, empty):
|
|
|
|
| 70 |
|
| 71 |
def _traffic(matrix):
|
| 72 |
rows = ""
|
| 73 |
+
for name, code in (matrix or {}).items():
|
| 74 |
+
ok = code in ("200", "302", "301")
|
| 75 |
dot = "#16a34a" if ok else ("#dc2626" if code in ("403", "401", "429", "차단") else "#9ca3af")
|
| 76 |
txt = "정상" if ok else ("차단" if code in ("403", "401", "429", "차단") else code)
|
| 77 |
rows += ('<div style="display:flex;align-items:center;gap:9px;padding:6px 10px;border:1px solid #eef1f6;border-radius:8px">'
|
|
|
|
| 86 |
return '<div style="border:1px solid #e4e9ef;border-left:4px solid %s;background:%s;border-radius:9px;padding:11px 14px;font-family:sans-serif;color:#374151">%s</div>' % (c, bg, msg)
|
| 87 |
|
| 88 |
|
| 89 |
+
def _h2(t):
|
| 90 |
+
return '<h2 style="font-size:18px;color:#2e1065;border-bottom:2px solid #6d28d9;padding-bottom:7px;margin:24px 0 12px">%s</h2>' % t
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
def _priority(allf):
|
| 94 |
+
def li(lst, when, col):
|
| 95 |
+
if not lst:
|
| 96 |
+
return ""
|
| 97 |
+
items = "".join("<li style='margin:3px 0'>%s</li>" % html.escape(str(f[1])) for f in lst)
|
| 98 |
+
return ('<div style="border:1px solid #e4e9ef;border-left:4px solid %s;border-radius:9px;padding:10px 14px;margin:7px 0">'
|
| 99 |
+
'<b style="color:%s">%s</b><ul style="margin:6px 0 0 2px;padding-left:18px;font-size:13px;color:#374151">%s</ul></div>') % (col, col, when, items)
|
| 100 |
+
hi = [f for f in allf if f[0] == "hi"]
|
| 101 |
+
mid = [f for f in allf if f[0] == "mid"]
|
| 102 |
+
low = [f for f in allf if f[0] == "low"]
|
| 103 |
+
out = li(hi, "즉시 (높음)", "#b42318") + li(mid, "단기 (보완)", "#b54708") + li(low, "중기 (낮음)", "#8a6d00")
|
| 104 |
+
return out or "<div style='color:#067647'>✓ 시급 조치 없음</div>"
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
def build_teaser(d):
|
| 108 |
+
"""1단계 무료 = 짧은 스코어카드 + ���장 급한 것 + AI신호등 + 2단계 유도. (전문 리포트 아님)"""
|
| 109 |
if d.get("error"):
|
| 110 |
return _note("⚠ " + html.escape(d["error"]), "hi")
|
| 111 |
if d.get("blocked"):
|
| 112 |
+
return ('<div style="font-family:sans-serif;max-width:720px;margin:0 auto;border:1px solid #e4e9ef;border-radius:12px;padding:20px">'
|
| 113 |
+
'<h3 style="color:#067647">🛡 자동 공격 차단(WAF) 작동 중</h3><p>비정상 접근을 탐지해 차단했습니다. <b>방어가 잘 되어 있다는 신호</b>입니다. 치토스는 차단을 우회하지 않습니다.</p></div>')
|
| 114 |
+
host = d.get("host", "")
|
| 115 |
+
allf = list(d.get("sec", [])) + list(d.get("seo", [])) + list(d.get("geo", []))
|
| 116 |
+
top = [f for f in allf if f[0] == "hi"] + [f for f in allf if f[0] == "mid"]
|
| 117 |
+
top = top[:3]
|
| 118 |
+
topcards = _cards(top, "✓ 눈에 띄는 시급 이슈 없음")
|
| 119 |
+
return ('<div style="font-family:sans-serif;max-width:720px;margin:0 auto">'
|
| 120 |
+
'<div style="text-align:center;color:#6b7280;font-size:12.5px;margin-bottom:8px">⚡ 무료 빠른 진단 · <b>' + html.escape(host) + '</b> · 홈 1페이지 · 비침투</div>'
|
| 121 |
+
'<div style="display:flex;gap:10px;margin-bottom:10px">'
|
| 122 |
+
+ _badge(d["sec_grade"], "🛡 보안", "자물쇠 " + str(d.get("locks_on", 0)) + "/6")
|
| 123 |
+
+ _badge(d.get("seo_grade", ["-", "-"]), "📈 SEO", "검색 토대")
|
| 124 |
+
+ _badge(d["geo_grade"], "🔍 AI가시성", "검색·AI 노출") + '</div>'
|
| 125 |
+
+ '<h3 style="color:#b42318;font-size:15px;margin:14px 0 6px">⚡ 가장 급한 것 (상위 ' + str(len(top)) + ')</h3>' + topcards
|
| 126 |
+
+ '<h3 style="color:#2e1065;font-size:15px;margin:16px 0 6px">🤖 AI 로봇이 내 사이트에 들어올 수 있나</h3>'
|
| 127 |
+
+ _traffic(d.get("matrix", {}))
|
| 128 |
+
+ '<div style="background:linear-gradient(135deg,#6d28d9,#8b5cf6);color:#fff;border-radius:12px;padding:16px 18px;margin-top:18px">'
|
| 129 |
+
'<div style="font-weight:800;font-size:15px">🔓 전사이트 정밀 리포트가 더 있습니다</div>'
|
| 130 |
+
'<div style="font-size:13px;opacity:.92;margin-top:6px">지금은 <b>홈 1페이지 요약</b>입니다. <b>② 도메인 인증 탭</b>에서 회사/조직 도메인 메일로 가입한 Hugging Face 계정으로 로그인하면 — '
|
| 131 |
+
'전사이트 페이지별 이슈 · 구조화데이터 커버리지 · <b>이메일 위조방지(SPF/DMARC)</b> · <b>자기모순(주소·전화) 탐지</b> · 조치 우선순위 · <b>다운로드 리포트</b>까지 받습니다.</div></div>'
|
| 132 |
+
'<div style="text-align:center;color:#9ca3af;font-size:11px;margin-top:12px">서비스: 퀀트ID(QuantID) · 엔진: 치토스(CHITOS)</div></div>')
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
def build_report(d, deep=False, verified_email=None):
|
| 136 |
+
if d.get("error"):
|
| 137 |
+
return _note("⚠ " + html.escape(d["error"]), "hi")
|
| 138 |
+
if d.get("blocked"):
|
| 139 |
+
return ('<div style="font-family:sans-serif;max-width:860px;margin:0 auto;border:1px solid #e4e9ef;border-radius:12px;padding:20px">'
|
| 140 |
+
'<h3 style="color:#067647">🛡 자동 공격 차단(WAF) 작동 중</h3>'
|
| 141 |
+
'<p>비정상 접근을 탐지해 차단했습니다. <b>방어가 잘 되어 있다는 좋은 신호</b>입니다. 치토스는 차단을 우회하지 않습니다(읽기전용).</p></div>')
|
| 142 |
+
host = d.get("host", "")
|
| 143 |
meta = d.get("meta", {})
|
| 144 |
+
today = datetime.date.today().isoformat()
|
| 145 |
+
sec, seo, geo = d.get("sec", []), d.get("seo", []), d.get("geo", [])
|
| 146 |
+
allf = list(sec) + list(seo) + list(geo)
|
| 147 |
+
dp = d.get("deep", {}) if deep else {}
|
| 148 |
+
if dp:
|
| 149 |
+
allf += dp.get("issues", [])
|
| 150 |
+
nhi = len([f for f in allf if f[0] == "hi"])
|
| 151 |
+
nmid = len([f for f in allf if f[0] == "mid"])
|
| 152 |
+
nlow = len([f for f in allf if f[0] == "low"])
|
| 153 |
good = "".join('<span style="display:inline-block;background:#ecfdf3;color:#067647;border-radius:999px;padding:3px 11px;font-size:12px;margin:3px 4px 0 0">✓ %s</span>' % html.escape(str(g)) for g in d.get("good", [])) or "—"
|
| 154 |
+
|
| 155 |
deep_html = ""
|
| 156 |
+
if dp:
|
|
|
|
| 157 |
es = dp.get("email_sec", {})
|
| 158 |
+
def _pill(ok, t):
|
| 159 |
+
c = "#16a34a" if ok else "#dc2626"
|
| 160 |
+
return '<span style="background:%s22;color:%s;border-radius:999px;padding:3px 11px;font-size:12px;font-weight:700">%s %s</span>' % (c, c, ("✓" if ok else "✕"), t)
|
| 161 |
+
sch = "".join('<span style="background:#ecfdf3;color:#067647;border-radius:6px;padding:2px 8px;font-size:11.5px;margin:2px;display:inline-block">%s</span>' % html.escape(x) for x in dp.get("schema_present", [])) or "없음"
|
| 162 |
+
schm = "".join('<span style="background:#fef3f2;color:#b42318;border-radius:6px;padding:2px 8px;font-size:11.5px;margin:2px;display:inline-block">%s</span>' % html.escape(x) for x in dp.get("schema_missing", [])) or "—"
|
| 163 |
incon = ""
|
| 164 |
if len(dp.get("phones", [])) > 1 or len(dp.get("addrs", [])) > 1 or len(dp.get("bizno", [])) > 1:
|
| 165 |
+
r = ""
|
| 166 |
+
if len(dp.get("phones", [])) > 1:
|
| 167 |
+
r += '<tr><td style="border:1px solid #e4e9ef;padding:6px">전화</td><td style="border:1px solid #e4e9ef;padding:6px">%s</td></tr>' % html.escape(", ".join(dp["phones"]))
|
| 168 |
+
if len(dp.get("addrs", [])) > 1:
|
| 169 |
+
r += '<tr><td style="border:1px solid #e4e9ef;padding:6px">주소</td><td style="border:1px solid #e4e9ef;padding:6px">%s</td></tr>' % html.escape(" / ".join(dp["addrs"]))
|
| 170 |
+
if len(dp.get("bizno", [])) > 1:
|
| 171 |
+
r += '<tr><td style="border:1px solid #e4e9ef;padding:6px">사업자번호</td><td style="border:1px solid #e4e9ef;padding:6px">%s</td></tr>' % html.escape(", ".join(dp["bizno"]))
|
| 172 |
+
incon = '<h4 style="color:#b54708;margin-top:14px">⚠ 확인 필요 — 사이트 안에서 다르게 보이는 값</h4><table style="width:100%;border-collapse:collapse;font-size:12.5px"><tr><th style="text-align:left;border:1px solid #e4e9ef;padding:6px;background:#f5f8fc">항목</th><th style="text-align:left;border:1px solid #e4e9ef;padding:6px;background:#f5f8fc">발견 값</th></tr>' + r + '</table>'
|
| 173 |
+
pglist = "".join('<div style="font-size:11.5px;color:#4b5563;padding:3px 0;border-bottom:1px dashed #eef1f6">%s %s <span style="color:#9ca3af">%s</span></div>' % (('✓' if c.get('meta') else '⚠'), html.escape(c.get('title') or c.get('url', '')), html.escape(c.get('url', ''))) for c in dp.get("crawled", [])[:12])
|
| 174 |
+
deep_html = (
|
| 175 |
+
'<div style="background:#ede9fe;border-radius:10px;padding:10px 14px;margin-top:4px;color:#5b21b6;font-weight:700">🔓 소유 인증 전용 심화 — 전사이트 %d페이지 정밀 분석 (비침투)</div>' % dp.get("pages", 0)
|
| 176 |
+
+ _h2("🔎 심화 발견") + _cards(dp.get("issues", []), "✓ 심화 점검 추가 이슈 없음")
|
| 177 |
+
+ _h2("📊 전사이트 요약")
|
| 178 |
+
+ ('<table style="width:100%%;border-collapse:collapse;font-size:12.5px"><tr><td style="border:1px solid #e4e9ef;padding:7px">점검 페이지</td><td style="border:1px solid #e4e9ef;padding:7px"><b>%d</b></td><td style="border:1px solid #e4e9ef;padding:7px">제목 중복</td><td style="border:1px solid #e4e9ef;padding:7px"><b>%d</b></td></tr><tr><td style="border:1px solid #e4e9ef;padding:7px">메타설명 없음</td><td style="border:1px solid #e4e9ef;padding:7px"><b>%d</b></td><td style="border:1px solid #e4e9ef;padding:7px">얇은 페이지</td><td style="border:1px solid #e4e9ef;padding:7px"><b>%d</b></td></tr><tr><td style="border:1px solid #e4e9ef;padding:7px">색인차단</td><td style="border:1px solid #e4e9ef;padding:7px"><b>%d</b></td><td style="border:1px solid #e4e9ef;padding:7px">canonical 없음</td><td style="border:1px solid #e4e9ef;padding:7px"><b>%d</b></td></tr></table>' % (dp.get("pages", 0), dp.get("dup_titles", 0), dp.get("no_meta", 0), dp.get("thin", 0), dp.get("noindex", 0), dp.get("no_canonical", 0)))
|
| 179 |
+
+ _h2("🧩 구조화 데이터 커버리지") + '<div style="font-size:12.5px"><b style="color:#067647">보유:</b> ' + sch + '<br><b style="color:#b42318;display:inline-block;margin-top:6px">누락:</b> ' + schm + '</div>'
|
| 180 |
+
+ _h2("📧 이메일 위조 방지") + '<div style="display:flex;gap:10px">' + _pill(es.get("spf"), "SPF") + " " + _pill(es.get("dmarc"), "DMARC") + '</div>'
|
| 181 |
+
+ incon
|
| 182 |
+
+ _h2("🗂 점검 페이지 (%d)" % dp.get("pages", 0)) + '<div style="max-height:220px;overflow:auto;border:1px solid #eef1f6;border-radius:8px;padding:8px 12px">' + pglist + '</div>'
|
| 183 |
+
)
|
| 184 |
+
|
| 185 |
+
vbanner = ('<div style="background:#ecfdf3;border:1px solid #a7f3d0;border-radius:10px;padding:10px 14px;color:#065f46;font-size:13px;margin-bottom:10px">✓ 도메인 소유 인증 완료(<b>%s</b>) — 심화 진단 포함</div>' % html.escape(verified_email)) if verified_email else ""
|
| 186 |
+
kind = "심화 진단" if deep else "인스턴트 진단"
|
| 187 |
+
title80 = html.escape(str(meta.get('title') or '(없음)'))[:80]
|
| 188 |
+
body = ('<div style="font-family:\'Malgun Gothic\',sans-serif;max-width:880px;margin:0 auto;color:#0e1621">'
|
| 189 |
+
'<div style="background:linear-gradient(135deg,#2e1065,#4c1d95 60%,#7c3aed 150%);color:#fff;border-radius:16px;padding:24px 26px;margin-bottom:14px">'
|
| 190 |
+
'<div style="font-size:12px;letter-spacing:5px;color:#d6bcff;font-weight:800">C H I T O S · ' + kind + '</div>'
|
| 191 |
+
'<div style="font-size:24px;font-weight:800;margin:8px 0 2px">보안 · SEO · AI가시성 진단 리포트</div>'
|
| 192 |
+
'<div style="opacity:.85;font-size:13px">대상 ' + html.escape(host) + ' · ' + today + ' · 비침투(읽기전용)</div></div>'
|
| 193 |
+
+ vbanner
|
| 194 |
+
+ '<div style="display:flex;gap:10px;margin-bottom:6px">'
|
| 195 |
+
+ _badge(d['sec_grade'], "🛡 보안", "자물쇠 " + str(d.get('locks_on', 0)) + "/6")
|
| 196 |
+
+ _badge(d.get('seo_grade', ['-', '-']), "📈 SEO", "검색 토대")
|
| 197 |
+
+ _badge(d['geo_grade'], "🔍 AI가시성", "검색·AI 노출") + '</div>'
|
| 198 |
+
+ '<div style="display:flex;gap:10px;text-align:center;margin:10px 0">'
|
| 199 |
+
+ '<div style="flex:1;border:1px solid #e4e9ef;border-radius:10px;padding:10px"><b style="color:#b42318;font-size:22px">%d</b><div style="font-size:11px;color:#6b7280">높음</div></div>' % nhi
|
| 200 |
+
+ '<div style="flex:1;border:1px solid #e4e9ef;border-radius:10px;padding:10px"><b style="color:#b54708;font-size:22px">%d</b><div style="font-size:11px;color:#6b7280">보완</div></div>' % nmid
|
| 201 |
+
+ '<div style="flex:1;border:1px solid #e4e9ef;border-radius:10px;padding:10px"><b style="color:#8a6d00;font-size:22px">%d</b><div style="font-size:11px;color:#6b7280">낮음</div></div>' % nlow
|
| 202 |
+
+ '</div>'
|
| 203 |
+
+ _h2("🛡 보안 점검") + _cards(sec, "✓ 외부에서 보이는 보안 위생 문제 없음")
|
| 204 |
+
+ _h2("📈 SEO 토대 (검색 노출)") + _cards(seo, "✓ SEO 기본 요소 양호")
|
| 205 |
+
+ _h2("🤖 AI 로봇 접근 (AI 가시성)")
|
| 206 |
+
+ '<div style="font-size:12.5px;color:#4b5563;margin:4px 0 8px">생성형 AI가 당신을 인용하려면 로봇이 먼저 들어와야 합니다.</div>'
|
| 207 |
+
+ _traffic(d.get('matrix', {})) + _cards(geo, "✓ 기계 판독 신호 양호")
|
| 208 |
+
+ '<div style="font-size:12px;color:#6b7280;margin-top:6px">제목: ' + title80 + ' · H1 ' + str(meta.get('h1', 0)) + ' · 구조화 ' + str(meta.get('jsonld', 0)) + ' · 홈 ' + str(meta.get('size_kb', 0)) + 'KB · alt ' + str(meta.get('alt_cov', 0)) + '%</div>'
|
| 209 |
+
+ deep_html
|
| 210 |
+
+ _h2("✓ 잘 되어 있는 점") + '<div>' + good + '</div>'
|
| 211 |
+
+ _h2("📌 조치 우선순위") + _priority(allf)
|
| 212 |
+
+ '<div style="background:#f4f0ff;border:1px dashed #b89cff;border-radius:12px;padding:14px 16px;margin-top:16px"><b style="color:#6d28d9">정밀 진단 안내</b><br><span style="font-size:13px;color:#374151">본 진단은 <b>비침투(읽기전용)</b>입니다. SQL삽입·파일업로드·인증우회 등 실제 취약점과 금융보안원 17종 에이전트 보안 정밀 점검은 <b>상담(3단계)</b>으로 제공합니다.</span></div>'
|
| 213 |
+
+ '<div style="color:#9ca3af;font-size:11px;margin-top:14px;border-top:1px solid #e4e9ef;padding-top:10px">본 진단은 비침투·비파괴로 수행되었으며 대상 서비스에 영향을 주지 않았습니다. 결과는 측정 시점(' + today + ') 기준. 서비스: 퀀트ID(QuantID) · 엔진: 치토스(CHITOS).</div>'
|
| 214 |
+
+ '</div>')
|
| 215 |
+
return body
|
| 216 |
+
|
| 217 |
+
|
| 218 |
+
def _save_html(body, host, deep):
|
| 219 |
+
full = "<!doctype html><html lang='ko'><head><meta charset='utf-8'><title>CHITOS 진단 %s</title></head><body style='background:#eef1f5;margin:0;padding:20px'>%s</body></html>" % (html.escape(host), body)
|
| 220 |
+
fn = os.path.join(tempfile.gettempdir(), "CHITOS_%s_%s.html" % (host.replace(".", "_"), "deep" if deep else "free"))
|
| 221 |
+
with open(fn, "w", encoding="utf-8") as f:
|
| 222 |
+
f.write(full)
|
| 223 |
+
return fn
|
| 224 |
|
| 225 |
|
| 226 |
_SPIN = """<div style="text-align:center;padding:40px 0;font-family:sans-serif">
|
| 227 |
<div style="width:46px;height:46px;border:5px solid #ede9fe;border-top-color:#6d28d9;border-radius:50%;margin:0 auto;animation:chspin .8s linear infinite"></div>
|
| 228 |
<div style="margin-top:16px;color:#6d28d9;font-weight:700">치토스가 점검 중입니다...</div>
|
| 229 |
+
<div style="margin-top:4px;color:#9ca3af;font-size:12px">보안 · SEO · AI 가시성을 읽는 중 (약 10~25초)</div>
|
| 230 |
<style>@keyframes chspin{to{transform:rotate(360deg)}}</style></div>"""
|
| 231 |
|
| 232 |
+
|
| 233 |
def _loading():
|
| 234 |
+
return gr.update(value=_SPIN), gr.update(visible=False)
|
| 235 |
+
|
| 236 |
|
| 237 |
def free_scan(url):
|
| 238 |
if not (url or "").strip():
|
| 239 |
return _note("진단할 주소를 입력하세요. 예: example.com", "mid")
|
| 240 |
+
return build_teaser(_api("/scan", {"url": url}))
|
| 241 |
+
|
| 242 |
+
|
| 243 |
+
def _spin1():
|
| 244 |
+
return _SPIN
|
| 245 |
|
| 246 |
|
| 247 |
def deep_scan(url, profile: gr.OAuthProfile | None = None, oauth_token: gr.OAuthToken | None = None):
|
| 248 |
if profile is None or oauth_token is None:
|
| 249 |
+
return _note('먼저 위의 <b>"Sign in with Hugging Face"</b> 버튼으로 로그인하세요. (회사/조직 도메인 메일로 가입한 계정)', "mid"), gr.update(visible=False)
|
| 250 |
if not (url or "").strip():
|
| 251 |
+
return _note("진단할 주소를 입력하세요.", "mid"), gr.update(visible=False)
|
| 252 |
try:
|
| 253 |
+
email = (whoami(token=oauth_token.token).get("email") or "").lower()
|
|
|
|
| 254 |
except Exception:
|
| 255 |
email = ""
|
| 256 |
if not email:
|
| 257 |
+
return _note("로그인 계정의 인증된 이메일을 읽지 못했습니다. HF 계정 이메일 인증 후 다시 시도하세요.", "hi"), gr.update(visible=False)
|
| 258 |
edom = email.split("@")[-1]
|
| 259 |
tdom = _domain(url)
|
| 260 |
if edom != tdom and not tdom.endswith("." + edom) and not edom.endswith("." + tdom):
|
| 261 |
+
return _note("도메인 소유 확인 실패. 진단 대상(<b>%s</b>)의 도메인 이메일로 가입한 HF 계정으로 로그인해야 합니다. 현재 계정 도메인: <b>%s</b>" % (html.escape(tdom), html.escape(edom)), "hi"), gr.update(visible=False)
|
| 262 |
d = _api("/deep", {"url": url})
|
| 263 |
+
body = build_report(d, deep=True, verified_email=email)
|
| 264 |
+
if d.get("error") or d.get("blocked"):
|
| 265 |
+
return body, gr.update(visible=False)
|
| 266 |
+
return body, gr.update(value=_save_html(body, d.get("host", "site"), True), visible=True)
|
| 267 |
|
| 268 |
|
| 269 |
def consult(name, company, email, phone, msg):
|
| 270 |
if not (name and email):
|
| 271 |
return _note("이름과 이메일은 필수입니다.", "mid")
|
| 272 |
if not CONSULT:
|
| 273 |
+
return _note("상담 접수처가 아직 설정되지 않았습니다.", "mid")
|
| 274 |
try:
|
| 275 |
+
rr = requests.post(CONSULT, json={"이름": name, "회사": company or "-", "이메일": email, "연락처": phone or "-", "문의": msg or "-", "_subject": "[CHITOS] 정밀진단 상담신청"}, timeout=15)
|
| 276 |
+
return _note("상담 신청이 접수됐습니다. 퀀트ID(QuantID)에서 곧 연락드립니다.", "ok") if rr.status_code < 300 else _note("접수 중 문제가 발생했습니다. 다시 시도해 주세요.", "mid")
|
|
|
|
| 277 |
except Exception:
|
| 278 |
return _note("접수 연결 실패. 잠시 후 다시 시도해 주세요.", "mid")
|
| 279 |
|
|
|
|
| 281 |
CSS = "#title{text-align:center}.gradio-container{max-width:980px!important;margin:0 auto}"
|
| 282 |
with gr.Blocks(title="CHITOS 인스턴트 스캔", css=CSS, theme=gr.themes.Soft(primary_hue="purple")) as demo:
|
| 283 |
gr.HTML('<div id="title" style="padding:10px 0 4px"><div style="font-size:13px;letter-spacing:5px;color:#8b5cf6;font-weight:800">C H I T O S</div>'
|
| 284 |
+
'<h1 style="margin:6px 0;color:#2e1065">보안 · SEO · AI가시성 진단</h1>'
|
| 285 |
+
'<div style="color:#6b7280">① 무료 즉시 리포트 → ② 도메인 메일 HF 로그인 심화 리포트 → ③ 정밀 진단 상담</div></div>')
|
| 286 |
with gr.Tabs():
|
| 287 |
with gr.Tab("① 무료 즉시 진단 (FREE)"):
|
| 288 |
+
gr.HTML('<div style="color:#4b5563;font-size:13px;margin:4px 0 8px">주소만 넣으세요. 공격 없이(읽기전용) 보안·SEO·AI가시성 전문 리포트를 생성합니다.</div>')
|
| 289 |
with gr.Row():
|
| 290 |
u1 = gr.Textbox(label="", placeholder="example.com", scale=4, container=False)
|
| 291 |
b1 = gr.Button("무료 진단", variant="primary", scale=1)
|
| 292 |
o1 = gr.HTML()
|
| 293 |
+
b1.click(_spin1, None, o1).then(free_scan, u1, o1)
|
| 294 |
+
u1.submit(_spin1, None, o1).then(free_scan, u1, o1)
|
| 295 |
with gr.Tab("② 도메인 인증 심화 진단"):
|
| 296 |
gr.HTML('<div style="color:#4b5563;font-size:13px;margin:4px 0 8px"><b>회사/조직 도메인 이메일로 가입한 Hugging Face 계정</b>으로 로그인하세요. '
|
| 297 |
+
'이메일 도메인이 진단 대상과 일치하면(소유 확인) 전사이트 심화 리포트가 열립니다. 별도 인증코드 발송은 없습니다.</div>')
|
| 298 |
gr.LoginButton()
|
| 299 |
u2 = gr.Textbox(label="진단할 주소", placeholder="example.com")
|
| 300 |
b2 = gr.Button("인증 후 심화 진단", variant="primary")
|
| 301 |
+
f2 = gr.File(label="심화 리포트 다운로드 (HTML)", visible=False)
|
| 302 |
o2 = gr.HTML()
|
| 303 |
+
b2.click(_loading, None, [o2, f2]).then(deep_scan, inputs=u2, outputs=[o2, f2])
|
| 304 |
with gr.Tab("③ 정밀 진단 상담"):
|
| 305 |
gr.HTML('<div style="color:#4b5563;font-size:13px;margin:4px 0 8px">금융보안원 17종 에이전트 보안·소스 코드 취약점·능동 점검 등 <b>정밀 진단</b> 상담 신청.</div>')
|
| 306 |
with gr.Row():
|