@lenne.tech/cli 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. package/build/commands/claude/install-commands.js +332 -0
  2. package/build/commands/claude/install-skills.js +5 -1
  3. package/build/commands/server/add-property.js +22 -41
  4. package/build/extensions/server.js +142 -46
  5. package/build/templates/claude-commands/code-cleanup.md +82 -0
  6. package/build/templates/claude-commands/mr-description-clipboard.md +48 -0
  7. package/build/templates/claude-commands/mr-description.md +33 -0
  8. package/build/templates/claude-commands/sec-review.md +62 -0
  9. package/build/templates/claude-commands/skill-optimize.md +140 -0
  10. package/build/templates/claude-commands/test-generate.md +45 -0
  11. package/build/templates/claude-skills/nest-server-generator/SKILL.md +372 -1314
  12. package/build/templates/claude-skills/nest-server-generator/configuration.md +279 -0
  13. package/build/templates/claude-skills/nest-server-generator/declare-keyword-warning.md +124 -0
  14. package/build/templates/claude-skills/nest-server-generator/description-management.md +217 -0
  15. package/build/templates/claude-skills/nest-server-generator/examples.md +131 -5
  16. package/build/templates/claude-skills/nest-server-generator/quality-review.md +855 -0
  17. package/build/templates/claude-skills/nest-server-generator/reference.md +67 -13
  18. package/build/templates/claude-skills/nest-server-generator/security-rules.md +358 -0
  19. package/build/templates/claude-skills/story-tdd/SKILL.md +1173 -0
  20. package/build/templates/claude-skills/story-tdd/code-quality.md +266 -0
  21. package/build/templates/claude-skills/story-tdd/database-indexes.md +173 -0
  22. package/build/templates/claude-skills/story-tdd/examples.md +1332 -0
  23. package/build/templates/claude-skills/story-tdd/reference.md +1180 -0
  24. package/build/templates/claude-skills/story-tdd/security-review.md +299 -0
  25. package/package.json +1 -1
