@wazir-dev/cli 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (629) hide show
  1. package/AGENTS.md +111 -0
  2. package/CHANGELOG.md +14 -0
  3. package/CONTRIBUTING.md +101 -0
  4. package/LICENSE +21 -0
  5. package/README.md +314 -0
  6. package/assets/composition-engine.mmd +34 -0
  7. package/assets/demo-script.sh +17 -0
  8. package/assets/logo-dark.svg +14 -0
  9. package/assets/logo.svg +14 -0
  10. package/assets/pipeline.mmd +39 -0
  11. package/assets/record-demo.sh +51 -0
  12. package/docs/README.md +51 -0
  13. package/docs/adapters/context-mode.md +60 -0
  14. package/docs/concepts/architecture.md +87 -0
  15. package/docs/concepts/artifact-model.md +60 -0
  16. package/docs/concepts/composition-engine.md +36 -0
  17. package/docs/concepts/indexing-and-recall.md +160 -0
  18. package/docs/concepts/observability.md +41 -0
  19. package/docs/concepts/roles-and-workflows.md +59 -0
  20. package/docs/concepts/terminology-policy.md +27 -0
  21. package/docs/getting-started/01-installation.md +78 -0
  22. package/docs/getting-started/02-first-run.md +102 -0
  23. package/docs/getting-started/03-adding-to-project.md +15 -0
  24. package/docs/getting-started/04-host-setup.md +15 -0
  25. package/docs/guides/ci-integration.md +15 -0
  26. package/docs/guides/creating-skills.md +15 -0
  27. package/docs/guides/expertise-module-authoring.md +15 -0
  28. package/docs/guides/hook-development.md +15 -0
  29. package/docs/guides/memory-and-learnings.md +34 -0
  30. package/docs/guides/multi-host-export.md +15 -0
  31. package/docs/guides/troubleshooting.md +101 -0
  32. package/docs/guides/writing-custom-roles.md +15 -0
  33. package/docs/plans/2026-03-15-cli-pipeline-integration-design.md +592 -0
  34. package/docs/plans/2026-03-15-cli-pipeline-integration-plan.md +598 -0
  35. package/docs/plans/2026-03-15-docs-enforcement-plan.md +238 -0
  36. package/docs/readmes/INDEX.md +99 -0
  37. package/docs/readmes/features/expertise/README.md +171 -0
  38. package/docs/readmes/features/exports/README.md +222 -0
  39. package/docs/readmes/features/hooks/README.md +103 -0
  40. package/docs/readmes/features/hooks/loop-cap-guard.md +133 -0
  41. package/docs/readmes/features/hooks/post-tool-capture.md +121 -0
  42. package/docs/readmes/features/hooks/post-tool-lint.md +130 -0
  43. package/docs/readmes/features/hooks/pre-compact-summary.md +122 -0
  44. package/docs/readmes/features/hooks/pre-tool-capture-route.md +100 -0
  45. package/docs/readmes/features/hooks/protected-path-write-guard.md +128 -0
  46. package/docs/readmes/features/hooks/session-start.md +119 -0
  47. package/docs/readmes/features/hooks/stop-handoff-harvest.md +125 -0
  48. package/docs/readmes/features/roles/README.md +157 -0
  49. package/docs/readmes/features/roles/clarifier.md +152 -0
  50. package/docs/readmes/features/roles/content-author.md +190 -0
  51. package/docs/readmes/features/roles/designer.md +193 -0
  52. package/docs/readmes/features/roles/executor.md +184 -0
  53. package/docs/readmes/features/roles/learner.md +210 -0
  54. package/docs/readmes/features/roles/planner.md +182 -0
  55. package/docs/readmes/features/roles/researcher.md +164 -0
  56. package/docs/readmes/features/roles/reviewer.md +184 -0
  57. package/docs/readmes/features/roles/specifier.md +162 -0
  58. package/docs/readmes/features/roles/verifier.md +215 -0
  59. package/docs/readmes/features/schemas/README.md +178 -0
  60. package/docs/readmes/features/skills/README.md +63 -0
  61. package/docs/readmes/features/skills/brainstorming.md +96 -0
  62. package/docs/readmes/features/skills/debugging.md +148 -0
  63. package/docs/readmes/features/skills/design.md +120 -0
  64. package/docs/readmes/features/skills/prepare-next.md +109 -0
  65. package/docs/readmes/features/skills/run-audit.md +159 -0
  66. package/docs/readmes/features/skills/scan-project.md +109 -0
  67. package/docs/readmes/features/skills/self-audit.md +176 -0
  68. package/docs/readmes/features/skills/tdd.md +137 -0
  69. package/docs/readmes/features/skills/using-skills.md +92 -0
  70. package/docs/readmes/features/skills/verification.md +120 -0
  71. package/docs/readmes/features/skills/writing-plans.md +104 -0
  72. package/docs/readmes/features/tooling/README.md +320 -0
  73. package/docs/readmes/features/workflows/README.md +186 -0
  74. package/docs/readmes/features/workflows/author.md +181 -0
  75. package/docs/readmes/features/workflows/clarify.md +154 -0
  76. package/docs/readmes/features/workflows/design-review.md +171 -0
  77. package/docs/readmes/features/workflows/design.md +169 -0
  78. package/docs/readmes/features/workflows/discover.md +162 -0
  79. package/docs/readmes/features/workflows/execute.md +173 -0
  80. package/docs/readmes/features/workflows/learn.md +167 -0
  81. package/docs/readmes/features/workflows/plan-review.md +165 -0
  82. package/docs/readmes/features/workflows/plan.md +170 -0
  83. package/docs/readmes/features/workflows/prepare-next.md +167 -0
  84. package/docs/readmes/features/workflows/review.md +169 -0
  85. package/docs/readmes/features/workflows/run-audit.md +191 -0
  86. package/docs/readmes/features/workflows/spec-challenge.md +159 -0
  87. package/docs/readmes/features/workflows/specify.md +160 -0
  88. package/docs/readmes/features/workflows/verify.md +177 -0
  89. package/docs/readmes/packages/README.md +50 -0
  90. package/docs/readmes/packages/ajv.md +117 -0
  91. package/docs/readmes/packages/context-mode.md +118 -0
  92. package/docs/readmes/packages/gray-matter.md +116 -0
  93. package/docs/readmes/packages/node-test.md +137 -0
  94. package/docs/readmes/packages/yaml.md +112 -0
  95. package/docs/reference/configuration-reference.md +159 -0
  96. package/docs/reference/expertise-index.md +52 -0
  97. package/docs/reference/git-flow.md +43 -0
  98. package/docs/reference/hooks.md +87 -0
  99. package/docs/reference/host-exports.md +50 -0
  100. package/docs/reference/launch-checklist.md +172 -0
  101. package/docs/reference/marketplace-listings.md +76 -0
  102. package/docs/reference/release-process.md +34 -0
  103. package/docs/reference/roles-reference.md +77 -0
  104. package/docs/reference/skills.md +33 -0
  105. package/docs/reference/templates.md +29 -0
  106. package/docs/reference/tooling-cli.md +94 -0
  107. package/docs/truth-claims.yaml +222 -0
  108. package/expertise/PROGRESS.md +63 -0
  109. package/expertise/README.md +18 -0
  110. package/expertise/antipatterns/PROGRESS.md +56 -0
  111. package/expertise/antipatterns/backend/api-design-antipatterns.md +1271 -0
  112. package/expertise/antipatterns/backend/auth-antipatterns.md +1195 -0
  113. package/expertise/antipatterns/backend/caching-antipatterns.md +622 -0
  114. package/expertise/antipatterns/backend/database-antipatterns.md +1038 -0
  115. package/expertise/antipatterns/backend/index.md +24 -0
  116. package/expertise/antipatterns/backend/microservices-antipatterns.md +850 -0
  117. package/expertise/antipatterns/code/architecture-antipatterns.md +919 -0
  118. package/expertise/antipatterns/code/async-antipatterns.md +622 -0
  119. package/expertise/antipatterns/code/code-smells.md +1186 -0
  120. package/expertise/antipatterns/code/dependency-antipatterns.md +1209 -0
  121. package/expertise/antipatterns/code/error-handling-antipatterns.md +1360 -0
  122. package/expertise/antipatterns/code/index.md +27 -0
  123. package/expertise/antipatterns/code/naming-and-abstraction.md +1118 -0
  124. package/expertise/antipatterns/code/state-management-antipatterns.md +1076 -0
  125. package/expertise/antipatterns/code/testing-antipatterns.md +1053 -0
  126. package/expertise/antipatterns/design/accessibility-antipatterns.md +1136 -0
  127. package/expertise/antipatterns/design/dark-patterns.md +1121 -0
  128. package/expertise/antipatterns/design/index.md +22 -0
  129. package/expertise/antipatterns/design/ui-antipatterns.md +1202 -0
  130. package/expertise/antipatterns/design/ux-antipatterns.md +680 -0
  131. package/expertise/antipatterns/frontend/css-layout-antipatterns.md +691 -0
  132. package/expertise/antipatterns/frontend/flutter-antipatterns.md +1827 -0
  133. package/expertise/antipatterns/frontend/index.md +23 -0
  134. package/expertise/antipatterns/frontend/mobile-antipatterns.md +573 -0
  135. package/expertise/antipatterns/frontend/react-antipatterns.md +1128 -0
  136. package/expertise/antipatterns/frontend/spa-antipatterns.md +1235 -0
  137. package/expertise/antipatterns/index.md +31 -0
  138. package/expertise/antipatterns/performance/index.md +20 -0
  139. package/expertise/antipatterns/performance/performance-antipatterns.md +1013 -0
  140. package/expertise/antipatterns/performance/premature-optimization.md +623 -0
  141. package/expertise/antipatterns/performance/scaling-antipatterns.md +785 -0
  142. package/expertise/antipatterns/process/ai-coding-antipatterns.md +853 -0
  143. package/expertise/antipatterns/process/code-review-antipatterns.md +656 -0
  144. package/expertise/antipatterns/process/deployment-antipatterns.md +920 -0
  145. package/expertise/antipatterns/process/index.md +23 -0
  146. package/expertise/antipatterns/process/technical-debt-antipatterns.md +647 -0
  147. package/expertise/antipatterns/security/index.md +20 -0
  148. package/expertise/antipatterns/security/secrets-antipatterns.md +849 -0
  149. package/expertise/antipatterns/security/security-theater.md +843 -0
  150. package/expertise/antipatterns/security/vulnerability-patterns.md +801 -0
  151. package/expertise/architecture/PROGRESS.md +70 -0
  152. package/expertise/architecture/data/caching-architecture.md +671 -0
  153. package/expertise/architecture/data/data-consistency.md +574 -0
  154. package/expertise/architecture/data/data-modeling.md +536 -0
  155. package/expertise/architecture/data/event-streams-and-queues.md +634 -0
  156. package/expertise/architecture/data/index.md +25 -0
  157. package/expertise/architecture/data/search-architecture.md +663 -0
  158. package/expertise/architecture/data/sql-vs-nosql.md +708 -0
  159. package/expertise/architecture/decisions/architecture-decision-records.md +640 -0
  160. package/expertise/architecture/decisions/build-vs-buy.md +616 -0
  161. package/expertise/architecture/decisions/index.md +23 -0
  162. package/expertise/architecture/decisions/monolith-to-microservices.md +790 -0
  163. package/expertise/architecture/decisions/technology-selection.md +616 -0
  164. package/expertise/architecture/distributed/cap-theorem-and-tradeoffs.md +800 -0
  165. package/expertise/architecture/distributed/circuit-breaker-bulkhead.md +741 -0
  166. package/expertise/architecture/distributed/consensus-and-coordination.md +796 -0
  167. package/expertise/architecture/distributed/distributed-systems-fundamentals.md +564 -0
  168. package/expertise/architecture/distributed/idempotency-and-retry.md +796 -0
  169. package/expertise/architecture/distributed/index.md +25 -0
  170. package/expertise/architecture/distributed/saga-pattern.md +797 -0
  171. package/expertise/architecture/foundations/architectural-thinking.md +460 -0
  172. package/expertise/architecture/foundations/coupling-and-cohesion.md +770 -0
  173. package/expertise/architecture/foundations/design-principles-solid.md +649 -0
  174. package/expertise/architecture/foundations/domain-driven-design.md +719 -0
  175. package/expertise/architecture/foundations/index.md +25 -0
  176. package/expertise/architecture/foundations/separation-of-concerns.md +472 -0
  177. package/expertise/architecture/foundations/twelve-factor-app.md +797 -0
  178. package/expertise/architecture/index.md +34 -0
  179. package/expertise/architecture/integration/api-design-graphql.md +638 -0
  180. package/expertise/architecture/integration/api-design-grpc.md +804 -0
  181. package/expertise/architecture/integration/api-design-rest.md +892 -0
  182. package/expertise/architecture/integration/index.md +25 -0
  183. package/expertise/architecture/integration/third-party-integration.md +795 -0
  184. package/expertise/architecture/integration/webhooks-and-callbacks.md +1152 -0
  185. package/expertise/architecture/integration/websockets-realtime.md +791 -0
  186. package/expertise/architecture/mobile-architecture/index.md +22 -0
  187. package/expertise/architecture/mobile-architecture/mobile-app-architecture.md +780 -0
  188. package/expertise/architecture/mobile-architecture/mobile-backend-for-frontend.md +670 -0
  189. package/expertise/architecture/mobile-architecture/offline-first.md +719 -0
  190. package/expertise/architecture/mobile-architecture/push-and-sync.md +782 -0
  191. package/expertise/architecture/patterns/cqrs-event-sourcing.md +717 -0
  192. package/expertise/architecture/patterns/event-driven.md +797 -0
  193. package/expertise/architecture/patterns/hexagonal-clean-architecture.md +870 -0
  194. package/expertise/architecture/patterns/index.md +27 -0
  195. package/expertise/architecture/patterns/layered-architecture.md +736 -0
  196. package/expertise/architecture/patterns/microservices.md +753 -0
  197. package/expertise/architecture/patterns/modular-monolith.md +692 -0
  198. package/expertise/architecture/patterns/monolith.md +626 -0
  199. package/expertise/architecture/patterns/plugin-architecture.md +735 -0
  200. package/expertise/architecture/patterns/serverless.md +780 -0
  201. package/expertise/architecture/scaling/database-scaling.md +615 -0
  202. package/expertise/architecture/scaling/feature-flags-and-rollouts.md +757 -0
  203. package/expertise/architecture/scaling/horizontal-vs-vertical.md +606 -0
  204. package/expertise/architecture/scaling/index.md +24 -0
  205. package/expertise/architecture/scaling/multi-tenancy.md +800 -0
  206. package/expertise/architecture/scaling/stateless-design.md +787 -0
  207. package/expertise/backend/embedded-firmware.md +625 -0
  208. package/expertise/backend/go.md +853 -0
  209. package/expertise/backend/index.md +24 -0
  210. package/expertise/backend/java-spring.md +448 -0
  211. package/expertise/backend/node-typescript.md +625 -0
  212. package/expertise/backend/python-fastapi.md +724 -0
  213. package/expertise/backend/rust.md +458 -0
  214. package/expertise/backend/solidity.md +711 -0
  215. package/expertise/composition-map.yaml +443 -0
  216. package/expertise/content/foundations/content-modeling.md +395 -0
  217. package/expertise/content/foundations/editorial-standards.md +449 -0
  218. package/expertise/content/foundations/index.md +24 -0
  219. package/expertise/content/foundations/microcopy.md +455 -0
  220. package/expertise/content/foundations/terminology-governance.md +509 -0
  221. package/expertise/content/index.md +34 -0
  222. package/expertise/content/patterns/accessibility-copy.md +518 -0
  223. package/expertise/content/patterns/index.md +24 -0
  224. package/expertise/content/patterns/notification-content.md +433 -0
  225. package/expertise/content/patterns/sample-content.md +486 -0
  226. package/expertise/content/patterns/state-copy.md +439 -0
  227. package/expertise/design/PROGRESS.md +58 -0
  228. package/expertise/design/disciplines/dark-mode-theming.md +577 -0
  229. package/expertise/design/disciplines/design-systems.md +595 -0
  230. package/expertise/design/disciplines/index.md +25 -0
  231. package/expertise/design/disciplines/information-architecture.md +800 -0
  232. package/expertise/design/disciplines/interaction-design.md +788 -0
  233. package/expertise/design/disciplines/responsive-design.md +552 -0
  234. package/expertise/design/disciplines/usability-testing.md +516 -0
  235. package/expertise/design/disciplines/user-research.md +792 -0
  236. package/expertise/design/foundations/accessibility-design.md +796 -0
  237. package/expertise/design/foundations/color-theory.md +797 -0
  238. package/expertise/design/foundations/iconography.md +795 -0
  239. package/expertise/design/foundations/index.md +26 -0
  240. package/expertise/design/foundations/motion-and-animation.md +653 -0
  241. package/expertise/design/foundations/rtl-design.md +585 -0
  242. package/expertise/design/foundations/spacing-and-layout.md +607 -0
  243. package/expertise/design/foundations/typography.md +800 -0
  244. package/expertise/design/foundations/visual-hierarchy.md +761 -0
  245. package/expertise/design/index.md +32 -0
  246. package/expertise/design/patterns/authentication-flows.md +474 -0
  247. package/expertise/design/patterns/content-consumption.md +789 -0
  248. package/expertise/design/patterns/data-display.md +618 -0
  249. package/expertise/design/patterns/e-commerce.md +1494 -0
  250. package/expertise/design/patterns/feedback-and-states.md +642 -0
  251. package/expertise/design/patterns/forms-and-input.md +819 -0
  252. package/expertise/design/patterns/gamification.md +801 -0
  253. package/expertise/design/patterns/index.md +31 -0
  254. package/expertise/design/patterns/microinteractions.md +449 -0
  255. package/expertise/design/patterns/navigation.md +800 -0
  256. package/expertise/design/patterns/notifications.md +705 -0
  257. package/expertise/design/patterns/onboarding.md +700 -0
  258. package/expertise/design/patterns/search-and-filter.md +601 -0
  259. package/expertise/design/patterns/settings-and-preferences.md +768 -0
  260. package/expertise/design/patterns/social-and-community.md +748 -0
  261. package/expertise/design/platforms/desktop-native.md +612 -0
  262. package/expertise/design/platforms/index.md +25 -0
  263. package/expertise/design/platforms/mobile-android.md +825 -0
  264. package/expertise/design/platforms/mobile-cross-platform.md +983 -0
  265. package/expertise/design/platforms/mobile-ios.md +699 -0
  266. package/expertise/design/platforms/tablet.md +794 -0
  267. package/expertise/design/platforms/web-dashboard.md +790 -0
  268. package/expertise/design/platforms/web-responsive.md +550 -0
  269. package/expertise/design/psychology/behavioral-nudges.md +449 -0
  270. package/expertise/design/psychology/cognitive-load.md +1191 -0
  271. package/expertise/design/psychology/error-psychology.md +778 -0
  272. package/expertise/design/psychology/index.md +22 -0
  273. package/expertise/design/psychology/persuasive-design.md +736 -0
  274. package/expertise/design/psychology/user-mental-models.md +623 -0
  275. package/expertise/design/tooling/open-pencil.md +266 -0
  276. package/expertise/frontend/angular.md +1073 -0
  277. package/expertise/frontend/desktop-electron.md +546 -0
  278. package/expertise/frontend/flutter.md +782 -0
  279. package/expertise/frontend/index.md +27 -0
  280. package/expertise/frontend/native-android.md +409 -0
  281. package/expertise/frontend/native-ios.md +490 -0
  282. package/expertise/frontend/react-native.md +1160 -0
  283. package/expertise/frontend/react.md +808 -0
  284. package/expertise/frontend/vue.md +1089 -0
  285. package/expertise/humanize/domain-rules-code.md +79 -0
  286. package/expertise/humanize/domain-rules-content.md +67 -0
  287. package/expertise/humanize/domain-rules-technical-docs.md +56 -0
  288. package/expertise/humanize/index.md +35 -0
  289. package/expertise/humanize/self-audit-checklist.md +87 -0
  290. package/expertise/humanize/sentence-patterns.md +218 -0
  291. package/expertise/humanize/vocabulary-blacklist.md +105 -0
  292. package/expertise/i18n/PROGRESS.md +65 -0
  293. package/expertise/i18n/advanced/accessibility-and-i18n.md +28 -0
  294. package/expertise/i18n/advanced/bidirectional-text-algorithm.md +38 -0
  295. package/expertise/i18n/advanced/complex-scripts.md +30 -0
  296. package/expertise/i18n/advanced/performance-and-i18n.md +27 -0
  297. package/expertise/i18n/advanced/testing-i18n.md +28 -0
  298. package/expertise/i18n/content/content-adaptation.md +23 -0
  299. package/expertise/i18n/content/locale-specific-formatting.md +23 -0
  300. package/expertise/i18n/content/machine-translation-integration.md +28 -0
  301. package/expertise/i18n/content/translation-management.md +29 -0
  302. package/expertise/i18n/foundations/date-time-calendars.md +67 -0
  303. package/expertise/i18n/foundations/i18n-architecture.md +272 -0
  304. package/expertise/i18n/foundations/locale-and-language-tags.md +79 -0
  305. package/expertise/i18n/foundations/numbers-currency-units.md +61 -0
  306. package/expertise/i18n/foundations/pluralization-and-gender.md +109 -0
  307. package/expertise/i18n/foundations/string-externalization.md +236 -0
  308. package/expertise/i18n/foundations/text-direction-bidi.md +241 -0
  309. package/expertise/i18n/foundations/unicode-and-encoding.md +86 -0
  310. package/expertise/i18n/index.md +38 -0
  311. package/expertise/i18n/platform/backend-i18n.md +31 -0
  312. package/expertise/i18n/platform/flutter-i18n.md +148 -0
  313. package/expertise/i18n/platform/native-android-i18n.md +36 -0
  314. package/expertise/i18n/platform/native-ios-i18n.md +36 -0
  315. package/expertise/i18n/platform/react-i18n.md +103 -0
  316. package/expertise/i18n/platform/web-css-i18n.md +81 -0
  317. package/expertise/i18n/rtl/arabic-specific.md +175 -0
  318. package/expertise/i18n/rtl/hebrew-specific.md +149 -0
  319. package/expertise/i18n/rtl/rtl-animations-and-transitions.md +111 -0
  320. package/expertise/i18n/rtl/rtl-forms-and-input.md +161 -0
  321. package/expertise/i18n/rtl/rtl-fundamentals.md +211 -0
  322. package/expertise/i18n/rtl/rtl-icons-and-images.md +181 -0
  323. package/expertise/i18n/rtl/rtl-layout-mirroring.md +252 -0
  324. package/expertise/i18n/rtl/rtl-navigation-and-gestures.md +107 -0
  325. package/expertise/i18n/rtl/rtl-testing-and-qa.md +147 -0
  326. package/expertise/i18n/rtl/rtl-typography.md +160 -0
  327. package/expertise/index.md +113 -0
  328. package/expertise/index.yaml +216 -0
  329. package/expertise/infrastructure/cloud-aws.md +597 -0
  330. package/expertise/infrastructure/cloud-gcp.md +599 -0
  331. package/expertise/infrastructure/cybersecurity.md +816 -0
  332. package/expertise/infrastructure/database-mongodb.md +447 -0
  333. package/expertise/infrastructure/database-postgres.md +400 -0
  334. package/expertise/infrastructure/devops-cicd.md +787 -0
  335. package/expertise/infrastructure/index.md +27 -0
  336. package/expertise/performance/PROGRESS.md +50 -0
  337. package/expertise/performance/backend/api-latency.md +1204 -0
  338. package/expertise/performance/backend/background-jobs.md +506 -0
  339. package/expertise/performance/backend/connection-pooling.md +1209 -0
  340. package/expertise/performance/backend/database-query-optimization.md +515 -0
  341. package/expertise/performance/backend/index.md +23 -0
  342. package/expertise/performance/backend/rate-limiting-and-throttling.md +971 -0
  343. package/expertise/performance/foundations/algorithmic-complexity.md +954 -0
  344. package/expertise/performance/foundations/caching-strategies.md +489 -0
  345. package/expertise/performance/foundations/concurrency-and-parallelism.md +847 -0
  346. package/expertise/performance/foundations/index.md +24 -0
  347. package/expertise/performance/foundations/measuring-and-profiling.md +440 -0
  348. package/expertise/performance/foundations/memory-management.md +964 -0
  349. package/expertise/performance/foundations/performance-budgets.md +1314 -0
  350. package/expertise/performance/index.md +31 -0
  351. package/expertise/performance/infrastructure/auto-scaling.md +1059 -0
  352. package/expertise/performance/infrastructure/cdn-and-edge.md +1081 -0
  353. package/expertise/performance/infrastructure/index.md +22 -0
  354. package/expertise/performance/infrastructure/load-balancing.md +1081 -0
  355. package/expertise/performance/infrastructure/observability.md +1079 -0
  356. package/expertise/performance/mobile/index.md +23 -0
  357. package/expertise/performance/mobile/mobile-animations.md +544 -0
  358. package/expertise/performance/mobile/mobile-memory-battery.md +416 -0
  359. package/expertise/performance/mobile/mobile-network.md +452 -0
  360. package/expertise/performance/mobile/mobile-rendering.md +599 -0
  361. package/expertise/performance/mobile/mobile-startup-time.md +505 -0
  362. package/expertise/performance/platform-specific/flutter-performance.md +647 -0
  363. package/expertise/performance/platform-specific/index.md +22 -0
  364. package/expertise/performance/platform-specific/node-performance.md +1307 -0
  365. package/expertise/performance/platform-specific/postgres-performance.md +1366 -0
  366. package/expertise/performance/platform-specific/react-performance.md +1403 -0
  367. package/expertise/performance/web/bundle-optimization.md +1239 -0
  368. package/expertise/performance/web/image-and-media.md +636 -0
  369. package/expertise/performance/web/index.md +24 -0
  370. package/expertise/performance/web/network-optimization.md +1133 -0
  371. package/expertise/performance/web/rendering-performance.md +1098 -0
  372. package/expertise/performance/web/ssr-and-hydration.md +918 -0
  373. package/expertise/performance/web/web-vitals.md +1374 -0
  374. package/expertise/quality/accessibility.md +985 -0
  375. package/expertise/quality/evidence-based-verification.md +499 -0
  376. package/expertise/quality/index.md +24 -0
  377. package/expertise/quality/ml-model-audit.md +614 -0
  378. package/expertise/quality/performance.md +600 -0
  379. package/expertise/quality/testing-api.md +891 -0
  380. package/expertise/quality/testing-mobile.md +496 -0
  381. package/expertise/quality/testing-web.md +849 -0
  382. package/expertise/security/PROGRESS.md +54 -0
  383. package/expertise/security/agentic-identity.md +540 -0
  384. package/expertise/security/compliance-frameworks.md +601 -0
  385. package/expertise/security/data/data-encryption.md +364 -0
  386. package/expertise/security/data/data-privacy-gdpr.md +692 -0
  387. package/expertise/security/data/database-security.md +1171 -0
  388. package/expertise/security/data/index.md +22 -0
  389. package/expertise/security/data/pii-handling.md +531 -0
  390. package/expertise/security/foundations/authentication.md +1041 -0
  391. package/expertise/security/foundations/authorization.md +603 -0
  392. package/expertise/security/foundations/cryptography.md +1001 -0
  393. package/expertise/security/foundations/index.md +25 -0
  394. package/expertise/security/foundations/owasp-top-10.md +1354 -0
  395. package/expertise/security/foundations/secrets-management.md +1217 -0
  396. package/expertise/security/foundations/secure-sdlc.md +700 -0
  397. package/expertise/security/foundations/supply-chain-security.md +698 -0
  398. package/expertise/security/index.md +31 -0
  399. package/expertise/security/infrastructure/cloud-security-aws.md +1296 -0
  400. package/expertise/security/infrastructure/cloud-security-gcp.md +1376 -0
  401. package/expertise/security/infrastructure/container-security.md +721 -0
  402. package/expertise/security/infrastructure/incident-response.md +1295 -0
  403. package/expertise/security/infrastructure/index.md +24 -0
  404. package/expertise/security/infrastructure/logging-and-monitoring.md +1618 -0
  405. package/expertise/security/infrastructure/network-security.md +1337 -0
  406. package/expertise/security/mobile/index.md +23 -0
  407. package/expertise/security/mobile/mobile-android-security.md +1218 -0
  408. package/expertise/security/mobile/mobile-binary-protection.md +1229 -0
  409. package/expertise/security/mobile/mobile-data-storage.md +1265 -0
  410. package/expertise/security/mobile/mobile-ios-security.md +1401 -0
  411. package/expertise/security/mobile/mobile-network-security.md +1520 -0
  412. package/expertise/security/smart-contract-security.md +594 -0
  413. package/expertise/security/testing/index.md +22 -0
  414. package/expertise/security/testing/penetration-testing.md +1258 -0
  415. package/expertise/security/testing/security-code-review.md +1765 -0
  416. package/expertise/security/testing/threat-modeling.md +1074 -0
  417. package/expertise/security/testing/vulnerability-scanning.md +1062 -0
  418. package/expertise/security/web/api-security.md +586 -0
  419. package/expertise/security/web/cors-and-headers.md +433 -0
  420. package/expertise/security/web/csrf.md +562 -0
  421. package/expertise/security/web/file-upload.md +1477 -0
  422. package/expertise/security/web/index.md +25 -0
  423. package/expertise/security/web/injection.md +1375 -0
  424. package/expertise/security/web/session-management.md +1101 -0
  425. package/expertise/security/web/xss.md +1158 -0
  426. package/exports/README.md +17 -0
  427. package/exports/hosts/claude/.claude/agents/clarifier.md +42 -0
  428. package/exports/hosts/claude/.claude/agents/content-author.md +63 -0
  429. package/exports/hosts/claude/.claude/agents/designer.md +55 -0
  430. package/exports/hosts/claude/.claude/agents/executor.md +55 -0
  431. package/exports/hosts/claude/.claude/agents/learner.md +51 -0
  432. package/exports/hosts/claude/.claude/agents/planner.md +53 -0
  433. package/exports/hosts/claude/.claude/agents/researcher.md +43 -0
  434. package/exports/hosts/claude/.claude/agents/reviewer.md +54 -0
  435. package/exports/hosts/claude/.claude/agents/specifier.md +47 -0
  436. package/exports/hosts/claude/.claude/agents/verifier.md +71 -0
  437. package/exports/hosts/claude/.claude/commands/author.md +42 -0
  438. package/exports/hosts/claude/.claude/commands/clarify.md +38 -0
  439. package/exports/hosts/claude/.claude/commands/design-review.md +46 -0
  440. package/exports/hosts/claude/.claude/commands/design.md +44 -0
  441. package/exports/hosts/claude/.claude/commands/discover.md +37 -0
  442. package/exports/hosts/claude/.claude/commands/execute.md +48 -0
  443. package/exports/hosts/claude/.claude/commands/learn.md +38 -0
  444. package/exports/hosts/claude/.claude/commands/plan-review.md +42 -0
  445. package/exports/hosts/claude/.claude/commands/plan.md +39 -0
  446. package/exports/hosts/claude/.claude/commands/prepare-next.md +37 -0
  447. package/exports/hosts/claude/.claude/commands/review.md +40 -0
  448. package/exports/hosts/claude/.claude/commands/run-audit.md +41 -0
  449. package/exports/hosts/claude/.claude/commands/spec-challenge.md +41 -0
  450. package/exports/hosts/claude/.claude/commands/specify.md +38 -0
  451. package/exports/hosts/claude/.claude/commands/verify.md +37 -0
  452. package/exports/hosts/claude/.claude/settings.json +34 -0
  453. package/exports/hosts/claude/CLAUDE.md +19 -0
  454. package/exports/hosts/claude/export.manifest.json +38 -0
  455. package/exports/hosts/claude/host-package.json +67 -0
  456. package/exports/hosts/codex/AGENTS.md +19 -0
  457. package/exports/hosts/codex/export.manifest.json +38 -0
  458. package/exports/hosts/codex/host-package.json +41 -0
  459. package/exports/hosts/cursor/.cursor/hooks.json +16 -0
  460. package/exports/hosts/cursor/.cursor/rules/wazir-core.mdc +19 -0
  461. package/exports/hosts/cursor/export.manifest.json +38 -0
  462. package/exports/hosts/cursor/host-package.json +42 -0
  463. package/exports/hosts/gemini/GEMINI.md +19 -0
  464. package/exports/hosts/gemini/export.manifest.json +38 -0
  465. package/exports/hosts/gemini/host-package.json +41 -0
  466. package/hooks/README.md +18 -0
  467. package/hooks/definitions/loop_cap_guard.yaml +21 -0
  468. package/hooks/definitions/post_tool_capture.yaml +24 -0
  469. package/hooks/definitions/pre_compact_summary.yaml +19 -0
  470. package/hooks/definitions/pre_tool_capture_route.yaml +19 -0
  471. package/hooks/definitions/protected_path_write_guard.yaml +19 -0
  472. package/hooks/definitions/session_start.yaml +19 -0
  473. package/hooks/definitions/stop_handoff_harvest.yaml +20 -0
  474. package/hooks/loop-cap-guard +17 -0
  475. package/hooks/post-tool-lint +36 -0
  476. package/hooks/protected-path-write-guard +17 -0
  477. package/hooks/session-start +41 -0
  478. package/llms-full.txt +2355 -0
  479. package/llms.txt +43 -0
  480. package/package.json +79 -0
  481. package/roles/README.md +20 -0
  482. package/roles/clarifier.md +42 -0
  483. package/roles/content-author.md +63 -0
  484. package/roles/designer.md +55 -0
  485. package/roles/executor.md +55 -0
  486. package/roles/learner.md +51 -0
  487. package/roles/planner.md +53 -0
  488. package/roles/researcher.md +43 -0
  489. package/roles/reviewer.md +54 -0
  490. package/roles/specifier.md +47 -0
  491. package/roles/verifier.md +71 -0
  492. package/schemas/README.md +24 -0
  493. package/schemas/accepted-learning.schema.json +20 -0
  494. package/schemas/author-artifact.schema.json +156 -0
  495. package/schemas/clarification.schema.json +19 -0
  496. package/schemas/design-artifact.schema.json +80 -0
  497. package/schemas/docs-claim.schema.json +18 -0
  498. package/schemas/export-manifest.schema.json +20 -0
  499. package/schemas/hook.schema.json +67 -0
  500. package/schemas/host-export-package.schema.json +18 -0
  501. package/schemas/implementation-plan.schema.json +19 -0
  502. package/schemas/proposed-learning.schema.json +19 -0
  503. package/schemas/research.schema.json +18 -0
  504. package/schemas/review.schema.json +29 -0
  505. package/schemas/run-manifest.schema.json +18 -0
  506. package/schemas/spec-challenge.schema.json +18 -0
  507. package/schemas/spec.schema.json +20 -0
  508. package/schemas/usage.schema.json +102 -0
  509. package/schemas/verification-proof.schema.json +29 -0
  510. package/schemas/wazir-manifest.schema.json +173 -0
  511. package/skills/README.md +40 -0
  512. package/skills/brainstorming/SKILL.md +77 -0
  513. package/skills/debugging/SKILL.md +50 -0
  514. package/skills/design/SKILL.md +61 -0
  515. package/skills/dispatching-parallel-agents/SKILL.md +128 -0
  516. package/skills/executing-plans/SKILL.md +70 -0
  517. package/skills/finishing-a-development-branch/SKILL.md +169 -0
  518. package/skills/humanize/SKILL.md +123 -0
  519. package/skills/init-pipeline/SKILL.md +124 -0
  520. package/skills/prepare-next/SKILL.md +20 -0
  521. package/skills/receiving-code-review/SKILL.md +123 -0
  522. package/skills/requesting-code-review/SKILL.md +105 -0
  523. package/skills/requesting-code-review/code-reviewer.md +108 -0
  524. package/skills/run-audit/SKILL.md +197 -0
  525. package/skills/scan-project/SKILL.md +41 -0
  526. package/skills/self-audit/SKILL.md +153 -0
  527. package/skills/subagent-driven-development/SKILL.md +154 -0
  528. package/skills/subagent-driven-development/code-quality-reviewer-prompt.md +26 -0
  529. package/skills/subagent-driven-development/implementer-prompt.md +102 -0
  530. package/skills/subagent-driven-development/spec-reviewer-prompt.md +61 -0
  531. package/skills/tdd/SKILL.md +23 -0
  532. package/skills/using-git-worktrees/SKILL.md +163 -0
  533. package/skills/using-skills/SKILL.md +95 -0
  534. package/skills/verification/SKILL.md +22 -0
  535. package/skills/wazir/SKILL.md +463 -0
  536. package/skills/writing-plans/SKILL.md +30 -0
  537. package/skills/writing-skills/SKILL.md +157 -0
  538. package/skills/writing-skills/anthropic-best-practices.md +122 -0
  539. package/skills/writing-skills/persuasion-principles.md +50 -0
  540. package/templates/README.md +20 -0
  541. package/templates/artifacts/README.md +10 -0
  542. package/templates/artifacts/accepted-learning.md +19 -0
  543. package/templates/artifacts/accepted-learning.template.json +12 -0
  544. package/templates/artifacts/author.md +74 -0
  545. package/templates/artifacts/author.template.json +19 -0
  546. package/templates/artifacts/clarification.md +21 -0
  547. package/templates/artifacts/clarification.template.json +12 -0
  548. package/templates/artifacts/execute-notes.md +19 -0
  549. package/templates/artifacts/implementation-plan.md +21 -0
  550. package/templates/artifacts/implementation-plan.template.json +11 -0
  551. package/templates/artifacts/learning-proposal.md +19 -0
  552. package/templates/artifacts/next-run-handoff.md +21 -0
  553. package/templates/artifacts/plan-review.md +19 -0
  554. package/templates/artifacts/proposed-learning.template.json +12 -0
  555. package/templates/artifacts/research.md +21 -0
  556. package/templates/artifacts/research.template.json +12 -0
  557. package/templates/artifacts/review-findings.md +19 -0
  558. package/templates/artifacts/review.template.json +11 -0
  559. package/templates/artifacts/run-manifest.template.json +8 -0
  560. package/templates/artifacts/spec-challenge.md +19 -0
  561. package/templates/artifacts/spec-challenge.template.json +11 -0
  562. package/templates/artifacts/spec.md +21 -0
  563. package/templates/artifacts/spec.template.json +12 -0
  564. package/templates/artifacts/verification-proof.md +19 -0
  565. package/templates/artifacts/verification-proof.template.json +11 -0
  566. package/templates/examples/accepted-learning.example.json +14 -0
  567. package/templates/examples/author.example.json +152 -0
  568. package/templates/examples/clarification.example.json +15 -0
  569. package/templates/examples/docs-claim.example.json +8 -0
  570. package/templates/examples/export-manifest.example.json +7 -0
  571. package/templates/examples/host-export-package.example.json +11 -0
  572. package/templates/examples/implementation-plan.example.json +17 -0
  573. package/templates/examples/proposed-learning.example.json +13 -0
  574. package/templates/examples/research.example.json +15 -0
  575. package/templates/examples/research.example.md +6 -0
  576. package/templates/examples/review.example.json +17 -0
  577. package/templates/examples/run-manifest.example.json +9 -0
  578. package/templates/examples/spec-challenge.example.json +14 -0
  579. package/templates/examples/spec.example.json +21 -0
  580. package/templates/examples/verification-proof.example.json +21 -0
  581. package/templates/examples/wazir-manifest.example.yaml +65 -0
  582. package/templates/task-definition-schema.md +99 -0
  583. package/tooling/README.md +20 -0
  584. package/tooling/src/adapters/context-mode.js +50 -0
  585. package/tooling/src/capture/command.js +376 -0
  586. package/tooling/src/capture/store.js +99 -0
  587. package/tooling/src/capture/usage.js +270 -0
  588. package/tooling/src/checks/branches.js +50 -0
  589. package/tooling/src/checks/brand-truth.js +110 -0
  590. package/tooling/src/checks/changelog.js +231 -0
  591. package/tooling/src/checks/command-registry.js +36 -0
  592. package/tooling/src/checks/commits.js +102 -0
  593. package/tooling/src/checks/docs-drift.js +103 -0
  594. package/tooling/src/checks/docs-truth.js +201 -0
  595. package/tooling/src/checks/runtime-surface.js +156 -0
  596. package/tooling/src/cli.js +116 -0
  597. package/tooling/src/command-options.js +56 -0
  598. package/tooling/src/commands/validate.js +320 -0
  599. package/tooling/src/doctor/command.js +91 -0
  600. package/tooling/src/export/command.js +77 -0
  601. package/tooling/src/export/compiler.js +498 -0
  602. package/tooling/src/guards/loop-cap-guard.js +52 -0
  603. package/tooling/src/guards/protected-path-write-guard.js +67 -0
  604. package/tooling/src/index/command.js +152 -0
  605. package/tooling/src/index/storage.js +1061 -0
  606. package/tooling/src/index/summarizers.js +261 -0
  607. package/tooling/src/loaders.js +18 -0
  608. package/tooling/src/project-root.js +22 -0
  609. package/tooling/src/recall/command.js +225 -0
  610. package/tooling/src/schema-validator.js +30 -0
  611. package/tooling/src/state-root.js +40 -0
  612. package/tooling/src/status/command.js +71 -0
  613. package/wazir.manifest.yaml +135 -0
  614. package/workflows/README.md +19 -0
  615. package/workflows/author.md +42 -0
  616. package/workflows/clarify.md +38 -0
  617. package/workflows/design-review.md +46 -0
  618. package/workflows/design.md +44 -0
  619. package/workflows/discover.md +37 -0
  620. package/workflows/execute.md +48 -0
  621. package/workflows/learn.md +38 -0
  622. package/workflows/plan-review.md +42 -0
  623. package/workflows/plan.md +39 -0
  624. package/workflows/prepare-next.md +37 -0
  625. package/workflows/review.md +40 -0
  626. package/workflows/run-audit.md +41 -0
  627. package/workflows/spec-challenge.md +41 -0
  628. package/workflows/specify.md +38 -0
  629. package/workflows/verify.md +37 -0
