kiro-agent-team 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/.kiro/README.md +228 -0
  2. package/.kiro/agents/backend-engineer.json +6 -0
  3. package/.kiro/agents/backend-engineer.md +643 -0
  4. package/.kiro/agents/database-specialist.json +6 -0
  5. package/.kiro/agents/database-specialist.md +390 -0
  6. package/.kiro/agents/development-logger.json +6 -0
  7. package/.kiro/agents/development-logger.md +265 -0
  8. package/.kiro/agents/devops-engineer.json +6 -0
  9. package/.kiro/agents/devops-engineer.md +287 -0
  10. package/.kiro/agents/frontend-architect.json +6 -0
  11. package/.kiro/agents/frontend-architect.md +1032 -0
  12. package/.kiro/agents/hooks/backend-engineer-hooks.yaml +540 -0
  13. package/.kiro/agents/hooks/database-specialist-hooks.yaml +488 -0
  14. package/.kiro/agents/hooks/development-logger-hooks.yaml +361 -0
  15. package/.kiro/agents/hooks/devops-engineer-hooks.yaml +345 -0
  16. package/.kiro/agents/hooks/frontend-architect-hooks.yaml +521 -0
  17. package/.kiro/agents/hooks/project-manager-hooks.yaml +513 -0
  18. package/.kiro/agents/hooks/security-specialist-hooks.yaml +358 -0
  19. package/.kiro/agents/hooks/test-orchestrator-hooks.yaml +380 -0
  20. package/.kiro/agents/hooks/ui-ux-designer-hooks.yaml +353 -0
  21. package/.kiro/agents/project-manager.json +6 -0
  22. package/.kiro/agents/project-manager.md +344 -0
  23. package/.kiro/agents/prompts/backend-engineer-system.md +815 -0
  24. package/.kiro/agents/prompts/database-specialist-system.md +332 -0
  25. package/.kiro/agents/prompts/development-logger-system.md +232 -0
  26. package/.kiro/agents/prompts/devops-engineer-system.md +260 -0
  27. package/.kiro/agents/prompts/frontend-architect-system.md +305 -0
  28. package/.kiro/agents/prompts/project-manager-system.md +285 -0
  29. package/.kiro/agents/prompts/security-specialist-system.md +231 -0
  30. package/.kiro/agents/prompts/test-orchestrator-system.md +214 -0
  31. package/.kiro/agents/prompts/ui-ux-designer-system.md +270 -0
  32. package/.kiro/agents/security-specialist.json +6 -0
  33. package/.kiro/agents/security-specialist.md +277 -0
  34. package/.kiro/agents/test-orchestrator.json +6 -0
  35. package/.kiro/agents/test-orchestrator.md +266 -0
  36. package/.kiro/agents/ui-ux-designer.json +6 -0
  37. package/.kiro/agents/ui-ux-designer.md +284 -0
  38. package/.kiro/devlog/00-START-HERE.md +444 -0
  39. package/.kiro/devlog/COMPLETE-WORKFLOW.md +553 -0
  40. package/.kiro/devlog/DEVLOG-INTEGRATION.md +413 -0
  41. package/.kiro/devlog/DEVLOG-PROCESS-FLOWS.md +484 -0
  42. package/.kiro/devlog/DEVLOG-QUICK-REF.md +299 -0
  43. package/.kiro/devlog/DEVLOG.md +22 -0
  44. package/.kiro/devlog/IMPLEMENTATION-COMPLETE.txt +434 -0
  45. package/.kiro/devlog/IMPLEMENTATION-SUMMARY.md +358 -0
  46. package/.kiro/devlog/README.md +363 -0
  47. package/.kiro/devlog/devlog-update.bat +136 -0
  48. package/.kiro/devlog/devlog-update.sh +275 -0
  49. package/.kiro/devlog/feature-completion-hook.bat +78 -0
  50. package/.kiro/devlog/feature-completion-hook.sh +84 -0
  51. package/.kiro/documentation/cli.md +31 -0
  52. package/.kiro/documentation/docs_cli.md +41 -0
  53. package/.kiro/documentation/docs_cli_authentication.md +43 -0
  54. package/.kiro/documentation/docs_cli_autocomplete.md +132 -0
  55. package/.kiro/documentation/docs_cli_billing.md +31 -0
  56. package/.kiro/documentation/docs_cli_billing_contact-support.md +43 -0
  57. package/.kiro/documentation/docs_cli_billing_managing-taxes.md +67 -0
  58. package/.kiro/documentation/docs_cli_billing_related-questions.md +49 -0
  59. package/.kiro/documentation/docs_cli_billing_subscription-portal.md +31 -0
  60. package/.kiro/documentation/docs_cli_chat.md +84 -0
  61. package/.kiro/documentation/docs_cli_chat_configuration.md +40 -0
  62. package/.kiro/documentation/docs_cli_chat_context.md +258 -0
  63. package/.kiro/documentation/docs_cli_chat_git-aware-selection.md +41 -0
  64. package/.kiro/documentation/docs_cli_chat_images.md +53 -0
  65. package/.kiro/documentation/docs_cli_chat_manage-prompts.md +216 -0
  66. package/.kiro/documentation/docs_cli_chat_model-selection.md +153 -0
  67. package/.kiro/documentation/docs_cli_chat_permissions.md +68 -0
  68. package/.kiro/documentation/docs_cli_chat_planning-agent.md +230 -0
  69. package/.kiro/documentation/docs_cli_chat_responding.md +123 -0
  70. package/.kiro/documentation/docs_cli_chat_security.md +87 -0
  71. package/.kiro/documentation/docs_cli_chat_subagents.md +77 -0
  72. package/.kiro/documentation/docs_cli_code-intelligence.md +251 -0
  73. package/.kiro/documentation/docs_cli_custom-agents.md +37 -0
  74. package/.kiro/documentation/docs_cli_custom-agents_configuration-reference.md +941 -0
  75. package/.kiro/documentation/docs_cli_custom-agents_creating.md +93 -0
  76. package/.kiro/documentation/docs_cli_custom-agents_examples.md +360 -0
  77. package/.kiro/documentation/docs_cli_custom-agents_troubleshooting.md +180 -0
  78. package/.kiro/documentation/docs_cli_enterprise_billing.md +33 -0
  79. package/.kiro/documentation/docs_cli_enterprise_concepts.md +34 -0
  80. package/.kiro/documentation/docs_cli_enterprise_getting-started.md +19 -0
  81. package/.kiro/documentation/docs_cli_enterprise_iam.md +251 -0
  82. package/.kiro/documentation/docs_cli_enterprise_monitor-and-track.md +15 -0
  83. package/.kiro/documentation/docs_cli_enterprise_monitor-and-track_dashboard.md +62 -0
  84. package/.kiro/documentation/docs_cli_enterprise_monitor-and-track_prompt-logging.md +165 -0
  85. package/.kiro/documentation/docs_cli_enterprise_monitor-and-track_user-activity.md +123 -0
  86. package/.kiro/documentation/docs_cli_enterprise_settings.md +15 -0
  87. package/.kiro/documentation/docs_cli_enterprise_subscribe.md +36 -0
  88. package/.kiro/documentation/docs_cli_enterprise_subscription-management.md +55 -0
  89. package/.kiro/documentation/docs_cli_enterprise_supported-regions.md +39 -0
  90. package/.kiro/documentation/docs_cli_experimental.md +282 -0
  91. package/.kiro/documentation/docs_cli_experimental_checkpointing.md +439 -0
  92. package/.kiro/documentation/docs_cli_experimental_delegate.md +422 -0
  93. package/.kiro/documentation/docs_cli_experimental_knowledge-management.md +449 -0
  94. package/.kiro/documentation/docs_cli_experimental_tangent-mode.md +357 -0
  95. package/.kiro/documentation/docs_cli_experimental_thinking.md +331 -0
  96. package/.kiro/documentation/docs_cli_experimental_todo-lists.md +385 -0
  97. package/.kiro/documentation/docs_cli_hooks.md +207 -0
  98. package/.kiro/documentation/docs_cli_installation.md +235 -0
  99. package/.kiro/documentation/docs_cli_mcp.md +106 -0
  100. package/.kiro/documentation/docs_cli_mcp_configuration.md +294 -0
  101. package/.kiro/documentation/docs_cli_mcp_examples.md +273 -0
  102. package/.kiro/documentation/docs_cli_mcp_governance.md +436 -0
  103. package/.kiro/documentation/docs_cli_mcp_security.md +77 -0
  104. package/.kiro/documentation/docs_cli_migrating-from-q.md +129 -0
  105. package/.kiro/documentation/docs_cli_privacy-and-security.md +83 -0
  106. package/.kiro/documentation/docs_cli_privacy-and-security_compliance-validation.md +17 -0
  107. package/.kiro/documentation/docs_cli_privacy-and-security_data-protection.md +104 -0
  108. package/.kiro/documentation/docs_cli_privacy-and-security_firewalls.md +26 -0
  109. package/.kiro/documentation/docs_cli_privacy-and-security_infrastructure-security.md +10 -0
  110. package/.kiro/documentation/docs_cli_privacy-and-security_vpc-endpoints.md +41 -0
  111. package/.kiro/documentation/docs_cli_reference_built-in-tools.md +624 -0
  112. package/.kiro/documentation/docs_cli_reference_cli-commands.md +689 -0
  113. package/.kiro/documentation/docs_cli_reference_settings.md +294 -0
  114. package/.kiro/documentation/docs_cli_reference_slash-commands.md +559 -0
  115. package/.kiro/documentation/docs_cli_steering.md +84 -0
  116. package/.kiro/guides/AGENT_WORKFLOW_GUIDE.md +294 -0
  117. package/.kiro/guides/DEVLOG.md +882 -0
  118. package/.kiro/guides/IMPLEMENTATION_EXAMPLES.md +611 -0
  119. package/.kiro/guides/PIV Loop.md +122 -0
  120. package/.kiro/guides/PIV Loop.png +0 -0
  121. package/.kiro/guides/PIVLoop.png +0 -0
  122. package/.kiro/guides/QUICK_REFERENCE.md +202 -0
  123. package/.kiro/guides/README.md +149 -0
  124. package/.kiro/guides/advanced-patterns.md +514 -0
  125. package/.kiro/guides/agent-coordination.md +434 -0
  126. package/.kiro/guides/core-workflows.md +409 -0
  127. package/.kiro/guides/emergency-procedures.md +414 -0
  128. package/.kiro/guides/project-evaluation.md +534 -0
  129. package/.kiro/guides/quality-assurance.md +431 -0
  130. package/.kiro/guides/quick-start.md +235 -0
  131. package/.kiro/guides/troubleshooting.md +575 -0
  132. package/.kiro/guides/walkthroughs.md +711 -0
  133. package/.kiro/prompts/add-to-devlog.md +263 -0
  134. package/.kiro/prompts/code-review-fix.md +18 -0
  135. package/.kiro/prompts/code-review-hackathon.md +167 -0
  136. package/.kiro/prompts/code-review-security.md +454 -0
  137. package/.kiro/prompts/code-review.md +113 -0
  138. package/.kiro/prompts/create-prd.md +151 -0
  139. package/.kiro/prompts/execute-backend.md +257 -0
  140. package/.kiro/prompts/execute-frontend.md +438 -0
  141. package/.kiro/prompts/execute-logging.md +491 -0
  142. package/.kiro/prompts/execute-security.md +482 -0
  143. package/.kiro/prompts/execute-testing.md +528 -0
  144. package/.kiro/prompts/execute.md +101 -0
  145. package/.kiro/prompts/execution-report.md +72 -0
  146. package/.kiro/prompts/implement-fix.md +228 -0
  147. package/.kiro/prompts/plan-feature.md +433 -0
  148. package/.kiro/prompts/prime.md +73 -0
  149. package/.kiro/prompts/quality-metrics.md +622 -0
  150. package/.kiro/prompts/quickstart.md +318 -0
  151. package/.kiro/prompts/rca.md +220 -0
  152. package/.kiro/prompts/system-review.md +189 -0
  153. package/README.md +32 -0
  154. package/bin/cli.js +97 -0
  155. package/package.json +33 -0