@@ -0,0 +1,299 @@
1
+ ---
2
+ name: story-tdd-security-review
3
+ version: 1.0.0
4
+ description: Security review checklist for Test-Driven Development - ensures no vulnerabilities are introduced
5
+ ---
6
+
7
+ # 🔐 Security Review Checklist
8
+
9
+ **CRITICAL: Perform security review before final testing!**
10
+
11
+ **ALWAYS review all code changes for security vulnerabilities before marking complete.**
12
+
13
+ Security issues can be introduced during implementation without realizing it. A systematic review prevents:
14
+ - Unauthorized access to data
15
+ - Privilege escalation
16
+ - Data leaks
17
+ - Injection attacks
18
+ - Authentication bypasses
19
+
20
+ ---
21
+
22
+ ## Security Checklist
23
+
24
+ ### 1. Authentication & Authorization
25
+
26
+ ✅ **Check decorators are NOT weakened:**
27
+
28
+ ```typescript
29
+ // ❌ WRONG: Removing security to make tests pass
30
+ // OLD:
31
+ @Restricted(RoleEnum.ADMIN)
32
+ async deleteUser(id: string) { ... }
33
+
34
+ // NEW (DANGEROUS):
35
+ async deleteUser(id: string) { ... } // ⚠️ No restriction!
36
+
37
+ // ✅ CORRECT: Keep or strengthen security
38
+ @Restricted(RoleEnum.ADMIN)
39
+ async deleteUser(id: string) { ... }
40
+ ```
41
+
42
+ ✅ **Verify @Roles decorators:**
43
+
44
+ ```typescript
45
+ // ❌ WRONG: Making endpoint too permissive
46
+ @Roles(RoleEnum.S_USER) // Everyone can delete!
47
+ async deleteOrder(id: string) { ... }
48
+
49
+ // ✅ CORRECT: Proper role restriction
50
+ @Roles(RoleEnum.ADMIN) // Only admins can delete
51
+ async deleteOrder(id: string) { ... }
52
+ ```
53
+
54
+ ✅ **Check ownership verification:**
55
+
56
+ ```typescript
57
+ // ❌ WRONG: No ownership check
58
+ async updateProfile(userId: string, data: UpdateProfileInput, currentUser: User) {
59
+ return this.userService.update(userId, data); // Any user can update any profile!
60
+ }
61
+
62
+ // ✅ CORRECT: Verify ownership or admin role
63
+ async updateProfile(userId: string, data: UpdateProfileInput, currentUser: User) {
64
+ // Check if user is updating their own profile or is admin
65
+ if (userId !== currentUser.id && !currentUser.roles.includes(RoleEnum.ADMIN)) {
66
+ throw new ForbiddenException('Cannot update other users');
67
+ }
68
+ return this.userService.update(userId, data);
69
+ }
70
+ ```
71
+
72
+ ### 2. Input Validation
73
+
74
+ ✅ **Verify all inputs are validated:**
75
+
76
+ ```typescript
77
+ // ❌ WRONG: No validation
78
+ async createProduct(input: any) {
79
+ return this.productService.create(input); // Dangerous!
80
+ }
81
+
82
+ // ✅ CORRECT: Proper DTO with validation
83
+ export class CreateProductInput {
84
+ @UnifiedField({
85
+ description: 'Product name',
86
+ isOptional: false,
87
+ mongoose: { type: String, required: true, minlength: 1, maxlength: 100 }
88
+ })
89
+ name: string;
90
+
91
+ @UnifiedField({
92
+ description: 'Price',
93
+ isOptional: false,
94
+ mongoose: { type: Number, required: true, min: 0 }
95
+ })
96
+ price: number;
97
+ }
98
+ ```
99
+
100
+ ✅ **Check for injection vulnerabilities:**
101
+
102
+ ```typescript
103
+ // ❌ WRONG: Direct string interpolation in queries
104
+ async findByName(name: string) {
105
+ return this.productModel.find({ $where: `this.name === '${name}'` }); // SQL Injection!
106
+ }
107
+
108
+ // ✅ CORRECT: Parameterized queries
109
+ async findByName(name: string) {
110
+ return this.productModel.find({ name }); // Safe
111
+ }
112
+ ```
113
+
114
+ ### 3. Data Exposure
115
+
116
+ ✅ **Verify sensitive data is protected:**
117
+
118
+ ```typescript
119
+ // ❌ WRONG: Exposing passwords
120
+ export class User {
121
+ @UnifiedField({ description: 'Email' })
122
+ email: string;
123
+
124
+ @UnifiedField({ description: 'Password' })
125
+ password: string; // ⚠️ Will be exposed in API!
126
+ }
127
+
128
+ // ✅ CORRECT: Hide sensitive fields
129
+ export class User {
130
+ @UnifiedField({ description: 'Email' })
131
+ email: string;
132
+
133
+ @UnifiedField({
134
+ description: 'Password hash',
135
+ hideField: true, // ✅ Never expose in API
136
+ mongoose: { type: String, required: true }
137
+ })
138
+ password: string;
139
+ }
140
+ ```
141
+
142
+ ✅ **Check error messages don't leak data:**
143
+
144
+ ```typescript
145
+ // ❌ WRONG: Exposing sensitive info in errors
146
+ catch (error) {
147
+ throw new BadRequestException(`Query failed: ${error.message}, SQL: ${query}`);
148
+ }
149
+
150
+ // ✅ CORRECT: Generic error messages
151
+ catch (error) {
152
+ this.logger.error(`Query failed: ${error.message}`, error.stack);
153
+ throw new BadRequestException('Invalid request');
154
+ }
155
+ ```
156
+
157
+ ### 4. Authorization in Services
158
+
159
+ ✅ **Verify service methods check permissions:**
160
+
161
+ ```typescript
162
+ // ❌ WRONG: Service doesn't check who can access
163
+ async getOrder(orderId: string) {
164
+ return this.orderModel.findById(orderId); // Anyone can see any order!
165
+ }
166
+
167
+ // ✅ CORRECT: Service checks ownership or role
168
+ async getOrder(orderId: string, currentUser: User) {
169
+ const order = await this.orderModel.findById(orderId);
170
+
171
+ // Check if user owns the order or is admin
172
+ if (order.customerId !== currentUser.id && !currentUser.roles.includes(RoleEnum.ADMIN)) {
173
+ throw new ForbiddenException('Access denied');
174
+ }
175
+
176
+ return order;
177
+ }
178
+ ```
179
+
180
+ ### 5. Security Model Checks
181
+
182
+ ✅ **Verify checkSecurity methods:**
183
+
184
+ ```typescript
185
+ // In model file
186
+ async checkSecurity(user: User, mode: SecurityMode): Promise<void> {
187
+ // ❌ WRONG: No security check
188
+ return;
189
+
190
+ // ✅ CORRECT: Proper security implementation
191
+ if (mode === SecurityMode.CREATE && !user.roles.includes(RoleEnum.ADMIN)) {
192
+ throw new ForbiddenException('Only admins can create');
193
+ }
194
+
195
+ if (mode === SecurityMode.UPDATE && this.createdBy !== user.id && !user.roles.includes(RoleEnum.ADMIN)) {
196
+ throw new ForbiddenException('Can only update own items');
197
+ }
198
+ }
199
+ ```
200
+
201
+ ### 6. Cross-Cutting Concerns
202
+
203
+ ✅ **Rate limiting for sensitive endpoints:**
204
+ - Password reset endpoints
205
+ - Authentication endpoints
206
+ - Payment processing
207
+ - Email sending
208
+
209
+ ✅ **HTTPS/TLS enforcement (production)**
210
+
211
+ ✅ **Proper CORS configuration**
212
+
213
+ ✅ **No hardcoded secrets or API keys**
214
+
215
+ ---
216
+
217
+ ## Security Decision Tree
218
+
219
+ ```
220
+ Code changes made?
221
+
222
+ ├─► Modified @Restricted or @Roles?
223
+ │ └─► ⚠️ CRITICAL: Verify this was intentional and justified
224
+
225
+ ├─► New endpoint added?
226
+ │ └─► ✅ Ensure proper authentication + authorization decorators
227
+
228
+ ├─► Service method modified?
229
+ │ └─► ✅ Verify ownership checks still in place
230
+
231
+ ├─► New input/query parameters?
232
+ │ └─► ✅ Ensure validation and sanitization
233
+
234
+ └─► Sensitive data accessed?
235
+ └─► ✅ Verify access control and data hiding
236
+ ```
237
+
238
+ ---
239
+
240
+ ## Red Flags - STOP and Review
241
+
242
+ 🚩 **Authentication/Authorization:**
243
+ - @Restricted decorator removed or changed
244
+ - @Roles changed to more permissive role
245
+ - Endpoints without authentication
246
+ - Missing ownership checks
247
+
248
+ 🚩 **Data Security:**
249
+ - Sensitive fields not marked with hideField
250
+ - Password or token fields exposed
251
+ - User data accessible without permission check
252
+ - Error messages revealing internal details
253
+
254
+ 🚩 **Input Validation:**
255
+ - Missing validation decorators
256
+ - Any type used instead of DTO
257
+ - Direct use of user input in queries
258
+ - No sanitization of string inputs
259
+
260
+ 🚩 **Business Logic:**
261
+ - Bypassing security checks "for convenience"
262
+ - Commented out authorization code
263
+ - Admin-only actions available to regular users
264
+ - Price/amount manipulation possible
265
+
266
+ ---
267
+
268
+ ## If ANY Red Flag Found
269
+
270
+ 1. **STOP implementation**
271
+ 2. **Fix the security issue immediately**
272
+ 3. **Review surrounding code for similar issues**
273
+ 4. **Re-run security checklist**
274
+ 5. **Update tests to verify security works**
275
+
276
+ ---
277
+
278
+ ## Remember
279
+
280
+ - **Security > Convenience**
281
+ - **Better to over-restrict than under-restrict**
282
+ - **Always preserve existing security mechanisms**
283
+ - **When in doubt, ask the developer**
284
+
285
+ ---
286
+
287
+ ## Quick Security Checklist
288
+
289
+ Before marking complete:
290
+
291
+ - [ ] **@Restricted/@Roles decorators NOT removed or weakened**
292
+ - [ ] **Ownership checks in place (users can only access own data)**
293
+ - [ ] **All inputs validated with proper DTOs**
294
+ - [ ] **Sensitive fields marked with hideField: true**
295
+ - [ ] **No SQL/NoSQL injection vulnerabilities**
296
+ - [ ] **Error messages don't expose sensitive data**
297
+ - [ ] **checkSecurity methods implemented in models**
298
+ - [ ] **Authorization tests pass**
299
+ - [ ] **No hardcoded secrets or credentials**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lenne.tech/cli",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "lenne.Tech CLI: lt",
5
5
  "keywords": [
6
6
  "lenne.Tech",