ai-flow-dev 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +408 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +791 -0
- package/dist/cli.js.map +1 -0
- package/dist/fs-utils.d.ts +2 -0
- package/dist/fs-utils.d.ts.map +1 -0
- package/dist/fs-utils.js +46 -0
- package/dist/fs-utils.js.map +1 -0
- package/package.json +71 -0
- package/prompts/backend/flow-dev-feature.md +1318 -0
- package/prompts/backend/flow-dev-fix.md +903 -0
- package/prompts/backend/flow-dev-refactor.md +715 -0
- package/prompts/backend/flow-dev-review.md +401 -0
- package/prompts/backend/flow-dev-work.md +1129 -0
- package/prompts/backend/flow-docs-gen-phase-0.md +1840 -0
- package/prompts/backend/flow-docs-gen-phase-1.md +435 -0
- package/prompts/backend/flow-docs-gen-phase-2.md +460 -0
- package/prompts/backend/flow-docs-gen-phase-3.md +684 -0
- package/prompts/backend/flow-docs-gen-phase-4.md +516 -0
- package/prompts/backend/flow-docs-gen-phase-5.md +637 -0
- package/prompts/backend/flow-docs-gen-phase-6.md +465 -0
- package/prompts/backend/flow-docs-gen-phase-7.md +1207 -0
- package/prompts/backend/flow-docs-gen.md +820 -0
- package/prompts/backend/flow-docs-sync.md +526 -0
- package/prompts/backend/flow-project-init.md +248 -0
- package/prompts/backend/flow-project-roadmap.md +1159 -0
- package/prompts/frontend/flow-docs-gen-phase-0.md +494 -0
- package/prompts/frontend/flow-docs-gen-phase-1.md +449 -0
- package/prompts/frontend/flow-docs-gen-phase-2.md +983 -0
- package/prompts/frontend/flow-docs-gen-phase-3.md +685 -0
- package/prompts/frontend/flow-docs-gen-phase-4.md +480 -0
- package/prompts/frontend/flow-docs-gen-phase-5.md +483 -0
- package/prompts/frontend/flow-docs-gen-phase-6.md +570 -0
- package/prompts/frontend/flow-docs-gen-phase-7.md +582 -0
- package/prompts/frontend/flow-docs-gen.md +413 -0
- package/prompts/frontend/flow-docs-sync.md +561 -0
- package/prompts/mobile/flow-docs-gen-phase-0.md +387 -0
- package/prompts/mobile/flow-docs-gen-phase-1.md +530 -0
- package/prompts/mobile/flow-docs-gen-phase-2.md +584 -0
- package/prompts/mobile/flow-docs-gen-phase-3.md +659 -0
- package/prompts/mobile/flow-docs-gen-phase-4.md +363 -0
- package/prompts/mobile/flow-docs-gen-phase-5.md +369 -0
- package/prompts/mobile/flow-docs-gen-phase-6.md +490 -0
- package/prompts/mobile/flow-docs-gen-phase-7.md +407 -0
- package/prompts/mobile/flow-docs-gen.md +430 -0
- package/prompts/mobile/flow-docs-sync.md +634 -0
- package/templates/backend/.clauderules.template +111 -0
- package/templates/backend/.cursorrules.template +102 -0
- package/templates/backend/.env.example.template +122 -0
- package/templates/backend/README.template.md +200 -0
- package/templates/backend/ai-instructions.template.md +354 -0
- package/templates/backend/copilot-instructions.template.md +160 -0
- package/templates/backend/docs/api.template.md +251 -0
- package/templates/backend/docs/architecture.template.md +612 -0
- package/templates/backend/docs/business-flows.template.md +109 -0
- package/templates/backend/docs/code-standards.template.md +828 -0
- package/templates/backend/docs/contributing.template.md +163 -0
- package/templates/backend/docs/data-model.template.md +416 -0
- package/templates/backend/docs/operations.template.md +591 -0
- package/templates/backend/docs/testing.template.md +762 -0
- package/templates/backend/project-brief.template.md +176 -0
- package/templates/backend/specs/configuration.template.md +133 -0
- package/templates/backend/specs/security.template.md +422 -0
- package/templates/frontend/README.template.md +121 -0
- package/templates/frontend/ai-instructions.template.md +368 -0
- package/templates/frontend/docs/api-integration.template.md +390 -0
- package/templates/frontend/docs/components.template.md +567 -0
- package/templates/frontend/docs/error-handling.template.md +385 -0
- package/templates/frontend/docs/operations.template.md +123 -0
- package/templates/frontend/docs/performance.template.md +140 -0
- package/templates/frontend/docs/pwa.template.md +135 -0
- package/templates/frontend/docs/state-management.template.md +394 -0
- package/templates/frontend/docs/styling.template.md +779 -0
- package/templates/frontend/docs/testing.template.md +736 -0
- package/templates/frontend/project-brief.template.md +55 -0
- package/templates/frontend/specs/accessibility.template.md +111 -0
- package/templates/frontend/specs/configuration.template.md +520 -0
- package/templates/frontend/specs/security.template.md +197 -0
- package/templates/fullstack/README.template.md +282 -0
- package/templates/fullstack/ai-instructions.template.md +487 -0
- package/templates/fullstack/project-brief.template.md +197 -0
- package/templates/fullstack/specs/configuration.template.md +380 -0
- package/templates/mobile/AGENT.template.md +251 -0
- package/templates/mobile/README.template.md +195 -0
- package/templates/mobile/ai-instructions.template.md +221 -0
- package/templates/mobile/docs/app-store.template.md +163 -0
- package/templates/mobile/docs/architecture.template.md +100 -0
- package/templates/mobile/docs/native-features.template.md +137 -0
- package/templates/mobile/docs/navigation.template.md +81 -0
- package/templates/mobile/docs/offline-strategy.template.md +90 -0
- package/templates/mobile/docs/permissions.template.md +70 -0
- package/templates/mobile/docs/state-management.template.md +116 -0
- package/templates/mobile/docs/testing.template.md +146 -0
- package/templates/mobile/project-brief.template.md +97 -0
- package/templates/mobile/specs/build-configuration.template.md +116 -0
- package/templates/mobile/specs/deployment.template.md +114 -0
- package/templates/shared/AGENT.template.md +252 -0
|
@@ -0,0 +1,516 @@
|
|
|
1
|
+
## PHASE 4: Security & Authentication (15-20 min)
|
|
2
|
+
|
|
3
|
+
> **Order for this phase:** 4.1 → 4.2 → 4.3 → 4.4 → 4.5 → 4.6 → 4.7 → 4.8 → 4.9 → 4.10 → 4.11
|
|
4
|
+
|
|
5
|
+
> **📌 Scope-based behavior:**
|
|
6
|
+
>
|
|
7
|
+
> - **MVP:** Ask 4.1-4.5 only (auth basics + CORS), skip 4.6-4.11 (advanced security), mark as "TBD"
|
|
8
|
+
> - **Production-Ready:** Ask 4.1-4.8 and 4.11, skip or simplify 4.9 (compliance) and 4.10 (audit logging)
|
|
9
|
+
> - **Enterprise:** Ask all questions 4.1-4.11 with emphasis on compliance and audit trails
|
|
10
|
+
|
|
11
|
+
### Objective
|
|
12
|
+
|
|
13
|
+
Define security policies, authentication, authorization, and compliance requirements.
|
|
14
|
+
|
|
15
|
+
**4.1 Authentication Method**
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
How will users authenticate?
|
|
19
|
+
|
|
20
|
+
A) ⭐ JWT (JSON Web Tokens) - Recommended for APIs
|
|
21
|
+
|
|
22
|
+
- Stateless, scalable
|
|
23
|
+
- Access + Refresh token pattern
|
|
24
|
+
|
|
25
|
+
B) 🔥 Session-based - Traditional web apps
|
|
26
|
+
|
|
27
|
+
- Server-side sessions
|
|
28
|
+
- Cookie-based
|
|
29
|
+
|
|
30
|
+
C) ⚡ OAuth 2.0 / OpenID Connect - External providers
|
|
31
|
+
|
|
32
|
+
- "Sign in with Google/GitHub/etc."
|
|
33
|
+
- Delegated authentication
|
|
34
|
+
|
|
35
|
+
D) 🏆 Multi-factor (MFA) - Enterprise security
|
|
36
|
+
|
|
37
|
+
- OTP, SMS, authenticator app
|
|
38
|
+
- Required or optional?
|
|
39
|
+
|
|
40
|
+
E) API Keys - Service-to-service
|
|
41
|
+
|
|
42
|
+
- Simple, stateless
|
|
43
|
+
- Limited use cases
|
|
44
|
+
|
|
45
|
+
Your choice: __
|
|
46
|
+
Why?
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
**4.2 JWT Configuration (if using JWT)**
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
JWT token configuration:
|
|
53
|
+
|
|
54
|
+
Access Token:
|
|
55
|
+
- Lifetime: __ (recommended: 15min - 1hour)
|
|
56
|
+
- Algorithm: __ (recommended: RS256 or HS256)
|
|
57
|
+
|
|
58
|
+
Refresh Token:
|
|
59
|
+
- Lifetime: __ (recommended: 7-30 days)
|
|
60
|
+
- Storage: [httpOnly cookie / localStorage / database]
|
|
61
|
+
- Rotation strategy: [rotate on use / rotate periodically / no rotation]
|
|
62
|
+
|
|
63
|
+
Token claims to include:
|
|
64
|
+
- userId ✅
|
|
65
|
+
- email ✅
|
|
66
|
+
- roles ✅
|
|
67
|
+
- Custom: __
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**4.3 Authorization Model**
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
How will you manage permissions?
|
|
74
|
+
|
|
75
|
+
A) ⭐ Role-Based Access Control (RBAC)
|
|
76
|
+
- Users have roles (admin, user, moderator, etc.)
|
|
77
|
+
- Roles have permissions
|
|
78
|
+
- Simple and common
|
|
79
|
+
|
|
80
|
+
B) 🏆 Attribute-Based Access Control (ABAC)
|
|
81
|
+
- Fine-grained based on attributes
|
|
82
|
+
- Complex rules
|
|
83
|
+
- Enterprise use cases
|
|
84
|
+
|
|
85
|
+
C) 🔒 Resource-based (Ownership)
|
|
86
|
+
- Users can only access their own resources
|
|
87
|
+
- Simple projects
|
|
88
|
+
|
|
89
|
+
D) 🌐 Multi-tenant with role hierarchy
|
|
90
|
+
- Organization → Teams → Users
|
|
91
|
+
- Complex enterprise systems
|
|
92
|
+
|
|
93
|
+
Your choice: __
|
|
94
|
+
|
|
95
|
+
List the roles you'll need:
|
|
96
|
+
-
|
|
97
|
+
-
|
|
98
|
+
|
|
99
|
+
List key permissions:
|
|
100
|
+
-
|
|
101
|
+
-
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**4.4 Password Policy**
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
Password requirements:
|
|
108
|
+
|
|
109
|
+
A) ⭐ Recommended Policy
|
|
110
|
+
- Minimum 8 characters
|
|
111
|
+
- At least 1 uppercase, 1 lowercase, 1 number
|
|
112
|
+
- Special characters encouraged but not required
|
|
113
|
+
- No maximum length limit
|
|
114
|
+
- Hash with bcrypt (12 rounds) or argon2
|
|
115
|
+
|
|
116
|
+
B) 🏆 Strong Policy (Enterprise)
|
|
117
|
+
- Minimum 12 characters
|
|
118
|
+
- Uppercase, lowercase, number, special char required
|
|
119
|
+
- Password expiration every 90 days
|
|
120
|
+
- Password history (can't reuse last 5)
|
|
121
|
+
|
|
122
|
+
C) 🔓 Simple Policy
|
|
123
|
+
- Minimum 6 characters
|
|
124
|
+
- No complexity requirements
|
|
125
|
+
- Good for low-risk apps
|
|
126
|
+
|
|
127
|
+
Your choice: __
|
|
128
|
+
|
|
129
|
+
Hashing algorithm:
|
|
130
|
+
A) ⭐ bcrypt (rounds: 10-12) - Recommended
|
|
131
|
+
B) argon2 - More secure, newer
|
|
132
|
+
C) scrypt - Good alternative
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
**4.5 Rate Limiting**
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
Will you implement rate limiting?
|
|
139
|
+
|
|
140
|
+
A) ⭐ Yes - Recommended for all public APIs
|
|
141
|
+
|
|
142
|
+
Rate limits by endpoint type:
|
|
143
|
+
- Authentication endpoints: ** requests per ** (e.g., 5 per 15 min)
|
|
144
|
+
- Public read endpoints: ** requests per ** (e.g., 100 per minute)
|
|
145
|
+
- Write endpoints: ** requests per ** (e.g., 30 per minute)
|
|
146
|
+
- Admin endpoints: ** requests per ** (e.g., 1000 per minute)
|
|
147
|
+
|
|
148
|
+
Rate limiting strategy:
|
|
149
|
+
A) IP-based
|
|
150
|
+
B) User/API key-based
|
|
151
|
+
C) Both
|
|
152
|
+
|
|
153
|
+
Tool:
|
|
154
|
+
A) express-rate-limit / @nestjs/throttler
|
|
155
|
+
B) Redis-based rate limiting
|
|
156
|
+
C) API Gateway (AWS, Kong, etc.)
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
**4.6 CORS Policy**
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
CORS (Cross-Origin Resource Sharing) configuration:
|
|
163
|
+
|
|
164
|
+
Allowed origins:
|
|
165
|
+
A) ⭐ Specific domains - https://myapp.com, https://admin.myapp.com
|
|
166
|
+
B) 🔧 Development only - localhost:3000, localhost:5173
|
|
167
|
+
C) ⚠️ Wildcard (*) - Allow all (NOT recommended for production)
|
|
168
|
+
|
|
169
|
+
Your allowed origins:
|
|
170
|
+
-
|
|
171
|
+
|
|
172
|
+
Allowed methods: [GET, POST, PUT, PATCH, DELETE, OPTIONS]
|
|
173
|
+
Credentials: [true/false] - Allow cookies/auth headers
|
|
174
|
+
Max age: __ seconds (cache preflight)
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
**4.7 Data Encryption**
|
|
178
|
+
|
|
179
|
+
```
|
|
180
|
+
Encryption requirements:
|
|
181
|
+
|
|
182
|
+
In Transit (HTTPS/TLS):
|
|
183
|
+
A) ✅ Yes, always - TLS 1.2+ required ⭐
|
|
184
|
+
B) Development only HTTP, production HTTPS
|
|
185
|
+
C) Optional
|
|
186
|
+
|
|
187
|
+
At Rest (Database/Files):
|
|
188
|
+
A) ⭐ Yes, encrypt sensitive fields - PII, payment info, secrets
|
|
189
|
+
B) 🏆 Yes, full database encryption - Enterprise requirement
|
|
190
|
+
C) No encryption - Low-risk data only
|
|
191
|
+
|
|
192
|
+
Fields to encrypt:
|
|
193
|
+
-
|
|
194
|
+
-
|
|
195
|
+
|
|
196
|
+
Encryption method:
|
|
197
|
+
A) AES-256-GCM (symmetric)
|
|
198
|
+
B) Database-level encryption
|
|
199
|
+
C) Application-level encryption
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
**4.8 Security Headers**
|
|
203
|
+
|
|
204
|
+
```
|
|
205
|
+
Which security headers will you implement?
|
|
206
|
+
|
|
207
|
+
A) ✅ All recommended headers (use helmet.js or equivalent)
|
|
208
|
+
- Content-Security-Policy
|
|
209
|
+
- X-Frame-Options: DENY
|
|
210
|
+
- X-Content-Type-Options: nosniff
|
|
211
|
+
- Strict-Transport-Security (HSTS)
|
|
212
|
+
- X-XSS-Protection
|
|
213
|
+
|
|
214
|
+
B) Basic headers only
|
|
215
|
+
C) None (not recommended)
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
**4.9 Compliance Requirements**
|
|
219
|
+
|
|
220
|
+
```
|
|
221
|
+
Does your project need to comply with specific regulations or standards?
|
|
222
|
+
|
|
223
|
+
Some projects must follow legal requirements or industry standards. If you're not sure, you can select "None" and add compliance requirements later.
|
|
224
|
+
|
|
225
|
+
Select all that apply:
|
|
226
|
+
|
|
227
|
+
A) 🌍 GDPR (General Data Protection Regulation)
|
|
228
|
+
What it is: EU data privacy regulation
|
|
229
|
+
When it applies: If you process personal data of users in the European Union
|
|
230
|
+
What it means: Users have rights to access, delete, and export their data
|
|
231
|
+
Key requirements:
|
|
232
|
+
- Right to access data (users can request their data)
|
|
233
|
+
- Right to deletion (users can request data removal)
|
|
234
|
+
- Data portability (users can export their data)
|
|
235
|
+
- Consent management (explicit consent for data processing)
|
|
236
|
+
Example: "We serve users in Germany, so we need GDPR compliance"
|
|
237
|
+
|
|
238
|
+
B) 🏥 HIPAA (Health Insurance Portability and Accountability Act)
|
|
239
|
+
What it is: US healthcare data protection law
|
|
240
|
+
When it applies: If you handle Protected Health Information (PHI) - medical records, health data
|
|
241
|
+
What it means: Strict rules for protecting patient health information
|
|
242
|
+
Key requirements:
|
|
243
|
+
- PHI protection (encryption, access controls)
|
|
244
|
+
- Audit logs (track who accessed what health data)
|
|
245
|
+
- Encryption requirements (data must be encrypted)
|
|
246
|
+
Example: "We're building a telemedicine platform that stores patient records"
|
|
247
|
+
|
|
248
|
+
C) 💳 PCI-DSS (Payment Card Industry Data Security Standard)
|
|
249
|
+
What it is: Security standard for credit card processing
|
|
250
|
+
When it applies: If you process, store, or transmit credit card information
|
|
251
|
+
What it means: Strict security rules to protect cardholder data
|
|
252
|
+
Key requirements:
|
|
253
|
+
- Never store CVV (security code on card)
|
|
254
|
+
- Tokenize card numbers (use tokens instead of real numbers)
|
|
255
|
+
- Secure transmission (encrypted connections required)
|
|
256
|
+
Example: "We process credit card payments directly (not using Stripe/PayPal)"
|
|
257
|
+
|
|
258
|
+
D) 🏢 SOC 2 (System and Organization Controls 2)
|
|
259
|
+
What it is: Security and compliance standard for SaaS companies
|
|
260
|
+
When it applies: If you're selling B2B SaaS and need to prove security to enterprise customers
|
|
261
|
+
What it means: Documented security controls and processes
|
|
262
|
+
Key requirements:
|
|
263
|
+
- Security controls (documented security measures)
|
|
264
|
+
- Audit trails (logs of all security-relevant actions)
|
|
265
|
+
- Access controls (who can access what)
|
|
266
|
+
Example: "We're selling to Fortune 500 companies who require SOC 2 certification"
|
|
267
|
+
|
|
268
|
+
E) 🇺🇸 CCPA (California Consumer Privacy Act)
|
|
269
|
+
What it is: California state privacy law
|
|
270
|
+
When it applies: If you have California users and meet certain thresholds (revenue/users)
|
|
271
|
+
What it means: California users have privacy rights
|
|
272
|
+
Key requirements:
|
|
273
|
+
- Right to know what data is collected
|
|
274
|
+
- Right to delete data
|
|
275
|
+
- Right to opt-out of data sales
|
|
276
|
+
Example: "We have users in California and meet the revenue threshold"
|
|
277
|
+
|
|
278
|
+
F) None - No specific compliance requirements
|
|
279
|
+
Select this if you're not sure or don't need compliance yet
|
|
280
|
+
|
|
281
|
+
Selected: __
|
|
282
|
+
|
|
283
|
+
For each selected, list specific requirements that apply to your project:
|
|
284
|
+
|
|
285
|
+
Example for GDPR:
|
|
286
|
+
- Must allow users to download all their data in JSON format
|
|
287
|
+
- Must completely delete user data when requested (not just soft delete)
|
|
288
|
+
- Need cookie consent banner for EU users
|
|
289
|
+
- Privacy policy must be accessible and up-to-date
|
|
290
|
+
|
|
291
|
+
Example for SOC 2:
|
|
292
|
+
- Need 90-day audit log retention
|
|
293
|
+
- Quarterly access control reviews required
|
|
294
|
+
- Security incident response procedures documented
|
|
295
|
+
- Continuous monitoring of administrative actions
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
**4.10 Logging & Audit Trail**
|
|
299
|
+
|
|
300
|
+
```
|
|
301
|
+
What security events will you log?
|
|
302
|
+
|
|
303
|
+
A) ✅ Authentication events
|
|
304
|
+
- Login success/failure
|
|
305
|
+
- Password changes
|
|
306
|
+
- Account creation
|
|
307
|
+
|
|
308
|
+
B) ✅ Authorization events
|
|
309
|
+
- Permission denied
|
|
310
|
+
- Role changes
|
|
311
|
+
|
|
312
|
+
C) ✅ Data access
|
|
313
|
+
- Sensitive data views
|
|
314
|
+
- Exports/downloads
|
|
315
|
+
|
|
316
|
+
D) ✅ Data modifications
|
|
317
|
+
- Create/Update/Delete operations
|
|
318
|
+
- Who, what, when
|
|
319
|
+
|
|
320
|
+
Log retention: __ days (recommended: 90+ days)
|
|
321
|
+
Log storage: [Database / File system / External service (CloudWatch, Datadog)]
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
**4.11 API Keys Management**
|
|
325
|
+
|
|
326
|
+
```
|
|
327
|
+
Will you use API keys for service-to-service authentication?
|
|
328
|
+
|
|
329
|
+
A) ⭐ Yes - API keys for programmatic access
|
|
330
|
+
B) No - JWT/Sessions only
|
|
331
|
+
|
|
332
|
+
If yes:
|
|
333
|
+
- Key format: [Prefix + random string, UUID, etc.]
|
|
334
|
+
- Key length: __ characters
|
|
335
|
+
- Storage: [Hashed in database, Plain text (not recommended)]
|
|
336
|
+
- Hashing algorithm: [bcrypt, SHA-256, etc.]
|
|
337
|
+
|
|
338
|
+
Key rotation:
|
|
339
|
+
A) ⭐ Manual rotation - Rotate on demand
|
|
340
|
+
B) Automatic rotation - Rotate every __ days
|
|
341
|
+
C) No rotation
|
|
342
|
+
|
|
343
|
+
Key revocation:
|
|
344
|
+
- Process: __
|
|
345
|
+
- Reasons: [Compromised, Expired, User request, Security incident]
|
|
346
|
+
|
|
347
|
+
Rate limiting by API key tier:
|
|
348
|
+
- Free tier: __ requests per __
|
|
349
|
+
- Paid tier: __ requests per __
|
|
350
|
+
- Enterprise: __ requests per __
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
**4.12 Dependency Security**
|
|
354
|
+
|
|
355
|
+
```
|
|
356
|
+
How will you manage dependency security?
|
|
357
|
+
|
|
358
|
+
A) ⭐ Automated scanning - Regular security audits (npm audit, Snyk, Dependabot)
|
|
359
|
+
B) Manual scanning - Check vulnerabilities manually
|
|
360
|
+
C) No scanning - Not recommended
|
|
361
|
+
|
|
362
|
+
Scanning frequency:
|
|
363
|
+
A) ⭐ On every install/update
|
|
364
|
+
B) Daily automated scans
|
|
365
|
+
C) Weekly scans
|
|
366
|
+
D) Monthly scans
|
|
367
|
+
|
|
368
|
+
Vulnerability response:
|
|
369
|
+
- Critical: Fix within __ hours
|
|
370
|
+
- High: Fix within __ days
|
|
371
|
+
- Medium: Fix within __ days
|
|
372
|
+
- Low: Fix in next release
|
|
373
|
+
|
|
374
|
+
Tools:
|
|
375
|
+
- Dependency scanner: __
|
|
376
|
+
- Security alerts: [GitHub Dependabot, Snyk, npm audit, etc.]
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
**4.13 Input Validation & Sanitization**
|
|
380
|
+
|
|
381
|
+
```
|
|
382
|
+
Input validation strategy:
|
|
383
|
+
|
|
384
|
+
A) ⭐ Strict validation with DTOs/Schemas (Recommended)
|
|
385
|
+
- Use validation library: [class-validator/Zod/Pydantic/Joi from Phase 3.6]
|
|
386
|
+
- Reject unknown fields: [yes/no]
|
|
387
|
+
- Type coercion: [strict/lenient]
|
|
388
|
+
|
|
389
|
+
B) Manual validation in services
|
|
390
|
+
- Custom validation logic
|
|
391
|
+
- More flexible but error-prone
|
|
392
|
+
|
|
393
|
+
Sanitization rules:
|
|
394
|
+
|
|
395
|
+
A) ✅ Sanitize all string inputs (XSS prevention)
|
|
396
|
+
- Strip HTML tags: [yes/no]
|
|
397
|
+
- Escape special characters: [yes/no]
|
|
398
|
+
- Library: [DOMPurify/validator.js/bleach]
|
|
399
|
+
|
|
400
|
+
B) ✅ SQL Injection prevention
|
|
401
|
+
- Use parameterized queries (ORM handles this automatically)
|
|
402
|
+
- Never concatenate user input in queries
|
|
403
|
+
|
|
404
|
+
Request size limits:
|
|
405
|
+
|
|
406
|
+
- Max JSON body size: __ MB (recommended: 1-10 MB)
|
|
407
|
+
- Max file upload size: __ MB (recommended: 10-50 MB)
|
|
408
|
+
- Max URL length: __ characters (recommended: 2048)
|
|
409
|
+
|
|
410
|
+
File upload validation (if applicable from Phase 3.9):
|
|
411
|
+
|
|
412
|
+
- Allowed file types: [jpg, png, pdf, etc.]
|
|
413
|
+
- MIME type validation: [yes/no - verify actual content matches extension]
|
|
414
|
+
- File content validation: [yes/no - check file headers]
|
|
415
|
+
- Virus scanning: [yes/no - ClamAV, VirusTotal API]
|
|
416
|
+
- Filename sanitization: [yes/no - remove special characters, limit length]
|
|
417
|
+
|
|
418
|
+
Content-Type enforcement:
|
|
419
|
+
|
|
420
|
+
A) ⭐ Strict - Reject if Content-Type doesn't match body (recommended)
|
|
421
|
+
B) Lenient - Accept common mismatches (application/json vs text/plain)
|
|
422
|
+
C) No validation
|
|
423
|
+
|
|
424
|
+
Validation approach:
|
|
425
|
+
|
|
426
|
+
A) ⭐ Whitelist - Only allow known good inputs (recommended)
|
|
427
|
+
- Define allowed values explicitly
|
|
428
|
+
- Reject everything else
|
|
429
|
+
|
|
430
|
+
B) Blacklist - Block known bad inputs (not recommended)
|
|
431
|
+
- Easy to bypass
|
|
432
|
+
- Incomplete protection
|
|
433
|
+
|
|
434
|
+
Special character handling:
|
|
435
|
+
|
|
436
|
+
- Allow special characters in: [names, descriptions, etc.]
|
|
437
|
+
- Escape/encode for: [HTML output, SQL queries, shell commands]
|
|
438
|
+
- Reject in: [IDs, slugs, filenames]
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
### Phase 4 Output
|
|
442
|
+
|
|
443
|
+
```
|
|
444
|
+
📋 PHASE 4 SUMMARY:
|
|
445
|
+
|
|
446
|
+
Authentication: [method]
|
|
447
|
+
JWT Config: [if applicable - access/refresh token lifetimes, algorithm, storage]
|
|
448
|
+
Authorization: [RBAC/ABAC/etc.]
|
|
449
|
+
Roles: [list]
|
|
450
|
+
Permissions: [key permissions defined]
|
|
451
|
+
Password Policy: [requirements and hashing algorithm]
|
|
452
|
+
Rate Limiting: [yes/no + limits by endpoint type]
|
|
453
|
+
CORS: [origins, methods, credentials, max-age]
|
|
454
|
+
Encryption: [in-transit + at-rest + fields to encrypt]
|
|
455
|
+
Security Headers: [list]
|
|
456
|
+
Compliance: [requirements with specific controls]
|
|
457
|
+
Audit Logging: [events logged + retention + storage]
|
|
458
|
+
API Keys Management: [yes/no + format + rotation + revocation + rate limiting]
|
|
459
|
+
Dependency Security: [scanning tool + frequency + vulnerability response]
|
|
460
|
+
Input Validation: [strategy + sanitization rules + size limits + file upload validation + whitelist/blacklist approach]
|
|
461
|
+
|
|
462
|
+
Is this correct? (Yes/No)
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
---
|
|
466
|
+
|
|
467
|
+
### 📄 Generate Phase 4 Documents
|
|
468
|
+
|
|
469
|
+
**Before starting generation:**
|
|
470
|
+
|
|
471
|
+
```
|
|
472
|
+
📖 Loading context from previous phases...
|
|
473
|
+
✅ Re-reading project-brief.md
|
|
474
|
+
✅ Re-reading docs/data-model.md
|
|
475
|
+
✅ Re-reading docs/architecture.md
|
|
476
|
+
✅ Re-reading ai-instructions.md
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
Once confirmed, generate:
|
|
480
|
+
|
|
481
|
+
**1. `specs/security.md`**
|
|
482
|
+
|
|
483
|
+
- Use template: `.ai-flow/templates/specs/security.template.md`
|
|
484
|
+
- Fill with all security policies, authentication, authorization
|
|
485
|
+
|
|
486
|
+
**2. Update `ai-instructions.md`**
|
|
487
|
+
|
|
488
|
+
- Add security rules to NEVER/ALWAYS sections
|
|
489
|
+
- Add authentication/authorization patterns
|
|
490
|
+
|
|
491
|
+
```
|
|
492
|
+
✅ Generated: specs/security.md
|
|
493
|
+
✅ Updated: ai-instructions.md (security rules added)
|
|
494
|
+
|
|
495
|
+
📝 Please review these documents. Do you need to make any corrections?
|
|
496
|
+
|
|
497
|
+
A) ✅ Look perfect, continue to Phase 5
|
|
498
|
+
B) 📝 I'll edit them now (I'll wait)
|
|
499
|
+
C) 🔄 Regenerate with changes (tell me what to modify)
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
**If user selects B:**
|
|
503
|
+
|
|
504
|
+
```
|
|
505
|
+
Perfect. Please edit the documents and type "ready" when you're done.
|
|
506
|
+
I'll re-read all files to update my context before continuing.
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
---
|
|
510
|
+
|
|
511
|
+
**Proceed to Phase 5 only after documents are validated.**
|
|
512
|
+
|
|
513
|
+
---
|
|
514
|
+
|
|
515
|
+
## PHASE 5: Code Standards (15-20 min)
|
|
516
|
+
|