@umacloud/knowledge 1.0.1

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 (418) hide show
  1. package/00-governance/governance-capabilities.md +557 -0
  2. package/00-governance/knowledge-map.md +39 -0
  3. package/00-governance/maintenance-policy.md +76 -0
  4. package/00-governance/review-checklist.md +81 -0
  5. package/README.md +13 -0
  6. package/ai/01-standards/agent-development-complete.md +691 -0
  7. package/ai/01-standards/llm-application-complete.md +488 -0
  8. package/ai/01-standards/mlops-complete.md +798 -0
  9. package/ai/01-standards/prompt-engineering-complete.md +646 -0
  10. package/ai/01-standards/rag-architecture-complete.md +649 -0
  11. package/ai/02-playbooks/llm-evaluation-playbook.md +847 -0
  12. package/ai/03-checklists/ai-project-checklist.md +215 -0
  13. package/ai/04-antipatterns/ai-antipatterns.md +661 -0
  14. package/ai/05-cases/case-rag-production.md +147 -0
  15. package/ai/06-glossary/ai-glossary.md +162 -0
  16. package/ai/agent-evaluation-benchmark.md +53 -0
  17. package/ai/ai-agent-memory-context-management.md +41 -0
  18. package/ai/ai-cost-capacity-optimization-playbook.md +42 -0
  19. package/ai/ai-data-security-and-compliance-playbook.md +37 -0
  20. package/ai/ai-domain-index-and-checklist.md +40 -0
  21. package/ai/ai-governance-maturity-model.md +50 -0
  22. package/ai/ai-model-selection-and-routing-strategy.md +47 -0
  23. package/ai/ai-observability-and-oncall-runbook.md +52 -0
  24. package/ai/ai-rag-engineering-playbook.md +42 -0
  25. package/ai/ai-red-team-and-safety-evaluation.md +42 -0
  26. package/ai/ai-release-readiness-and-rollback-gate.md +42 -0
  27. package/ai/llm-agent-engineering-deep-dive.md +57 -0
  28. package/ai/prompt-and-tool-guardrails.md +52 -0
  29. package/api/01-standards/enterprise-api-standards.md +198 -0
  30. package/api/01-standards/rest-api-design-guide.md +63 -0
  31. package/api/02-playbooks/api-pagination-playbook.md +93 -0
  32. package/api/02-playbooks/graphql-production-playbook.md +176 -0
  33. package/api/03-checklists/api-review-checklist.md +55 -0
  34. package/api/04-antipatterns/api-antipatterns.md +112 -0
  35. package/architecture/01-standards/api-gateway-patterns.md +496 -0
  36. package/architecture/01-standards/cloud-native-patterns.md +644 -0
  37. package/architecture/01-standards/distributed-systems-patterns.md +591 -0
  38. package/architecture/01-standards/event-driven-architecture.md +595 -0
  39. package/architecture/01-standards/microservices-patterns-complete.md +968 -0
  40. package/architecture/01-standards/microservices-patterns.md +495 -0
  41. package/architecture/01-standards/system-design-interview.md +664 -0
  42. package/architecture/02-playbooks/microservices-patterns-playbook.md +137 -0
  43. package/architecture/02-playbooks/migration-playbook.md +780 -0
  44. package/architecture/02-playbooks/system-design-playbook.md +779 -0
  45. package/architecture/03-checklists/architecture-decision-checklist.md +297 -0
  46. package/architecture/04-antipatterns/architecture-antipatterns.md +417 -0
  47. package/architecture/05-cases/case-netflix-microservices.md +413 -0
  48. package/architecture/06-glossary/architecture-glossary.md +164 -0
  49. package/architecture/adr-template-and-examples.md +38 -0
  50. package/architecture/api-gateway-deep-dive.md +1291 -0
  51. package/architecture/configuration-management.md +1162 -0
  52. package/architecture/distributed-transactions.md +1220 -0
  53. package/architecture/microservices-complete.md +735 -0
  54. package/architecture/resilience-and-disaster-patterns.md +37 -0
  55. package/architecture/service-governance.md +1198 -0
  56. package/architecture/system-architecture-deep-dive.md +37 -0
  57. package/backend/01-standards/analytics-and-growth.md +65 -0
  58. package/backend/01-standards/api-and-error-conventions.md +120 -0
  59. package/backend/01-standards/application-layering-and-packaging.md +160 -0
  60. package/backend/01-standards/auth-implementation.md +104 -0
  61. package/backend/01-standards/backend-framework-idioms.md +74 -0
  62. package/backend/01-standards/background-jobs-and-async.md +66 -0
  63. package/backend/01-standards/caching-strategies-complete.md +390 -0
  64. package/backend/01-standards/config-and-observability.md +77 -0
  65. package/backend/01-standards/data-modeling-and-persistence.md +94 -0
  66. package/backend/01-standards/django-complete.md +1765 -0
  67. package/backend/01-standards/email-and-notifications.md +64 -0
  68. package/backend/01-standards/fastapi-complete.md +925 -0
  69. package/backend/01-standards/file-upload-and-storage.md +66 -0
  70. package/backend/01-standards/graphql-api-complete.md +416 -0
  71. package/backend/01-standards/llm-application-standard.md +78 -0
  72. package/backend/01-standards/message-queue-patterns.md +379 -0
  73. package/backend/01-standards/microservices-and-distributed.md +78 -0
  74. package/backend/01-standards/nestjs-complete.md +2167 -0
  75. package/backend/01-standards/payment-integration.md +80 -0
  76. package/backend/01-standards/rate-limiting-complete.md +451 -0
  77. package/backend/01-standards/realtime-and-websocket.md +65 -0
  78. package/backend/01-standards/search-and-filtering.md +64 -0
  79. package/backend/01-standards/spring-boot-complete.md +445 -0
  80. package/backend/02-playbooks/api-design-playbook.md +718 -0
  81. package/backend/02-playbooks/email-send-playbook.md +130 -0
  82. package/backend/02-playbooks/file-upload-s3-playbook.md +153 -0
  83. package/backend/02-playbooks/typescript-enterprise-playbook.md +133 -0
  84. package/backend/02-playbooks/websocket-realtime-playbook.md +154 -0
  85. package/backend/03-checklists/api-launch-checklist.md +189 -0
  86. package/backend/04-antipatterns/backend-antipatterns.md +1051 -0
  87. package/blockchain/01-standards/blockchain-basics.md +557 -0
  88. package/blockchain/01-standards/smart-contract-development.md +1315 -0
  89. package/cicd/01-standards/deployment-and-delivery-standard.md +96 -0
  90. package/cicd/01-standards/github-actions-complete.md +473 -0
  91. package/cicd/01-standards/release-and-store-submission.md +75 -0
  92. package/cicd/02-playbooks/cicd-pipeline-playbook.md +144 -0
  93. package/cicd/02-playbooks/release-management-playbook.md +605 -0
  94. package/cicd/03-checklists/pipeline-security-checklist.md +168 -0
  95. package/cicd/04-antipatterns/cicd-antipatterns.md +589 -0
  96. package/cicd/05-cases/case-deployment-automation.md +221 -0
  97. package/cicd/05-cases/case-gitops-transformation.md +212 -0
  98. package/cicd/06-glossary/cicd-glossary.md +114 -0
  99. package/cicd/cicd-blueprint-deep-dive.md +38 -0
  100. package/cicd/release-readiness-gate.md +37 -0
  101. package/cloud-native/01-standards/container-security.md +741 -0
  102. package/cloud-native/01-standards/kubernetes-complete.md +812 -0
  103. package/cloud-native/02-playbooks/api-gateway-playbook.md +155 -0
  104. package/cloud-native/02-playbooks/gitops-with-argocd.md +760 -0
  105. package/cloud-native/02-playbooks/k8s-troubleshooting-playbook.md +1942 -0
  106. package/cloud-native/02-playbooks/message-queue-playbook.md +129 -0
  107. package/cloud-native/02-playbooks/multicloud-governance.md +726 -0
  108. package/cloud-native/02-playbooks/serverless-patterns.md +788 -0
  109. package/cloud-native/02-playbooks/service-mesh-playbook.md +612 -0
  110. package/cloud-native/02-playbooks/terraform-iac-playbook.md +143 -0
  111. package/cloud-native/03-checklists/container-security-checklist.md +431 -0
  112. package/cloud-native/03-checklists/k8s-production-readiness-checklist.md +460 -0
  113. package/cloud-native/04-antipatterns/container-antipatterns.md +660 -0
  114. package/cloud-native/04-antipatterns/k8s-antipatterns.md +743 -0
  115. package/cloud-native/05-cases/case-k8s-migration.md +478 -0
  116. package/cloud-native/05-cases/case-k8s-scaling.md +642 -0
  117. package/cloud-native/05-cases/case-k8s-security-incident.md +397 -0
  118. package/cloud-native/06-glossary/cloud-native-glossary.md +337 -0
  119. package/cross-platform/01-standards/cross-platform-frameworks.md +83 -0
  120. package/cross-platform/01-standards/platform-selection-and-architecture.md +77 -0
  121. package/data/01-standards/elasticsearch-complete.md +2098 -0
  122. package/data/01-standards/postgresql-complete.md +1613 -0
  123. package/data/01-standards/redis-complete.md +1527 -0
  124. package/data/02-playbooks/database-optimization-playbook.md +403 -0
  125. package/data/02-playbooks/elasticsearch-production-playbook.md +132 -0
  126. package/data/03-checklists/database-launch-checklist.md +187 -0
  127. package/data/04-antipatterns/database-antipatterns.md +873 -0
  128. package/data/05-cases/case-database-migration.md +310 -0
  129. package/data/06-glossary/database-glossary.md +440 -0
  130. package/data/data-governance-and-modeling-deep-dive.md +39 -0
  131. package/data-engineering/01-standards/airflow-complete.md +523 -0
  132. package/data-engineering/01-standards/kafka-complete.md +1521 -0
  133. package/data-engineering/02-playbooks/spark-etl-playbook.md +496 -0
  134. package/data-engineering/03-checklists/pipeline-launch-checklist.md +194 -0
  135. package/data-engineering/04-antipatterns/data-pipeline-antipatterns.md +684 -0
  136. package/data-engineering/05-cases/case-real-time-pipeline.md +355 -0
  137. package/data-engineering/06-glossary/data-engineering-glossary.md +429 -0
  138. package/database/01-standards/database-schema-standards.md +147 -0
  139. package/database/02-playbooks/postgresql-optimization-quick.md +52 -0
  140. package/database/02-playbooks/postgresql-performance-optimization.md +58 -0
  141. package/database/02-playbooks/postgresql-production-playbook.md +146 -0
  142. package/database/02-playbooks/redis-caching-playbook.md +117 -0
  143. package/database/03-checklists/database-review-checklist.md +50 -0
  144. package/database/04-antipatterns/database-antipatterns.md +112 -0
  145. package/design/01-standards/ui-design-system-complete.md +423 -0
  146. package/design/02-playbooks/design-handoff-playbook.md +254 -0
  147. package/design/02-playbooks/design-review-playbook.md +388 -0
  148. package/design/03-checklists/design-review-checklist.md +246 -0
  149. package/design/04-antipatterns/design-antipatterns.md +378 -0
  150. package/design/05-cases/case-design-system-adoption.md +328 -0
  151. package/design/06-glossary/design-glossary.md +329 -0
  152. package/design/ui-full-lifecycle-cross-platform-playbook.md +571 -0
  153. package/design/ux-system-deep-dive.md +38 -0
  154. package/design-systems/00-craft-rules.md +71 -0
  155. package/design-systems/aesthetic-families.md +43 -0
  156. package/design-systems/anti-ai-slop.md +162 -0
  157. package/design-systems/bold-geometric.md +120 -0
  158. package/design-systems/brutalist-bold.md +103 -0
  159. package/design-systems/editorial-clean.md +109 -0
  160. package/design-systems/glass-aurora.md +108 -0
  161. package/design-systems/modern-minimal.md +145 -0
  162. package/design-systems/premium-luxury.md +106 -0
  163. package/design-systems/product-type-design-map.md +48 -0
  164. package/design-systems/soft-warm.md +123 -0
  165. package/design-systems/tech-utility.md +113 -0
  166. package/desktop/01-standards/desktop-app-standard.md +72 -0
  167. package/desktop/01-standards/desktop-design.md +71 -0
  168. package/development/00-governance/document-template.md +41 -0
  169. package/development/01-standards/api-versioning-strategies.md +432 -0
  170. package/development/01-standards/authentication-patterns-complete.md +479 -0
  171. package/development/01-standards/css-architecture-complete.md +550 -0
  172. package/development/01-standards/database-migration-strategies.md +484 -0
  173. package/development/01-standards/elasticsearch-complete.md +347 -0
  174. package/development/01-standards/git-complete.md +371 -0
  175. package/development/01-standards/golang-complete.md +1565 -0
  176. package/development/01-standards/graphql-complete.md +298 -0
  177. package/development/01-standards/javascript-bundlers-complete.md +469 -0
  178. package/development/01-standards/javascript-typescript-complete.md +528 -0
  179. package/development/01-standards/jest-complete.md +275 -0
  180. package/development/01-standards/linux-complete.md +234 -0
  181. package/development/01-standards/logging-observability-complete.md +526 -0
  182. package/development/01-standards/microservices-communication.md +502 -0
  183. package/development/01-standards/mongodb-complete.md +406 -0
  184. package/development/01-standards/oauth2-complete.md +285 -0
  185. package/development/01-standards/performance-optimization-complete.md +289 -0
  186. package/development/01-standards/playwright-complete.md +247 -0
  187. package/development/01-standards/postgresql-complete.md +456 -0
  188. package/development/01-standards/pytest-complete.md +340 -0
  189. package/development/01-standards/python-async-programming.md +902 -0
  190. package/development/01-standards/python-complete.md +956 -0
  191. package/development/01-standards/python-decorators-complete.md +799 -0
  192. package/development/01-standards/python-design-patterns.md +2854 -0
  193. package/development/01-standards/python-packaging-distribution.md +420 -0
  194. package/development/01-standards/python-testing-strategies.md +607 -0
  195. package/development/01-standards/python-web-frameworks-comparison.md +471 -0
  196. package/development/01-standards/redis-complete.md +317 -0
  197. package/development/01-standards/rest-api-complete.md +316 -0
  198. package/development/01-standards/rust-complete.md +578 -0
  199. package/development/01-standards/typescript-advanced-types.md +1513 -0
  200. package/development/01-standards/web-security-complete.md +292 -0
  201. package/development/02-playbooks/api-design-playbook.md +810 -0
  202. package/development/02-playbooks/database-migration-playbook.md +580 -0
  203. package/development/02-playbooks/debugging-playbook.md +692 -0
  204. package/development/02-playbooks/feature-delivery-playbook.md +430 -0
  205. package/development/02-playbooks/incident-hotfix-playbook.md +387 -0
  206. package/development/02-playbooks/performance-optimization-playbook.md +531 -0
  207. package/development/02-playbooks/performance-tuning-playbook.md +652 -0
  208. package/development/02-playbooks/refactor-playbook.md +403 -0
  209. package/development/02-playbooks/release-playbook.md +469 -0
  210. package/development/03-checklists/architecture-review-checklist.md +168 -0
  211. package/development/03-checklists/data-migration-checklist.md +157 -0
  212. package/development/03-checklists/oncall-handover-checklist.md +173 -0
  213. package/development/03-checklists/pr-checklist.md +158 -0
  214. package/development/03-checklists/production-readiness-checklist.md +190 -0
  215. package/development/03-checklists/release-readiness-checklist.md +154 -0
  216. package/development/03-checklists/security-review-checklist.md +182 -0
  217. package/development/04-antipatterns/api-antipatterns.md +657 -0
  218. package/development/04-antipatterns/architecture-antipatterns.md +686 -0
  219. package/development/04-antipatterns/backend-antipatterns.md +648 -0
  220. package/development/04-antipatterns/cicd-antipatterns.md +540 -0
  221. package/development/04-antipatterns/code-smell-antipatterns.md +571 -0
  222. package/development/04-antipatterns/data-antipatterns.md +658 -0
  223. package/development/04-antipatterns/database-antipatterns.md +578 -0
  224. package/development/04-antipatterns/frontend-antipatterns.md +635 -0
  225. package/development/04-antipatterns/reliability-antipatterns.md +700 -0
  226. package/development/04-antipatterns/security-antipatterns.md +747 -0
  227. package/development/05-cases/case-api-version-migration.md +428 -0
  228. package/development/05-cases/case-authorization-hardening.md +383 -0
  229. package/development/05-cases/case-bluegreen-rollback.md +466 -0
  230. package/development/05-cases/case-cache-snowball-protection.md +485 -0
  231. package/development/05-cases/case-ci-cd-pipeline.md +544 -0
  232. package/development/05-cases/case-database-scaling.md +500 -0
  233. package/development/05-cases/case-db-hotspot-optimization.md +487 -0
  234. package/development/05-cases/case-incident-mttr-reduction.md +563 -0
  235. package/development/05-cases/case-microservice-migration.md +375 -0
  236. package/development/05-cases/case-performance-optimization.md +406 -0
  237. package/development/05-cases/case-security-incident-response.md +345 -0
  238. package/development/06-glossary/full-stack-glossary.md +166 -0
  239. package/development/09-maturity/quarterly-audit-template.md +35 -0
  240. package/development/11-ui-excellence/ui-aesthetic-system.md +41 -0
  241. package/development/11-ui-excellence/ui-engineering-excellence.md +435 -0
  242. package/development/12-scenarios/development-scenarios-guide.md +565 -0
  243. package/development/13-implementation-assets/implementation-toolkit.md +282 -0
  244. package/development/13-implementation-assets/knowledge-gates-execution.md +43 -0
  245. package/development/14-full-lifecycle/software-lifecycle-gates.md +511 -0
  246. package/development/15-lifecycle-templates/project-templates-collection.md +791 -0
  247. package/development/api-contract-and-versioning-guide.md +36 -0
  248. package/development/api-governance-complete.md +43 -0
  249. package/development/backend-engineering-complete.md +43 -0
  250. package/development/code-review-quality-complete.md +43 -0
  251. package/development/concurrency-reliability-complete.md +43 -0
  252. package/development/database-engineering-complete.md +43 -0
  253. package/development/engineering-effectiveness-complete.md +43 -0
  254. package/development/engineering-standards-deep-dive.md +38 -0
  255. package/development/frontend-engineering-complete.md +43 -0
  256. package/development/performance-capacity-complete.md +43 -0
  257. package/development/refactor-migration-complete.md +42 -0
  258. package/development/refactoring-and-techdebt-playbook.md +37 -0
  259. package/development/security-in-development-complete.md +43 -0
  260. package/devops/01-standards/cicd-pipeline-complete.md +262 -0
  261. package/devops/01-standards/docker-complete.md +1490 -0
  262. package/devops/01-standards/github-actions-complete.md +337 -0
  263. package/devops/01-standards/kubernetes-complete.md +638 -0
  264. package/devops/01-standards/terraform-complete.md +2117 -0
  265. package/devops/02-playbooks/docker-compose-playbook.md +233 -0
  266. package/devops/02-playbooks/docker-k8s-production-playbook.md +186 -0
  267. package/devops/02-playbooks/docker-production-playbook.md +952 -0
  268. package/edge-iot/01-standards/edge-iot-complete.md +473 -0
  269. package/experts/architect/api-design.md +178 -0
  270. package/experts/architect/methodology.md +124 -0
  271. package/experts/architect/security.md +75 -0
  272. package/experts/backend-lead/methodology.md +216 -0
  273. package/experts/devops/methodology.md +160 -0
  274. package/experts/frontend-lead/methodology.md +178 -0
  275. package/experts/product-manager/industry/ecommerce.md +43 -0
  276. package/experts/product-manager/industry/saas.md +40 -0
  277. package/experts/product-manager/methodology.md +97 -0
  278. package/experts/qa-lead/methodology.md +123 -0
  279. package/experts/qa-lead/test-strategy.md +128 -0
  280. package/experts/uiux-designer/methodology.md +125 -0
  281. package/frontend/01-standards/accessibility-complete.md +532 -0
  282. package/frontend/01-standards/accessibility-standard.md +74 -0
  283. package/frontend/01-standards/admin-dashboard-and-crud.md +72 -0
  284. package/frontend/01-standards/design-tokens-complete.md +444 -0
  285. package/frontend/01-standards/forms-and-validation.md +77 -0
  286. package/frontend/01-standards/frontend-architecture-and-layering.md +119 -0
  287. package/frontend/01-standards/i18n-and-localization.md +65 -0
  288. package/frontend/01-standards/nextjs-complete.md +451 -0
  289. package/frontend/01-standards/react-complete.md +713 -0
  290. package/frontend/01-standards/react-hooks-complete-guide.md +1100 -0
  291. package/frontend/01-standards/react-hooks-complete.md +1171 -0
  292. package/frontend/01-standards/seo-and-web-vitals.md +77 -0
  293. package/frontend/01-standards/state-management-complete.md +444 -0
  294. package/frontend/01-standards/vue-complete.md +499 -0
  295. package/frontend/01-standards/vue3-complete.md +2002 -0
  296. package/frontend/01-standards/web-framework-best-practices.md +64 -0
  297. package/frontend/01-standards/web-performance-complete.md +495 -0
  298. package/frontend/02-playbooks/accessibility-a11y-playbook.md +161 -0
  299. package/frontend/02-playbooks/frontend-performance-playbook.md +707 -0
  300. package/frontend/02-playbooks/i18n-internationalization-playbook.md +120 -0
  301. package/frontend/02-playbooks/performance-optimization-playbook.md +163 -0
  302. package/frontend/02-playbooks/react-nextjs-production-playbook.md +167 -0
  303. package/frontend/02-playbooks/react-state-management-playbook.md +173 -0
  304. package/frontend/03-checklists/component-quality-checklist.md +166 -0
  305. package/frontend/03-checklists/frontend-launch-checklist.md +299 -0
  306. package/frontend/04-antipatterns/frontend-antipatterns.md +886 -0
  307. package/frontend/05-cases/case-performance-optimization.md +274 -0
  308. package/harmony/01-standards/harmonyos-arkts-standard.md +75 -0
  309. package/harmony/01-standards/harmonyos-design.md +65 -0
  310. package/high-quality-engineering-playbook.md +54 -0
  311. package/incident/01-standards/incident-response-complete.md +303 -0
  312. package/incident/02-playbooks/chaos-engineering-playbook.md +883 -0
  313. package/incident/02-playbooks/postmortem-playbook.md +398 -0
  314. package/incident/03-checklists/incident-readiness-checklist.md +181 -0
  315. package/incident/04-antipatterns/incident-antipatterns.md +490 -0
  316. package/incident/05-cases/case-cascade-failure.md +176 -0
  317. package/incident/06-glossary/incident-glossary.md +114 -0
  318. package/incident/postmortem-and-response-deep-dive.md +39 -0
  319. package/industries/ecommerce/ecommerce-complete.md +631 -0
  320. package/industries/education/education-complete.md +555 -0
  321. package/industries/fintech/fintech-complete.md +501 -0
  322. package/industries/gaming/gaming-complete.md +587 -0
  323. package/industries/healthcare/healthcare-complete.md +452 -0
  324. package/low-code/01-standards/low-code-complete.md +944 -0
  325. package/miniprogram/01-standards/ai-common-mistakes.md +61 -0
  326. package/miniprogram/01-standards/miniprogram-custom-navbar-capsule.md +77 -0
  327. package/miniprogram/01-standards/miniprogram-design.md +61 -0
  328. package/miniprogram/01-standards/miniprogram-standard.md +81 -0
  329. package/mobile/01-standards/android-material-design.md +70 -0
  330. package/mobile/01-standards/flutter-complete.md +384 -0
  331. package/mobile/01-standards/ios-design-hig.md +78 -0
  332. package/mobile/01-standards/mobile-app-standard.md +85 -0
  333. package/mobile/01-standards/react-native-complete.md +352 -0
  334. package/mobile/02-playbooks/mobile-cross-platform-playbook.md +175 -0
  335. package/mobile/02-playbooks/mobile-performance.md +473 -0
  336. package/mobile/03-checklists/mobile-release-checklist.md +234 -0
  337. package/mobile/04-antipatterns/mobile-antipatterns.md +798 -0
  338. package/mobile/05-cases/case-app-performance.md +500 -0
  339. package/mobile/05-cases/case-app-startup-optimization.md +218 -0
  340. package/mobile/06-glossary/mobile-glossary.md +484 -0
  341. package/observability/01-standards/observability-standards.md +103 -0
  342. package/observability/02-playbooks/prometheus-grafana-playbook.md +135 -0
  343. package/observability/02-playbooks/structured-logging-playbook.md +73 -0
  344. package/observability/03-checklists/observability-checklist.md +54 -0
  345. package/observability/04-antipatterns/observability-antipatterns.md +106 -0
  346. package/operations/01-standards/prometheus-monitoring-complete.md +1578 -0
  347. package/operations/02-playbooks/capacity-planning-playbook.md +620 -0
  348. package/operations/03-checklists/production-launch-checklist.md +365 -0
  349. package/operations/04-antipatterns/operations-antipatterns.md +664 -0
  350. package/operations/05-cases/case-sre-practices.md +581 -0
  351. package/operations/06-glossary/operations-glossary.md +120 -0
  352. package/operations/aiops-anomaly-detection.md +758 -0
  353. package/operations/capacity-planning.md +1061 -0
  354. package/operations/chaos-engineering.md +659 -0
  355. package/operations/incident-command-system.md +38 -0
  356. package/operations/observability-complete.md +442 -0
  357. package/operations/slo-sli-playbook.md +517 -0
  358. package/operations/sre-operations-deep-dive.md +39 -0
  359. package/package.json +8 -0
  360. package/performance/01-standards/performance-and-scalability.md +80 -0
  361. package/performance/01-standards/performance-standards.md +156 -0
  362. package/performance/02-playbooks/query-optimization-playbook.md +103 -0
  363. package/performance/03-checklists/performance-checklist.md +56 -0
  364. package/performance/04-antipatterns/performance-antipatterns.md +146 -0
  365. package/product/01-standards/product-management-complete.md +285 -0
  366. package/product/02-playbooks/feature-launch-playbook.md +207 -0
  367. package/product/02-playbooks/user-research-playbook.md +532 -0
  368. package/product/03-checklists/feature-launch-checklist.md +275 -0
  369. package/product/04-antipatterns/product-antipatterns.md +355 -0
  370. package/product/05-cases/case-mvp-to-scale.md +384 -0
  371. package/product/06-glossary/product-glossary.md +462 -0
  372. package/product/feature-prioritization-framework.md +40 -0
  373. package/product/kpi-and-metric-tree.md +37 -0
  374. package/product/product-discovery-and-prd-deep-dive.md +41 -0
  375. package/quantum/01-standards/quantum-complete.md +1186 -0
  376. package/security/01-standards/api-security-complete.md +511 -0
  377. package/security/01-standards/container-runtime-security.md +574 -0
  378. package/security/01-standards/data-protection-gdpr.md +543 -0
  379. package/security/01-standards/owasp-top10-complete.md +1890 -0
  380. package/security/01-standards/secure-coding-baseline.md +90 -0
  381. package/security/01-standards/supply-chain-security.md +441 -0
  382. package/security/01-standards/web-security-checklist.md +108 -0
  383. package/security/01-standards/zero-trust-architecture.md +521 -0
  384. package/security/02-playbooks/auth-sso-playbook.md +166 -0
  385. package/security/02-playbooks/incident-response-security-playbook.md +588 -0
  386. package/security/02-playbooks/owasp-api-security-playbook.md +129 -0
  387. package/security/02-playbooks/payment-integration-playbook.md +119 -0
  388. package/security/02-playbooks/penetration-testing-playbook.md +517 -0
  389. package/security/03-checklists/security-audit-checklist.md +356 -0
  390. package/security/04-antipatterns/security-coding-antipatterns.md +580 -0
  391. package/security/05-cases/case-log4shell-incident.md +537 -0
  392. package/security/05-cases/case-major-breaches.md +468 -0
  393. package/security/06-glossary/security-glossary.md +212 -0
  394. package/security/compliance-automation.md +993 -0
  395. package/security/container-security.md +680 -0
  396. package/security/devsecops-complete.md +426 -0
  397. package/security/sast-dast-sca.md +775 -0
  398. package/security/secrets-management.md +594 -0
  399. package/security/security-architecture-deep-dive.md +37 -0
  400. package/security/threat-modeling-stride-playbook.md +40 -0
  401. package/seed-templates/auth-system.md +59 -0
  402. package/seed-templates/blog-content.md +94 -0
  403. package/seed-templates/dashboard.md +89 -0
  404. package/seed-templates/docs-site.md +73 -0
  405. package/seed-templates/e-commerce.md +50 -0
  406. package/seed-templates/saas-landing.md +92 -0
  407. package/seed-templates/settings-page.md +51 -0
  408. package/testing/01-standards/test-strategy-and-layering.md +83 -0
  409. package/testing/01-standards/testing-strategy-complete.md +422 -0
  410. package/testing/01-standards/unit-testing-best-practices.md +118 -0
  411. package/testing/02-playbooks/e2e-testing-playbook.md +988 -0
  412. package/testing/02-playbooks/testing-strategy-playbook.md +126 -0
  413. package/testing/03-checklists/test-strategy-checklist.md +208 -0
  414. package/testing/04-antipatterns/testing-antipatterns.md +718 -0
  415. package/testing/05-cases/case-testing-transformation.md +300 -0
  416. package/testing/06-glossary/testing-glossary.md +110 -0
  417. package/testing/risk-based-test-matrix.md +36 -0
  418. package/testing/testing-strategy-deep-dive.md +37 -0
