ginskill-init 2.7.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/.wrangler/cache/pages.json +4 -0
- package/.wrangler/cache/wrangler-account.json +6 -0
- package/DEVELOPMENT.md +510 -0
- package/README.md +104 -0
- package/agents/developer.md +56 -0
- package/agents/frontend-design.md +69 -0
- package/agents/mobile-reviewer.md +36 -0
- package/agents/review-code.md +49 -0
- package/agents/security-scanner.md +50 -0
- package/agents/tester.md +72 -0
- package/bin/cli.js +461 -0
- package/landing/ai-build-ai.png +0 -0
- package/landing/index.html +1495 -0
- package/landing/logo.png +0 -0
- package/package.json +37 -0
- package/skills/active-life-dev/SKILL.md +157 -0
- package/skills/active-life-dev/docs/auth.md +187 -0
- package/skills/active-life-dev/docs/customers.md +216 -0
- package/skills/active-life-dev/docs/integrations.md +209 -0
- package/skills/active-life-dev/docs/inventory.md +192 -0
- package/skills/active-life-dev/docs/modules.md +181 -0
- package/skills/active-life-dev/docs/orders.md +180 -0
- package/skills/active-life-dev/docs/patterns.md +319 -0
- package/skills/active-life-dev/docs/products.md +216 -0
- package/skills/active-life-dev/docs/schema.md +502 -0
- package/skills/active-life-dev/docs/setup.md +169 -0
- package/skills/active-life-dev/docs/vouchers.md +144 -0
- package/skills/ai-asset-generator/SKILL.md +247 -0
- package/skills/ai-asset-generator/docs/gen-image.md +274 -0
- package/skills/ai-asset-generator/docs/genvideo.md +341 -0
- package/skills/ai-asset-generator/docs/remove-background.md +19 -0
- package/skills/ai-asset-generator/lib/bg-remove.mjs +34 -0
- package/skills/ai-asset-generator/lib/env.mjs +48 -0
- package/skills/ai-asset-generator/lib/kie-client.mjs +100 -0
- package/skills/ai-build-ai/SKILL.md +127 -0
- package/skills/ai-build-ai/docs/agent-teams.md +293 -0
- package/skills/ai-build-ai/docs/checkpointing.md +161 -0
- package/skills/ai-build-ai/docs/create-agent.md +399 -0
- package/skills/ai-build-ai/docs/create-mcp.md +395 -0
- package/skills/ai-build-ai/docs/create-skill.md +299 -0
- package/skills/ai-build-ai/docs/headless-mode.md +614 -0
- package/skills/ai-build-ai/docs/hooks.md +578 -0
- package/skills/ai-build-ai/docs/memory-claude-md.md +375 -0
- package/skills/ai-build-ai/docs/output-styles.md +208 -0
- package/skills/ai-build-ai/docs/overview.md +162 -0
- package/skills/ai-build-ai/docs/permissions.md +391 -0
- package/skills/ai-build-ai/docs/plugins.md +396 -0
- package/skills/ai-build-ai/docs/sandbox.md +262 -0
- package/skills/ai-build-ai/docs/team-lead-workflow.md +648 -0
- package/skills/ant-design/SKILL.md +323 -0
- package/skills/ant-design/docs/components.md +160 -0
- package/skills/ant-design/docs/data-entry.md +406 -0
- package/skills/ant-design/docs/display.md +594 -0
- package/skills/ant-design/docs/feedback.md +451 -0
- package/skills/ant-design/docs/key-components.md +414 -0
- package/skills/ant-design/docs/navigation.md +310 -0
- package/skills/ant-design/docs/pro-components.md +543 -0
- package/skills/ant-design/docs/setup.md +213 -0
- package/skills/ant-design/docs/theme.md +265 -0
- package/skills/flutter-performance/SKILL.md +803 -0
- package/skills/flutter-performance/references/flutter-patterns.md +595 -0
- package/skills/icon-generator/SKILL.md +270 -0
- package/skills/mobile-app-review/SKILL.md +321 -0
- package/skills/mobile-app-review/references/apple-review.md +132 -0
- package/skills/mobile-app-review/references/google-play-review.md +203 -0
- package/skills/mongodb/SKILL.md +667 -0
- package/skills/mongodb/references/mongoose-patterns.md +368 -0
- package/skills/nestjs-architecture/SKILL.md +1086 -0
- package/skills/nestjs-architecture/references/advanced-patterns.md +590 -0
- package/skills/performance/SKILL.md +509 -0
- package/skills/react-fsd-architecture/SKILL.md +693 -0
- package/skills/react-fsd-architecture/references/fsd-patterns.md +747 -0
- package/skills/react-native-expo/SKILL.md +128 -0
- package/skills/react-native-expo/references/data-layer.md +252 -0
- package/skills/react-native-expo/references/design-system.md +252 -0
- package/skills/react-native-expo/references/navigation.md +199 -0
- package/skills/react-native-expo/references/performance.md +229 -0
- package/skills/react-native-expo/references/platform-services.md +179 -0
- package/skills/react-native-expo/references/state-management.md +209 -0
- package/skills/react-native-expo/references/ui-patterns.md +301 -0
- package/skills/react-query/SKILL.md +685 -0
- package/skills/react-query/references/query-patterns.md +365 -0
- package/skills/review-code/SKILL.md +374 -0
- package/skills/review-code/references/clean-code-principles.md +395 -0
- package/skills/review-code/references/frontend-patterns.md +136 -0
- package/skills/review-code/references/nestjs-patterns.md +184 -0
- package/skills/security-scanner/SKILL.md +366 -0
- package/skills/security-scanner/references/nestjs-security.md +260 -0
- package/skills/security-scanner/references/nextjs-security.md +201 -0
- package/skills/security-scanner/references/react-native-security.md +199 -0
- package/skills/traefik/SKILL.md +105 -0
- package/skills/traefik/docs/advanced-routing.md +186 -0
- package/skills/traefik/docs/auth-providers.md +137 -0
- package/skills/traefik/docs/cicd-devops.md +396 -0
- package/skills/traefik/docs/core-config.md +171 -0
- package/skills/traefik/docs/distributed-config.md +96 -0
- package/skills/traefik/docs/docker-compose.md +182 -0
- package/skills/traefik/docs/ha-performance.md +177 -0
- package/skills/traefik/docs/kubernetes.md +278 -0
- package/skills/traefik/docs/middleware.md +205 -0
- package/skills/traefik/docs/monitoring.md +357 -0
- package/skills/traefik/docs/security.md +391 -0
- package/skills/traefik/docs/tls-acme.md +155 -0
- package/skills/ui-ux-pro-max/SKILL.md +377 -0
- package/skills/ui-ux-pro-max/data/charts.csv +26 -0
- package/skills/ui-ux-pro-max/data/colors.csv +97 -0
- package/skills/ui-ux-pro-max/data/icons.csv +101 -0
- package/skills/ui-ux-pro-max/data/landing.csv +31 -0
- package/skills/ui-ux-pro-max/data/products.csv +97 -0
- package/skills/ui-ux-pro-max/data/react-performance.csv +45 -0
- package/skills/ui-ux-pro-max/data/stacks/astro.csv +54 -0
- package/skills/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/skills/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/skills/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
- package/skills/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/skills/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
- package/skills/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
- package/skills/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/skills/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/skills/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
- package/skills/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/skills/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/skills/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/skills/ui-ux-pro-max/data/styles.csv +68 -0
- package/skills/ui-ux-pro-max/data/typography.csv +58 -0
- package/skills/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
- package/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/skills/ui-ux-pro-max/data/web-interface.csv +31 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
# NestJS Patterns — Backend Review Reference
|
|
2
|
+
|
|
3
|
+
Quick reference for reviewing NestJS backend code.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
1. [Module Structure](#module-structure)
|
|
7
|
+
2. [Controller Conventions](#controller-conventions)
|
|
8
|
+
3. [Service Patterns](#service-patterns)
|
|
9
|
+
4. [Schema / Entity Patterns](#schema--entity-patterns)
|
|
10
|
+
5. [DTO Validation](#dto-validation)
|
|
11
|
+
6. [Error Handling](#error-handling)
|
|
12
|
+
7. [Auth & Guards](#auth--guards)
|
|
13
|
+
8. [AI Agent Patterns](#ai-agent-patterns)
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Module Structure
|
|
18
|
+
|
|
19
|
+
Every feature module follows this layout:
|
|
20
|
+
```
|
|
21
|
+
features/<name>/
|
|
22
|
+
├── <name>.module.ts # @Module declaration
|
|
23
|
+
├── <name>.controller.ts # HTTP routes
|
|
24
|
+
├── <name>.service.ts # Business logic
|
|
25
|
+
├── dto/ # class-validator DTOs
|
|
26
|
+
├── entities/ # Mongoose schemas
|
|
27
|
+
├── interfaces/ # TypeScript interfaces
|
|
28
|
+
└── __tests__/ # Jest tests (when they exist)
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Module registration in `app.module.ts` — all feature modules are imported at the root level.
|
|
32
|
+
|
|
33
|
+
## Controller Conventions
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
@Controller('items')
|
|
37
|
+
@ApiTags('Items')
|
|
38
|
+
@UseGuards(JwtAuthGuard) // Protect all routes
|
|
39
|
+
export class ItemController {
|
|
40
|
+
constructor(private readonly itemService: ItemService) {}
|
|
41
|
+
|
|
42
|
+
@Post()
|
|
43
|
+
@ApiOperation({ summary: 'Create item' })
|
|
44
|
+
create(@Body() dto: CreateItemDto, @CurrentUser() user: User) {
|
|
45
|
+
return this.itemService.create(dto, user);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Review checklist:
|
|
51
|
+
- Controllers should be thin — validate input, delegate to service, return response (SRP)
|
|
52
|
+
- No business logic, DB calls, or side effects in controllers (separation of concerns)
|
|
53
|
+
- Use `@ApiTags` and `@ApiOperation` for Swagger docs
|
|
54
|
+
- Use `@UseGuards(JwtAuthGuard)` for protected routes
|
|
55
|
+
- Use `@CurrentUser()` decorator (from shared) to get authenticated user
|
|
56
|
+
- Use proper HTTP methods and status codes
|
|
57
|
+
- Controller methods should be <15 lines — if longer, logic belongs in the service
|
|
58
|
+
- Avoid catch blocks in controllers — let exception filters handle errors
|
|
59
|
+
|
|
60
|
+
## Service Patterns
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
@Injectable()
|
|
64
|
+
export class ItemService {
|
|
65
|
+
constructor(
|
|
66
|
+
@InjectModel(Item.name) private itemModel: Model<ItemDocument>,
|
|
67
|
+
private readonly mediaService: MediaService,
|
|
68
|
+
) {}
|
|
69
|
+
|
|
70
|
+
async create(dto: CreateItemDto, user: User): Promise<Item> {
|
|
71
|
+
// Business logic here
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Review checklist:
|
|
77
|
+
- Services own business logic, not controllers (SRP)
|
|
78
|
+
- Inject dependencies through constructor (DIP) — never use `new` for services or `moduleRef.get()`
|
|
79
|
+
- Use proper Mongoose model injection
|
|
80
|
+
- Return typed responses — avoid `any`, use explicit return types on public methods
|
|
81
|
+
- Handle errors with NestJS exceptions (`NotFoundException`, `BadRequestException`, etc.)
|
|
82
|
+
- Keep services focused: <200 lines, <10 public methods. Split if growing beyond this (SRP)
|
|
83
|
+
- Use early returns / guard clauses instead of deep nesting
|
|
84
|
+
- Extract repeated query patterns to private helper methods (DRY)
|
|
85
|
+
- Prefer composition over inheritance — inject other services rather than extending base classes
|
|
86
|
+
- Avoid side effects in methods that read data (query methods shouldn't mutate state)
|
|
87
|
+
|
|
88
|
+
## Schema / Entity Patterns
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
@Schema({ timestamps: true, collection: 'items' })
|
|
92
|
+
export class Item {
|
|
93
|
+
@Prop({ required: true })
|
|
94
|
+
name: string;
|
|
95
|
+
|
|
96
|
+
@Prop({ type: mongoose.Schema.Types.ObjectId, ref: 'User', required: true, index: true })
|
|
97
|
+
userId: mongoose.Types.ObjectId;
|
|
98
|
+
|
|
99
|
+
@Prop({ type: [String], default: [] })
|
|
100
|
+
tags: string[];
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Review checklist:
|
|
105
|
+
- Use `{ timestamps: true }` for automatic createdAt/updatedAt
|
|
106
|
+
- Add `required: true` on non-optional fields
|
|
107
|
+
- Add `index: true` on fields used in queries
|
|
108
|
+
- Use `ref` for cross-document references
|
|
109
|
+
- Specify `collection` name explicitly
|
|
110
|
+
|
|
111
|
+
## DTO Validation
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
export class CreateItemDto {
|
|
115
|
+
@IsString()
|
|
116
|
+
@IsNotEmpty()
|
|
117
|
+
name: string;
|
|
118
|
+
|
|
119
|
+
@IsOptional()
|
|
120
|
+
@IsArray()
|
|
121
|
+
@IsString({ each: true })
|
|
122
|
+
tags?: string[];
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Review checklist:
|
|
127
|
+
- All input DTOs should use class-validator decorators
|
|
128
|
+
- Mark optional fields with `@IsOptional()`
|
|
129
|
+
- Use `@Transform()` for sanitization when needed
|
|
130
|
+
- Separate Create, Update, and Query DTOs
|
|
131
|
+
|
|
132
|
+
## Error Handling
|
|
133
|
+
|
|
134
|
+
The project should use a global `HttpExceptionFilter` in `core/exception/`.
|
|
135
|
+
|
|
136
|
+
In services, throw typed NestJS exceptions:
|
|
137
|
+
```typescript
|
|
138
|
+
throw new NotFoundException('Item not found');
|
|
139
|
+
throw new BadRequestException('Invalid input');
|
|
140
|
+
throw new UnauthorizedException('Not authorized');
|
|
141
|
+
throw new ConflictException('Item already exists');
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Review checklist:
|
|
145
|
+
- Never swallow errors silently (empty catch blocks) — this is a CRITICAL code smell
|
|
146
|
+
- Use typed exceptions, not generic `Error` — exception type communicates intent
|
|
147
|
+
- Log errors before throwing when there's useful context
|
|
148
|
+
- Handle async errors — all async functions should have try/catch or let exceptions propagate meaningfully
|
|
149
|
+
- **Fail fast**: Validate inputs at the boundary (controller/DTO), don't check deep in business logic
|
|
150
|
+
- **Consistent strategy per layer**: Controllers use HTTP exceptions, services use domain exceptions, repositories propagate DB errors
|
|
151
|
+
- Avoid `try/catch` around every line — wrap logical units, not individual statements
|
|
152
|
+
- Include actionable context in error messages: `Item ${id} not found` not just `Not found`
|
|
153
|
+
|
|
154
|
+
## Auth & Guards
|
|
155
|
+
|
|
156
|
+
- `JwtAuthGuard` — Standard JWT Bearer token guard
|
|
157
|
+
- `@CurrentUser()` — Extracts user from JWT payload
|
|
158
|
+
- Role-based guards for admin/privileged operations
|
|
159
|
+
|
|
160
|
+
Review checklist:
|
|
161
|
+
- All non-public endpoints should have `@UseGuards(JwtAuthGuard)`
|
|
162
|
+
- User-specific queries should filter by `userId` from `@CurrentUser()`
|
|
163
|
+
- No endpoints should expose other users' data without admin check
|
|
164
|
+
|
|
165
|
+
## AI Agent Patterns
|
|
166
|
+
|
|
167
|
+
AI agent modules have their own internal architecture:
|
|
168
|
+
|
|
169
|
+
```
|
|
170
|
+
ai-agents/core/
|
|
171
|
+
├── llm/services/ # Abstraction layer for all LLM calls
|
|
172
|
+
├── providers/ # Provider configs (OpenAI, Gemini, Vertex AI)
|
|
173
|
+
├── graph/ # LangGraph state machine
|
|
174
|
+
├── tools/ # Custom tools the agent can call
|
|
175
|
+
├── knowledge/ # Knowledge base (embeddings → vector DB)
|
|
176
|
+
└── config/ # System prompts, tool configs
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Review checklist:
|
|
180
|
+
- LLM calls should go through the abstraction layer, not direct SDK calls
|
|
181
|
+
- New tools should follow the existing pattern (DynamicStructuredTool)
|
|
182
|
+
- System prompts should use reusable sections from config
|
|
183
|
+
- Token limits and timeouts should be configured, not hardcoded
|
|
184
|
+
- Retry logic should use circuit breakers
|
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: security-scanner
|
|
3
|
+
description: |
|
|
4
|
+
**Security Scanner**: Comprehensive security audit for fullstack monorepos — NestJS backend, Next.js frontend, and React Native mobile app. Aligned with OWASP Top 10:2025, OWASP Top 10 for LLM Apps 2025, and OWASP Mobile Top 10. Scans for vulnerabilities, secrets exposure, auth misconfigurations, injection risks, supply chain threats, LLM/AI agent risks, and platform-specific security issues.
|
|
5
|
+
- MANDATORY TRIGGERS: security scan, security audit, security review, check security, vulnerability scan, find vulnerabilities, check secrets, secret leak, hardcoded password, hardcoded key, OWASP, injection, XSS, CSRF, auth security, token security, check dependencies, dependency audit, CVE, security headers, CORS check, CSP check, penetration test, pen test, security checklist, supply chain, prompt injection, LLM security
|
|
6
|
+
- Use this skill whenever the user mentions anything about security, vulnerabilities, secrets, or wants to audit code for safety issues. Also trigger when the user asks about CORS, CSP headers, auth guards, token handling, API key exposure, dependency vulnerabilities, supply chain risks, prompt injection, or AI agent security — even casual mentions like "is this secure?" or "any security issues?".
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Security Scanner
|
|
10
|
+
|
|
11
|
+
Scan fullstack monorepos for security vulnerabilities with deep awareness of the project's architecture. Aligned with **OWASP Top 10:2025**, **OWASP Top 10 for LLM Applications 2025**, and **OWASP Mobile Top 10 2024**. This skill understands modern NestJS/Next.js/React Native security posture.
|
|
12
|
+
|
|
13
|
+
## Project Security Architecture (Current State)
|
|
14
|
+
|
|
15
|
+
### What's Already Good
|
|
16
|
+
- JWT with 15min access / 7d refresh tokens (`core/config/jwt.config.ts`)
|
|
17
|
+
- Global `ValidationPipe` with `whitelist: true` + `forbidNonWhitelisted: true`
|
|
18
|
+
- Mobile uses `react-native-keychain` (OS-level secure storage, not AsyncStorage)
|
|
19
|
+
- Single-flight token refresh pattern prevents race conditions
|
|
20
|
+
- Swagger protected with basic auth middleware
|
|
21
|
+
- HSTS enabled (1 year, preload)
|
|
22
|
+
- Signed httpOnly cookies for token transport
|
|
23
|
+
|
|
24
|
+
### Known Risks (Flagged)
|
|
25
|
+
- CSP allows `'unsafe-inline'` in both `scriptSrc` and `styleSrc`
|
|
26
|
+
- `connectSrc: ["'self'", 'https://*']` — too permissive
|
|
27
|
+
- CORS defaults to `['*']` in non-production environments
|
|
28
|
+
- `.env.example` may contain reusable example secrets
|
|
29
|
+
- `strictNullChecks: false` increases null-related vulnerability surface
|
|
30
|
+
|
|
31
|
+
## OWASP Alignment
|
|
32
|
+
|
|
33
|
+
### OWASP Top 10:2025 — Web Application Risks
|
|
34
|
+
Map every finding to these categories where applicable:
|
|
35
|
+
|
|
36
|
+
| ID | Category | What to Check |
|
|
37
|
+
|----|----------|---------------------|
|
|
38
|
+
| A01 | Broken Access Control | IDOR in user endpoints, auth guard gaps, RBAC bypass |
|
|
39
|
+
| A02 | Security Misconfiguration | CORS wildcard, CSP unsafe-inline, Helmet config |
|
|
40
|
+
| A03 | Software Supply Chain Failures | npm dependencies, lockfile integrity, lifecycle scripts |
|
|
41
|
+
| A04 | Cryptographic Failures | JWT signing, token storage, TLS configuration |
|
|
42
|
+
| A05 | Injection | NoSQL injection (MongoDB), XSS, command injection |
|
|
43
|
+
| A06 | Insecure Design | Missing rate limiting, no abuse detection on AI endpoints |
|
|
44
|
+
| A07 | Authentication Failures | Token handling, refresh flow, session management |
|
|
45
|
+
| A08 | Software/Data Integrity Failures | CI/CD pipeline, unsigned OTA updates, unverified deps |
|
|
46
|
+
| A09 | Security Logging & Alerting | Missing audit logs, no alerting on suspicious activity |
|
|
47
|
+
| A10 | Mishandling Exceptional Conditions | Uncaught errors leaking stack traces, fail-open patterns |
|
|
48
|
+
|
|
49
|
+
### OWASP Top 10 for LLM Applications 2025
|
|
50
|
+
The project uses LangChain + LangGraph agents with multi-provider LLMs — these risks are critical:
|
|
51
|
+
|
|
52
|
+
| ID | Category | Check |
|
|
53
|
+
|----|----------|-------|
|
|
54
|
+
| LLM01 | Prompt Injection | User input sanitized before LLM prompts? System prompts hidden? |
|
|
55
|
+
| LLM02 | Sensitive Info Disclosure | PII leaked in LLM responses? Conversation history access controlled? |
|
|
56
|
+
| LLM03 | Supply Chain | LLM package versions pinned? Model provenance verified? |
|
|
57
|
+
| LLM05 | Improper Output Handling | AI-generated content sanitized before rendering/storing? |
|
|
58
|
+
| LLM06 | Excessive Agency | LangGraph tools sandboxed? Permissions scoped to minimum? |
|
|
59
|
+
| LLM07 | System Prompt Leakage | System prompts retrievable by users? |
|
|
60
|
+
| LLM08 | Vector/Embedding Weaknesses | Qdrant access controlled? Embedding poisoning possible? |
|
|
61
|
+
| LLM10 | Unbounded Consumption | Token limits on AI calls? Rate limiting on AI endpoints? |
|
|
62
|
+
|
|
63
|
+
### OWASP Mobile Top 10 2024
|
|
64
|
+
For React Native (mobile app):
|
|
65
|
+
|
|
66
|
+
| ID | Category | Check |
|
|
67
|
+
|----|----------|-------|
|
|
68
|
+
| M1 | Improper Credential Usage | Keychain used? No hardcoded credentials? |
|
|
69
|
+
| M2 | Inadequate Supply Chain | Third-party SDK audit? Dependency scanning? |
|
|
70
|
+
| M3 | Insecure Auth/AuthZ | Token rotation? Biometric for sensitive actions? |
|
|
71
|
+
| M4 | Insufficient Input/Output Validation | Deep link params validated? WebView input sanitized? |
|
|
72
|
+
| M5 | Insecure Communication | Certificate pinning? No cleartext traffic? |
|
|
73
|
+
| M8 | Security Misconfiguration | Debug flags stripped? ProGuard enabled? |
|
|
74
|
+
| M9 | Insecure Data Storage | AsyncStorage audit? Sensitive data encrypted? |
|
|
75
|
+
| M10 | Insufficient Cryptography | Proper key management? Strong algorithms? |
|
|
76
|
+
|
|
77
|
+
## Scan Process
|
|
78
|
+
|
|
79
|
+
When asked to scan, follow this order. Adapt scope based on what the user asks — they might want a full audit or just one area.
|
|
80
|
+
|
|
81
|
+
### 1. Determine Scope
|
|
82
|
+
|
|
83
|
+
Ask (or infer) what they want scanned:
|
|
84
|
+
- **Full audit** — All platforms, all categories
|
|
85
|
+
- **Backend only** — NestJS auth, injection, config, dependencies
|
|
86
|
+
- **Frontend only** — Next.js XSS, auth, API routes
|
|
87
|
+
- **Mobile only** — React Native storage, certificate pinning, deep links
|
|
88
|
+
- **Specific area** — Just auth, just secrets, just dependencies, etc.
|
|
89
|
+
|
|
90
|
+
### 2. Run Automated Checks
|
|
91
|
+
|
|
92
|
+
Use the scripts in `scripts/` to get quick automated results first:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
# Full security scan (all platforms)
|
|
96
|
+
./scripts/security-scan.sh all
|
|
97
|
+
|
|
98
|
+
# Platform-specific
|
|
99
|
+
./scripts/security-scan.sh backend
|
|
100
|
+
./scripts/security-scan.sh frontend
|
|
101
|
+
./scripts/security-scan.sh mobile
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
The script checks for: hardcoded secrets, `any` type abuse, console.log of sensitive data, missing auth guards, unsafe eval, dependency vulnerabilities, and more.
|
|
105
|
+
|
|
106
|
+
#### Deep Credential Scanning
|
|
107
|
+
|
|
108
|
+
For comprehensive credential and API key leak detection, use the dedicated credential scanner:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
# Scan entire project for leaked credentials (100+ patterns)
|
|
112
|
+
./scripts/credential-scanner.sh /path/to/project
|
|
113
|
+
|
|
114
|
+
# Scan with JSON output for CI/CD integration
|
|
115
|
+
./scripts/credential-scanner.sh /path/to/project --format json --output report.json
|
|
116
|
+
|
|
117
|
+
# Scan only critical/high severity
|
|
118
|
+
./scripts/credential-scanner.sh /path/to/project --severity high
|
|
119
|
+
|
|
120
|
+
# Scan specific category (cloud, payment, ai, vcs, etc.)
|
|
121
|
+
./scripts/credential-scanner.sh /path/to/project --category cloud
|
|
122
|
+
|
|
123
|
+
# Skip git history scanning (faster)
|
|
124
|
+
./scripts/credential-scanner.sh /path/to/project --no-git-history
|
|
125
|
+
|
|
126
|
+
# Run the test suite to validate all patterns
|
|
127
|
+
./scripts/test-secret-detection.sh
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
The credential scanner uses a **multi-pass engine**:
|
|
131
|
+
1. **Direct pattern matching** — 100+ provider-specific regex patterns (AWS, GCP, Stripe, GitHub, OpenAI, etc.)
|
|
132
|
+
2. **Contextual pattern matching** — patterns that need surrounding context to reduce false positives
|
|
133
|
+
3. **Entropy analysis** — Shannon entropy calculation on matched strings to distinguish real secrets from placeholders
|
|
134
|
+
4. **File-based checks** — `.env` files, `.pem` keys, `credentials.json`, Docker/CI configs
|
|
135
|
+
5. **Git history scanning** — finds secrets ever committed then deleted
|
|
136
|
+
|
|
137
|
+
All patterns are defined in `scripts/secret-patterns.sh` (sourceable pattern database).
|
|
138
|
+
Test coverage is in `scripts/test-fixtures.sh` + `scripts/test-secret-detection.sh`.
|
|
139
|
+
|
|
140
|
+
### 3. Manual Review by Category
|
|
141
|
+
|
|
142
|
+
After automated checks, do targeted manual review based on findings.
|
|
143
|
+
|
|
144
|
+
#### Category 1: Secrets & Credentials (CRITICAL)
|
|
145
|
+
|
|
146
|
+
Scan for leaked secrets, hardcoded keys, and exposed credentials. **Use `credential-scanner.sh` for comprehensive automated detection.**
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
# Run the dedicated credential scanner first
|
|
150
|
+
./scripts/credential-scanner.sh /path/to/project --format json --output cred-report.json
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
The credential scanner covers **100+ patterns** across these provider categories:
|
|
154
|
+
|
|
155
|
+
| Category | Patterns | Examples |
|
|
156
|
+
|----------|----------|----------|
|
|
157
|
+
| **Cloud** | AWS, GCP, Azure | `AKIA...`, `AIza...`, Azure connection strings |
|
|
158
|
+
| **Payment** | Stripe, Square, PayPal | `sk_live_...`, `sq0atp-...` |
|
|
159
|
+
| **AI/ML** | OpenAI, Anthropic, HuggingFace | `sk-proj-...`, `sk-ant-...`, `hf_...` |
|
|
160
|
+
| **VCS/CI** | GitHub, GitLab, CircleCI | `ghp_...`, `glpat-...`, `github_pat_...` |
|
|
161
|
+
| **Communication** | Slack, Discord, Twilio, SendGrid | `xoxb-...`, `SG....`, `AC...` |
|
|
162
|
+
| **Database** | MongoDB, PostgreSQL, MySQL, Redis | Connection strings with embedded passwords |
|
|
163
|
+
| **Infrastructure** | Cloudflare, DigitalOcean, Vercel, Fly.io | `dop_v1_...`, `fo1_...` |
|
|
164
|
+
| **Crypto** | RSA, EC, OpenSSH, PGP private keys | `-----BEGIN ... PRIVATE KEY-----` |
|
|
165
|
+
| **Auth** | Firebase, Supabase, Auth0, Clerk | FCM keys, JWT tokens |
|
|
166
|
+
| **Registry** | NPM, PyPI, RubyGems | `npm_...`, `pypi-...` |
|
|
167
|
+
| **SaaS** | Linear, Notion, Doppler, PlanetScale | `lin_api_...`, `secret_...`, `dp.pt....` |
|
|
168
|
+
| **Shopify** | Access, custom app, shared secret | `shpat_...`, `shpca_...` |
|
|
169
|
+
| **Generic** | Passwords, secrets, tokens, Bearer, Basic | Entropy-based detection |
|
|
170
|
+
|
|
171
|
+
**Additional manual checks:**
|
|
172
|
+
- Secrets in `.env.example` that look real (not placeholder-ish)
|
|
173
|
+
- Secrets logged to console or error responses
|
|
174
|
+
- Secrets in URL query parameters
|
|
175
|
+
- Secrets in frontend bundles (`NEXT_PUBLIC_*`, `EXPO_PUBLIC_*`)
|
|
176
|
+
- Check git history for deleted secret files: `git log --all --diff-filter=D -- "*.env" "*.pem" "*.key"`
|
|
177
|
+
|
|
178
|
+
#### Category 2: Authentication & Authorization
|
|
179
|
+
|
|
180
|
+
**Backend (NestJS):**
|
|
181
|
+
- Are all non-public endpoints guarded with `@UseGuards(JwtAuthGuard)`?
|
|
182
|
+
- Do user-specific queries filter by `userId` from `@CurrentUser()`?
|
|
183
|
+
- Can users access/modify other users' data? (IDOR)
|
|
184
|
+
- Is the admin bypass in `roles.guard.ts` properly restricted?
|
|
185
|
+
- Are refresh tokens properly invalidated on logout?
|
|
186
|
+
- Token expiration: are access/refresh token lifetimes enforced?
|
|
187
|
+
|
|
188
|
+
**Frontend (Next.js):**
|
|
189
|
+
- Are API routes in `src/app/api/` checking auth before processing?
|
|
190
|
+
- Are tokens stored in httpOnly cookies (not localStorage)?
|
|
191
|
+
- Is there CSRF protection on state-changing requests?
|
|
192
|
+
|
|
193
|
+
**Mobile (React Native):**
|
|
194
|
+
- Tokens stored in Keychain/Keystore via `react-native-keychain`? (currently yes)
|
|
195
|
+
- Is biometric auth implemented for sensitive actions?
|
|
196
|
+
- Are deep link handlers validating the source?
|
|
197
|
+
|
|
198
|
+
Read `references/auth-security.md` for detailed checklist.
|
|
199
|
+
|
|
200
|
+
#### Category 3: Injection Attacks
|
|
201
|
+
|
|
202
|
+
**NoSQL Injection (MongoDB):**
|
|
203
|
+
- Are Mongoose queries using user input directly in `$where`, `$regex`, or `$expr`?
|
|
204
|
+
- Is `JSON.parse()` used on user input without validation?
|
|
205
|
+
- Does `forbidNonWhitelisted: true` catch all inputs? (check file uploads, query params)
|
|
206
|
+
|
|
207
|
+
**XSS:**
|
|
208
|
+
- Is user-generated content rendered with `dangerouslySetInnerHTML`?
|
|
209
|
+
- Are Markdown/rich text inputs sanitized before storage and display?
|
|
210
|
+
- Do AI-generated responses get sanitized before rendering?
|
|
211
|
+
|
|
212
|
+
**Command Injection:**
|
|
213
|
+
- Does any code use `exec()`, `spawn()`, or `eval()` with user input?
|
|
214
|
+
- Playwright scraper — is the URL validated before navigation?
|
|
215
|
+
|
|
216
|
+
#### Category 4: Security Headers & CORS
|
|
217
|
+
|
|
218
|
+
**Current config** (`core/config/helmet.config.ts` and `cors.config.ts`):
|
|
219
|
+
|
|
220
|
+
Check these against best practices:
|
|
221
|
+
- CSP should NOT have `'unsafe-inline'` (currently does)
|
|
222
|
+
- `connectSrc` should list specific domains, not `https://*`
|
|
223
|
+
- CORS should not default to `['*']` even in development
|
|
224
|
+
- X-Frame-Options: should be `DENY` or `SAMEORIGIN`
|
|
225
|
+
- Referrer-Policy: should be `strict-origin-when-cross-origin`
|
|
226
|
+
|
|
227
|
+
Read `references/headers-checklist.md` for the full checklist.
|
|
228
|
+
|
|
229
|
+
#### Category 5: Dependencies & Supply Chain (OWASP A03:2025)
|
|
230
|
+
|
|
231
|
+
This is newly elevated in OWASP 2025. Treat supply chain as a first-class risk.
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
# Vulnerability scan
|
|
235
|
+
cd <backend-dir> && npm audit
|
|
236
|
+
cd <frontend-dir> && npm audit
|
|
237
|
+
cd <mobile-dir> && npm audit
|
|
238
|
+
|
|
239
|
+
# Verify package signatures (npm 9+)
|
|
240
|
+
npm audit signatures
|
|
241
|
+
|
|
242
|
+
# Check for lifecycle scripts that download code
|
|
243
|
+
./scripts/security-scan.sh supply-chain
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
**What to check:**
|
|
247
|
+
- Known CVEs in dependencies (`npm audit`)
|
|
248
|
+
- Lockfile integrity — are lockfiles committed? (`pnpm-lock.yaml`, `package-lock.json`)
|
|
249
|
+
- Lifecycle scripts — `preinstall`/`postinstall` that download or execute code
|
|
250
|
+
- Typosquatting — dependency names close to popular packages
|
|
251
|
+
- Dependency signature verification (`npm audit signatures`)
|
|
252
|
+
- SBOM generation for compliance (`npm sbom --sbom-format cyclonedx`)
|
|
253
|
+
- NestJS-specific: **CVE-2025-54782** — RCE in `@nestjs/devtools-integration` ≤0.2.0 (unsafe `vm.runInNewContext` + missing CORS). Verify version ≥0.2.1
|
|
254
|
+
|
|
255
|
+
**Supply chain attack awareness:**
|
|
256
|
+
- The Sept 2025 "Shai-Hulud" attack compromised 18 popular npm packages (chalk, debug, etc.)
|
|
257
|
+
- Always disable lifecycle scripts by default: `npm config set ignore-scripts true`
|
|
258
|
+
- Use `--ignore-scripts` in CI/CD and explicitly allow-list needed scripts
|
|
259
|
+
|
|
260
|
+
#### Category 6: LLM/AI Agent Security (OWASP LLM Top 10)
|
|
261
|
+
|
|
262
|
+
The project has LangChain + LangGraph agents, multi-provider LLMs, and Qdrant vector DB. This category is critical.
|
|
263
|
+
|
|
264
|
+
**Prompt Injection (LLM01):**
|
|
265
|
+
- Is user input concatenated directly into LLM prompts?
|
|
266
|
+
- Are system prompts retrievable via conversation manipulation?
|
|
267
|
+
- Check `features/ai-agents/` for prompt construction patterns
|
|
268
|
+
- Multi-modal inputs (images) can contain hidden prompts
|
|
269
|
+
|
|
270
|
+
**Output Handling (LLM05):**
|
|
271
|
+
- Are AI-generated responses sanitized before rendering in frontend/mobile?
|
|
272
|
+
- Can AI output contain executable HTML/JS/markdown that bypasses sanitization?
|
|
273
|
+
- Are AI-suggested actions validated before execution?
|
|
274
|
+
|
|
275
|
+
**Excessive Agency (LLM06):**
|
|
276
|
+
- What tools can LangGraph agents call? Are they scoped to minimum permissions?
|
|
277
|
+
- Can agents access/modify resources beyond the current user's scope?
|
|
278
|
+
- Is there human-in-the-loop for destructive agent actions?
|
|
279
|
+
|
|
280
|
+
**Vector DB Security (LLM08):**
|
|
281
|
+
- Is Qdrant access authenticated?
|
|
282
|
+
- Can users poison the fashion knowledge base via injected content?
|
|
283
|
+
- Are embeddings isolated per tenant?
|
|
284
|
+
|
|
285
|
+
**Resource Limits (LLM10):**
|
|
286
|
+
- Token limits on LLM API calls?
|
|
287
|
+
- Rate limiting on AI chat endpoints?
|
|
288
|
+
- Timeout on LangGraph agent execution?
|
|
289
|
+
|
|
290
|
+
Read `references/nestjs-security.md` → "LLM/AI Agent Security" for detailed checklist.
|
|
291
|
+
|
|
292
|
+
#### Category 7: Platform-Specific
|
|
293
|
+
|
|
294
|
+
Read the platform-specific references for deeper checks:
|
|
295
|
+
- `references/nestjs-security.md` — Backend: auth, injection, rate limiting, error handling, LLM security
|
|
296
|
+
- `references/react-native-security.md` — Mobile: OWASP Mobile Top 10, secure storage, cert pinning, binary protection
|
|
297
|
+
- `references/nextjs-security.md` — Frontend: server/client boundary, API routes, CSP, dependency safety
|
|
298
|
+
|
|
299
|
+
#### Category 8: Exceptional Conditions (OWASP A10:2025)
|
|
300
|
+
|
|
301
|
+
New in OWASP 2025 — check how the app handles edge cases:
|
|
302
|
+
- Do uncaught exceptions expose stack traces in production?
|
|
303
|
+
- Do auth failures fail-open (grant access) instead of fail-closed (deny)?
|
|
304
|
+
- Are Bull queue job failures handled gracefully without data loss?
|
|
305
|
+
- Do LLM API timeouts fall back safely (no infinite retries, no credential exposure)?
|
|
306
|
+
- Are MongoDB connection failures handled without crashing the process?
|
|
307
|
+
|
|
308
|
+
### 4. Report Findings
|
|
309
|
+
|
|
310
|
+
Structure the report by severity:
|
|
311
|
+
|
|
312
|
+
```
|
|
313
|
+
🔴 CRITICAL — Exploitable now, data at risk
|
|
314
|
+
🟠 HIGH — Significant risk, should fix before next release
|
|
315
|
+
🟡 MEDIUM — Defense-in-depth improvement
|
|
316
|
+
🟢 LOW — Best practice recommendation
|
|
317
|
+
ℹ️ INFO — Observation, no action needed
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
For each finding:
|
|
321
|
+
```
|
|
322
|
+
**[SEVERITY] Title**
|
|
323
|
+
Location: file:line
|
|
324
|
+
Impact: What an attacker could do
|
|
325
|
+
Evidence: The vulnerable code
|
|
326
|
+
Fix: Concrete remediation with code example
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
### 5. Provide Fix Priority
|
|
330
|
+
|
|
331
|
+
End with a prioritized action list:
|
|
332
|
+
1. Critical fixes (do today)
|
|
333
|
+
2. High fixes (this sprint)
|
|
334
|
+
3. Medium fixes (next sprint)
|
|
335
|
+
4. Low/info (backlog)
|
|
336
|
+
|
|
337
|
+
## Recommended Tools Integration
|
|
338
|
+
|
|
339
|
+
For CI/CD pipeline integration, recommend these tools:
|
|
340
|
+
|
|
341
|
+
| Tool | Type | Use Case |
|
|
342
|
+
|------|------|----------|
|
|
343
|
+
| **Semgrep** | SAST | Custom rules for NestJS/Next.js patterns, free for open source |
|
|
344
|
+
| **npm audit** | SCA | Built-in dependency vulnerability scanning |
|
|
345
|
+
| **Socket.dev** | SCA+ | Detects malicious packages, supply chain attacks |
|
|
346
|
+
| **OWASP ZAP** | DAST | Runtime API scanning in staging |
|
|
347
|
+
| **SonarQube** | SAST | Continuous code quality + security |
|
|
348
|
+
| **Snyk** | SCA | Dependency monitoring with auto-fix PRs |
|
|
349
|
+
| **Gitleaks** | Secrets | Pre-commit hook for secret detection |
|
|
350
|
+
|
|
351
|
+
**AI-generated code note:** If the team uses AI coding assistants (Copilot, Claude, etc.), treat AI-generated code with the same scrutiny as external dependencies. Studies show ~40% of AI-generated security-sensitive code contains vulnerabilities.
|
|
352
|
+
|
|
353
|
+
## References
|
|
354
|
+
|
|
355
|
+
Platform-specific deep-dive checklists — read these when scanning a specific area:
|
|
356
|
+
|
|
357
|
+
- `references/nestjs-security.md` — Backend: auth guards, injection, rate limiting, file upload, error handling, LLM/AI agent security
|
|
358
|
+
- `references/react-native-security.md` — Mobile: OWASP Mobile Top 10, secure storage, certificate pinning, binary protection, deep links
|
|
359
|
+
- `references/nextjs-security.md` — Frontend: server/client boundary, API routes, middleware auth, env vars, CSP, dependency supply chain
|
|
360
|
+
|
|
361
|
+
**External references:**
|
|
362
|
+
- [OWASP Top 10:2025](https://owasp.org/Top10/2025/)
|
|
363
|
+
- [OWASP Top 10 for LLM Applications 2025](https://genai.owasp.org/llm-top-10/)
|
|
364
|
+
- [OWASP Mobile Top 10](https://owasp.org/www-project-mobile-top-10/)
|
|
365
|
+
- [NPM Security Cheat Sheet (OWASP)](https://cheatsheetseries.owasp.org/cheatsheets/NPM_Security_Cheat_Sheet.html)
|
|
366
|
+
- [NestJS Security Best Practices](https://dev.to/drbenzene/best-security-implementation-practices-in-nestjs-a-comprehensive-guide-2p88)
|