4.2.7 · Scorecard + known bugs
บทสรุปของ 4.2.1 ถึง 4.2.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-RC-01 | .env committed — MSSQL conn string + AES key | vtrc-rc-backoffice/.env | 4.2.5 |
SEC-VTRC-RC-02 | /pathLogin/:token/:refreshToken SSO bypass — token in URL | App/index.js:24 | 4.2.5 |
SEC-VTRC-RC-03 | Login password ไม่มี encryption (plaintext) | Login/index.js:55-66 | 4.2.5 |
SEC-VTRC-RC-04 | dangerouslySetInnerHTML — XSS risk | กระจายใน pages/ | 4.2.5 |
SEC-VTRC-RC-05 | Token ใน localStorage — XSS accessible | utils/auth.js | 4.2.5 |
PERF-VTRC-RC-01 | Bundle 11-13MB — TTI ~5-8s | package.json + ไม่มี code splitting | 4.2.6 |
Severity: High (🟡)
| ID | Finding | ที่มา | บท |
|---|---|---|---|
SEC-VTRC-RC-06 | ไม่มี CSP + SRI | nginx config + public/index.html | 4.2.5 |
SEC-VTRC-RC-07 | console.log = () => {} ปิดทั้ง production — debug ยาก | App/index.js:17 | 4.2.5 |
SEC-VTRC-RC-08 | showModalErrors อาจกลืน error ที่เกี่ยวกับ security | Login/index.js:75-78 | 4.2.5 |
PERF-VTRC-RC-02 | fetchPolicy: 'no-cache' — network load สูง | config/apollo.js:171-185 | 4.2.6 |
PERF-VTRC-RC-03 | console.log = () => {} — debug cycle ช้า | App/index.js:17 | 4.2.6 |
QUAL-VTRC-RC-01 | TheamCss typo route — ห้ามแก้ | App/index.js:23 | 4.2.1 |
QUAL-VTRC-RC-02 | 2 component styles ผสม (class + function+Recoil) — sync ยาก | กระจาย | 4.2.2 |
QUAL-VTRC-RC-03 | GraphQL queries ไม่มี fragment — field ซ้ำ | graphql/queries.js | 4.2.2 |
Severity: Medium (🟢)
| ID | Finding | ที่มา | บท |
|---|---|---|---|
SEC-VTRC-RC-09 | No CSRF protection | ทุก mutation | 4.2.5 |
SEC-VTRC-RC-10 | No ErrorBoundary | containers/App/index.js | 4.2.5 |
SEC-VTRC-RC-11 | checkLinkURL() env branching ที่ client | config/apollo.js | 4.2.5 |
SEC-VTRC-RC-12 | appVersion: "v1.0" hardcoded | Login/index.js:61 | 4.2.5 |
PERF-VTRC-RC-04 | Image ไม่ optimize | public/, src/assets/ | 4.2.6 |
PERF-VTRC-RC-05 | Build time 6-10 min cold | Dockerfile | 4.2.6 |
LEG-VTRC-RC-01 | CRA 3.4.3 + Node 16 (EOL) | package.json, Dockerfile | 4.2.6 |
QUAL-VTRC-RC-04 | Snapshot ไฟล์ legacy (queries_bk-061265.js, mutations_bk.js) | src/graphql/ | 4.2.2 |
QUAL-VTRC-RC-05 | 212 Recoil atoms ไม่ grouped | src/pages/WorkForce/recoil/ | 4.2.2 |
QUAL-VTRC-RC-06 | MUI v5 + AntD v4 ผสมกัน — bundle ใหญ่ | package.json | 4.2.6 |
OBS-VTRC-RC-01 | ไม่มี structured logging ฝั่ง client | — | 4.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 typo | App/index.js:23, pages/TheamCss/ | import ทุกที่อ้างถึง — rename ต้อง update ทั้งหมด |
Mutations.loginBackoffice (suffix BO) | graphql/mutations.js | ต่างจาก Mutations.login ของ vtrc-web — backend แยก flow |
Queries.refreshTokenBO | graphql/queries.js | refresh flow แยกจาก user-side |
getOrganization() from sessionStorage | utils/auth.js | login flow ต้องใช้ — reset sessionStorage = login fail |
apiKeyNews() returns WEB_ADMIN device key | utils/apiKey.js | backend 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)
- ลบ
.envออกจาก git + rotate secret — fix SEC-VTRC-RC-01, investment เล็กมาก, impact ใหญ่ที่สุด - POST body SSO — fix SEC-VTRC-RC-02, investment ปานกลาง
dompurify— fix SEC-VTRC-RC-04, investment เล็ก- CSP header — fix SEC-VTRC-RC-06, investment นิดเดียว
- Lazy-load Stimulsoft — fix PERF-VTRC-RC-01, investment ปานกลาง
- AntD tree-shake — fix PERF-VTRC-RC-01 (ต่อ), investment เล็ก
- HttpOnly cookie สำหรับ token — fix SEC-VTRC-RC-05, investment ใหญ่
- ErrorBoundary — fix SEC-VTRC-RC-10, investment เล็ก
- CRA → Webpack 5 migration — fix LEG-VTRC-RC-01, investment ใหญ่
- 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 (
.envcommitted) — 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 ได้
บทถัดไปขอแนะนำ
- ถ้าอยากเข้าใจ user-side frontend → บท 4.1 vtrc-web
- ถ้าอยากเข้าใจ backend → Volume 3 vtrc-api
- ถ้าอยากเข้าใจ security เชิงระบบ → Volume 18 Security