@@ -0,0 +1,993 @@
1
+ ---
2
+ id: compliance-automation
3
+ title: 合规自动化完整指南
4
+ domain: security
5
+ category: compliance-automation.md
6
+ difficulty: intermediate
7
+ tags: [automation, code, compliance, security, 合规工作流, 合规报告, 合规框架, 审计日志]
8
+ quality_score: 70
9
+ last_updated: 2026-06-15
10
+ ---
11
+ # 合规自动化完整指南
12
+
13
+ ## 概述
14
+ 合规自动化(Compliance as Code)将合规要求转化为可执行代码,实现持续监控、自动检查和快速审计,降低合规成本和风险。
15
+
16
+ ## 合规框架
17
+
18
+ ### 1. 常见合规标准
19
+
20
+ #### GDPR(通用数据保护条例)
21
+ ```yaml
22
+ 核心要求:
23
+ - 数据主体权利(访问、删除、移植)
24
+ - 数据处理合法性
25
+ - 数据最小化原则
26
+ - 数据安全保护
27
+ - 隐私设计(Privacy by Design)
28
+ - 数据泄露通知(72 小时)
29
+ - DPO(数据保护官)任命
30
+ - 跨境数据传输合规
31
+
32
+ 技术控制:
33
+ - 数据加密(传输、存储)
34
+ - 访问控制和审计
35
+ - 数据分类和标记
36
+ - 同意管理系统
37
+ - 数据保留策略
38
+ - 备份和恢复
39
+ ```
40
+
41
+ #### SOC 2 Type II
42
+ ```yaml
43
+ 信任服务标准:
44
+ - 安全性(Security)
45
+ - 可用性(Availability)
46
+ - 处理完整性(Processing Integrity)
47
+ - 机密性(Confidentiality)
48
+ - 隐私性(Privacy)
49
+
50
+ 控制域:
51
+ - 访问控制
52
+ - 加密管理
53
+ - 变更管理
54
+ - 事件响应
55
+ - 备份恢复
56
+ - 网络安全
57
+ - 供应商管理
58
+ ```
59
+
60
+ #### PCI-DSS(支付卡行业数据安全标准)
61
+ ```yaml
62
+ 12 项核心要求:
63
+ 1. 防火墙配置
64
+ 2. 默认密码修改
65
+ 3. 存储卡数据保护
66
+ 4. 传输加密
67
+ 5. 防病毒软件
68
+ 6. 安全系统开发
69
+ 7. 访问限制
70
+ 8. 身份认证
71
+ 9. 物理访问控制
72
+ 10. 日志审计
73
+ 11. 安全测试
74
+ 12. 信息安全策略
75
+
76
+ 技术控制:
77
+ - 网络分段
78
+ - 数据加密(TLS 1.2+)
79
+ - 密钥管理
80
+ - 漏洞扫描(季度)
81
+ - 渗透测试(年度)
82
+ - 文件完整性监控
83
+ ```
84
+
85
+ #### ISO 27001
86
+ ```yaml
87
+ 控制域(Annex A):
88
+ A.5 - 信息安全策略
89
+ A.6 - 信息安全组织
90
+ A.7 - 人力资源安全
91
+ A.8 - 资产管理
92
+ A.9 - 访问控制
93
+ A.10 - 密码学
94
+ A.11 - 物理和环境安全
95
+ A.12 - 操作安全
96
+ A.13 - 通信安全
97
+ A.14 - 系统获取、开发和维护
98
+ A.15 - 供应商关系
99
+ A.16 - 信息安全事件管理
100
+ A.17 - 业务连续性管理
101
+ A.18 - 合规性
102
+ ```
103
+
104
+ ## 合规即代码(Compliance as Code)
105
+
106
+ ### 1. 策略定义
107
+
108
+ #### Open Policy Agent(OPA)
109
+ ```rego
110
+ # policy.rego
111
+ package authz
112
+
113
+ # RBAC 策略
114
+ default allow = false
115
+
116
+ allow {
117
+ some i
118
+ input.user.roles[i] = "admin"
119
+ }
120
+
121
+ allow {
122
+ some i
123
+ input.user.roles[i] = "viewer"
124
+ input.method = "GET"
125
+ }
126
+
127
+ # 数据访问控制
128
+ allow {
129
+ input.user.department = input.resource.department
130
+ input.method in ["GET", "POST"]
131
+ }
132
+
133
+ # 拒绝敏感数据访问
134
+ deny[msg] {
135
+ input.resource.sensitive = true
136
+ not input.user.clearance_level in ["confidential", "secret"]
137
+ msg := "用户无权访问敏感数据"
138
+ }
139
+ ```
140
+
141
+ #### Checkov(IaC 扫描)
142
+ ```yaml
143
+ # custom_check.yaml
144
+ metadata:
145
+ id: "CKV_CUSTOM_001"
146
+ name: "确保 S3 存储桶启用加密"
147
+ category: "ENCRYPTION"
148
+ definition:
149
+ cond_type: attribute
150
+ resource_types:
151
+ - aws_s3_bucket
152
+ attribute: server_side_encryption_configuration.rule.apply_server_side_encryption_by_default.sse_algorithm
153
+ operator: exists
154
+ ```
155
+
156
+ ```python
157
+ # Python 自定义检查
158
+ from checkov.terraform.checks.resource.base_resource_value_check import BaseResourceValueCheck
159
+
160
+ class S3EncryptionCheck(BaseResourceValueCheck):
161
+ def __init__(self):
162
+ name = "确保 S3 存储桶启用加密"
163
+ id = "CKV_CUSTOM_001"
164
+ supported_resources = ['aws_s3_bucket']
165
+ categories = ['encryption']
166
+ super().__init__(name=name, id=id, categories=categories, supported_resources=supported_resources)
167
+
168
+ def scan_resource_conf(self, conf):
169
+ if 'server_side_encryption_configuration' in conf:
170
+ return CheckResult.PASSED
171
+ return CheckResult.FAILED
172
+ ```
173
+
174
+ ### 2. 自动化检查
175
+
176
+ #### Kubernetes 准入控制
177
+ ```yaml
178
+ # Gatekeeper 约束模板
179
+ apiVersion: templates.gatekeeper.sh/v1
180
+ kind: ConstraintTemplate
181
+ metadata:
182
+ name: k8srequiredlabels
183
+ spec:
184
+ crd:
185
+ spec:
186
+ names:
187
+ kind: K8sRequiredLabels
188
+ validation:
189
+ openAPIV3Schema:
190
+ properties:
191
+ labels:
192
+ type: array
193
+ items:
194
+ type: string
195
+ targets:
196
+ - target: admission.k8s.gatekeeper.sh
197
+ rego: |
198
+ package k8srequiredlabels
199
+
200
+ violation[{"msg": msg}] {
201
+ provided := {label | input.review.object.metadata.labels[label]}
202
+ required := {label | label := input.parameters.labels[_]}
203
+ missing := required - provided
204
+ count(missing) > 0
205
+ msg := sprintf("缺少必需标签: %v", [missing])
206
+ }
207
+
208
+ ---
209
+ # 应用约束
210
+ apiVersion: constraints.gatekeeper.sh/v1beta1
211
+ kind: K8sRequiredLabels
212
+ metadata:
213
+ name: require-compliance-labels
214
+ spec:
215
+ match:
216
+ kinds:
217
+ - apiGroups: [""]
218
+ kinds: ["Pod", "Deployment"]
219
+ parameters:
220
+ labels:
221
+ - "owner"
222
+ - "environment"
223
+ - "compliance-level"
224
+ ```
225
+
226
+ #### 云资源合规检查
227
+ ```python
228
+ # AWS Config 规则
229
+ import json
230
+ import boto3
231
+
232
+ def lambda_handler(event, context):
233
+ config = boto3.client('config')
234
+
235
+ # 检查 S3 加密
236
+ invoking_event = json.loads(event['invokingEvent'])
237
+ configuration_item = invoking_event['configurationItem']
238
+
239
+ if configuration_item['resourceType'] != 'AWS::S3::Bucket':
240
+ return {'compliance_type': 'NOT_APPLICABLE'}
241
+
242
+ bucket_encryption = configuration_item['supplementaryConfiguration'].get('ServerSideEncryptionConfiguration')
243
+
244
+ if bucket_encryption:
245
+ return {
246
+ 'compliance_type': 'COMPLIANT',
247
+ 'annotation': 'S3 存储桶已启用加密'
248
+ }
249
+ else:
250
+ return {
251
+ 'compliance_type': 'NON_COMPLIANT',
252
+ 'annotation': 'S3 存储桶未启用加密'
253
+ }
254
+ ```
255
+
256
+ ### 3. 持续监控
257
+
258
+ #### Prowler(AWS 安全检查)
259
+ ```bash
260
+ # 运行 CIS 合规检查
261
+ prowler aws --cis-levels 1,2 --severity high critical
262
+
263
+ # 自定义检查
264
+ prowler aws --checks custom_check_001,custom_check_002
265
+
266
+ # 输出报告
267
+ prowler aws --output-formats json-ocsF csv html
268
+ ```
269
+
270
+ #### Scout Suite(多云安全审计)
271
+ ```bash
272
+ # AWS 审计
273
+ scout aws
274
+
275
+ # Azure 审计
276
+ scout azure
277
+
278
+ # GCP 审计
279
+ scout gcp
280
+
281
+ # 生成报告
282
+ open scout-report/scoutsuite-results/scoutsuite_results_*.html
283
+ ```
284
+
285
+ ## 数据合规
286
+
287
+ ### 1. 数据分类
288
+ ```yaml
289
+ # 数据分类策略
290
+ data_classification:
291
+ public:
292
+ description: 公开信息,无限制访问
293
+ examples: [产品文档, 营销材料]
294
+ controls: []
295
+
296
+ internal:
297
+ description: 内部信息,仅限员工访问
298
+ examples: [内部政策, 组织架构]
299
+ controls:
300
+ - 访问控制
301
+ - 传输加密
302
+
303
+ confidential:
304
+ description: 机密信息,需授权访问
305
+ examples: [客户数据, 财务数据]
306
+ controls:
307
+ - 严格访问控制
308
+ - 传输和存储加密
309
+ - 审计日志
310
+ - 数据掩码
311
+
312
+ restricted:
313
+ description: 高度机密,严格限制访问
314
+ examples: [密钥, PII, 医疗数据]
315
+ controls:
316
+ - 最小权限访问
317
+ - 端到端加密
318
+ - 完整审计追踪
319
+ - 数据丢失防护(DLP)
320
+ - 定期审查
321
+ ```
322
+
323
+ ### 2. 数据保留策略
324
+ ```python
325
+ # 数据保留自动化
326
+ from datetime import datetime, timedelta
327
+ from dataclasses import dataclass
328
+
329
+ @dataclass
330
+ class RetentionPolicy:
331
+ data_type: str
332
+ retention_days: int
333
+ legal_hold: bool = False
334
+
335
+ def should_delete(self, created_at: datetime) -> bool:
336
+ if self.legal_hold:
337
+ return False
338
+
339
+ expiry_date = created_at + timedelta(days=self.retention_days)
340
+ return datetime.now() > expiry_date
341
+
342
+ # 应用保留策略
343
+ policies = {
344
+ 'user_logs': RetentionPolicy('user_logs', 90),
345
+ 'financial_records': RetentionPolicy('financial_records', 2555, legal_hold=True), # 7 年
346
+ 'marketing_data': RetentionPolicy('marketing_data', 365),
347
+ 'pii_data': RetentionPolicy('pii_data', 180)
348
+ }
349
+
350
+ def enforce_retention():
351
+ for data_type, policy in policies.items():
352
+ records = get_records(data_type)
353
+ for record in records:
354
+ if policy.should_delete(record.created_at):
355
+ delete_record(record.id)
356
+ log_deletion(record.id, data_type)
357
+ ```
358
+
359
+ ### 3. 隐私保护
360
+ ```python
361
+ # 数据匿名化
362
+ import hashlib
363
+ from faker import Faker
364
+
365
+ fake = Faker()
366
+
367
+ def anonymize_pii(data: dict) -> dict:
368
+ """匿名化 PII 数据"""
369
+ anonymized = data.copy()
370
+
371
+ # 哈希化邮箱
372
+ if 'email' in anonymized:
373
+ anonymized['email'] = hashlib.sha256(
374
+ anonymized['email'].encode()
375
+ ).hexdigest()[:10] + '@anonymized.com'
376
+
377
+ # 替换姓名
378
+ if 'name' in anonymized:
379
+ anonymized['name'] = fake.name()
380
+
381
+ # 掩码电话号码
382
+ if 'phone' in anonymized:
383
+ phone = anonymized['phone']
384
+ anonymized['phone'] = phone[:3] + '****' + phone[-4:]
385
+
386
+ # 泛化地址
387
+ if 'address' in anonymized:
388
+ anonymized['address'] = fake.city()
389
+
390
+ return anonymized
391
+
392
+ # 数据掩码
393
+ def mask_sensitive_data(data: str, visible_chars: int = 4) -> str:
394
+ """掩码敏感数据"""
395
+ if len(data) <= visible_chars:
396
+ return '*' * len(data)
397
+
398
+ visible = data[:visible_chars]
399
+ masked = '*' * (len(data) - visible_chars)
400
+ return visible + masked
401
+ ```
402
+
403
+ ## 访问控制合规
404
+
405
+ ### 1. RBAC 实施
406
+ ```yaml
407
+ # Kubernetes RBAC
408
+ apiVersion: rbac.authorization.k8s.io/v1
409
+ kind: Role
410
+ metadata:
411
+ name: compliance-viewer
412
+ namespace: production
413
+ rules:
414
+ - apiGroups: [""]
415
+ resources: ["pods", "configmaps"]
416
+ verbs: ["get", "list", "watch"]
417
+ - apiGroups: [""]
418
+ resources: ["secrets"]
419
+ verbs: ["get"]
420
+ resourceNames: ["non-sensitive-secret"]
421
+
422
+ ---
423
+ apiVersion: rbac.authorization.k8s.io/v1
424
+ kind: RoleBinding
425
+ metadata:
426
+ name: compliance-auditor-binding
427
+ namespace: production
428
+ subjects:
429
+ - kind: User
430
+ name: auditor@company.com
431
+ apiGroup: rbac.authorization.k8s.io
432
+ roleRef:
433
+ kind: Role
434
+ name: compliance-viewer
435
+ apiGroup: rbac.authorization.k8s.io
436
+ ```
437
+
438
+ ### 2. 权限审查
439
+ ```python
440
+ # 权限审查自动化
441
+ import boto3
442
+
443
+ def audit_iam_permissions():
444
+ iam = boto3.client('iam')
445
+
446
+ findings = []
447
+
448
+ # 获取所有用户
449
+ users = iam.list_users()['Users']
450
+
451
+ for user in users:
452
+ username = user['UserName']
453
+
454
+ # 检查活动访问密钥
455
+ access_keys = iam.list_access_keys(UserName=username)['AccessKeyMetadata']
456
+ active_keys = [k for k in access_keys if k['Status'] == 'Active']
457
+
458
+ if len(active_keys) > 1:
459
+ findings.append({
460
+ 'user': username,
461
+ 'finding': '多个活动访问密钥',
462
+ 'severity': 'medium'
463
+ })
464
+
465
+ # 检查密码使用情况
466
+ if 'PasswordLastUsed' in user:
467
+ last_used = user['PasswordLastUsed']
468
+ days_since_use = (datetime.now() - last_used).days
469
+
470
+ if days_since_use > 90:
471
+ findings.append({
472
+ 'user': username,
473
+ 'finding': f'密码 {days_since_use} 天未使用',
474
+ 'severity': 'low'
475
+ })
476
+
477
+ # 检查附加策略
478
+ attached_policies = iam.list_attached_user_policies(UserName=username)['AttachedPolicies']
479
+
480
+ for policy in attached_policies:
481
+ if 'AdministratorAccess' in policy['PolicyName']:
482
+ findings.append({
483
+ 'user': username,
484
+ 'finding': '拥有管理员权限',
485
+ 'severity': 'high'
486
+ })
487
+
488
+ return findings
489
+ ```
490
+
491
+ ## 审计日志
492
+
493
+ ### 1. 日志收集
494
+ ```yaml
495
+ # Elasticsearch 日志收集
496
+ apiVersion: v1
497
+ kind: ConfigMap
498
+ metadata:
499
+ name: audit-log-config
500
+ data:
501
+ fluent.conf: |
502
+ <source>
503
+ @type tail
504
+ path /var/log/audit/*.log
505
+ pos_file /var/log/audit.log.pos
506
+ tag audit
507
+ format json
508
+ time_key timestamp
509
+ time_format %Y-%m-%dT%H:%M:%S.%NZ
510
+ </source>
511
+
512
+ <filter audit>
513
+ @type record_transformer
514
+ <record>
515
+ hostname ${hostname}
516
+ environment #{ENV['ENVIRONMENT']}
517
+ compliance_tag pci-dss,gdpr
518
+ </record>
519
+ </filter>
520
+
521
+ <match audit>
522
+ @type elasticsearch
523
+ host elasticsearch
524
+ port 9200
525
+ index_name audit-logs
526
+ type_name _doc
527
+ </match>
528
+ ```
529
+
530
+ ### 2. 审计事件
531
+ ```json
532
+ {
533
+ "timestamp": "2025-03-20T10:00:00Z",
534
+ "event_type": "data_access",
535
+ "actor": {
536
+ "user_id": "user-123",
537
+ "username": "john.doe",
538
+ "ip_address": "10.0.1.100",
539
+ "user_agent": "Mozilla/5.0",
540
+ "session_id": "sess-abc123"
541
+ },
542
+ "resource": {
543
+ "type": "customer_record",
544
+ "id": "cust-456",
545
+ "classification": "confidential",
546
+ "contains_pii": true
547
+ },
548
+ "action": {
549
+ "type": "read",
550
+ "result": "success",
551
+ "details": {
552
+ "fields_accessed": ["name", "email", "phone"],
553
+ "records_count": 1
554
+ }
555
+ },
556
+ "compliance": {
557
+ "gdpr": {
558
+ "lawful_basis": "legitimate_interest",
559
+ "data_subject_consent": true
560
+ },
561
+ "pci_dss": {
562
+ "requirement": "7.1",
563
+ "control": "need_to_know"
564
+ }
565
+ },
566
+ "location": {
567
+ "country": "CN",
568
+ "region": "Beijing"
569
+ }
570
+ }
571
+ ```
572
+
573
+ ### 3. 日志分析
574
+ ```python
575
+ # 合规日志分析
576
+ from elasticsearch import Elasticsearch
577
+
578
+ es = Elasticsearch(['http://elasticsearch:9200'])
579
+
580
+ def analyze_access_patterns():
581
+ """分析异常访问模式"""
582
+
583
+ query = {
584
+ "query": {
585
+ "bool": {
586
+ "must": [
587
+ {"range": {"timestamp": {"gte": "now-7d"}}},
588
+ {"term": {"resource.contains_pii": True}}
589
+ ]
590
+ }
591
+ },
592
+ "aggs": {
593
+ "users": {
594
+ "terms": {"field": "actor.user_id"},
595
+ "aggs": {
596
+ "access_count": {"value_count": {"field": "_id"}},
597
+ "unique_resources": {"cardinality": {"field": "resource.id"}}
598
+ }
599
+ }
600
+ }
601
+ }
602
+
603
+ result = es.search(index='audit-logs', body=query)
604
+
605
+ anomalies = []
606
+ for bucket in result['aggregations']['users']['buckets']:
607
+ access_count = bucket['access_count']['value']
608
+ unique_resources = bucket['unique_resources']['value']
609
+
610
+ # 检测异常访问
611
+ if access_count > 1000 and unique_resources > 100:
612
+ anomalies.append({
613
+ 'user_id': bucket['key'],
614
+ 'finding': '高频 PII 数据访问',
615
+ 'access_count': access_count,
616
+ 'unique_resources': unique_resources,
617
+ 'severity': 'high'
618
+ })
619
+
620
+ return anomalies
621
+ ```
622
+
623
+ ## 合规报告
624
+
625
+ ### 1. 自动生成报告
626
+ ```python
627
+ # 合规报告生成器
628
+ from datetime import datetime, timedelta
629
+ from reportlab.lib.pagesizes import A4
630
+ from reportlab.pdfgen import canvas
631
+
632
+ class ComplianceReport:
633
+ def __init__(self, framework: str):
634
+ self.framework = framework
635
+ self.controls = []
636
+
637
+ def add_control(self, control_id: str, status: str, evidence: str):
638
+ self.controls.append({
639
+ 'id': control_id,
640
+ 'status': status,
641
+ 'evidence': evidence,
642
+ 'timestamp': datetime.now()
643
+ })
644
+
645
+ def generate_pdf(self, output_path: str):
646
+ c = canvas.Canvas(output_path, pagesize=A4)
647
+ width, height = A4
648
+
649
+ # 标题
650
+ c.setFont("Helvetica-Bold", 20)
651
+ c.drawString(100, height - 50, f"{self.framework} Compliance Report")
652
+
653
+ # 日期
654
+ c.setFont("Helvetica", 12)
655
+ c.drawString(100, height - 80, f"Generated: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
656
+
657
+ # 控制项
658
+ y_position = height - 150
659
+ for control in self.controls:
660
+ c.setFont("Helvetica-Bold", 10)
661
+ c.drawString(100, y_position, f"{control['id']} - {control['status']}")
662
+
663
+ c.setFont("Helvetica", 9)
664
+ c.drawString(120, y_position - 15, f"Evidence: {control['evidence']}")
665
+
666
+ y_position -= 50
667
+
668
+ if y_position < 100:
669
+ c.showPage()
670
+ y_position = height - 50
671
+
672
+ c.save()
673
+
674
+ # 生成 SOC 2 报告
675
+ report = ComplianceReport('SOC 2 Type II')
676
+ report.add_control('CC6.1', 'COMPLIANT', 'Access control policy reviewed 2025-03-01')
677
+ report.add_control('CC6.6', 'COMPLIANT', 'MFA enabled for all users')
678
+ report.add_control('CC7.1', 'NON_COMPLIANT', 'Missing vulnerability scan for Q1')
679
+ report.generate_pdf('/reports/soc2-report.pdf')
680
+ ```
681
+
682
+ ### 2. 仪表板
683
+ ```yaml
684
+ # Grafana 仪表板配置
685
+ apiVersion: 1
686
+ providers:
687
+ - name: 'Compliance Dashboard'
688
+ folder: 'Security'
689
+ type: file
690
+ options:
691
+ path: /var/lib/grafana/dashboards
692
+
693
+ dashboards:
694
+ - uid: compliance-overview
695
+ title: Compliance Overview
696
+ panels:
697
+ - title: Control Compliance Rate
698
+ type: gauge
699
+ gridPos:
700
+ x: 0
701
+ y: 0
702
+ w: 8
703
+ h: 6
704
+ targets:
705
+ - expr: (sum(compliant_controls) / sum(total_controls)) * 100
706
+
707
+ - title: Non-Compliant Controls by Framework
708
+ type: piechart
709
+ gridPos:
710
+ x: 8
711
+ y: 0
712
+ w: 8
713
+ h: 6
714
+ targets:
715
+ - expr: sum(non_compliant_controls) by (framework)
716
+
717
+ - title: Control Status Trend
718
+ type: graph
719
+ gridPos:
720
+ x: 0
721
+ y: 6
722
+ w: 16
723
+ h: 8
724
+ targets:
725
+ - expr: sum(compliant_controls)
726
+ legendFormat: Compliant
727
+ - expr: sum(non_compliant_controls)
728
+ legendFormat: Non-Compliant
729
+ ```
730
+
731
+ ## 合规工作流
732
+
733
+ ### 1. 事件响应
734
+ ```yaml
735
+ # 合规事件响应流程
736
+ name: compliance_incident_response
737
+ trigger:
738
+ type: compliance_violation
739
+ severity: [high, critical]
740
+
741
+ steps:
742
+ - name: assess_impact
743
+ action: analyze_violation
744
+ params:
745
+ control_id: "{{ event.control_id }}"
746
+ framework: "{{ event.framework }}"
747
+
748
+ - name: notify_stakeholders
749
+ condition: impact == "high"
750
+ action: send_notification
751
+ params:
752
+ channels:
753
+ - "#compliance-alerts"
754
+ - "#security-team"
755
+ message: |
756
+ 合规违规告警
757
+ 框架: {{ event.framework }}
758
+ 控制项: {{ event.control_id }}
759
+ 严重性: {{ event.severity }}
760
+ 详情: {{ event.details }}
761
+
762
+ - name: create_remediation_task
763
+ action: create_jira_ticket
764
+ params:
765
+ project: "COMPLIANCE"
766
+ issue_type: "Bug"
767
+ priority: "{{ event.severity }}"
768
+ summary: "修复合规违规: {{ event.control_id }}"
769
+ description: |
770
+ 框架: {{ event.framework }}
771
+ 控制项: {{ event.control_id }}
772
+ 证据: {{ event.evidence }}
773
+ 影响: {{ impact }}
774
+
775
+ - name: escalate_to_dpo
776
+ condition: framework == "GDPR" and contains_pii == True
777
+ action: notify_user
778
+ params:
779
+ user: "dpo@company.com"
780
+ subject: "GDPR 合规违规需审查"
781
+ message: "{{ event.details }}"
782
+ ```
783
+
784
+ ### 2. 变更管理
785
+ ```yaml
786
+ # 变更审批流程
787
+ name: change_approval_workflow
788
+ trigger:
789
+ type: pull_request
790
+ paths:
791
+ - "terraform/**"
792
+ - "kubernetes/**"
793
+
794
+ steps:
795
+ - name: compliance_check
796
+ action: run_compliance_scan
797
+ params:
798
+ frameworks:
799
+ - pci-dss
800
+ - soc2
801
+ - gdpr
802
+
803
+ - name: impact_assessment
804
+ condition: compliance_check.status == "non_compliant"
805
+ action: assess_impact
806
+ params:
807
+ changes: "{{ git.diff }}"
808
+
809
+ - name: require_approval
810
+ condition: impact == "high"
811
+ action: request_review
812
+ params:
813
+ reviewers:
814
+ - "compliance-team"
815
+ - "security-team"
816
+ auto_approve: false
817
+
818
+ - name: document_change
819
+ action: create_record
820
+ params:
821
+ type: "change_log"
822
+ data:
823
+ change_id: "{{ git.commit_sha }}"
824
+ framework_impact: "{{ impact.frameworks }}"
825
+ approved_by: "{{ reviewers.approved_by }}"
826
+ timestamp: "{{ now }}"
827
+ ```
828
+
829
+ ## 供应商合规管理
830
+
831
+ ### 1. 供应商评估
832
+ ```yaml
833
+ # 供应商安全评估清单
834
+ vendor_assessment:
835
+ general:
836
+ - name: 公司注册信息
837
+ required: true
838
+ - name: 财务稳定性证明
839
+ required: true
840
+ - name: 保险覆盖
841
+ required: true
842
+
843
+ security:
844
+ - name: 安全认证(ISO 27001, SOC 2)
845
+ required: true
846
+ - name: 渗透测试报告
847
+ required: true
848
+ frequency: annual
849
+ - name: 漏洞扫描报告
850
+ required: true
851
+ frequency: quarterly
852
+ - name: 事件响应计划
853
+ required: true
854
+ - name: BCP/DR 计划
855
+ required: true
856
+
857
+ privacy:
858
+ - name: 隐私政策
859
+ required: true
860
+ - name: DPA(数据处理协议)
861
+ required: true
862
+ - name: 数据处理地点
863
+ required: true
864
+ - name: 数据保留政策
865
+ required: true
866
+
867
+ compliance:
868
+ - name: GDPR 合规声明
869
+ required: condition
870
+ condition: 处理 EU 居民数据
871
+ - name: PCI-DSS 合规证明
872
+ required: condition
873
+ condition: 处理支付数据
874
+ - name: HIPAA 合规证明
875
+ required: condition
876
+ condition: 处理医疗数据
877
+ ```
878
+
879
+ ### 2. 持续监控
880
+ ```python
881
+ # 供应商风险监控
882
+ from datetime import datetime, timedelta
883
+
884
+ class VendorMonitor:
885
+ def __init__(self):
886
+ self.vendors = {}
887
+
888
+ def check_certification_expiry(self, vendor_id: str):
889
+ """检查认证过期"""
890
+ vendor = self.vendors[vendor_id]
891
+
892
+ for cert in vendor['certifications']:
893
+ expiry_date = datetime.strptime(cert['expiry_date'], '%Y-%m-%d')
894
+ days_until_expiry = (expiry_date - datetime.now()).days
895
+
896
+ if days_until_expiry < 0:
897
+ self.alert(f"[CRITICAL] {vendor['name']} 认证已过期: {cert['name']}")
898
+ elif days_until_expiry < 30:
899
+ self.alert(f"[WARNING] {vendor['name']} 认证即将过期: {cert['name']} (剩余 {days_until_expiry} 天)")
900
+
901
+ def check_security_incidents(self, vendor_id: str):
902
+ """检查安全事件"""
903
+ vendor = self.vendors[vendor_id]
904
+
905
+ # 检查公开漏洞
906
+ vulns = self.query_vulnerability_database(vendor['products'])
907
+ if vulns:
908
+ self.alert(f"[HIGH] {vendor['name']} 存在公开漏洞: {len(vulns)} 个")
909
+
910
+ def assess_risk_score(self, vendor_id: str) -> int:
911
+ """评估供应商风险评分"""
912
+ vendor = self.vendors[vendor_id]
913
+ score = 0
914
+
915
+ # 认证过期风险
916
+ for cert in vendor['certifications']:
917
+ if cert['status'] != 'valid':
918
+ score += 20
919
+
920
+ # 安全事件风险
921
+ incidents = vendor.get('security_incidents', [])
922
+ score += len(incidents) * 15
923
+
924
+ # 数据访问风险
925
+ if vendor.get('access_to_pii'):
926
+ score += 25
927
+
928
+ # 合规违规风险
929
+ violations = vendor.get('compliance_violations', [])
930
+ score += len(violations) * 30
931
+
932
+ return min(score, 100) # 最高 100 分
933
+ ```
934
+
935
+ ## 实施检查清单
936
+
937
+ ### GDPR
938
+ - [ ] 数据处理活动记录(ROPA)
939
+ - [ ] 隐私影响评估(DPIA)
940
+ - [ ] 数据主体权利流程
941
+ - [ ] 数据泄露响应计划
942
+ - [ ] DPO 任命
943
+ - [ ] 同意管理机制
944
+ - [ ] 数据保留政策
945
+ - [ ] 跨境数据传输协议
946
+
947
+ ### SOC 2
948
+ - [ ] 控制目标定义
949
+ - [ ] 策略和程序文档
950
+ - [ ] 访问控制实施
951
+ - [ ] 变更管理流程
952
+ - [ ] 事件响应计划
953
+ - [ ] 备份和恢复测试
954
+ - [ ] 定期风险评估
955
+ - [ ] 第三方审计安排
956
+
957
+ ### PCI-DSS
958
+ - [ ] 网络分段
959
+ - [ ] 数据加密
960
+ - [ ] 访问控制
961
+ - [ ] 日志审计
962
+ - [ ] 漏洞扫描
963
+ - [ ] 渗透测试
964
+ - [ ] 文件完整性监控
965
+ - [ ] 安全培训
966
+
967
+ ### ISO 27001
968
+ - [ ] 信息安全管理体系(ISMS)
969
+ - [ ] 风险评估方法
970
+ - [ ] 适用性声明(SoA)
971
+ - [ ] 控制措施实施
972
+ - [ ] 内部审计计划
973
+ - [ ] 管理评审
974
+ - [ ] 持续改进机制
975
+ - [ ] 认证审核
976
+
977
+ ## 工具链
978
+
979
+ | 类别 | 工具 | 用途 |
980
+ |------|------|------|
981
+ | 策略引擎 | OPA, Kyverno | 策略执行 |
982
+ | IaC 扫描 | Checkov, tfsec | 基础设施合规 |
983
+ | 云审计 | Prowler, Scout Suite | 云资源检查 |
984
+ | 日志分析 | ELK, Splunk | 审计分析 |
985
+ | 报告生成 | Custom Scripts | 合规报告 |
986
+ | 供应商管理 | OneTrust, BitSight | 第三方风险 |
987
+
988
+ ## 参考资料
989
+ - [GDPR Official Text](https://gdpr-info.eu/)
990
+ - [SOC 2 Guide](https://www.aicpa.org/soc2)
991
+ - [PCI-DSS Standards](https://www.pcisecuritystandards.org/)
992
+ - [ISO 27001 Requirements](https://www.iso.org/isoiec-27001-information-security.html)
993
+ - [Open Policy Agent](https://www.openpolicyagent.org/)