@zimezone/z-command 1.1.1 → 1.1.4

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 (288) hide show
  1. package/README.md +13 -1
  2. package/dist/cli.js +1 -1
  3. package/dist/commands/init.d.ts.map +1 -1
  4. package/dist/commands/init.js +42 -10
  5. package/dist/commands/init.js.map +1 -1
  6. package/dist/platforms.d.ts.map +1 -1
  7. package/dist/platforms.js +11 -1
  8. package/dist/platforms.js.map +1 -1
  9. package/dist/types.d.ts +2 -0
  10. package/dist/types.d.ts.map +1 -1
  11. package/package.json +8 -3
  12. package/templates.zip +0 -0
  13. package/templates/agents/accessibility-expert.agent.md +0 -56
  14. package/templates/agents/ai-engineer.agent.md +0 -61
  15. package/templates/agents/angular-architect.agent.md +0 -49
  16. package/templates/agents/api-designer.agent.md +0 -40
  17. package/templates/agents/api-documenter.agent.md +0 -161
  18. package/templates/agents/architect-review.agent.md +0 -146
  19. package/templates/agents/arm-cortex-expert.agent.md +0 -288
  20. package/templates/agents/azure-infra-engineer.agent.md +0 -57
  21. package/templates/agents/backend-architect.agent.md +0 -309
  22. package/templates/agents/backend-developer.agent.md +0 -61
  23. package/templates/agents/backend-security-coder.agent.md +0 -152
  24. package/templates/agents/bash-pro.agent.md +0 -285
  25. package/templates/agents/blockchain-developer.agent.md +0 -57
  26. package/templates/agents/build-engineer.agent.md +0 -56
  27. package/templates/agents/business-analyst.agent.md +0 -47
  28. package/templates/agents/c-pro.agent.md +0 -35
  29. package/templates/agents/c4-code.agent.md +0 -320
  30. package/templates/agents/c4-component.agent.md +0 -227
  31. package/templates/agents/c4-container.agent.md +0 -248
  32. package/templates/agents/c4-context.agent.md +0 -235
  33. package/templates/agents/cli-developer.agent.md +0 -57
  34. package/templates/agents/cloud-architect.agent.md +0 -56
  35. package/templates/agents/code-architect.agent.md +0 -63
  36. package/templates/agents/code-reviewer.agent.md +0 -49
  37. package/templates/agents/competitive-analyst.agent.md +0 -48
  38. package/templates/agents/conductor-validator.agent.md +0 -245
  39. package/templates/agents/context-manager.agent.md +0 -55
  40. package/templates/agents/cpp-pro.agent.md +0 -59
  41. package/templates/agents/csharp-developer.agent.md +0 -57
  42. package/templates/agents/csharp-pro.agent.md +0 -38
  43. package/templates/agents/customer-support.agent.md +0 -148
  44. package/templates/agents/data-engineer.agent.md +0 -55
  45. package/templates/agents/data-researcher.agent.md +0 -55
  46. package/templates/agents/data-scientist.agent.md +0 -56
  47. package/templates/agents/database-admin.agent.md +0 -142
  48. package/templates/agents/database-administrator.agent.md +0 -50
  49. package/templates/agents/database-architect.agent.md +0 -238
  50. package/templates/agents/database-optimizer.agent.md +0 -144
  51. package/templates/agents/debugger.agent.md +0 -30
  52. package/templates/agents/deployment-engineer.agent.md +0 -0
  53. package/templates/agents/devops-engineer.agent.md +0 -59
  54. package/templates/agents/devops-troubleshooter.agent.md +0 -138
  55. package/templates/agents/django-developer.agent.md +0 -50
  56. package/templates/agents/django-pro.agent.md +0 -159
  57. package/templates/agents/docs-architect.agent.md +0 -77
  58. package/templates/agents/documentation-engineer.agent.md +0 -57
  59. package/templates/agents/dotnet-architect.agent.md +0 -175
  60. package/templates/agents/dx-optimizer.agent.md +0 -63
  61. package/templates/agents/electron-pro.agent.md +0 -56
  62. package/templates/agents/elixir-pro.agent.md +0 -38
  63. package/templates/agents/embedded-systems.agent.md +0 -55
  64. package/templates/agents/error-detective.agent.md +0 -32
  65. package/templates/agents/event-sourcing-architect.agent.md +0 -42
  66. package/templates/agents/fastapi-pro.agent.md +0 -171
  67. package/templates/agents/fintech-engineer.agent.md +0 -57
  68. package/templates/agents/firmware-analyst.agent.md +0 -330
  69. package/templates/agents/flutter-expert.agent.md +0 -50
  70. package/templates/agents/frontend-developer.agent.md +0 -59
  71. package/templates/agents/frontend-security-coder.agent.md +0 -149
  72. package/templates/agents/fullstack-developer.agent.md +0 -46
  73. package/templates/agents/git-workflow-manager.agent.md +0 -57
  74. package/templates/agents/golang-pro.agent.md +0 -50
  75. package/templates/agents/graphql-architect.agent.md +0 -48
  76. package/templates/agents/haskell-pro.agent.md +0 -37
  77. package/templates/agents/hr-pro.agent.md +0 -105
  78. package/templates/agents/incident-responder.agent.md +0 -190
  79. package/templates/agents/ios-developer.agent.md +0 -198
  80. package/templates/agents/iot-engineer.agent.md +0 -56
  81. package/templates/agents/java-architect.agent.md +0 -48
  82. package/templates/agents/java-pro.agent.md +0 -156
  83. package/templates/agents/javascript-pro.agent.md +0 -35
  84. package/templates/agents/julia-pro.agent.md +0 -187
  85. package/templates/agents/kotlin-specialist.agent.md +0 -50
  86. package/templates/agents/laravel-specialist.agent.md +0 -50
  87. package/templates/agents/legacy-modernizer.agent.md +0 -56
  88. package/templates/agents/legal-advisor.agent.md +0 -49
  89. package/templates/agents/llm-architect.agent.md +0 -58
  90. package/templates/agents/malware-analyst.agent.md +0 -272
  91. package/templates/agents/mcp-developer.agent.md +0 -54
  92. package/templates/agents/mermaid-expert.agent.md +0 -39
  93. package/templates/agents/microservices-architect.agent.md +0 -47
  94. package/templates/agents/minecraft-bukkit-pro.agent.md +0 -104
  95. package/templates/agents/ml-engineer.agent.md +0 -56
  96. package/templates/agents/mlops-engineer.agent.md +0 -56
  97. package/templates/agents/mobile-developer.agent.md +0 -45
  98. package/templates/agents/mobile-security-coder.agent.md +0 -163
  99. package/templates/agents/monorepo-architect.agent.md +0 -44
  100. package/templates/agents/multi-agent-coordinator.agent.md +0 -55
  101. package/templates/agents/network-engineer.agent.md +0 -57
  102. package/templates/agents/nextjs-developer.agent.md +0 -48
  103. package/templates/agents/nlp-engineer.agent.md +0 -58
  104. package/templates/agents/observability-engineer.agent.md +0 -228
  105. package/templates/agents/payment-integration.agent.md +0 -56
  106. package/templates/agents/performance-engineer.agent.md +0 -167
  107. package/templates/agents/performance-optimizer.agent.md +0 -57
  108. package/templates/agents/php-pro.agent.md +0 -43
  109. package/templates/agents/platform-engineer.agent.md +0 -57
  110. package/templates/agents/posix-shell-pro.agent.md +0 -284
  111. package/templates/agents/postgres-pro.agent.md +0 -58
  112. package/templates/agents/product-manager.agent.md +0 -55
  113. package/templates/agents/project-manager.agent.md +0 -57
  114. package/templates/agents/prompt-engineer.agent.md +0 -58
  115. package/templates/agents/python-pro.agent.md +0 -48
  116. package/templates/agents/quant-analyst.agent.md +0 -32
  117. package/templates/agents/rails-expert.agent.md +0 -50
  118. package/templates/agents/react-specialist.agent.md +0 -49
  119. package/templates/agents/refactoring-specialist.agent.md +0 -56
  120. package/templates/agents/reference-builder.agent.md +0 -167
  121. package/templates/agents/research-analyst.agent.md +0 -63
  122. package/templates/agents/reverse-engineer.agent.md +0 -202
  123. package/templates/agents/risk-manager.agent.md +0 -41
  124. package/templates/agents/ruby-pro.agent.md +0 -35
  125. package/templates/agents/rust-pro.agent.md +0 -156
  126. package/templates/agents/sales-automator.agent.md +0 -35
  127. package/templates/agents/scala-pro.agent.md +0 -60
  128. package/templates/agents/scrum-master.agent.md +0 -54
  129. package/templates/agents/search-specialist.agent.md +0 -59
  130. package/templates/agents/security-analyst.agent.md +0 -57
  131. package/templates/agents/security-auditor.agent.md +0 -138
  132. package/templates/agents/security-engineer.agent.md +0 -57
  133. package/templates/agents/seo-authority-builder.agent.md +0 -116
  134. package/templates/agents/seo-cannibalization-detector.agent.md +0 -103
  135. package/templates/agents/seo-content-auditor.agent.md +0 -63
  136. package/templates/agents/seo-content-planner.agent.md +0 -88
  137. package/templates/agents/seo-content-refresher.agent.md +0 -98
  138. package/templates/agents/seo-content-writer.agent.md +0 -76
  139. package/templates/agents/seo-keyword-strategist.agent.md +0 -75
  140. package/templates/agents/seo-meta-optimizer.agent.md +0 -72
  141. package/templates/agents/seo-snippet-hunter.agent.md +0 -94
  142. package/templates/agents/seo-specialist.agent.md +0 -57
  143. package/templates/agents/seo-structure-architect.agent.md +0 -88
  144. package/templates/agents/service-mesh-expert.agent.md +0 -41
  145. package/templates/agents/sql-pro.agent.md +0 -146
  146. package/templates/agents/sre-engineer.agent.md +0 -58
  147. package/templates/agents/swift-expert.agent.md +0 -49
  148. package/templates/agents/task-distributor.agent.md +0 -47
  149. package/templates/agents/tdd-orchestrator.agent.md +0 -183
  150. package/templates/agents/technical-writer.agent.md +0 -48
  151. package/templates/agents/temporal-python-pro.agent.md +0 -349
  152. package/templates/agents/terraform-engineer.agent.md +0 -57
  153. package/templates/agents/terraform-specialist.agent.md +0 -137
  154. package/templates/agents/test-automator.agent.md +0 -203
  155. package/templates/agents/test-engineer.agent.md +0 -55
  156. package/templates/agents/threat-modeling-expert.agent.md +0 -44
  157. package/templates/agents/trend-analyst.agent.md +0 -47
  158. package/templates/agents/tutorial-engineer.agent.md +0 -118
  159. package/templates/agents/typescript-pro.agent.md +0 -48
  160. package/templates/agents/ui-designer.agent.md +0 -48
  161. package/templates/agents/ui-ux-designer.agent.md +0 -188
  162. package/templates/agents/ui-visual-validator.agent.md +0 -192
  163. package/templates/agents/ux-researcher.agent.md +0 -48
  164. package/templates/agents/vector-database-engineer.agent.md +0 -43
  165. package/templates/agents/vue-expert.agent.md +0 -48
  166. package/templates/agents/websocket-engineer.agent.md +0 -49
  167. package/templates/agents/workflow-orchestrator.agent.md +0 -48
  168. package/templates/skills/angular-migration/SKILL.md +0 -410
  169. package/templates/skills/api-design-principles/SKILL.md +0 -528
  170. package/templates/skills/api-design-principles/assets/api-design-checklist.md +0 -155
  171. package/templates/skills/api-design-principles/assets/rest-api-template.py +0 -182
  172. package/templates/skills/api-design-principles/references/graphql-schema-design.md +0 -583
  173. package/templates/skills/api-design-principles/references/rest-best-practices.md +0 -408
  174. package/templates/skills/architecture-decision-records/SKILL.md +0 -428
  175. package/templates/skills/architecture-patterns/SKILL.md +0 -494
  176. package/templates/skills/async-python-patterns/SKILL.md +0 -694
  177. package/templates/skills/auth-implementation-patterns/SKILL.md +0 -634
  178. package/templates/skills/changelog-automation/SKILL.md +0 -552
  179. package/templates/skills/code-review/SKILL.md +0 -62
  180. package/templates/skills/code-review-excellence/SKILL.md +0 -520
  181. package/templates/skills/competitive-landscape/SKILL.md +0 -479
  182. package/templates/skills/context-driven-development/SKILL.md +0 -385
  183. package/templates/skills/cost-optimization/SKILL.md +0 -274
  184. package/templates/skills/cqrs-implementation/SKILL.md +0 -554
  185. package/templates/skills/data-quality-frameworks/SKILL.md +0 -587
  186. package/templates/skills/data-storytelling/SKILL.md +0 -453
  187. package/templates/skills/database-migration/SKILL.md +0 -424
  188. package/templates/skills/dbt-transformation-patterns/SKILL.md +0 -561
  189. package/templates/skills/debugging-strategies/SKILL.md +0 -527
  190. package/templates/skills/defi-protocol-templates/SKILL.md +0 -454
  191. package/templates/skills/dependency-upgrade/SKILL.md +0 -409
  192. package/templates/skills/deployment-pipeline-design/SKILL.md +0 -359
  193. package/templates/skills/distributed-tracing/SKILL.md +0 -438
  194. package/templates/skills/dotnet-backend-patterns/SKILL.md +0 -815
  195. package/templates/skills/dotnet-backend-patterns/assets/repository-template.cs +0 -523
  196. package/templates/skills/dotnet-backend-patterns/assets/service-template.cs +0 -336
  197. package/templates/skills/dotnet-backend-patterns/references/dapper-patterns.md +0 -544
  198. package/templates/skills/dotnet-backend-patterns/references/ef-core-best-practices.md +0 -355
  199. package/templates/skills/e2e-testing-patterns/SKILL.md +0 -547
  200. package/templates/skills/employment-contract-templates/SKILL.md +0 -507
  201. package/templates/skills/error-handling-patterns/SKILL.md +0 -636
  202. package/templates/skills/event-store-design/SKILL.md +0 -437
  203. package/templates/skills/fastapi-templates/SKILL.md +0 -567
  204. package/templates/skills/git-advanced-workflows/SKILL.md +0 -400
  205. package/templates/skills/github-actions-templates/SKILL.md +0 -333
  206. package/templates/skills/go-concurrency-patterns/SKILL.md +0 -655
  207. package/templates/skills/grafana-dashboards/SKILL.md +0 -369
  208. package/templates/skills/helm-chart-scaffolding/SKILL.md +0 -544
  209. package/templates/skills/helm-chart-scaffolding/assets/Chart.yaml.template +0 -42
  210. package/templates/skills/helm-chart-scaffolding/assets/values.yaml.template +0 -185
  211. package/templates/skills/helm-chart-scaffolding/references/chart-structure.md +0 -500
  212. package/templates/skills/helm-chart-scaffolding/scripts/validate-chart.sh +0 -244
  213. package/templates/skills/javascript-testing-patterns/SKILL.md +0 -1025
  214. package/templates/skills/langchain-architecture/SKILL.md +0 -338
  215. package/templates/skills/llm-evaluation/SKILL.md +0 -471
  216. package/templates/skills/microservices-patterns/SKILL.md +0 -595
  217. package/templates/skills/modern-javascript-patterns/SKILL.md +0 -911
  218. package/templates/skills/monorepo-management/SKILL.md +0 -622
  219. package/templates/skills/nextjs-app-router-patterns/SKILL.md +0 -544
  220. package/templates/skills/nodejs-backend-patterns/SKILL.md +0 -1020
  221. package/templates/skills/nx-workspace-patterns/SKILL.md +0 -452
  222. package/templates/skills/openapi-spec-generation/SKILL.md +0 -1028
  223. package/templates/skills/paypal-integration/SKILL.md +0 -467
  224. package/templates/skills/pci-compliance/SKILL.md +0 -466
  225. package/templates/skills/postgresql/SKILL.md +0 -204
  226. package/templates/skills/projection-patterns/SKILL.md +0 -490
  227. package/templates/skills/prometheus-configuration/SKILL.md +0 -392
  228. package/templates/skills/prompt-engineering-patterns/SKILL.md +0 -201
  229. package/templates/skills/prompt-engineering-patterns/assets/few-shot-examples.json +0 -106
  230. package/templates/skills/prompt-engineering-patterns/assets/prompt-template-library.md +0 -246
  231. package/templates/skills/prompt-engineering-patterns/references/chain-of-thought.md +0 -399
  232. package/templates/skills/prompt-engineering-patterns/references/few-shot-learning.md +0 -369
  233. package/templates/skills/prompt-engineering-patterns/references/prompt-optimization.md +0 -414
  234. package/templates/skills/prompt-engineering-patterns/references/prompt-templates.md +0 -470
  235. package/templates/skills/prompt-engineering-patterns/references/system-prompts.md +0 -189
  236. package/templates/skills/prompt-engineering-patterns/scripts/optimize-prompt.py +0 -279
  237. package/templates/skills/python-packaging/SKILL.md +0 -870
  238. package/templates/skills/python-performance-optimization/SKILL.md +0 -869
  239. package/templates/skills/python-testing-patterns/SKILL.md +0 -907
  240. package/templates/skills/rag-implementation/SKILL.md +0 -403
  241. package/templates/skills/react-modernization/SKILL.md +0 -513
  242. package/templates/skills/react-native-architecture/SKILL.md +0 -671
  243. package/templates/skills/react-state-management/SKILL.md +0 -429
  244. package/templates/skills/risk-metrics-calculation/SKILL.md +0 -555
  245. package/templates/skills/rust-async-patterns/SKILL.md +0 -517
  246. package/templates/skills/secrets-management/SKILL.md +0 -346
  247. package/templates/skills/security-requirement-extraction/SKILL.md +0 -677
  248. package/templates/skills/security-review/SKILL.md +0 -78
  249. package/templates/skills/shellcheck-configuration/SKILL.md +0 -454
  250. package/templates/skills/similarity-search-patterns/SKILL.md +0 -558
  251. package/templates/skills/slo-implementation/SKILL.md +0 -329
  252. package/templates/skills/sql-optimization-patterns/SKILL.md +0 -493
  253. package/templates/skills/stripe-integration/SKILL.md +0 -442
  254. package/templates/skills/systematic-debugging/SKILL.md +0 -57
  255. package/templates/skills/tailwind-design-system/SKILL.md +0 -666
  256. package/templates/skills/temporal-python-testing/SKILL.md +0 -158
  257. package/templates/skills/temporal-python-testing/resources/integration-testing.md +0 -455
  258. package/templates/skills/temporal-python-testing/resources/local-setup.md +0 -553
  259. package/templates/skills/temporal-python-testing/resources/replay-testing.md +0 -462
  260. package/templates/skills/temporal-python-testing/resources/unit-testing.md +0 -328
  261. package/templates/skills/terraform-module-library/SKILL.md +0 -249
  262. package/templates/skills/terraform-module-library/references/aws-modules.md +0 -63
  263. package/templates/skills/test-driven-development/SKILL.md +0 -46
  264. package/templates/skills/threat-mitigation-mapping/SKILL.md +0 -745
  265. package/templates/skills/track-management/SKILL.md +0 -593
  266. package/templates/skills/typescript-advanced-types/SKILL.md +0 -717
  267. package/templates/skills/ui-ux-pro-max/SKILL.md +0 -352
  268. package/templates/skills/ui-ux-pro-max/data/charts.csv +0 -26
  269. package/templates/skills/ui-ux-pro-max/data/colors.csv +0 -97
  270. package/templates/skills/ui-ux-pro-max/data/icons.csv +0 -101
  271. package/templates/skills/ui-ux-pro-max/data/landing.csv +0 -31
  272. package/templates/skills/ui-ux-pro-max/data/products.csv +0 -97
  273. package/templates/skills/ui-ux-pro-max/data/prompts.csv +0 -24
  274. package/templates/skills/ui-ux-pro-max/data/react-performance.csv +0 -45
  275. package/templates/skills/ui-ux-pro-max/data/styles.csv +0 -59
  276. package/templates/skills/ui-ux-pro-max/data/typography.csv +0 -58
  277. package/templates/skills/ui-ux-pro-max/data/ui-reasoning.csv +0 -101
  278. package/templates/skills/ui-ux-pro-max/data/ux-guidelines.csv +0 -100
  279. package/templates/skills/ui-ux-pro-max/data/web-interface.csv +0 -31
  280. package/templates/skills/ui-ux-pro-max/scripts/core.py +0 -258
  281. package/templates/skills/ui-ux-pro-max/scripts/design_system.py +0 -547
  282. package/templates/skills/ui-ux-pro-max/scripts/search.py +0 -76
  283. package/templates/skills/uv-package-manager/SKILL.md +0 -831
  284. package/templates/skills/vector-index-tuning/SKILL.md +0 -521
  285. package/templates/skills/wcag-audit-patterns/SKILL.md +0 -555
  286. package/templates/skills/workflow-orchestration-patterns/SKILL.md +0 -316
  287. package/templates/skills/workflow-patterns/SKILL.md +0 -623
  288. package/templates/skills/writing-plans/SKILL.md +0 -64
