Skip to content

4.2.7 · Scorecard + known bugs

บทสรุปของ 4.2.1 ถึง 4.2.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-RC-01.env committed — MSSQL conn string + AES keyvtrc-rc-backoffice/.env4.2.5
SEC-VTRC-RC-02/pathLogin/:token/:refreshToken SSO bypass — token in URLApp/index.js:244.2.5
SEC-VTRC-RC-03Login password ไม่มี encryption (plaintext)Login/index.js:55-664.2.5
SEC-VTRC-RC-04dangerouslySetInnerHTML — XSS riskกระจายใน pages/4.2.5
SEC-VTRC-RC-05Token ใน localStorage — XSS accessibleutils/auth.js4.2.5
PERF-VTRC-RC-01Bundle 11-13MB — TTI ~5-8spackage.json + ไม่มี code splitting4.2.6

Severity: High (🟡)

IDFindingที่มาบท
SEC-VTRC-RC-06ไม่มี CSP + SRInginx config + public/index.html4.2.5
SEC-VTRC-RC-07console.log = () => {} ปิดทั้ง production — debug ยากApp/index.js:174.2.5
SEC-VTRC-RC-08showModalErrors อาจกลืน error ที่เกี่ยวกับ securityLogin/index.js:75-784.2.5
PERF-VTRC-RC-02fetchPolicy: 'no-cache' — network load สูงconfig/apollo.js:171-1854.2.6
PERF-VTRC-RC-03console.log = () => {} — debug cycle ช้าApp/index.js:174.2.6
QUAL-VTRC-RC-01TheamCss typo route — ห้ามแก้App/index.js:234.2.1
QUAL-VTRC-RC-022 component styles ผสม (class + function+Recoil) — sync ยากกระจาย4.2.2
QUAL-VTRC-RC-03GraphQL queries ไม่มี fragment — field ซ้ำgraphql/queries.js4.2.2

Severity: Medium (🟢)

IDFindingที่มาบท
SEC-VTRC-RC-09No CSRF protectionทุก mutation4.2.5
SEC-VTRC-RC-10No ErrorBoundarycontainers/App/index.js4.2.5
SEC-VTRC-RC-11checkLinkURL() env branching ที่ clientconfig/apollo.js4.2.5
SEC-VTRC-RC-12appVersion: "v1.0" hardcodedLogin/index.js:614.2.5
PERF-VTRC-RC-04Image ไม่ optimizepublic/, src/assets/4.2.6
PERF-VTRC-RC-05Build time 6-10 min coldDockerfile4.2.6
LEG-VTRC-RC-01CRA 3.4.3 + Node 16 (EOL)package.json, Dockerfile4.2.6
QUAL-VTRC-RC-04Snapshot ไฟล์ legacy (queries_bk-061265.js, mutations_bk.js)src/graphql/4.2.2
QUAL-VTRC-RC-05212 Recoil atoms ไม่ groupedsrc/pages/WorkForce/recoil/4.2.2
QUAL-VTRC-RC-06MUI v5 + AntD v4 ผสมกัน — bundle ใหญ่package.json4.2.6
OBS-VTRC-RC-01ไม่มี structured logging ฝั่ง client4.2.5

Health Scorecard

Dimensionสถานะเหตุผล
Auth/token handling🔴localStorage + SSO bypass + no encryption
XSS protection🔴dangerouslySetInnerHTML + no CSP
Routing & state🟡2 styles ผสม — sync ยาก
Component architecture🟡class + function+Recoil mix
GraphQL strategy🟡Apollo v2 + no-cache — works แต่ network load สูง
Performance🔴bundle 11-13MB, TTI 5-8s
Build pipeline🟡CRA 3.4.3 + Node 16 (EOL)
Observability🔴console.log ปิดทั้งหมด
Test coverage🔴ไม่พบ test suite
Dependency freshness🟡React 16, AntD 4, Apollo v2 — ทุกตัว EOL
Secret hygiene🔴.env committed with MSSQL password

คะแนนรวม: 0 🟢 / 3 🟡 / 8 🔴 — repo ใช้งานได้แต่มี technical debt สะสมสูง


Public contract — สิ่งที่ต้อง maintain

รายการที่ตั้งเหตุผลที่ต้องคง
TheamCss route + folder typoApp/index.js:23, pages/TheamCss/import ทุกที่อ้างถึง — rename ต้อง update ทั้งหมด
Mutations.loginBackoffice (suffix BO)graphql/mutations.jsต่างจาก Mutations.login ของ vtrc-web — backend แยก flow
Queries.refreshTokenBOgraphql/queries.jsrefresh flow แยกจาก user-side
getOrganization() from sessionStorageutils/auth.jslogin flow ต้องใช้ — reset sessionStorage = login fail
apiKeyNews() returns WEB_ADMIN device keyutils/apiKey.jsbackend map apiKey → APP_TYPE
AntD v4 Form.useForm() + v3 getFieldDecorator mixกระจายmigration ทีละ form — ห้าม mix ใน form เดียว
TheamCss ห้ามลบpages/TheamCss/dev tool — ใช้สำหรับ preview CSS
2way-meeting-backoffice sub-app embedded(ถ้ามี)pattern SSO ผ่าน pathLogin

Modernization priority (ROI-weighted)

  1. ลบ .env ออกจาก git + rotate secret — fix SEC-VTRC-RC-01, investment เล็กมาก, impact ใหญ่ที่สุด
  2. POST body SSO — fix SEC-VTRC-RC-02, investment ปานกลาง
  3. dompurify — fix SEC-VTRC-RC-04, investment เล็ก
  4. CSP header — fix SEC-VTRC-RC-06, investment นิดเดียว
  5. Lazy-load Stimulsoft — fix PERF-VTRC-RC-01, investment ปานกลาง
  6. AntD tree-shake — fix PERF-VTRC-RC-01 (ต่อ), investment เล็ก
  7. HttpOnly cookie สำหรับ token — fix SEC-VTRC-RC-05, investment ใหญ่
  8. ErrorBoundary — fix SEC-VTRC-RC-10, investment เล็ก
  9. CRA → Webpack 5 migration — fix LEG-VTRC-RC-01, investment ใหญ่
  10. MUI v5 → AntD v4 consolidation — fix QUAL-VTRC-RC-06, investment ใหญ่

การเปลี่ยนแปลงจาก v1

V1 มี debt item คล้ายกัน แต่ V2:

  • แก้ V1 ผิด: V1 ระบุ RSA encryption ที่ login — จริง ๆ ไม่มี RSA library ใน repo (verified) — V2 แก้เป็น SEC-VTRC-RC-03 (plaintext password)
  • เพิ่ม SEC-VTRC-RC-01 (.env committed) — V1 ไม่ระบุชัด
  • เพิ่ม SEC-VTRC-RC-02 (SSO bypass) — V1 mention สั้น ๆ แต่ V2 deep dive
  • เพิ่ม PERF-VTRC-RC-02 (fetchPolicy: 'no-cache') — V1 ไม่ระบุ
  • เพิ่ม QUAL-VTRC-RC-02 (2 component styles mix) — V1 ไม่ระบุเพราะ module WorkForce ยังไม่มีตอน V1 เขียน

จบ Volume 4.2

ถ้าอ่านมาถึงตรงนี้ — คุณน่าจะเข้าใจ vtrc-rc-backoffice ในระดับที่สามารถ maintain, debug, และ plan modernization ได้

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