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.
Files changed (60) hide show
  1. package/dist/sbom/generator.d.ts +42 -0
  2. package/dist/sbom/generator.d.ts.map +1 -1
  3. package/dist/sbom/generator.js +168 -7
  4. package/dist/secrets/allowlist.d.ts +38 -0
  5. package/dist/secrets/allowlist.d.ts.map +1 -0
  6. package/dist/secrets/allowlist.js +131 -0
  7. package/dist/secrets/config-loader.d.ts +25 -0
  8. package/dist/secrets/config-loader.d.ts.map +1 -0
  9. package/dist/secrets/config-loader.js +103 -0
  10. package/dist/secrets/contextual-risk.d.ts +19 -0
  11. package/dist/secrets/contextual-risk.d.ts.map +1 -0
  12. package/dist/secrets/contextual-risk.js +88 -0
  13. package/dist/secrets/git-scanner.d.ts +29 -0
  14. package/dist/secrets/git-scanner.d.ts.map +1 -0
  15. package/dist/secrets/git-scanner.js +109 -0
  16. package/dist/secrets/guardian.d.ts +70 -57
  17. package/dist/secrets/guardian.d.ts.map +1 -1
  18. package/dist/secrets/guardian.js +531 -258
  19. package/dist/secrets/index.d.ts +4 -0
  20. package/dist/secrets/index.d.ts.map +1 -1
  21. package/dist/secrets/index.js +11 -1
  22. package/dist/secrets/patterns.d.ts +39 -10
  23. package/dist/secrets/patterns.d.ts.map +1 -1
  24. package/dist/secrets/patterns.js +129 -71
  25. package/dist/secrets/pre-commit.d.ts.map +1 -1
  26. package/dist/secrets/pre-commit.js +1 -1
  27. package/dist/secrets/vault-integration.d.ts.map +1 -1
  28. package/dist/secrets/vault-integration.js +1 -0
  29. package/dist/supply-chain/vulnerability-db.d.ts +89 -16
  30. package/dist/supply-chain/vulnerability-db.d.ts.map +1 -1
  31. package/dist/supply-chain/vulnerability-db.js +404 -115
  32. package/dist/utils/semver.d.ts +37 -0
  33. package/dist/utils/semver.d.ts.map +1 -0
  34. package/dist/utils/semver.js +109 -0
  35. package/package.json +17 -3
  36. package/src/__tests__/license/engine.test.ts +0 -250
  37. package/src/__tests__/supply-chain/typosquat.test.ts +0 -191
  38. package/src/attack-surface/analyzer.ts +0 -153
  39. package/src/attack-surface/index.ts +0 -5
  40. package/src/index.ts +0 -21
  41. package/src/languages/index.ts +0 -91
  42. package/src/languages/java-analyzer.ts +0 -490
  43. package/src/languages/python-analyzer.ts +0 -498
  44. package/src/license/compatibility-matrix.ts +0 -366
  45. package/src/license/engine.ts +0 -346
  46. package/src/license/index.ts +0 -6
  47. package/src/sbom/generator.ts +0 -355
  48. package/src/sbom/index.ts +0 -5
  49. package/src/secrets/guardian.ts +0 -468
  50. package/src/secrets/index.ts +0 -10
  51. package/src/secrets/patterns.ts +0 -186
  52. package/src/secrets/pre-commit.ts +0 -158
  53. package/src/secrets/vault-integration.ts +0 -360
  54. package/src/secrets/vault-providers.ts +0 -446
  55. package/src/supply-chain/detector.ts +0 -253
  56. package/src/supply-chain/index.ts +0 -11
  57. package/src/supply-chain/malicious-db.ts +0 -103
  58. package/src/supply-chain/script-analyzer.ts +0 -194
  59. package/src/supply-chain/typosquat.ts +0 -302
  60. 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();
@@ -1,5 +0,0 @@
1
- /**
2
- * Attack Surface Analyzer
3
- */
4
-
5
- export * from './analyzer';
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';
@@ -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
- }