@nahisaho/musubix-security 1.8.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/README.md +105 -0
- package/bin/musubix-security-mcp.js +12 -0
- package/bin/musubix-security.js +12 -0
- package/dist/analysis/dependency-auditor.d.ts +30 -0
- package/dist/analysis/dependency-auditor.d.ts.map +1 -0
- package/dist/analysis/dependency-auditor.js +325 -0
- package/dist/analysis/dependency-auditor.js.map +1 -0
- package/dist/analysis/index.d.ts +9 -0
- package/dist/analysis/index.d.ts.map +1 -0
- package/dist/analysis/index.js +9 -0
- package/dist/analysis/index.js.map +1 -0
- package/dist/analysis/secret-detector.d.ts +44 -0
- package/dist/analysis/secret-detector.d.ts.map +1 -0
- package/dist/analysis/secret-detector.js +465 -0
- package/dist/analysis/secret-detector.js.map +1 -0
- package/dist/analysis/taint-analyzer.d.ts +62 -0
- package/dist/analysis/taint-analyzer.d.ts.map +1 -0
- package/dist/analysis/taint-analyzer.js +519 -0
- package/dist/analysis/taint-analyzer.js.map +1 -0
- package/dist/analysis/vulnerability-scanner.d.ts +58 -0
- package/dist/analysis/vulnerability-scanner.d.ts.map +1 -0
- package/dist/analysis/vulnerability-scanner.js +417 -0
- package/dist/analysis/vulnerability-scanner.js.map +1 -0
- package/dist/cli/commands.d.ts +15 -0
- package/dist/cli/commands.d.ts.map +1 -0
- package/dist/cli/commands.js +405 -0
- package/dist/cli/commands.js.map +1 -0
- package/dist/cli/index.d.ts +6 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +6 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +66 -0
- package/dist/index.js.map +1 -0
- package/dist/infrastructure/ast-parser.d.ts +87 -0
- package/dist/infrastructure/ast-parser.d.ts.map +1 -0
- package/dist/infrastructure/ast-parser.js +273 -0
- package/dist/infrastructure/ast-parser.js.map +1 -0
- package/dist/infrastructure/cache.d.ts +100 -0
- package/dist/infrastructure/cache.d.ts.map +1 -0
- package/dist/infrastructure/cache.js +288 -0
- package/dist/infrastructure/cache.js.map +1 -0
- package/dist/infrastructure/config-loader.d.ts +35 -0
- package/dist/infrastructure/config-loader.d.ts.map +1 -0
- package/dist/infrastructure/config-loader.js +358 -0
- package/dist/infrastructure/config-loader.js.map +1 -0
- package/dist/infrastructure/file-scanner.d.ts +94 -0
- package/dist/infrastructure/file-scanner.d.ts.map +1 -0
- package/dist/infrastructure/file-scanner.js +189 -0
- package/dist/infrastructure/file-scanner.js.map +1 -0
- package/dist/infrastructure/index.d.ts +9 -0
- package/dist/infrastructure/index.d.ts.map +1 -0
- package/dist/infrastructure/index.js +9 -0
- package/dist/infrastructure/index.js.map +1 -0
- package/dist/mcp/index.d.ts +7 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +7 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/server.d.ts +34 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +88 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tools.d.ts +88 -0
- package/dist/mcp/tools.d.ts.map +1 -0
- package/dist/mcp/tools.js +443 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/services/fix-generator.d.ts +56 -0
- package/dist/services/fix-generator.d.ts.map +1 -0
- package/dist/services/fix-generator.js +346 -0
- package/dist/services/fix-generator.js.map +1 -0
- package/dist/services/fix-verifier.d.ts +62 -0
- package/dist/services/fix-verifier.d.ts.map +1 -0
- package/dist/services/fix-verifier.js +224 -0
- package/dist/services/fix-verifier.js.map +1 -0
- package/dist/services/index.d.ts +9 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +13 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/report-generator.d.ts +87 -0
- package/dist/services/report-generator.d.ts.map +1 -0
- package/dist/services/report-generator.js +463 -0
- package/dist/services/report-generator.js.map +1 -0
- package/dist/services/security-service.d.ts +151 -0
- package/dist/services/security-service.d.ts.map +1 -0
- package/dist/services/security-service.js +279 -0
- package/dist/services/security-service.js.map +1 -0
- package/dist/types/config.d.ts +188 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +89 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/dependency.d.ts +266 -0
- package/dist/types/dependency.d.ts.map +1 -0
- package/dist/types/dependency.js +7 -0
- package/dist/types/dependency.js.map +1 -0
- package/dist/types/fix.d.ts +213 -0
- package/dist/types/fix.d.ts.map +1 -0
- package/dist/types/fix.js +7 -0
- package/dist/types/fix.js.map +1 -0
- package/dist/types/index.d.ts +14 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +8 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/secret.d.ts +151 -0
- package/dist/types/secret.d.ts.map +1 -0
- package/dist/types/secret.js +91 -0
- package/dist/types/secret.js.map +1 -0
- package/dist/types/taint.d.ts +182 -0
- package/dist/types/taint.d.ts.map +1 -0
- package/dist/types/taint.js +24 -0
- package/dist/types/taint.js.map +1 -0
- package/dist/types/vulnerability.d.ts +136 -0
- package/dist/types/vulnerability.d.ts.map +1 -0
- package/dist/types/vulnerability.js +7 -0
- package/dist/types/vulnerability.js.map +1 -0
- package/package.json +87 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Secret detection type definitions
|
|
3
|
+
* @module @nahisaho/musubix-security/types/secret
|
|
4
|
+
* @trace REQ-SEC-SECRET-001, REQ-SEC-SECRET-002
|
|
5
|
+
*/
|
|
6
|
+
import type { SourceLocation, Severity } from './vulnerability.js';
|
|
7
|
+
/**
|
|
8
|
+
* Secret type classification
|
|
9
|
+
* @trace REQ-SEC-SECRET-001
|
|
10
|
+
*/
|
|
11
|
+
export type SecretType = 'api-key' | 'aws-access-key' | 'aws-secret-key' | 'azure-connection-string' | 'gcp-service-account' | 'github-token' | 'gitlab-token' | 'npm-token' | 'private-key' | 'ssh-key' | 'database-url' | 'jwt-secret' | 'oauth-secret' | 'password' | 'encryption-key' | 'slack-webhook' | 'stripe-key' | 'twilio-key' | 'sendgrid-key' | 'custom';
|
|
12
|
+
/**
|
|
13
|
+
* Secret context (where it was found)
|
|
14
|
+
*/
|
|
15
|
+
export type SecretContext = 'source-code' | 'config-file' | 'environment' | 'comment' | 'string-literal' | 'template-literal' | 'object-property' | 'array-element';
|
|
16
|
+
/**
|
|
17
|
+
* Detected secret
|
|
18
|
+
* @trace REQ-SEC-SECRET-001
|
|
19
|
+
*/
|
|
20
|
+
export interface Secret {
|
|
21
|
+
/** Unique secret ID (e.g., "SEC-2026-001") */
|
|
22
|
+
id: string;
|
|
23
|
+
/** Secret type */
|
|
24
|
+
type: SecretType;
|
|
25
|
+
/** Source code location */
|
|
26
|
+
location: SourceLocation;
|
|
27
|
+
/** Masked value (first 4 and last 4 chars visible) */
|
|
28
|
+
maskedValue: string;
|
|
29
|
+
/** Full value hash (SHA-256) for deduplication */
|
|
30
|
+
valueHash: string;
|
|
31
|
+
/** Variable/key name if identifiable */
|
|
32
|
+
keyName?: string;
|
|
33
|
+
/** Context where secret was found */
|
|
34
|
+
context: SecretContext;
|
|
35
|
+
/** Detection confidence (0.0 - 1.0) */
|
|
36
|
+
confidence: number;
|
|
37
|
+
/** Whether this appears to be a test/example value */
|
|
38
|
+
isTestValue: boolean;
|
|
39
|
+
/** Pattern ID that detected this secret */
|
|
40
|
+
patternId: string;
|
|
41
|
+
/** Detection timestamp */
|
|
42
|
+
detectedAt: Date;
|
|
43
|
+
/** Severity based on secret type */
|
|
44
|
+
severity: Severity;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Secret detection pattern
|
|
48
|
+
* @trace REQ-SEC-SECRET-002
|
|
49
|
+
*/
|
|
50
|
+
export interface SecretPattern {
|
|
51
|
+
/** Unique pattern ID */
|
|
52
|
+
id: string;
|
|
53
|
+
/** Pattern name */
|
|
54
|
+
name: string;
|
|
55
|
+
/** Secret type this pattern detects */
|
|
56
|
+
type: SecretType;
|
|
57
|
+
/** Regex pattern to match */
|
|
58
|
+
regex: RegExp;
|
|
59
|
+
/** Optional key name patterns (for key=value pairs) */
|
|
60
|
+
keyPatterns?: RegExp[];
|
|
61
|
+
/** Severity when matched */
|
|
62
|
+
severity: Severity;
|
|
63
|
+
/** Patterns that indicate test/example values */
|
|
64
|
+
testValuePatterns?: RegExp[];
|
|
65
|
+
/** Additional validation function name */
|
|
66
|
+
validator?: string;
|
|
67
|
+
/** Pattern description */
|
|
68
|
+
description: string;
|
|
69
|
+
/** Whether pattern is enabled by default */
|
|
70
|
+
enabled: boolean;
|
|
71
|
+
/** False positive rate (for tuning) */
|
|
72
|
+
falsePositiveRate?: number;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Built-in secret patterns
|
|
76
|
+
*/
|
|
77
|
+
export declare const BUILTIN_SECRET_PATTERNS: Omit<SecretPattern, 'regex' | 'keyPatterns' | 'testValuePatterns'>[];
|
|
78
|
+
/**
|
|
79
|
+
* Secret scan options
|
|
80
|
+
*/
|
|
81
|
+
export interface SecretScanOptions {
|
|
82
|
+
/** Custom patterns to use */
|
|
83
|
+
customPatterns?: SecretPattern[];
|
|
84
|
+
/** Built-in patterns to disable */
|
|
85
|
+
disablePatterns?: string[];
|
|
86
|
+
/** File patterns to exclude */
|
|
87
|
+
excludePatterns?: string[];
|
|
88
|
+
/** Ignore test/example values */
|
|
89
|
+
ignoreTestValues?: boolean;
|
|
90
|
+
/** Maximum file size in bytes */
|
|
91
|
+
maxFileSize?: number;
|
|
92
|
+
/** Verify secrets (check if they're valid/active) */
|
|
93
|
+
verify?: boolean;
|
|
94
|
+
/** Entropy threshold for generic detection */
|
|
95
|
+
entropyThreshold?: number;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Secret scan result
|
|
99
|
+
* @trace REQ-SEC-SECRET-001
|
|
100
|
+
*/
|
|
101
|
+
export interface SecretScanResult {
|
|
102
|
+
/** Detected secrets */
|
|
103
|
+
secrets: Secret[];
|
|
104
|
+
/** Number of files scanned */
|
|
105
|
+
scannedFiles: number;
|
|
106
|
+
/** Number of files skipped */
|
|
107
|
+
skippedFiles: number;
|
|
108
|
+
/** Scan duration in milliseconds */
|
|
109
|
+
duration: number;
|
|
110
|
+
/** Scan timestamp */
|
|
111
|
+
timestamp: Date;
|
|
112
|
+
/** Scan options used */
|
|
113
|
+
options: SecretScanOptions;
|
|
114
|
+
/** Summary by type */
|
|
115
|
+
summary: {
|
|
116
|
+
byType: Partial<Record<SecretType, number>>;
|
|
117
|
+
bySeverity: {
|
|
118
|
+
critical: number;
|
|
119
|
+
high: number;
|
|
120
|
+
medium: number;
|
|
121
|
+
low: number;
|
|
122
|
+
};
|
|
123
|
+
total: number;
|
|
124
|
+
testValues: number;
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Secret verification result
|
|
129
|
+
*/
|
|
130
|
+
export interface SecretVerification {
|
|
131
|
+
/** Secret ID */
|
|
132
|
+
secretId: string;
|
|
133
|
+
/** Whether the secret is valid/active */
|
|
134
|
+
isValid: boolean;
|
|
135
|
+
/** Verification method used */
|
|
136
|
+
method: 'api-call' | 'format-check' | 'entropy' | 'none';
|
|
137
|
+
/** Additional info from verification */
|
|
138
|
+
info?: {
|
|
139
|
+
/** For API keys: associated account/org */
|
|
140
|
+
account?: string;
|
|
141
|
+
/** For API keys: permissions */
|
|
142
|
+
permissions?: string[];
|
|
143
|
+
/** Expiration if known */
|
|
144
|
+
expiresAt?: Date;
|
|
145
|
+
};
|
|
146
|
+
/** Verification timestamp */
|
|
147
|
+
verifiedAt: Date;
|
|
148
|
+
/** Error if verification failed */
|
|
149
|
+
error?: string;
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=secret.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secret.d.ts","sourceRoot":"","sources":["../../src/types/secret.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AE,MAAM,CAAC;IACjB,qBAAqB;IACrB,SAAS,EAAE,IAAI,CAAC;IAChB,wBAAwB;IACxB,OAAO,EAAE,iBAAiB,CAAC;IAC3B,sBAAsB;IACtB,OAAO,EAAE;QACP,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC;QAC5C,UAAU,EAAE;YACV,QAAQ,EAAE,MAAM,CAAC;YACjB,IAAI,EAAE,MAAM,CAAC;YACb,MAAM,EAAE,MAAM,CAAC;YACf,GAAG,EAAE,MAAM,CAAC;SACb,CAAC;QACF,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,gBAAgB;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,yCAAyC;IACzC,OAAO,EAAE,OAAO,CAAC;IACjB,+BAA+B;IAC/B,MAAM,EAAE,UAAU,GAAG,cAAc,GAAG,SAAS,GAAG,MAAM,CAAC;IACzD,wCAAwC;IACxC,IAAI,CAAC,EAAE;QACL,2CAA2C;QAC3C,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,gCAAgC;QAChC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;QACvB,0BAA0B;QAC1B,SAAS,CAAC,EAAE,IAAI,CAAC;KAClB,CAAC;IACF,6BAA6B;IAC7B,UAAU,EAAE,IAAI,CAAC;IACjB,mCAAmC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Secret detection type definitions
|
|
3
|
+
* @module @nahisaho/musubix-security/types/secret
|
|
4
|
+
* @trace REQ-SEC-SECRET-001, REQ-SEC-SECRET-002
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Built-in secret patterns
|
|
8
|
+
*/
|
|
9
|
+
export const BUILTIN_SECRET_PATTERNS = [
|
|
10
|
+
{
|
|
11
|
+
id: 'aws-access-key',
|
|
12
|
+
name: 'AWS Access Key ID',
|
|
13
|
+
type: 'aws-access-key',
|
|
14
|
+
severity: 'critical',
|
|
15
|
+
description: 'AWS Access Key ID (starts with AKIA)',
|
|
16
|
+
enabled: true,
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
id: 'aws-secret-key',
|
|
20
|
+
name: 'AWS Secret Access Key',
|
|
21
|
+
type: 'aws-secret-key',
|
|
22
|
+
severity: 'critical',
|
|
23
|
+
description: 'AWS Secret Access Key (40 character base64)',
|
|
24
|
+
enabled: true,
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: 'github-pat',
|
|
28
|
+
name: 'GitHub Personal Access Token',
|
|
29
|
+
type: 'github-token',
|
|
30
|
+
severity: 'critical',
|
|
31
|
+
description: 'GitHub PAT (ghp_*, gho_*, ghu_*, ghs_*, ghr_*)',
|
|
32
|
+
enabled: true,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: 'private-key',
|
|
36
|
+
name: 'Private Key',
|
|
37
|
+
type: 'private-key',
|
|
38
|
+
severity: 'critical',
|
|
39
|
+
description: 'RSA/EC/DSA private key in PEM format',
|
|
40
|
+
enabled: true,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
id: 'jwt-secret',
|
|
44
|
+
name: 'JWT Secret',
|
|
45
|
+
type: 'jwt-secret',
|
|
46
|
+
severity: 'high',
|
|
47
|
+
description: 'JWT signing secret in common patterns',
|
|
48
|
+
enabled: true,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: 'database-url',
|
|
52
|
+
name: 'Database URL',
|
|
53
|
+
type: 'database-url',
|
|
54
|
+
severity: 'high',
|
|
55
|
+
description: 'Database connection string with credentials',
|
|
56
|
+
enabled: true,
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
id: 'generic-api-key',
|
|
60
|
+
name: 'Generic API Key',
|
|
61
|
+
type: 'api-key',
|
|
62
|
+
severity: 'medium',
|
|
63
|
+
description: 'Generic API key patterns',
|
|
64
|
+
enabled: true,
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
id: 'azure-connection',
|
|
68
|
+
name: 'Azure Connection String',
|
|
69
|
+
type: 'azure-connection-string',
|
|
70
|
+
severity: 'critical',
|
|
71
|
+
description: 'Azure storage/service connection strings',
|
|
72
|
+
enabled: true,
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
id: 'stripe-key',
|
|
76
|
+
name: 'Stripe API Key',
|
|
77
|
+
type: 'stripe-key',
|
|
78
|
+
severity: 'critical',
|
|
79
|
+
description: 'Stripe API keys (sk_live_*, rk_live_*)',
|
|
80
|
+
enabled: true,
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
id: 'slack-webhook',
|
|
84
|
+
name: 'Slack Webhook URL',
|
|
85
|
+
type: 'slack-webhook',
|
|
86
|
+
severity: 'medium',
|
|
87
|
+
description: 'Slack incoming webhook URLs',
|
|
88
|
+
enabled: true,
|
|
89
|
+
},
|
|
90
|
+
];
|
|
91
|
+
//# sourceMappingURL=secret.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secret.js","sourceRoot":"","sources":["../../src/types/secret.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAuGH;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAyE;IAC3G;QACE,EAAE,EAAE,gBAAgB;QACpB,IAAI,EAAE,mBAAmB;QACzB,IAAI,EAAE,gBAAgB;QACtB,QAAQ,EAAE,UAAU;QACpB,WAAW,EAAE,sCAAsC;QACnD,OAAO,EAAE,IAAI;KACd;IACD;QACE,EAAE,EAAE,gBAAgB;QACpB,IAAI,EAAE,uBAAuB;QAC7B,IAAI,EAAE,gBAAgB;QACtB,QAAQ,EAAE,UAAU;QACpB,WAAW,EAAE,6CAA6C;QAC1D,OAAO,EAAE,IAAI;KACd;IACD;QACE,EAAE,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QAC1C,OAAO,EAAE,IAAI;KACd;CACF,CAAC"}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Taint analysis type definitions
|
|
3
|
+
* @module @nahisaho/musubix-security/types/taint
|
|
4
|
+
* @trace REQ-SEC-TAINT-001, REQ-SEC-TAINT-002, REQ-SEC-TAINT-003, REQ-SEC-TAINT-004
|
|
5
|
+
*/
|
|
6
|
+
import type { SourceLocation, Severity } from './vulnerability.js';
|
|
7
|
+
/**
|
|
8
|
+
* Taint source category
|
|
9
|
+
* @trace REQ-SEC-TAINT-001
|
|
10
|
+
*/
|
|
11
|
+
export type TaintSourceCategory = 'user-input' | 'database' | 'file-system' | 'network' | 'environment' | 'config' | 'cli-args';
|
|
12
|
+
/**
|
|
13
|
+
* Taint source (where untrusted data enters)
|
|
14
|
+
* @trace REQ-SEC-TAINT-001
|
|
15
|
+
*/
|
|
16
|
+
export interface TaintSource {
|
|
17
|
+
/** Unique source ID */
|
|
18
|
+
id: string;
|
|
19
|
+
/** Source category */
|
|
20
|
+
category: TaintSourceCategory;
|
|
21
|
+
/** Source code location */
|
|
22
|
+
location: SourceLocation;
|
|
23
|
+
/** Variable/parameter name holding tainted data */
|
|
24
|
+
variableName: string;
|
|
25
|
+
/** Expression that produces tainted data */
|
|
26
|
+
expression: string;
|
|
27
|
+
/** Human-readable description */
|
|
28
|
+
description: string;
|
|
29
|
+
/** Detection confidence */
|
|
30
|
+
confidence: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Taint sink category
|
|
34
|
+
* @trace REQ-SEC-TAINT-002
|
|
35
|
+
*/
|
|
36
|
+
export type TaintSinkCategory = 'sql-query' | 'nosql-query' | 'command-exec' | 'file-write' | 'file-read' | 'html-output' | 'redirect' | 'eval' | 'deserialization' | 'ldap-query' | 'xpath-query' | 'http-request';
|
|
37
|
+
/**
|
|
38
|
+
* Taint sink (where tainted data could cause harm)
|
|
39
|
+
* @trace REQ-SEC-TAINT-002
|
|
40
|
+
*/
|
|
41
|
+
export interface TaintSink {
|
|
42
|
+
/** Unique sink ID */
|
|
43
|
+
id: string;
|
|
44
|
+
/** Sink category */
|
|
45
|
+
category: TaintSinkCategory;
|
|
46
|
+
/** Source code location */
|
|
47
|
+
location: SourceLocation;
|
|
48
|
+
/** Function/method name being called */
|
|
49
|
+
functionName: string;
|
|
50
|
+
/** Argument index receiving tainted data (0-based) */
|
|
51
|
+
argumentIndex: number;
|
|
52
|
+
/** Expected sanitization functions */
|
|
53
|
+
expectedSanitizers: string[];
|
|
54
|
+
/** Human-readable description */
|
|
55
|
+
description: string;
|
|
56
|
+
/** Severity if tainted data reaches this sink */
|
|
57
|
+
severity: Severity;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Taint flow step in the propagation path
|
|
61
|
+
* @trace REQ-SEC-TAINT-003
|
|
62
|
+
*/
|
|
63
|
+
export interface TaintFlowStep {
|
|
64
|
+
/** Step index in the path (0-based) */
|
|
65
|
+
index: number;
|
|
66
|
+
/** Source code location */
|
|
67
|
+
location: SourceLocation;
|
|
68
|
+
/** Expression at this step */
|
|
69
|
+
expression: string;
|
|
70
|
+
/** Variable name holding data at this step */
|
|
71
|
+
variableName?: string;
|
|
72
|
+
/** Type of operation (assignment, call, return, etc.) */
|
|
73
|
+
operation: 'assignment' | 'call' | 'return' | 'parameter' | 'property-access' | 'array-access';
|
|
74
|
+
/** Whether sanitization was applied at this step */
|
|
75
|
+
sanitized: boolean;
|
|
76
|
+
/** Sanitizer function if sanitization was applied */
|
|
77
|
+
sanitizer?: string;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Complete taint propagation path from source to sink
|
|
81
|
+
* @trace REQ-SEC-TAINT-003
|
|
82
|
+
*/
|
|
83
|
+
export interface TaintPath {
|
|
84
|
+
/** Unique path ID */
|
|
85
|
+
id: string;
|
|
86
|
+
/** Source where tainted data originates */
|
|
87
|
+
source: TaintSource;
|
|
88
|
+
/** Sink where tainted data is used unsafely */
|
|
89
|
+
sink: TaintSink;
|
|
90
|
+
/** Steps in the propagation path */
|
|
91
|
+
steps: TaintFlowStep[];
|
|
92
|
+
/** Whether any sanitization was applied */
|
|
93
|
+
sanitized: boolean;
|
|
94
|
+
/** Overall path confidence */
|
|
95
|
+
confidence: number;
|
|
96
|
+
/** Path length (number of steps) */
|
|
97
|
+
length: number;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Taint analysis result
|
|
101
|
+
* @trace REQ-SEC-TAINT-001
|
|
102
|
+
*/
|
|
103
|
+
export interface TaintResult {
|
|
104
|
+
/** Detected taint sources */
|
|
105
|
+
sources: TaintSource[];
|
|
106
|
+
/** Detected taint sinks */
|
|
107
|
+
sinks: TaintSink[];
|
|
108
|
+
/** Unsafe taint paths (source → sink without proper sanitization) */
|
|
109
|
+
unsafePaths: TaintPath[];
|
|
110
|
+
/** Number of files analyzed */
|
|
111
|
+
analyzedFiles: number;
|
|
112
|
+
/** Analysis duration in milliseconds */
|
|
113
|
+
duration: number;
|
|
114
|
+
/** Analysis timestamp */
|
|
115
|
+
timestamp: Date;
|
|
116
|
+
/** Summary statistics */
|
|
117
|
+
summary: {
|
|
118
|
+
totalSources: number;
|
|
119
|
+
totalSinks: number;
|
|
120
|
+
unsafePathCount: number;
|
|
121
|
+
bySeverity: {
|
|
122
|
+
critical: number;
|
|
123
|
+
high: number;
|
|
124
|
+
medium: number;
|
|
125
|
+
low: number;
|
|
126
|
+
};
|
|
127
|
+
bySourceCategory: Record<TaintSourceCategory, number>;
|
|
128
|
+
bySinkCategory: Record<TaintSinkCategory, number>;
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Taint analysis options
|
|
133
|
+
* @trace REQ-SEC-TAINT-004
|
|
134
|
+
*/
|
|
135
|
+
export interface TaintAnalysisOptions {
|
|
136
|
+
/** Custom source patterns (regex patterns) */
|
|
137
|
+
customSources?: {
|
|
138
|
+
pattern: string;
|
|
139
|
+
category: TaintSourceCategory;
|
|
140
|
+
description: string;
|
|
141
|
+
}[];
|
|
142
|
+
/** Custom sink patterns */
|
|
143
|
+
customSinks?: {
|
|
144
|
+
pattern: string;
|
|
145
|
+
category: TaintSinkCategory;
|
|
146
|
+
severity: Severity;
|
|
147
|
+
description: string;
|
|
148
|
+
}[];
|
|
149
|
+
/** Additional sanitizer functions to recognize */
|
|
150
|
+
additionalSanitizers?: {
|
|
151
|
+
functionName: string;
|
|
152
|
+
sinkCategories: TaintSinkCategory[];
|
|
153
|
+
}[];
|
|
154
|
+
/** Maximum path depth to track */
|
|
155
|
+
maxPathDepth?: number;
|
|
156
|
+
/** Enable inter-procedural analysis */
|
|
157
|
+
interprocedural?: boolean;
|
|
158
|
+
/** Track through async/await boundaries */
|
|
159
|
+
trackAsync?: boolean;
|
|
160
|
+
/** File patterns to exclude */
|
|
161
|
+
excludePatterns?: string[];
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Known sanitizer function
|
|
165
|
+
*/
|
|
166
|
+
export interface SanitizerDefinition {
|
|
167
|
+
/** Function name or pattern */
|
|
168
|
+
name: string;
|
|
169
|
+
/** Package/module containing the sanitizer */
|
|
170
|
+
package?: string;
|
|
171
|
+
/** Sink categories this sanitizer protects against */
|
|
172
|
+
protects: TaintSinkCategory[];
|
|
173
|
+
/** Whether sanitization is complete or partial */
|
|
174
|
+
complete: boolean;
|
|
175
|
+
/** Notes about the sanitizer */
|
|
176
|
+
notes?: string;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Built-in sanitizer definitions
|
|
180
|
+
*/
|
|
181
|
+
export declare const BUILTIN_SANITIZERS: SanitizerDefinition[];
|
|
182
|
+
//# sourceMappingURL=taint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taint.d.ts","sourceRoot":"","sources":["../../src/types/taint.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,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ACH,eAAO,MAAM,kBAAkB,EAAE,mBAAmB,EAcnD,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Taint analysis type definitions
|
|
3
|
+
* @module @nahisaho/musubix-security/types/taint
|
|
4
|
+
* @trace REQ-SEC-TAINT-001, REQ-SEC-TAINT-002, REQ-SEC-TAINT-003, REQ-SEC-TAINT-004
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Built-in sanitizer definitions
|
|
8
|
+
*/
|
|
9
|
+
export const BUILTIN_SANITIZERS = [
|
|
10
|
+
// SQL
|
|
11
|
+
{ name: 'escape', package: 'mysql', protects: ['sql-query'], complete: true },
|
|
12
|
+
{ name: 'escape', package: 'pg', protects: ['sql-query'], complete: true },
|
|
13
|
+
{ name: 'parameterize', protects: ['sql-query', 'nosql-query'], complete: true },
|
|
14
|
+
// XSS
|
|
15
|
+
{ name: 'escapeHtml', protects: ['html-output'], complete: true },
|
|
16
|
+
{ name: 'sanitizeHtml', package: 'sanitize-html', protects: ['html-output'], complete: true },
|
|
17
|
+
{ name: 'encode', package: 'html-entities', protects: ['html-output'], complete: true },
|
|
18
|
+
// Command
|
|
19
|
+
{ name: 'quote', package: 'shell-quote', protects: ['command-exec'], complete: true },
|
|
20
|
+
// Path
|
|
21
|
+
{ name: 'basename', package: 'path', protects: ['file-read', 'file-write'], complete: false, notes: 'Only removes directory components' },
|
|
22
|
+
{ name: 'normalize', package: 'path', protects: ['file-read', 'file-write'], complete: false, notes: 'Resolves .. but does not prevent traversal' },
|
|
23
|
+
];
|
|
24
|
+
//# sourceMappingURL=taint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taint.js","sourceRoot":"","sources":["../../src/types/taint.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA2MH;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAA0B;IACvD,MAAM;IACN,EAAE,IAAI,EAAE,QAAQ,EA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ulnerability type definitions
|
|
3
|
+
* @module @nahisaho/musubix-security/types/vulnerability
|
|
4
|
+
* @trace REQ-SEC-SCAN-001, REQ-SEC-SCAN-002, REQ-SEC-SCAN-003
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* OWASP Top 10 (2021) vulnerability categories
|
|
8
|
+
*/
|
|
9
|
+
export type OWASPCategory = 'A01:2021' | 'A02:2021' | 'A03:2021' | 'A04:2021' | 'A05:2021' | 'A06:2021' | 'A07:2021' | 'A08:2021' | 'A09:2021' | 'A10:2021';
|
|
10
|
+
/**
|
|
11
|
+
* Vulnerability type classification
|
|
12
|
+
*/
|
|
13
|
+
export type VulnerabilityType = 'injection' | 'xss' | 'broken-access' | 'broken-auth' | 'sensitive-exposure' | 'xxe' | 'misconfig' | 'insecure-deser' | 'vuln-components' | 'insufficient-logging' | 'ssrf' | 'path-traversal' | 'command-injection' | 'code-injection' | 'open-redirect' | 'prototype-pollution';
|
|
14
|
+
/**
|
|
15
|
+
* Severity levels for vulnerabilities
|
|
16
|
+
*/
|
|
17
|
+
export type Severity = 'critical' | 'high' | 'medium' | 'low' | 'info';
|
|
18
|
+
/**
|
|
19
|
+
* Source code location
|
|
20
|
+
* @trace DES-SEC-SCAN-001
|
|
21
|
+
*/
|
|
22
|
+
export interface SourceLocation {
|
|
23
|
+
/** Absolute file path */
|
|
24
|
+
file: string;
|
|
25
|
+
/** Start line number (1-based) */
|
|
26
|
+
startLine: number;
|
|
27
|
+
/** End line number (1-based) */
|
|
28
|
+
endLine: number;
|
|
29
|
+
/** Start column number (0-based) */
|
|
30
|
+
startColumn: number;
|
|
31
|
+
/** End column number (0-based) */
|
|
32
|
+
endColumn: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Detected vulnerability
|
|
36
|
+
* @trace REQ-SEC-SCAN-001
|
|
37
|
+
*/
|
|
38
|
+
export interface Vulnerability {
|
|
39
|
+
/** Unique vulnerability ID (e.g., "VULN-2026-001") */
|
|
40
|
+
id: string;
|
|
41
|
+
/** Vulnerability type classification */
|
|
42
|
+
type: VulnerabilityType;
|
|
43
|
+
/** Severity level */
|
|
44
|
+
severity: Severity;
|
|
45
|
+
/** Related CWE identifiers */
|
|
46
|
+
cwes: string[];
|
|
47
|
+
/** Related OWASP categories */
|
|
48
|
+
owasp?: OWASPCategory[];
|
|
49
|
+
/** Source code location */
|
|
50
|
+
location: SourceLocation;
|
|
51
|
+
/** Human-readable description */
|
|
52
|
+
description: string;
|
|
53
|
+
/** Recommended fix */
|
|
54
|
+
recommendation: string;
|
|
55
|
+
/** Detection confidence (0.0 - 1.0) */
|
|
56
|
+
confidence: number;
|
|
57
|
+
/** Rule ID that detected this vulnerability */
|
|
58
|
+
ruleId: string;
|
|
59
|
+
/** Original vulnerable code snippet */
|
|
60
|
+
codeSnippet?: string;
|
|
61
|
+
/** Detection timestamp */
|
|
62
|
+
detectedAt: Date;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Scan options
|
|
66
|
+
* @trace REQ-SEC-SCAN-004
|
|
67
|
+
*/
|
|
68
|
+
export interface ScanOptions {
|
|
69
|
+
/** Filter by severity levels */
|
|
70
|
+
severityFilter?: Severity[];
|
|
71
|
+
/** Rulesets to use */
|
|
72
|
+
rulesets?: ('owasp-top-10' | 'cwe-top-25' | 'custom')[];
|
|
73
|
+
/** File patterns to exclude */
|
|
74
|
+
excludePatterns?: string[];
|
|
75
|
+
/** Maximum file size in bytes */
|
|
76
|
+
maxFileSize?: number;
|
|
77
|
+
/** Enable incremental scanning */
|
|
78
|
+
incremental?: boolean;
|
|
79
|
+
/** Custom rules directory */
|
|
80
|
+
customRulesDir?: string;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Scan result
|
|
84
|
+
* @trace REQ-SEC-SCAN-001
|
|
85
|
+
*/
|
|
86
|
+
export interface ScanResult {
|
|
87
|
+
/** Detected vulnerabilities */
|
|
88
|
+
vulnerabilities: Vulnerability[];
|
|
89
|
+
/** Number of files scanned */
|
|
90
|
+
scannedFiles: number;
|
|
91
|
+
/** Number of files skipped */
|
|
92
|
+
skippedFiles: number;
|
|
93
|
+
/** Scan duration in milliseconds */
|
|
94
|
+
duration: number;
|
|
95
|
+
/** Scan timestamp */
|
|
96
|
+
timestamp: Date;
|
|
97
|
+
/** Scan options used */
|
|
98
|
+
options: ScanOptions;
|
|
99
|
+
/** Summary by severity */
|
|
100
|
+
summary: {
|
|
101
|
+
critical: number;
|
|
102
|
+
high: number;
|
|
103
|
+
medium: number;
|
|
104
|
+
low: number;
|
|
105
|
+
info: number;
|
|
106
|
+
total: number;
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Security rule definition
|
|
111
|
+
*/
|
|
112
|
+
export interface SecurityRule {
|
|
113
|
+
/** Unique rule ID */
|
|
114
|
+
id: string;
|
|
115
|
+
/** Rule name */
|
|
116
|
+
name: string;
|
|
117
|
+
/** Rule description */
|
|
118
|
+
description: string;
|
|
119
|
+
/** Vulnerability type this rule detects */
|
|
120
|
+
type: VulnerabilityType;
|
|
121
|
+
/** Default severity */
|
|
122
|
+
severity: Severity;
|
|
123
|
+
/** Related CWEs */
|
|
124
|
+
cwes: string[];
|
|
125
|
+
/** Related OWASP categories */
|
|
126
|
+
owasp?: OWASPCategory[];
|
|
127
|
+
/** AST pattern to match (simplified) */
|
|
128
|
+
pattern?: string;
|
|
129
|
+
/** Detection function name */
|
|
130
|
+
detector?: string;
|
|
131
|
+
/** Whether rule is enabled by default */
|
|
132
|
+
enabled: boolean;
|
|
133
|
+
/** Rule metadata */
|
|
134
|
+
metadata?: Record<string, unknown>;
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=vulnerability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vulnerability.d.ts","sourceRoot":"","sources":["../../src/types/vulnerability.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,MAAM,a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