اختبار الأمان و OWASP ASVS: الأمن جُوّه الـ CI، مش audit آخر السنة

جارٍ التحميل…

01 / ملخص الدرس

اختبار الأمان و OWASP ASVS: الأمن جُوّه الـ CI، مش audit آخر السنة

كل اللي اتعلمناه في قسم الأمن ما ينفعش يعتمد على إن حد فاكر. بنفهم أنواع الـ AppSec testing: SAST و DAST و SCA و secret scanning و fuzzing و pentesting، وكل واحد بيمسك إيه وبيفوّت إيه، و OWASP ASVS كـ checklist ومستوياته، وإزاي تربط كل finding بـ CWE، و SARIF في GitHub، و false positives والتجاهل المنضبط. والتحدي: SAST صغير بتمن rules على code حقيقي الشكل، ويوقّف الـ PR.

02 / شرح الدرس مكتوبًا

نص شرح المعلم والكود الذي كتبه ونتيجة تشغيله، بنفس ترتيب الدرس.

أهلًا بيك. في الدروس اللي فاتت اتعلمنا SQL injection، و XSS، و SSRF، و JWT، و secrets، و supply chain، و logs. بس فيه مشكلة: كل ده بيعتمد على إن المبرمج فاكر. وفي فريق فيه عشرين واحد، وألف PR في السنة، حد هينسى. الحل إن الأمن يبقى جزء من الـ pipeline: كل PR بيتفحص أوتوماتيك قبل الـ merge، زي الـ tests بالضبط. ده اسمه shift left: تمسك المشكلة بدري، لما تصليحها بياخد دقيقة، مش بعد ما تنزل الإنتاج. app slash routes dot js: code حقيقي الشكل من مشروع، فيه مشاكل أمان شفناها في القسم ده، مستخبية وسط code سليم. حاول تلاقيهم بعينك قبل ما نكمّل. لقيت كام؟ الـ API key مكتوب، و SQL بـ template، و exec بـ input، و eval، و Math random للـ reset token، و md5 للباسورد، و jwt verify من غير algorithms، و TLS مقفول. ده وأنا عارف إنهم موجودين. في code base فيه مِيّة ألف سطر، العين مش هتلاقيهم. وفيه حاجتين في الآخر: الـ report فيه eval بس على string مكتوب في الـ code، وعليه comment بيقول ليه ده آمن. والـ legacy عليه نفس الـ comment من غير سبب. واحد فيهم مقبول، والتاني لأ.

أنواع الـ AppSec testing: SAST، يعني static: بيقرا الـ code من غير ما يشغّله، ويدوّر على patterns خطيرة. سريع، وعلى كل PR، وبيقولك السطر بالضبط. بس ما يعرفش الـ runtime، فبيطلّع false positives. زي Semgrep و CodeQL. DAST، يعني dynamic: بيكلّم الـ app وهو شغّال من برّه زي المهاجم، يبعت payloads ويشوف الـ responses. بيلاقي مشاكل الـ config والـ headers، بس ما يعرفش السطر. زي OWASP ZAP. والـ scanner بتاع درس الـ security headers كان DAST صغير. SCA: فحص الـ dependencies، ده درس الـ supply chain. secret scanning: بيدوّر على keys في الـ code وفي الـ git history كلها، زي gitleaks. fuzzing: بيبعت آلاف المدخلات العشوائية لحد ما حاجة تقع. والـ pentest: ناس بتهاجمك بإيدها مرة أو مرتين في السنة، وبيلاقوا مشاكل الـ logic اللي الأدوات ما تفهمهاش، زي الـ BOLA.

