Skip to content

4.1.7 · Scorecard + known bugs

บทสรุปของ 4.1.1 ถึง 4.1.6 — จัด severity ของทุก finding และให้สุขภาพ repo แบบภาพรวม


Severity legend

Levelเกณฑ์Action
🔴 Criticalactive security/data-loss/availability riskต้องแก้ก่อน deploy ถัดไป
🟡 Highcorrectness/maintainability hazard, real impactวางแผนแก้ใน quarter นี้
🟢 Mediumfriction/hygiene, ยังไม่อันตรายระดับ activeแก้ตามโอกาส

Severity: Critical (🔴)

IDFindingที่มาบท
SEC-VTRC-WEB-01Token ใน localStorage — XSS accessibleutils/auth.js (setToken/getToken)4.1.5
SEC-VTRC-WEB-02dangerouslySetInnerHTML หลายสิบไฟล์ — XSS riskกระจายใน pages/user/ (News, Policy, About detail)4.1.5
SEC-VTRC-WEB-03ไม่มี CSP headernginx config4.1.5
SEC-VTRC-WEB-04ไม่มี SRI hash บน bundlepublic/index.html4.1.5

Severity: High (🟡)

IDFindingที่มาบท
PERF-VTRC-WEB-01Bundle 12MB — TTI ~5-8spackage.json + ไม่มี code splitting4.1.6
PERF-VTRC-WEB-02fetchPolicy: 'cache-first' default — ข้อมูลเก่าconfig/apollo.js4.1.6
SEC-VTRC-WEB-05ไม่มี ErrorBoundary — white screen บน crashcontainers/App/index.js4.1.5
SEC-VTRC-WEB-06checkLinkURL() env branching ที่ clientconfig/apollo.js:checkLinkURL4.1.5
SEC-VTRC-WEB-07Console log ใน productionกระจาย (console.log)4.1.5
QUAL-VTRC-WEB-01from/ folder typo — ห้ามแก้ importcomponents/user/from/4.1.2
QUAL-VTRC-WEB-02GraphQL queries ไม่มี fragment — field ซ้ำทุก querygraphql/queries.js4.1.2

Severity: Medium (🟢)

IDFindingที่มาบท
PERF-VTRC-WEB-03ไม่มี service workerserviceWorker.js4.1.6
PERF-VTRC-WEB-04Image ไม่ optimizepublic/, src/assets/images/4.1.6
PERF-VTRC-WEB-05No HTTP/2 pushnginx config4.1.6
SEC-VTRC-WEB-08ไม่มี auth gate ที่ rootcontainers/App/index.js4.1.5
SEC-VTRC-WEB-09ไม่มี CSRF protectionทุก mutation4.1.5
LEG-VTRC-WEB-01Webpack 4 + Node 14 (EOL)Dockerfile, package.json4.1.6
QUAL-VTRC-WEB-03console.log ทุกที่ — debug noiseกระจาย4.1.2
QUAL-VTRC-WEB-04Snapshot ไฟล์ legacy (queries_pentest.js, querries_prd.js)src/graphql/4.1.2
OBS-VTRC-WEB-01ไม่มี structured logging ฝั่ง client4.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 typocomponents/user/from/import ทุกที่อ้างถึง — rename ต้อง update import ทั้งหมด
AntD v3 getFieldDecorator APIกระจายทั่ว formsAPI ไม่มีใน 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.jsbackend resolver matching
Mutations.login (no suffix)mutations.jsต่างจาก Mutations.loginBackoffice ของ vtrc-rc-backoffice
apiKeyNews() helperutils/apiKey.jsreturns device key for WEB APP_TYPE

Modernization priority (ROI-weighted)

  1. dompurify สำหรับ dangerouslySetInnerHTML — ลบ SEC-VTRC-WEB-02, investment เล็ก, impact ใหญ่
  2. CSP header — ลบ SEC-VTRC-WEB-03, investment นิดเดียว
  3. Code splitting — ลด TTI, investment ปานกลาง
  4. AntD tree-shake — ลด bundle ~600KB, investment เล็ก
  5. Replace moment.js — ลด bundle ~250KB, investment ปานกลาง
  6. HttpOnly cookie สำหรับ token — ลบ SEC-VTRC-WEB-01, investment ใหญ่ (เปลี่ยนทั้ง frontend + backend)
  7. ErrorBoundary — ลบ SEC-VTRC-WEB-05, investment เล็ก
  8. 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 ได้

บทถัดไปขอแนะนำ