← Secure by Design

Phase 1: Foundation & Pattern Awareness

สัปดาห์ที่ 1–2 · Day 1–14 · ปูรากฐานความคิด เห็นรอยแตกร้าวในโค้ด และออกแบบความปลอดภัยด้วย Secure by Design กับ Domain-Driven Design

Week 1 · Part 1 & 2 — Mindset & DDD Building Blocks

Day 1–2 ว่าทำไมการออกแบบถึงสำคัญ และเคส Anti-Hamlet · Day 3–7 คือแนวคิด DDD, Domain Primitives และความถูกต้องของสถานะ

เป้าหมายสัปดาห์ที่ 1: เลิกมองว่า security เป็นฟีเจอร์ที่แปะทีหลัง แล้วมองว่ามันเป็นผลจากการออกแบบที่ดี พร้อมสร้างส่วนประกอบพื้นฐานของ Domain-Driven Security

Day 1

Chapter 1 — Why design matters for security

เปลี่ยนจากการไล่แก้บั๊ก มาเป็นการออกแบบโครงสร้างที่ไม่ยอมให้เกิดสถานะที่ไม่ถูกต้อง

Shallow vs. Deep Modeling, Hinge vs. Lock, กรณีศึกษา Heartbleed

เปิดบทเรียน →
Day 2

Chapter 2 — Intermission: The anti-Hamlet

เคส Joe Tester ที่สั่งหนังสือ Anti-Hamlet จำนวน -1 เล่ม

Primitive Obsession, Systems living the same lie, รอยแตกร้าวจาก Shallow Modeling

เปิดบทเรียน →
Day 3

Chapter 3 — Core concepts of Domain-Driven Design

ใช้ภาษาและขอบเขตทางธุรกิจใน DDD เพื่อตีกรอบความปลอดภัยของระบบ

Ubiquitous Language, Bounded Contexts, Entities vs. Value Objects, Aggregates

เปิดบทเรียน →
Day 4

Chapter 4 — Code constructs promoting security

โครงสร้างโค้ดที่ปกป้องสถานะ และสร้างหลักประกันว่าของที่สร้างขึ้นนั้นใช้ได้

Immutability, Pure Value Objects, Contracts & Guarantees, Defensive Copying

เปิดบทเรียน →
Day 5

Chapter 5 — Domain primitives

สกัดข้อมูลเสียตั้งแต่ตอนที่ข้อมูลข้าม Bounded Context

Domain Primitives, Validation Pipeline 5 ขั้น, Fail-Fast, Read-Once Objects

เปิดบทเรียน →
Day 6

Chapter 6 — Ensuring integrity of state

รักษาความถูกต้องของข้อมูลตลอดชีวิตของ Aggregate

State Invariants, Aggregate Root Boundary, Unmodifiable Collections, Escaping References

เปิดบทเรียน →
Day 7

Chapter 7 — Reducing complexity of state

ลดความซับซ้อนของการเปลี่ยนสถานะ เพื่อปิดช่องโหว่เชิงตรรกะ

State Machine, Entity Relay, กำจัด null และสถานะที่ไม่ถูกต้องตั้งแต่ตอนคอมไพล์

เปิดบทเรียน →

Week 2 · Part 3 — Applying Fundamentals to Real-World Systems

Day 8–10 คือ pipeline, การรับมือความล้มเหลว และ cloud thinking · Day 11–14 คือเคสประกันภัย, โค้ดเก่า, microservices และวัฒนธรรม antifragile

เป้าหมายสัปดาห์ที่ 2: เอาทฤษฎีสัปดาห์แรกไปใช้กับ pipeline, การจัดการความล้มเหลว, cloud thinking, โค้ดเก่า, microservices และการสร้างระบบที่แข็งขึ้นหลังถูกกระแทก

Day 8

Chapter 8 — Leveraging your delivery pipeline for security

ใส่การตรวจความปลอดภัยเข้าไปใน CI/CD

Security-style unit testing 4 มิติ (Normal, Boundary, Invalid, Extreme), Static Analysis, Quality Gates

เปิดบทเรียน →
Day 9

Chapter 9 — Handling failures securely

ทำให้การรับมือความผิดพลาดไม่รั่วข้อมูล และไม่ล่มตามกัน

Fail-Secure vs Fail-Open, ไม่ส่ง stack trace ออกไป, Circuit Breaker, Bulkhead, Correlation ID

เปิดบทเรียน →
Day 10

Chapter 10 — Benefits of cloud thinking

ใช้แนว cloud-native และ Twelve-Factor เป็นยุทธศาสตร์ความปลอดภัย

Secrets ใน environment, Stateless processes, Centralized logging, The Three R's: Rotate, Repave, Repair

เปิดบทเรียน →
Day 11

Chapter 11 — Intermission: An insurance policy for free

เคสประกันภัยรถยนต์ที่ยิง event ข้ามบริบทผิดความหมาย จนออกกรมธรรม์ทั้งที่เงินยังไม่เข้า

Microservices Myopia, ความหมายที่ไม่ตรงกัน, Context Mapping, Domain Events ที่พูดชัด

เปิดบทเรียน →
Day 12

Chapter 12 — Guidance in legacy code

แทรก Domain Primitives เข้าโค้ดเก่าโดยไม่ทำให้ระบบพัง

Direct, Discovery และ New API, เลิกตรวจ null ซ้ำในชั้นลึก, Misapplied DRY

เปิดบทเรียน →
Day 13

Chapter 13 — Guidance on microservices

คุมความปลอดภัยและการไหลของข้อมูลในระบบที่แยกบริการ

Domain Operations กับ Anemic CRUD, การส่งต่อ identity token (JWT), CIA-T ของข้อมูลกระจาย, Domain-oriented logging

เปิดบทเรียน →
Day 14

Chapter 14 — A final word: Don’t forget about security!

เอาการออกแบบที่ดีไปคู่กับงาน security ที่ลงมือตรวจจริง และยกทีมให้เรียนรู้จากการถูกทดสอบ

Code security reviews, OWASP dependency tracking, penetration testing กับการใช้กฎธุรกิจโจมตี, Wolff's Law และวัฒนธรรม Antifragile

เปิดบทเรียน →

ผลลัพธ์จาก Phase 1

  1. เลนส์มองความปลอดภัย: เห็นช่องโหว่เชิงตรรกะและจุดเปราะในโค้ดก่อนที่คนจะเอาไปใช้
  2. Checksheet ส่วนตัว: มีรูปแบบการออกแบบจาก 14 บท พร้อมเอาไปใช้กับงานจริง
  3. ฐานสำหรับ Phase 2: ทฤษฎีแน่นพอจะไปฝึกเขียนและ refactor ใน Phase 2 วันที่ 15–35