طيب نفحص على أساس إيه؟ هنا OWASP ASVS، يعني Application Security Verification Standard. الـ Top Ten بتاع OWASP list بأشهر المشاكل، كويسة للتوعية. بس ASVS حاجة تانية: checklist كاملة بمئات المتطلبات، مقسومة فصول: V2 الـ authentication، و V3 الـ sessions، و V5 الـ validation والـ injection، و V6 الـ cryptography، و V9 الـ communications، و V14 الـ configuration، وغيرهم. وكل متطلب مكتوب بطريقة تقدر تختبرها: يا آه يا لأ. وفيه تلات مستويات: L1 لأي app، أقل حاجة. L2 لأي app فيه data حساسة، وده اللي أغلب الـ backends المفروض توصله. L3 للحاجات الحرجة زي البنوك والصحة. وكل finding بيتربط بـ CWE، يعني رقم عالمي لنوع المشكلة. CWE تسعة وتمانين يعني SQL injection في أي أداة في الدنيا، فتقدر تعدّ وتقارن. main dot js هي خطوة الـ SAST في الـ CI: بتفحص الـ folder اللي اسمه app، وتطبع التقرير، وتكتب results dot sarif. SARIF ده format قياسي: لو رفعته لـ GitHub، الـ finding بيطلع كـ comment على السطر نفسه في الـ PR. ولو فيه high، الـ exit code بيبقى واحد، والـ PR ما يتعملوش merge. وحاجة مهمة: الـ false positives. لو الأداة بتصرّخ على حاجات سليمة كتير، الفريق هيتجاهلها كلها. فلازم طريقة تقول بيها: السطر ده أنا راجعته وهو آمن. بس التجاهل ده لازم يبقى فيه اسم الـ rule وسبب مكتوب، علشان الـ reviewer يشوفه ويوافق عليه. تجاهل من غير سبب ما يتحسبش. التحدي: اكتب sast dot js. test dot js فيه ستة وتلاتين حالة.

تمرين

sast.js: تمن rules بـ regex (sql-concat و cmd-injection و eval و weak-random و weak-hash و jwt-no-alg و tls-off و hardcoded-secret) كل واحدة بـ CWE و ASVS، و scan بيتجاهل الـ comments والـ appsec-ignore اللي فيها سبب بس، و toSarif.

الحل. كل rule سطر واحد: id و severity و CWE و فصل ASVS و regex ورسالة. الـ regex بتاع الـ SQL والـ exec بيدوّر على backtick وجُوّاه dollar sign و curly braces. لو مفيش interpolation، مفيش مشكلة. الـ jwt بيستخدم negative lookahead: jwt verify، والسطر بعدها ما فيهوش algorithms. scan بيشيك التجاهل على السطر نفسه واللي قبله بس، والـ regex بتاع التجاهل بيطلب كلمة بعد اسم الـ rule، يعني سبب. وتحويل SARIF شكل بس. وده بالضبط إزاي Semgrep شغّال من جُوّه، بس هو بيفهم الـ syntax tree مش النص، فبيعرف إن الـ variable جاي من req ولا مكتوب في الـ code. نشغّل main dot js على الـ routes.

sast.js
// sast.js: SAST صغير: rules بـ regex على كل سطر، كل rule مربوطة بـ CWE وفصل في ASVS

const R = (id, severity, cwe, asvs, re, msg) => ({ id, severity, cwe, asvs, re, msg });

