ai-devx 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.
- package/package.json +1 -1
- package/templates/.agent/.shared/ui-ux-pro-max/data/charts.csv +26 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/colors.csv +97 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/icons.csv +101 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/landing.csv +31 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/products.csv +97 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/prompts.csv +24 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/react-performance.csv +45 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/styles.csv +59 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/typography.csv +58 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/templates/.agent/.shared/ui-ux-pro-max/data/web-interface.csv +31 -0
- package/templates/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/core.cpython-313.pyc +0 -0
- package/templates/.agent/.shared/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-313.pyc +0 -0
- package/templates/.agent/.shared/ui-ux-pro-max/scripts/core.py +258 -0
- package/templates/.agent/.shared/ui-ux-pro-max/scripts/design_system.py +1067 -0
- package/templates/.agent/.shared/ui-ux-pro-max/scripts/search.py +106 -0
- package/templates/.agent/ARCHITECTURE.md +288 -0
- package/templates/.agent/agents/backend-specialist.md +251 -135
- package/templates/.agent/agents/code-archaeologist.md +106 -0
- package/templates/.agent/agents/database-architect.md +222 -160
- package/templates/.agent/agents/debugger.md +205 -108
- package/templates/.agent/agents/devops-engineer.md +226 -169
- package/templates/.agent/agents/documentation-writer.md +104 -0
- package/templates/.agent/agents/explorer-agent.md +73 -0
- package/templates/.agent/agents/frontend-specialist.md +587 -116
- package/templates/.agent/agents/game-developer.md +162 -0
- package/templates/.agent/agents/mobile-developer.md +377 -0
- package/templates/.agent/agents/orchestrator.md +412 -133
- package/templates/.agent/agents/penetration-tester.md +188 -0
- package/templates/.agent/agents/performance-optimizer.md +187 -0
- package/templates/.agent/agents/product-manager.md +112 -0
- package/templates/.agent/agents/product-owner.md +95 -0
- package/templates/.agent/agents/project-planner.md +390 -111
- package/templates/.agent/agents/qa-automation-engineer.md +103 -0
- package/templates/.agent/agents/security-auditor.md +158 -110
- package/templates/.agent/agents/seo-specialist.md +111 -0
- package/templates/.agent/agents/test-engineer.md +136 -154
- package/templates/.agent/mcp_config.json +24 -0
- package/templates/.agent/rules/GEMINI.md +273 -0
- package/templates/.agent/scripts/auto_preview.py +148 -0
- package/templates/.agent/scripts/checklist.py +217 -0
- package/templates/.agent/scripts/session_manager.py +120 -0
- package/templates/.agent/scripts/verify_all.py +327 -0
- package/templates/.agent/skills/api-patterns/SKILL.md +77 -232
- package/templates/.agent/skills/api-patterns/api-style.md +42 -0
- package/templates/.agent/skills/api-patterns/auth.md +24 -0
- package/templates/.agent/skills/api-patterns/documentation.md +26 -0
- package/templates/.agent/skills/api-patterns/graphql.md +41 -0
- package/templates/.agent/skills/api-patterns/rate-limiting.md +31 -0
- package/templates/.agent/skills/api-patterns/response.md +37 -0
- package/templates/.agent/skills/api-patterns/rest.md +40 -0
- package/templates/.agent/skills/api-patterns/scripts/api_validator.py +211 -0
- package/templates/.agent/skills/api-patterns/security-testing.md +122 -0
- package/templates/.agent/skills/api-patterns/trpc.md +41 -0
- package/templates/.agent/skills/api-patterns/versioning.md +22 -0
- package/templates/.agent/skills/app-builder/SKILL.md +75 -0
- package/templates/.agent/skills/app-builder/agent-coordination.md +71 -0
- package/templates/.agent/skills/app-builder/feature-building.md +53 -0
- package/templates/.agent/skills/app-builder/project-detection.md +34 -0
- package/templates/.agent/skills/app-builder/scaffolding.md +118 -0
- package/templates/.agent/skills/app-builder/tech-stack.md +40 -0
- package/templates/.agent/skills/app-builder/templates/SKILL.md +39 -0
- package/templates/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +76 -0
- package/templates/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +92 -0
- package/templates/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +88 -0
- package/templates/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +88 -0
- package/templates/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +83 -0
- package/templates/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +90 -0
- package/templates/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +90 -0
- package/templates/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +122 -0
- package/templates/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +122 -0
- package/templates/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +169 -0
- package/templates/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +134 -0
- package/templates/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +83 -0
- package/templates/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +119 -0
- package/templates/.agent/skills/architecture/SKILL.md +55 -0
- package/templates/.agent/skills/architecture/context-discovery.md +43 -0
- package/templates/.agent/skills/architecture/examples.md +94 -0
- package/templates/.agent/skills/architecture/pattern-selection.md +68 -0
- package/templates/.agent/skills/architecture/patterns-reference.md +50 -0
- package/templates/.agent/skills/architecture/trade-off-analysis.md +77 -0
- package/templates/.agent/skills/bash-linux/SKILL.md +199 -0
- package/templates/.agent/skills/behavioral-modes/SKILL.md +242 -0
- package/templates/.agent/skills/brainstorming/SKILL.md +163 -0
- package/templates/.agent/skills/brainstorming/dynamic-questioning.md +350 -0
- package/templates/.agent/skills/clean-code/SKILL.md +201 -0
- package/templates/.agent/skills/code-review-checklist/SKILL.md +109 -0
- package/templates/.agent/skills/database-design/SKILL.md +34 -285
- package/templates/.agent/skills/database-design/database-selection.md +43 -0
- package/templates/.agent/skills/database-design/indexing.md +39 -0
- package/templates/.agent/skills/database-design/migrations.md +48 -0
- package/templates/.agent/skills/database-design/optimization.md +36 -0
- package/templates/.agent/skills/database-design/orm-selection.md +30 -0
- package/templates/.agent/skills/database-design/schema-design.md +56 -0
- package/templates/.agent/skills/database-design/scripts/schema_validator.py +172 -0
- package/templates/.agent/skills/deployment-procedures/SKILL.md +241 -0
- package/templates/.agent/skills/doc.md +177 -0
- package/templates/.agent/skills/documentation-templates/SKILL.md +194 -0
- package/templates/.agent/skills/frontend-design/SKILL.md +418 -0
- package/templates/.agent/skills/frontend-design/animation-guide.md +331 -0
- package/templates/.agent/skills/frontend-design/color-system.md +311 -0
- package/templates/.agent/skills/frontend-design/decision-trees.md +418 -0
- package/templates/.agent/skills/frontend-design/motion-graphics.md +306 -0
- package/templates/.agent/skills/frontend-design/scripts/accessibility_checker.py +183 -0
- package/templates/.agent/skills/frontend-design/scripts/ux_audit.py +722 -0
- package/templates/.agent/skills/frontend-design/typography-system.md +345 -0
- package/templates/.agent/skills/frontend-design/ux-psychology.md +1116 -0
- package/templates/.agent/skills/frontend-design/visual-effects.md +383 -0
- package/templates/.agent/skills/game-development/2d-games/SKILL.md +119 -0
- package/templates/.agent/skills/game-development/3d-games/SKILL.md +135 -0
- package/templates/.agent/skills/game-development/SKILL.md +167 -0
- package/templates/.agent/skills/game-development/game-art/SKILL.md +185 -0
- package/templates/.agent/skills/game-development/game-audio/SKILL.md +190 -0
- package/templates/.agent/skills/game-development/game-design/SKILL.md +129 -0
- package/templates/.agent/skills/game-development/mobile-games/SKILL.md +108 -0
- package/templates/.agent/skills/game-development/multiplayer/SKILL.md +132 -0
- package/templates/.agent/skills/game-development/pc-games/SKILL.md +144 -0
- package/templates/.agent/skills/game-development/vr-ar/SKILL.md +123 -0
- package/templates/.agent/skills/game-development/web-games/SKILL.md +150 -0
- package/templates/.agent/skills/geo-fundamentals/SKILL.md +156 -0
- package/templates/.agent/skills/geo-fundamentals/scripts/geo_checker.py +289 -0
- package/templates/.agent/skills/i18n-localization/SKILL.md +154 -0
- package/templates/.agent/skills/i18n-localization/scripts/i18n_checker.py +241 -0
- package/templates/.agent/skills/intelligent-routing/SKILL.md +335 -0
- package/templates/.agent/skills/lint-and-validate/SKILL.md +45 -0
- package/templates/.agent/skills/lint-and-validate/scripts/lint_runner.py +184 -0
- package/templates/.agent/skills/lint-and-validate/scripts/type_coverage.py +173 -0
- package/templates/.agent/skills/mcp-builder/SKILL.md +176 -0
- package/templates/.agent/skills/mobile-design/SKILL.md +394 -0
- package/templates/.agent/skills/mobile-design/decision-trees.md +516 -0
- package/templates/.agent/skills/mobile-design/mobile-backend.md +491 -0
- package/templates/.agent/skills/mobile-design/mobile-color-system.md +420 -0
- package/templates/.agent/skills/mobile-design/mobile-debugging.md +122 -0
- package/templates/.agent/skills/mobile-design/mobile-design-thinking.md +357 -0
- package/templates/.agent/skills/mobile-design/mobile-navigation.md +458 -0
- package/templates/.agent/skills/mobile-design/mobile-performance.md +767 -0
- package/templates/.agent/skills/mobile-design/mobile-testing.md +356 -0
- package/templates/.agent/skills/mobile-design/mobile-typography.md +433 -0
- package/templates/.agent/skills/mobile-design/platform-android.md +666 -0
- package/templates/.agent/skills/mobile-design/platform-ios.md +561 -0
- package/templates/.agent/skills/mobile-design/scripts/mobile_audit.py +670 -0
- package/templates/.agent/skills/mobile-design/touch-psychology.md +537 -0
- package/templates/.agent/skills/nextjs-react-expert/1-async-eliminating-waterfalls.md +312 -0
- package/templates/.agent/skills/nextjs-react-expert/2-bundle-bundle-size-optimization.md +240 -0
- package/templates/.agent/skills/nextjs-react-expert/3-server-server-side-performance.md +490 -0
- package/templates/.agent/skills/nextjs-react-expert/4-client-client-side-data-fetching.md +264 -0
- package/templates/.agent/skills/nextjs-react-expert/5-rerender-re-render-optimization.md +581 -0
- package/templates/.agent/skills/nextjs-react-expert/6-rendering-rendering-performance.md +432 -0
- package/templates/.agent/skills/nextjs-react-expert/7-js-javascript-performance.md +684 -0
- package/templates/.agent/skills/nextjs-react-expert/8-advanced-advanced-patterns.md +150 -0
- package/templates/.agent/skills/nextjs-react-expert/SKILL.md +286 -0
- package/templates/.agent/skills/nextjs-react-expert/scripts/convert_rules.py +222 -0
- package/templates/.agent/skills/nextjs-react-expert/scripts/react_performance_checker.py +252 -0
- package/templates/.agent/skills/nodejs-best-practices/SKILL.md +333 -0
- package/templates/.agent/skills/parallel-agents/SKILL.md +175 -0
- package/templates/.agent/skills/performance-profiling/SKILL.md +143 -0
- package/templates/.agent/skills/performance-profiling/scripts/lighthouse_audit.py +76 -0
- package/templates/.agent/skills/plan-writing/SKILL.md +152 -0
- package/templates/.agent/skills/powershell-windows/SKILL.md +167 -0
- package/templates/.agent/skills/python-patterns/SKILL.md +441 -0
- package/templates/.agent/skills/red-team-tactics/SKILL.md +199 -0
- package/templates/.agent/skills/rust-pro/SKILL.md +176 -0
- package/templates/.agent/skills/seo-fundamentals/SKILL.md +129 -0
- package/templates/.agent/skills/seo-fundamentals/scripts/seo_checker.py +219 -0
- package/templates/.agent/skills/server-management/SKILL.md +161 -0
- package/templates/.agent/skills/systematic-debugging/SKILL.md +109 -0
- package/templates/.agent/skills/tailwind-patterns/SKILL.md +269 -0
- package/templates/.agent/skills/tdd-workflow/SKILL.md +149 -0
- package/templates/.agent/skills/testing-patterns/SKILL.md +156 -240
- package/templates/.agent/skills/testing-patterns/scripts/test_runner.py +219 -0
- package/templates/.agent/skills/vulnerability-scanner/SKILL.md +276 -0
- package/templates/.agent/skills/vulnerability-scanner/checklists.md +121 -0
- package/templates/.agent/skills/vulnerability-scanner/scripts/security_scan.py +458 -0
- package/templates/.agent/skills/web-design-guidelines/SKILL.md +57 -0
- package/templates/.agent/skills/webapp-testing/SKILL.md +187 -0
- package/templates/.agent/skills/webapp-testing/scripts/playwright_runner.py +173 -0
- package/templates/.agent/workflows/brainstorm.md +113 -0
- package/templates/.agent/workflows/create.md +40 -112
- package/templates/.agent/workflows/debug.md +82 -117
- package/templates/.agent/workflows/deploy.md +142 -129
- package/templates/.agent/workflows/enhance.md +63 -0
- package/templates/.agent/workflows/orchestrate.md +237 -0
- package/templates/.agent/workflows/plan.md +74 -138
- package/templates/.agent/workflows/preview.md +81 -0
- package/templates/.agent/workflows/status.md +86 -0
- package/templates/.agent/workflows/test.md +109 -130
- package/templates/.agent/workflows/ui-ux-pro-max.md +296 -0
- package/templates/.agent/scripts/checklist.js +0 -260
- package/templates/.agent/scripts/security_scan.js +0 -251
- package/templates/.agent/skills/docker-expert/SKILL.md +0 -286
- package/templates/.agent/skills/react-best-practices/SKILL.md +0 -246
- package/templates/.agent/workflows/security.md +0 -181
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* AI-DEVX Security Scanner
|
|
5
|
-
* Scans codebase for security vulnerabilities
|
|
6
|
-
* Usage: node .agent/scripts/security_scan.js [path]
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
const fs = require('fs');
|
|
10
|
-
const path = require('path');
|
|
11
|
-
|
|
12
|
-
const SEVERITY = {
|
|
13
|
-
CRITICAL: { label: '🔴 CRITICAL', score: 4 },
|
|
14
|
-
HIGH: { label: '🟠 HIGH', score: 3 },
|
|
15
|
-
MEDIUM: { label: '🟡 MEDIUM', score: 2 },
|
|
16
|
-
LOW: { label: '🟢 LOW', score: 1 },
|
|
17
|
-
INFO: { label: 'ℹ INFO', score: 0 }
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const SECURITY_PATTERNS = [
|
|
21
|
-
{
|
|
22
|
-
name: 'Hardcoded Secret/Password',
|
|
23
|
-
pattern: /['"]?(password|passwd|pwd|secret)['"]?\s*[:=]\s*['"][^'"]{8,}['"]/i,
|
|
24
|
-
severity: 'CRITICAL',
|
|
25
|
-
check: (content) => !content.includes('process.env') && !content.includes('import.meta.env')
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
name: 'Hardcoded API Key',
|
|
29
|
-
pattern: /['"]?(api[_-]?key|apikey)['"]?\s*[:=]\s*['"][a-zA-Z0-9]{16,}['"]/i,
|
|
30
|
-
severity: 'CRITICAL',
|
|
31
|
-
check: (content) => !content.includes('process.env')
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
name: 'Hardcoded Token',
|
|
35
|
-
pattern: /['"]?(token|access[_-]?token|auth[_-]?token)['"]?\s*[:=]\s*['"][a-zA-Z0-9-_]{20,}['"]/i,
|
|
36
|
-
severity: 'CRITICAL',
|
|
37
|
-
check: (content) => !content.includes('process.env')
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
name: 'AWS Access Key ID',
|
|
41
|
-
pattern: /['"]?AKIA[0-9A-Z]{16}['"]?/,
|
|
42
|
-
severity: 'CRITICAL',
|
|
43
|
-
check: () => true
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
name: 'Private Key',
|
|
47
|
-
pattern: /-----BEGIN (RSA |DSA |EC |OPENSSH )?PRIVATE KEY-----/,
|
|
48
|
-
severity: 'CRITICAL',
|
|
49
|
-
check: () => true
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
name: 'SQL Injection Risk',
|
|
53
|
-
pattern: /(SELECT|INSERT|UPDATE|DELETE|DROP).*\$\{/,
|
|
54
|
-
severity: 'HIGH',
|
|
55
|
-
check: () => true
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
name: 'eval() Usage',
|
|
59
|
-
pattern: /\beval\s*\(/,
|
|
60
|
-
severity: 'HIGH',
|
|
61
|
-
check: () => true
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
name: 'innerHTML Assignment',
|
|
65
|
-
pattern: /\.innerHTML\s*=/,
|
|
66
|
-
severity: 'MEDIUM',
|
|
67
|
-
check: (content, match) => !content.includes('DOMPurify') && !content.includes('sanitize')
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
name: 'Debug Mode Enabled',
|
|
71
|
-
pattern: /DEBUG\s*[:=]\s*true/i,
|
|
72
|
-
severity: 'MEDIUM',
|
|
73
|
-
check: (content) => content.includes('.env') || content.includes('production')
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
name: 'Insecure HTTP',
|
|
77
|
-
pattern: /http:\/\/(?!localhost|127\.0\.0\.1)/,
|
|
78
|
-
severity: 'MEDIUM',
|
|
79
|
-
check: () => true
|
|
80
|
-
}
|
|
81
|
-
];
|
|
82
|
-
|
|
83
|
-
const VULNERABLE_DEPENDENCIES = [
|
|
84
|
-
{ name: 'lodash', vulnerable: '<4.17.21', severity: 'HIGH' },
|
|
85
|
-
{ name: 'express', vulnerable: '<4.18.2', severity: 'MEDIUM' },
|
|
86
|
-
{ name: 'axios', vulnerable: '<0.28.0', severity: 'MEDIUM' },
|
|
87
|
-
{ name: 'minimist', vulnerable: '<1.2.6', severity: 'HIGH' }
|
|
88
|
-
];
|
|
89
|
-
|
|
90
|
-
function log(message) {
|
|
91
|
-
console.log(message);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function getAllFiles(dir, extensions) {
|
|
95
|
-
const files = [];
|
|
96
|
-
|
|
97
|
-
function traverse(currentDir) {
|
|
98
|
-
try {
|
|
99
|
-
const items = fs.readdirSync(currentDir);
|
|
100
|
-
for (const item of items) {
|
|
101
|
-
const fullPath = path.join(currentDir, item);
|
|
102
|
-
const stat = fs.statSync(fullPath);
|
|
103
|
-
|
|
104
|
-
if (stat.isDirectory()) {
|
|
105
|
-
if (!['node_modules', '.git', 'dist', 'build', '.agent'].includes(item)) {
|
|
106
|
-
traverse(fullPath);
|
|
107
|
-
}
|
|
108
|
-
} else {
|
|
109
|
-
files.push(fullPath);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
} catch (e) {
|
|
113
|
-
// Skip inaccessible directories
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
traverse(dir);
|
|
118
|
-
return files;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function scanFile(filePath, content) {
|
|
122
|
-
const issues = [];
|
|
123
|
-
|
|
124
|
-
for (const pattern of SECURITY_PATTERNS) {
|
|
125
|
-
const matches = content.match(pattern.pattern);
|
|
126
|
-
if (matches && pattern.check(content, matches)) {
|
|
127
|
-
issues.push({
|
|
128
|
-
file: filePath,
|
|
129
|
-
pattern: pattern.name,
|
|
130
|
-
severity: pattern.severity,
|
|
131
|
-
line: content.substring(0, matches.index).split('\n').length
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
return issues;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
function checkDependencies(projectPath) {
|
|
140
|
-
const issues = [];
|
|
141
|
-
const packageJsonPath = path.join(projectPath, 'package.json');
|
|
142
|
-
|
|
143
|
-
if (!fs.existsSync(packageJsonPath)) {
|
|
144
|
-
return issues;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
try {
|
|
148
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
149
|
-
const deps = { ...packageJson.dependencies, ...packageJson.devDependencies };
|
|
150
|
-
|
|
151
|
-
for (const [dep, version] of Object.entries(deps)) {
|
|
152
|
-
const vulnerable = VULNERABLE_DEPENDENCIES.find(v =>
|
|
153
|
-
v.name === dep && version.match(/\d+\.\d+\.\d+/)?.[0] < v.vulnerable.replace('<', '')
|
|
154
|
-
);
|
|
155
|
-
|
|
156
|
-
if (vulnerable) {
|
|
157
|
-
issues.push({
|
|
158
|
-
file: 'package.json',
|
|
159
|
-
pattern: `Vulnerable dependency: ${dep}@${version}`,
|
|
160
|
-
severity: vulnerable.severity,
|
|
161
|
-
line: 0
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
} catch (e) {
|
|
166
|
-
// Skip if package.json can't be parsed
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
return issues;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
function main() {
|
|
173
|
-
const projectPath = process.argv[2] || process.cwd();
|
|
174
|
-
|
|
175
|
-
log('\n🔐 AI-DEVX Security Scanner\n');
|
|
176
|
-
log('=' .repeat(60));
|
|
177
|
-
|
|
178
|
-
const allIssues = [];
|
|
179
|
-
|
|
180
|
-
// Scan source files
|
|
181
|
-
log('\n📁 Scanning source files...\n');
|
|
182
|
-
const files = getAllFiles(projectPath, []);
|
|
183
|
-
|
|
184
|
-
for (const file of files) {
|
|
185
|
-
if (file.includes('node_modules') || file.includes('.git')) continue;
|
|
186
|
-
|
|
187
|
-
try {
|
|
188
|
-
const content = fs.readFileSync(file, 'utf-8');
|
|
189
|
-
const issues = scanFile(path.relative(projectPath, file), content);
|
|
190
|
-
allIssues.push(...issues);
|
|
191
|
-
} catch (e) {
|
|
192
|
-
// Skip unreadable files
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
// Check dependencies
|
|
197
|
-
log('📦 Checking dependencies...\n');
|
|
198
|
-
const depIssues = checkDependencies(projectPath);
|
|
199
|
-
allIssues.push(...depIssues);
|
|
200
|
-
|
|
201
|
-
// Sort by severity
|
|
202
|
-
const severityOrder = { CRITICAL: 4, HIGH: 3, MEDIUM: 2, LOW: 1, INFO: 0 };
|
|
203
|
-
allIssues.sort((a, b) => severityOrder[b.severity] - severityOrder[a.severity]);
|
|
204
|
-
|
|
205
|
-
// Group by severity
|
|
206
|
-
const grouped = allIssues.reduce((acc, issue) => {
|
|
207
|
-
acc[issue.severity] = acc[issue.severity] || [];
|
|
208
|
-
acc[issue.severity].push(issue);
|
|
209
|
-
return acc;
|
|
210
|
-
}, {});
|
|
211
|
-
|
|
212
|
-
// Display results
|
|
213
|
-
if (allIssues.length === 0) {
|
|
214
|
-
log('\n✅ No security issues found!\n');
|
|
215
|
-
} else {
|
|
216
|
-
log(`\n⚠️ Found ${allIssues.length} security issue(s):\n`);
|
|
217
|
-
|
|
218
|
-
for (const severity of ['CRITICAL', 'HIGH', 'MEDIUM', 'LOW', 'INFO']) {
|
|
219
|
-
const issues = grouped[severity];
|
|
220
|
-
if (issues) {
|
|
221
|
-
log(`\n${SEVERITY[severity].label} (${issues.length}):\n`);
|
|
222
|
-
issues.forEach(issue => {
|
|
223
|
-
log(` 📄 ${issue.file}:${issue.line}`);
|
|
224
|
-
log(` ${issue.pattern}\n`);
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
// Summary
|
|
231
|
-
log('=' .repeat(60));
|
|
232
|
-
const critical = grouped.CRITICAL?.length || 0;
|
|
233
|
-
const high = grouped.HIGH?.length || 0;
|
|
234
|
-
const medium = grouped.MEDIUM?.length || 0;
|
|
235
|
-
const low = grouped.LOW?.length || 0;
|
|
236
|
-
|
|
237
|
-
log(`\nSummary: 🔴 ${critical} Critical | 🟠 ${high} High | 🟡 ${medium} Medium | 🟢 ${low} Low`);
|
|
238
|
-
|
|
239
|
-
if (critical > 0 || high > 0) {
|
|
240
|
-
log('\n⚠️ Critical or High severity issues found! Fix immediately.');
|
|
241
|
-
process.exit(1);
|
|
242
|
-
} else if (medium > 0) {
|
|
243
|
-
log('\n⚠️ Medium severity issues found. Fix recommended.');
|
|
244
|
-
process.exit(0);
|
|
245
|
-
} else {
|
|
246
|
-
log('\n✅ Security scan complete.');
|
|
247
|
-
process.exit(0);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
main();
|
|
@@ -1,286 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: docker-expert
|
|
3
|
-
description: Docker containerization, multi-stage builds, and container orchestration
|
|
4
|
-
version: "1.0.0"
|
|
5
|
-
requires: []
|
|
6
|
-
related:
|
|
7
|
-
- deployment-procedures
|
|
8
|
-
- ci-cd
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
# Docker Expert Skill
|
|
12
|
-
|
|
13
|
-
## Dockerfile Best Practices
|
|
14
|
-
|
|
15
|
-
### Multi-Stage Build
|
|
16
|
-
```dockerfile
|
|
17
|
-
# Build stage
|
|
18
|
-
FROM node:18-alpine AS builder
|
|
19
|
-
WORKDIR /app
|
|
20
|
-
COPY package*.json ./
|
|
21
|
-
RUN npm ci
|
|
22
|
-
COPY . .
|
|
23
|
-
RUN npm run build
|
|
24
|
-
|
|
25
|
-
# Production stage
|
|
26
|
-
FROM node:18-alpine AS production
|
|
27
|
-
WORKDIR /app
|
|
28
|
-
ENV NODE_ENV=production
|
|
29
|
-
COPY package*.json ./
|
|
30
|
-
RUN npm ci --only=production && npm cache clean --force
|
|
31
|
-
COPY --from=builder /app/dist ./dist
|
|
32
|
-
USER node
|
|
33
|
-
EXPOSE 3000
|
|
34
|
-
CMD ["node", "dist/main.js"]
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
### Optimization Tips
|
|
38
|
-
|
|
39
|
-
**Use specific tags**
|
|
40
|
-
```dockerfile
|
|
41
|
-
# ✅ Good
|
|
42
|
-
FROM node:18.19.0-alpine3.19
|
|
43
|
-
|
|
44
|
-
# ❌ Avoid
|
|
45
|
-
FROM node:latest
|
|
46
|
-
FROM node:18
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
**Minimize layers**
|
|
50
|
-
```dockerfile
|
|
51
|
-
# ✅ Good - Single layer
|
|
52
|
-
RUN apt-get update && apt-get install -y \
|
|
53
|
-
package1 \
|
|
54
|
-
package2 \
|
|
55
|
-
&& rm -rf /var/lib/apt/lists/*
|
|
56
|
-
|
|
57
|
-
# ❌ Bad - Multiple layers
|
|
58
|
-
RUN apt-get update
|
|
59
|
-
RUN apt-get install -y package1
|
|
60
|
-
RUN apt-get install -y package2
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
**Leverage build cache**
|
|
64
|
-
```dockerfile
|
|
65
|
-
# Copy dependency files first (cache if unchanged)
|
|
66
|
-
COPY package*.json ./
|
|
67
|
-
RUN npm ci
|
|
68
|
-
|
|
69
|
-
# Copy source code (invalidates cache on change)
|
|
70
|
-
COPY . .
|
|
71
|
-
RUN npm run build
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
**Use .dockerignore**
|
|
75
|
-
```
|
|
76
|
-
node_modules
|
|
77
|
-
npm-debug.log
|
|
78
|
-
Dockerfile
|
|
79
|
-
.dockerignore
|
|
80
|
-
.git
|
|
81
|
-
.gitignore
|
|
82
|
-
README.md
|
|
83
|
-
.env
|
|
84
|
-
.env.local
|
|
85
|
-
dist
|
|
86
|
-
build
|
|
87
|
-
coverage
|
|
88
|
-
.nyc_output
|
|
89
|
-
.vscode
|
|
90
|
-
.idea
|
|
91
|
-
*.md
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
## Docker Compose
|
|
95
|
-
|
|
96
|
-
### Web Application Stack
|
|
97
|
-
```yaml
|
|
98
|
-
version: '3.8'
|
|
99
|
-
|
|
100
|
-
services:
|
|
101
|
-
app:
|
|
102
|
-
build:
|
|
103
|
-
context: .
|
|
104
|
-
dockerfile: Dockerfile
|
|
105
|
-
ports:
|
|
106
|
-
- "3000:3000"
|
|
107
|
-
environment:
|
|
108
|
-
- NODE_ENV=production
|
|
109
|
-
- DATABASE_URL=postgresql://user:pass@db:5432/mydb
|
|
110
|
-
- REDIS_URL=redis://redis:6379
|
|
111
|
-
depends_on:
|
|
112
|
-
- db
|
|
113
|
-
- redis
|
|
114
|
-
volumes:
|
|
115
|
-
- ./logs:/app/logs
|
|
116
|
-
restart: unless-stopped
|
|
117
|
-
healthcheck:
|
|
118
|
-
test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
|
|
119
|
-
interval: 30s
|
|
120
|
-
timeout: 10s
|
|
121
|
-
retries: 3
|
|
122
|
-
|
|
123
|
-
db:
|
|
124
|
-
image: postgres:15-alpine
|
|
125
|
-
environment:
|
|
126
|
-
POSTGRES_USER: user
|
|
127
|
-
POSTGRES_PASSWORD: pass
|
|
128
|
-
POSTGRES_DB: mydb
|
|
129
|
-
volumes:
|
|
130
|
-
- postgres_data:/var/lib/postgresql/data
|
|
131
|
-
- ./init.sql:/docker-entrypoint-initdb.d/init.sql
|
|
132
|
-
ports:
|
|
133
|
-
- "5432:5432"
|
|
134
|
-
restart: unless-stopped
|
|
135
|
-
|
|
136
|
-
redis:
|
|
137
|
-
image: redis:7-alpine
|
|
138
|
-
volumes:
|
|
139
|
-
- redis_data:/data
|
|
140
|
-
restart: unless-stopped
|
|
141
|
-
|
|
142
|
-
nginx:
|
|
143
|
-
image: nginx:alpine
|
|
144
|
-
ports:
|
|
145
|
-
- "80:80"
|
|
146
|
-
- "443:443"
|
|
147
|
-
volumes:
|
|
148
|
-
- ./nginx.conf:/etc/nginx/nginx.conf:ro
|
|
149
|
-
- ./ssl:/etc/nginx/ssl:ro
|
|
150
|
-
depends_on:
|
|
151
|
-
- app
|
|
152
|
-
restart: unless-stopped
|
|
153
|
-
|
|
154
|
-
volumes:
|
|
155
|
-
postgres_data:
|
|
156
|
-
redis_data:
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
### Development vs Production
|
|
160
|
-
|
|
161
|
-
**docker-compose.yml** (Production)
|
|
162
|
-
```yaml
|
|
163
|
-
version: '3.8'
|
|
164
|
-
services:
|
|
165
|
-
app:
|
|
166
|
-
build: .
|
|
167
|
-
environment:
|
|
168
|
-
- NODE_ENV=production
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
**docker-compose.dev.yml** (Development)
|
|
172
|
-
```yaml
|
|
173
|
-
version: '3.8'
|
|
174
|
-
services:
|
|
175
|
-
app:
|
|
176
|
-
build:
|
|
177
|
-
context: .
|
|
178
|
-
target: development
|
|
179
|
-
volumes:
|
|
180
|
-
- .:/app
|
|
181
|
-
- /app/node_modules
|
|
182
|
-
environment:
|
|
183
|
-
- NODE_ENV=development
|
|
184
|
-
command: npm run dev
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
Usage:
|
|
188
|
-
```bash
|
|
189
|
-
# Production
|
|
190
|
-
docker-compose up -d
|
|
191
|
-
|
|
192
|
-
# Development
|
|
193
|
-
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
## Container Security
|
|
197
|
-
|
|
198
|
-
### Non-root User
|
|
199
|
-
```dockerfile
|
|
200
|
-
FROM node:18-alpine
|
|
201
|
-
|
|
202
|
-
# Create app user
|
|
203
|
-
RUN addgroup -g 1001 -S nodejs
|
|
204
|
-
RUN adduser -S nodejs -u 1001
|
|
205
|
-
|
|
206
|
-
WORKDIR /app
|
|
207
|
-
COPY --chown=nodejs:nodejs . .
|
|
208
|
-
RUN npm ci --only=production
|
|
209
|
-
|
|
210
|
-
USER nodejs
|
|
211
|
-
EXPOSE 3000
|
|
212
|
-
CMD ["node", "server.js"]
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
### Read-only Filesystem
|
|
216
|
-
```yaml
|
|
217
|
-
services:
|
|
218
|
-
app:
|
|
219
|
-
read_only: true
|
|
220
|
-
tmpfs:
|
|
221
|
-
- /tmp
|
|
222
|
-
volumes:
|
|
223
|
-
- ./logs:/app/logs
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
### Scan for Vulnerabilities
|
|
227
|
-
```bash
|
|
228
|
-
# Using Trivy
|
|
229
|
-
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock \
|
|
230
|
-
aquasec/trivy image myapp:latest
|
|
231
|
-
|
|
232
|
-
# Using Docker Scout
|
|
233
|
-
docker scout cves myapp:latest
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
## Common Commands
|
|
237
|
-
|
|
238
|
-
```bash
|
|
239
|
-
# Build image
|
|
240
|
-
docker build -t myapp:latest .
|
|
241
|
-
|
|
242
|
-
# Run container
|
|
243
|
-
docker run -d -p 3000:3000 --name myapp myapp:latest
|
|
244
|
-
|
|
245
|
-
# View logs
|
|
246
|
-
docker logs -f myapp
|
|
247
|
-
|
|
248
|
-
# Execute command in container
|
|
249
|
-
docker exec -it myapp sh
|
|
250
|
-
|
|
251
|
-
# Remove stopped containers
|
|
252
|
-
docker container prune
|
|
253
|
-
|
|
254
|
-
# Remove unused images
|
|
255
|
-
docker image prune
|
|
256
|
-
|
|
257
|
-
# Clean everything
|
|
258
|
-
docker system prune -a
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
## Health Checks
|
|
262
|
-
|
|
263
|
-
```dockerfile
|
|
264
|
-
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
|
265
|
-
CMD curl -f http://localhost:3000/health || exit 1
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
## Environment Variables
|
|
269
|
-
|
|
270
|
-
```dockerfile
|
|
271
|
-
# Set at build time
|
|
272
|
-
ARG NODE_VERSION=18
|
|
273
|
-
FROM node:${NODE_VERSION}-alpine
|
|
274
|
-
|
|
275
|
-
# Set at runtime
|
|
276
|
-
ENV NODE_ENV=production
|
|
277
|
-
ENV PORT=3000
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
```bash
|
|
281
|
-
# Pass at build
|
|
282
|
-
docker build --build-arg NODE_VERSION=20 -t myapp .
|
|
283
|
-
|
|
284
|
-
# Pass at runtime
|
|
285
|
-
docker run -e NODE_ENV=production -e PORT=3000 myapp
|
|
286
|
-
```
|