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.
- package/.kiro/README.md +228 -0
- package/.kiro/agents/backend-engineer.json +6 -0
- package/.kiro/agents/backend-engineer.md +643 -0
- package/.kiro/agents/database-specialist.json +6 -0
- package/.kiro/agents/database-specialist.md +390 -0
- package/.kiro/agents/development-logger.json +6 -0
- package/.kiro/agents/development-logger.md +265 -0
- package/.kiro/agents/devops-engineer.json +6 -0
- package/.kiro/agents/devops-engineer.md +287 -0
- package/.kiro/agents/frontend-architect.json +6 -0
- package/.kiro/agents/frontend-architect.md +1032 -0
- package/.kiro/agents/hooks/backend-engineer-hooks.yaml +540 -0
- package/.kiro/agents/hooks/database-specialist-hooks.yaml +488 -0
- package/.kiro/agents/hooks/development-logger-hooks.yaml +361 -0
- package/.kiro/agents/hooks/devops-engineer-hooks.yaml +345 -0
- package/.kiro/agents/hooks/frontend-architect-hooks.yaml +521 -0
- package/.kiro/agents/hooks/project-manager-hooks.yaml +513 -0
- package/.kiro/agents/hooks/security-specialist-hooks.yaml +358 -0
- package/.kiro/agents/hooks/test-orchestrator-hooks.yaml +380 -0
- package/.kiro/agents/hooks/ui-ux-designer-hooks.yaml +353 -0
- package/.kiro/agents/project-manager.json +6 -0
- package/.kiro/agents/project-manager.md +344 -0
- package/.kiro/agents/prompts/backend-engineer-system.md +815 -0
- package/.kiro/agents/prompts/database-specialist-system.md +332 -0
- package/.kiro/agents/prompts/development-logger-system.md +232 -0
- package/.kiro/agents/prompts/devops-engineer-system.md +260 -0
- package/.kiro/agents/prompts/frontend-architect-system.md +305 -0
- package/.kiro/agents/prompts/project-manager-system.md +285 -0
- package/.kiro/agents/prompts/security-specialist-system.md +231 -0
- package/.kiro/agents/prompts/test-orchestrator-system.md +214 -0
- package/.kiro/agents/prompts/ui-ux-designer-system.md +270 -0
- package/.kiro/agents/security-specialist.json +6 -0
- package/.kiro/agents/security-specialist.md +277 -0
- package/.kiro/agents/test-orchestrator.json +6 -0
- package/.kiro/agents/test-orchestrator.md +266 -0
- package/.kiro/agents/ui-ux-designer.json +6 -0
- package/.kiro/agents/ui-ux-designer.md +284 -0
- package/.kiro/devlog/00-START-HERE.md +444 -0
- package/.kiro/devlog/COMPLETE-WORKFLOW.md +553 -0
- package/.kiro/devlog/DEVLOG-INTEGRATION.md +413 -0
- package/.kiro/devlog/DEVLOG-PROCESS-FLOWS.md +484 -0
- package/.kiro/devlog/DEVLOG-QUICK-REF.md +299 -0
- package/.kiro/devlog/DEVLOG.md +22 -0
- package/.kiro/devlog/IMPLEMENTATION-COMPLETE.txt +434 -0
- package/.kiro/devlog/IMPLEMENTATION-SUMMARY.md +358 -0
- package/.kiro/devlog/README.md +363 -0
- package/.kiro/devlog/devlog-update.bat +136 -0
- package/.kiro/devlog/devlog-update.sh +275 -0
- package/.kiro/devlog/feature-completion-hook.bat +78 -0
- package/.kiro/devlog/feature-completion-hook.sh +84 -0
- package/.kiro/documentation/cli.md +31 -0
- package/.kiro/documentation/docs_cli.md +41 -0
- package/.kiro/documentation/docs_cli_authentication.md +43 -0
- package/.kiro/documentation/docs_cli_autocomplete.md +132 -0
- package/.kiro/documentation/docs_cli_billing.md +31 -0
- package/.kiro/documentation/docs_cli_billing_contact-support.md +43 -0
- package/.kiro/documentation/docs_cli_billing_managing-taxes.md +67 -0
- package/.kiro/documentation/docs_cli_billing_related-questions.md +49 -0
- package/.kiro/documentation/docs_cli_billing_subscription-portal.md +31 -0
- package/.kiro/documentation/docs_cli_chat.md +84 -0
- package/.kiro/documentation/docs_cli_chat_configuration.md +40 -0
- package/.kiro/documentation/docs_cli_chat_context.md +258 -0
- package/.kiro/documentation/docs_cli_chat_git-aware-selection.md +41 -0
- package/.kiro/documentation/docs_cli_chat_images.md +53 -0
- package/.kiro/documentation/docs_cli_chat_manage-prompts.md +216 -0
- package/.kiro/documentation/docs_cli_chat_model-selection.md +153 -0
- package/.kiro/documentation/docs_cli_chat_permissions.md +68 -0
- package/.kiro/documentation/docs_cli_chat_planning-agent.md +230 -0
- package/.kiro/documentation/docs_cli_chat_responding.md +123 -0
- package/.kiro/documentation/docs_cli_chat_security.md +87 -0
- package/.kiro/documentation/docs_cli_chat_subagents.md +77 -0
- package/.kiro/documentation/docs_cli_code-intelligence.md +251 -0
- package/.kiro/documentation/docs_cli_custom-agents.md +37 -0
- package/.kiro/documentation/docs_cli_custom-agents_configuration-reference.md +941 -0
- package/.kiro/documentation/docs_cli_custom-agents_creating.md +93 -0
- package/.kiro/documentation/docs_cli_custom-agents_examples.md +360 -0
- package/.kiro/documentation/docs_cli_custom-agents_troubleshooting.md +180 -0
- package/.kiro/documentation/docs_cli_enterprise_billing.md +33 -0
- package/.kiro/documentation/docs_cli_enterprise_concepts.md +34 -0
- package/.kiro/documentation/docs_cli_enterprise_getting-started.md +19 -0
- package/.kiro/documentation/docs_cli_enterprise_iam.md +251 -0
- package/.kiro/documentation/docs_cli_enterprise_monitor-and-track.md +15 -0
- package/.kiro/documentation/docs_cli_enterprise_monitor-and-track_dashboard.md +62 -0
- package/.kiro/documentation/docs_cli_enterprise_monitor-and-track_prompt-logging.md +165 -0
- package/.kiro/documentation/docs_cli_enterprise_monitor-and-track_user-activity.md +123 -0
- package/.kiro/documentation/docs_cli_enterprise_settings.md +15 -0
- package/.kiro/documentation/docs_cli_enterprise_subscribe.md +36 -0
- package/.kiro/documentation/docs_cli_enterprise_subscription-management.md +55 -0
- package/.kiro/documentation/docs_cli_enterprise_supported-regions.md +39 -0
- package/.kiro/documentation/docs_cli_experimental.md +282 -0
- package/.kiro/documentation/docs_cli_experimental_checkpointing.md +439 -0
- package/.kiro/documentation/docs_cli_experimental_delegate.md +422 -0
- package/.kiro/documentation/docs_cli_experimental_knowledge-management.md +449 -0
- package/.kiro/documentation/docs_cli_experimental_tangent-mode.md +357 -0
- package/.kiro/documentation/docs_cli_experimental_thinking.md +331 -0
- package/.kiro/documentation/docs_cli_experimental_todo-lists.md +385 -0
- package/.kiro/documentation/docs_cli_hooks.md +207 -0
- package/.kiro/documentation/docs_cli_installation.md +235 -0
- package/.kiro/documentation/docs_cli_mcp.md +106 -0
- package/.kiro/documentation/docs_cli_mcp_configuration.md +294 -0
- package/.kiro/documentation/docs_cli_mcp_examples.md +273 -0
- package/.kiro/documentation/docs_cli_mcp_governance.md +436 -0
- package/.kiro/documentation/docs_cli_mcp_security.md +77 -0
- package/.kiro/documentation/docs_cli_migrating-from-q.md +129 -0
- package/.kiro/documentation/docs_cli_privacy-and-security.md +83 -0
- package/.kiro/documentation/docs_cli_privacy-and-security_compliance-validation.md +17 -0
- package/.kiro/documentation/docs_cli_privacy-and-security_data-protection.md +104 -0
- package/.kiro/documentation/docs_cli_privacy-and-security_firewalls.md +26 -0
- package/.kiro/documentation/docs_cli_privacy-and-security_infrastructure-security.md +10 -0
- package/.kiro/documentation/docs_cli_privacy-and-security_vpc-endpoints.md +41 -0
- package/.kiro/documentation/docs_cli_reference_built-in-tools.md +624 -0
- package/.kiro/documentation/docs_cli_reference_cli-commands.md +689 -0
- package/.kiro/documentation/docs_cli_reference_settings.md +294 -0
- package/.kiro/documentation/docs_cli_reference_slash-commands.md +559 -0
- package/.kiro/documentation/docs_cli_steering.md +84 -0
- package/.kiro/guides/AGENT_WORKFLOW_GUIDE.md +294 -0
- package/.kiro/guides/DEVLOG.md +882 -0
- package/.kiro/guides/IMPLEMENTATION_EXAMPLES.md +611 -0
- package/.kiro/guides/PIV Loop.md +122 -0
- package/.kiro/guides/PIV Loop.png +0 -0
- package/.kiro/guides/PIVLoop.png +0 -0
- package/.kiro/guides/QUICK_REFERENCE.md +202 -0
- package/.kiro/guides/README.md +149 -0
- package/.kiro/guides/advanced-patterns.md +514 -0
- package/.kiro/guides/agent-coordination.md +434 -0
- package/.kiro/guides/core-workflows.md +409 -0
- package/.kiro/guides/emergency-procedures.md +414 -0
- package/.kiro/guides/project-evaluation.md +534 -0
- package/.kiro/guides/quality-assurance.md +431 -0
- package/.kiro/guides/quick-start.md +235 -0
- package/.kiro/guides/troubleshooting.md +575 -0
- package/.kiro/guides/walkthroughs.md +711 -0
- package/.kiro/prompts/add-to-devlog.md +263 -0
- package/.kiro/prompts/code-review-fix.md +18 -0
- package/.kiro/prompts/code-review-hackathon.md +167 -0
- package/.kiro/prompts/code-review-security.md +454 -0
- package/.kiro/prompts/code-review.md +113 -0
- package/.kiro/prompts/create-prd.md +151 -0
- package/.kiro/prompts/execute-backend.md +257 -0
- package/.kiro/prompts/execute-frontend.md +438 -0
- package/.kiro/prompts/execute-logging.md +491 -0
- package/.kiro/prompts/execute-security.md +482 -0
- package/.kiro/prompts/execute-testing.md +528 -0
- package/.kiro/prompts/execute.md +101 -0
- package/.kiro/prompts/execution-report.md +72 -0
- package/.kiro/prompts/implement-fix.md +228 -0
- package/.kiro/prompts/plan-feature.md +433 -0
- package/.kiro/prompts/prime.md +73 -0
- package/.kiro/prompts/quality-metrics.md +622 -0
- package/.kiro/prompts/quickstart.md +318 -0
- package/.kiro/prompts/rca.md +220 -0
- package/.kiro/prompts/system-review.md +189 -0
- package/README.md +32 -0
- package/bin/cli.js +97 -0
- package/package.json +33 -0
|
@@ -0,0 +1,454 @@
|
|
|
1
|
+
# Security-Focused Code Review
|
|
2
|
+
|
|
3
|
+
## Security Code Review Framework
|
|
4
|
+
|
|
5
|
+
This specialized code review framework focuses on identifying security vulnerabilities, validating security controls, and ensuring compliance with security best practices.
|
|
6
|
+
|
|
7
|
+
## Security Review Process
|
|
8
|
+
|
|
9
|
+
### Phase 1: Security Context Analysis
|
|
10
|
+
**Security Review Preparation:**
|
|
11
|
+
- Identify security-sensitive components and data flows
|
|
12
|
+
- Review threat model and security requirements
|
|
13
|
+
- Understand compliance requirements and standards
|
|
14
|
+
- Analyze attack surface and potential vulnerabilities
|
|
15
|
+
- Review previous security findings and remediation
|
|
16
|
+
|
|
17
|
+
**Security Context Questions:**
|
|
18
|
+
- What security-sensitive operations are being performed?
|
|
19
|
+
- What data is being processed and how sensitive is it?
|
|
20
|
+
- What authentication and authorization controls are in place?
|
|
21
|
+
- What external interfaces and integrations exist?
|
|
22
|
+
- What compliance requirements apply to this code?
|
|
23
|
+
|
|
24
|
+
### Phase 2: Vulnerability Assessment
|
|
25
|
+
**Common Vulnerability Categories:**
|
|
26
|
+
|
|
27
|
+
#### Authentication and Session Management
|
|
28
|
+
```typescript
|
|
29
|
+
// ❌ SECURITY ISSUE: Weak password requirements
|
|
30
|
+
const isValidPassword = (password: string) => password.length >= 6;
|
|
31
|
+
|
|
32
|
+
// ✅ SECURE: Strong password requirements
|
|
33
|
+
const isValidPassword = (password: string) => {
|
|
34
|
+
const minLength = 12;
|
|
35
|
+
const hasUpperCase = /[A-Z]/.test(password);
|
|
36
|
+
const hasLowerCase = /[a-z]/.test(password);
|
|
37
|
+
const hasNumbers = /\d/.test(password);
|
|
38
|
+
const hasSpecialChar = /[!@#$%^&*(),.?":{}|<>]/.test(password);
|
|
39
|
+
|
|
40
|
+
return password.length >= minLength &&
|
|
41
|
+
hasUpperCase &&
|
|
42
|
+
hasLowerCase &&
|
|
43
|
+
hasNumbers &&
|
|
44
|
+
hasSpecialChar;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// ❌ SECURITY ISSUE: JWT secret in code
|
|
48
|
+
const JWT_SECRET = 'mysecret123';
|
|
49
|
+
|
|
50
|
+
// ✅ SECURE: JWT secret from environment
|
|
51
|
+
const JWT_SECRET = process.env.JWT_SECRET;
|
|
52
|
+
if (!JWT_SECRET) {
|
|
53
|
+
throw new Error('JWT_SECRET environment variable is required');
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
#### Input Validation and Injection Prevention
|
|
58
|
+
```typescript
|
|
59
|
+
// ❌ SECURITY ISSUE: SQL injection vulnerability
|
|
60
|
+
const getUserById = async (id: string) => {
|
|
61
|
+
const query = `SELECT * FROM users WHERE id = '${id}'`;
|
|
62
|
+
return await db.query(query);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// ✅ SECURE: Parameterized query
|
|
66
|
+
const getUserById = async (id: string) => {
|
|
67
|
+
const query = 'SELECT * FROM users WHERE id = $1';
|
|
68
|
+
return await db.query(query, [id]);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// ❌ SECURITY ISSUE: XSS vulnerability
|
|
72
|
+
const displayUserName = (name: string) => {
|
|
73
|
+
return `<h1>Welcome ${name}</h1>`;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// ✅ SECURE: Proper escaping
|
|
77
|
+
import DOMPurify from 'isomorphic-dompurify';
|
|
78
|
+
|
|
79
|
+
const displayUserName = (name: string) => {
|
|
80
|
+
const sanitizedName = DOMPurify.sanitize(name);
|
|
81
|
+
return `<h1>Welcome ${sanitizedName}</h1>`;
|
|
82
|
+
};
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
#### Authorization and Access Control
|
|
86
|
+
```typescript
|
|
87
|
+
// ❌ SECURITY ISSUE: Missing authorization check
|
|
88
|
+
app.get('/admin/users', (req, res) => {
|
|
89
|
+
const users = getAllUsers();
|
|
90
|
+
res.json(users);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// ✅ SECURE: Proper authorization
|
|
94
|
+
app.get('/admin/users', authenticate, authorize(['admin']), (req, res) => {
|
|
95
|
+
const users = getAllUsers();
|
|
96
|
+
res.json(users);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// ❌ SECURITY ISSUE: Insecure direct object reference
|
|
100
|
+
app.get('/user/:id/profile', (req, res) => {
|
|
101
|
+
const profile = getUserProfile(req.params.id);
|
|
102
|
+
res.json(profile);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
// ✅ SECURE: Access control validation
|
|
106
|
+
app.get('/user/:id/profile', authenticate, (req, res) => {
|
|
107
|
+
const requestedUserId = req.params.id;
|
|
108
|
+
const currentUserId = req.user.id;
|
|
109
|
+
|
|
110
|
+
// Users can only access their own profile unless they're admin
|
|
111
|
+
if (requestedUserId !== currentUserId && !req.user.isAdmin) {
|
|
112
|
+
return res.status(403).json({ error: 'Access denied' });
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const profile = getUserProfile(requestedUserId);
|
|
116
|
+
res.json(profile);
|
|
117
|
+
});
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
#### Data Protection and Encryption
|
|
121
|
+
```typescript
|
|
122
|
+
// ❌ SECURITY ISSUE: Storing passwords in plain text
|
|
123
|
+
const createUser = async (userData: any) => {
|
|
124
|
+
const user = {
|
|
125
|
+
...userData,
|
|
126
|
+
password: userData.password // Plain text password
|
|
127
|
+
};
|
|
128
|
+
return await db.users.create(user);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
// ✅ SECURE: Proper password hashing
|
|
132
|
+
import bcrypt from 'bcrypt';
|
|
133
|
+
|
|
134
|
+
const createUser = async (userData: any) => {
|
|
135
|
+
const saltRounds = 12;
|
|
136
|
+
const hashedPassword = await bcrypt.hash(userData.password, saltRounds);
|
|
137
|
+
|
|
138
|
+
const user = {
|
|
139
|
+
...userData,
|
|
140
|
+
password: hashedPassword
|
|
141
|
+
};
|
|
142
|
+
return await db.users.create(user);
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
// ❌ SECURITY ISSUE: Sensitive data in logs
|
|
146
|
+
logger.info('User login attempt', { email, password });
|
|
147
|
+
|
|
148
|
+
// ✅ SECURE: No sensitive data in logs
|
|
149
|
+
logger.info('User login attempt', { email, timestamp: new Date().toISOString() });
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Phase 3: Security Control Validation
|
|
153
|
+
**Security Control Checklist:**
|
|
154
|
+
|
|
155
|
+
#### Rate Limiting and DDoS Protection
|
|
156
|
+
```typescript
|
|
157
|
+
// ✅ SECURE: Rate limiting implementation
|
|
158
|
+
import rateLimit from 'express-rate-limit';
|
|
159
|
+
|
|
160
|
+
const loginRateLimit = rateLimit({
|
|
161
|
+
windowMs: 15 * 60 * 1000, // 15 minutes
|
|
162
|
+
max: 5, // Limit each IP to 5 requests per windowMs
|
|
163
|
+
message: 'Too many login attempts, please try again later',
|
|
164
|
+
standardHeaders: true,
|
|
165
|
+
legacyHeaders: false,
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
app.post('/auth/login', loginRateLimit, loginController);
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
#### Security Headers
|
|
172
|
+
```typescript
|
|
173
|
+
// ✅ SECURE: Security headers middleware
|
|
174
|
+
const securityHeaders = (req: Request, res: Response, next: NextFunction) => {
|
|
175
|
+
res.setHeader('X-Content-Type-Options', 'nosniff');
|
|
176
|
+
res.setHeader('X-Frame-Options', 'DENY');
|
|
177
|
+
res.setHeader('X-XSS-Protection', '1; mode=block');
|
|
178
|
+
res.setHeader('Strict-Transport-Security', 'max-age=31536000; includeSubDomains');
|
|
179
|
+
res.setHeader('Content-Security-Policy', "default-src 'self'");
|
|
180
|
+
next();
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
app.use(securityHeaders);
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
#### Error Handling
|
|
187
|
+
```typescript
|
|
188
|
+
// ❌ SECURITY ISSUE: Information disclosure in errors
|
|
189
|
+
app.use((error: Error, req: Request, res: Response, next: NextFunction) => {
|
|
190
|
+
res.status(500).json({
|
|
191
|
+
error: error.message,
|
|
192
|
+
stack: error.stack, // Exposes internal information
|
|
193
|
+
query: req.query // May contain sensitive data
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
// ✅ SECURE: Safe error handling
|
|
198
|
+
app.use((error: Error, req: Request, res: Response, next: NextFunction) => {
|
|
199
|
+
// Log full error details securely
|
|
200
|
+
logger.error('Application error', {
|
|
201
|
+
message: error.message,
|
|
202
|
+
stack: error.stack,
|
|
203
|
+
url: req.url,
|
|
204
|
+
method: req.method,
|
|
205
|
+
ip: req.ip
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
// Return generic error to client
|
|
209
|
+
res.status(500).json({
|
|
210
|
+
error: 'Internal server error',
|
|
211
|
+
timestamp: new Date().toISOString()
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### Phase 4: Compliance Validation
|
|
217
|
+
**Compliance Requirements Check:**
|
|
218
|
+
|
|
219
|
+
#### GDPR Compliance
|
|
220
|
+
```typescript
|
|
221
|
+
// ✅ GDPR: Data minimization and purpose limitation
|
|
222
|
+
const collectUserData = (userData: any) => {
|
|
223
|
+
// Only collect necessary data
|
|
224
|
+
const { email, name, preferences } = userData;
|
|
225
|
+
|
|
226
|
+
return {
|
|
227
|
+
email,
|
|
228
|
+
name,
|
|
229
|
+
preferences,
|
|
230
|
+
createdAt: new Date(),
|
|
231
|
+
// Don't collect unnecessary personal data
|
|
232
|
+
};
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
// ✅ GDPR: Right to deletion
|
|
236
|
+
const deleteUserData = async (userId: string) => {
|
|
237
|
+
await db.transaction(async (tx) => {
|
|
238
|
+
// Delete user data from all tables
|
|
239
|
+
await tx.userProfiles.delete({ where: { userId } });
|
|
240
|
+
await tx.userPreferences.delete({ where: { userId } });
|
|
241
|
+
await tx.users.delete({ where: { id: userId } });
|
|
242
|
+
|
|
243
|
+
// Log deletion for audit trail
|
|
244
|
+
await tx.auditLog.create({
|
|
245
|
+
data: {
|
|
246
|
+
action: 'USER_DATA_DELETED',
|
|
247
|
+
userId,
|
|
248
|
+
timestamp: new Date()
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
});
|
|
252
|
+
};
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
#### SOC 2 Compliance
|
|
256
|
+
```typescript
|
|
257
|
+
// ✅ SOC 2: Audit logging
|
|
258
|
+
const auditLog = {
|
|
259
|
+
logUserAction: async (userId: string, action: string, details: any) => {
|
|
260
|
+
await db.auditLog.create({
|
|
261
|
+
data: {
|
|
262
|
+
userId,
|
|
263
|
+
action,
|
|
264
|
+
details: JSON.stringify(details),
|
|
265
|
+
timestamp: new Date(),
|
|
266
|
+
ipAddress: details.ipAddress,
|
|
267
|
+
userAgent: details.userAgent
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
// ✅ SOC 2: Access monitoring
|
|
274
|
+
const monitorAccess = async (req: Request, res: Response, next: NextFunction) => {
|
|
275
|
+
await auditLog.logUserAction(req.user?.id, 'RESOURCE_ACCESS', {
|
|
276
|
+
resource: req.path,
|
|
277
|
+
method: req.method,
|
|
278
|
+
ipAddress: req.ip,
|
|
279
|
+
userAgent: req.get('User-Agent')
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
next();
|
|
283
|
+
};
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### Phase 5: Security Testing Validation
|
|
287
|
+
**Security Test Coverage:**
|
|
288
|
+
|
|
289
|
+
#### Authentication Tests
|
|
290
|
+
```typescript
|
|
291
|
+
describe('Authentication Security', () => {
|
|
292
|
+
it('should prevent brute force attacks', async () => {
|
|
293
|
+
const email = 'test@example.com';
|
|
294
|
+
|
|
295
|
+
// Attempt multiple failed logins
|
|
296
|
+
for (let i = 0; i < 6; i++) {
|
|
297
|
+
await request(app)
|
|
298
|
+
.post('/auth/login')
|
|
299
|
+
.send({ email, password: 'wrongpassword' })
|
|
300
|
+
.expect(i < 5 ? 401 : 429);
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
it('should invalidate tokens on logout', async () => {
|
|
305
|
+
const { token } = await loginUser();
|
|
306
|
+
|
|
307
|
+
await request(app)
|
|
308
|
+
.post('/auth/logout')
|
|
309
|
+
.set('Authorization', `Bearer ${token}`)
|
|
310
|
+
.expect(200);
|
|
311
|
+
|
|
312
|
+
// Token should no longer work
|
|
313
|
+
await request(app)
|
|
314
|
+
.get('/protected')
|
|
315
|
+
.set('Authorization', `Bearer ${token}`)
|
|
316
|
+
.expect(401);
|
|
317
|
+
});
|
|
318
|
+
});
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
#### Input Validation Tests
|
|
322
|
+
```typescript
|
|
323
|
+
describe('Input Validation Security', () => {
|
|
324
|
+
it('should prevent SQL injection', async () => {
|
|
325
|
+
const maliciousInput = "'; DROP TABLE users; --";
|
|
326
|
+
|
|
327
|
+
const response = await request(app)
|
|
328
|
+
.get(`/users/search?name=${encodeURIComponent(maliciousInput)}`)
|
|
329
|
+
.expect(200);
|
|
330
|
+
|
|
331
|
+
// Should return empty results, not execute malicious SQL
|
|
332
|
+
expect(response.body.users).toEqual([]);
|
|
333
|
+
|
|
334
|
+
// Verify users table still exists
|
|
335
|
+
const userCount = await db.users.count();
|
|
336
|
+
expect(userCount).toBeGreaterThan(0);
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
it('should sanitize XSS attempts', async () => {
|
|
340
|
+
const xssPayload = '<script>alert("xss")</script>';
|
|
341
|
+
|
|
342
|
+
const response = await request(app)
|
|
343
|
+
.post('/comments')
|
|
344
|
+
.send({ content: xssPayload })
|
|
345
|
+
.expect(201);
|
|
346
|
+
|
|
347
|
+
// Content should be sanitized
|
|
348
|
+
expect(response.body.comment.content).not.toContain('<script>');
|
|
349
|
+
});
|
|
350
|
+
});
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
## Security Review Checklist
|
|
354
|
+
|
|
355
|
+
### Authentication and Authorization
|
|
356
|
+
- [ ] Strong password policies enforced
|
|
357
|
+
- [ ] Multi-factor authentication implemented where required
|
|
358
|
+
- [ ] Session management secure (no session fixation, proper timeout)
|
|
359
|
+
- [ ] JWT tokens properly signed and validated
|
|
360
|
+
- [ ] Authorization checks on all protected endpoints
|
|
361
|
+
- [ ] Principle of least privilege enforced
|
|
362
|
+
- [ ] Role-based access control properly implemented
|
|
363
|
+
|
|
364
|
+
### Input Validation and Injection Prevention
|
|
365
|
+
- [ ] All user inputs validated and sanitized
|
|
366
|
+
- [ ] SQL injection prevention (parameterized queries)
|
|
367
|
+
- [ ] XSS prevention (proper output encoding)
|
|
368
|
+
- [ ] Command injection prevention
|
|
369
|
+
- [ ] Path traversal prevention
|
|
370
|
+
- [ ] File upload security implemented
|
|
371
|
+
- [ ] API input validation comprehensive
|
|
372
|
+
|
|
373
|
+
### Data Protection
|
|
374
|
+
- [ ] Sensitive data encrypted at rest and in transit
|
|
375
|
+
- [ ] Encryption keys properly managed
|
|
376
|
+
- [ ] Passwords properly hashed (bcrypt, scrypt, or Argon2)
|
|
377
|
+
- [ ] Sensitive data not logged or exposed in errors
|
|
378
|
+
- [ ] Data retention policies implemented
|
|
379
|
+
- [ ] Secure data deletion implemented
|
|
380
|
+
|
|
381
|
+
### Security Controls
|
|
382
|
+
- [ ] Rate limiting implemented for sensitive endpoints
|
|
383
|
+
- [ ] Security headers properly configured
|
|
384
|
+
- [ ] HTTPS enforced for all communications
|
|
385
|
+
- [ ] CORS properly configured
|
|
386
|
+
- [ ] Content Security Policy implemented
|
|
387
|
+
- [ ] Error handling doesn't leak information
|
|
388
|
+
- [ ] Audit logging captures security events
|
|
389
|
+
|
|
390
|
+
### Infrastructure Security
|
|
391
|
+
- [ ] Dependencies regularly updated and scanned
|
|
392
|
+
- [ ] Environment variables used for secrets
|
|
393
|
+
- [ ] No hardcoded credentials or secrets
|
|
394
|
+
- [ ] Proper file permissions and access controls
|
|
395
|
+
- [ ] Security monitoring and alerting implemented
|
|
396
|
+
- [ ] Incident response procedures documented
|
|
397
|
+
|
|
398
|
+
### Compliance Requirements
|
|
399
|
+
- [ ] GDPR compliance (if applicable)
|
|
400
|
+
- [ ] HIPAA compliance (if applicable)
|
|
401
|
+
- [ ] SOC 2 compliance (if applicable)
|
|
402
|
+
- [ ] PCI DSS compliance (if applicable)
|
|
403
|
+
- [ ] Industry-specific requirements met
|
|
404
|
+
- [ ] Audit trails comprehensive and tamper-proof
|
|
405
|
+
|
|
406
|
+
## Security Review Report Template
|
|
407
|
+
|
|
408
|
+
### Executive Summary
|
|
409
|
+
- Overall security posture assessment
|
|
410
|
+
- Critical vulnerabilities identified
|
|
411
|
+
- Compliance status summary
|
|
412
|
+
- Recommended priority actions
|
|
413
|
+
|
|
414
|
+
### Detailed Findings
|
|
415
|
+
|
|
416
|
+
#### Critical Issues (Fix Immediately)
|
|
417
|
+
- **Issue**: [Description]
|
|
418
|
+
- **Impact**: [Security impact and business risk]
|
|
419
|
+
- **Location**: [File and line number]
|
|
420
|
+
- **Recommendation**: [Specific fix instructions]
|
|
421
|
+
- **Timeline**: Immediate
|
|
422
|
+
|
|
423
|
+
#### High Priority Issues (Fix Within 1 Week)
|
|
424
|
+
- **Issue**: [Description]
|
|
425
|
+
- **Impact**: [Security impact and business risk]
|
|
426
|
+
- **Location**: [File and line number]
|
|
427
|
+
- **Recommendation**: [Specific fix instructions]
|
|
428
|
+
- **Timeline**: 1 week
|
|
429
|
+
|
|
430
|
+
#### Medium Priority Issues (Fix Within 1 Month)
|
|
431
|
+
- **Issue**: [Description]
|
|
432
|
+
- **Impact**: [Security impact and business risk]
|
|
433
|
+
- **Location**: [File and line number]
|
|
434
|
+
- **Recommendation**: [Specific fix instructions]
|
|
435
|
+
- **Timeline**: 1 month
|
|
436
|
+
|
|
437
|
+
### Security Best Practices Validation
|
|
438
|
+
- Authentication and authorization implementation
|
|
439
|
+
- Input validation and injection prevention
|
|
440
|
+
- Data protection and encryption
|
|
441
|
+
- Security controls and monitoring
|
|
442
|
+
- Compliance requirements adherence
|
|
443
|
+
|
|
444
|
+
### Recommendations
|
|
445
|
+
- Immediate security improvements
|
|
446
|
+
- Long-term security strategy enhancements
|
|
447
|
+
- Security training and awareness needs
|
|
448
|
+
- Security tool and process improvements
|
|
449
|
+
|
|
450
|
+
## Output Format
|
|
451
|
+
|
|
452
|
+
Save a new file to `.kiro/code-reviews/security-[appropriate-name].md`
|
|
453
|
+
|
|
454
|
+
This security-focused code review framework ensures comprehensive security validation and provides actionable recommendations for maintaining a strong security posture.
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Technical code review for quality and bugs that runs pre-commit
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Perform technical code review on recently changed files.
|
|
6
|
+
|
|
7
|
+
## Core Principles
|
|
8
|
+
|
|
9
|
+
Review Philosophy:
|
|
10
|
+
|
|
11
|
+
- Simplicity is the ultimate sophistication - every line should justify its existence
|
|
12
|
+
- Code is read far more often than it's written - optimize for readability
|
|
13
|
+
- The best code is often the code you don't write
|
|
14
|
+
- Elegance emerges from clarity of intent and economy of expression
|
|
15
|
+
|
|
16
|
+
## What to Review
|
|
17
|
+
|
|
18
|
+
Start by gathering codebase context to understand the codebase standards and patterns.
|
|
19
|
+
|
|
20
|
+
Start by examining:
|
|
21
|
+
|
|
22
|
+
- PRD.md
|
|
23
|
+
- README.md
|
|
24
|
+
- Key files in the /core module
|
|
25
|
+
- Documented standards in the /docs directory
|
|
26
|
+
|
|
27
|
+
After you have a good understanding
|
|
28
|
+
|
|
29
|
+
Run these commands:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
git status
|
|
33
|
+
git diff HEAD
|
|
34
|
+
git diff --stat HEAD
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Then check the list of new files:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
git ls-files --others --exclude-standard
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Read each new file in its entirety. Read each changed file in its entirety (not just the diff) to understand full context.
|
|
44
|
+
|
|
45
|
+
For each changed file or new file, analyze for:
|
|
46
|
+
|
|
47
|
+
1. **Logic Errors**
|
|
48
|
+
- Off-by-one errors
|
|
49
|
+
- Incorrect conditionals
|
|
50
|
+
- Missing error handling
|
|
51
|
+
- Race conditions
|
|
52
|
+
|
|
53
|
+
2. **Security Issues**
|
|
54
|
+
- SQL injection vulnerabilities
|
|
55
|
+
- XSS vulnerabilities
|
|
56
|
+
- Insecure data handling
|
|
57
|
+
- Exposed secrets or API keys
|
|
58
|
+
|
|
59
|
+
3. **Performance Problems**
|
|
60
|
+
- N+1 queries
|
|
61
|
+
- Inefficient algorithms
|
|
62
|
+
- Memory leaks
|
|
63
|
+
- Unnecessary computations
|
|
64
|
+
|
|
65
|
+
4. **Code Quality**
|
|
66
|
+
- Violations of DRY principle
|
|
67
|
+
- Overly complex functions
|
|
68
|
+
- Poor naming
|
|
69
|
+
- Missing type hints/annotations
|
|
70
|
+
|
|
71
|
+
5. **Adherence to Codebase Standards and Existing Patterns**
|
|
72
|
+
- Adherence to standards documented in the /docs directory
|
|
73
|
+
- Linting, typing, and formatting standards
|
|
74
|
+
- Logging standards
|
|
75
|
+
- Testing standards
|
|
76
|
+
|
|
77
|
+
## Verify Issues Are Real
|
|
78
|
+
|
|
79
|
+
- Run specific tests for issues found
|
|
80
|
+
- Confirm type errors are legitimate
|
|
81
|
+
- Validate security concerns with context
|
|
82
|
+
|
|
83
|
+
## Output Format
|
|
84
|
+
|
|
85
|
+
Save a new file to `.kiro/code-reviews/[appropriate-name].md`
|
|
86
|
+
|
|
87
|
+
**Stats:**
|
|
88
|
+
|
|
89
|
+
- Files Modified: 0
|
|
90
|
+
- Files Added: 0
|
|
91
|
+
- Files Deleted: 0
|
|
92
|
+
- New lines: 0
|
|
93
|
+
- Deleted lines: 0
|
|
94
|
+
|
|
95
|
+
**For each issue found:**
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
severity: critical|high|medium|low
|
|
99
|
+
file: path/to/file.py
|
|
100
|
+
line: 42
|
|
101
|
+
issue: [one-line description]
|
|
102
|
+
detail: [explanation of why this is a problem]
|
|
103
|
+
suggestion: [how to fix it]
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
If no issues found: "Code review passed. No technical issues detected."
|
|
107
|
+
|
|
108
|
+
## Important
|
|
109
|
+
|
|
110
|
+
- Be specific (line numbers, not vague complaints)
|
|
111
|
+
- Focus on real bugs, not style
|
|
112
|
+
- Suggest fixes, don't just complain
|
|
113
|
+
- Flag security issues as CRITICAL
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Create a Product Requirements Document from conversation
|
|
3
|
+
argument-hint: [output-filename]
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Create PRD: Generate Product Requirements Document
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Generate a comprehensive Product Requirements Document (PRD) based on the current conversation context and requirements discussed. Use the structure and sections defined below to create a thorough, professional PRD.
|
|
11
|
+
|
|
12
|
+
## Output File
|
|
13
|
+
|
|
14
|
+
Write the PRD to: `$ARGUMENTS` (default: `./kiro/PRD.md`)
|
|
15
|
+
|
|
16
|
+
## PRD Structure
|
|
17
|
+
|
|
18
|
+
Create a well-structured PRD with the following sections. Adapt depth and detail based on available information:
|
|
19
|
+
|
|
20
|
+
### Required Sections
|
|
21
|
+
|
|
22
|
+
**1. Executive Summary**
|
|
23
|
+
- Concise product overview (2-3 paragraphs)
|
|
24
|
+
- Core value proposition
|
|
25
|
+
- MVP goal statement
|
|
26
|
+
|
|
27
|
+
**2. Mission**
|
|
28
|
+
- Product mission statement
|
|
29
|
+
- Core principles (3-5 key principles)
|
|
30
|
+
|
|
31
|
+
**3. Target Users**
|
|
32
|
+
- Primary user personas
|
|
33
|
+
- Technical comfort level
|
|
34
|
+
- Key user needs and pain points
|
|
35
|
+
|
|
36
|
+
**4. MVP Scope**
|
|
37
|
+
- **In Scope:** Core functionality for MVP (use ✅ checkboxes)
|
|
38
|
+
- **Out of Scope:** Features deferred to future phases (use ❌ checkboxes)
|
|
39
|
+
- Group by categories (Core Functionality, Technical, Integration, Deployment)
|
|
40
|
+
|
|
41
|
+
**5. User Stories**
|
|
42
|
+
- Primary user stories (5-8 stories) in format: "As a [user], I want to [action], so that [benefit]"
|
|
43
|
+
- Include concrete examples for each story
|
|
44
|
+
- Add technical user stories if relevant
|
|
45
|
+
|
|
46
|
+
**6. Core Architecture & Patterns**
|
|
47
|
+
- High-level architecture approach
|
|
48
|
+
- Directory structure (if applicable)
|
|
49
|
+
- Key design patterns and principles
|
|
50
|
+
- Technology-specific patterns
|
|
51
|
+
|
|
52
|
+
**7. Tools/Features**
|
|
53
|
+
- Detailed feature specifications
|
|
54
|
+
- If building an agent: Tool designs with purpose, operations, and key features
|
|
55
|
+
- If building an app: Core feature breakdown
|
|
56
|
+
|
|
57
|
+
**8. Technology Stack**
|
|
58
|
+
- Backend/Frontend technologies with versions
|
|
59
|
+
- Dependencies and libraries
|
|
60
|
+
- Optional dependencies
|
|
61
|
+
- Third-party integrations
|
|
62
|
+
|
|
63
|
+
**9. Security & Configuration**
|
|
64
|
+
- Authentication/authorization approach
|
|
65
|
+
- Configuration management (environment variables, settings)
|
|
66
|
+
- Security scope (in-scope and out-of-scope)
|
|
67
|
+
- Deployment considerations
|
|
68
|
+
|
|
69
|
+
**10. API Specification** (if applicable)
|
|
70
|
+
- Endpoint definitions
|
|
71
|
+
- Request/response formats
|
|
72
|
+
- Authentication requirements
|
|
73
|
+
- Example payloads
|
|
74
|
+
|
|
75
|
+
**11. Success Criteria**
|
|
76
|
+
- MVP success definition
|
|
77
|
+
- Functional requirements (use ✅ checkboxes)
|
|
78
|
+
- Quality indicators
|
|
79
|
+
- User experience goals
|
|
80
|
+
|
|
81
|
+
**12. Implementation Phases**
|
|
82
|
+
- Break down into 3-4 phases
|
|
83
|
+
- Each phase includes: Goal, Deliverables (✅ checkboxes), Validation criteria
|
|
84
|
+
- Realistic timeline estimates
|
|
85
|
+
|
|
86
|
+
**13. Future Considerations**
|
|
87
|
+
- Post-MVP enhancements
|
|
88
|
+
- Integration opportunities
|
|
89
|
+
- Advanced features for later phases
|
|
90
|
+
|
|
91
|
+
**14. Risks & Mitigations**
|
|
92
|
+
- 3-5 key risks with specific mitigation strategies
|
|
93
|
+
|
|
94
|
+
**15. Appendix** (if applicable)
|
|
95
|
+
- Related documents
|
|
96
|
+
- Key dependencies with links
|
|
97
|
+
- Repository/project structure
|
|
98
|
+
|
|
99
|
+
## Instructions
|
|
100
|
+
|
|
101
|
+
### 1. Extract Requirements
|
|
102
|
+
- Review the entire conversation history
|
|
103
|
+
- Identify explicit requirements and implicit needs
|
|
104
|
+
- Note technical constraints and preferences
|
|
105
|
+
- Capture user goals and success criteria
|
|
106
|
+
|
|
107
|
+
### 2. Synthesize Information
|
|
108
|
+
- Organize requirements into appropriate sections
|
|
109
|
+
- Fill in reasonable assumptions where details are missing
|
|
110
|
+
- Maintain consistency across sections
|
|
111
|
+
- Ensure technical feasibility
|
|
112
|
+
|
|
113
|
+
### 3. Write the PRD
|
|
114
|
+
- Use clear, professional language
|
|
115
|
+
- Include concrete examples and specifics
|
|
116
|
+
- Use markdown formatting (headings, lists, code blocks, checkboxes)
|
|
117
|
+
- Add code snippets for technical sections where helpful
|
|
118
|
+
- Keep Executive Summary concise but comprehensive
|
|
119
|
+
|
|
120
|
+
### 4. Quality Checks
|
|
121
|
+
- ✅ All required sections present
|
|
122
|
+
- ✅ User stories have clear benefits
|
|
123
|
+
- ✅ MVP scope is realistic and well-defined
|
|
124
|
+
- ✅ Technology choices are justified
|
|
125
|
+
- ✅ Implementation phases are actionable
|
|
126
|
+
- ✅ Success criteria are measurable
|
|
127
|
+
- ✅ Consistent terminology throughout
|
|
128
|
+
|
|
129
|
+
## Style Guidelines
|
|
130
|
+
|
|
131
|
+
- **Tone:** Professional, clear, action-oriented
|
|
132
|
+
- **Format:** Use markdown extensively (headings, lists, code blocks, tables)
|
|
133
|
+
- **Checkboxes:** Use ✅ for in-scope items, ❌ for out-of-scope
|
|
134
|
+
- **Specificity:** Prefer concrete examples over abstract descriptions
|
|
135
|
+
- **Length:** Comprehensive but scannable (typically 30-60 sections worth of content)
|
|
136
|
+
|
|
137
|
+
## Output Confirmation
|
|
138
|
+
|
|
139
|
+
After creating the PRD:
|
|
140
|
+
1. Confirm the file path where it was written
|
|
141
|
+
2. Provide a brief summary of the PRD contents
|
|
142
|
+
3. Highlight any assumptions made due to missing information
|
|
143
|
+
4. Suggest next steps (e.g., review, refinement, planning)
|
|
144
|
+
|
|
145
|
+
## Notes
|
|
146
|
+
|
|
147
|
+
- If critical information is missing, ask clarifying questions before generating
|
|
148
|
+
- Adapt section depth based on available details
|
|
149
|
+
- For highly technical products, emphasize architecture and technical stack
|
|
150
|
+
- For user-facing products, emphasize user stories and experience
|
|
151
|
+
- This command contains the complete PRD template structure - no external references needed
|