@@ -0,0 +1,816 @@
1
+ # Cybersecurity — Expertise Module
2
+
3
+ > A cybersecurity specialist in software development embeds security into every phase of the SDLC — from threat modeling and secure design through implementation, testing, deployment, and incident response. The scope spans application security (AppSec), infrastructure hardening, identity and access management, supply chain integrity, compliance, and continuous monitoring across cloud-native and traditional environments.
4
+
5
+ ---
6
+
7
+ ## Core Patterns & Conventions
8
+
9
+ ### Secure Development Lifecycle (SDL / SSDLC)
10
+
11
+ The Secure Software Development Lifecycle integrates security activities into each phase:
12
+
13
+ 1. **Planning** — Threat modeling (STRIDE, PASTA), security requirements, abuse case analysis
14
+ 2. **Design** — Secure architecture review, trust boundary identification, least-privilege design
15
+ 3. **Implementation** — Secure coding standards (OWASP Secure Coding Practices), peer review
16
+ 4. **Testing** — SAST, DAST, SCA, penetration testing, fuzz testing
17
+ 5. **Deployment** — Hardened configurations, secrets injection, infrastructure scanning
18
+ 6. **Operations** — Runtime monitoring, incident response, vulnerability management
19
+ 7. **Decommission** — Data sanitization, credential revocation, access removal
20
+
21
+ Reference: Microsoft SDL, NIST SP 800-218 (SSDF), OWASP SAMM.
22
+
23
+ ### OWASP Top 10 (2021 / 2025)
24
+
25
+ The OWASP Top 10 was updated in 2025 with significant changes. Key vulnerabilities and prevention patterns:
26
+
27
+ | # | Vulnerability | Prevention Pattern |
28
+ |---|---|---|
29
+ | A01 | **Broken Access Control** | Deny by default; enforce server-side access checks; use RBAC/ABAC; disable directory listing; log access failures; rate-limit APIs |
30
+ | A02 | **Security Misconfiguration** (moved to #2 in 2025) | Automated hardening; minimal installs; disable unused features; review cloud IAM policies; use CIS Benchmarks |
31
+ | A03 | **Software Supply Chain Failures** (new in 2025, expands A06:2021) | Generate SBOMs (SPDX, CycloneDX); sign artifacts with Sigstore; enforce SLSA provenance; pin dependencies; use lockfiles |
32
+ | A04 | **Cryptographic Failures** (was #2 in 2021) | Enforce TLS 1.2+; use AES-256-GCM or ChaCha20-Poly1305; hash passwords with Argon2id; never roll custom crypto; classify data sensitivity |
33
+ | A05 | **Injection** (was #3 in 2021) | Parameterized queries; ORM usage; input validation (allowlist); output encoding; CSP headers |
34
+ | A06 | **Insecure Design** | Threat model early; use secure design patterns; establish paved roads; integrate security user stories |
35
+ | A07 | **Identification & Authentication Failures** | MFA enforcement; WebAuthn/passkeys; rate-limit login; use proven IdP libraries; ban common passwords (NIST SP 800-63B) |
36
+ | A08 | **Software & Data Integrity Failures** | Verify signatures on updates and dependencies; protect CI/CD pipelines; use Subresource Integrity (SRI) for CDN assets |
37
+ | A09 | **Security Logging & Monitoring Failures** | Log authentication, access control, and input validation failures; centralize logs (SIEM); set up alerting; retain logs per compliance |
38
+ | A10 | **Mishandling of Exceptional Conditions** (new in 2025) | Never expose stack traces; fail closed (not open); handle all error paths; use typed errors; test edge cases |
39
+
40
+ Source: OWASP Top 10:2021, OWASP Top 10:2025.
41
+
42
+ ### Authentication Patterns
43
+
44
+ **OAuth 2.1** consolidates best practices from OAuth 2.0 extensions:
45
+ - Mandatory PKCE for all clients (not just public clients)
46
+ - Refresh token rotation with sender-constrained tokens
47
+ - No implicit grant; no ROPC grant
48
+ - Exact redirect URI matching required
49
+
50
+ **OpenID Connect (OIDC)** adds identity layer atop OAuth 2.1:
51
+ - ID tokens for authentication; access tokens for authorization
52
+ - Use `nonce` parameter to prevent replay attacks
53
+ - Validate `iss`, `aud`, `exp`, `iat` claims server-side
54
+
55
+ **WebAuthn / Passkeys (FIDO2):**
56
+ - Cryptographic key pairs bound to specific origin (phishing-resistant by design)
57
+ - Passkeys synced across devices via platform authenticators (Apple, Google, Microsoft)
58
+ - Recommended as primary auth for consumer and enterprise apps in 2025-2026
59
+ - Use as MFA factor or standalone passwordless authentication
60
+
61
+ **Multi-Factor Authentication (MFA):**
62
+ - Prefer hardware keys (YubiKey) or passkeys over TOTP over SMS
63
+ - SMS-based MFA vulnerable to SIM-swap attacks — use only as fallback
64
+ - Enforce MFA for all privileged accounts and administrative access
65
+
66
+ ### Authorization Models
67
+
68
+ **RBAC (Role-Based Access Control):**
69
+ - Assign permissions to roles, roles to users
70
+ - Best for: stable permission structures, small number of well-defined roles
71
+ - Limitation: "role explosion" when permissions become context-dependent
72
+
73
+ **ABAC (Attribute-Based Access Control):**
74
+ - Evaluate attributes of user, resource, action, and environment
75
+ - Best for: complex conditional logic (time, location, data classification)
76
+ - Implementation: Open Policy Agent (OPA), Cedar (AWS), Casbin
77
+
78
+ **ReBAC (Relationship-Based Access Control):**
79
+ - Permissions derived from entity relationships (owner-of, member-of, parent-of)
80
+ - Best for: hierarchical data (documents, organizations, projects)
81
+ - Implementation: Google Zanzibar model, SpiceDB, Ory Keto, Authzed
82
+
83
+ **Best practice (2025):** Start with RBAC; layer ABAC for context-dependent rules; add ReBAC for relationship-driven resources. Use a dedicated authorization service rather than embedding logic in application code.
84
+
85
+ ### Cryptography Best Practices
86
+
87
+ **Hashing:**
88
+ - Passwords: Argon2id (preferred), bcrypt (cost >= 12), scrypt
89
+ - Data integrity: SHA-256 or SHA-3; never MD5 or SHA-1
90
+ - HMAC for message authentication: HMAC-SHA256 minimum
91
+
92
+ **Symmetric Encryption:**
93
+ - AES-256-GCM (authenticated encryption) for data at rest
94
+ - ChaCha20-Poly1305 for environments without AES hardware acceleration
95
+ - Never use ECB mode — it leaks plaintext patterns
96
+
97
+ **Asymmetric Encryption:**
98
+ - RSA: minimum 2048-bit keys (3072+ recommended by NIST for post-2030)
99
+ - Ed25519 for signatures (faster, shorter keys than RSA)
100
+ - X25519 for key exchange
101
+
102
+ **Key Management:**
103
+ - Rotate encryption keys periodically (90 days for high-sensitivity)
104
+ - Use envelope encryption (encrypt data key with master key)
105
+ - Store master keys in HSMs or cloud KMS (AWS KMS, GCP KMS, Azure Key Vault)
106
+ - Never hardcode keys in source code
107
+
108
+ Reference: NIST SP 800-175B, NIST SP 800-131A Rev 2.
109
+
110
+ ### Secure API Design
111
+
112
+ - **Input validation:** Validate all inputs server-side using schema validation (JSON Schema, Zod, Joi). Allowlist expected patterns; reject everything else.
113
+ - **Output encoding:** Encode data based on output context (HTML, URL, JavaScript, CSS). Use framework-provided auto-escaping.
114
+ - **Rate limiting:** Apply per-user and per-endpoint limits. Use token bucket or sliding window algorithms. Return `429 Too Many Requests` with `Retry-After` header.
115
+ - **Authentication:** Require bearer tokens (JWT or opaque) on all non-public endpoints. Use short-lived access tokens (5-15 min) with refresh token rotation.
116
+ - **Transport:** TLS 1.2+ mandatory; prefer TLS 1.3. HSTS header with `max-age >= 31536000; includeSubDomains; preload`.
117
+ - **Versioning:** Version APIs to allow security fixes without breaking clients.
118
+ - **Error handling:** Return generic error messages to clients; log detailed errors server-side.
119
+
120
+ ### Supply Chain Security
121
+
122
+ - **SBOM generation:** Use Syft or Trivy to produce SBOMs in SPDX or CycloneDX format at build time
123
+ - **Artifact signing:** Sign container images and binaries with Sigstore (cosign + Fulcio + Rekor) using keyless signing via OIDC identity
124
+ - **SLSA framework:** Aim for SLSA Build Level 2+ (scripted build, version-controlled, authenticated provenance)
125
+ - **Dependency management:** Pin exact versions in lockfiles; enable Dependabot or Renovate for automated updates; review changelogs before merging
126
+ - **Registry security:** Use private registries with access control; enable vulnerability scanning on push; verify image signatures with Kyverno or Connaisseur
127
+ - **CI/CD pipeline protection:** Require MFA for pipeline configuration changes; restrict who can modify build scripts; use ephemeral build environments
128
+
129
+ Reference: OpenSSF Scorecard, SLSA 1.0 specification, CISA SBOM guidance.
130
+
131
+ ### Zero Trust Architecture
132
+
133
+ Core principles per NIST SP 800-207:
134
+
135
+ 1. **Never trust, always verify** — Authenticate and authorize every request regardless of network location
136
+ 2. **Assume breach** — Design as if the attacker is already inside the perimeter
137
+ 3. **Least-privilege access** — Grant minimum permissions for minimum duration
138
+ 4. **Micro-segmentation** — Isolate workloads; enforce east-west traffic controls
139
+ 5. **Continuous verification** — Re-evaluate trust based on device posture, user behavior, and context
140
+ 6. **Encrypt everything** — mTLS for service-to-service; TLS for client-to-service
141
+ 7. **Comprehensive logging** — Log all access decisions for audit and anomaly detection
142
+
143
+ **Seven pillars:** Identity, Devices, Networks, Applications, Data, Infrastructure, Analytics/Visibility.
144
+
145
+ Implementation: Start with identity (strong MFA + SSO), then device trust (MDM + posture checks), then micro-segmentation, then continuous monitoring.
146
+
147
+ Reference: NIST SP 800-207, DoD Zero Trust Reference Architecture, CISA Zero Trust Maturity Model.
148
+
149
+ ---
150
+
151
+ ## Anti-Patterns & Pitfalls
152
+
153
+ ### 1. Hardcoded Secrets in Source Code
154
+ **Why dangerous:** Secrets in Git history persist forever, even after deletion. Bots scrape public repositories for AWS keys within minutes of exposure.
155
+ **Consequence:** The 2022 Uber breach started with hardcoded credentials in a PowerShell script. AWS key exposure costs companies an average of $28,000 per incident.
156
+ **Fix:** Use environment variables, secrets managers (Vault, AWS Secrets Manager), and pre-commit hooks (git-secrets, gitleaks).
157
+
158
+ ### 2. Trusting Client-Side Validation Only
159
+ **Why dangerous:** Attackers bypass the browser entirely using curl, Postman, or custom scripts. Client validation is UX, not security.
160
+ **Consequence:** SQL injection, XSS, and business logic bypasses in production despite "validated" forms.
161
+ **Fix:** Always validate and sanitize server-side. Treat all client input as untrusted.
162
+
163
+ ### 3. Rolling Your Own Cryptography
164
+ **Why dangerous:** Cryptographic primitives have subtle implementation requirements. Timing attacks, padding oracles, and nonce reuse can silently break security.
165
+ **Consequence:** Homebrew encryption has led to complete data exposure in numerous breaches. ECB mode usage leaked data patterns in the Adobe breach (153 million records).
166
+ **Fix:** Use well-audited libraries (libsodium, OpenSSL, Web Crypto API). Use high-level APIs (NaCl secretbox, AES-GCM).
167
+
168
+ ### 4. Excessive Permissions and Privilege Creep
169
+ **Why dangerous:** Over-privileged accounts amplify blast radius when compromised. Cloud IAM policies with `*:*` permissions grant full account access.
170
+ **Consequence:** The Capital One breach (2019) exploited an overly permissive IAM role to access 100+ million records.
171
+ **Fix:** Enforce least privilege. Use IAM Access Analyzer. Conduct quarterly access reviews. Time-bound elevated access (just-in-time).
172
+
173
+ ### 5. Ignoring Dependency Vulnerabilities
174
+ **Why dangerous:** 80%+ of modern application code comes from dependencies. A single vulnerable transitive dependency can compromise the entire application.
175
+ **Consequence:** Log4Shell (CVE-2021-44228) affected virtually every Java application. The event-stream npm compromise injected a cryptocurrency stealer.
176
+ **Fix:** Enable automated SCA scanning (Snyk, Dependabot, Socket). Monitor advisories. Update promptly. Generate and audit SBOMs.
177
+
178
+ ### 6. Missing or Inadequate Logging
179
+ **Why dangerous:** Without logs, breaches go undetected for months. The average time to identify a breach is 194 days (IBM Cost of a Data Breach 2024).
180
+ **Consequence:** Attackers operate undetected, exfiltrating data over extended periods.
181
+ **Fix:** Log authentication events, access control decisions, input validation failures, and administrative actions. Centralize in SIEM. Set up alerting.
182
+
183
+ ### 7. Using Outdated or Deprecated Protocols
184
+ **Why dangerous:** TLS 1.0/1.1, SSLv3, and weak cipher suites have known exploits (POODLE, BEAST, CRIME).
185
+ **Consequence:** Man-in-the-middle attacks; PCI DSS non-compliance; data interception.
186
+ **Fix:** Enforce TLS 1.2+ (prefer 1.3). Disable weak ciphers. Test with SSL Labs (aim for A+ rating). Enable HSTS.
187
+
188
+ ### 8. SQL Injection via String Concatenation
189
+ **Why dangerous:** Directly embedding user input in SQL queries allows arbitrary database commands.
190
+ **Consequence:** Remains the most exploited web vulnerability class. The Heartland Payment Systems breach (2008) compromised 130 million cards via SQL injection.
191
+ **Fix:** Use parameterized queries or prepared statements exclusively. Use ORMs. Never concatenate user input into queries.
192
+
193
+ ### 9. Storing Passwords in Plaintext or Weak Hashes
194
+ **Why dangerous:** MD5 and SHA-1 are fast hashes designed for integrity, not password storage. Modern GPUs crack billions of MD5 hashes per second.
195
+ **Consequence:** The RockYou breach exposed 32 million plaintext passwords. LinkedIn breach (2012) exposed SHA-1 hashed passwords, which were rapidly cracked.
196
+ **Fix:** Use Argon2id, bcrypt, or scrypt with appropriate work factors. Never use MD5, SHA-1, or unsalted hashes for passwords.
197
+
198
+ ### 10. Overly Permissive CORS Configuration
199
+ **Why dangerous:** `Access-Control-Allow-Origin: *` with credentials allows any site to make authenticated requests to your API.
200
+ **Consequence:** Cross-origin data theft, session hijacking, unauthorized API access.
201
+ **Fix:** Allowlist specific origins. Never reflect the `Origin` header without validation. Never combine `*` with `credentials: true`.
202
+
203
+ ### 11. Disabling Security Features for "Convenience"
204
+ **Why dangerous:** Turning off CSRF protection, disabling TLS verification, or using `--no-verify` in Git bypasses critical safeguards.
205
+ **Consequence:** CSRF attacks, MITM attacks, malicious code pushed past security hooks.
206
+ **Fix:** Fix the root cause instead of disabling protections. Document any temporary exceptions with expiration dates.
207
+
208
+ ### 12. Improper Error Handling (Fail Open)
209
+ **Why dangerous:** When authentication or authorization checks fail with an exception, "fail open" designs grant access by default.
210
+ **Consequence:** Authentication bypass, authorization escalation, data exposure during outages.
211
+ **Fix:** Always fail closed. Wrap security checks in try/catch that defaults to deny. Test error paths explicitly.
212
+
213
+ ### 13. Blindly Trusting AI-Generated Code
214
+ **Why dangerous:** Research shows 86% of AI-generated code fails XSS defenses (Veracode 2025). LLMs optimize for "working" code, not secure code.
215
+ **Consequence:** Validation shortcuts, insecure defaults, missing `await` on security checks (race conditions), and injection vulnerabilities.
216
+ **Fix:** Review all AI-generated code for security. Run SAST on AI outputs. Treat AI code with the same scrutiny as junior developer code.
217
+
218
+ ---
219
+
220
+ ## Testing Strategy
221
+
222
+ ### SAST (Static Application Security Testing)
223
+
224
+ | Tool | Strengths | Languages | Pricing |
225
+ |---|---|---|---|
226
+ | **Semgrep** | Fast (10s median CI scans), transparent YAML rules, customizable | 40+ languages | Free CE; Teams $35/dev/mo |
227
+ | **CodeQL** | Semantic analysis, low false positives, GitHub-native | C/C++, C#, Go, Java, JS/TS, Python | Free for public repos; GHAS for private |
228
+ | **SonarQube** | Quality + security combined, broad ecosystem | 30+ languages | Community Edition free; Developer $150/yr |
229
+ | **Snyk Code** | Real-time IDE scanning, AI-powered fixes, unified platform | 15+ languages | Free tier; Teams $25/dev/mo |
230
+
231
+ **Recommendation:** Run Semgrep in CI on every PR for speed; use CodeQL for deep analysis on merges to main.
232
+
233
+ ### DAST (Dynamic Application Security Testing)
234
+
235
+ | Tool | Use Case | Key Feature |
236
+ |---|---|---|
237
+ | **OWASP ZAP** | Open-source DAST | Active/passive scanning, API scanning, CI integration |
238
+ | **Burp Suite Pro** | Manual + automated testing | Crawler, intruder, repeater; gold standard for pen testers |
239
+ | **Nuclei** | Template-based scanning | 8000+ community templates; fast; CI-friendly |
240
+
241
+ ### SCA (Software Composition Analysis)
242
+
243
+ | Tool | Strengths | Integration |
244
+ |---|---|---|
245
+ | **Snyk** | Deep vulnerability database, fix PRs, container + IaC scanning | GitHub, GitLab, CI/CD, IDEs |
246
+ | **Dependabot** | GitHub-native, automated PRs for updates | GitHub Actions |
247
+ | **Socket** | Detects supply chain attacks (typosquatting, install scripts) | npm, PyPI; GitHub App |
248
+ | **Trivy** | All-in-one (SCA + container + IaC + SBOM) | CLI, CI/CD, Kubernetes |
249
+
250
+ ### Penetration Testing Methodology
251
+
252
+ Follow OWASP Testing Guide v4.2 or PTES:
253
+ 1. **Reconnaissance** — Subdomain enumeration, port scanning, technology fingerprinting
254
+ 2. **Mapping** — Identify attack surface, authentication flows, API endpoints
255
+ 3. **Discovery** — Automated scanning + manual testing for OWASP Top 10
256
+ 4. **Exploitation** — Validate findings with proof-of-concept; assess business impact
257
+ 5. **Reporting** — Risk-rated findings with reproduction steps, evidence, and remediation
258
+ 6. **Retest** — Verify fixes after remediation
259
+
260
+ Frequency: Annual pen test minimum; continuous for high-risk applications. Engage CREST or OSCP-certified testers.
261
+
262
+ ### Security Unit Testing Patterns
263
+
264
+ - Test authentication bypass (missing tokens, expired tokens, tampered tokens)
265
+ - Test authorization boundary (user A accessing user B's resources)
266
+ - Test input validation (SQL injection payloads, XSS vectors, path traversal)
267
+ - Test rate limiting (verify 429 responses after threshold)
268
+ - Test CSRF token validation (missing, invalid, reused tokens)
269
+ - Test error handling (verify no stack traces or internal details in responses)
270
+
271
+ ### Bug Bounty Programs
272
+
273
+ Platforms: HackerOne, Bugcrowd, Intigriti.
274
+ - Define clear scope (in-scope domains, out-of-scope areas)
275
+ - Start with a private program (invite-only) before going public
276
+ - Set competitive bounty ranges ($500-$50,000+ based on severity)
277
+ - Provide a safe harbor clause in your vulnerability disclosure policy
278
+ - Response SLA: triage within 48 hours; remediation timeline by severity
279
+
280
+ ---
281
+
282
+ ## Performance Considerations
283
+
284
+ ### Security vs. Performance Tradeoffs
285
+
286
+ | Security Feature | Performance Impact | Mitigation |
287
+ |---|---|---|
288
+ | TLS encryption | 1-2ms latency per handshake | TLS 1.3 (1-RTT), session resumption, 0-RTT for repeat connections |
289
+ | Password hashing (Argon2id) | 100-500ms per hash | Offload to async workers; tune cost parameters to target ~250ms |
290
+ | JWT validation | Microseconds (symmetric) to ~1ms (asymmetric) | Cache public keys; use symmetric HMAC for internal services |
291
+ | Input validation | Negligible for most patterns | Avoid catastrophic regex backtracking (ReDoS); use RE2 engine |
292
+ | WAF inspection | 1-5ms per request | Tune rules to minimize false positives; bypass for health checks |
293
+
294
+ ### Rate Limiting Implementation
295
+
296
+ **Token Bucket:**
297
+ - Tokens added at fixed rate; each request consumes one token
298
+ - Allows controlled bursts up to bucket capacity
299
+ - Best for: APIs needing burst tolerance with a sustained average limit
300
+ - Implementation: Redis + Lua script for atomic operations
301
+
302
+ **Sliding Window Log:**
303
+ - Track timestamps of all requests in the window
304
+ - Most accurate but highest memory usage
305
+ - Best for: strict per-user fairness requirements
306
+
307
+ **Sliding Window Counter:**
308
+ - Hybrid of fixed window and sliding window
309
+ - Weighted count from current and previous window
310
+ - Best for: balance of accuracy and memory efficiency
311
+
312
+ **Best practice:** Implement at API gateway level (Kong, Envoy, AWS API Gateway). Use per-user + per-endpoint limits. Return `X-RateLimit-Limit`, `X-RateLimit-Remaining`, `X-RateLimit-Reset` headers.
313
+
314
+ ### WAF Configuration Without Blocking Legitimate Traffic
315
+
316
+ - Start in detection mode (log-only) for 2-4 weeks before enforcement
317
+ - Tune rules based on false positive analysis of logged traffic
318
+ - Allowlist known-good patterns (e.g., specific Content-Types, internal IPs)
319
+ - Use managed rule sets (AWS WAF Managed Rules, Cloudflare OWASP) as baseline
320
+ - Create custom rules for application-specific threats
321
+ - Monitor false positive rate and adjust; target < 0.1% false positives
322
+
323
+ ### TLS Performance Optimization
324
+
325
+ - **TLS 1.3:** 1-RTT handshake (vs 2-RTT in 1.2); 0-RTT for resumed sessions
326
+ - **Cipher selection:** Prefer AES-128-GCM (faster than AES-256 with negligible security difference for most use cases); use ChaCha20-Poly1305 for mobile clients without AES-NI
327
+ - **OCSP Stapling:** Eliminate client-side certificate revocation check latency
328
+ - **Session tickets:** Enable for TLS 1.2; TLS 1.3 handles resumption natively
329
+ - **Hardware acceleration:** Ensure servers have AES-NI support; use kernel TLS (kTLS) for offloading
330
+ - **Certificate chain:** Minimize intermediate certificates; keep chain short
331
+
332
+ Reference: Mozilla SSL Configuration Generator, Qualys SSL Labs best practices.
333
+
334
+ ---
335
+
336
+ ## Security Considerations (Deep Dive)
337
+
338
+ ### Secrets Management
339
+
340
+ **HashiCorp Vault:**
341
+ - Dynamic secrets with automatic rotation (database credentials, cloud IAM)
342
+ - Transit secrets engine for encryption-as-a-service
343
+ - Kubernetes Vault Secrets Operator for pod injection without persistent storage
344
+ - Best for: multi-cloud, large-scale, dynamic secret requirements
345
+ - Requires operational expertise and dedicated platform team
346
+
347
+ **AWS Secrets Manager:**
348
+ - Native AWS integration; automatic rotation for RDS, Redshift, DocumentDB
349
+ - Cross-account sharing via resource policies
350
+ - Best for: AWS-only environments wanting zero operational overhead
351
+ - Limitation: rotation for non-AWS services requires custom Lambda functions
352
+
353
+ **SOPS (Secrets OPerationS):**
354
+ - Encrypts values in-place within YAML, JSON, ENV, INI files
355
+ - Integrates with AWS KMS, GCP KMS, Azure Key Vault, age, PGP
356
+ - Best for: GitOps workflows, small teams, static secrets in version control
357
+ - Limitation: no dynamic secrets or automatic rotation
358
+
359
+ **2025 Best Practice:** Eliminate long-lived secrets where possible. Use Workload Identity Federation, cloud IAM roles, and short-lived tokens. For remaining secrets, use Vault or cloud-native secrets managers with External Secrets Operator for Kubernetes bridging.
360
+
361
+ ### Certificate Management and Rotation
362
+
363
+ - Automate certificate issuance with ACME protocol (Let's Encrypt, ZeroSSL)
364
+ - Use cert-manager in Kubernetes for automatic TLS certificate lifecycle
365
+ - Set certificate lifetime to 90 days maximum (Let's Encrypt default)
366
+ - Monitor certificate expiry with alerting at 30, 14, and 7 days
367
+ - Use Certificate Transparency (CT) logs to detect unauthorized certificates for your domains
368
+ - Implement CAA DNS records to restrict which CAs can issue certificates
369
+
370
+ ### Container Security
371
+
372
+ **Image Security:**
373
+ - Use distroless or Alpine base images (minimal attack surface)
374
+ - Scan images with Trivy, Grype, or Snyk Container in CI pipeline
375
+ - Never use `latest` tag; pin to digest for reproducibility
376
+ - Multi-stage builds to exclude build tools from runtime image
377
+
378
+ **Runtime Security:**
379
+ - Deploy Falco (CNCF graduated project) for syscall-based threat detection
380
+ - Alert on: shell spawned in production container, unexpected network connections, file modifications in read-only containers
381
+ - Use Seccomp profiles to restrict available system calls
382
+ - Apply AppArmor or SELinux profiles for mandatory access control
383
+ - Run containers read-only (`readOnlyRootFilesystem: true`)
384
+
385
+ **Registry Security:**
386
+ - Use private registries with access control and vulnerability scanning on push
387
+ - Sign images with cosign (Sigstore); verify signatures at admission (Kyverno, Connaisseur)
388
+ - Enable content trust / image signing policies
389
+
390
+ ### Cloud Security Posture Management (CSPM)
391
+
392
+ - Tools: Wiz, Prisma Cloud, AWS Security Hub, Prowler (open source)
393
+ - Continuously assess cloud configurations against CIS Benchmarks
394
+ - Monitor for: public S3 buckets, open security groups, unencrypted databases, excessive IAM permissions
395
+ - Automate remediation for critical findings (e.g., auto-close public S3 buckets)
396
+
397
+ ### Incident Response Planning
398
+
399
+ Per NIST SP 800-61 Rev. 3 (finalized April 2025):
400
+
401
+ **Preparation Phase:**
402
+ - Govern: Establish IR policy, define roles (incident commander, triage, comms)
403
+ - Identify: Asset inventory, threat intelligence feeds, risk assessment
404
+ - Protect: Hardening, patching, backup verification, tabletop exercises
405
+
406
+ **Response Phase:**
407
+ - Detect: SIEM alerting, endpoint detection (EDR), network monitoring
408
+ - Respond: Contain (isolate affected systems), eradicate (remove threat), communicate (stakeholders, legal, regulators)
409
+ - Recover: Restore from backups, verify integrity, monitor for recurrence
410
+
411
+ **Post-Incident:**
412
+ - Conduct blameless post-mortem within 72 hours
413
+ - Update playbooks based on lessons learned
414
+ - Report to relevant authorities within regulatory timeframes (72 hours for GDPR)
415
+
416
+ ### Compliance Frameworks
417
+
418
+ | Framework | Scope | Key Requirements |
419
+ |---|---|---|
420
+ | **SOC 2** | SaaS/cloud service providers | 5 Trust Service Criteria: security, availability, processing integrity, confidentiality, privacy |
421
+ | **GDPR** | EU personal data | Consent, right to erasure, DPIAs, 72-hour breach notification, Data Protection Officer |
422
+ | **HIPAA** | US healthcare data (PHI) | Access controls, audit logs, encryption, BAAs with vendors, breach notification |
423
+ | **PCI DSS v4.0** | Payment card data | Network segmentation, encryption, vulnerability management, access control, logging, annual pen test |
424
+ | **ISO 27001** | Information security management | Risk assessment, Annex A controls, continuous improvement, annual audits |
425
+
426
+ **Cross-framework mapping:** ISO 27001 controls overlap significantly with SOC 2 and GDPR, enabling efficient multi-framework compliance. Use automation platforms (Vanta, Drata, Sprinto) for continuous compliance monitoring.
427
+
428
+ ---
429
+
430
+ ## Integration Patterns
431
+
432
+ ### Security in CI/CD Pipelines (Shift-Left Security)
433
+
434
+ ```
435
+ commit → pre-commit hooks → build → test → deploy → monitor
436
+ │ │ │ │ │ │
437
+ │ gitleaks/git-secrets Semgrep DAST Checkov Falco
438
+ │ (secrets detection) CodeQL ZAP cosign SIEM
439
+ │ Trivy Kyverno
440
+ │ (SCA+SBOM)
441
+ ```
442
+
443
+ **Pipeline stages:**
444
+ 1. **Pre-commit:** Secret detection (gitleaks), linting (eslint-plugin-security)
445
+ 2. **Build:** SAST (Semgrep), SCA (Trivy), license compliance
446
+ 3. **Test:** DAST (ZAP), security unit tests, contract tests
447
+ 4. **Pre-deploy:** IaC scanning (Checkov), image scanning (Trivy), SBOM generation
448
+ 5. **Deploy:** Image signature verification (Kyverno), admission control
449
+ 6. **Runtime:** Monitoring (Falco), log aggregation, anomaly detection
450
+
451
+ **2025-2026 trend:** "Shift smart" over "shift left" — focus on actionable, contextual findings rather than flooding developers with low-impact alerts. Prioritize reachability analysis and exploit probability.
452
+
453
+ ### SIEM Integration
454
+
455
+ | Platform | Strengths | Best For |
456
+ |---|---|---|
457
+ | **Splunk** | Mature ecosystem, SOAR capabilities | Large enterprises, complex correlation |
458
+ | **ELK Stack** (Elastic) | Open source, flexible, cost-effective | Mid-size teams, custom dashboards |
459
+ | **Datadog Security** | Unified observability + security | DevOps-centric teams, cloud-native |
460
+ | **Microsoft Sentinel** | Azure-native, AI-driven analytics | Azure-heavy environments |
461
+
462
+ Key integration points: application logs, WAF logs, authentication events, container runtime events, cloud audit trails, vulnerability scan results.
463
+
464
+ ### Identity Providers
465
+
466
+ | Provider | Strengths | Best For |
467
+ |---|---|---|
468
+ | **Auth0** (Okta) | Developer experience, extensive SDKs, adaptive MFA | SaaS applications |
469
+ | **Keycloak** | Open source, self-hosted, full OIDC/SAML | On-prem or sovereignty requirements |
470
+ | **Okta Workforce** | Enterprise SSO, lifecycle management | Large enterprise IAM |
471
+ | **AWS Cognito** | AWS-native, user pools + federated identities | AWS-centric applications |
472
+
473
+ Best practice: Never build authentication from scratch. Use a proven IdP. Externalize authentication to reduce attack surface.
474
+
475
+ ### API Gateway Security Patterns
476
+
477
+ - **Authentication termination:** Validate tokens at the gateway; pass verified claims to backends
478
+ - **Rate limiting:** Enforce at gateway to protect all downstream services
479
+ - **Request/response validation:** Schema validation against OpenAPI spec at gateway
480
+ - **mTLS termination:** Gateway handles TLS; internal traffic can use mTLS or service mesh
481
+ - **IP allowlisting/blocklisting:** First line of defense at gateway level
482
+ - Tools: Kong, Envoy, AWS API Gateway, Cloudflare API Shield
483
+
484
+ ### Service Mesh Security (mTLS)
485
+
486
+ - **Istio / Linkerd / Cilium:** Automatic mTLS between all services in the mesh
487
+ - Zero-trust networking: every service-to-service call authenticated and encrypted
488
+ - **Authorization policies:** Define which services can communicate (equivalent to network policies at L7)
489
+ - **Certificate rotation:** Handled automatically by mesh control plane (typically every 24 hours)
490
+ - **Observability:** Mesh provides encrypted traffic visibility without application changes
491
+
492
+ ---
493
+
494
+ ## DevOps & Deployment (DevSecOps)
495
+
496
+ ### Container Hardening
497
+
498
+ **Distroless Images:**
499
+ - Contain only the application and runtime dependencies
500
+ - No shell, no package manager, no utilities — attacker cannot spawn a shell or install tools
501
+ - Available for: Java, Python, Node.js, Go, .NET, Rust (gcr.io/distroless)
502
+
503
+ **Rootless Containers:**
504
+ - Run container daemon and containers as non-root user
505
+ - Container breakout less likely to yield root-on-host
506
+ - Supported in Docker 20.10+, Podman (default), containerd
507
+
508
+ **Hardening Checklist:**
509
+ - Drop all capabilities: `securityContext.capabilities.drop: ["ALL"]`
510
+ - Add back only needed caps (rare): e.g., `NET_BIND_SERVICE`
511
+ - Read-only root filesystem: `readOnlyRootFilesystem: true`
512
+ - No privilege escalation: `allowPrivilegeEscalation: false`
513
+ - Run as non-root: `runAsNonRoot: true; runAsUser: 65534`
514
+ - Resource limits: set CPU and memory limits to prevent resource exhaustion
515
+
516
+ ### Kubernetes Security
517
+
518
+ **Pod Security Standards (PSS):**
519
+ - **Privileged:** Unrestricted (only for system-level workloads)
520
+ - **Baseline:** Prevents known privilege escalations; suitable for most workloads
521
+ - **Restricted:** Hardened best practices; recommended for security-sensitive applications
522
+
523
+ Enforce via Pod Security Admission (built-in since K8s 1.25) at namespace level:
524
+ ```yaml
525
+ apiVersion: v1
526
+ kind: Namespace
527
+ metadata:
528
+ name: production
529
+ labels:
530
+ pod-security.kubernetes.io/enforce: restricted
531
+ pod-security.kubernetes.io/warn: restricted
532
+ pod-security.kubernetes.io/audit: restricted
533
+ ```
534
+
535
+ **Network Policies:**
536
+ - Default deny all ingress and egress traffic
537
+ - Explicitly allow required communication paths
538
+ - Use Cilium Network Policies for L7 (HTTP, gRPC) filtering
539
+ - Enforce DNS policies to prevent data exfiltration via DNS
540
+
541
+ **RBAC:**
542
+ - Avoid `cluster-admin` for application workloads
543
+ - Use namespace-scoped Roles over ClusterRoles
544
+ - Audit RBAC with `kubectl auth can-i --list` and rbac-lookup tool
545
+ - Disable anonymous authentication to the API server
546
+
547
+ **Secrets:**
548
+ - Enable encryption at rest for etcd (EncryptionConfiguration)
549
+ - Use External Secrets Operator to sync from Vault/AWS Secrets Manager
550
+ - Never store secrets in ConfigMaps or environment variables in pod specs
551
+
552
+ ### Infrastructure Security Scanning
553
+
554
+ | Tool | Scope | Status (2026) |
555
+ |---|---|---|
556
+ | **Checkov** | Terraform, CloudFormation, K8s, Helm, Docker | Active; 1000+ built-in rules; graph-based analysis |
557
+ | **Trivy** (successor to tfsec) | Terraform, K8s, Docker, CloudFormation, ARM | Active; absorbed tfsec rule library in 2024 |
558
+ | **KICS** | Terraform, CloudFormation, Ansible, Docker, K8s | Active; Checkmarx-maintained |
559
+ | **Terrascan** | (archived Nov 2025) | Migrate to Checkov, KICS, or Trivy |
560
+
561
+ **Implementation:** Run Checkov or Trivy in CI on every PR for IaC changes. Fail the build on HIGH/CRITICAL findings. Suppress known false positives with inline annotations.
562
+
563
+ ### Runtime Protection
564
+
565
+ - **Falco:** Kernel-level syscall monitoring; detect anomalous behavior (unexpected process execution, file access, network connections)
566
+ - **eBPF-based tools:** Tetragon (Cilium), Tracee (Aqua) — lower overhead than kernel modules
567
+ - **Read-only filesystems:** Detect unauthorized file modifications
568
+ - **Network monitoring:** Detect unexpected outbound connections (C2 callbacks, data exfiltration)
569
+ - **Drift detection:** Alert when running container diverges from its image
570
+
571
+ ### Audit Logging and Monitoring
572
+
573
+ **What to log (per OWASP Logging Cheat Sheet):**
574
+ - Authentication successes and failures
575
+ - Authorization failures (access denied)
576
+ - Input validation failures
577
+ - Application errors and exceptions
578
+ - Administrative operations (user creation, permission changes)
579
+ - Data access for sensitive resources
580
+
581
+ **Log format:** Structured JSON with timestamp, severity, user ID, source IP, action, resource, result, correlation ID.
582
+
583
+ **Retention:** Per compliance requirements (SOC 2: 1 year, PCI DSS: 1 year, HIPAA: 6 years, GDPR: as needed for purpose).
584
+
585
+ **Monitoring:** Set up alerts for brute-force attempts (>5 failed logins), privilege escalation, anomalous data access patterns, and security scan failures in CI.
586
+
587
+ ---
588
+
589
+ ## Decision Trees
590
+
591
+ ### Which Authentication Method?
592
+
593
+ ```
594
+ Is this a consumer-facing application?
595
+ ├── Yes
596
+ │ ├── High security (banking, healthcare)?
597
+ │ │ ├── Yes → WebAuthn/Passkeys (primary) + MFA fallback (TOTP)
598
+ │ │ └── No → Social login (OIDC) + optional passkey enrollment
599
+ │ └── Mobile-first?
600
+ │ ├── Yes → Passkeys (synced) + biometric local auth
601
+ │ └── No → Email magic link + optional passkey enrollment
602
+ ├── No (B2B / Enterprise)
603
+ │ ├── Enterprise SSO required?
604
+ │ │ ├── Yes → SAML 2.0 / OIDC federation with customer IdP
605
+ │ │ └── No → OIDC with your IdP (Auth0, Keycloak, Okta)
606
+ │ └── Machine-to-machine?
607
+ │ ├── Yes → OAuth 2.1 Client Credentials + mTLS or signed JWTs
608
+ │ └── No → API keys (low sensitivity) or OAuth 2.1 (high sensitivity)
609
+ └── Privileged / Admin access?
610
+ └── Always → Hardware security key (FIDO2) + session time limits
611
+ ```
612
+
613
+ ### Which Secrets Management Solution?
614
+
615
+ ```
616
+ What is your infrastructure?
617
+ ├── AWS-only, small team, no dynamic secrets needed?
618
+ │ └── AWS Secrets Manager (zero ops overhead, native rotation for AWS services)
619
+ ├── Multi-cloud or hybrid?
620
+ │ ├── Have a platform team to operate it?
621
+ │ │ ├── Yes → HashiCorp Vault (dynamic secrets, transit engine, multi-cloud)
622
+ │ │ └── No → Managed Vault (HCP Vault) or Infisical (SaaS)
623
+ │ └── Using GitOps with static secrets?
624
+ │ └── SOPS + cloud KMS (encrypt in-repo, decrypt at deploy)
625
+ ├── Kubernetes-native?
626
+ │ └── External Secrets Operator + backend (Vault, AWS SM, GCP SM)
627
+ └── Small project / MVP?
628
+ └── Environment variables in CI/CD (GitHub Secrets, GitLab CI vars)
629
+ └── Migrate to proper secrets manager before production
630
+ ```
631
+
632
+ ### When to Use WAF vs. Application-Level Security?
633
+
634
+ ```
635
+ What is the threat?
636
+ ├── Generic web attacks (SQLi, XSS, known CVE exploits)?
637
+ │ └── WAF (first line of defense) + application validation (defense in depth)
638
+ ├── Business logic attacks (account takeover, price manipulation)?
639
+ │ └── Application-level security (WAF cannot understand business logic)
640
+ ├── DDoS / volumetric attacks?
641
+ │ └── WAF + CDN (Cloudflare, AWS Shield) at network edge
642
+ ├── API abuse (scraping, credential stuffing)?
643
+ │ └── WAF rate limiting + application-level bot detection + CAPTCHA
644
+ ├── Zero-day / targeted attacks?
645
+ │ └── WAF (virtual patching for quick mitigation) + application fix (permanent)
646
+ └── Compliance requirement (PCI DSS, etc.)?
647
+ └── WAF required by compliance + application security (both mandatory)
648
+
649
+ Rule of thumb: WAF is a safety net, not a replacement for secure code.
650
+ Application-level security is always required. WAF adds defense in depth.
651
+ ```
652
+
653
+ ---
654
+
655
+ ## Code Examples
656
+
657
+ ### 1. Parameterized SQL Queries (Preventing Injection)
658
+
659
+ ```python
660
+ # WRONG - SQL injection vulnerability
661
+ def get_user_bad(username):
662
+ query = f"SELECT * FROM users WHERE username = '{username}'"
663
+ cursor.execute(query) # Attacker input: ' OR '1'='1
664
+
665
+ # CORRECT - Parameterized query
666
+ def get_user_safe(username):
667
+ query = "SELECT * FROM users WHERE username = %s"
668
+ cursor.execute(query, (username,)) # Driver handles escaping
669
+ return cursor.fetchone()
670
+
671
+ # CORRECT - Using an ORM (SQLAlchemy)
672
+ def get_user_orm(username):
673
+ return db.session.query(User).filter(User.username == username).first()
674
+ ```
675
+
676
+ ### 2. Password Hashing with Argon2id
677
+
678
+ ```python
679
+ from argon2 import PasswordHasher
680
+ from argon2.exceptions import VerifyMismatchError
681
+
682
+ ph = PasswordHasher(
683
+ time_cost=3, # Number of iterations
684
+ memory_cost=65536, # 64 MB memory usage
685
+ parallelism=4, # Parallel threads
686
+ hash_len=32, # Output hash length
687
+ salt_len=16 # Salt length
688
+ )
689
+
690
+ def hash_password(password: str) -> str:
691
+ return ph.hash(password) # Salt generated automatically
692
+
693
+ def verify_password(stored_hash: str, password: str) -> bool:
694
+ try:
695
+ ph.verify(stored_hash, password)
696
+ # Check if rehash needed (params changed)
697
+ if ph.check_needs_rehash(stored_hash):
698
+ return True # Signal caller to update stored hash
699
+ return True
700
+ except VerifyMismatchError:
701
+ return False
702
+ ```
703
+
704
+ ### 3. Secure JWT Handling (Node.js)
705
+
706
+ ```javascript
707
+ const jose = require('jose');
708
+
709
+ // WRONG - common JWT mistakes
710
+ // 1. Using 'none' algorithm
711
+ // 2. Not validating issuer/audience
712
+ // 3. Accepting both symmetric and asymmetric algorithms
713
+
714
+ // CORRECT - Secure JWT verification
715
+ async function verifyToken(token) {
716
+ const JWKS = jose.createRemoteJWKS(
717
+ new URL('https://auth.example.com/.well-known/jwks.json')
718
+ );
719
+
720
+ const { payload } = await jose.jwtVerify(token, JWKS, {
721
+ issuer: 'https://auth.example.com', // Validate issuer
722
+ audience: 'https://api.example.com', // Validate audience
723
+ algorithms: ['RS256'], // Restrict algorithms explicitly
724
+ maxTokenAge: '15 minutes', // Enforce max age
725
+ clockTolerance: '30 seconds', // Allow minor clock skew
726
+ });
727
+
728
+ return payload;
729
+ }
730
+
731
+ // CORRECT - Token creation with short expiry
732
+ async function createToken(userId, privateKey) {
733
+ return new jose.SignJWT({ sub: userId, scope: 'read write' })
734
+ .setProtectedHeader({ alg: 'RS256', kid: 'key-2025-03' })
735
+ .setIssuer('https://auth.example.com')
736
+ .setAudience('https://api.example.com')
737
+ .setIssuedAt()
738
+ .setExpirationTime('15m') // Short-lived access token
739
+ .setJti(crypto.randomUUID()) // Unique token ID for revocation
740
+ .sign(privateKey);
741
+ }
742
+ ```
743
+
744
+ ### 4. Content Security Policy Headers
745
+
746
+ ```javascript
747
+ // Express.js middleware - strict CSP
748
+ const helmet = require('helmet');
749
+
750
+ app.use(helmet.contentSecurityPolicy({
751
+ directives: {
752
+ defaultSrc: ["'self'"],
753
+ scriptSrc: ["'self'", "'strict-dynamic'"], // strict-dynamic for nonce-based
754
+ styleSrc: ["'self'", "'unsafe-inline'"], // Consider nonces for styles too
755
+ imgSrc: ["'self'", "data:", "https:"],
756
+ fontSrc: ["'self'"],
757
+ connectSrc: ["'self'", "https://api.example.com"],
758
+ frameSrc: ["'none'"], // Prevent clickjacking
759
+ objectSrc: ["'none'"], // Block plugins
760
+ baseUri: ["'self'"], // Prevent base tag hijacking
761
+ formAction: ["'self'"], // Restrict form submissions
762
+ upgradeInsecureRequests: [], // Force HTTPS
763
+ },
764
+ }));
765
+
766
+ // Additional security headers
767
+ app.use(helmet.hsts({ maxAge: 31536000, includeSubDomains: true, preload: true }));
768
+ app.use(helmet.referrerPolicy({ policy: 'strict-origin-when-cross-origin' }));
769
+ app.use(helmet.permittedCrossDomainPolicies());
770
+ app.use(helmet.noSniff()); // X-Content-Type-Options: nosniff
771
+ ```
772
+
773
+ ### 5. Input Validation with Schema (TypeScript / Zod)
774
+
775
+ ```typescript
776
+ import { z } from 'zod';
777
+
778
+ // Define strict schema for user registration
779
+ const UserRegistrationSchema = z.object({
780
+ email: z.string()
781
+ .email('Invalid email format')
782
+ .max(254, 'Email too long')
783
+ .transform(val => val.toLowerCase().trim()),
784
+ password: z.string()
785
+ .min(12, 'Password must be at least 12 characters')
786
+ .max(128, 'Password too long') // Prevent bcrypt DoS (72-byte limit)
787
+ .regex(/[A-Z]/, 'Must contain uppercase letter')
788
+ .regex(/[a-z]/, 'Must contain lowercase letter')
789
+ .regex(/[0-9]/, 'Must contain a number'),
790
+ username: z.string()
791
+ .min(3).max(30)
792
+ .regex(/^[a-zA-Z0-9_-]+$/, 'Only alphanumeric, underscore, hyphen allowed'),
793
+ role: z.enum(['user', 'editor']), // Allowlist — never accept 'admin' from client
794
+ });
795
+
796
+ // Usage in Express route
797
+ app.post('/api/register', async (req, res) => {
798
+ const result = UserRegistrationSchema.safeParse(req.body);
799
+ if (!result.success) {
800
+ return res.status(400).json({
801
+ error: 'Validation failed',
802
+ // Return field errors, never expose internal details
803
+ details: result.error.issues.map(i => ({
804
+ field: i.path.join('.'),
805
+ message: i.message,
806
+ })),
807
+ });
808
+ }
809
+ const validated = result.data; // Typed, validated, transformed
810
+ // ... proceed with registration
811
+ });
812
+ ```
813
+
814
+ ---
815
+
816
+ *Researched: 2026-03-07 | Sources: [OWASP Top 10:2021](https://owasp.org/Top10/2021/), [OWASP Top 10:2025](https://owasp.org/Top10/2025/), [NIST SP 800-207 Zero Trust Architecture](https://csrc.nist.gov/pubs/sp/800/207/final), [NIST SP 800-61r3 Incident Response](https://csrc.nist.gov/pubs/sp/800/61/r3/final), [NIST Implementing ZTA](https://pages.nist.gov/zero-trust-architecture/), [Sigstore](https://www.sigstore.dev), [SLSA Framework](https://slsa.dev), [OpenSSF](https://openssf.org), [Kubernetes Pod Security Standards](https://kubernetes.io/docs/concepts/security/pod-security-standards/), [CNCF Falco](https://falco.org), [Semgrep](https://semgrep.dev), [Snyk](https://snyk.io), [Trivy](https://trivy.dev), [OWASP Secure Coding Practices](https://owasp.org/www-project-secure-coding-practices-quick-reference-guide/), [CIS Benchmarks](https://www.cisecurity.org/cis-benchmarks), [Mozilla SSL Configuration Generator](https://ssl-config.mozilla.org), [JWT Best Practices (Curity)](https://curity.io/resources/learn/jwt-best-practices/)*