ruvector 0.1.80 → 0.1.81
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/dist/analysis/complexity.d.ts +52 -0
- package/dist/analysis/complexity.d.ts.map +1 -0
- package/dist/analysis/complexity.js +146 -0
- package/dist/analysis/index.d.ts +15 -0
- package/dist/analysis/index.d.ts.map +1 -0
- package/dist/analysis/index.js +38 -0
- package/dist/analysis/patterns.d.ts +71 -0
- package/dist/analysis/patterns.d.ts.map +1 -0
- package/dist/analysis/patterns.js +243 -0
- package/dist/analysis/security.d.ts +51 -0
- package/dist/analysis/security.d.ts.map +1 -0
- package/dist/analysis/security.js +139 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +2 -0
- package/dist/core/parallel-workers.d.ts +2 -8
- package/dist/core/parallel-workers.d.ts.map +1 -1
- package/dist/workers/native-worker.d.ts +3 -3
- package/dist/workers/native-worker.d.ts.map +1 -1
- package/dist/workers/native-worker.js +45 -87
- package/package.json +1 -1
- package/.agentic-flow/intelligence.db +0 -0
- package/.agentic-flow/vectors.db +0 -0
- package/.agentic-flow/workers.db +0 -0
- package/.claude-flow/metrics/agent-metrics.json +0 -1
- package/.claude-flow/metrics/performance.json +0 -87
- package/.claude-flow/metrics/task-metrics.json +0 -10
- package/.ruvector/intelligence.json +0 -5289
- package/.ruvector/workers/code-analyzer.db +0 -0
- package/ruvector.db +0 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Security Analysis Module - Consolidated security scanning
|
|
4
|
+
*
|
|
5
|
+
* Single source of truth for security patterns and vulnerability detection.
|
|
6
|
+
* Used by native-worker.ts and parallel-workers.ts
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
+
}) : function(o, v) {
|
|
22
|
+
o["default"] = v;
|
|
23
|
+
});
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.SECURITY_PATTERNS = void 0;
|
|
43
|
+
exports.scanFile = scanFile;
|
|
44
|
+
exports.scanFiles = scanFiles;
|
|
45
|
+
exports.getSeverityScore = getSeverityScore;
|
|
46
|
+
exports.sortBySeverity = sortBySeverity;
|
|
47
|
+
const fs = __importStar(require("fs"));
|
|
48
|
+
/**
|
|
49
|
+
* Default security patterns for vulnerability detection
|
|
50
|
+
*/
|
|
51
|
+
exports.SECURITY_PATTERNS = [
|
|
52
|
+
// Critical: Hardcoded secrets
|
|
53
|
+
{ pattern: /password\s*=\s*['"][^'"]+['"]/gi, rule: 'no-hardcoded-password', severity: 'critical', message: 'Hardcoded password detected', suggestion: 'Use environment variables or secret management' },
|
|
54
|
+
{ pattern: /api[_-]?key\s*=\s*['"][^'"]+['"]/gi, rule: 'no-hardcoded-apikey', severity: 'critical', message: 'Hardcoded API key detected', suggestion: 'Use environment variables' },
|
|
55
|
+
{ pattern: /secret\s*=\s*['"][^'"]+['"]/gi, rule: 'no-hardcoded-secret', severity: 'critical', message: 'Hardcoded secret detected', suggestion: 'Use environment variables or secret management' },
|
|
56
|
+
{ pattern: /private[_-]?key\s*=\s*['"][^'"]+['"]/gi, rule: 'no-hardcoded-private-key', severity: 'critical', message: 'Hardcoded private key detected', suggestion: 'Use secure key management' },
|
|
57
|
+
// High: Code execution risks
|
|
58
|
+
{ pattern: /eval\s*\(/g, rule: 'no-eval', severity: 'high', message: 'Avoid eval() - code injection risk', suggestion: 'Use safer alternatives like JSON.parse()' },
|
|
59
|
+
{ pattern: /exec\s*\(/g, rule: 'no-exec', severity: 'high', message: 'Avoid exec() - command injection risk', suggestion: 'Use execFile or spawn with args array' },
|
|
60
|
+
{ pattern: /Function\s*\(/g, rule: 'no-function-constructor', severity: 'high', message: 'Avoid Function constructor - code injection risk' },
|
|
61
|
+
{ pattern: /child_process.*exec\(/g, rule: 'no-shell-exec', severity: 'high', message: 'Shell execution detected', suggestion: 'Use execFile or spawn instead' },
|
|
62
|
+
// High: SQL injection
|
|
63
|
+
{ pattern: /SELECT\s+.*\s+FROM.*\+/gi, rule: 'sql-injection-risk', severity: 'high', message: 'Potential SQL injection - string concatenation in query', suggestion: 'Use parameterized queries' },
|
|
64
|
+
{ pattern: /`SELECT.*\$\{/gi, rule: 'sql-injection-template', severity: 'high', message: 'Template literal in SQL query', suggestion: 'Use parameterized queries' },
|
|
65
|
+
// Medium: XSS risks
|
|
66
|
+
{ pattern: /dangerouslySetInnerHTML/g, rule: 'xss-risk', severity: 'medium', message: 'XSS risk: dangerouslySetInnerHTML', suggestion: 'Sanitize content before rendering' },
|
|
67
|
+
{ pattern: /innerHTML\s*=/g, rule: 'no-inner-html', severity: 'medium', message: 'Avoid innerHTML - XSS risk', suggestion: 'Use textContent or sanitize content' },
|
|
68
|
+
{ pattern: /document\.write\s*\(/g, rule: 'no-document-write', severity: 'medium', message: 'Avoid document.write - XSS risk' },
|
|
69
|
+
// Medium: Other risks
|
|
70
|
+
{ pattern: /\$\{.*\}/g, rule: 'template-injection', severity: 'low', message: 'Template literal detected - verify no injection' },
|
|
71
|
+
{ pattern: /new\s+RegExp\s*\([^)]*\+/g, rule: 'regex-injection', severity: 'medium', message: 'Dynamic RegExp - potential ReDoS risk', suggestion: 'Validate/sanitize regex input' },
|
|
72
|
+
{ pattern: /\.on\s*\(\s*['"]error['"]/g, rule: 'unhandled-error', severity: 'low', message: 'Error handler detected - verify proper error handling' },
|
|
73
|
+
];
|
|
74
|
+
/**
|
|
75
|
+
* Scan a single file for security issues
|
|
76
|
+
*/
|
|
77
|
+
function scanFile(filePath, content, patterns = exports.SECURITY_PATTERNS) {
|
|
78
|
+
const findings = [];
|
|
79
|
+
try {
|
|
80
|
+
const fileContent = content ?? (fs.existsSync(filePath) ? fs.readFileSync(filePath, 'utf-8') : '');
|
|
81
|
+
if (!fileContent)
|
|
82
|
+
return findings;
|
|
83
|
+
for (const { pattern, rule, severity, message, suggestion } of patterns) {
|
|
84
|
+
const regex = new RegExp(pattern.source, pattern.flags);
|
|
85
|
+
let match;
|
|
86
|
+
while ((match = regex.exec(fileContent)) !== null) {
|
|
87
|
+
const lineNum = fileContent.slice(0, match.index).split('\n').length;
|
|
88
|
+
findings.push({
|
|
89
|
+
file: filePath,
|
|
90
|
+
line: lineNum,
|
|
91
|
+
severity,
|
|
92
|
+
rule,
|
|
93
|
+
message,
|
|
94
|
+
match: match[0].slice(0, 50),
|
|
95
|
+
suggestion,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
// Skip unreadable files
|
|
102
|
+
}
|
|
103
|
+
return findings;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Scan multiple files for security issues
|
|
107
|
+
*/
|
|
108
|
+
function scanFiles(files, patterns = exports.SECURITY_PATTERNS, maxFiles = 100) {
|
|
109
|
+
const findings = [];
|
|
110
|
+
for (const file of files.slice(0, maxFiles)) {
|
|
111
|
+
findings.push(...scanFile(file, undefined, patterns));
|
|
112
|
+
}
|
|
113
|
+
return findings;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Get severity score (for sorting/filtering)
|
|
117
|
+
*/
|
|
118
|
+
function getSeverityScore(severity) {
|
|
119
|
+
switch (severity) {
|
|
120
|
+
case 'critical': return 4;
|
|
121
|
+
case 'high': return 3;
|
|
122
|
+
case 'medium': return 2;
|
|
123
|
+
case 'low': return 1;
|
|
124
|
+
default: return 0;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Sort findings by severity (highest first)
|
|
129
|
+
*/
|
|
130
|
+
function sortBySeverity(findings) {
|
|
131
|
+
return [...findings].sort((a, b) => getSeverityScore(b.severity) - getSeverityScore(a.severity));
|
|
132
|
+
}
|
|
133
|
+
exports.default = {
|
|
134
|
+
SECURITY_PATTERNS: exports.SECURITY_PATTERNS,
|
|
135
|
+
scanFile,
|
|
136
|
+
scanFiles,
|
|
137
|
+
getSeverityScore,
|
|
138
|
+
sortBySeverity,
|
|
139
|
+
};
|
package/dist/core/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export * from './coverage-router';
|
|
|
21
21
|
export * from './graph-algorithms';
|
|
22
22
|
export * from './tensor-compress';
|
|
23
23
|
export * from './learning-engine';
|
|
24
|
+
export * from '../analysis';
|
|
24
25
|
export { default as gnnWrapper } from './gnn-wrapper';
|
|
25
26
|
export { default as attentionFallbacks } from './attention-fallbacks';
|
|
26
27
|
export { default as agentdbFast } from './agentdb-fast';
|
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAGlC,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,cA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D,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AAGrD,OAAO,EAAE,UAAU,IAAI,SAAS,EAAE,MAAM,cAAc,CAAC;AAGvD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/core/index.js
CHANGED
|
@@ -41,6 +41,8 @@ __exportStar(require("./coverage-router"), exports);
|
|
|
41
41
|
__exportStar(require("./graph-algorithms"), exports);
|
|
42
42
|
__exportStar(require("./tensor-compress"), exports);
|
|
43
43
|
__exportStar(require("./learning-engine"), exports);
|
|
44
|
+
// Analysis module (consolidated security, complexity, patterns)
|
|
45
|
+
__exportStar(require("../analysis"), exports);
|
|
44
46
|
// Re-export default objects for convenience
|
|
45
47
|
var gnn_wrapper_1 = require("./gnn-wrapper");
|
|
46
48
|
Object.defineProperty(exports, "gnnWrapper", { enumerable: true, get: function () { return __importDefault(gnn_wrapper_1).default; } });
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
* - Merge conflict prediction
|
|
39
39
|
* - Code churn metrics
|
|
40
40
|
*/
|
|
41
|
+
import { SecurityFinding } from '../analysis/security';
|
|
41
42
|
export interface WorkerPoolConfig {
|
|
42
43
|
numWorkers?: number;
|
|
43
44
|
enabled?: boolean;
|
|
@@ -59,14 +60,7 @@ export interface ASTAnalysis {
|
|
|
59
60
|
exports: string[];
|
|
60
61
|
dependencies: string[];
|
|
61
62
|
}
|
|
62
|
-
export
|
|
63
|
-
file: string;
|
|
64
|
-
line: number;
|
|
65
|
-
severity: 'low' | 'medium' | 'high' | 'critical';
|
|
66
|
-
rule: string;
|
|
67
|
-
message: string;
|
|
68
|
-
suggestion?: string;
|
|
69
|
-
}
|
|
63
|
+
export type { SecurityFinding };
|
|
70
64
|
export interface ContextChunk {
|
|
71
65
|
content: string;
|
|
72
66
|
source: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parallel-workers.d.ts","sourceRoot":"","sources":["../../src/core/parallel-workers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;
|
|
1
|
+
{"version":3,"file":"parallel-workers.d.ts","sourceRoot":"","sources":["../../src/core/parallel-workers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAQH,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAMvD,MAAM,WAAW,gBAAgB;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU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AAE,MAAY,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAQ9E;;;OAGG;IACG,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAIpD;;;OAGG;IACG,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAQrE,QAAQ,IAAI;QACV,OAAO,EAAE,OAAO,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;QACf,oBAAoB,EAAE,MAAM,CAAC;QAC7B,YAAY,EAAE,MAAM,CAAC;KACtB;IAWD,WAAW,IAAI,IAAI;IAKb,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAchC;AAQD,wBAAgB,qBAAqB,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,kBAAkB,CAKnF;AAED,wBAAsB,sBAAsB,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAInG;AAED,eAAe,kBAAkB,CAAC"}
|
|
@@ -35,7 +35,7 @@ export declare class NativeWorker {
|
|
|
35
35
|
*/
|
|
36
36
|
private phaseFileDiscovery;
|
|
37
37
|
/**
|
|
38
|
-
* Phase: Pattern Extraction
|
|
38
|
+
* Phase: Pattern Extraction (uses shared analysis module)
|
|
39
39
|
*/
|
|
40
40
|
private phasePatternExtraction;
|
|
41
41
|
/**
|
|
@@ -51,11 +51,11 @@ export declare class NativeWorker {
|
|
|
51
51
|
*/
|
|
52
52
|
private phaseSimilaritySearch;
|
|
53
53
|
/**
|
|
54
|
-
* Phase: Security Scan
|
|
54
|
+
* Phase: Security Scan (uses shared analysis module)
|
|
55
55
|
*/
|
|
56
56
|
private phaseSecurityScan;
|
|
57
57
|
/**
|
|
58
|
-
* Phase: Complexity Analysis
|
|
58
|
+
* Phase: Complexity Analysis (uses shared analysis module)
|
|
59
59
|
*/
|
|
60
60
|
private phaseComplexityAnalysis;
|
|
61
61
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-worker.d.ts","sourceRoot":"","sources":["../../src/workers/native-worker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,EACL,YAAY,EACZ,YAAY,EAKb,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"native-worker.d.ts","sourceRoot":"","sources":["../../src/workers/native-worker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,EACL,YAAY,EACZ,YAAY,EAKb,MAAM,SAAS,CAAC;AA0BjB;;GAEG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,QAAQ,CAAa;IAC7B,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,KAAK,CAKX;gBAEU,MAAM,EAAE,YAAY;IAIhC;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAmB3B;;OAEG;IACG,GAAG,CAAC,UAAU,GAAE,MAAY,GAAG,OAAO,CAAC,YAAY,CAAC;IAiD1D;;OAEG;YACW,YAAY;IAmC1B;;OAEG;YACW,kBAAkB;IAqBhC;;OAEG;YACW,sBAAsB;IAoCpC;;OAEG;YACW,wBAAwB;IAgDtC;;OAEG;YACW,kBAAkB;IA8BhC;;OAEG;YACW,qBAAqB;IAoBnC;;OAEG;YACW,iBAAiB;IAuB/B;;OAEG;YACW,uBAAuB;IA0BrC;;OAEG;YACW,kBAAkB;IAqBhC;;OAEG;IACH,OAAO,CAAC,kBAAkB;CAsB3B;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,SAAqB,GAAG,YAAY,CAW5E;AAED,wBAAgB,oBAAoB,CAAC,IAAI,SAAkB,GAAG,YAAY,CAczE;AAED,wBAAgB,oBAAoB,CAAC,IAAI,SAAoB,GAAG,YAAY,CAa3E"}
|
|
@@ -51,6 +51,9 @@ const fs = __importStar(require("fs"));
|
|
|
51
51
|
const path = __importStar(require("path"));
|
|
52
52
|
const glob_1 = require("glob");
|
|
53
53
|
const onnx_embedder_1 = require("../core/onnx-embedder");
|
|
54
|
+
const security_1 = require("../analysis/security");
|
|
55
|
+
const complexity_1 = require("../analysis/complexity");
|
|
56
|
+
const patterns_1 = require("../analysis/patterns");
|
|
54
57
|
// Lazy imports for optional dependencies
|
|
55
58
|
let VectorDb = null;
|
|
56
59
|
let intelligence = null;
|
|
@@ -193,41 +196,28 @@ class NativeWorker {
|
|
|
193
196
|
return { ...context, files };
|
|
194
197
|
}
|
|
195
198
|
/**
|
|
196
|
-
* Phase: Pattern Extraction
|
|
199
|
+
* Phase: Pattern Extraction (uses shared analysis module)
|
|
197
200
|
*/
|
|
198
201
|
async phasePatternExtraction(context, config) {
|
|
199
202
|
const patterns = [];
|
|
200
203
|
const patternTypes = config?.types || ['function', 'class', 'import', 'export', 'todo'];
|
|
201
204
|
for (const file of context.files.slice(0, 100)) {
|
|
202
205
|
try {
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
// Extract TODOs
|
|
220
|
-
if (patternTypes.includes('todo')) {
|
|
221
|
-
const todoMatches = content.match(/\/\/\s*(TODO|FIXME|HACK|XXX):.*/gi) || [];
|
|
222
|
-
patterns.push(...todoMatches.map(m => ({ type: 'todo', match: m, file })));
|
|
223
|
-
// Add findings for TODOs
|
|
224
|
-
todoMatches.forEach(m => {
|
|
225
|
-
this.findings.push({
|
|
226
|
-
type: 'info',
|
|
227
|
-
message: m,
|
|
228
|
-
file,
|
|
229
|
-
});
|
|
230
|
-
});
|
|
206
|
+
const filePatterns = (0, patterns_1.extractAllPatterns)(file);
|
|
207
|
+
const matches = (0, patterns_1.toPatternMatches)(filePatterns);
|
|
208
|
+
// Filter by requested pattern types
|
|
209
|
+
for (const match of matches) {
|
|
210
|
+
if (patternTypes.includes(match.type)) {
|
|
211
|
+
patterns.push(match);
|
|
212
|
+
// Add findings for TODOs
|
|
213
|
+
if (match.type === 'todo') {
|
|
214
|
+
this.findings.push({
|
|
215
|
+
type: 'info',
|
|
216
|
+
message: match.match,
|
|
217
|
+
file,
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
}
|
|
231
221
|
}
|
|
232
222
|
}
|
|
233
223
|
catch {
|
|
@@ -324,75 +314,43 @@ class NativeWorker {
|
|
|
324
314
|
return { ...context, searchResults: results };
|
|
325
315
|
}
|
|
326
316
|
/**
|
|
327
|
-
* Phase: Security Scan
|
|
317
|
+
* Phase: Security Scan (uses shared analysis module)
|
|
328
318
|
*/
|
|
329
319
|
async phaseSecurityScan(context, config) {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
{
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
for (const { pattern, severity, type } of securityPatterns) {
|
|
344
|
-
let match;
|
|
345
|
-
const regex = new RegExp(pattern.source, pattern.flags);
|
|
346
|
-
while ((match = regex.exec(content)) !== null) {
|
|
347
|
-
const lineNum = content.slice(0, match.index).split('\n').length;
|
|
348
|
-
this.findings.push({
|
|
349
|
-
type: 'security',
|
|
350
|
-
message: `${type}: ${match[0].slice(0, 50)}...`,
|
|
351
|
-
file,
|
|
352
|
-
line: lineNum,
|
|
353
|
-
severity: severity === 'high' ? 3 : 2,
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
catch {
|
|
359
|
-
// Skip
|
|
360
|
-
}
|
|
320
|
+
// Use consolidated security scanner
|
|
321
|
+
const findings = (0, security_1.scanFiles)(context.files, undefined, 100);
|
|
322
|
+
// Convert to worker findings format
|
|
323
|
+
for (const finding of findings) {
|
|
324
|
+
this.findings.push({
|
|
325
|
+
type: 'security',
|
|
326
|
+
message: `${finding.rule}: ${finding.message}`,
|
|
327
|
+
file: finding.file,
|
|
328
|
+
line: finding.line,
|
|
329
|
+
severity: finding.severity === 'critical' ? 4 :
|
|
330
|
+
finding.severity === 'high' ? 3 :
|
|
331
|
+
finding.severity === 'medium' ? 2 : 1,
|
|
332
|
+
});
|
|
361
333
|
}
|
|
362
334
|
return context;
|
|
363
335
|
}
|
|
364
336
|
/**
|
|
365
|
-
* Phase: Complexity Analysis
|
|
337
|
+
* Phase: Complexity Analysis (uses shared analysis module)
|
|
366
338
|
*/
|
|
367
339
|
async phaseComplexityAnalysis(context, config) {
|
|
368
340
|
const complexityThreshold = config?.threshold || 10;
|
|
369
341
|
const complexFiles = [];
|
|
370
342
|
for (const file of context.files.slice(0, 50)) {
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
(content.match(/\?/g)?.length || 0);
|
|
383
|
-
const complexity = branches + 1;
|
|
384
|
-
if (complexity > complexityThreshold) {
|
|
385
|
-
complexFiles.push({ file, complexity });
|
|
386
|
-
this.findings.push({
|
|
387
|
-
type: 'warning',
|
|
388
|
-
message: `High complexity: ${complexity} (threshold: ${complexityThreshold})`,
|
|
389
|
-
file,
|
|
390
|
-
severity: complexity > 20 ? 3 : 2,
|
|
391
|
-
});
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
catch {
|
|
395
|
-
// Skip
|
|
343
|
+
// Use consolidated complexity analyzer
|
|
344
|
+
const result = (0, complexity_1.analyzeFile)(file);
|
|
345
|
+
if (result.cyclomaticComplexity > complexityThreshold) {
|
|
346
|
+
complexFiles.push(result);
|
|
347
|
+
const rating = (0, complexity_1.getComplexityRating)(result.cyclomaticComplexity);
|
|
348
|
+
this.findings.push({
|
|
349
|
+
type: 'warning',
|
|
350
|
+
message: `High complexity: ${result.cyclomaticComplexity} (threshold: ${complexityThreshold})`,
|
|
351
|
+
file,
|
|
352
|
+
severity: rating === 'critical' ? 4 : rating === 'high' ? 3 : 2,
|
|
353
|
+
});
|
|
396
354
|
}
|
|
397
355
|
}
|
|
398
356
|
return { ...context, complexFiles };
|
package/package.json
CHANGED
|
Binary file
|
package/.agentic-flow/vectors.db
DELETED
|
Binary file
|
package/.agentic-flow/workers.db
DELETED
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"startTime": 1765652041941,
|
|
3
|
-
"sessionId": "session-1765652041941",
|
|
4
|
-
"lastActivity": 1765652041941,
|
|
5
|
-
"sessionDuration": 0,
|
|
6
|
-
"totalTasks": 1,
|
|
7
|
-
"successfulTasks": 1,
|
|
8
|
-
"failedTasks": 0,
|
|
9
|
-
"totalAgents": 0,
|
|
10
|
-
"activeAgents": 0,
|
|
11
|
-
"neuralEvents": 0,
|
|
12
|
-
"memoryMode": {
|
|
13
|
-
"reasoningbankOperations": 0,
|
|
14
|
-
"basicOperations": 0,
|
|
15
|
-
"autoModeSelections": 0,
|
|
16
|
-
"modeOverrides": 0,
|
|
17
|
-
"currentMode": "auto"
|
|
18
|
-
},
|
|
19
|
-
"operations": {
|
|
20
|
-
"store": {
|
|
21
|
-
"count": 0,
|
|
22
|
-
"totalDuration": 0,
|
|
23
|
-
"errors": 0
|
|
24
|
-
},
|
|
25
|
-
"retrieve": {
|
|
26
|
-
"count": 0,
|
|
27
|
-
"totalDuration": 0,
|
|
28
|
-
"errors": 0
|
|
29
|
-
},
|
|
30
|
-
"query": {
|
|
31
|
-
"count": 0,
|
|
32
|
-
"totalDuration": 0,
|
|
33
|
-
"errors": 0
|
|
34
|
-
},
|
|
35
|
-
"list": {
|
|
36
|
-
"count": 0,
|
|
37
|
-
"totalDuration": 0,
|
|
38
|
-
"errors": 0
|
|
39
|
-
},
|
|
40
|
-
"delete": {
|
|
41
|
-
"count": 0,
|
|
42
|
-
"totalDuration": 0,
|
|
43
|
-
"errors": 0
|
|
44
|
-
},
|
|
45
|
-
"search": {
|
|
46
|
-
"count": 0,
|
|
47
|
-
"totalDuration": 0,
|
|
48
|
-
"errors": 0
|
|
49
|
-
},
|
|
50
|
-
"init": {
|
|
51
|
-
"count": 0,
|
|
52
|
-
"totalDuration": 0,
|
|
53
|
-
"errors": 0
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
"performance": {
|
|
57
|
-
"avgOperationDuration": 0,
|
|
58
|
-
"minOperationDuration": null,
|
|
59
|
-
"maxOperationDuration": null,
|
|
60
|
-
"slowOperations": 0,
|
|
61
|
-
"fastOperations": 0,
|
|
62
|
-
"totalOperationTime": 0
|
|
63
|
-
},
|
|
64
|
-
"storage": {
|
|
65
|
-
"totalEntries": 0,
|
|
66
|
-
"reasoningbankEntries": 0,
|
|
67
|
-
"basicEntries": 0,
|
|
68
|
-
"databaseSize": 0,
|
|
69
|
-
"lastBackup": null,
|
|
70
|
-
"growthRate": 0
|
|
71
|
-
},
|
|
72
|
-
"errors": {
|
|
73
|
-
"total": 0,
|
|
74
|
-
"byType": {},
|
|
75
|
-
"byOperation": {},
|
|
76
|
-
"recent": []
|
|
77
|
-
},
|
|
78
|
-
"reasoningbank": {
|
|
79
|
-
"semanticSearches": 0,
|
|
80
|
-
"sqlFallbacks": 0,
|
|
81
|
-
"embeddingGenerated": 0,
|
|
82
|
-
"consolidations": 0,
|
|
83
|
-
"avgQueryTime": 0,
|
|
84
|
-
"cacheHits": 0,
|
|
85
|
-
"cacheMisses": 0
|
|
86
|
-
}
|
|
87
|
-
}
|