ginskill-init 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/README.md +77 -0
  2. package/agents/developer.md +56 -0
  3. package/agents/frontend-design.md +69 -0
  4. package/agents/mobile-reviewer.md +36 -0
  5. package/agents/review-code.md +49 -0
  6. package/agents/security-scanner.md +50 -0
  7. package/agents/tester.md +72 -0
  8. package/bin/cli.js +226 -0
  9. package/package.json +20 -0
  10. package/skills/ai-asset-generator/SKILL.md +255 -0
  11. package/skills/ai-asset-generator/docs/gen-image.md +274 -0
  12. package/skills/ai-asset-generator/docs/genvideo.md +341 -0
  13. package/skills/ai-asset-generator/docs/remove-background.md +19 -0
  14. package/skills/ai-asset-generator/generate-credit-assets.mjs +180 -0
  15. package/skills/ai-asset-generator/generate-ginbrowser-assets.mjs +242 -0
  16. package/skills/ai-asset-generator/generate-sty-icon.mjs +149 -0
  17. package/skills/ai-asset-generator/lib/bg-remove.mjs +34 -0
  18. package/skills/ai-asset-generator/lib/env.mjs +38 -0
  19. package/skills/ai-asset-generator/lib/kie-client.mjs +88 -0
  20. package/skills/ai-asset-generator/scripts/scaffold-generator.mjs +203 -0
  21. package/skills/ai-build-ai/SKILL.md +124 -0
  22. package/skills/ai-build-ai/docs/agent-teams.md +293 -0
  23. package/skills/ai-build-ai/docs/checkpointing.md +161 -0
  24. package/skills/ai-build-ai/docs/create-agent.md +399 -0
  25. package/skills/ai-build-ai/docs/create-mcp.md +395 -0
  26. package/skills/ai-build-ai/docs/create-skill.md +299 -0
  27. package/skills/ai-build-ai/docs/headless-mode.md +614 -0
  28. package/skills/ai-build-ai/docs/hooks.md +578 -0
  29. package/skills/ai-build-ai/docs/memory-claude-md.md +375 -0
  30. package/skills/ai-build-ai/docs/output-styles.md +208 -0
  31. package/skills/ai-build-ai/docs/overview.md +162 -0
  32. package/skills/ai-build-ai/docs/permissions.md +391 -0
  33. package/skills/ai-build-ai/docs/plugins.md +396 -0
  34. package/skills/ai-build-ai/docs/sandbox.md +262 -0
  35. package/skills/ai-build-ai/scripts/load-tutorial.sh +54 -0
  36. package/skills/icon-generator/SKILL.md +270 -0
  37. package/skills/mobile-app-review/SKILL.md +321 -0
  38. package/skills/mobile-app-review/references/apple-review.md +132 -0
  39. package/skills/mobile-app-review/references/google-play-review.md +203 -0
  40. package/skills/mongodb/SKILL.md +667 -0
  41. package/skills/mongodb/references/mongoose-patterns.md +368 -0
  42. package/skills/nestjs-architecture/SKILL.md +1086 -0
  43. package/skills/nestjs-architecture/references/advanced-patterns.md +590 -0
  44. package/skills/performance/SKILL.md +509 -0
  45. package/skills/react-fsd-architecture/SKILL.md +693 -0
  46. package/skills/react-fsd-architecture/references/fsd-patterns.md +747 -0
  47. package/skills/react-query/SKILL.md +685 -0
  48. package/skills/react-query/references/query-patterns.md +365 -0
  49. package/skills/review-code/SKILL.md +321 -0
  50. package/skills/review-code/references/clean-code-principles.md +395 -0
  51. package/skills/review-code/references/frontend-patterns.md +136 -0
  52. package/skills/review-code/references/nestjs-patterns.md +184 -0
  53. package/skills/review-code/scripts/check-module.sh +201 -0
  54. package/skills/review-code/scripts/deep-scan.sh +604 -0
  55. package/skills/review-code/scripts/dep-check.sh +522 -0
  56. package/skills/review-code/scripts/detect-duplicates.sh +466 -0
  57. package/skills/review-code/scripts/format-check.sh +577 -0
  58. package/skills/review-code/scripts/run-review.sh +167 -0
  59. package/skills/review-code/scripts/scan-codebase.sh +152 -0
  60. package/skills/security-scanner/SKILL.md +327 -0
  61. package/skills/security-scanner/references/nestjs-security.md +260 -0
  62. package/skills/security-scanner/references/nextjs-security.md +201 -0
  63. package/skills/security-scanner/references/react-native-security.md +199 -0
  64. package/skills/security-scanner/scripts/security-scan.sh +478 -0
  65. package/skills/ui-ux-pro-max/SKILL.md +377 -0
  66. package/skills/ui-ux-pro-max/data/charts.csv +26 -0
  67. package/skills/ui-ux-pro-max/data/colors.csv +97 -0
  68. package/skills/ui-ux-pro-max/data/icons.csv +101 -0
  69. package/skills/ui-ux-pro-max/data/landing.csv +31 -0
  70. package/skills/ui-ux-pro-max/data/products.csv +97 -0
  71. package/skills/ui-ux-pro-max/data/react-performance.csv +45 -0
  72. package/skills/ui-ux-pro-max/data/stacks/astro.csv +54 -0
  73. package/skills/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
  74. package/skills/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
  75. package/skills/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
  76. package/skills/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
  77. package/skills/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
  78. package/skills/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
  79. package/skills/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
  80. package/skills/ui-ux-pro-max/data/stacks/react.csv +54 -0
  81. package/skills/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
  82. package/skills/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
  83. package/skills/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
  84. package/skills/ui-ux-pro-max/data/stacks/vue.csv +50 -0
  85. package/skills/ui-ux-pro-max/data/styles.csv +68 -0
  86. package/skills/ui-ux-pro-max/data/typography.csv +58 -0
  87. package/skills/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
  88. package/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
  89. package/skills/ui-ux-pro-max/data/web-interface.csv +31 -0
  90. package/skills/ui-ux-pro-max/scripts/core.py +253 -0
  91. package/skills/ui-ux-pro-max/scripts/design_system.py +1067 -0
  92. package/skills/ui-ux-pro-max/scripts/search.py +114 -0
