guardrail-security 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.
- package/dist/attack-surface/analyzer.d.ts +50 -0
- package/dist/attack-surface/analyzer.d.ts.map +1 -0
- package/dist/attack-surface/analyzer.js +83 -0
- package/dist/attack-surface/index.d.ts +5 -0
- package/dist/attack-surface/index.d.ts.map +1 -0
- package/dist/attack-surface/index.js +20 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +33 -0
- package/dist/languages/index.d.ts +21 -0
- package/dist/languages/index.d.ts.map +1 -0
- package/dist/languages/index.js +78 -0
- package/dist/languages/java-analyzer.d.ts +72 -0
- package/dist/languages/java-analyzer.d.ts.map +1 -0
- package/dist/languages/java-analyzer.js +417 -0
- package/dist/languages/python-analyzer.d.ts +70 -0
- package/dist/languages/python-analyzer.d.ts.map +1 -0
- package/dist/languages/python-analyzer.js +425 -0
- package/dist/license/compatibility-matrix.d.ts +28 -0
- package/dist/license/compatibility-matrix.d.ts.map +1 -0
- package/dist/license/compatibility-matrix.js +323 -0
- package/dist/license/engine.d.ts +77 -0
- package/dist/license/engine.d.ts.map +1 -0
- package/dist/license/engine.js +264 -0
- package/dist/license/index.d.ts +6 -0
- package/dist/license/index.d.ts.map +1 -0
- package/dist/license/index.js +21 -0
- package/dist/sbom/generator.d.ts +108 -0
- package/dist/sbom/generator.d.ts.map +1 -0
- package/dist/sbom/generator.js +271 -0
- package/dist/sbom/index.d.ts +5 -0
- package/dist/sbom/index.d.ts.map +1 -0
- package/dist/sbom/index.js +20 -0
- package/dist/secrets/guardian.d.ts +113 -0
- package/dist/secrets/guardian.d.ts.map +1 -0
- package/dist/secrets/guardian.js +334 -0
- package/dist/secrets/index.d.ts +10 -0
- package/dist/secrets/index.d.ts.map +1 -0
- package/dist/secrets/index.js +30 -0
- package/dist/secrets/patterns.d.ts +42 -0
- package/dist/secrets/patterns.d.ts.map +1 -0
- package/dist/secrets/patterns.js +165 -0
- package/dist/secrets/pre-commit.d.ts +39 -0
- package/dist/secrets/pre-commit.d.ts.map +1 -0
- package/dist/secrets/pre-commit.js +127 -0
- package/dist/secrets/vault-integration.d.ts +83 -0
- package/dist/secrets/vault-integration.d.ts.map +1 -0
- package/dist/secrets/vault-integration.js +295 -0
- package/dist/secrets/vault-providers.d.ts +110 -0
- package/dist/secrets/vault-providers.d.ts.map +1 -0
- package/dist/secrets/vault-providers.js +417 -0
- package/dist/supply-chain/detector.d.ts +80 -0
- package/dist/supply-chain/detector.d.ts.map +1 -0
- package/dist/supply-chain/detector.js +168 -0
- package/dist/supply-chain/index.d.ts +11 -0
- package/dist/supply-chain/index.d.ts.map +1 -0
- package/dist/supply-chain/index.js +26 -0
- package/dist/supply-chain/malicious-db.d.ts +41 -0
- package/dist/supply-chain/malicious-db.d.ts.map +1 -0
- package/dist/supply-chain/malicious-db.js +82 -0
- package/dist/supply-chain/script-analyzer.d.ts +54 -0
- package/dist/supply-chain/script-analyzer.d.ts.map +1 -0
- package/dist/supply-chain/script-analyzer.js +160 -0
- package/dist/supply-chain/typosquat.d.ts +58 -0
- package/dist/supply-chain/typosquat.d.ts.map +1 -0
- package/dist/supply-chain/typosquat.js +257 -0
- package/dist/supply-chain/vulnerability-db.d.ts +114 -0
- package/dist/supply-chain/vulnerability-db.d.ts.map +1 -0
- package/dist/supply-chain/vulnerability-db.js +310 -0
- package/package.json +34 -0
- package/src/__tests__/license/engine.test.ts +250 -0
- package/src/__tests__/supply-chain/typosquat.test.ts +191 -0
- package/src/attack-surface/analyzer.ts +152 -0
- package/src/attack-surface/index.ts +5 -0
- package/src/index.ts +21 -0
- package/src/languages/index.ts +91 -0
- package/src/languages/java-analyzer.ts +490 -0
- package/src/languages/python-analyzer.ts +498 -0
- package/src/license/compatibility-matrix.ts +366 -0
- package/src/license/engine.ts +345 -0
- package/src/license/index.ts +6 -0
- package/src/sbom/generator.ts +355 -0
- package/src/sbom/index.ts +5 -0
- package/src/secrets/guardian.ts +448 -0
- package/src/secrets/index.ts +10 -0
- package/src/secrets/patterns.ts +186 -0
- package/src/secrets/pre-commit.ts +158 -0
- package/src/secrets/vault-integration.ts +360 -0
- package/src/secrets/vault-providers.ts +446 -0
- package/src/supply-chain/detector.ts +252 -0
- package/src/supply-chain/index.ts +11 -0
- package/src/supply-chain/malicious-db.ts +103 -0
- package/src/supply-chain/script-analyzer.ts +194 -0
- package/src/supply-chain/typosquat.ts +302 -0
- package/src/supply-chain/vulnerability-db.ts +386 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export interface EntryPoint {
|
|
2
|
+
type: "http" | "graphql" | "websocket" | "grpc";
|
|
3
|
+
path: string;
|
|
4
|
+
method?: string;
|
|
5
|
+
file: string;
|
|
6
|
+
line: number;
|
|
7
|
+
authentication?: string;
|
|
8
|
+
rateLimit?: string;
|
|
9
|
+
parameters: ParameterInfo[];
|
|
10
|
+
}
|
|
11
|
+
export interface ParameterInfo {
|
|
12
|
+
name: string;
|
|
13
|
+
type: string;
|
|
14
|
+
required: boolean;
|
|
15
|
+
validated: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface APISecurityFinding {
|
|
18
|
+
category: string;
|
|
19
|
+
severity: "low" | "medium" | "high" | "critical";
|
|
20
|
+
endpoint: string;
|
|
21
|
+
description: string;
|
|
22
|
+
recommendation: string;
|
|
23
|
+
}
|
|
24
|
+
export interface AttackPath {
|
|
25
|
+
id: string;
|
|
26
|
+
entry: string;
|
|
27
|
+
steps: string[];
|
|
28
|
+
impact: string;
|
|
29
|
+
likelihood: "low" | "medium" | "high";
|
|
30
|
+
}
|
|
31
|
+
export interface AttackSurfaceAnalysisResult {
|
|
32
|
+
projectId: string;
|
|
33
|
+
summary: {
|
|
34
|
+
totalEntryPoints: number;
|
|
35
|
+
byType: Record<string, number>;
|
|
36
|
+
risksByLevel: Record<string, number>;
|
|
37
|
+
};
|
|
38
|
+
entryPoints: EntryPoint[];
|
|
39
|
+
attackPaths: AttackPath[];
|
|
40
|
+
apiFindings: APISecurityFinding[];
|
|
41
|
+
}
|
|
42
|
+
export declare class AttackSurfaceAnalyzer {
|
|
43
|
+
analyzeProject(projectPath: string, projectId: string): Promise<AttackSurfaceAnalysisResult>;
|
|
44
|
+
private scanHTTPEndpoints;
|
|
45
|
+
private analyzeEndpoints;
|
|
46
|
+
private buildAttackPaths;
|
|
47
|
+
generateVisualization(analysis: AttackSurfaceAnalysisResult): Promise<string>;
|
|
48
|
+
}
|
|
49
|
+
export declare const attackSurfaceAnalyzer: AttackSurfaceAnalyzer;
|
|
50
|
+
//# sourceMappingURL=analyzer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyzer.d.ts","sourceRoot":"","sources":["../../src/attack-surface/analyzer.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,WAAW,GAAG,MAAM,CAAC;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,aAAa,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAC;IACjD,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;CACvC;AAED,MAAM,WAAW,2BAA2B;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE;QACP,gBAAgB,EAAE,MAAM,CAAC;QACzB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC/B,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACtC,CAAC;IACF,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,WAAW,EAAE,kBAAkB,EAAE,CAAC;CACnC;AAED,qBAAa,qBAAqB;IAC1B,cAAc,CAClB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,2BAA2B,CAAC;YA0CzB,iBAAiB;YAKjB,gBAAgB;YA8BhB,gBAAgB;IAOxB,qBAAqB,CACzB,QAAQ,EAAE,2BAA2B,GACpC,OAAO,CAAC,MAAM,CAAC;CAWnB;AAED,eAAO,MAAM,qBAAqB,uBAA8B,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.attackSurfaceAnalyzer = exports.AttackSurfaceAnalyzer = void 0;
|
|
4
|
+
const database_1 = require("@guardrail/database");
|
|
5
|
+
class AttackSurfaceAnalyzer {
|
|
6
|
+
async analyzeProject(projectPath, projectId) {
|
|
7
|
+
const entryPoints = await this.scanHTTPEndpoints(projectPath);
|
|
8
|
+
const apiFindings = await this.analyzeEndpoints(entryPoints);
|
|
9
|
+
const attackPaths = await this.buildAttackPaths(entryPoints, apiFindings);
|
|
10
|
+
const byType = {};
|
|
11
|
+
const risksByLevel = {};
|
|
12
|
+
for (const ep of entryPoints) {
|
|
13
|
+
byType[ep.type] = (byType[ep.type] || 0) + 1;
|
|
14
|
+
}
|
|
15
|
+
for (const finding of apiFindings) {
|
|
16
|
+
risksByLevel[finding.severity] =
|
|
17
|
+
(risksByLevel[finding.severity] || 0) + 1;
|
|
18
|
+
}
|
|
19
|
+
const result = {
|
|
20
|
+
projectId,
|
|
21
|
+
summary: {
|
|
22
|
+
totalEntryPoints: entryPoints.length,
|
|
23
|
+
byType,
|
|
24
|
+
risksByLevel,
|
|
25
|
+
},
|
|
26
|
+
entryPoints,
|
|
27
|
+
attackPaths,
|
|
28
|
+
apiFindings,
|
|
29
|
+
};
|
|
30
|
+
await database_1.prisma.attackSurfaceAnalysis.create({
|
|
31
|
+
data: {
|
|
32
|
+
projectId,
|
|
33
|
+
summary: JSON.parse(JSON.stringify(result.summary)),
|
|
34
|
+
endpoints: JSON.parse(JSON.stringify(entryPoints)),
|
|
35
|
+
attackPaths: JSON.parse(JSON.stringify(attackPaths)),
|
|
36
|
+
apiFindings: JSON.parse(JSON.stringify(apiFindings)),
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
async scanHTTPEndpoints(_projectPath) {
|
|
42
|
+
// In production, would use AST parsing to find routes
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
async analyzeEndpoints(entryPoints) {
|
|
46
|
+
const findings = [];
|
|
47
|
+
for (const ep of entryPoints) {
|
|
48
|
+
if (!ep.authentication) {
|
|
49
|
+
findings.push({
|
|
50
|
+
category: "Broken Authentication",
|
|
51
|
+
severity: "high",
|
|
52
|
+
endpoint: ep.path,
|
|
53
|
+
description: "No authentication detected",
|
|
54
|
+
recommendation: "Add authentication middleware",
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
if (!ep.rateLimit) {
|
|
58
|
+
findings.push({
|
|
59
|
+
category: "Unrestricted Resource Consumption",
|
|
60
|
+
severity: "medium",
|
|
61
|
+
endpoint: ep.path,
|
|
62
|
+
description: "No rate limiting detected",
|
|
63
|
+
recommendation: "Add rate limiting middleware",
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return findings;
|
|
68
|
+
}
|
|
69
|
+
async buildAttackPaths(_entryPoints, _findings) {
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
72
|
+
async generateVisualization(analysis) {
|
|
73
|
+
let mermaid = "graph TD\n";
|
|
74
|
+
mermaid += " Start[External User]\n";
|
|
75
|
+
for (const ep of analysis.entryPoints) {
|
|
76
|
+
const epId = ep.path.replace(/[^a-zA-Z0-9]/g, "_");
|
|
77
|
+
mermaid += ` Start --> ${epId}[${ep.method} ${ep.path}]\n`;
|
|
78
|
+
}
|
|
79
|
+
return mermaid;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.AttackSurfaceAnalyzer = AttackSurfaceAnalyzer;
|
|
83
|
+
exports.attackSurfaceAnalyzer = new AttackSurfaceAnalyzer();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/attack-surface/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Attack Surface Analyzer
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
17
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
__exportStar(require("./analyzer"), exports);
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Guardrail Security Package
|
|
3
|
+
*
|
|
4
|
+
* Comprehensive security layer including:
|
|
5
|
+
* - Secrets & Credential Guardian
|
|
6
|
+
* - Supply Chain Attack Detection
|
|
7
|
+
* - License Compliance Engine
|
|
8
|
+
* - Attack Surface Analyzer
|
|
9
|
+
*/
|
|
10
|
+
export * from './secrets';
|
|
11
|
+
export * from './supply-chain';
|
|
12
|
+
export * from './license';
|
|
13
|
+
export * from './attack-surface';
|
|
14
|
+
export { SBOMGenerator, sbomGenerator, type SBOMFormat, type SBOMGeneratorOptions, type SBOMDependency, } from './sbom';
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,OAAO,EACL,aAAa,EACb,aAAa,EACb,KAAK,UAAU,EACf,KAAK,oBAAoB,EACzB,KAAK,cAAc,GACpB,MAAM,QAAQ,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Guardrail Security Package
|
|
4
|
+
*
|
|
5
|
+
* Comprehensive security layer including:
|
|
6
|
+
* - Secrets & Credential Guardian
|
|
7
|
+
* - Supply Chain Attack Detection
|
|
8
|
+
* - License Compliance Engine
|
|
9
|
+
* - Attack Surface Analyzer
|
|
10
|
+
*/
|
|
11
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
15
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
16
|
+
}
|
|
17
|
+
Object.defineProperty(o, k2, desc);
|
|
18
|
+
}) : (function(o, m, k, k2) {
|
|
19
|
+
if (k2 === undefined) k2 = k;
|
|
20
|
+
o[k2] = m[k];
|
|
21
|
+
}));
|
|
22
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
23
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.sbomGenerator = exports.SBOMGenerator = void 0;
|
|
27
|
+
__exportStar(require("./secrets"), exports);
|
|
28
|
+
__exportStar(require("./supply-chain"), exports);
|
|
29
|
+
__exportStar(require("./license"), exports);
|
|
30
|
+
__exportStar(require("./attack-surface"), exports);
|
|
31
|
+
var sbom_1 = require("./sbom");
|
|
32
|
+
Object.defineProperty(exports, "SBOMGenerator", { enumerable: true, get: function () { return sbom_1.SBOMGenerator; } });
|
|
33
|
+
Object.defineProperty(exports, "sbomGenerator", { enumerable: true, get: function () { return sbom_1.sbomGenerator; } });
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multi-Language Security Analysis
|
|
3
|
+
*
|
|
4
|
+
* Provides security analysis for multiple programming languages
|
|
5
|
+
*/
|
|
6
|
+
export * from "./python-analyzer";
|
|
7
|
+
export * from "./java-analyzer";
|
|
8
|
+
export type SupportedLanguage = "javascript" | "typescript" | "python" | "java" | "go" | "rust";
|
|
9
|
+
export interface LanguageDetectionResult {
|
|
10
|
+
primaryLanguage: SupportedLanguage;
|
|
11
|
+
languages: {
|
|
12
|
+
language: SupportedLanguage;
|
|
13
|
+
percentage: number;
|
|
14
|
+
}[];
|
|
15
|
+
buildTools: string[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Detect project languages
|
|
19
|
+
*/
|
|
20
|
+
export declare function detectProjectLanguages(projectPath: string): LanguageDetectionResult;
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/languages/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAEhC,MAAM,MAAM,iBAAiB,GACzB,YAAY,GACZ,YAAY,GACZ,QAAQ,GACR,MAAM,GACN,IAAI,GACJ,MAAM,CAAC;AAEX,MAAM,WAAW,uBAAuB;IACtC,eAAe,EAAE,iBAAiB,CAAC;IACnC,SAAS,EAAE;QAAE,QAAQ,EAAE,iBAAiB,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACjE,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,MAAM,GAClB,uBAAuB,CA8DzB"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Multi-Language Security Analysis
|
|
4
|
+
*
|
|
5
|
+
* Provides security analysis for multiple programming languages
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.detectProjectLanguages = detectProjectLanguages;
|
|
23
|
+
__exportStar(require("./python-analyzer"), exports);
|
|
24
|
+
__exportStar(require("./java-analyzer"), exports);
|
|
25
|
+
/**
|
|
26
|
+
* Detect project languages
|
|
27
|
+
*/
|
|
28
|
+
function detectProjectLanguages(projectPath) {
|
|
29
|
+
const { existsSync } = require("fs");
|
|
30
|
+
const { join } = require("path");
|
|
31
|
+
const languages = [];
|
|
32
|
+
const buildTools = [];
|
|
33
|
+
// Check for JavaScript/TypeScript
|
|
34
|
+
if (existsSync(join(projectPath, "package.json"))) {
|
|
35
|
+
if (existsSync(join(projectPath, "tsconfig.json"))) {
|
|
36
|
+
languages.push({ language: "typescript", percentage: 0 });
|
|
37
|
+
buildTools.push("npm/yarn/pnpm");
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
languages.push({ language: "javascript", percentage: 0 });
|
|
41
|
+
buildTools.push("npm/yarn/pnpm");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// Check for Python
|
|
45
|
+
if (existsSync(join(projectPath, "requirements.txt")) ||
|
|
46
|
+
existsSync(join(projectPath, "pyproject.toml")) ||
|
|
47
|
+
existsSync(join(projectPath, "Pipfile"))) {
|
|
48
|
+
languages.push({ language: "python", percentage: 0 });
|
|
49
|
+
buildTools.push("pip/poetry/pipenv");
|
|
50
|
+
}
|
|
51
|
+
// Check for Java
|
|
52
|
+
if (existsSync(join(projectPath, "pom.xml"))) {
|
|
53
|
+
languages.push({ language: "java", percentage: 0 });
|
|
54
|
+
buildTools.push("maven");
|
|
55
|
+
}
|
|
56
|
+
if (existsSync(join(projectPath, "build.gradle")) ||
|
|
57
|
+
existsSync(join(projectPath, "build.gradle.kts"))) {
|
|
58
|
+
languages.push({ language: "java", percentage: 0 });
|
|
59
|
+
buildTools.push("gradle");
|
|
60
|
+
}
|
|
61
|
+
// Check for Go
|
|
62
|
+
if (existsSync(join(projectPath, "go.mod"))) {
|
|
63
|
+
languages.push({ language: "go", percentage: 0 });
|
|
64
|
+
buildTools.push("go");
|
|
65
|
+
}
|
|
66
|
+
// Check for Rust
|
|
67
|
+
if (existsSync(join(projectPath, "Cargo.toml"))) {
|
|
68
|
+
languages.push({ language: "rust", percentage: 0 });
|
|
69
|
+
buildTools.push("cargo");
|
|
70
|
+
}
|
|
71
|
+
// Determine primary language (first detected)
|
|
72
|
+
const primaryLanguage = languages.length > 0 && languages[0] ? languages[0].language : "javascript";
|
|
73
|
+
return {
|
|
74
|
+
primaryLanguage,
|
|
75
|
+
languages,
|
|
76
|
+
buildTools: [...new Set(buildTools)],
|
|
77
|
+
};
|
|
78
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Java Language Analyzer
|
|
3
|
+
*
|
|
4
|
+
* Security analysis for Java projects including:
|
|
5
|
+
* - Maven pom.xml / Gradle build.gradle parsing
|
|
6
|
+
* - Import analysis for detecting dangerous classes
|
|
7
|
+
* - Secret detection patterns specific to Java
|
|
8
|
+
* - Common vulnerability patterns (SQL injection, XXE, deserialization, etc.)
|
|
9
|
+
*/
|
|
10
|
+
export interface JavaDependency {
|
|
11
|
+
groupId: string;
|
|
12
|
+
artifactId: string;
|
|
13
|
+
version: string;
|
|
14
|
+
scope?: string;
|
|
15
|
+
source: "maven" | "gradle";
|
|
16
|
+
}
|
|
17
|
+
export interface JavaSecurityIssue {
|
|
18
|
+
type: "vulnerability" | "secret" | "dangerous_import" | "code_pattern";
|
|
19
|
+
severity: "low" | "medium" | "high" | "critical";
|
|
20
|
+
file: string;
|
|
21
|
+
line?: number;
|
|
22
|
+
message: string;
|
|
23
|
+
recommendation: string;
|
|
24
|
+
cwe?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface JavaAnalysisResult {
|
|
27
|
+
projectPath: string;
|
|
28
|
+
javaVersion?: string;
|
|
29
|
+
buildTool: "maven" | "gradle" | "unknown";
|
|
30
|
+
dependencies: JavaDependency[];
|
|
31
|
+
securityIssues: JavaSecurityIssue[];
|
|
32
|
+
summary: {
|
|
33
|
+
totalDependencies: number;
|
|
34
|
+
issuesBySeverity: Record<string, number>;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export declare class JavaAnalyzer {
|
|
38
|
+
/**
|
|
39
|
+
* Analyze a Java project
|
|
40
|
+
*/
|
|
41
|
+
analyze(projectPath: string): Promise<JavaAnalysisResult>;
|
|
42
|
+
/**
|
|
43
|
+
* Detect build tool
|
|
44
|
+
*/
|
|
45
|
+
private detectBuildTool;
|
|
46
|
+
/**
|
|
47
|
+
* Extract dependencies
|
|
48
|
+
*/
|
|
49
|
+
private extractDependencies;
|
|
50
|
+
/**
|
|
51
|
+
* Parse Maven pom.xml
|
|
52
|
+
*/
|
|
53
|
+
private parseMavenPom;
|
|
54
|
+
/**
|
|
55
|
+
* Parse Gradle build file
|
|
56
|
+
*/
|
|
57
|
+
private parseGradleBuild;
|
|
58
|
+
/**
|
|
59
|
+
* Find all Java files
|
|
60
|
+
*/
|
|
61
|
+
private findJavaFiles;
|
|
62
|
+
/**
|
|
63
|
+
* Scan a Java file for security issues
|
|
64
|
+
*/
|
|
65
|
+
private scanFile;
|
|
66
|
+
/**
|
|
67
|
+
* Detect Java version
|
|
68
|
+
*/
|
|
69
|
+
private detectJavaVersion;
|
|
70
|
+
}
|
|
71
|
+
export declare const javaAnalyzer: JavaAnalyzer;
|
|
72
|
+
//# sourceMappingURL=java-analyzer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"java-analyzer.d.ts","sourceRoot":"","sources":["../../src/languages/java-analyzer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,GAAG,QAAQ,CAAC;CAC5B;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,eAAe,GAAG,QAAQ,GAAG,kBAAkB,GAAG,cAAc,CAAC;IACvE,QAAQ,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAC;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAC;IAC1C,YAAY,EAAE,cAAc,EAAE,CAAC;IAC/B,cAAc,EAAE,iBAAiB,EAAE,CAAC;IACpC,OAAO,EAAE;QACP,iBAAiB,EAAE,MAAM,CAAC;QAC1B,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAC1C,CAAC;CACH;AA4ID,qBAAa,YAAY;IACvB;;OAEG;IACG,OAAO,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA0C/D;;OAEG;IACH,OAAO,CAAC,eAAe;IAavB;;OAEG;YACW,mBAAmB;IAajC;;OAEG;IACH,OAAO,CAAC,aAAa;IA+BrB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAsCxB;;OAEG;IACH,OAAO,CAAC,aAAa;IA4CrB;;OAEG;IACH,OAAO,CAAC,QAAQ;IAsEhB;;OAEG;IACH,OAAO,CAAC,iBAAiB;CA6B1B;AAGD,eAAO,MAAM,YAAY,cAAqB,CAAC"}
|