guardrail-security 1.0.2 → 2.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/sbom/generator.d.ts +42 -0
- package/dist/sbom/generator.d.ts.map +1 -1
- package/dist/sbom/generator.js +168 -7
- package/dist/secrets/allowlist.d.ts +38 -0
- package/dist/secrets/allowlist.d.ts.map +1 -0
- package/dist/secrets/allowlist.js +131 -0
- package/dist/secrets/config-loader.d.ts +25 -0
- package/dist/secrets/config-loader.d.ts.map +1 -0
- package/dist/secrets/config-loader.js +103 -0
- package/dist/secrets/contextual-risk.d.ts +19 -0
- package/dist/secrets/contextual-risk.d.ts.map +1 -0
- package/dist/secrets/contextual-risk.js +88 -0
- package/dist/secrets/git-scanner.d.ts +29 -0
- package/dist/secrets/git-scanner.d.ts.map +1 -0
- package/dist/secrets/git-scanner.js +109 -0
- package/dist/secrets/guardian.d.ts +70 -57
- package/dist/secrets/guardian.d.ts.map +1 -1
- package/dist/secrets/guardian.js +531 -258
- package/dist/secrets/index.d.ts +4 -0
- package/dist/secrets/index.d.ts.map +1 -1
- package/dist/secrets/index.js +11 -1
- package/dist/secrets/patterns.d.ts +39 -10
- package/dist/secrets/patterns.d.ts.map +1 -1
- package/dist/secrets/patterns.js +129 -71
- package/dist/secrets/pre-commit.d.ts.map +1 -1
- package/dist/secrets/pre-commit.js +1 -1
- package/dist/secrets/vault-integration.d.ts.map +1 -1
- package/dist/secrets/vault-integration.js +1 -0
- package/dist/supply-chain/vulnerability-db.d.ts +89 -16
- package/dist/supply-chain/vulnerability-db.d.ts.map +1 -1
- package/dist/supply-chain/vulnerability-db.js +404 -115
- package/dist/utils/semver.d.ts +37 -0
- package/dist/utils/semver.d.ts.map +1 -0
- package/dist/utils/semver.js +109 -0
- package/package.json +17 -3
- package/src/__tests__/license/engine.test.ts +0 -250
- package/src/__tests__/supply-chain/typosquat.test.ts +0 -191
- package/src/attack-surface/analyzer.ts +0 -153
- package/src/attack-surface/index.ts +0 -5
- package/src/index.ts +0 -21
- package/src/languages/index.ts +0 -91
- package/src/languages/java-analyzer.ts +0 -490
- package/src/languages/python-analyzer.ts +0 -498
- package/src/license/compatibility-matrix.ts +0 -366
- package/src/license/engine.ts +0 -346
- package/src/license/index.ts +0 -6
- package/src/sbom/generator.ts +0 -355
- package/src/sbom/index.ts +0 -5
- package/src/secrets/guardian.ts +0 -468
- package/src/secrets/index.ts +0 -10
- package/src/secrets/patterns.ts +0 -186
- package/src/secrets/pre-commit.ts +0 -158
- package/src/secrets/vault-integration.ts +0 -360
- package/src/secrets/vault-providers.ts +0 -446
- package/src/supply-chain/detector.ts +0 -253
- package/src/supply-chain/index.ts +0 -11
- package/src/supply-chain/malicious-db.ts +0 -103
- package/src/supply-chain/script-analyzer.ts +0 -194
- package/src/supply-chain/typosquat.ts +0 -302
- package/src/supply-chain/vulnerability-db.ts +0 -386
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
// Stub prisma for standalone use
|
|
2
|
-
const prisma: any = null;
|
|
3
|
-
|
|
4
|
-
export interface EntryPoint {
|
|
5
|
-
type: "http" | "graphql" | "websocket" | "grpc";
|
|
6
|
-
path: string;
|
|
7
|
-
method?: string;
|
|
8
|
-
file: string;
|
|
9
|
-
line: number;
|
|
10
|
-
authentication?: string;
|
|
11
|
-
rateLimit?: string;
|
|
12
|
-
parameters: ParameterInfo[];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface ParameterInfo {
|
|
16
|
-
name: string;
|
|
17
|
-
type: string;
|
|
18
|
-
required: boolean;
|
|
19
|
-
validated: boolean;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface APISecurityFinding {
|
|
23
|
-
category: string;
|
|
24
|
-
severity: "low" | "medium" | "high" | "critical";
|
|
25
|
-
endpoint: string;
|
|
26
|
-
description: string;
|
|
27
|
-
recommendation: string;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface AttackPath {
|
|
31
|
-
id: string;
|
|
32
|
-
entry: string;
|
|
33
|
-
steps: string[];
|
|
34
|
-
impact: string;
|
|
35
|
-
likelihood: "low" | "medium" | "high";
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export interface AttackSurfaceAnalysisResult {
|
|
39
|
-
projectId: string;
|
|
40
|
-
summary: {
|
|
41
|
-
totalEntryPoints: number;
|
|
42
|
-
byType: Record<string, number>;
|
|
43
|
-
risksByLevel: Record<string, number>;
|
|
44
|
-
};
|
|
45
|
-
entryPoints: EntryPoint[];
|
|
46
|
-
attackPaths: AttackPath[];
|
|
47
|
-
apiFindings: APISecurityFinding[];
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export class AttackSurfaceAnalyzer {
|
|
51
|
-
async analyzeProject(
|
|
52
|
-
projectPath: string,
|
|
53
|
-
projectId: string,
|
|
54
|
-
): Promise<AttackSurfaceAnalysisResult> {
|
|
55
|
-
const entryPoints = await this.scanHTTPEndpoints(projectPath);
|
|
56
|
-
const apiFindings = await this.analyzeEndpoints(entryPoints);
|
|
57
|
-
const attackPaths = await this.buildAttackPaths(entryPoints, apiFindings);
|
|
58
|
-
|
|
59
|
-
const byType: Record<string, number> = {};
|
|
60
|
-
const risksByLevel: Record<string, number> = {};
|
|
61
|
-
|
|
62
|
-
for (const ep of entryPoints) {
|
|
63
|
-
byType[ep.type] = (byType[ep.type] || 0) + 1;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
for (const finding of apiFindings) {
|
|
67
|
-
risksByLevel[finding.severity] =
|
|
68
|
-
(risksByLevel[finding.severity] || 0) + 1;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const result: AttackSurfaceAnalysisResult = {
|
|
72
|
-
projectId,
|
|
73
|
-
summary: {
|
|
74
|
-
totalEntryPoints: entryPoints.length,
|
|
75
|
-
byType,
|
|
76
|
-
risksByLevel,
|
|
77
|
-
},
|
|
78
|
-
entryPoints,
|
|
79
|
-
attackPaths,
|
|
80
|
-
apiFindings,
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
await prisma.attackSurfaceAnalysis.create({
|
|
84
|
-
data: {
|
|
85
|
-
projectId,
|
|
86
|
-
summary: JSON.parse(JSON.stringify(result.summary)),
|
|
87
|
-
endpoints: JSON.parse(JSON.stringify(entryPoints)),
|
|
88
|
-
attackPaths: JSON.parse(JSON.stringify(attackPaths)),
|
|
89
|
-
apiFindings: JSON.parse(JSON.stringify(apiFindings)),
|
|
90
|
-
},
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
return result;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
private async scanHTTPEndpoints(_projectPath: string): Promise<EntryPoint[]> {
|
|
97
|
-
// In production, would use AST parsing to find routes
|
|
98
|
-
return [];
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
private async analyzeEndpoints(
|
|
102
|
-
entryPoints: EntryPoint[],
|
|
103
|
-
): Promise<APISecurityFinding[]> {
|
|
104
|
-
const findings: APISecurityFinding[] = [];
|
|
105
|
-
|
|
106
|
-
for (const ep of entryPoints) {
|
|
107
|
-
if (!ep.authentication) {
|
|
108
|
-
findings.push({
|
|
109
|
-
category: "Broken Authentication",
|
|
110
|
-
severity: "high",
|
|
111
|
-
endpoint: ep.path,
|
|
112
|
-
description: "No authentication detected",
|
|
113
|
-
recommendation: "Add authentication middleware",
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if (!ep.rateLimit) {
|
|
118
|
-
findings.push({
|
|
119
|
-
category: "Unrestricted Resource Consumption",
|
|
120
|
-
severity: "medium",
|
|
121
|
-
endpoint: ep.path,
|
|
122
|
-
description: "No rate limiting detected",
|
|
123
|
-
recommendation: "Add rate limiting middleware",
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
return findings;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
private async buildAttackPaths(
|
|
132
|
-
_entryPoints: EntryPoint[],
|
|
133
|
-
_findings: APISecurityFinding[],
|
|
134
|
-
): Promise<AttackPath[]> {
|
|
135
|
-
return [];
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
async generateVisualization(
|
|
139
|
-
analysis: AttackSurfaceAnalysisResult,
|
|
140
|
-
): Promise<string> {
|
|
141
|
-
let mermaid = "graph TD\n";
|
|
142
|
-
mermaid += " Start[External User]\n";
|
|
143
|
-
|
|
144
|
-
for (const ep of analysis.entryPoints) {
|
|
145
|
-
const epId = ep.path.replace(/[^a-zA-Z0-9]/g, "_");
|
|
146
|
-
mermaid += ` Start --> ${epId}[${ep.method} ${ep.path}]\n`;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
return mermaid;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export const attackSurfaceAnalyzer = new AttackSurfaceAnalyzer();
|
package/src/index.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
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
|
-
|
|
11
|
-
export * from './secrets';
|
|
12
|
-
export * from './supply-chain';
|
|
13
|
-
export * from './license';
|
|
14
|
-
export * from './attack-surface';
|
|
15
|
-
export {
|
|
16
|
-
SBOMGenerator,
|
|
17
|
-
sbomGenerator,
|
|
18
|
-
type SBOMFormat,
|
|
19
|
-
type SBOMGeneratorOptions,
|
|
20
|
-
type SBOMDependency,
|
|
21
|
-
} from './sbom';
|
package/src/languages/index.ts
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Multi-Language Security Analysis
|
|
3
|
-
*
|
|
4
|
-
* Provides security analysis for multiple programming languages
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
export * from "./python-analyzer";
|
|
8
|
-
export * from "./java-analyzer";
|
|
9
|
-
|
|
10
|
-
export type SupportedLanguage =
|
|
11
|
-
| "javascript"
|
|
12
|
-
| "typescript"
|
|
13
|
-
| "python"
|
|
14
|
-
| "java"
|
|
15
|
-
| "go"
|
|
16
|
-
| "rust";
|
|
17
|
-
|
|
18
|
-
export interface LanguageDetectionResult {
|
|
19
|
-
primaryLanguage: SupportedLanguage;
|
|
20
|
-
languages: { language: SupportedLanguage; percentage: number }[];
|
|
21
|
-
buildTools: string[];
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Detect project languages
|
|
26
|
-
*/
|
|
27
|
-
export function detectProjectLanguages(
|
|
28
|
-
projectPath: string,
|
|
29
|
-
): LanguageDetectionResult {
|
|
30
|
-
const { existsSync } = require("fs");
|
|
31
|
-
const { join } = require("path");
|
|
32
|
-
|
|
33
|
-
const languages: { language: SupportedLanguage; percentage: number }[] = [];
|
|
34
|
-
const buildTools: string[] = [];
|
|
35
|
-
|
|
36
|
-
// Check for JavaScript/TypeScript
|
|
37
|
-
if (existsSync(join(projectPath, "package.json"))) {
|
|
38
|
-
if (existsSync(join(projectPath, "tsconfig.json"))) {
|
|
39
|
-
languages.push({ language: "typescript", percentage: 0 });
|
|
40
|
-
buildTools.push("npm/yarn/pnpm");
|
|
41
|
-
} else {
|
|
42
|
-
languages.push({ language: "javascript", percentage: 0 });
|
|
43
|
-
buildTools.push("npm/yarn/pnpm");
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Check for Python
|
|
48
|
-
if (
|
|
49
|
-
existsSync(join(projectPath, "requirements.txt")) ||
|
|
50
|
-
existsSync(join(projectPath, "pyproject.toml")) ||
|
|
51
|
-
existsSync(join(projectPath, "Pipfile"))
|
|
52
|
-
) {
|
|
53
|
-
languages.push({ language: "python", percentage: 0 });
|
|
54
|
-
buildTools.push("pip/poetry/pipenv");
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Check for Java
|
|
58
|
-
if (existsSync(join(projectPath, "pom.xml"))) {
|
|
59
|
-
languages.push({ language: "java", percentage: 0 });
|
|
60
|
-
buildTools.push("maven");
|
|
61
|
-
}
|
|
62
|
-
if (
|
|
63
|
-
existsSync(join(projectPath, "build.gradle")) ||
|
|
64
|
-
existsSync(join(projectPath, "build.gradle.kts"))
|
|
65
|
-
) {
|
|
66
|
-
languages.push({ language: "java", percentage: 0 });
|
|
67
|
-
buildTools.push("gradle");
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Check for Go
|
|
71
|
-
if (existsSync(join(projectPath, "go.mod"))) {
|
|
72
|
-
languages.push({ language: "go", percentage: 0 });
|
|
73
|
-
buildTools.push("go");
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Check for Rust
|
|
77
|
-
if (existsSync(join(projectPath, "Cargo.toml"))) {
|
|
78
|
-
languages.push({ language: "rust", percentage: 0 });
|
|
79
|
-
buildTools.push("cargo");
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// Determine primary language (first detected)
|
|
83
|
-
const primaryLanguage =
|
|
84
|
-
languages.length > 0 && languages[0] ? languages[0].language : "javascript";
|
|
85
|
-
|
|
86
|
-
return {
|
|
87
|
-
primaryLanguage,
|
|
88
|
-
languages,
|
|
89
|
-
buildTools: [...new Set(buildTools)],
|
|
90
|
-
};
|
|
91
|
-
}
|