@@ -0,0 +1,167 @@
1
+ #!/usr/bin/env bash
2
+ # ─────────────────────────────────────────────────────────────
3
+ # Code Review — Automated Checks
4
+ #
5
+ # Runs ESLint, TypeScript type-check, and test suite against
6
+ # the specified target (backend, frontend, or both).
7
+ # Auto-detects project directories from the repo root.
8
+ #
9
+ # Usage:
10
+ # ./run-review.sh backend # lint + test backend only
11
+ # ./run-review.sh frontend # lint + type-check + test frontend only
12
+ # ./run-review.sh all # both
13
+ # ./run-review.sh backend --fix # auto-fix lint issues
14
+ #
15
+ # Environment variables (override auto-detection):
16
+ # BE_DIR=./my-backend FE_DIR=./my-frontend ./run-review.sh all
17
+ #
18
+ # Output: JSON report at ./review-output/review-report.json
19
+ # ─────────────────────────────────────────────────────────────
20
+
21
+ set -euo pipefail
22
+
23
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
24
+ REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || cd "$SCRIPT_DIR/../../../../.." && pwd)"
25
+
26
+ # ─── Auto-detect project directories ─────────────────────────
27
+ detect_dir() {
28
+ local kind="$1"
29
+ shift
30
+ for candidate in "$@"; do
31
+ if [ -d "$REPO_ROOT/$candidate" ] && [ -f "$REPO_ROOT/$candidate/package.json" ]; then
32
+ echo "$REPO_ROOT/$candidate"
33
+ return
34
+ fi
35
+ done
36
+ echo ""
37
+ }
38
+
39
+ BE_DIR="${BE_DIR:-$(detect_dir backend backend be-* server api apps/api apps/backend)}"
40
+ FE_DIR="${FE_DIR:-$(detect_dir frontend frontend web-* client apps/web apps/frontend)}"
41
+
42
+ OUTPUT_DIR="$SCRIPT_DIR/../review-output"
43
+ REPORT="$OUTPUT_DIR/review-report.json"
44
+
45
+ TARGET="${1:-all}"
46
+ FIX_FLAG="${2:-}"
47
+
48
+ mkdir -p "$OUTPUT_DIR"
49
+
50
+ # ─── Helpers ─────────────────────────────────────────────────
51
+ log() { echo " [review] $*"; }
52
+ warn() { echo " [warn] $*"; }
53
+ ok() { echo " [ok] $*"; }
54
+ fail() { echo " [fail] $*"; }
55
+
56
+ run_check() {
57
+ local name="$1"
58
+ local dir="$2"
59
+ shift 2
60
+ local cmd=("$@")
61
+
62
+ log "Running $name..."
63
+ local start_ms
64
+ start_ms=$(date +%s%3N 2>/dev/null || date +%s)
65
+
66
+ local output exit_code=0
67
+ output=$( cd "$dir" && "${cmd[@]}" 2>&1 ) || exit_code=$?
68
+
69
+ local end_ms
70
+ end_ms=$(date +%s%3N 2>/dev/null || date +%s)
71
+ local duration_ms=$(( end_ms - start_ms ))
72
+
73
+ if [ $exit_code -eq 0 ]; then
74
+ ok "$name passed (${duration_ms}ms)"
75
+ else
76
+ fail "$name failed (exit $exit_code, ${duration_ms}ms)"
77
+ fi
78
+
79
+ # Append to results array
80
+ RESULTS+=("{\"check\":\"$name\",\"exit_code\":$exit_code,\"duration_ms\":$duration_ms,\"output\":$(echo "$output" | head -100 | python3 -c 'import json,sys; print(json.dumps(sys.stdin.read()))' 2>/dev/null || echo '""')}")
81
+ }
82
+
83
+ RESULTS=()
84
+
85
+ # ─── Backend Checks ──────────────────────────────────────────
86
+ if [[ "$TARGET" == "backend" || "$TARGET" == "all" ]]; then
87
+ log ""
88
+ if [ -z "$BE_DIR" ]; then
89
+ warn "No backend directory detected — set BE_DIR or ensure a backend/ directory exists"
90
+ else
91
+ log "═══ Backend ($(basename "$BE_DIR")) ═══"
92
+
93
+ if [ -d "$BE_DIR/node_modules" ]; then
94
+ if [[ "$FIX_FLAG" == "--fix" ]]; then
95
+ run_check "backend-lint-fix" "$BE_DIR" npx eslint "{src,apps,libs,test}/**/*.ts" --fix
96
+ else
97
+ run_check "backend-lint" "$BE_DIR" npx eslint "{src,apps,libs,test}/**/*.ts" --max-warnings 50
98
+ fi
99
+
100
+ run_check "backend-test" "$BE_DIR" npx jest --config jest.config.cjs --passWithNoTests --silent
101
+ else
102
+ warn "Backend node_modules not found — run 'npm install' in $(basename "$BE_DIR")/ first"
103
+ RESULTS+=("{\"check\":\"backend-deps\",\"exit_code\":1,\"duration_ms\":0,\"output\":\"node_modules not found\"}")
104
+ fi
105
+ fi
106
+ fi
107
+
108
+ # ─── Frontend Checks ─────────────────────────────────────────
109
+ if [[ "$TARGET" == "frontend" || "$TARGET" == "all" ]]; then
110
+ log ""
111
+ if [ -z "$FE_DIR" ]; then
112
+ warn "No frontend directory detected — set FE_DIR or ensure a frontend/ directory exists"
113
+ else
114
+ log "═══ Frontend ($(basename "$FE_DIR")) ═══"
115
+
116
+ if [ -d "$FE_DIR/node_modules" ]; then
117
+ if [[ "$FIX_FLAG" == "--fix" ]]; then
118
+ run_check "frontend-lint-fix" "$FE_DIR" npx next lint --fix
119
+ else
120
+ run_check "frontend-lint" "$FE_DIR" npx next lint
121
+ fi
122
+
123
+ run_check "frontend-typecheck" "$FE_DIR" npx tsc --noEmit
124
+
125
+ run_check "frontend-test" "$FE_DIR" npx jest --passWithNoTests --silent
126
+ else
127
+ warn "Frontend node_modules not found — run 'npm install' in $(basename "$FE_DIR")/ first"
128
+ RESULTS+=("{\"check\":\"frontend-deps\",\"exit_code\":1,\"duration_ms\":0,\"output\":\"node_modules not found\"}")
129
+ fi
130
+ fi
131
+ fi
132
+
133
+ # ─── Generate Report ─────────────────────────────────────────
134
+ log ""
135
+ log "═══ Generating Report ═══"
136
+
137
+ RESULTS_JSON=$(printf '%s\n' "${RESULTS[@]}" | paste -sd ',' -)
138
+ cat > "$REPORT" <<EOF
139
+ {
140
+ "timestamp": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
141
+ "target": "$TARGET",
142
+ "repo_root": "$REPO_ROOT",
143
+ "checks": [$RESULTS_JSON]
144
+ }
145
+ EOF
146
+
147
+ ok "Report saved to $REPORT"
148
+
149
+ # ─── Summary ─────────────────────────────────────────────────
150
+ TOTAL=${#RESULTS[@]}
151
+ PASSED=0
152
+ for r in "${RESULTS[@]}"; do
153
+ if echo "$r" | grep -q '"exit_code":0'; then
154
+ PASSED=$((PASSED + 1))
155
+ fi
156
+ done
157
+ FAILED=$((TOTAL - PASSED))
158
+
159
+ log ""
160
+ log "════════════════════════════════"
161
+ log " Results: $PASSED/$TOTAL passed"
162
+ if [ $FAILED -gt 0 ]; then
163
+ fail " $FAILED check(s) failed"
164
+ exit 1
165
+ else
166
+ ok " All checks passed!"
167
+ fi
@@ -0,0 +1,152 @@
1
+ #!/usr/bin/env bash
2
+ # ─────────────────────────────────────────────────────────────
3
+ # Codebase Scanner
4
+ #
5
+ # Quick scan of the entire monorepo for common code quality
6
+ # issues. Auto-detects project directories.
7
+ #
8
+ # Usage:
9
+ # ./scan-codebase.sh # scan everything
10
+ # ./scan-codebase.sh --json # output as JSON
11
+ #
12
+ # Environment variables (override auto-detection):
13
+ # BE_SRC=./my-backend/src FE_SRC=./my-frontend/src ./scan-codebase.sh
14
+ # ─────────────────────────────────────────────────────────────
15
+
16
+ set -euo pipefail
17
+
18
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
19
+ REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || cd "$SCRIPT_DIR/../../../../.." && pwd)"
20
+
21
+ # ─── Auto-detect project directories ─────────────────────────
22
+ detect_src() {
23
+ local kind="$1"
24
+ shift
25
+ for candidate in "$@"; do
26
+ if [ -d "$REPO_ROOT/$candidate/src" ]; then
27
+ echo "$REPO_ROOT/$candidate/src"
28
+ return
29
+ fi
30
+ done
31
+ echo ""
32
+ }
33
+
34
+ BE_SRC="${BE_SRC:-$(detect_src backend backend be-* server api apps/api apps/backend)}"
35
+ FE_SRC="${FE_SRC:-$(detect_src frontend frontend web-* client apps/web apps/frontend)}"
36
+
37
+ JSON_MODE="${1:-}"
38
+
39
+ echo ""
40
+ echo " ╔══════════════════════════════════════════╗"
41
+ echo " ║ Codebase Scanner ║"
42
+ echo " ╚══════════════════════════════════════════╝"
43
+ echo ""
44
+
45
+ # ─── Backend Scan ─────────────────────────────────────────────
46
+ if [ -n "$BE_SRC" ] && [ -d "$BE_SRC" ]; then
47
+ BE_NAME="$(basename "$(dirname "$BE_SRC")")"
48
+ echo " ═══ Backend ($BE_NAME) ═══"
49
+ echo ""
50
+
51
+ # Count features
52
+ FEATURE_COUNT=$(ls -1d "$BE_SRC/features"/*/ 2>/dev/null | wc -l | tr -d ' ')
53
+ echo " Feature modules: $FEATURE_COUNT"
54
+
55
+ # Total TS files
56
+ BE_TS_COUNT=$(find "$BE_SRC" -name "*.ts" | wc -l | tr -d ' ')
57
+ echo " TypeScript files: $BE_TS_COUNT"
58
+
59
+ # Test files
60
+ BE_TEST_COUNT=$(find "$BE_SRC" -name "*.spec.ts" -o -name "*.test.ts" 2>/dev/null | wc -l | tr -d ' ')
61
+ echo " Test files: $BE_TEST_COUNT"
62
+
63
+ # Test coverage ratio
64
+ if [ "$BE_TS_COUNT" -gt 0 ]; then
65
+ COVERAGE_PCT=$(( BE_TEST_COUNT * 100 / BE_TS_COUNT ))
66
+ echo " Test file ratio: ${COVERAGE_PCT}%"
67
+ fi
68
+
69
+ echo ""
70
+ echo " Code quality indicators:"
71
+
72
+ # any usage across backend
73
+ ANY_COUNT=$(grep -r ": any\b" "$BE_SRC" --include="*.ts" 2>/dev/null | wc -l | tr -d ' ')
74
+ echo " 'any' type usage: $ANY_COUNT occurrences"
75
+
76
+ # TODO/FIXME/HACK comments
77
+ TODO_COUNT=$(grep -ri "TODO\|FIXME\|HACK\|XXX" "$BE_SRC" --include="*.ts" 2>/dev/null | wc -l | tr -d ' ')
78
+ echo " TODO/FIXME/HACK: $TODO_COUNT comments"
79
+
80
+ # console.log (should use structured logger)
81
+ CONSOLE_COUNT=$(grep -r "console\.log\|console\.error\|console\.warn" "$BE_SRC" --include="*.ts" 2>/dev/null | wc -l | tr -d ' ')
82
+ echo " console.* usage: $CONSOLE_COUNT (should use structured logger)"
83
+
84
+ # Empty catch blocks
85
+ EMPTY_CATCH=$(grep -r "catch.*{" "$BE_SRC" --include="*.ts" -A1 2>/dev/null | grep -c "^[[:space:]]*}" || true)
86
+ echo " Potentially empty catch blocks: $EMPTY_CATCH"
87
+
88
+ # Modules without tests
89
+ echo ""
90
+ echo " Modules without tests:"
91
+ for mod_dir in "$BE_SRC/features"/*/; do
92
+ mod_name=$(basename "$mod_dir")
93
+ test_files=$(find "$mod_dir" -name "*.spec.ts" -o -name "*.test.ts" 2>/dev/null | wc -l | tr -d ' ')
94
+ if [ "$test_files" -eq 0 ]; then
95
+ echo " - $mod_name"
96
+ fi
97
+ done
98
+
99
+ # Modules without Swagger docs
100
+ echo ""
101
+ echo " Modules without Swagger decorators:"
102
+ for mod_dir in "$BE_SRC/features"/*/; do
103
+ mod_name=$(basename "$mod_dir")
104
+ swagger=$(grep -r "@ApiTags\|@ApiOperation" "$mod_dir" 2>/dev/null | wc -l | tr -d ' ')
105
+ controller=$(find "$mod_dir" -name "*.controller.ts" 2>/dev/null | wc -l | tr -d ' ')
106
+ if [ "$controller" -gt 0 ] && [ "$swagger" -eq 0 ]; then
107
+ echo " - $mod_name"
108
+ fi
109
+ done
110
+
111
+ # Top any-heavy files
112
+ echo ""
113
+ echo " Top 10 files by 'any' usage:"
114
+ grep -rc ": any\b" "$BE_SRC" --include="*.ts" 2>/dev/null | grep -v ":0$" | sort -t: -k2 -rn | head -10 | while IFS=: read -r file count; do
115
+ echo " $count ${file#$REPO_ROOT/}"
116
+ done
117
+ else
118
+ echo " [skip] No backend source directory detected"
119
+ fi
120
+
121
+ # ─── Frontend Scan ────────────────────────────────────────────
122
+ echo ""
123
+ if [ -n "$FE_SRC" ] && [ -d "$FE_SRC" ]; then
124
+ FE_NAME="$(basename "$(dirname "$FE_SRC")")"
125
+ echo " ═══ Frontend ($FE_NAME) ═══"
126
+ echo ""
127
+
128
+ FE_TS_COUNT=$(find "$FE_SRC" -name "*.ts" -o -name "*.tsx" | wc -l | tr -d ' ')
129
+ echo " TypeScript files: $FE_TS_COUNT"
130
+
131
+ FE_TEST_COUNT=$(find "$FE_SRC" -name "*.spec.ts" -o -name "*.spec.tsx" -o -name "*.test.ts" -o -name "*.test.tsx" 2>/dev/null | wc -l | tr -d ' ')
132
+ echo " Test files: $FE_TEST_COUNT"
133
+
134
+ # use client directives
135
+ USE_CLIENT=$(grep -rl "\"use client\"" "$FE_SRC" --include="*.tsx" --include="*.ts" 2>/dev/null | wc -l | tr -d ' ')
136
+ echo " 'use client' components: $USE_CLIENT"
137
+
138
+ # any usage
139
+ FE_ANY=$(grep -r ": any\b" "$FE_SRC" --include="*.ts" --include="*.tsx" 2>/dev/null | wc -l | tr -d ' ')
140
+ echo " 'any' type usage: $FE_ANY"
141
+
142
+ # console usage
143
+ FE_CONSOLE=$(grep -r "console\.log" "$FE_SRC" --include="*.ts" --include="*.tsx" 2>/dev/null | wc -l | tr -d ' ')
144
+ echo " console.log usage: $FE_CONSOLE"
145
+ else
146
+ echo " [skip] No frontend source directory detected"
147
+ fi
148
+
149
+ echo ""
150
+ echo " ════════════════════════════════════════════"
151
+ echo " Scan complete."
152
+ echo ""
@@ -0,0 +1,327 @@
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
+ ### 3. Manual Review by Category
107
+
108
+ After automated checks, do targeted manual review based on findings.
109
+
110
+ #### Category 1: Secrets & Credentials (CRITICAL)
111
+
112
+ Scan for leaked secrets, hardcoded keys, and exposed credentials.
113
+
114
+ **What to look for:**
115
+ - API keys, tokens, passwords in source code (not `.env`)
116
+ - Secrets in `.env.example` that look real (not placeholder-ish)
117
+ - Private keys committed to git
118
+ - Secrets logged to console or error responses
119
+ - Secrets in URL query parameters
120
+ - Secrets in frontend bundles (anything prefixed `NEXT_PUBLIC_` or `EXPO_PUBLIC_`)
121
+
122
+ **Known locations in this project:**
123
+ - Check for hardcoded API keys in utility scripts and lib files
124
+ - `.env.example` — check for example passwords that could be reused
125
+ - `core/config/` — check all config files load from env, not hardcoded
126
+
127
+ **Patterns to grep:**
128
+ ```bash
129
+ # Hardcoded secrets
130
+ grep -rn "password\s*[:=]\s*['\"]" --include="*.ts" --include="*.mjs"
131
+ grep -rn "api[_-]?key\s*[:=]\s*['\"]" --include="*.ts" --include="*.mjs"
132
+ grep -rn "secret\s*[:=]\s*['\"]" --include="*.ts"
133
+ grep -rn "Bearer\s" --include="*.ts" --include="*.mjs"
134
+
135
+ # Secrets in logs
136
+ grep -rn "console\.log.*token\|console\.log.*password\|console\.log.*secret" --include="*.ts"
137
+ ```
138
+
139
+ #### Category 2: Authentication & Authorization
140
+
141
+ **Backend (NestJS):**
142
+ - Are all non-public endpoints guarded with `@UseGuards(JwtAuthGuard)`?
143
+ - Do user-specific queries filter by `userId` from `@CurrentUser()`?
144
+ - Can users access/modify other users' data? (IDOR)
145
+ - Is the admin bypass in `roles.guard.ts` properly restricted?
146
+ - Are refresh tokens properly invalidated on logout?
147
+ - Token expiration: are access/refresh token lifetimes enforced?
148
+
149
+ **Frontend (Next.js):**
150
+ - Are API routes in `src/app/api/` checking auth before processing?
151
+ - Are tokens stored in httpOnly cookies (not localStorage)?
152
+ - Is there CSRF protection on state-changing requests?
153
+
154
+ **Mobile (React Native):**
155
+ - Tokens stored in Keychain/Keystore via `react-native-keychain`? (currently yes)
156
+ - Is biometric auth implemented for sensitive actions?
157
+ - Are deep link handlers validating the source?
158
+
159
+ Read `references/auth-security.md` for detailed checklist.
160
+
161
+ #### Category 3: Injection Attacks
162
+
163
+ **NoSQL Injection (MongoDB):**
164
+ - Are Mongoose queries using user input directly in `$where`, `$regex`, or `$expr`?
165
+ - Is `JSON.parse()` used on user input without validation?
166
+ - Does `forbidNonWhitelisted: true` catch all inputs? (check file uploads, query params)
167
+
168
+ **XSS:**
169
+ - Is user-generated content rendered with `dangerouslySetInnerHTML`?
170
+ - Are Markdown/rich text inputs sanitized before storage and display?
171
+ - Do AI-generated responses get sanitized before rendering?
172
+
173
+ **Command Injection:**
174
+ - Does any code use `exec()`, `spawn()`, or `eval()` with user input?
175
+ - Playwright scraper — is the URL validated before navigation?
176
+
177
+ #### Category 4: Security Headers & CORS
178
+
179
+ **Current config** (`core/config/helmet.config.ts` and `cors.config.ts`):
180
+
181
+ Check these against best practices:
182
+ - CSP should NOT have `'unsafe-inline'` (currently does)
183
+ - `connectSrc` should list specific domains, not `https://*`
184
+ - CORS should not default to `['*']` even in development
185
+ - X-Frame-Options: should be `DENY` or `SAMEORIGIN`
186
+ - Referrer-Policy: should be `strict-origin-when-cross-origin`
187
+
188
+ Read `references/headers-checklist.md` for the full checklist.
189
+
190
+ #### Category 5: Dependencies & Supply Chain (OWASP A03:2025)
191
+
192
+ This is newly elevated in OWASP 2025. Treat supply chain as a first-class risk.
193
+
194
+ ```bash
195
+ # Vulnerability scan
196
+ cd <backend-dir> && npm audit
197
+ cd <frontend-dir> && npm audit
198
+ cd <mobile-dir> && npm audit
199
+
200
+ # Verify package signatures (npm 9+)
201
+ npm audit signatures
202
+
203
+ # Check for lifecycle scripts that download code
204
+ ./scripts/security-scan.sh supply-chain
205
+ ```
206
+
207
+ **What to check:**
208
+ - Known CVEs in dependencies (`npm audit`)
209
+ - Lockfile integrity — are lockfiles committed? (`pnpm-lock.yaml`, `package-lock.json`)
210
+ - Lifecycle scripts — `preinstall`/`postinstall` that download or execute code
211
+ - Typosquatting — dependency names close to popular packages
212
+ - Dependency signature verification (`npm audit signatures`)
213
+ - SBOM generation for compliance (`npm sbom --sbom-format cyclonedx`)
214
+ - NestJS-specific: **CVE-2025-54782** — RCE in `@nestjs/devtools-integration` ≤0.2.0 (unsafe `vm.runInNewContext` + missing CORS). Verify version ≥0.2.1
215
+
216
+ **Supply chain attack awareness:**
217
+ - The Sept 2025 "Shai-Hulud" attack compromised 18 popular npm packages (chalk, debug, etc.)
218
+ - Always disable lifecycle scripts by default: `npm config set ignore-scripts true`
219
+ - Use `--ignore-scripts` in CI/CD and explicitly allow-list needed scripts
220
+
221
+ #### Category 6: LLM/AI Agent Security (OWASP LLM Top 10)
222
+
223
+ The project has LangChain + LangGraph agents, multi-provider LLMs, and Qdrant vector DB. This category is critical.
224
+
225
+ **Prompt Injection (LLM01):**
226
+ - Is user input concatenated directly into LLM prompts?
227
+ - Are system prompts retrievable via conversation manipulation?
228
+ - Check `features/ai-agents/` for prompt construction patterns
229
+ - Multi-modal inputs (images) can contain hidden prompts
230
+
231
+ **Output Handling (LLM05):**
232
+ - Are AI-generated responses sanitized before rendering in frontend/mobile?
233
+ - Can AI output contain executable HTML/JS/markdown that bypasses sanitization?
234
+ - Are AI-suggested actions validated before execution?
235
+
236
+ **Excessive Agency (LLM06):**
237
+ - What tools can LangGraph agents call? Are they scoped to minimum permissions?
238
+ - Can agents access/modify resources beyond the current user's scope?
239
+ - Is there human-in-the-loop for destructive agent actions?
240
+
241
+ **Vector DB Security (LLM08):**
242
+ - Is Qdrant access authenticated?
243
+ - Can users poison the fashion knowledge base via injected content?
244
+ - Are embeddings isolated per tenant?
245
+
246
+ **Resource Limits (LLM10):**
247
+ - Token limits on LLM API calls?
248
+ - Rate limiting on AI chat endpoints?
249
+ - Timeout on LangGraph agent execution?
250
+
251
+ Read `references/nestjs-security.md` → "LLM/AI Agent Security" for detailed checklist.
252
+
253
+ #### Category 7: Platform-Specific
254
+
255
+ Read the platform-specific references for deeper checks:
256
+ - `references/nestjs-security.md` — Backend: auth, injection, rate limiting, error handling, LLM security
257
+ - `references/react-native-security.md` — Mobile: OWASP Mobile Top 10, secure storage, cert pinning, binary protection
258
+ - `references/nextjs-security.md` — Frontend: server/client boundary, API routes, CSP, dependency safety
259
+
260
+ #### Category 8: Exceptional Conditions (OWASP A10:2025)
261
+
262
+ New in OWASP 2025 — check how the app handles edge cases:
263
+ - Do uncaught exceptions expose stack traces in production?
264
+ - Do auth failures fail-open (grant access) instead of fail-closed (deny)?
265
+ - Are Bull queue job failures handled gracefully without data loss?
266
+ - Do LLM API timeouts fall back safely (no infinite retries, no credential exposure)?
267
+ - Are MongoDB connection failures handled without crashing the process?
268
+
269
+ ### 4. Report Findings
270
+
271
+ Structure the report by severity:
272
+
273
+ ```
274
+ 🔴 CRITICAL — Exploitable now, data at risk
275
+ 🟠 HIGH — Significant risk, should fix before next release
276
+ 🟡 MEDIUM — Defense-in-depth improvement
277
+ 🟢 LOW — Best practice recommendation
278
+ ℹ️ INFO — Observation, no action needed
279
+ ```
280
+
281
+ For each finding:
282
+ ```
283
+ **[SEVERITY] Title**
284
+ Location: file:line
285
+ Impact: What an attacker could do
286
+ Evidence: The vulnerable code
287
+ Fix: Concrete remediation with code example
288
+ ```
289
+
290
+ ### 5. Provide Fix Priority
291
+
292
+ End with a prioritized action list:
293
+ 1. Critical fixes (do today)
294
+ 2. High fixes (this sprint)
295
+ 3. Medium fixes (next sprint)
296
+ 4. Low/info (backlog)
297
+
298
+ ## Recommended Tools Integration
299
+
300
+ For CI/CD pipeline integration, recommend these tools:
301
+
302
+ | Tool | Type | Use Case |
303
+ |------|------|----------|
304
+ | **Semgrep** | SAST | Custom rules for NestJS/Next.js patterns, free for open source |
305
+ | **npm audit** | SCA | Built-in dependency vulnerability scanning |
306
+ | **Socket.dev** | SCA+ | Detects malicious packages, supply chain attacks |
307
+ | **OWASP ZAP** | DAST | Runtime API scanning in staging |
308
+ | **SonarQube** | SAST | Continuous code quality + security |
309
+ | **Snyk** | SCA | Dependency monitoring with auto-fix PRs |
310
+ | **Gitleaks** | Secrets | Pre-commit hook for secret detection |
311
+
312
+ **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.
313
+
314
+ ## References
315
+
316
+ Platform-specific deep-dive checklists — read these when scanning a specific area:
317
+
318
+ - `references/nestjs-security.md` — Backend: auth guards, injection, rate limiting, file upload, error handling, LLM/AI agent security
319
+ - `references/react-native-security.md` — Mobile: OWASP Mobile Top 10, secure storage, certificate pinning, binary protection, deep links
320
+ - `references/nextjs-security.md` — Frontend: server/client boundary, API routes, middleware auth, env vars, CSP, dependency supply chain
321
+
322
+ **External references:**
323
+ - [OWASP Top 10:2025](https://owasp.org/Top10/2025/)
324
+ - [OWASP Top 10 for LLM Applications 2025](https://genai.owasp.org/llm-top-10/)
325
+ - [OWASP Mobile Top 10](https://owasp.org/www-project-mobile-top-10/)
326
+ - [NPM Security Cheat Sheet (OWASP)](https://cheatsheetseries.owasp.org/cheatsheets/NPM_Security_Cheat_Sheet.html)
327
+ - [NestJS Security Best Practices](https://dev.to/drbenzene/best-security-implementation-practices-in-nestjs-a-comprehensive-guide-2p88)