@feardread/fear 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/FEAR.js +459 -0
- package/FEARServer.js +280 -0
- package/controllers/agent.js +438 -0
- package/controllers/auth/index.js +345 -0
- package/controllers/auth/token.js +50 -0
- package/controllers/blog.js +105 -0
- package/controllers/brand.js +10 -0
- package/controllers/cart.js +425 -0
- package/controllers/category.js +9 -0
- package/controllers/coupon.js +63 -0
- package/controllers/crud/crud.js +508 -0
- package/controllers/crud/index.js +36 -0
- package/controllers/email.js +34 -0
- package/controllers/enquiry.js +65 -0
- package/controllers/events.js +9 -0
- package/controllers/order.js +125 -0
- package/controllers/payment.js +31 -0
- package/controllers/product.js +147 -0
- package/controllers/review.js +247 -0
- package/controllers/tag.js +10 -0
- package/controllers/task.js +10 -0
- package/controllers/upload.js +41 -0
- package/controllers/user.js +401 -0
- package/index.js +7 -0
- package/libs/agent/index.js +561 -0
- package/libs/agent/modules/ai/ai.js +285 -0
- package/libs/agent/modules/ai/chat.js +518 -0
- package/libs/agent/modules/ai/config.js +688 -0
- package/libs/agent/modules/ai/operations.js +787 -0
- package/libs/agent/modules/analyze/api.js +546 -0
- package/libs/agent/modules/analyze/dorks.js +395 -0
- package/libs/agent/modules/ccard/README.md +454 -0
- package/libs/agent/modules/ccard/audit.js +479 -0
- package/libs/agent/modules/ccard/checker.js +674 -0
- package/libs/agent/modules/ccard/payment-processors.json +16 -0
- package/libs/agent/modules/ccard/validator.js +629 -0
- package/libs/agent/modules/code/analyzer.js +303 -0
- package/libs/agent/modules/code/jquery.js +1093 -0
- package/libs/agent/modules/code/react.js +1536 -0
- package/libs/agent/modules/code/refactor.js +499 -0
- package/libs/agent/modules/crypto/exchange.js +564 -0
- package/libs/agent/modules/net/proxy.js +409 -0
- package/libs/agent/modules/security/cve.js +442 -0
- package/libs/agent/modules/security/monitor.js +360 -0
- package/libs/agent/modules/security/scanner.js +300 -0
- package/libs/agent/modules/security/vulnerability.js +506 -0
- package/libs/agent/modules/security/web.js +465 -0
- package/libs/agent/modules/utils/browser.js +492 -0
- package/libs/agent/modules/utils/colorizer.js +285 -0
- package/libs/agent/modules/utils/manager.js +478 -0
- package/libs/cloud/index.js +228 -0
- package/libs/config/db.js +21 -0
- package/libs/config/validator.js +82 -0
- package/libs/db/index.js +318 -0
- package/libs/emailer/imap.js +126 -0
- package/libs/emailer/info.js +41 -0
- package/libs/emailer/smtp.js +77 -0
- package/libs/handler/async.js +3 -0
- package/libs/handler/error.js +66 -0
- package/libs/handler/index.js +161 -0
- package/libs/logger/index.js +49 -0
- package/libs/logger/morgan.js +24 -0
- package/libs/passport/passport.js +109 -0
- package/libs/search/api.js +384 -0
- package/libs/search/features.js +219 -0
- package/libs/search/service.js +64 -0
- package/libs/swagger/config.js +18 -0
- package/libs/swagger/index.js +35 -0
- package/libs/validator/index.js +254 -0
- package/models/blog.js +31 -0
- package/models/brand.js +12 -0
- package/models/cart.js +14 -0
- package/models/category.js +11 -0
- package/models/coupon.js +9 -0
- package/models/customer.js +0 -0
- package/models/enquiry.js +29 -0
- package/models/events.js +13 -0
- package/models/order.js +94 -0
- package/models/product.js +32 -0
- package/models/review.js +14 -0
- package/models/tag.js +10 -0
- package/models/task.js +11 -0
- package/models/user.js +68 -0
- package/package.json +12 -0
- package/routes/agent.js +615 -0
- package/routes/auth.js +13 -0
- package/routes/blog.js +19 -0
- package/routes/brand.js +15 -0
- package/routes/cart.js +105 -0
- package/routes/category.js +16 -0
- package/routes/coupon.js +15 -0
- package/routes/enquiry.js +14 -0
- package/routes/events.js +16 -0
- package/routes/mail.js +170 -0
- package/routes/order.js +19 -0
- package/routes/product.js +22 -0
- package/routes/review.js +11 -0
- package/routes/task.js +12 -0
- package/routes/user.js +17 -0
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
// modules/ai/ai.js - Enhanced Main AI Module
|
|
2
|
+
const AIConfig = require('./config');
|
|
3
|
+
const AIOperations = require('./operations');
|
|
4
|
+
const colorizer = require('../utils/colorizer');
|
|
5
|
+
|
|
6
|
+
const AiAnalyzer = function() {
|
|
7
|
+
// Initialize configuration
|
|
8
|
+
this.config = new AIConfig();
|
|
9
|
+
|
|
10
|
+
// Initialize operations with config reference
|
|
11
|
+
this.operations = new AIOperations(this.config);
|
|
12
|
+
|
|
13
|
+
// Track initialization status
|
|
14
|
+
this.initialized = false;
|
|
15
|
+
|
|
16
|
+
console.log(colorizer.dim('\n🤖 AI Module Loading...'));
|
|
17
|
+
this.initialize();
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
AiAnalyzer.prototype = {
|
|
21
|
+
initialize() {
|
|
22
|
+
// Check if any provider is configured
|
|
23
|
+
const configured = this.config.isConfigured();
|
|
24
|
+
|
|
25
|
+
if (configured) {
|
|
26
|
+
console.log(colorizer.success('✓ AI Module Ready'));
|
|
27
|
+
console.log(colorizer.dim(` Active Provider: ${this.config.getProviderName()}`));
|
|
28
|
+
console.log(colorizer.dim(` Model: ${this.config.getModel()}`));
|
|
29
|
+
this.initialized = true;
|
|
30
|
+
} else {
|
|
31
|
+
console.log(colorizer.warning('⚠ AI Module: No provider configured'));
|
|
32
|
+
console.log(colorizer.dim(' Run "ai-setup" to configure a provider'));
|
|
33
|
+
}
|
|
34
|
+
console.log();
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
// Configuration methods
|
|
38
|
+
setup(args) {
|
|
39
|
+
return this.config.setup(args)
|
|
40
|
+
.then(result => {
|
|
41
|
+
if (result) {
|
|
42
|
+
this.initialized = true;
|
|
43
|
+
}
|
|
44
|
+
return result;
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
setProvider(args) {
|
|
49
|
+
return this.config.setProvider(args)
|
|
50
|
+
.then(() => {
|
|
51
|
+
if (this.config.isConfigured()) {
|
|
52
|
+
this.initialized = true;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
isConfigured() {
|
|
58
|
+
return this.config.isConfigured();
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
getProviderName() {
|
|
62
|
+
return this.config.getProviderName();
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
getProvider() {
|
|
66
|
+
return this.config.getProvider();
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
getModel() {
|
|
70
|
+
return this.config.getModel();
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
// Operation methods - Code Analysis
|
|
74
|
+
analyzeCode(args) {
|
|
75
|
+
if (!this.ensureConfigured()) return Promise.resolve();
|
|
76
|
+
return this.operations.analyzeCode(args);
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
analyzeBatch(args) {
|
|
80
|
+
if (!this.ensureConfigured()) return Promise.resolve();
|
|
81
|
+
return this.operations.analyzeBatch(args);
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
compareCodeVersions(args) {
|
|
85
|
+
if (!this.ensureConfigured()) return Promise.resolve();
|
|
86
|
+
return this.operations.compareCodeVersions(args);
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
// Operation methods - Security Analysis
|
|
90
|
+
threatAssessment(args) {
|
|
91
|
+
if (!this.ensureConfigured()) return Promise.resolve();
|
|
92
|
+
return this.operations.threatAssessment(args);
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
explainVulnerability(args) {
|
|
96
|
+
if (!this.ensureConfigured()) return Promise.resolve();
|
|
97
|
+
return this.operations.explainVulnerability(args);
|
|
98
|
+
},
|
|
99
|
+
|
|
100
|
+
analyzeTrafficPattern(trafficData) {
|
|
101
|
+
if (!this.ensureConfigured()) return Promise.resolve(null);
|
|
102
|
+
return this.operations.analyzeTrafficPattern(trafficData);
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
// Operation methods - Code Generation
|
|
106
|
+
generateNodeCode(args) {
|
|
107
|
+
if (!this.ensureConfigured()) return Promise.resolve();
|
|
108
|
+
return this.operations.generateNodeCode(args);
|
|
109
|
+
},
|
|
110
|
+
|
|
111
|
+
// Operation methods - Recommendations
|
|
112
|
+
suggestImprovements(args) {
|
|
113
|
+
if (!this.ensureConfigured()) return Promise.resolve();
|
|
114
|
+
return this.operations.suggestImprovements(args);
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
// Operation methods - Chat
|
|
118
|
+
chat(args) {
|
|
119
|
+
if (!this.ensureConfigured()) return Promise.resolve();
|
|
120
|
+
return this.operations.chat(args);
|
|
121
|
+
},
|
|
122
|
+
|
|
123
|
+
clearChatHistory() {
|
|
124
|
+
this.operations.clearHistory();
|
|
125
|
+
console.log(colorizer.success('Chat history cleared.\n'));
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
// Utility methods
|
|
129
|
+
ensureConfigured() {
|
|
130
|
+
if (!this.initialized || !this.config.isConfigured()) {
|
|
131
|
+
console.log(colorizer.error('AI not configured. Please run "ai-setup <provider> <key>" first.\n'));
|
|
132
|
+
console.log(colorizer.info('Supported providers:'));
|
|
133
|
+
console.log(colorizer.dim(' * anthropic (Claude)'));
|
|
134
|
+
console.log(colorizer.dim(' * openai (GPT)'));
|
|
135
|
+
console.log(colorizer.dim(' * google (Gemini)\n'));
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
return true;
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
// Status and info methods
|
|
142
|
+
status() {
|
|
143
|
+
console.log(colorizer.header('AI Module Status'));
|
|
144
|
+
console.log(colorizer.separator());
|
|
145
|
+
|
|
146
|
+
console.log(colorizer.section('Configuration'));
|
|
147
|
+
console.log(colorizer.cyan(' Status: ') +
|
|
148
|
+
(this.initialized ? colorizer.green('✓ Initialized') : colorizer.red('✗ Not initialized')));
|
|
149
|
+
|
|
150
|
+
if (this.config.isConfigured()) {
|
|
151
|
+
console.log(colorizer.cyan(' Provider: ') + colorizer.bright(this.config.getProviderName()));
|
|
152
|
+
console.log(colorizer.cyan(' Model: ') + colorizer.dim(this.config.getModel()));
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
console.log();
|
|
156
|
+
console.log(colorizer.section('Available Providers'));
|
|
157
|
+
|
|
158
|
+
const providers = [
|
|
159
|
+
{ name: 'Anthropic Claude', key: 'anthropic', available: !!this.config.anthropic },
|
|
160
|
+
{ name: 'OpenAI GPT', key: 'openai', available: !!this.config.openai },
|
|
161
|
+
{ name: 'Google Gemini', key: 'google', available: !!this.config.googleAi }
|
|
162
|
+
];
|
|
163
|
+
|
|
164
|
+
providers.forEach(p => {
|
|
165
|
+
const status = p.available ? colorizer.green('✓ Available') : colorizer.red('✗ Not configured');
|
|
166
|
+
const model = p.available ? colorizer.dim(` (${this.config.models[p.key]})`) : '';
|
|
167
|
+
console.log(` ${p.name}: ${status}${model}`);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
console.log();
|
|
171
|
+
console.log(colorizer.section('Available Commands'));
|
|
172
|
+
console.log(colorizer.bullet('ai-setup <provider> <key> - Configure AI provider'));
|
|
173
|
+
console.log(colorizer.bullet('ai-provider <name> - Switch provider'));
|
|
174
|
+
console.log(colorizer.bullet('ai-analyze <file> - Analyze code security'));
|
|
175
|
+
console.log(colorizer.bullet('ai-batch <dir> [ext] - Batch analyze files'));
|
|
176
|
+
console.log(colorizer.bullet('ai-compare <file1> <file2> - Compare versions'));
|
|
177
|
+
console.log(colorizer.bullet('ai-threat <description> - Threat assessment'));
|
|
178
|
+
console.log(colorizer.bullet('ai-explain <vulnerability> - Explain concept'));
|
|
179
|
+
console.log(colorizer.bullet('ai-generate <description> - Generate code'));
|
|
180
|
+
console.log(colorizer.bullet('ai-improve [path] - Suggest improvements'));
|
|
181
|
+
console.log(colorizer.bullet('ai-chat [query] - Interactive chat'));
|
|
182
|
+
console.log();
|
|
183
|
+
|
|
184
|
+
if (this.operations.conversationHistory.length > 0) {
|
|
185
|
+
console.log(colorizer.section('Chat History'));
|
|
186
|
+
console.log(colorizer.cyan(' Messages: ') + this.operations.conversationHistory.length);
|
|
187
|
+
console.log(colorizer.dim(' Use "ai-chat /history" to view'));
|
|
188
|
+
console.log();
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
return Promise.resolve();
|
|
192
|
+
},
|
|
193
|
+
|
|
194
|
+
help() {
|
|
195
|
+
console.log(colorizer.header('AI Module Help'));
|
|
196
|
+
console.log(colorizer.separator());
|
|
197
|
+
|
|
198
|
+
console.log(colorizer.section('Setup & Configuration'));
|
|
199
|
+
console.log(colorizer.cyan(' ai-setup <provider> <key>'));
|
|
200
|
+
console.log(colorizer.dim(' Configure an AI provider (anthropic, openai, google)'));
|
|
201
|
+
console.log(colorizer.dim(' Example: ai-setup openai sk-your-key-here'));
|
|
202
|
+
console.log();
|
|
203
|
+
console.log(colorizer.cyan(' ai-provider <name>'));
|
|
204
|
+
console.log(colorizer.dim(' Switch between configured providers'));
|
|
205
|
+
console.log(colorizer.dim(' Example: ai-provider google'));
|
|
206
|
+
console.log();
|
|
207
|
+
|
|
208
|
+
console.log(colorizer.section('Code Analysis'));
|
|
209
|
+
console.log(colorizer.cyan(' ai-analyze <file-path>'));
|
|
210
|
+
console.log(colorizer.dim(' Perform security analysis on a code file'));
|
|
211
|
+
console.log(colorizer.dim(' Example: ai-analyze ./src/auth.js'));
|
|
212
|
+
console.log();
|
|
213
|
+
console.log(colorizer.cyan(' ai-batch <directory> [extension]'));
|
|
214
|
+
console.log(colorizer.dim(' Analyze multiple files in a directory'));
|
|
215
|
+
console.log(colorizer.dim(' Example: ai-batch ./src .js'));
|
|
216
|
+
console.log();
|
|
217
|
+
console.log(colorizer.cyan(' ai-compare <file1> <file2>'));
|
|
218
|
+
console.log(colorizer.dim(' Compare security between two code versions'));
|
|
219
|
+
console.log(colorizer.dim(' Example: ai-compare old.js new.js'));
|
|
220
|
+
console.log();
|
|
221
|
+
|
|
222
|
+
console.log(colorizer.section('Security Intelligence'));
|
|
223
|
+
console.log(colorizer.cyan(' ai-threat <description>'));
|
|
224
|
+
console.log(colorizer.dim(' Get comprehensive threat assessment'));
|
|
225
|
+
console.log(colorizer.dim(' Example: ai-threat SQL injection vulnerability'));
|
|
226
|
+
console.log();
|
|
227
|
+
console.log(colorizer.cyan(' ai-explain <vulnerability>'));
|
|
228
|
+
console.log(colorizer.dim(' Get detailed explanation of security concepts'));
|
|
229
|
+
console.log(colorizer.dim(' Example: ai-explain CWE-79'));
|
|
230
|
+
console.log();
|
|
231
|
+
|
|
232
|
+
console.log(colorizer.section('Code Generation'));
|
|
233
|
+
console.log(colorizer.cyan(' ai-generate <description>'));
|
|
234
|
+
console.log(colorizer.dim(' Generate secure Node.js code'));
|
|
235
|
+
console.log(colorizer.dim(' Example: ai-generate JWT authentication middleware'));
|
|
236
|
+
console.log();
|
|
237
|
+
|
|
238
|
+
console.log(colorizer.section('Project Improvement'));
|
|
239
|
+
console.log(colorizer.cyan(' ai-improve [project-path]'));
|
|
240
|
+
console.log(colorizer.dim(' Get security recommendations for your project'));
|
|
241
|
+
console.log(colorizer.dim(' Example: ai-improve ./my-app'));
|
|
242
|
+
console.log();
|
|
243
|
+
|
|
244
|
+
console.log(colorizer.section('Interactive Chat'));
|
|
245
|
+
console.log(colorizer.cyan(' ai-chat [query]'));
|
|
246
|
+
console.log(colorizer.dim(' Chat with AI assistant'));
|
|
247
|
+
console.log(colorizer.dim(' • With query: Single question mode'));
|
|
248
|
+
console.log(colorizer.dim(' • Without query: Interactive conversation mode'));
|
|
249
|
+
console.log(colorizer.dim(' Example: ai-chat How to prevent XSS attacks?'));
|
|
250
|
+
console.log();
|
|
251
|
+
console.log(colorizer.dim(' Chat Commands (interactive mode):'));
|
|
252
|
+
console.log(colorizer.dim(' /exit, /quit - Exit chat'));
|
|
253
|
+
console.log(colorizer.dim(' /clear - Clear conversation history'));
|
|
254
|
+
console.log(colorizer.dim(' /history - Show conversation'));
|
|
255
|
+
console.log(colorizer.dim(' /save <file> - Save conversation'));
|
|
256
|
+
console.log(colorizer.dim(' /stream - Toggle streaming (Gemini)'));
|
|
257
|
+
console.log();
|
|
258
|
+
|
|
259
|
+
console.log(colorizer.section('Tips'));
|
|
260
|
+
console.log(colorizer.dim(' • Set AI_PROVIDER env variable to auto-select provider'));
|
|
261
|
+
console.log(colorizer.dim(' • Use environment variables for API keys'));
|
|
262
|
+
console.log(colorizer.dim(' • Google Gemini supports streaming responses'));
|
|
263
|
+
console.log(colorizer.dim(' • Chat maintains context for follow-up questions'));
|
|
264
|
+
console.log(colorizer.dim(' • Batch analysis works on entire directories'));
|
|
265
|
+
console.log();
|
|
266
|
+
|
|
267
|
+
return Promise.resolve();
|
|
268
|
+
},
|
|
269
|
+
|
|
270
|
+
// Quick access to commonly used features
|
|
271
|
+
quickScan(filePath) {
|
|
272
|
+
console.log(colorizer.info('Quick Security Scan'));
|
|
273
|
+
return this.analyzeCode([filePath]);
|
|
274
|
+
},
|
|
275
|
+
|
|
276
|
+
quickChat(query) {
|
|
277
|
+
if (!query) {
|
|
278
|
+
console.log(colorizer.error('Please provide a query for quick chat\n'));
|
|
279
|
+
return Promise.resolve();
|
|
280
|
+
}
|
|
281
|
+
return this.chat([query]);
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
module.exports = AiAnalyzer;
|