4.1.7 · Scorecard + known bugs
บทสรุปของ 4.1.1 ถึง 4.1.6 — จัด severity ของทุก finding และให้สุขภาพ repo แบบภาพรวม
Severity legend
| Level | เกณฑ์ | Action |
|---|---|---|
| 🔴 Critical | active security/data-loss/availability risk | ต้องแก้ก่อน deploy ถัดไป |
| 🟡 High | correctness/maintainability hazard, real impact | วางแผนแก้ใน quarter นี้ |
| 🟢 Medium | friction/hygiene, ยังไม่อันตรายระดับ active | แก้ตามโอกาส |
Severity: Critical (🔴)
| ID | Finding | ที่มา | บท |
|---|---|---|---|
SEC-VTRC-WEB-01 | Token ใน localStorage — XSS accessible | utils/auth.js (setToken/getToken) | 4.1.5 |
SEC-VTRC-WEB-02 | dangerouslySetInnerHTML หลายสิบไฟล์ — XSS risk | กระจายใน pages/user/ (News, Policy, About detail) | 4.1.5 |
SEC-VTRC-WEB-03 | ไม่มี CSP header | nginx config | 4.1.5 |
SEC-VTRC-WEB-04 | ไม่มี SRI hash บน bundle | public/index.html | 4.1.5 |
Severity: High (🟡)
| ID | Finding | ที่มา | บท |
|---|---|---|---|
PERF-VTRC-WEB-01 | Bundle 12MB — TTI ~5-8s | package.json + ไม่มี code splitting | 4.1.6 |
PERF-VTRC-WEB-02 | fetchPolicy: 'cache-first' default — ข้อมูลเก่า | config/apollo.js | 4.1.6 |
SEC-VTRC-WEB-05 | ไม่มี ErrorBoundary — white screen บน crash | containers/App/index.js | 4.1.5 |
SEC-VTRC-WEB-06 | checkLinkURL() env branching ที่ client | config/apollo.js:checkLinkURL | 4.1.5 |
SEC-VTRC-WEB-07 | Console log ใน production | กระจาย (console.log) | 4.1.5 |
QUAL-VTRC-WEB-01 | from/ folder typo — ห้ามแก้ import | components/user/from/ | 4.1.2 |
QUAL-VTRC-WEB-02 | GraphQL queries ไม่มี fragment — field ซ้ำทุก query | graphql/queries.js | 4.1.2 |
Severity: Medium (🟢)
| ID | Finding | ที่มา | บท |
|---|---|---|---|
PERF-VTRC-WEB-03 | ไม่มี service worker | serviceWorker.js | 4.1.6 |
PERF-VTRC-WEB-04 | Image ไม่ optimize | public/, src/assets/images/ | 4.1.6 |
PERF-VTRC-WEB-05 | No HTTP/2 push | nginx config | 4.1.6 |
SEC-VTRC-WEB-08 | ไม่มี auth gate ที่ root | containers/App/index.js | 4.1.5 |
SEC-VTRC-WEB-09 | ไม่มี CSRF protection | ทุก mutation | 4.1.5 |
LEG-VTRC-WEB-01 | Webpack 4 + Node 14 (EOL) | Dockerfile, package.json | 4.1.6 |
QUAL-VTRC-WEB-03 | console.log ทุกที่ — debug noise | กระจาย | 4.1.2 |
QUAL-VTRC-WEB-04 | Snapshot ไฟล์ legacy (queries_pentest.js, querries_prd.js) | src/graphql/ | 4.1.2 |
OBS-VTRC-WEB-01 | ไม่มี structured logging ฝั่ง client | — | 4.1.5 |
Health Scorecard
| Dimension | สถานะ | เหตุผล |
|---|---|---|
| Auth/token handling | 🔴 | localStorage + no refresh token rotation policy |
| XSS protection | 🔴 | dangerouslySetInnerHTML ทั่ว + no CSP + no SRI |
| Routing & state | 🟡 | class component pattern เสถียร แต่ no central auth gate |
| Component architecture | 🟡 | class + withApollo เสถียร แต่ no code splitting |
| GraphQL strategy | 🟡 | Apollo v2 + cache-first — works แต่ stale risk |
| Performance | 🔴 | bundle 12MB, TTI 5-8s, no optimization |
| Build pipeline | 🟡 | Webpack 4 + Node 14 (EOL) — works แต่ล้าสมัย |
| Observability | 🟡 | console.log กระจาย, ไม่มี error reporting |
| Test coverage | 🔴 | ไม่พบ test suite |
| Dependency freshness | 🟡 | React 16, AntD 3, Webpack 4 — ทุกตัว EOL |
คะแนนรวม: 0 🟢 / 4 🟡 / 6 🔴 — repo ใช้งานได้แต่มี technical debt สะสม
Public contract — สิ่งที่ต้อง maintain
| รายการ | ที่ตั้ง | เหตุผลที่ต้องคง |
|---|---|---|
from/ folder typo | components/user/from/ | import ทุกที่อ้างถึง — rename ต้อง update import ทั้งหมด |
AntD v3 getFieldDecorator API | กระจายทั่ว forms | API ไม่มีใน v4 — upgrade AntD ต้อง rewrite ทุก form |
moment.js th_TH locale + Buddhist year | กระจาย | change library ต้อง sync Buddhist year conversion |
| GraphQL operation name (PascalCase) | queries.js, mutations.js | backend resolver matching |
Mutations.login (no suffix) | mutations.js | ต่างจาก Mutations.loginBackoffice ของ vtrc-rc-backoffice |
apiKeyNews() helper | utils/apiKey.js | returns device key for WEB APP_TYPE |
Modernization priority (ROI-weighted)
dompurifyสำหรับdangerouslySetInnerHTML— ลบ SEC-VTRC-WEB-02, investment เล็ก, impact ใหญ่- CSP header — ลบ SEC-VTRC-WEB-03, investment นิดเดียว
- Code splitting — ลด TTI, investment ปานกลาง
- AntD tree-shake — ลด bundle ~600KB, investment เล็ก
- Replace moment.js — ลด bundle ~250KB, investment ปานกลาง
- HttpOnly cookie สำหรับ token — ลบ SEC-VTRC-WEB-01, investment ใหญ่ (เปลี่ยนทั้ง frontend + backend)
- ErrorBoundary — ลบ SEC-VTRC-WEB-05, investment เล็ก
- Webpack 5 + Node 18 upgrade — ลด LEG-VTRC-WEB-01, investment ใหญ่
การเปลี่ยนแปลงจาก v1
V1's ch10 scorecard มี debt item ที่คล้ายกัน แต่:
- V1 ไม่ได้ quantify bundle size และ TTI — V2 ประเมินแล้ว
- V1 ระบุ RSA encryption ที่ login — V2 แก้: ไม่มี RSA ใน
vtrc-webเหมือนกัน (V1 claim ผิดทั้งคู่) - V2 เพิ่ม
SEC-VTRC-WEB-04(SRI) และPERF-VTRC-WEB-04(image optimization) ที่ V1 ไม่ระบุ
จบ Volume 4.1
ถ้าอ่านมาถึงตรงนี้ — คุณน่าจะเข้าใจ vtrc-web ในระดับที่สามารถ maintain, debug, และ plan modernization ได้
บทถัดไปขอแนะนำ
- ถ้าอยากเข้าใจ backoffice → บท 4.2 vtrc-rc-backoffice
- ถ้าอยากเข้าใจ backend → Volume 3 vtrc-api
- ถ้าอยากเข้าใจ security เชิงระบบ → Volume 18 Security