From 9de9c543c68359fc27fb71ea51d1b04646f8ea89 Mon Sep 17 00:00:00 2001 From: admin Date: Tue, 18 Nov 2025 17:00:43 +0700 Subject: [PATCH] =?UTF-8?q?251118:1700=20=E0=B8=9B=E0=B8=A3=E0=B8=B1?= =?UTF-8?q?=E0=B8=9A=E0=B8=9B=E0=B8=A3=E0=B8=B8=E0=B8=87=20Project=20requi?= =?UTF-8?q?rement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...Task Breakdown สำหรับ Phase 2A–2C (v1.4.2).md | 234 +++ ...BP3-DMS_V1_4_1_Backend_Development_Plan.md | 3 + ...MS_V1_4_1_Backend_Development_Plan_Grok.md | 521 ++++++ ..._V1_4_2_Backend_Development_Plan (Patched) | 204 +++ .../LCBP3-DMS_V1_4_2_FullStackJS (Patched) | 160 ++ .../LCBP3-DMS_V1_4_2_Requirements (Patched) | 124 ++ ...BP3-DMS_V1_4_2_Backend_Development_Plan.md | 1592 +++++++++++++++++ 7 files changed, 2838 insertions(+) create mode 100644 Documnets/Project/LCBP3-DMS — Task Breakdown สำหรับ Phase 2A–2C (v1.4.2).md create mode 100644 Documnets/Project/LCBP3-DMS_V1_4_1_Backend_Development_Plan_Grok.md create mode 100644 Documnets/Project/LCBP3-DMS_V1_4_2_Backend_Development_Plan (Patched) create mode 100644 Documnets/Project/LCBP3-DMS_V1_4_2_FullStackJS (Patched) create mode 100644 Documnets/Project/LCBP3-DMS_V1_4_2_Requirements (Patched) create mode 100644 Documnets/Project/working LCBP3-DMS_V1_4_2_Backend_Development_Plan.md diff --git a/Documnets/Project/LCBP3-DMS — Task Breakdown สำหรับ Phase 2A–2C (v1.4.2).md b/Documnets/Project/LCBP3-DMS — Task Breakdown สำหรับ Phase 2A–2C (v1.4.2).md new file mode 100644 index 0000000..1171414 --- /dev/null +++ b/Documnets/Project/LCBP3-DMS — Task Breakdown สำหรับ Phase 2A–2C (v1.4.2).md @@ -0,0 +1,234 @@ +# LCBP3-DMS — Task Breakdown สำหรับ Phase 2A–2C (v1.4.2) + +เอกสารนี้เป็นรายละเอียด Task Breakdown เชิงลึกของ Phase 2A, 2B, 2C ที่ถูกแยกออกตามสถาปัตยกรรม v1.4.2 + +โครงสร้างประกอบด้วย: + +* Objectives +* Deliverables +* Task Breakdown (ละเอียดเป็นลำดับงาน) +* Developer Checklist +* Test Coverage +* Dependencies & Risks + +--- + +# 🟦 Phase 2A — Security Layer + +**Objective:** วาง Security Foundation ให้ระบบทั้งหมดใช้ร่วมกัน: Validation Pipeline, Security Headers, Rate Limiting, Request Guards + +## ✔ Deliverables + +* Global ValidationPipe +* Sanitization Layer +* Rate Limit Rules (anonymous/authenticated) +* Security Headers (Helmet) +* XSS / SQL Injection safeguards +* Security Tests + +## 🛠 Task Breakdown + +### 2A.1 Validation Pipeline + +* ตั้งค่า Global ValidationPipe +* เปิด whitelist, forbidNonWhitelisted +* เพิ่ม custom exception mapping → ErrorModel +* เชื่อม RequestIdInterceptor + +### 2A.2 Input Sanitization Layer + +* ติดตั้ง sanitize-html หรือ DOMPurify server-side +* เพิ่ม sanitization middleware สำหรับ: + + * query params + * body JSON + * form inputs +* เพิ่ม unit test: sanitized input → safe output + +### 2A.3 Security Headers (Helmet) + +* เปิดใช้งาน Helmet ทั้งระบบ +* ปรับ policy: `contentSecurityPolicy`, `xssFilter`, `noSniff` +* เพิ่ม config per environment + +### 2A.4 Rate Limiting + +* Rate limit แบบ 2 ชั้น: + + * anonymous (เช่น 30 req/min) + * authenticated (100 req/min) +* สร้าง Redis key pattern: `ratelimit:{ip}` +* สร้าง RateLimitGuard + decorator +* ทดสอบ burst traffic (locust หรือ autocannon) + +### 2A.5 SQL Injection / XSS Protection + +* เปิด TypeORM parameterized queries +* Sanitizer ตรวจจับ script tags +* เขียน test ที่ inject payload จำลอง + +### 2A.6 Logging + Error Model Integration + +* ผูก SecurityException → Error Model +* เพิ่ม request_id logging + +## ✔ Developer Checklist (Phase 2A) + +* [ ] ทุก controller มี ValidationPipe ครอบ +* [ ] Sanitization ทำงานในทุก input source +* [ ] Error ทั้งหมดออกตาม Error Model กลาง +* [ ] RateLimitGuard ทำงานผ่าน Redis +* [ ] มี security test อย่างน้อย 10 ชุด + +## ✔ Test Coverage (Phase 2A) + +* Input injection tests +* Rate limit tests +* Validation rejects undefined fields +* ErrorModel mapping + +--- + +# 🟪 Phase 2B — JSON Schema System + +**Objective:** จัดการ JSON Schema แบบ versioned, ตรวจสอบ payload, บังคับใช้ format ก่อนเก็บ DB + +## ✔ Deliverables + +* Schema Registry +* Schema Versioning +* Schema Validation Service +* Compatibility Rules +* Schema Migration Tests + +## 🛠 Task Breakdown + +### 2B.1 Schema Registry + +* Entity: `json_schemas`, `json_schema_versions` +* Endpoint: `POST /json-schemas` +* ฟิลด์สำคัญ: schema_id, version, schema_json +* สร้าง SchemaStore class + +### 2B.2 Schema Versioning + +* Version rule: semantic versioning (major.minor.patch) +* Migration notes per version +* นโยบาย: Breaking change → major bump +* API: `GET /json-schemas/:id?version=` + +### 2B.3 Schema Validation Service + +* ใช้ AJV หรือ Fastest-Validator +* preload schema เมื่อ boot server +* mapping validation error → Error Model +* เพิ่ม test: invalid schema / missing fields / wrong types + +### 2B.4 Compatibility Rules + +* ตรวจสอบ backward compatibility: + + * field removal → major version + * enum shrink → major version +* เพิ่ม script ตรวจ schema diff + +### 2B.5 Schema Migration Tests + +* ทดสอบ schema upgrade (v1 → v2) +* ทดสอบ payload ที่ใช้ version เก่า + +## ✔ Developer Checklist (Phase 2B) + +* [ ] ทุก JSON field อ้างอิง schema version +* [ ] ทุก schema ผ่าน validation +* [ ] Schema diff pass +* [ ] Schema test ครอบครบทุก field + +## ✔ Test Coverage (Phase 2B) + +* Schema version switch tests +* Incompatible payload rejection +* Schema registry CRUD + +--- + +# 🟧 Phase 2C — JSON Processing + +**Objective:** จัดการ JSON payload: sanitization, compression, encryption, size limits + +## ✔ Deliverables + +* JSON size validator +* JSON sanitizer +* JSON compressor (gzip/deflate) +* Sensitive fields encryption +* JSON transformation layer + +## 🛠 Task Breakdown + +### 2C.1 JSON Size Controls + +* ตั้ง global limit (เช่น 2MB ต่อฟิลด์) +* เพิ่ม JSONSizeGuard +* เขียน test: oversize JSON → error_code: `JSON.TOO_LARGE` + +### 2C.2 JSON Sanitization (ลึกกว่า Phase 2A) + +* ล้าง nested fields +* ล้าง `