@@ -0,0 +1,482 @@
1
+ # Execute: Security Implementation
2
+
3
+ ## Security-Specific Implementation Framework
4
+
5
+ This specialized execution framework is optimized for security-focused development tasks, emphasizing threat mitigation, vulnerability prevention, and compliance implementation.
6
+
7
+ ## Security Implementation Process
8
+
9
+ ### Phase 1: Security Requirements Analysis
10
+ **Security-Specific Analysis:**
11
+ - Threat modeling and attack surface analysis
12
+ - Compliance requirements and regulatory standards
13
+ - Data classification and protection requirements
14
+ - Authentication and authorization needs
15
+ - Security control requirements and risk tolerance
16
+ - Incident response and monitoring requirements
17
+
18
+ **Questions to Address:**
19
+ - What are the primary security threats and risks?
20
+ - What compliance standards must be met?
21
+ - What data needs protection and at what level?
22
+ - What authentication and authorization patterns are required?
23
+ - What security controls need to be implemented?
24
+ - What monitoring and incident response capabilities are needed?
25
+
26
+ ### Phase 2: Security Architecture Design
27
+ **Security Architecture Planning:**
28
+ - Defense-in-depth security strategy
29
+ - Authentication and authorization architecture
30
+ - Data protection and encryption strategies
31
+ - Network security and access control design
32
+ - Monitoring and incident response architecture
33
+ - Security testing and validation approach
34
+
35
+ **Security Design Decisions:**
36
+ - Choose appropriate authentication mechanisms
37
+ - Define authorization patterns and access controls
38
+ - Plan data encryption and key management
39
+ - Design security monitoring and alerting
40
+ - Establish incident response procedures
41
+
42
+ ### Phase 3: Implementation
43
+ **Systematic Security Implementation:**
44
+
45
+ #### Authentication Implementation
46
+ ```typescript
47
+ // JWT-based authentication with refresh tokens
48
+ import jwt from 'jsonwebtoken';
49
+ import bcrypt from 'bcrypt';
50
+
51
+ export class AuthService {
52
+ private readonly JWT_SECRET = process.env.JWT_SECRET!;
53
+ private readonly REFRESH_SECRET = process.env.REFRESH_SECRET!;
54
+ private readonly ACCESS_TOKEN_EXPIRY = '15m';
55
+ private readonly REFRESH_TOKEN_EXPIRY = '7d';
56
+
57
+ async authenticateUser(email: string, password: string): Promise<AuthResult> {
58
+ // Rate limiting check
59
+ await this.checkRateLimit(email);
60
+
61
+ // Find user with secure query
62
+ const user = await this.userRepository.findByEmail(email);
63
+ if (!user) {
64
+ // Prevent user enumeration
65
+ await this.simulatePasswordCheck();
66
+ throw new AuthenticationError('Invalid credentials');
67
+ }
68
+
69
+ // Verify password with timing-safe comparison
70
+ const isValidPassword = await bcrypt.compare(password, user.passwordHash);
71
+ if (!isValidPassword) {
72
+ await this.logFailedAttempt(email);
73
+ throw new AuthenticationError('Invalid credentials');
74
+ }
75
+
76
+ // Generate secure tokens
77
+ const accessToken = this.generateAccessToken(user);
78
+ const refreshToken = this.generateRefreshToken(user);
79
+
80
+ // Store refresh token securely
81
+ await this.storeRefreshToken(user.id, refreshToken);
82
+
83
+ return {
84
+ accessToken,
85
+ refreshToken,
86
+ user: this.sanitizeUser(user)
87
+ };
88
+ }
89
+
90
+ private generateAccessToken(user: User): string {
91
+ return jwt.sign(
92
+ {
93
+ userId: user.id,
94
+ email: user.email,
95
+ role: user.role,
96
+ permissions: user.permissions
97
+ },
98
+ this.JWT_SECRET,
99
+ {
100
+ expiresIn: this.ACCESS_TOKEN_EXPIRY,
101
+ issuer: 'taskflow-api',
102
+ audience: 'taskflow-client'
103
+ }
104
+ );
105
+ }
106
+ }
107
+ ```
108
+
109
+ #### Authorization Implementation
110
+ ```typescript
111
+ // Role-based access control middleware
112
+ export const authorize = (requiredPermissions: string[]) => {
113
+ return async (req: AuthenticatedRequest, res: Response, next: NextFunction) => {
114
+ try {
115
+ const user = req.user;
116
+
117
+ // Check if user has required permissions
118
+ const hasPermission = requiredPermissions.every(permission =>
119
+ user.permissions.includes(permission) || user.role === 'admin'
120
+ );
121
+
122
+ if (!hasPermission) {
123
+ return res.status(403).json({
124
+ error: 'Insufficient permissions',
125
+ required: requiredPermissions,
126
+ message: 'Access denied'
127
+ });
128
+ }
129
+
130
+ next();
131
+ } catch (error) {
132
+ res.status(401).json({ error: 'Authorization failed' });
133
+ }
134
+ };
135
+ };
136
+
137
+ // Usage in routes
138
+ router.get('/admin/users',
139
+ authenticate,
140
+ authorize(['user:read', 'admin:access']),
141
+ getUsersController
142
+ );
143
+ ```
144
+
145
+ #### Input Validation and Sanitization
146
+ ```typescript
147
+ // Comprehensive input validation
148
+ import { z } from 'zod';
149
+ import DOMPurify from 'isomorphic-dompurify';
150
+
151
+ // SQL injection prevention with parameterized queries
152
+ export class SecureUserRepository {
153
+ async findUsersByRole(role: string): Promise<User[]> {
154
+ // Use parameterized query to prevent SQL injection
155
+ return await this.db.query(
156
+ 'SELECT id, email, name, role FROM users WHERE role = $1 AND deleted_at IS NULL',
157
+ [role]
158
+ );
159
+ }
160
+
161
+ async updateUser(id: string, updates: Partial<User>): Promise<User> {
162
+ // Validate and sanitize input
163
+ const sanitizedUpdates = this.sanitizeUserInput(updates);
164
+
165
+ // Use transaction for data integrity
166
+ return await this.db.transaction(async (tx) => {
167
+ const user = await tx.user.update({
168
+ where: { id },
169
+ data: sanitizedUpdates
170
+ });
171
+
172
+ // Log security-relevant changes
173
+ await this.auditLog.logUserUpdate(id, sanitizedUpdates);
174
+
175
+ return user;
176
+ });
177
+ }
178
+
179
+ private sanitizeUserInput(input: Partial<User>): Partial<User> {
180
+ const sanitized: Partial<User> = {};
181
+
182
+ if (input.name) {
183
+ sanitized.name = DOMPurify.sanitize(input.name.trim());
184
+ }
185
+
186
+ if (input.email) {
187
+ sanitized.email = input.email.toLowerCase().trim();
188
+ }
189
+
190
+ // Never allow direct role updates through user input
191
+ // Role changes should go through separate admin endpoints
192
+
193
+ return sanitized;
194
+ }
195
+ }
196
+ ```
197
+
198
+ #### Data Encryption Implementation
199
+ ```typescript
200
+ // Data encryption and key management
201
+ import crypto from 'crypto';
202
+
203
+ export class EncryptionService {
204
+ private readonly ALGORITHM = 'aes-256-gcm';
205
+ private readonly KEY_LENGTH = 32;
206
+ private readonly IV_LENGTH = 16;
207
+ private readonly TAG_LENGTH = 16;
208
+
209
+ async encryptSensitiveData(data: string): Promise<EncryptedData> {
210
+ const key = await this.getEncryptionKey();
211
+ const iv = crypto.randomBytes(this.IV_LENGTH);
212
+
213
+ const cipher = crypto.createCipher(this.ALGORITHM, key);
214
+ cipher.setAAD(Buffer.from('taskflow-data'));
215
+
216
+ let encrypted = cipher.update(data, 'utf8', 'hex');
217
+ encrypted += cipher.final('hex');
218
+
219
+ const tag = cipher.getAuthTag();
220
+
221
+ return {
222
+ encrypted,
223
+ iv: iv.toString('hex'),
224
+ tag: tag.toString('hex')
225
+ };
226
+ }
227
+
228
+ async decryptSensitiveData(encryptedData: EncryptedData): Promise<string> {
229
+ const key = await this.getEncryptionKey();
230
+ const iv = Buffer.from(encryptedData.iv, 'hex');
231
+ const tag = Buffer.from(encryptedData.tag, 'hex');
232
+
233
+ const decipher = crypto.createDecipher(this.ALGORITHM, key);
234
+ decipher.setAAD(Buffer.from('taskflow-data'));
235
+ decipher.setAuthTag(tag);
236
+
237
+ let decrypted = decipher.update(encryptedData.encrypted, 'hex', 'utf8');
238
+ decrypted += decipher.final('utf8');
239
+
240
+ return decrypted;
241
+ }
242
+
243
+ private async getEncryptionKey(): Promise<Buffer> {
244
+ // In production, use proper key management service
245
+ const keyString = process.env.ENCRYPTION_KEY;
246
+ if (!keyString) {
247
+ throw new Error('Encryption key not configured');
248
+ }
249
+
250
+ return crypto.scryptSync(keyString, 'salt', this.KEY_LENGTH);
251
+ }
252
+ }
253
+ ```
254
+
255
+ ### Phase 4: Security Controls Implementation
256
+ **Security Control Measures:**
257
+ - Rate limiting and DDoS protection
258
+ - Security headers and CORS configuration
259
+ - Content Security Policy implementation
260
+ - Session management and token security
261
+ - Audit logging and monitoring
262
+ - Error handling without information disclosure
263
+
264
+ **Security Controls Implementation:**
265
+ ```typescript
266
+ // Rate limiting implementation
267
+ import rateLimit from 'express-rate-limit';
268
+
269
+ export const createRateLimit = (options: RateLimitOptions) => {
270
+ return rateLimit({
271
+ windowMs: options.windowMs,
272
+ max: options.max,
273
+ message: {
274
+ error: 'Too many requests',
275
+ retryAfter: Math.ceil(options.windowMs / 1000)
276
+ },
277
+ standardHeaders: true,
278
+ legacyHeaders: false,
279
+ handler: (req, res) => {
280
+ // Log rate limit violations
281
+ logger.warn('Rate limit exceeded', {
282
+ ip: req.ip,
283
+ userAgent: req.get('User-Agent'),
284
+ endpoint: req.path
285
+ });
286
+
287
+ res.status(429).json({
288
+ error: 'Rate limit exceeded',
289
+ retryAfter: Math.ceil(options.windowMs / 1000)
290
+ });
291
+ }
292
+ });
293
+ };
294
+
295
+ // Security headers middleware
296
+ export const securityHeaders = (req: Request, res: Response, next: NextFunction) => {
297
+ // Prevent clickjacking
298
+ res.setHeader('X-Frame-Options', 'DENY');
299
+
300
+ // Prevent MIME type sniffing
301
+ res.setHeader('X-Content-Type-Options', 'nosniff');
302
+
303
+ // XSS protection
304
+ res.setHeader('X-XSS-Protection', '1; mode=block');
305
+
306
+ // Strict transport security
307
+ res.setHeader('Strict-Transport-Security', 'max-age=31536000; includeSubDomains');
308
+
309
+ // Content Security Policy
310
+ res.setHeader('Content-Security-Policy',
311
+ "default-src 'self'; " +
312
+ "script-src 'self' 'unsafe-inline'; " +
313
+ "style-src 'self' 'unsafe-inline'; " +
314
+ "img-src 'self' data: https:; " +
315
+ "connect-src 'self'; " +
316
+ "font-src 'self'; " +
317
+ "object-src 'none'; " +
318
+ "media-src 'self'; " +
319
+ "frame-src 'none';"
320
+ );
321
+
322
+ next();
323
+ };
324
+ ```
325
+
326
+ ### Phase 5: Security Testing Implementation
327
+ **Security Testing Strategy:**
328
+ - Static Application Security Testing (SAST)
329
+ - Dynamic Application Security Testing (DAST)
330
+ - Dependency vulnerability scanning
331
+ - Penetration testing for critical paths
332
+ - Security code review and threat modeling
333
+ - Compliance validation testing
334
+
335
+ **Security Testing Examples:**
336
+ ```typescript
337
+ // Security-focused unit tests
338
+ describe('Authentication Security', () => {
339
+ it('should prevent timing attacks on login', async () => {
340
+ const startTime = Date.now();
341
+
342
+ try {
343
+ await authService.authenticateUser('nonexistent@example.com', 'password');
344
+ } catch (error) {
345
+ // Should take similar time as valid user check
346
+ }
347
+
348
+ const endTime = Date.now();
349
+ const duration = endTime - startTime;
350
+
351
+ // Should take at least minimum time to prevent timing attacks
352
+ expect(duration).toBeGreaterThan(100);
353
+ });
354
+
355
+ it('should rate limit failed login attempts', async () => {
356
+ const email = 'test@example.com';
357
+
358
+ // Attempt multiple failed logins
359
+ for (let i = 0; i < 5; i++) {
360
+ try {
361
+ await authService.authenticateUser(email, 'wrongpassword');
362
+ } catch (error) {
363
+ // Expected to fail
364
+ }
365
+ }
366
+
367
+ // Next attempt should be rate limited
368
+ await expect(
369
+ authService.authenticateUser(email, 'wrongpassword')
370
+ ).rejects.toThrow('Rate limit exceeded');
371
+ });
372
+ });
373
+
374
+ // SQL injection prevention test
375
+ describe('SQL Injection Prevention', () => {
376
+ it('should prevent SQL injection in user queries', async () => {
377
+ const maliciousInput = "'; DROP TABLE users; --";
378
+
379
+ // Should not execute malicious SQL
380
+ const result = await userRepository.findUsersByRole(maliciousInput);
381
+
382
+ // Should return empty array, not crash or execute malicious SQL
383
+ expect(result).toEqual([]);
384
+
385
+ // Verify users table still exists
386
+ const userCount = await userRepository.count();
387
+ expect(userCount).toBeGreaterThan(0);
388
+ });
389
+ });
390
+ ```
391
+
392
+ ### Phase 6: Monitoring and Incident Response
393
+ **Security Monitoring Implementation:**
394
+ - Security event logging and correlation
395
+ - Anomaly detection and alerting
396
+ - Incident response automation
397
+ - Forensic data collection and preservation
398
+ - Security metrics and reporting
399
+ - Threat intelligence integration
400
+
401
+ ### Phase 7: Compliance Documentation
402
+ **Security Documentation Requirements:**
403
+ - Security architecture documentation
404
+ - Threat model and risk assessment
405
+ - Security control implementation guide
406
+ - Incident response procedures
407
+ - Compliance mapping and evidence
408
+ - Security training and awareness materials
409
+
410
+ ## Security-Specific Validation Checklist
411
+
412
+ ### Authentication Security Validation
413
+ - [ ] Password policies enforce strong passwords
414
+ - [ ] Multi-factor authentication implemented where required
415
+ - [ ] Session management prevents session fixation
416
+ - [ ] Token security prevents token theft and replay
417
+ - [ ] Account lockout prevents brute force attacks
418
+ - [ ] Password reset process is secure
419
+
420
+ ### Authorization Security Validation
421
+ - [ ] Role-based access control properly implemented
422
+ - [ ] Principle of least privilege enforced
423
+ - [ ] Authorization checks on all protected resources
424
+ - [ ] Privilege escalation prevented
425
+ - [ ] Cross-user data access prevented
426
+ - [ ] Admin functions properly protected
427
+
428
+ ### Data Protection Validation
429
+ - [ ] Sensitive data encrypted at rest and in transit
430
+ - [ ] Encryption keys properly managed
431
+ - [ ] Data classification implemented
432
+ - [ ] Data retention policies enforced
433
+ - [ ] Data deletion is secure and complete
434
+ - [ ] Personal data handling complies with regulations
435
+
436
+ ### Input Validation Security
437
+ - [ ] All inputs validated and sanitized
438
+ - [ ] SQL injection prevention implemented
439
+ - [ ] Cross-site scripting (XSS) prevention implemented
440
+ - [ ] Command injection prevention implemented
441
+ - [ ] File upload security implemented
442
+ - [ ] API input validation comprehensive
443
+
444
+ ### Infrastructure Security Validation
445
+ - [ ] Security headers properly configured
446
+ - [ ] HTTPS enforced for all communications
447
+ - [ ] CORS properly configured
448
+ - [ ] Rate limiting prevents abuse
449
+ - [ ] Error handling doesn't leak information
450
+ - [ ] Logging captures security events
451
+
452
+ ## Security Implementation Success Criteria
453
+
454
+ ### Threat Mitigation
455
+ - All identified threats have appropriate controls
456
+ - Security controls are properly implemented and tested
457
+ - Defense-in-depth strategy is effective
458
+ - Attack surface is minimized
459
+ - Incident response procedures are tested
460
+
461
+ ### Compliance Achievement
462
+ - All regulatory requirements are met
463
+ - Compliance evidence is documented
464
+ - Audit trails are comprehensive
465
+ - Privacy requirements are satisfied
466
+ - Security policies are enforced
467
+
468
+ ### Security Monitoring
469
+ - Security events are properly logged
470
+ - Anomalies are detected and alerted
471
+ - Incident response is automated where possible
472
+ - Security metrics are tracked and reported
473
+ - Threat intelligence is integrated
474
+
475
+ ### Continuous Improvement
476
+ - Security testing is automated
477
+ - Vulnerability management is systematic
478
+ - Security training is provided
479
+ - Security reviews are regular
480
+ - Lessons learned are incorporated
481
+
482
+ This security-specific execution framework ensures systematic, comprehensive security implementation with thorough validation and continuous monitoring.