report-log — Scorecard
Legend:
- Critical = active security/data-loss/availability risk
- High = correctness/maintainability hazard, real impact
- Medium = friction/hygiene, ยังไม่เป็นอันตราย
repo นี้ (branch: master) มีรายการระดับ Critical เพราะมีข้อมูลส่วนบุคคลจริงของผู้ใช้ระบบฝังอยู่ใน git history แบบ plaintext
Scorecard table
| ID | Severity | คำอธิบาย | หลักฐาน (file:line) | การแก้ไข |
|---|---|---|---|---|
| SEC-REPORTLOG-01 | Critical | ไฟล์ request_*.log ที่ commit ไว้ 63 ไฟล์ มีเลขบัตรประชาชน (citizenId), วันเกิด, empCode, รหัสผ่าน login แบบ plaintext ใน query string, JWT/refresh ใน query, FCM token, และ IP — ไม่ถูก mask ก่อน commit (header authorization ถูก _REPLACED_ แต่ inline query ไม่ถูก) | request_2023-02-17.log … request_2023-04-20.log; pattern ที่ app.js:10; producer gap ที่ vtrc-api/api/src/lib/logging.js:7-8,65-70 | ลบไฟล์ log ที่มี PII ออกจาก git history (rewrite history), จำกัดการ clone, แจ้งตามนโยบาย PDPA; แก้ redaction ที่ vtrc-api ให้ครอบคลุม inline args + apikey |
| SEC-REPORTLOG-02 | High | .gitignore มี # *.log ถูก comment ปิด — นโยบายปัจจุบันคืออนุญาต commit log | report-log/.gitignore:16-17 | เปิด *.log ใน gitignore; mask PII ก่อน export จาก API host |
| SEC-REPORTLOG-03 | High | console.log(dataM) / console.log(dataW) พิมพ์ raw log lines (รวม PII) ออก stdout ทุกครั้งที่รัน | app.js:108-109 | ลบหรือลดให้เหลือ count เท่านั้น; ห้าม dump raw line |
| CORR-REPORTLOG-01 | Medium | โค้ดจัด OMM/OWW ด้วย users.filter(item => !keyUserM.includes(item)) — ได้สมาชิก users.json ที่ไม่ปรากฏในวันนั้น ไม่ใช่ "user นอกจุฬาที่เรียก API" ตามชื่อ type | app.js:128-141 | แก้ logic ให้ Other = keyUser − users หรือตั้งชื่อ type ใหม่ให้ตรงความหมาย |
| QUAL-REPORTLOG-01 | Medium | users.json (9,486 UUID) ไม่มี metadata แหล่งที่มา/วันที่ export | users.json; คอมเมนต์ app.js:111,124 | เพิ่ม README อธิบายที่มา |
| QUAL-REPORTLOG-02 | Medium | hard-code วันที่; CSV export comment ปิด; ต้องแก้ source ทุกครั้งที่จะรันซ้ำ | app.js:4,211,221-229 | CLI args --start/--end/--output; เปิด export เป็น default |
| QUAL-REPORTLOG-03 | Medium | setVerticalData เป็น dead code และมี index arithmetic ที่เสี่ยง throw | app.js:150-206 | ลบหรือแยกเป็น script พร้อม test |
| OBS-REPORTLOG-01 | Medium | ไม่มี try/catch รอบ readData — ไฟล์วันใดหายแล้วทั้ง batch ล้ม | app.js:85-88,208-219 | catch ต่อวันแล้ว continue |
ตัวเลขที่ยืนยันใหม่ (แก้เอกสารเก่า)
| รายการ | ค่าเก่าใน scaffold | ค่าที่ยืนยันบน master | วิธียืนยัน |
|---|---|---|---|
| จำนวนไฟล์ log | 50 | 63 | ls request_*.log | wc -l |
จำนวน pattern ใน array | 28 | 31 | นับ entries ใน app.js:9-47 |
จำนวน menu | 29 | 31 | app.js:51-83 |
| จำนวน UUID ใน users.json | 9,485 | 9,486 | json.load length |
ลำดับ remediation
- SEC-REPORTLOG-01 — sanitize/ลบ git history ของ
request_*.log+ ประสาน PDPA - SEC-REPORTLOG-02 — ปิดการ commit log ในอนาคต
- แก้ redaction ที่ vtrc-api (
logging.js) — นอก repo นี้แต่เป็น root cause - hygiene ของ
app.js(CORR/QUAL/OBS)
Cross-ref
- โครงสร้างไฟล์ / menu map → 01-repository-map
- Producer pipeline → 02-core-pipeline
- Field inventory เต็ม → 03-log-field-inventory