@@ -1,677 +0,0 @@
1
- ---
2
- name: security-requirement-extraction
3
- description: Derive security requirements from threat models and business context. Use when translating threats into actionable requirements, creating security user stories, or building security test cases.
4
- ---
5
-
6
- # Security Requirement Extraction
7
-
8
- Transform threat analysis into actionable security requirements.
9
-
10
- ## When to Use This Skill
11
-
12
- - Converting threat models to requirements
13
- - Writing security user stories
14
- - Creating security test cases
15
- - Building security acceptance criteria
16
- - Compliance requirement mapping
17
- - Security architecture documentation
18
-
19
- ## Core Concepts
20
-
21
- ### 1. Requirement Categories
22
-
23
- ```
24
- Business Requirements → Security Requirements → Technical Controls
25
- ↓ ↓ ↓
26
- "Protect customer "Encrypt PII at rest" "AES-256 encryption
27
- data" with KMS key rotation"
28
- ```
29
-
30
- ### 2. Security Requirement Types
31
-
32
- | Type | Focus | Example |
33
- |------|-------|---------|
34
- | **Functional** | What system must do | "System must authenticate users" |
35
- | **Non-functional** | How system must perform | "Authentication must complete in <2s" |
36
- | **Constraint** | Limitations imposed | "Must use approved crypto libraries" |
37
-
38
- ### 3. Requirement Attributes
39
-
40
- | Attribute | Description |
41
- |-----------|-------------|
42
- | **Traceability** | Links to threats/compliance |
43
- | **Testability** | Can be verified |
44
- | **Priority** | Business importance |
45
- | **Risk Level** | Impact if not met |
46
-
47
- ## Templates
48
-
49
- ### Template 1: Security Requirement Model
50
-
51
- ```python
52
- from dataclasses import dataclass, field
53
- from enum import Enum
54
- from typing import List, Dict, Optional, Set
55
- from datetime import datetime
56
-
57
- class RequirementType(Enum):
58
- FUNCTIONAL = "functional"
59
- NON_FUNCTIONAL = "non_functional"
60
- CONSTRAINT = "constraint"
61
-
62
-
63
- class Priority(Enum):
64
- CRITICAL = 1
65
- HIGH = 2
66
- MEDIUM = 3
67
- LOW = 4
68
-
69
-
70
- class SecurityDomain(Enum):
71
- AUTHENTICATION = "authentication"
72
- AUTHORIZATION = "authorization"
73
- DATA_PROTECTION = "data_protection"
74
- AUDIT_LOGGING = "audit_logging"
75
- INPUT_VALIDATION = "input_validation"
76
- ERROR_HANDLING = "error_handling"
77
- SESSION_MANAGEMENT = "session_management"
78
- CRYPTOGRAPHY = "cryptography"
79
- NETWORK_SECURITY = "network_security"
80
- AVAILABILITY = "availability"
81
-
82
-
83
- class ComplianceFramework(Enum):
84
- PCI_DSS = "pci_dss"
85
- HIPAA = "hipaa"
86
- GDPR = "gdpr"
87
- SOC2 = "soc2"
88
- NIST_CSF = "nist_csf"
89
- ISO_27001 = "iso_27001"
90
- OWASP = "owasp"
91
-
92
-
93
- @dataclass
94
- class SecurityRequirement:
95
- id: str
96
- title: str
97
- description: str
98
- req_type: RequirementType
99
- domain: SecurityDomain
100
- priority: Priority
101
- rationale: str = ""
102
- acceptance_criteria: List[str] = field(default_factory=list)
103
- test_cases: List[str] = field(default_factory=list)
104
- threat_refs: List[str] = field(default_factory=list)
105
- compliance_refs: List[str] = field(default_factory=list)
106
- dependencies: List[str] = field(default_factory=list)
107
- status: str = "draft"
108
- owner: str = ""
109
- created_date: datetime = field(default_factory=datetime.now)
110
-
111
- def to_user_story(self) -> str:
112
- """Convert to user story format."""
113
- return f"""
114
- **{self.id}: {self.title}**
115
-
116
- As a security-conscious system,
117
- I need to {self.description.lower()},
118
- So that {self.rationale.lower()}.
119
-
120
- **Acceptance Criteria:**
121
- {chr(10).join(f'- [ ] {ac}' for ac in self.acceptance_criteria)}
122
-
123
- **Priority:** {self.priority.name}
124
- **Domain:** {self.domain.value}
125
- **Threat References:** {', '.join(self.threat_refs)}
126
- """
127
-
128
- def to_test_spec(self) -> str:
129
- """Convert to test specification."""
130
- return f"""
131
- ## Test Specification: {self.id}
132
-
133
- ### Requirement
134
- {self.description}
135
-
136
- ### Test Cases
137
- {chr(10).join(f'{i+1}. {tc}' for i, tc in enumerate(self.test_cases))}
138
-
139
- ### Acceptance Criteria Verification
140
- {chr(10).join(f'- {ac}' for ac in self.acceptance_criteria)}
141
- """
142
-
143
-
144
- @dataclass
145
- class RequirementSet:
146
- name: str
147
- version: str
148
- requirements: List[SecurityRequirement] = field(default_factory=list)
149
-
150
- def add(self, req: SecurityRequirement) -> None:
151
- self.requirements.append(req)
152
-
153
- def get_by_domain(self, domain: SecurityDomain) -> List[SecurityRequirement]:
154
- return [r for r in self.requirements if r.domain == domain]
155
-
156
- def get_by_priority(self, priority: Priority) -> List[SecurityRequirement]:
157
- return [r for r in self.requirements if r.priority == priority]
158
-
159
- def get_by_threat(self, threat_id: str) -> List[SecurityRequirement]:
160
- return [r for r in self.requirements if threat_id in r.threat_refs]
161
-
162
- def get_critical_requirements(self) -> List[SecurityRequirement]:
163
- return [r for r in self.requirements if r.priority == Priority.CRITICAL]
164
-
165
- def export_markdown(self) -> str:
166
- """Export all requirements as markdown."""
167
- lines = [f"# Security Requirements: {self.name}\n"]
168
- lines.append(f"Version: {self.version}\n")
169
-
170
- for domain in SecurityDomain:
171
- domain_reqs = self.get_by_domain(domain)
172
- if domain_reqs:
173
- lines.append(f"\n## {domain.value.replace('_', ' ').title()}\n")
174
- for req in domain_reqs:
175
- lines.append(req.to_user_story())
176
-
177
- return "\n".join(lines)
178
-
179
- def traceability_matrix(self) -> Dict[str, List[str]]:
180
- """Generate threat-to-requirement traceability."""
181
- matrix = {}
182
- for req in self.requirements:
183
- for threat_id in req.threat_refs:
184
- if threat_id not in matrix:
185
- matrix[threat_id] = []
186
- matrix[threat_id].append(req.id)
187
- return matrix
188
- ```
189
-
190
- ### Template 2: Threat-to-Requirement Extractor
191
-
192
- ```python
193
- from dataclasses import dataclass
194
- from typing import List, Dict, Tuple
195
-
196
- @dataclass
197
- class ThreatInput:
198
- id: str
199
- category: str # STRIDE category
200
- title: str
201
- description: str
202
- target: str
203
- impact: str
204
- likelihood: str
205
-
206
-
207
- class RequirementExtractor:
208
- """Extract security requirements from threats."""
209
-
210
- # Mapping of STRIDE categories to security domains and requirement patterns
211
- STRIDE_MAPPINGS = {
212
- "SPOOFING": {
213
- "domains": [SecurityDomain.AUTHENTICATION, SecurityDomain.SESSION_MANAGEMENT],
214
- "patterns": [
215
- ("Implement strong authentication for {target}",
216
- "Ensure {target} authenticates all users before granting access"),
217
- ("Validate identity tokens for {target}",
218
- "All authentication tokens must be cryptographically verified"),
219
- ("Implement session management for {target}",
220
- "Sessions must be securely managed with proper expiration"),
221
- ]
222
- },
223
- "TAMPERING": {
224
- "domains": [SecurityDomain.INPUT_VALIDATION, SecurityDomain.DATA_PROTECTION],
225
- "patterns": [
226
- ("Validate all input to {target}",
227
- "All input must be validated against expected formats"),
228
- ("Implement integrity checks for {target}",
229
- "Data integrity must be verified using cryptographic signatures"),
230
- ("Protect {target} from modification",
231
- "Implement controls to prevent unauthorized data modification"),
232
- ]
233
- },
234
- "REPUDIATION": {
235
- "domains": [SecurityDomain.AUDIT_LOGGING],
236
- "patterns": [
237
- ("Log all security events for {target}",
238
- "Security-relevant events must be logged for audit purposes"),
239
- ("Implement non-repudiation for {target}",
240
- "Critical actions must have cryptographic proof of origin"),
241
- ("Protect audit logs for {target}",
242
- "Audit logs must be tamper-evident and protected"),
243
- ]
244
- },
245
- "INFORMATION_DISCLOSURE": {
246
- "domains": [SecurityDomain.DATA_PROTECTION, SecurityDomain.CRYPTOGRAPHY],
247
- "patterns": [
248
- ("Encrypt sensitive data in {target}",
249
- "Sensitive data must be encrypted at rest and in transit"),
250
- ("Implement access controls for {target}",
251
- "Data access must be restricted based on need-to-know"),
252
- ("Prevent information leakage from {target}",
253
- "Error messages and logs must not expose sensitive information"),
254
- ]
255
- },
256
- "DENIAL_OF_SERVICE": {
257
- "domains": [SecurityDomain.AVAILABILITY, SecurityDomain.INPUT_VALIDATION],
258
- "patterns": [
259
- ("Implement rate limiting for {target}",
260
- "Requests must be rate-limited to prevent resource exhaustion"),
261
- ("Ensure availability of {target}",
262
- "System must remain available under high load conditions"),
263
- ("Implement resource quotas for {target}",
264
- "Resource consumption must be bounded and monitored"),
265
- ]
266
- },
267
- "ELEVATION_OF_PRIVILEGE": {
268
- "domains": [SecurityDomain.AUTHORIZATION],
269
- "patterns": [
270
- ("Enforce authorization for {target}",
271
- "All actions must be authorized based on user permissions"),
272
- ("Implement least privilege for {target}",
273
- "Users must only have minimum necessary permissions"),
274
- ("Validate permissions for {target}",
275
- "Permission checks must be performed server-side"),
276
- ]
277
- },
278
- }
279
-
280
- def extract_requirements(
281
- self,
282
- threats: List[ThreatInput],
283
- project_name: str
284
- ) -> RequirementSet:
285
- """Extract security requirements from threats."""
286
- req_set = RequirementSet(
287
- name=f"{project_name} Security Requirements",
288
- version="1.0"
289
- )
290
-
291
- req_counter = 1
292
- for threat in threats:
293
- reqs = self._threat_to_requirements(threat, req_counter)
294
- for req in reqs:
295
- req_set.add(req)
296
- req_counter += len(reqs)
297
-
298
- return req_set
299
-
300
- def _threat_to_requirements(
301
- self,
302
- threat: ThreatInput,
303
- start_id: int
304
- ) -> List[SecurityRequirement]:
305
- """Convert a single threat to requirements."""
306
- requirements = []
307
- mapping = self.STRIDE_MAPPINGS.get(threat.category, {})
308
- domains = mapping.get("domains", [])
309
- patterns = mapping.get("patterns", [])
310
-
311
- priority = self._calculate_priority(threat.impact, threat.likelihood)
312
-
313
- for i, (title_pattern, desc_pattern) in enumerate(patterns):
314
- req = SecurityRequirement(
315
- id=f"SR-{start_id + i:03d}",
316
- title=title_pattern.format(target=threat.target),
317
- description=desc_pattern.format(target=threat.target),
318
- req_type=RequirementType.FUNCTIONAL,
319
- domain=domains[i % len(domains)] if domains else SecurityDomain.DATA_PROTECTION,
320
- priority=priority,
321
- rationale=f"Mitigates threat: {threat.title}",
322
- threat_refs=[threat.id],
323
- acceptance_criteria=self._generate_acceptance_criteria(
324
- threat.category, threat.target
325
- ),
326
- test_cases=self._generate_test_cases(
327
- threat.category, threat.target
328
- )
329
- )
330
- requirements.append(req)
331
-
332
- return requirements
333
-
334
- def _calculate_priority(self, impact: str, likelihood: str) -> Priority:
335
- """Calculate requirement priority from threat attributes."""
336
- score_map = {"LOW": 1, "MEDIUM": 2, "HIGH": 3, "CRITICAL": 4}
337
- impact_score = score_map.get(impact.upper(), 2)
338
- likelihood_score = score_map.get(likelihood.upper(), 2)
339
-
340
- combined = impact_score * likelihood_score
341
-
342
- if combined >= 12:
343
- return Priority.CRITICAL
344
- elif combined >= 6:
345
- return Priority.HIGH
346
- elif combined >= 3:
347
- return Priority.MEDIUM
348
- return Priority.LOW
349
-
350
- def _generate_acceptance_criteria(
351
- self,
352
- category: str,
353
- target: str
354
- ) -> List[str]:
355
- """Generate acceptance criteria for requirement."""
356
- criteria_templates = {
357
- "SPOOFING": [
358
- f"Users must authenticate before accessing {target}",
359
- "Authentication failures are logged and monitored",
360
- "Multi-factor authentication is available for sensitive operations",
361
- ],
362
- "TAMPERING": [
363
- f"All input to {target} is validated",
364
- "Data integrity is verified before processing",
365
- "Modification attempts trigger alerts",
366
- ],
367
- "REPUDIATION": [
368
- f"All actions on {target} are logged with user identity",
369
- "Logs cannot be modified by regular users",
370
- "Log retention meets compliance requirements",
371
- ],
372
- "INFORMATION_DISCLOSURE": [
373
- f"Sensitive data in {target} is encrypted",
374
- "Access to sensitive data is logged",
375
- "Error messages do not reveal sensitive information",
376
- ],
377
- "DENIAL_OF_SERVICE": [
378
- f"Rate limiting is enforced on {target}",
379
- "System degrades gracefully under load",
380
- "Resource exhaustion triggers alerts",
381
- ],
382
- "ELEVATION_OF_PRIVILEGE": [
383
- f"Authorization is checked for all {target} operations",
384
- "Users cannot access resources beyond their permissions",
385
- "Privilege changes are logged and monitored",
386
- ],
387
- }
388
- return criteria_templates.get(category, [])
389
-
390
- def _generate_test_cases(
391
- self,
392
- category: str,
393
- target: str
394
- ) -> List[str]:
395
- """Generate test cases for requirement."""
396
- test_templates = {
397
- "SPOOFING": [
398
- f"Test: Unauthenticated access to {target} is denied",
399
- "Test: Invalid credentials are rejected",
400
- "Test: Session tokens cannot be forged",
401
- ],
402
- "TAMPERING": [
403
- f"Test: Invalid input to {target} is rejected",
404
- "Test: Tampered data is detected and rejected",
405
- "Test: SQL injection attempts are blocked",
406
- ],
407
- "REPUDIATION": [
408
- "Test: Security events are logged",
409
- "Test: Logs include sufficient detail for forensics",
410
- "Test: Log integrity is protected",
411
- ],
412
- "INFORMATION_DISCLOSURE": [
413
- f"Test: {target} data is encrypted in transit",
414
- f"Test: {target} data is encrypted at rest",
415
- "Test: Error messages are sanitized",
416
- ],
417
- "DENIAL_OF_SERVICE": [
418
- f"Test: Rate limiting on {target} works correctly",
419
- "Test: System handles burst traffic gracefully",
420
- "Test: Resource limits are enforced",
421
- ],
422
- "ELEVATION_OF_PRIVILEGE": [
423
- f"Test: Unauthorized access to {target} is denied",
424
- "Test: Privilege escalation attempts are blocked",
425
- "Test: IDOR vulnerabilities are not present",
426
- ],
427
- }
428
- return test_templates.get(category, [])
429
- ```
430
-
431
- ### Template 3: Compliance Mapping
432
-
433
- ```python
434
- from typing import Dict, List, Set
435
-
436
- class ComplianceMapper:
437
- """Map security requirements to compliance frameworks."""
438
-
439
- FRAMEWORK_CONTROLS = {
440
- ComplianceFramework.PCI_DSS: {
441
- SecurityDomain.AUTHENTICATION: ["8.1", "8.2", "8.3"],
442
- SecurityDomain.AUTHORIZATION: ["7.1", "7.2"],
443
- SecurityDomain.DATA_PROTECTION: ["3.4", "3.5", "4.1"],
444
- SecurityDomain.AUDIT_LOGGING: ["10.1", "10.2", "10.3"],
445
- SecurityDomain.NETWORK_SECURITY: ["1.1", "1.2", "1.3"],
446
- SecurityDomain.CRYPTOGRAPHY: ["3.5", "3.6", "4.1"],
447
- },
448
- ComplianceFramework.HIPAA: {
449
- SecurityDomain.AUTHENTICATION: ["164.312(d)"],
450
- SecurityDomain.AUTHORIZATION: ["164.312(a)(1)"],
451
- SecurityDomain.DATA_PROTECTION: ["164.312(a)(2)(iv)", "164.312(e)(2)(ii)"],
452
- SecurityDomain.AUDIT_LOGGING: ["164.312(b)"],
453
- },
454
- ComplianceFramework.GDPR: {
455
- SecurityDomain.DATA_PROTECTION: ["Art. 32", "Art. 25"],
456
- SecurityDomain.AUDIT_LOGGING: ["Art. 30"],
457
- SecurityDomain.AUTHORIZATION: ["Art. 25"],
458
- },
459
- ComplianceFramework.OWASP: {
460
- SecurityDomain.AUTHENTICATION: ["V2.1", "V2.2", "V2.3"],
461
- SecurityDomain.SESSION_MANAGEMENT: ["V3.1", "V3.2", "V3.3"],
462
- SecurityDomain.INPUT_VALIDATION: ["V5.1", "V5.2", "V5.3"],
463
- SecurityDomain.CRYPTOGRAPHY: ["V6.1", "V6.2"],
464
- SecurityDomain.ERROR_HANDLING: ["V7.1", "V7.2"],
465
- SecurityDomain.DATA_PROTECTION: ["V8.1", "V8.2", "V8.3"],
466
- SecurityDomain.AUDIT_LOGGING: ["V7.1", "V7.2"],
467
- },
468
- }
469
-
470
- def map_requirement_to_compliance(
471
- self,
472
- requirement: SecurityRequirement,
473
- frameworks: List[ComplianceFramework]
474
- ) -> Dict[str, List[str]]:
475
- """Map a requirement to compliance controls."""
476
- mapping = {}
477
- for framework in frameworks:
478
- controls = self.FRAMEWORK_CONTROLS.get(framework, {})
479
- domain_controls = controls.get(requirement.domain, [])
480
- if domain_controls:
481
- mapping[framework.value] = domain_controls
482
- return mapping
483
-
484
- def get_requirements_for_control(
485
- self,
486
- requirement_set: RequirementSet,
487
- framework: ComplianceFramework,
488
- control_id: str
489
- ) -> List[SecurityRequirement]:
490
- """Find requirements that satisfy a compliance control."""
491
- matching = []
492
- framework_controls = self.FRAMEWORK_CONTROLS.get(framework, {})
493
-
494
- for domain, controls in framework_controls.items():
495
- if control_id in controls:
496
- matching.extend(requirement_set.get_by_domain(domain))
497
-
498
- return matching
499
-
500
- def generate_compliance_matrix(
501
- self,
502
- requirement_set: RequirementSet,
503
- frameworks: List[ComplianceFramework]
504
- ) -> Dict[str, Dict[str, List[str]]]:
505
- """Generate compliance traceability matrix."""
506
- matrix = {}
507
-
508
- for framework in frameworks:
509
- matrix[framework.value] = {}
510
- framework_controls = self.FRAMEWORK_CONTROLS.get(framework, {})
511
-
512
- for domain, controls in framework_controls.items():
513
- for control in controls:
514
- reqs = self.get_requirements_for_control(
515
- requirement_set, framework, control
516
- )
517
- if reqs:
518
- matrix[framework.value][control] = [r.id for r in reqs]
519
-
520
- return matrix
521
-
522
- def gap_analysis(
523
- self,
524
- requirement_set: RequirementSet,
525
- framework: ComplianceFramework
526
- ) -> Dict[str, List[str]]:
527
- """Identify compliance gaps."""
528
- gaps = {"missing_controls": [], "weak_coverage": []}
529
- framework_controls = self.FRAMEWORK_CONTROLS.get(framework, {})
530
-
531
- for domain, controls in framework_controls.items():
532
- domain_reqs = requirement_set.get_by_domain(domain)
533
- for control in controls:
534
- matching = self.get_requirements_for_control(
535
- requirement_set, framework, control
536
- )
537
- if not matching:
538
- gaps["missing_controls"].append(f"{framework.value}:{control}")
539
- elif len(matching) < 2:
540
- gaps["weak_coverage"].append(f"{framework.value}:{control}")
541
-
542
- return gaps
543
- ```
544
-
545
- ### Template 4: Security User Story Generator
546
-
547
- ```python
548
- class SecurityUserStoryGenerator:
549
- """Generate security-focused user stories."""
550
-
551
- STORY_TEMPLATES = {
552
- SecurityDomain.AUTHENTICATION: {
553
- "as_a": "security-conscious user",
554
- "so_that": "my identity is protected from impersonation",
555
- },
556
- SecurityDomain.AUTHORIZATION: {
557
- "as_a": "system administrator",
558
- "so_that": "users can only access resources appropriate to their role",
559
- },
560
- SecurityDomain.DATA_PROTECTION: {
561
- "as_a": "data owner",
562
- "so_that": "my sensitive information remains confidential",
563
- },
564
- SecurityDomain.AUDIT_LOGGING: {
565
- "as_a": "security analyst",
566
- "so_that": "I can investigate security incidents",
567
- },
568
- SecurityDomain.INPUT_VALIDATION: {
569
- "as_a": "application developer",
570
- "so_that": "the system is protected from malicious input",
571
- },
572
- }
573
-
574
- def generate_story(self, requirement: SecurityRequirement) -> str:
575
- """Generate a user story from requirement."""
576
- template = self.STORY_TEMPLATES.get(
577
- requirement.domain,
578
- {"as_a": "user", "so_that": "the system is secure"}
579
- )
580
-
581
- story = f"""
582
- ## {requirement.id}: {requirement.title}
583
-
584
- **User Story:**
585
- As a {template['as_a']},
586
- I want the system to {requirement.description.lower()},
587
- So that {template['so_that']}.
588
-
589
- **Priority:** {requirement.priority.name}
590
- **Type:** {requirement.req_type.value}
591
- **Domain:** {requirement.domain.value}
592
-
593
- **Acceptance Criteria:**
594
- {self._format_acceptance_criteria(requirement.acceptance_criteria)}
595
-
596
- **Definition of Done:**
597
- - [ ] Implementation complete
598
- - [ ] Security tests pass
599
- - [ ] Code review complete
600
- - [ ] Security review approved
601
- - [ ] Documentation updated
602
-
603
- **Security Test Cases:**
604
- {self._format_test_cases(requirement.test_cases)}
605
-
606
- **Traceability:**
607
- - Threats: {', '.join(requirement.threat_refs) or 'N/A'}
608
- - Compliance: {', '.join(requirement.compliance_refs) or 'N/A'}
609
- """
610
- return story
611
-
612
- def _format_acceptance_criteria(self, criteria: List[str]) -> str:
613
- return "\n".join(f"- [ ] {c}" for c in criteria) if criteria else "- [ ] TBD"
614
-
615
- def _format_test_cases(self, tests: List[str]) -> str:
616
- return "\n".join(f"- {t}" for t in tests) if tests else "- TBD"
617
-
618
- def generate_epic(
619
- self,
620
- requirement_set: RequirementSet,
621
- domain: SecurityDomain
622
- ) -> str:
623
- """Generate an epic for a security domain."""
624
- reqs = requirement_set.get_by_domain(domain)
625
-
626
- epic = f"""
627
- # Security Epic: {domain.value.replace('_', ' ').title()}
628
-
629
- ## Overview
630
- This epic covers all security requirements related to {domain.value.replace('_', ' ')}.
631
-
632
- ## Business Value
633
- - Protect against {domain.value.replace('_', ' ')} related threats
634
- - Meet compliance requirements
635
- - Reduce security risk
636
-
637
- ## Stories in this Epic
638
- {chr(10).join(f'- [{r.id}] {r.title}' for r in reqs)}
639
-
640
- ## Acceptance Criteria
641
- - All stories complete
642
- - Security tests passing
643
- - Security review approved
644
- - Compliance requirements met
645
-
646
- ## Risk if Not Implemented
647
- - Vulnerability to {domain.value.replace('_', ' ')} attacks
648
- - Compliance violations
649
- - Potential data breach
650
-
651
- ## Dependencies
652
- {chr(10).join(f'- {d}' for r in reqs for d in r.dependencies) or '- None identified'}
653
- """
654
- return epic
655
- ```
656
-
657
- ## Best Practices
658
-
659
- ### Do's
660
- - **Trace to threats** - Every requirement should map to threats
661
- - **Be specific** - Vague requirements can't be tested
662
- - **Include acceptance criteria** - Define "done"
663
- - **Consider compliance** - Map to frameworks early
664
- - **Review regularly** - Requirements evolve with threats
665
-
666
- ### Don'ts
667
- - **Don't be generic** - "Be secure" is not a requirement
668
- - **Don't skip rationale** - Explain why it matters
669
- - **Don't ignore priorities** - Not all requirements are equal
670
- - **Don't forget testability** - If you can't test it, you can't verify it
671
- - **Don't work in isolation** - Involve stakeholders
672
-
673
- ## Resources
674
-
675
- - [OWASP ASVS](https://owasp.org/www-project-application-security-verification-standard/)
676
- - [NIST SP 800-53](https://csrc.nist.gov/publications/detail/sp/800-53/rev-5/final)
677
- - [Security User Stories](https://www.oreilly.com/library/view/agile-application-security/9781491938836/)