export const RULES = [
  R("sql-concat", "high", "CWE-89", "V5 injection", /\b(query|execute)\s*\(\s*`[^`]*\$\{/, "SQL من template: استخدم parameters"),
  R("cmd-injection", "high", "CWE-78", "V5 injection", /\bexec(Sync)?\s*\(\s*`[^`]*\$\{/, "exec بـ shell: استخدم execFile"),
  R("eval-injection", "high", "CWE-95", "V5 injection", /\beval\s*\(|\bnew\s+Function\s*\(/, "eval أو new Function"),
  R("weak-random", "medium", "CWE-338", "V6 crypto", /\bMath\.random\s*\(/, "Math.random للـ tokens: استخدم randomBytes"),
  R("weak-hash", "high", "CWE-327", "V6 crypto", /createHash\(\s*["'](md5|sha1)["']/i, "md5/sha1 ضعاف"),
  R("jwt-no-alg", "medium", "CWE-347", "V3 session", /\bjwt\.verify\((?![^\n]*algorithms)/, "jwt.verify من غير algorithms"),
  R("tls-off", "high", "CWE-295", "V9 TLS", /rejectUnauthorized\s*:\s*false/, "التحقق من الشهادة مقفول"),
  R("hardcoded-secret", "high", "CWE-798", "V14 config", /["'](sk_live_|sk_lab_|ghp_|AKIA)[A-Za-z0-9]{8,}/, "secret مكتوب في الـ code"),
];

// "// appsec-ignore: rule-id السبب" على السطر نفسه أو اللي قبله. لازم rule id وسبب، وإلا التجاهل ما يتحسبش
const IGNORE = /appsec-ignore:\s*([a-z-]+)\s+(\S.*)$/;

export function scan(file, source) {
  const lines = source.split("\n");
  const ignoredAt = (i) => {
    const out = new Set();
    for (const l of [lines[i], lines[i - 1] ?? ""]) {
      const m = IGNORE.exec(l);
      if (m) out.add(m[1]);
    }
    return out;
  };
  const findings = [];
  lines.forEach((text, i) => {
    if (/^\s*\/\//.test(text)) return; // سطر comment كامل
    const ignored = ignoredAt(i);
    for (const r of RULES)
      if (r.re.test(text) && !ignored.has(r.id))
        findings.push({ file, line: i + 1, rule: r.id, severity: r.severity, cwe: r.cwe, asvs: r.asvs, message: r.msg });
  });
  return findings;
}

// SARIF 2.1.0: الشكل اللي GitHub code scanning بيفهمه
export function toSarif(findings) {
  const level = { high: "error", medium: "warning", low: "note" };
  return {
    version: "2.1.0",
    $schema: "https://json.schemastore.org/sarif-2.1.0.json",
    runs: [
      {
        tool: { driver: { name: "mini-sast", rules: RULES.map((r) => ({ id: r.id, shortDescription: { text: r.msg }, properties: { tags: [r.cwe] } })) } },
        results: findings.map((f) => ({
          ruleId: f.rule,
          level: level[f.severity],
          message: { text: `${f.message} (${f.cwe}, ASVS ${f.asvs})` },
          locations: [{ physicalLocation: { artifactLocation: { uri: f.file }, region: { startLine: f.line } } }],
        })),
      },
    ],
  };
}

المخرجات

$ node main.js
high     app/routes.js:7  hardcoded-secret   CWE-798  V14 config
high     app/routes.js:11 sql-concat         CWE-89   V5 injection
high     app/routes.js:21 cmd-injection      CWE-78   V5 injection
high     app/routes.js:28 eval-injection     CWE-95   V5 injection
medium   app/routes.js:31 weak-random        CWE-338  V6 crypto
high     app/routes.js:38 weak-hash          CWE-327  V6 crypto
medium   app/routes.js:44 jwt-no-alg         CWE-347  V3 session
high     app/routes.js:54 tls-off            CWE-295  V9 TLS
high     app/routes.js:64 cmd-injection      CWE-78   V5 injection

9 finding، منهم 7 high
⛔ الـ PR ما يتعملوش merge

تسعة findings، كل واحد بالسطر والـ CWE والفصل في ASVS. والـ PR اتوقف. وخد بالك: الـ report اتجاهل لأن فيه سبب، والـ legacy طلع لأن التجاهل من غير سبب. والسطور السليمة، الـ execFile والـ parameters والـ randomBytes والـ jwt بـ algorithms، ما طلعتش. ونشغّل test dot js.

sast.js

المخرجات

$ node test.js
✅ فيه تمن rules على الأقل بـ id و severity و cwe و asvs 
✅ SQL بـ template ← sql-concat ["sql-concat"]
✅ SQL بـ parameters ← مفيش finding []
✅ template من غير ${}  ← مفيش finding []
✅ exec بـ template ← cmd-injection ["cmd-injection"]
✅ execSync بـ template ← cmd-injection ["cmd-injection"]
✅ execFile بـ array ← مفيش finding []
✅ eval ← eval-injection ["eval-injection"]
✅ new Function ← eval-injection ["eval-injection"]
✅ كلمة evaluate عادية ← مفيش finding []
✅ Math.random ← weak-random ["weak-random"]
✅ randomBytes ← مفيش finding []
✅ md5 ← weak-hash ["weak-hash"]
✅ sha1 بـ single quotes ← weak-hash ["weak-hash"]
✅ sha256 ← مفيش finding []
✅ jwt.verify من غير algorithms ← jwt-no-alg ["jwt-no-alg"]
✅ jwt.verify بـ algorithms ← مفيش finding []
✅ rejectUnauthorized false ← tls-off ["tls-off"]
✅ rejectUnauthorized true ← مفيش finding []
✅ مفتاح مكتوب في الـ code ← hardcoded-secret ["hardcoded-secret"]
✅ مفتاح من الـ env ← مفيش finding []
✅ سطر comment كامل فيه eval ← مفيش finding []
✅ ignore بـ rule و سبب على السطر اللي قبله ← مفيش finding []
✅ ignore على نفس السطر ← مفيش finding []
✅ ignore من غير سبب ما يتحسبش ← eval-injection ["eval-injection"]
✅ ignore لـ rule تانية
…

كله نجح. وده آخر درس في قسم الأمن التطبيقي تقريبًا. الـ pipeline الكامل بيبقى: secret scanning و SAST و SCA على كل PR، و DAST على الـ staging بعد كل deploy، و pentest كل سنة، و ASVS L2 كهدف تقيس نفسك عليه. الدرس الجاي آخر درس في القسم: prototype pollution والـ resource DoS. ليه object عادي في JavaScript ممكن يخلّي كل users الـ app admins، وإزاي regex واحدة أو JSON كبير يوقّع الـ server كله.

main.js
// main.js (ci): خطوة الـ SAST في الـ CI: افحص app/، اطبع التقرير، واكتب SARIF، ووقّف لو فيه high
import { readFileSync, writeFileSync, readdirSync } from "node:fs";
import { scan, toSarif } from "./sast.js";

const files = readdirSync("app").filter((f) => f.endsWith(".js")).map((f) => `app/${f}`);
const findings = files.flatMap((f) => scan(f, readFileSync(f, "utf8")));

for (const f of findings)
  console.log(`${f.severity.padEnd(8)} ${`${f.file}:${f.line}`.padEnd(16)} ${f.rule.padEnd(18)} ${f.cwe.padEnd(8)} ${f.asvs}`);
writeFileSync("results.sarif", JSON.stringify(toSarif(findings), null, 2)); // GitHub بيعرضه في الـ PR

const high = findings.filter((f) => f.severity === "high").length;
console.log(`\n${findings.length} finding، منهم ${high} high`);
console.log(high ? "⛔ الـ PR ما يتعملوش merge" : "✅ عدّى");
process.exitCode = high ? 1 : 0;
app/routes.js
// app/routes.js: code حقيقي الشكل من مشروع، فيه مشاكل أمان مستخبية وسط code سليم
import { exec, execFile } from "node:child_process";
import { createHash, randomBytes } from "node:crypto";
import https from "node:https";
import jwt from "jsonwebtoken";

const API_KEY = "sk_lab_51HxFakeKey00000000"; // اتكتب هنا "مؤقتًا" من سنتين

export function routes(app, db) {
  app.get("/users", async (req, res) => {
    const rows = await db.query(`SELECT * FROM users WHERE name = '${req.query.name}'`);
    res.json(rows);
  });

  app.get("/users/:id", async (req, res) => {
    const rows = await db.query("SELECT * FROM users WHERE id = $1", [req.params.id]); // سليم
    res.json(rows);
  });

  app.post("/convert", (req, res) => {
    exec(`convert ${req.body.file} out.png`, () => res.send("ok"));
  });

  app.post("/thumb", (req, res) => {
    execFile("convert", [req.body.file, "thumb.png"], () => res.send("ok")); // سليم: مفيش shell
  });

  app.post("/calc", (req, res) => res.json({ result: eval(req.body.expr) }));

  app.post("/reset", (req, res) => {
    const token = Math.random().toString(36).slice(2);
    res.json({ sent: true, debug: token });
  });

  app.post("/invite", (req, res) => res.json({ code: randomBytes(16).toString("hex") })); // سليم

  app.post("/register", async (req, res) => {
    const hash = createHash("md5").update(req.body.password).digest("hex");
    await db.query("INSERT INTO users (email, hash) VALUES ($1, $2)", [req.body.email, hash]);
    res.sendStatus(201);
  });

  app.get("/me", (req, res) => {
    const claims = jwt.verify(req.headers.authorization.slice(7), process.env.JWT_KEY);
    res.json(claims);
  });

  app.get("/admin", (req, res) => {
    const claims = jwt.verify(req.cookies.t, process.env.JWT_KEY, { algorithms: ["HS256"] }); // سليم
    res.json(claims);
  });

  app.get("/partner", (req, res) => {
    https.get("https://partner.internal/api", { rejectUnauthorized: false }, (r) => r.pipe(res));
  });

  app.get("/report", (req, res) => {
    // appsec-ignore: eval-injection الـ expr ثابت ومن عندنا، مش من المستخدم
    res.json(eval("1 + 1"));
  });

  app.get("/legacy", (req, res) => {
    // appsec-ignore: cmd-injection
    exec(`legacy ${req.query.x}`, () => res.end());
  });
}
test.js
import { readFileSync } from "node:fs";
import { scan, toSarif, RULES } from "./sast.js";

let ok = 0, all = 0;
const check = (name, cond, extra = "") => { all++; if (cond) ok++; console.log(cond ? "✅" : "❌", name, extra); };
const rules = (src) => scan("t.js", src).map((f) => f.rule);
const hit = (name, src, rule) => check(`${name} ← ${rule}`, rules(src).includes(rule), JSON.stringify(rules(src)));
const clean = (name, src) => check(`${name} ← مفيش finding`, rules(src).length === 0, JSON.stringify(rules(src)));

check("فيه تمن rules على الأقل بـ id و severity و cwe و asvs", RULES.length >= 8 && RULES.every((r) => r.id && r.severity && /^CWE-\d+$/.test(r.cwe) && r.asvs));
hit("SQL بـ template", "db.query(`SELECT * FROM t WHERE a = '${x}'`)", "sql-concat");
clean("SQL بـ parameters", 'db.query("SELECT * FROM t WHERE a = $1", [x])');
clean("template من غير ${} ", "db.query(`SELECT 1`)");
hit("exec بـ template", "exec(`ls ${dir}`)", "cmd-injection");
hit("execSync بـ template", "execSync(`rm ${f}`)", "cmd-injection");
clean("execFile بـ array", 'execFile("ls", [dir])');
hit("eval", "eval(req.body.x)", "eval-injection");
hit("new Function", 'new Function("return " + x)', "eval-injection");
clean("كلمة evaluate عادية", "const evaluate = (x) => x; evaluate(1)");
hit("Math.random", "const t = Math.random().toString(36)", "weak-random");
clean("randomBytes", "randomBytes(16)");
hit("md5", 'createHash("md5")', "weak-hash");
hit("sha1 بـ single quotes", "createHash('SHA1')", "weak-hash");
clean("sha256", 'createHash("sha256")');
hit("jwt.verify من غير algorithms", "jwt.verify(t, key)", "jwt-no-alg");
clean("jwt.verify بـ algorithms", 'jwt.verify(t, key, { algorithms: ["HS256"] })');
hit("rejectUnauthorized false", "https.get(u, { rejectUnauthorized: false })", "tls-off");
clean("rejectUnauthorized true", "{ rejectUnauthorized: true }");
const FAKE = ["sk", "lab", "abcdefgh123"].join("_");
hit("مفتاح مكتوب في الـ code", `const k = "${FAKE}"`, "hardcoded-secret");
clean("مفتاح من الـ env", "const k = process.env.STRIPE_KEY");
clean("سطر comment كامل فيه eval", "// eval(x) كان هنا زمان");
clean("ignore بـ rule و سبب على السطر اللي قبله", "// appsec-ignore: eval-injection ثابت من عندنا\neval('1+1')");
clean("ignore على نفس السطر", "eval('1+1') // appsec-ignore: eval-injection ثابت");
hit("ignore من غير سبب ما يتحسبش", "// appsec-ignore: eval-injection\neval(x)", "eval-injection");
hit("ignore لـ rule تانية ما يتحسبش", "// appsec-ignore: weak-random سبب\neval(x)", "eval-injection");
hit("ignore على بعد سطرين ما يتحسبش", "// appsec-ignore: eval-injection سبب\n\neval(x)", "eval-injection");

const f = scan("app/x.js", "a\nb\neval(x)")[0];
check("finding فيه file و line و rule و severity و cwe و asvs و message",
  f?.file === "app/x.js" && f?.line === 3 && f?.rule === "eval-injection" && f?.severity === "high" && f?.cwe === "CWE-95" && !!f?.asvs && !!f?.message);
check("سطر فيه مشكلتين ← اتنين findings", scan("t.js", "exec(`a ${x}`); eval(y)").length === 2);

cons
…
03 / دروس المسار (122)
  1. 01أهلًا بيك: يعني إيه backend، والكورس ده ماشي إزاي
  2. 02الملفات والفولدرات والـ terminal: تتحرك على جهازك زي المبرمجين
  3. 03Node وأول برنامج: تشغّل وتقرا رسالة الخطأ
  4. 04القيم والمتغيرات والأنواع: const و let و typeof
  5. 05القرارات والتكرار: if و === والـ truthy والـ loops
  6. 06الـ functions: parameters و return والـ arrow functions والـ scope
  7. 07الـ objects والـ arrays: destructuring و spread و map و filter و reduce
  8. 08JSON والنصوص والتواريخ: اللغة اللي الـ backend بيتكلم بيها
  9. 09الـ callbacks والـ closures وأول لمسة async: setTimeout
  10. 10الـ classes والـ errors: throw و try/catch و stack trace
  11. 11git: تحفَظ كل خطوة وترجعلها، وما تسرّبش أسرارك
  12. 12ESM و CommonJS و package exports: Node بيلاقي الـ modules إزاي
  13. 13الـ Promises و async/await: sequential و parallel والأخطاء والإلغاء
  14. 14الـ event loop والـ microtasks: Node بيعمل كل حاجة بـ thread واحد إزاي
  15. 15الـ Streams والـ Backpressure: ملفات أكبر من الـ memory
  16. 16الـ File System والـ paths: قراية وكتابة صح، ومن غير path traversal
  17. 17الـ Buffers والبيانات الـ binary: الـ bytes من جُوّه
  18. 18Crypto APIs والأسرار: random و hash و HMAC و AES-GCM
  19. 19الـ Worker Threads: شغل CPU تقيل من غير ما توقف الـ server
  20. 20الـ Errors على مستوى الـ process: operational و programmer و crash-only
  21. 21الـ Node test runner والـ debugging: tests من غير مكتبات
  22. 22HTTP من جُوّه: الـ methods والـ status codes والـ headers
  23. 23Express والـ Routing: الـ params والـ query والترتيب والـ Router
  24. 24Express 5: إيه اللي اتغيّر، وإزاي تنقل مشروع قديم
  25. 25الـ Middleware ودورة حياة الـ request جُوّه Express
  26. 26Validation للمدخلات بـ Zod: ما تصدّقش أي حاجة جاية من برة
  27. 27تصنيف الأخطاء و Problem Details: شكل واحد لكل الـ errors
  28. 28الـ CORS والـ Cookies: المتصفح بيحمي المستخدم إزاي
  29. 29رفع الملفات وحدود الحجم: multer من غير ثغرات
  30. 30الـ Realtime: Server-Sent Events و WebSockets
  31. 31OpenAPI والـ API Versioning: عقد مكتوب، وتغيير من غير ما تكسر حد
  32. 32PostgreSQL: الـ DDL وأنواع البيانات الصح لكل عمود
  33. 33الـ Constraints: PK و FK و UNIQUE و CHECK — الـ database بتحمي نفسها
  34. 34الـ Normalization والـ ERD: تقسّم البيانات صح من أول يوم
  35. 35الـ JOINs والتجميع: INNER و LEFT و GROUP BY و HAVING و window functions
  36. 36JSONB في PostgreSQL: إمتى تستخدمه، وإزاي تسأله وتعمله index
  37. 37الـ Indexes من جُوّه: B-tree و GIN و BRIN
  38. 38Partial و Covering indexes: indexes أصغر وأسرع
  39. 39الـ Pagination بالـ Keyset: ليه OFFSET بيبطّأ وبيكرر
  40. 40Full Text Search في Postgres: بحث بالكلمات، بالعربي والإنجليزي
  41. 41EXPLAIN ANALYZE والـ Planner: اقرا الـ plan وصلّح الـ query
  42. 42الـ Transactions بـ node-postgres: كله أو ولا حاجة
  43. 43الـ MVCC ومستويات الـ Isolation: transactions كتير في نفس الوقت
  44. 44الـ Locks والـ Deadlocks: مين مستني مين
  45. 45SKIP LOCKED و Job Leasing: Postgres كـ job queue
  46. 46Row Level Security والـ Multi-tenancy: كل عميل يشوف بياناته بس
  47. 47Migrations من غير downtime: expand و backfill و contract
  48. 48الـ Replication والـ Read Replicas: نسخ حية من الـ database
  49. 49الـ Connection Pooling و PgBouncer: connections أقل، requests أكتر
  50. 50الـ Partitioning والـ VACUUM والمراقبة: Postgres على المدى الطويل
  51. 51Redis وأنواع البيانات: strings و hashes و lists و sets و sorted sets
  52. 52Cache-aside والـ TTL: Redis قدام الـ database
  53. 53الـ Cache invalidation والـ Stampede: لما الـ key الشهير يموت
  54. 54Lua والـ Atomicity في Redis: كام أمر كأنهم أمر واحد
  55. 55الـ Rate Limiting في Redis: fixed window و sliding window و token bucket
  56. 56الـ Sessions في Redis: تسجيل دخول تقدر تلغيه في أي وقت
  57. 57Redis Streams والـ Consumer Groups: log بيتوزع على workers
  58. 58Pub/Sub و BullMQ: إشارات بين الـ instances، وطوابير شغل محترمة
  59. 59Redis لما يقع: الـ persistence (RDB و AOF) والـ replication
  60. 60Redis في الإنتاج: الـ ACLs والـ Cluster والمراقبة
  61. 61تخزين الـ Passwords بـ Argon2id: صح من أول مرة
  62. 62Session Fixation والـ Rotation: id جديد مع كل صلاحية جديدة
  63. 63الـ Cookie Flags والـ CSRF: المتصفح بيبعت الـ cookie، فلازم تتأكد مين اللي طلب
  64. 64الـ XSS والـ Content Security Policy: ما تخليش النص يتحوّل لـ code
  65. 65الـ OAuth و OpenID Connect و PKCE: login بـ Google من غير ما تشوف الـ password
  66. 66التأكد من الـ JWT صح: التوقيع والـ claims والـ scopes
  67. 67الـ BOLA و BFLA: الـ token السليم مش معناه إن الطلب مسموح
  68. 68الـ RBAC و ABAC والملكية: policy واحدة بدل ifs متفرقة
  69. 69الـ MFA والـ recovery: التاني factor اللي بجد
  70. 70الـ Passkeys و WebAuthn: login من غير password وضد الـ phishing
  71. 71الـ Threat Modeling بـ STRIDE: فكّر زي المهاجم قبل ما تكتب code
  72. 72الـ SQL Injection والـ Parameterization: الـ data ما تبقاش code
  73. 73الـ SSRF والـ Egress: ما تخليش الـ server بتاعك يزور الشبكة الداخلية
  74. 74الـ Security Headers والـ TLS: كل response يقول للـ browser يحمي المستخدم إزاي
  75. 75توقيع الـ Webhooks والـ Replay: الـ webhook ده جاي فعلًا من Stripe؟
  76. 76تغيير الأسرار والـ HMAC: إزاي تغيّر مفتاح من غير ما كل حاجة تقع
  77. 77سلسلة التوريد والـ SBOM: إنت واثق في ألف package ما تعرفهمش؟
  78. 78الـ Audit والـ Privacy Logs: سجّل مين عمل إيه، من غير ما تسجّل الأسرار
  79. 79اختبار الأمان و OWASP ASVS: الأمن جُوّه الـ CI، مش audit آخر السنةانت هنا
  80. 80الـ Prototype Pollution والـ Resource DoS: request واحد يخلّي الكل admin أو يوقّع الـ server
  81. 81الـ SLI والـ SLO والـ Error Budget: إمتى تصحّي الـ on-call وإمتى تسيبه نايم
  82. 82الـ Event Loop Delay والـ ELU: لما Node نفسه يتخنق
  83. 83الـ Worker Threads والـ CPU Profiling: الشغل التقيل بره الـ event loop، والوقت راح فين
  84. 84الـ Memory والـ GC والـ Leaks: الـ process اللي بيكبر لحد ما يقع
  85. 85الـ N+1 Queries والـ DataLoader: صفحة واحدة بمِيّتين query
  86. 86الـ HTTP Caching والـ Compression: أسرع request هو اللي ما بيوصلش
  87. 87الـ Load Testing والـ Soak Testing: الـ server بيستحمل قد إيه بجد
  88. 88الـ Concurrency Limits والـ Bulkheads: dependency بطيئة ما توقعش الـ app كله
  89. 89الـ Timeouts والـ Retries والـ Circuit Breakers: إزاي تتعامل مع dependency بطيئة أو واقعة
  90. 90OpenTelemetry والـ Distributed Tracing: الـ request راح فين وضاع وقته فين
  91. 91Docker Layers والـ Build Context: ليه الـ build بياخد دقيقة وفيه الـ .env بتاعك
  92. 92Multi-stage Builds و Non-root: image صغيرة ومن غير root
  93. 93Docker Compose والـ Networks: الـ services بتلاقي بعض إزاي
  94. 94Docker Volumes: الـ data بتتحفَظ فين
  95. 95Healthcheck و Restart و Resource Limits: running مش معناها شغّال
  96. 96BuildKit والـ Build Secrets: الـ token ما يدخلش الـ image
  97. 97Reverse Proxy و TLS: اللي واقف قدام الـ app
  98. 98Multi-arch Images والـ Native Modules: اشتغلت عندي
  99. 99CI/CD و Rollback و Canary: الـ deploy يبقى ممل
  100. 100Kubernetes من الأول: Pods و Deployments و Services و Probes
  101. 101Modular Monolith و DDD: حدود واضحة من غير network
  102. 102Transactional Outbox و Inbox: الـ event ما يضيعش وما يتنفذش مرتين
  103. 103Sagas: عملية واحدة على تلات services من غير transaction واحدة
  104. 104CQRS و Event Sourcing: الـ events هي الحقيقة
  105. 105الـ Queues والـ Brokers: BullMQ و RabbitMQ و Kafka و SQS
  106. 106Realtime على أكتر من instance: Redis pub/sub و presence و resume
  107. 107الـ Object Storage والـ Media: presigned URLs و uploads مباشرة
  108. 108التكامل مع الـ Email والـ Search: retries و webhooks و indexes
  109. 109GraphQL و gRPC في الإنتاج: contracts و DataLoader و limits و deadlines
  110. 110Kafka على أكتر من zone و region: الـ replication والـ ISR والـ acks والـ MirrorMaker والـ failover
  111. 111TypeScript و runtime boundaries: الـ types بتختفي، والـ schemas لأ
  112. 112ORM ولا SQL: query builders و repositories و migrations و transactions
  113. 113الـ Serverless من جُوّه: cold starts و freeze و timeouts و connections
  114. 114الـ Testing Pyramid: unit و integration و e2e على Postgres حقيقية
  115. 115Contract Testing و Property-Based Testing بـ fast-check
  116. 116الـ Payments: idempotency و webhooks و refunds و reconciliation
  117. 117الـ Timezones والـ Internationalization: UTC و DST والـ locales والـ plurals والفلوس
  118. 118الـ Privacy والـ Data Retention: consent و export و erasure و crypto shredding
  119. 119الـ ADRs والـ Feature Flags: القرارات المكتوبة والـ rollout من غير deploy
  120. 120Multi-region active-active: حل الـ conflicts بـ HLC و CRDTs
  121. 121Readiness و Liveness و Startup Probes: الـ pod جاهز ولا عايش؟
  122. 122Incident Runbooks: من الـ alert للـ postmortem