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