@claude-flow/security 3.0.0-alpha.1
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/.agentic-flow/intelligence.json +16 -0
- package/README.md +234 -0
- package/__tests__/acceptance/security-compliance.test.ts +674 -0
- package/__tests__/coverage/base.css +224 -0
- package/__tests__/coverage/block-navigation.js +87 -0
- package/__tests__/coverage/coverage-final.json +11 -0
- package/__tests__/coverage/favicon.png +0 -0
- package/__tests__/coverage/index.html +161 -0
- package/__tests__/coverage/lcov-report/base.css +224 -0
- package/__tests__/coverage/lcov-report/block-navigation.js +87 -0
- package/__tests__/coverage/lcov-report/favicon.png +0 -0
- package/__tests__/coverage/lcov-report/index.html +161 -0
- package/__tests__/coverage/lcov-report/prettify.css +1 -0
- package/__tests__/coverage/lcov-report/prettify.js +2 -0
- package/__tests__/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/__tests__/coverage/lcov-report/sorter.js +210 -0
- package/__tests__/coverage/lcov-report/src/CVE-REMEDIATION.ts.html +838 -0
- package/__tests__/coverage/lcov-report/src/application/services/index.html +116 -0
- package/__tests__/coverage/lcov-report/src/application/services/security-application-service.ts.html +664 -0
- package/__tests__/coverage/lcov-report/src/credential-generator.ts.html +1189 -0
- package/__tests__/coverage/lcov-report/src/domain/entities/index.html +116 -0
- package/__tests__/coverage/lcov-report/src/domain/entities/security-context.ts.html +604 -0
- package/__tests__/coverage/lcov-report/src/domain/services/index.html +116 -0
- package/__tests__/coverage/lcov-report/src/domain/services/security-domain-service.ts.html +973 -0
- package/__tests__/coverage/lcov-report/src/index.html +206 -0
- package/__tests__/coverage/lcov-report/src/input-validator.ts.html +1483 -0
- package/__tests__/coverage/lcov-report/src/password-hasher.ts.html +895 -0
- package/__tests__/coverage/lcov-report/src/path-validator.ts.html +1660 -0
- package/__tests__/coverage/lcov-report/src/safe-executor.ts.html +1660 -0
- package/__tests__/coverage/lcov-report/src/token-generator.ts.html +1474 -0
- package/__tests__/coverage/lcov.info +3650 -0
- package/__tests__/coverage/prettify.css +1 -0
- package/__tests__/coverage/prettify.js +2 -0
- package/__tests__/coverage/sort-arrow-sprite.png +0 -0
- package/__tests__/coverage/sorter.js +210 -0
- package/__tests__/coverage/src/CVE-REMEDIATION.ts.html +838 -0
- package/__tests__/coverage/src/application/services/index.html +116 -0
- package/__tests__/coverage/src/application/services/security-application-service.ts.html +664 -0
- package/__tests__/coverage/src/credential-generator.ts.html +1189 -0
- package/__tests__/coverage/src/domain/entities/index.html +116 -0
- package/__tests__/coverage/src/domain/entities/security-context.ts.html +604 -0
- package/__tests__/coverage/src/domain/services/index.html +116 -0
- package/__tests__/coverage/src/domain/services/security-domain-service.ts.html +973 -0
- package/__tests__/coverage/src/index.html +206 -0
- package/__tests__/coverage/src/input-validator.ts.html +1483 -0
- package/__tests__/coverage/src/password-hasher.ts.html +895 -0
- package/__tests__/coverage/src/path-validator.ts.html +1660 -0
- package/__tests__/coverage/src/safe-executor.ts.html +1660 -0
- package/__tests__/coverage/src/token-generator.ts.html +1474 -0
- package/__tests__/credential-generator.test.ts +310 -0
- package/__tests__/fixtures/configurations.ts +419 -0
- package/__tests__/fixtures/index.ts +21 -0
- package/__tests__/helpers/create-mock.ts +469 -0
- package/__tests__/helpers/index.ts +32 -0
- package/__tests__/input-validator.test.ts +381 -0
- package/__tests__/integration/security-flow.test.ts +606 -0
- package/__tests__/password-hasher.test.ts +239 -0
- package/__tests__/path-validator.test.ts +302 -0
- package/__tests__/safe-executor.test.ts +292 -0
- package/__tests__/token-generator.test.ts +371 -0
- package/__tests__/unit/credential-generator.test.ts +182 -0
- package/__tests__/unit/password-hasher.test.ts +359 -0
- package/__tests__/unit/path-validator.test.ts +509 -0
- package/__tests__/unit/safe-executor.test.ts +667 -0
- package/__tests__/unit/token-generator.test.ts +310 -0
- package/dist/CVE-REMEDIATION.d.ts +86 -0
- package/dist/CVE-REMEDIATION.d.ts.map +1 -0
- package/dist/CVE-REMEDIATION.js +221 -0
- package/dist/CVE-REMEDIATION.js.map +1 -0
- package/dist/application/index.d.ts +7 -0
- package/dist/application/index.d.ts.map +1 -0
- package/dist/application/index.js +7 -0
- package/dist/application/index.js.map +1 -0
- package/dist/application/services/security-application-service.d.ts +71 -0
- package/dist/application/services/security-application-service.d.ts.map +1 -0
- package/dist/application/services/security-application-service.js +153 -0
- package/dist/application/services/security-application-service.js.map +1 -0
- package/dist/credential-generator.d.ts +176 -0
- package/dist/credential-generator.d.ts.map +1 -0
- package/dist/credential-generator.js +272 -0
- package/dist/credential-generator.js.map +1 -0
- package/dist/domain/entities/security-context.d.ts +68 -0
- package/dist/domain/entities/security-context.d.ts.map +1 -0
- package/dist/domain/entities/security-context.js +132 -0
- package/dist/domain/entities/security-context.js.map +1 -0
- package/dist/domain/index.d.ts +8 -0
- package/dist/domain/index.d.ts.map +1 -0
- package/dist/domain/index.js +8 -0
- package/dist/domain/index.js.map +1 -0
- package/dist/domain/services/security-domain-service.d.ts +71 -0
- package/dist/domain/services/security-domain-service.d.ts.map +1 -0
- package/dist/domain/services/security-domain-service.js +237 -0
- package/dist/domain/services/security-domain-service.js.map +1 -0
- package/dist/index.d.ts +119 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +145 -0
- package/dist/index.js.map +1 -0
- package/dist/input-validator.d.ts +306 -0
- package/dist/input-validator.d.ts.map +1 -0
- package/dist/input-validator.js +393 -0
- package/dist/input-validator.js.map +1 -0
- package/dist/password-hasher.d.ts +128 -0
- package/dist/password-hasher.d.ts.map +1 -0
- package/dist/password-hasher.js +183 -0
- package/dist/password-hasher.js.map +1 -0
- package/dist/path-validator.d.ts +148 -0
- package/dist/path-validator.d.ts.map +1 -0
- package/dist/path-validator.js +421 -0
- package/dist/path-validator.js.map +1 -0
- package/dist/safe-executor.d.ts +173 -0
- package/dist/safe-executor.d.ts.map +1 -0
- package/dist/safe-executor.js +370 -0
- package/dist/safe-executor.js.map +1 -0
- package/dist/token-generator.d.ts +224 -0
- package/dist/token-generator.d.ts.map +1 -0
- package/dist/token-generator.js +351 -0
- package/dist/token-generator.js.map +1 -0
- package/package.json +28 -0
- package/src/CVE-REMEDIATION.ts +251 -0
- package/src/application/index.ts +10 -0
- package/src/application/services/security-application-service.ts +193 -0
- package/src/credential-generator.ts +368 -0
- package/src/domain/entities/security-context.ts +173 -0
- package/src/domain/index.ts +17 -0
- package/src/domain/services/security-domain-service.ts +296 -0
- package/src/index.ts +271 -0
- package/src/input-validator.ts +466 -0
- package/src/password-hasher.ts +270 -0
- package/src/path-validator.ts +525 -0
- package/src/safe-executor.ts +525 -0
- package/src/token-generator.ts +463 -0
- package/tsconfig.json +9 -0
- package/tsconfig.tsbuildinfo +1 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* V3 Security Module
|
|
3
|
+
*
|
|
4
|
+
* Comprehensive security module addressing all identified vulnerabilities:
|
|
5
|
+
* - CVE-2: Weak Password Hashing (password-hasher.ts)
|
|
6
|
+
* - CVE-3: Hardcoded Default Credentials (credential-generator.ts)
|
|
7
|
+
* - HIGH-1: Command Injection (safe-executor.ts)
|
|
8
|
+
* - HIGH-2: Path Traversal (path-validator.ts)
|
|
9
|
+
*
|
|
10
|
+
* Also provides:
|
|
11
|
+
* - Input validation with Zod schemas
|
|
12
|
+
* - Secure token generation
|
|
13
|
+
*
|
|
14
|
+
* @module v3/security
|
|
15
|
+
*/
|
|
16
|
+
export { PasswordHasher, PasswordHashError, createPasswordHasher, type PasswordHasherConfig, type PasswordValidationResult, } from './password-hasher.js';
|
|
17
|
+
export { CredentialGenerator, CredentialGeneratorError, createCredentialGenerator, generateCredentials, type CredentialConfig, type GeneratedCredentials, type ApiKeyCredential, } from './credential-generator.js';
|
|
18
|
+
export { SafeExecutor, SafeExecutorError, createDevelopmentExecutor, createReadOnlyExecutor, type ExecutorConfig, type ExecutionResult, type StreamingExecutor, } from './safe-executor.js';
|
|
19
|
+
export { PathValidator, PathValidatorError, createProjectPathValidator, createFullProjectPathValidator, type PathValidatorConfig, type PathValidationResult, } from './path-validator.js';
|
|
20
|
+
export { InputValidator, sanitizeString, sanitizeHtml, sanitizePath, SafeStringSchema, IdentifierSchema, FilenameSchema, EmailSchema, PasswordSchema, UUIDSchema, HttpsUrlSchema, UrlSchema, SemverSchema, PortSchema, IPv4Schema, IPSchema, UserRoleSchema, PermissionSchema, LoginRequestSchema, CreateUserSchema, CreateApiKeySchema, AgentTypeSchema, SpawnAgentSchema, TaskInputSchema, CommandArgumentSchema, PathSchema, SecurityConfigSchema, ExecutorConfigSchema, PATTERNS, LIMITS, z, } from './input-validator.js';
|
|
21
|
+
export { TokenGenerator, TokenGeneratorError, createTokenGenerator, getDefaultGenerator, quickGenerate, type TokenConfig, type Token, type SignedToken, type VerificationCode, } from './token-generator.js';
|
|
22
|
+
import { PasswordHasher } from './password-hasher.js';
|
|
23
|
+
import { CredentialGenerator } from './credential-generator.js';
|
|
24
|
+
import { SafeExecutor } from './safe-executor.js';
|
|
25
|
+
import { PathValidator } from './path-validator.js';
|
|
26
|
+
import { TokenGenerator } from './token-generator.js';
|
|
27
|
+
/**
|
|
28
|
+
* Security module configuration
|
|
29
|
+
*/
|
|
30
|
+
export interface SecurityModuleConfig {
|
|
31
|
+
/**
|
|
32
|
+
* Project root directory for path validation
|
|
33
|
+
*/
|
|
34
|
+
projectRoot: string;
|
|
35
|
+
/**
|
|
36
|
+
* HMAC secret for token signing
|
|
37
|
+
*/
|
|
38
|
+
hmacSecret: string;
|
|
39
|
+
/**
|
|
40
|
+
* Bcrypt rounds for password hashing
|
|
41
|
+
* Default: 12
|
|
42
|
+
*/
|
|
43
|
+
bcryptRounds?: number;
|
|
44
|
+
/**
|
|
45
|
+
* Allowed commands for safe executor
|
|
46
|
+
* Default: ['git', 'npm', 'npx', 'node']
|
|
47
|
+
*/
|
|
48
|
+
allowedCommands?: string[];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Complete security module instance
|
|
52
|
+
*/
|
|
53
|
+
export interface SecurityModule {
|
|
54
|
+
passwordHasher: PasswordHasher;
|
|
55
|
+
credentialGenerator: CredentialGenerator;
|
|
56
|
+
safeExecutor: SafeExecutor;
|
|
57
|
+
pathValidator: PathValidator;
|
|
58
|
+
tokenGenerator: TokenGenerator;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Creates a complete security module with all components configured.
|
|
62
|
+
*
|
|
63
|
+
* @param config - Module configuration
|
|
64
|
+
* @returns Complete security module
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```typescript
|
|
68
|
+
* const security = createSecurityModule({
|
|
69
|
+
* projectRoot: '/workspaces/project',
|
|
70
|
+
* hmacSecret: process.env.HMAC_SECRET!,
|
|
71
|
+
* });
|
|
72
|
+
*
|
|
73
|
+
* // Hash password
|
|
74
|
+
* const hash = await security.passwordHasher.hash('password');
|
|
75
|
+
*
|
|
76
|
+
* // Validate path
|
|
77
|
+
* const result = await security.pathValidator.validate('/workspaces/project/src/file.ts');
|
|
78
|
+
*
|
|
79
|
+
* // Execute command safely
|
|
80
|
+
* const output = await security.safeExecutor.execute('git', ['status']);
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export declare function createSecurityModule(config: SecurityModuleConfig): SecurityModule;
|
|
84
|
+
/**
|
|
85
|
+
* Minimum recommended bcrypt rounds for production
|
|
86
|
+
*/
|
|
87
|
+
export declare const MIN_BCRYPT_ROUNDS = 12;
|
|
88
|
+
/**
|
|
89
|
+
* Maximum recommended bcrypt rounds (performance consideration)
|
|
90
|
+
*/
|
|
91
|
+
export declare const MAX_BCRYPT_ROUNDS = 14;
|
|
92
|
+
/**
|
|
93
|
+
* Minimum password length
|
|
94
|
+
*/
|
|
95
|
+
export declare const MIN_PASSWORD_LENGTH = 8;
|
|
96
|
+
/**
|
|
97
|
+
* Maximum password length (bcrypt limitation)
|
|
98
|
+
*/
|
|
99
|
+
export declare const MAX_PASSWORD_LENGTH = 72;
|
|
100
|
+
/**
|
|
101
|
+
* Default token expiration in seconds (1 hour)
|
|
102
|
+
*/
|
|
103
|
+
export declare const DEFAULT_TOKEN_EXPIRATION = 3600;
|
|
104
|
+
/**
|
|
105
|
+
* Default session expiration in seconds (24 hours)
|
|
106
|
+
*/
|
|
107
|
+
export declare const DEFAULT_SESSION_EXPIRATION = 86400;
|
|
108
|
+
/**
|
|
109
|
+
* Checks security configuration for common issues.
|
|
110
|
+
*
|
|
111
|
+
* @param config - Configuration to audit
|
|
112
|
+
* @returns Array of security warnings
|
|
113
|
+
*/
|
|
114
|
+
export declare function auditSecurityConfig(config: Partial<SecurityModuleConfig>): string[];
|
|
115
|
+
/**
|
|
116
|
+
* Security module version
|
|
117
|
+
*/
|
|
118
|
+
export declare const SECURITY_MODULE_VERSION = "3.0.0-alpha.1";
|
|
119
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,GAC9B,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EACzB,mBAAmB,EACnB,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,GACtB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,yBAAyB,EACzB,sBAAsB,EACtB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,iBAAiB,GACvB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,0BAA0B,EAC1B,8BAA8B,EAC9B,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,GAC1B,MAAM,qBAAqB,C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AC3B,aAAa,EAAE,aAAa,CAAC;IAC7B,cAAc,EAAE,cAAc,CAAC;CAChC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,oBAAoB,GAAG,cAAc,CAiBjF;AAMD;;GAEG;AACH,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAEpC;;GAEG;AACH,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAEpC;;GAEG;AACH,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC;;GAEG;AACH,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAEtC;;GAEG;AACH,eAAO,MAAM,wBAAwB,OAAO,CAAC;AAE7C;;GAEG;AACH,eAAO,MAAM,0BAA0B,QAAQ,CAAC;AAMhD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAAG,MAAM,EAAE,CAoBnF;AAED;;GAEG;AACH,eAAO,MAAM,uBAAuB,kBAAkB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* V3 Security Module
|
|
3
|
+
*
|
|
4
|
+
* Comprehensive security module addressing all identified vulnerabilities:
|
|
5
|
+
* - CVE-2: Weak Password Hashing (password-hasher.ts)
|
|
6
|
+
* - CVE-3: Hardcoded Default Credentials (credential-generator.ts)
|
|
7
|
+
* - HIGH-1: Command Injection (safe-executor.ts)
|
|
8
|
+
* - HIGH-2: Path Traversal (path-validator.ts)
|
|
9
|
+
*
|
|
10
|
+
* Also provides:
|
|
11
|
+
* - Input validation with Zod schemas
|
|
12
|
+
* - Secure token generation
|
|
13
|
+
*
|
|
14
|
+
* @module v3/security
|
|
15
|
+
*/
|
|
16
|
+
// Password Hashing (CVE-2 Fix)
|
|
17
|
+
export { PasswordHasher, PasswordHashError, createPasswordHasher, } from './password-hasher.js';
|
|
18
|
+
// Credential Generation (CVE-3 Fix)
|
|
19
|
+
export { CredentialGenerator, CredentialGeneratorError, createCredentialGenerator, generateCredentials, } from './credential-generator.js';
|
|
20
|
+
// Safe Command Execution (HIGH-1 Fix)
|
|
21
|
+
export { SafeExecutor, SafeExecutorError, createDevelopmentExecutor, createReadOnlyExecutor, } from './safe-executor.js';
|
|
22
|
+
// Path Validation (HIGH-2 Fix)
|
|
23
|
+
export { PathValidator, PathValidatorError, createProjectPathValidator, createFullProjectPathValidator, } from './path-validator.js';
|
|
24
|
+
// Input Validation
|
|
25
|
+
export { InputValidator, sanitizeString, sanitizeHtml, sanitizePath,
|
|
26
|
+
// Base schemas
|
|
27
|
+
SafeStringSchema, IdentifierSchema, FilenameSchema, EmailSchema, PasswordSchema, UUIDSchema, HttpsUrlSchema, UrlSchema, SemverSchema, PortSchema, IPv4Schema, IPSchema,
|
|
28
|
+
// Auth schemas
|
|
29
|
+
UserRoleSchema, PermissionSchema, LoginRequestSchema, CreateUserSchema, CreateApiKeySchema,
|
|
30
|
+
// Agent & Task schemas
|
|
31
|
+
AgentTypeSchema, SpawnAgentSchema, TaskInputSchema,
|
|
32
|
+
// Command & Path schemas
|
|
33
|
+
CommandArgumentSchema, PathSchema,
|
|
34
|
+
// Config schemas
|
|
35
|
+
SecurityConfigSchema, ExecutorConfigSchema,
|
|
36
|
+
// Utilities
|
|
37
|
+
PATTERNS, LIMITS, z, } from './input-validator.js';
|
|
38
|
+
// Token Generation
|
|
39
|
+
export { TokenGenerator, TokenGeneratorError, createTokenGenerator, getDefaultGenerator, quickGenerate, } from './token-generator.js';
|
|
40
|
+
// ============================================================================
|
|
41
|
+
// Convenience Factory Functions
|
|
42
|
+
// ============================================================================
|
|
43
|
+
import { PasswordHasher } from './password-hasher.js';
|
|
44
|
+
import { CredentialGenerator } from './credential-generator.js';
|
|
45
|
+
import { SafeExecutor } from './safe-executor.js';
|
|
46
|
+
import { PathValidator } from './path-validator.js';
|
|
47
|
+
import { TokenGenerator } from './token-generator.js';
|
|
48
|
+
/**
|
|
49
|
+
* Creates a complete security module with all components configured.
|
|
50
|
+
*
|
|
51
|
+
* @param config - Module configuration
|
|
52
|
+
* @returns Complete security module
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* const security = createSecurityModule({
|
|
57
|
+
* projectRoot: '/workspaces/project',
|
|
58
|
+
* hmacSecret: process.env.HMAC_SECRET!,
|
|
59
|
+
* });
|
|
60
|
+
*
|
|
61
|
+
* // Hash password
|
|
62
|
+
* const hash = await security.passwordHasher.hash('password');
|
|
63
|
+
*
|
|
64
|
+
* // Validate path
|
|
65
|
+
* const result = await security.pathValidator.validate('/workspaces/project/src/file.ts');
|
|
66
|
+
*
|
|
67
|
+
* // Execute command safely
|
|
68
|
+
* const output = await security.safeExecutor.execute('git', ['status']);
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export function createSecurityModule(config) {
|
|
72
|
+
return {
|
|
73
|
+
passwordHasher: new PasswordHasher({
|
|
74
|
+
rounds: config.bcryptRounds ?? 12,
|
|
75
|
+
}),
|
|
76
|
+
credentialGenerator: new CredentialGenerator(),
|
|
77
|
+
safeExecutor: new SafeExecutor({
|
|
78
|
+
allowedCommands: config.allowedCommands ?? ['git', 'npm', 'npx', 'node'],
|
|
79
|
+
}),
|
|
80
|
+
pathValidator: new PathValidator({
|
|
81
|
+
allowedPrefixes: [config.projectRoot],
|
|
82
|
+
allowHidden: true,
|
|
83
|
+
}),
|
|
84
|
+
tokenGenerator: new TokenGenerator({
|
|
85
|
+
hmacSecret: config.hmacSecret,
|
|
86
|
+
}),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
// ============================================================================
|
|
90
|
+
// Security Constants
|
|
91
|
+
// ============================================================================
|
|
92
|
+
/**
|
|
93
|
+
* Minimum recommended bcrypt rounds for production
|
|
94
|
+
*/
|
|
95
|
+
export const MIN_BCRYPT_ROUNDS = 12;
|
|
96
|
+
/**
|
|
97
|
+
* Maximum recommended bcrypt rounds (performance consideration)
|
|
98
|
+
*/
|
|
99
|
+
export const MAX_BCRYPT_ROUNDS = 14;
|
|
100
|
+
/**
|
|
101
|
+
* Minimum password length
|
|
102
|
+
*/
|
|
103
|
+
export const MIN_PASSWORD_LENGTH = 8;
|
|
104
|
+
/**
|
|
105
|
+
* Maximum password length (bcrypt limitation)
|
|
106
|
+
*/
|
|
107
|
+
export const MAX_PASSWORD_LENGTH = 72;
|
|
108
|
+
/**
|
|
109
|
+
* Default token expiration in seconds (1 hour)
|
|
110
|
+
*/
|
|
111
|
+
export const DEFAULT_TOKEN_EXPIRATION = 3600;
|
|
112
|
+
/**
|
|
113
|
+
* Default session expiration in seconds (24 hours)
|
|
114
|
+
*/
|
|
115
|
+
export const DEFAULT_SESSION_EXPIRATION = 86400;
|
|
116
|
+
// ============================================================================
|
|
117
|
+
// Security Audit Helper
|
|
118
|
+
// ============================================================================
|
|
119
|
+
/**
|
|
120
|
+
* Checks security configuration for common issues.
|
|
121
|
+
*
|
|
122
|
+
* @param config - Configuration to audit
|
|
123
|
+
* @returns Array of security warnings
|
|
124
|
+
*/
|
|
125
|
+
export function auditSecurityConfig(config) {
|
|
126
|
+
const warnings = [];
|
|
127
|
+
if (config.bcryptRounds && config.bcryptRounds < MIN_BCRYPT_ROUNDS) {
|
|
128
|
+
warnings.push(`bcryptRounds (${config.bcryptRounds}) below recommended minimum (${MIN_BCRYPT_ROUNDS})`);
|
|
129
|
+
}
|
|
130
|
+
if (config.hmacSecret && config.hmacSecret.length < 32) {
|
|
131
|
+
warnings.push('hmacSecret should be at least 32 characters');
|
|
132
|
+
}
|
|
133
|
+
if (!config.projectRoot) {
|
|
134
|
+
warnings.push('projectRoot not configured - path validation may be disabled');
|
|
135
|
+
}
|
|
136
|
+
if (config.allowedCommands && config.allowedCommands.length === 0) {
|
|
137
|
+
warnings.push('No commands allowed - executor will reject all commands');
|
|
138
|
+
}
|
|
139
|
+
return warnings;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Security module version
|
|
143
|
+
*/
|
|
144
|
+
export const SECURITY_MODULE_VERSION = '3.0.0-alpha.1';
|
|
145
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,+BAA+B;AAC/B,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,oBAAoB,GAGrB,MAAM,sBAAsB,CAAC;AAE9B,oCAAoC;AACpC,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EACzB,mBAAmB,GAIpB,MAAM,2BAA2B,CAAC;AAEnC,sCAAsC;AACtC,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,yBAAyB,EACzB,sBAAsB,GAIvB,MAAM,oBAAoB,CAAC;AAE5B,+BAA+B;AAC/B,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,0BAA0B,EAC1B,8BAA8B,GAG/B,MAAM,qBAAqB,CAAC;AAE7B,mBAAmB;AACnB,OAAO,EACL,cAAc,EACd,cAAc,EACd,YAAY,EACZ,YAAY;AACZ,eAAe;AACf,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,cAAc,EACd,UAAU,EACV,cAAc,EACd,SAAS,EACT,YAAY,EACZ,UAAU,EACV,UAAU,EACV,QAAQ;AACR,eAAe;AACf,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB;AAClB,uBAAuB;AACvB,eAAe,EACf,gBAAgB,EAChB,eAAe;AACf,yBAAyB;AACzB,qBAAqB,EACrB,UAAU;AACV,iBAAiB;AACjB,oBAAoB,EACpB,oBAAoB;AACpB,YAAY;AACZ,QAAQ,EACR,MAAM,EACN,CAAC,GACF,MAAM,sBAAsB,CAAC;AAE9B,mBAAmB;AACnB,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EACpB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AAG,EAAE,CAAC;AAEtC;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,CAAC;AAE7C;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,KAAK,CAAC;AAEhD,+EAA+E;AAC/E,wBAAwB;AACxB,+EAA+E;AAE/E;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAqC;IACvE,MAAM,QAAQ,GAAa,EAAE,CAAC;IAE9B,IAAI,MAAM,CAAC,YAAY,IAAI,MAAM,CAAC,YAAY,GAAG,iBAAiB,EAAE,CAAC;QACnE,QAAQ,CAAC,IAAI,CAAC,iBAAiB,MAAM,CAAC,YAAY,gCAAgC,iBAAiB,GAAG,CAAC,CAAC;IAC1G,CAAC;IAED,IAAI,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;QACvD,QAAQ,CAAC,IAAI,CAAC,6CAA6C,CAAC,CAAC;IAC/D,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QACxB,QAAQ,CAAC,IAAI,CAAC,8DAA8D,CAAC,CAAC;IAChF,CAAC;IAED,IAAI,MAAM,CAAC,eAAe,IAAI,MAAM,CAAC,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAClE,QAAQ,CAAC,IAAI,CAAC,yDAAyD,CAAC,CAAC;IAC3E,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,eAAe,CAAC"}
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Input Validator - Comprehensive Input Validation
|
|
3
|
+
*
|
|
4
|
+
* Provides Zod-based validation schemas for all security-critical inputs.
|
|
5
|
+
*
|
|
6
|
+
* Security Properties:
|
|
7
|
+
* - Type-safe validation
|
|
8
|
+
* - Custom error messages
|
|
9
|
+
* - Sanitization transforms
|
|
10
|
+
* - Reusable schemas
|
|
11
|
+
*
|
|
12
|
+
* @module v3/security/input-validator
|
|
13
|
+
*/
|
|
14
|
+
import { z } from 'zod';
|
|
15
|
+
/**
|
|
16
|
+
* Common validation patterns as reusable regex
|
|
17
|
+
*/
|
|
18
|
+
declare const PATTERNS: {
|
|
19
|
+
SAFE_IDENTIFIER: RegExp;
|
|
20
|
+
SAFE_FILENAME: RegExp;
|
|
21
|
+
SAFE_PATH_SEGMENT: RegExp;
|
|
22
|
+
NO_SHELL_CHARS: RegExp;
|
|
23
|
+
SEMVER: RegExp;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Validation limits
|
|
27
|
+
*/
|
|
28
|
+
declare const LIMITS: {
|
|
29
|
+
MIN_PASSWORD_LENGTH: number;
|
|
30
|
+
MAX_PASSWORD_LENGTH: number;
|
|
31
|
+
MAX_EMAIL_LENGTH: number;
|
|
32
|
+
MAX_IDENTIFIER_LENGTH: number;
|
|
33
|
+
MAX_PATH_LENGTH: number;
|
|
34
|
+
MAX_CONTENT_LENGTH: number;
|
|
35
|
+
MAX_ARRAY_LENGTH: number;
|
|
36
|
+
MAX_OBJECT_KEYS: number;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Safe string that cannot contain shell metacharacters
|
|
40
|
+
*/
|
|
41
|
+
export declare const SafeStringSchema: z.ZodString;
|
|
42
|
+
/**
|
|
43
|
+
* Safe identifier for IDs, names, etc.
|
|
44
|
+
*/
|
|
45
|
+
export declare const IdentifierSchema: z.ZodString;
|
|
46
|
+
/**
|
|
47
|
+
* Safe filename
|
|
48
|
+
*/
|
|
49
|
+
export declare const FilenameSchema: z.ZodString;
|
|
50
|
+
/**
|
|
51
|
+
* Email schema with length limit
|
|
52
|
+
*/
|
|
53
|
+
export declare const EmailSchema: z.ZodString;
|
|
54
|
+
/**
|
|
55
|
+
* Password schema with complexity requirements
|
|
56
|
+
*/
|
|
57
|
+
export declare const PasswordSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>, string, string>;
|
|
58
|
+
/**
|
|
59
|
+
* UUID schema
|
|
60
|
+
*/
|
|
61
|
+
export declare const UUIDSchema: z.ZodString;
|
|
62
|
+
/**
|
|
63
|
+
* URL schema with HTTPS enforcement
|
|
64
|
+
*/
|
|
65
|
+
export declare const HttpsUrlSchema: z.ZodEffects<z.ZodString, string, string>;
|
|
66
|
+
/**
|
|
67
|
+
* URL schema (allows HTTP for development)
|
|
68
|
+
*/
|
|
69
|
+
export declare const UrlSchema: z.ZodString;
|
|
70
|
+
/**
|
|
71
|
+
* Semantic version schema
|
|
72
|
+
*/
|
|
73
|
+
export declare const SemverSchema: z.ZodString;
|
|
74
|
+
/**
|
|
75
|
+
* Port number schema
|
|
76
|
+
*/
|
|
77
|
+
export declare const PortSchema: z.ZodNumber;
|
|
78
|
+
/**
|
|
79
|
+
* IP address schema (v4)
|
|
80
|
+
*/
|
|
81
|
+
export declare const IPv4Schema: z.ZodString;
|
|
82
|
+
/**
|
|
83
|
+
* IP address schema (v4 or v6)
|
|
84
|
+
*/
|
|
85
|
+
export declare const IPSchema: z.ZodString;
|
|
86
|
+
/**
|
|
87
|
+
* User role schema
|
|
88
|
+
*/
|
|
89
|
+
export declare const UserRoleSchema: z.ZodEnum<["admin", "operator", "developer", "viewer", "service"]>;
|
|
90
|
+
/**
|
|
91
|
+
* Permission schema
|
|
92
|
+
*/
|
|
93
|
+
export declare const PermissionSchema: z.ZodEnum<["swarm.create", "swarm.read", "swarm.update", "swarm.delete", "swarm.scale", "agent.spawn", "agent.read", "agent.terminate", "task.create", "task.read", "task.cancel", "metrics.read", "system.admin", "api.access"]>;
|
|
94
|
+
/**
|
|
95
|
+
* Login request schema
|
|
96
|
+
*/
|
|
97
|
+
export declare const LoginRequestSchema: z.ZodObject<{
|
|
98
|
+
email: z.ZodString;
|
|
99
|
+
password: z.ZodString;
|
|
100
|
+
mfaCode: z.ZodOptional<z.ZodString>;
|
|
101
|
+
}, "strip", z.ZodTypeAny, {
|
|
102
|
+
email: string;
|
|
103
|
+
password: string;
|
|
104
|
+
mfaCode?: string | undefined;
|
|
105
|
+
}, {
|
|
106
|
+
email: string;
|
|
107
|
+
password: string;
|
|
108
|
+
mfaCode?: string | undefined;
|
|
109
|
+
}>;
|
|
110
|
+
/**
|
|
111
|
+
* User creation schema
|
|
112
|
+
*/
|
|
113
|
+
export declare const CreateUserSchema: z.ZodObject<{
|
|
114
|
+
email: z.ZodString;
|
|
115
|
+
password: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>, string, string>;
|
|
116
|
+
role: z.ZodEnum<["admin", "operator", "developer", "viewer", "service"]>;
|
|
117
|
+
permissions: z.ZodOptional<z.ZodArray<z.ZodEnum<["swarm.create", "swarm.read", "swarm.update", "swarm.delete", "swarm.scale", "agent.spawn", "agent.read", "agent.terminate", "task.create", "task.read", "task.cancel", "metrics.read", "system.admin", "api.access"]>, "many">>;
|
|
118
|
+
isActive: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
119
|
+
}, "strip", z.ZodTypeAny, {
|
|
120
|
+
email: string;
|
|
121
|
+
password: string;
|
|
122
|
+
role: "admin" | "operator" | "developer" | "viewer" | "service";
|
|
123
|
+
isActive: boolean;
|
|
124
|
+
permissions?: ("swarm.create" | "swarm.read" | "swarm.update" | "swarm.delete" | "swarm.scale" | "agent.spawn" | "agent.read" | "agent.terminate" | "task.create" | "task.read" | "task.cancel" | "metrics.read" | "system.admin" | "api.access")[] | undefined;
|
|
125
|
+
}, {
|
|
126
|
+
email: string;
|
|
127
|
+
password: string;
|
|
128
|
+
role: "admin" | "operator" | "developer" | "viewer" | "service";
|
|
129
|
+
permissions?: ("swarm.create" | "swarm.read" | "swarm.update" | "swarm.delete" | "swarm.scale" | "agent.spawn" | "agent.read" | "agent.terminate" | "task.create" | "task.read" | "task.cancel" | "metrics.read" | "system.admin" | "api.access")[] | undefined;
|
|
130
|
+
isActive?: boolean | undefined;
|
|
131
|
+
}>;
|
|
132
|
+
/**
|
|
133
|
+
* API key creation schema
|
|
134
|
+
*/
|
|
135
|
+
export declare const CreateApiKeySchema: z.ZodObject<{
|
|
136
|
+
name: z.ZodString;
|
|
137
|
+
permissions: z.ZodOptional<z.ZodArray<z.ZodEnum<["swarm.create", "swarm.read", "swarm.update", "swarm.delete", "swarm.scale", "agent.spawn", "agent.read", "agent.terminate", "task.create", "task.read", "task.cancel", "metrics.read", "system.admin", "api.access"]>, "many">>;
|
|
138
|
+
expiresAt: z.ZodOptional<z.ZodDate>;
|
|
139
|
+
}, "strip", z.ZodTypeAny, {
|
|
140
|
+
name: string;
|
|
141
|
+
permissions?: ("swarm.create" | "swarm.read" | "swarm.update" | "swarm.delete" | "swarm.scale" | "agent.spawn" | "agent.read" | "agent.terminate" | "task.create" | "task.read" | "task.cancel" | "metrics.read" | "system.admin" | "api.access")[] | undefined;
|
|
142
|
+
expiresAt?: Date | undefined;
|
|
143
|
+
}, {
|
|
144
|
+
name: string;
|
|
145
|
+
permissions?: ("swarm.create" | "swarm.read" | "swarm.update" | "swarm.delete" | "swarm.scale" | "agent.spawn" | "agent.read" | "agent.terminate" | "task.create" | "task.read" | "task.cancel" | "metrics.read" | "system.admin" | "api.access")[] | undefined;
|
|
146
|
+
expiresAt?: Date | undefined;
|
|
147
|
+
}>;
|
|
148
|
+
/**
|
|
149
|
+
* Agent type schema
|
|
150
|
+
*/
|
|
151
|
+
export declare const AgentTypeSchema: z.ZodEnum<["coder", "reviewer", "tester", "planner", "researcher", "security-architect", "security-auditor", "memory-specialist", "swarm-specialist", "integration-architect", "performance-engineer", "core-architect", "test-architect", "queen-coordinator", "project-coordinator"]>;
|
|
152
|
+
/**
|
|
153
|
+
* Agent spawn request schema
|
|
154
|
+
*/
|
|
155
|
+
export declare const SpawnAgentSchema: z.ZodObject<{
|
|
156
|
+
type: z.ZodEnum<["coder", "reviewer", "tester", "planner", "researcher", "security-architect", "security-auditor", "memory-specialist", "swarm-specialist", "integration-architect", "performance-engineer", "core-architect", "test-architect", "queen-coordinator", "project-coordinator"]>;
|
|
157
|
+
id: z.ZodOptional<z.ZodString>;
|
|
158
|
+
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
159
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
160
|
+
}, "strip", z.ZodTypeAny, {
|
|
161
|
+
type: "coder" | "reviewer" | "tester" | "planner" | "researcher" | "security-architect" | "security-auditor" | "memory-specialist" | "swarm-specialist" | "integration-architect" | "performance-engineer" | "core-architect" | "test-architect" | "queen-coordinator" | "project-coordinator";
|
|
162
|
+
config?: Record<string, unknown> | undefined;
|
|
163
|
+
timeout?: number | undefined;
|
|
164
|
+
id?: string | undefined;
|
|
165
|
+
}, {
|
|
166
|
+
type: "coder" | "reviewer" | "tester" | "planner" | "researcher" | "security-architect" | "security-auditor" | "memory-specialist" | "swarm-specialist" | "integration-architect" | "performance-engineer" | "core-architect" | "test-architect" | "queen-coordinator" | "project-coordinator";
|
|
167
|
+
config?: Record<string, unknown> | undefined;
|
|
168
|
+
timeout?: number | undefined;
|
|
169
|
+
id?: string | undefined;
|
|
170
|
+
}>;
|
|
171
|
+
/**
|
|
172
|
+
* Task input schema
|
|
173
|
+
*/
|
|
174
|
+
export declare const TaskInputSchema: z.ZodObject<{
|
|
175
|
+
taskId: z.ZodString;
|
|
176
|
+
content: z.ZodString;
|
|
177
|
+
agentType: z.ZodEnum<["coder", "reviewer", "tester", "planner", "researcher", "security-architect", "security-auditor", "memory-specialist", "swarm-specialist", "integration-architect", "performance-engineer", "core-architect", "test-architect", "queen-coordinator", "project-coordinator"]>;
|
|
178
|
+
priority: z.ZodOptional<z.ZodEnum<["low", "medium", "high", "critical"]>>;
|
|
179
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
180
|
+
}, "strip", z.ZodTypeAny, {
|
|
181
|
+
taskId: string;
|
|
182
|
+
content: string;
|
|
183
|
+
agentType: "coder" | "reviewer" | "tester" | "planner" | "researcher" | "security-architect" | "security-auditor" | "memory-specialist" | "swarm-specialist" | "integration-architect" | "performance-engineer" | "core-architect" | "test-architect" | "queen-coordinator" | "project-coordinator";
|
|
184
|
+
priority?: "critical" | "high" | "medium" | "low" | undefined;
|
|
185
|
+
metadata?: Record<string, unknown> | undefined;
|
|
186
|
+
}, {
|
|
187
|
+
taskId: string;
|
|
188
|
+
content: string;
|
|
189
|
+
agentType: "coder" | "reviewer" | "tester" | "planner" | "researcher" | "security-architect" | "security-auditor" | "memory-specialist" | "swarm-specialist" | "integration-architect" | "performance-engineer" | "core-architect" | "test-architect" | "queen-coordinator" | "project-coordinator";
|
|
190
|
+
priority?: "critical" | "high" | "medium" | "low" | undefined;
|
|
191
|
+
metadata?: Record<string, unknown> | undefined;
|
|
192
|
+
}>;
|
|
193
|
+
/**
|
|
194
|
+
* Command argument schema
|
|
195
|
+
*/
|
|
196
|
+
export declare const CommandArgumentSchema: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
197
|
+
/**
|
|
198
|
+
* Path schema
|
|
199
|
+
*/
|
|
200
|
+
export declare const PathSchema: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
201
|
+
/**
|
|
202
|
+
* Security configuration schema
|
|
203
|
+
*/
|
|
204
|
+
export declare const SecurityConfigSchema: z.ZodObject<{
|
|
205
|
+
bcryptRounds: z.ZodDefault<z.ZodNumber>;
|
|
206
|
+
jwtExpiresIn: z.ZodDefault<z.ZodString>;
|
|
207
|
+
sessionTimeout: z.ZodDefault<z.ZodNumber>;
|
|
208
|
+
maxLoginAttempts: z.ZodDefault<z.ZodNumber>;
|
|
209
|
+
lockoutDuration: z.ZodDefault<z.ZodNumber>;
|
|
210
|
+
requireMFA: z.ZodDefault<z.ZodBoolean>;
|
|
211
|
+
}, "strip", z.ZodTypeAny, {
|
|
212
|
+
bcryptRounds: number;
|
|
213
|
+
jwtExpiresIn: string;
|
|
214
|
+
sessionTimeout: number;
|
|
215
|
+
maxLoginAttempts: number;
|
|
216
|
+
lockoutDuration: number;
|
|
217
|
+
requireMFA: boolean;
|
|
218
|
+
}, {
|
|
219
|
+
bcryptRounds?: number | undefined;
|
|
220
|
+
jwtExpiresIn?: string | undefined;
|
|
221
|
+
sessionTimeout?: number | undefined;
|
|
222
|
+
maxLoginAttempts?: number | undefined;
|
|
223
|
+
lockoutDuration?: number | undefined;
|
|
224
|
+
requireMFA?: boolean | undefined;
|
|
225
|
+
}>;
|
|
226
|
+
/**
|
|
227
|
+
* Executor configuration schema
|
|
228
|
+
*/
|
|
229
|
+
export declare const ExecutorConfigSchema: z.ZodObject<{
|
|
230
|
+
allowedCommands: z.ZodArray<z.ZodString, "many">;
|
|
231
|
+
blockedPatterns: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
232
|
+
timeout: z.ZodDefault<z.ZodNumber>;
|
|
233
|
+
maxBuffer: z.ZodDefault<z.ZodNumber>;
|
|
234
|
+
cwd: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
|
|
235
|
+
allowSudo: z.ZodDefault<z.ZodBoolean>;
|
|
236
|
+
}, "strip", z.ZodTypeAny, {
|
|
237
|
+
allowedCommands: string[];
|
|
238
|
+
timeout: number;
|
|
239
|
+
maxBuffer: number;
|
|
240
|
+
allowSudo: boolean;
|
|
241
|
+
blockedPatterns?: string[] | undefined;
|
|
242
|
+
cwd?: string | undefined;
|
|
243
|
+
}, {
|
|
244
|
+
allowedCommands: string[];
|
|
245
|
+
blockedPatterns?: string[] | undefined;
|
|
246
|
+
timeout?: number | undefined;
|
|
247
|
+
maxBuffer?: number | undefined;
|
|
248
|
+
cwd?: string | undefined;
|
|
249
|
+
allowSudo?: boolean | undefined;
|
|
250
|
+
}>;
|
|
251
|
+
/**
|
|
252
|
+
* Sanitizes a string by removing dangerous characters
|
|
253
|
+
*/
|
|
254
|
+
export declare function sanitizeString(input: string): string;
|
|
255
|
+
/**
|
|
256
|
+
* Sanitizes HTML entities
|
|
257
|
+
*/
|
|
258
|
+
export declare function sanitizeHtml(input: string): string;
|
|
259
|
+
/**
|
|
260
|
+
* Sanitizes a path by removing traversal patterns
|
|
261
|
+
*/
|
|
262
|
+
export declare function sanitizePath(input: string): string;
|
|
263
|
+
export declare class InputValidator {
|
|
264
|
+
/**
|
|
265
|
+
* Validates input against a schema
|
|
266
|
+
*/
|
|
267
|
+
static validate<T>(schema: z.ZodSchema<T>, input: unknown): T;
|
|
268
|
+
/**
|
|
269
|
+
* Safely validates input, returning result
|
|
270
|
+
*/
|
|
271
|
+
static safeParse<T>(schema: z.ZodSchema<T>, input: unknown): z.SafeParseReturnType<unknown, T>;
|
|
272
|
+
/**
|
|
273
|
+
* Validates email
|
|
274
|
+
*/
|
|
275
|
+
static validateEmail(email: string): string;
|
|
276
|
+
/**
|
|
277
|
+
* Validates password
|
|
278
|
+
*/
|
|
279
|
+
static validatePassword(password: string): string;
|
|
280
|
+
/**
|
|
281
|
+
* Validates identifier
|
|
282
|
+
*/
|
|
283
|
+
static validateIdentifier(id: string): string;
|
|
284
|
+
/**
|
|
285
|
+
* Validates path
|
|
286
|
+
*/
|
|
287
|
+
static validatePath(path: string): string;
|
|
288
|
+
/**
|
|
289
|
+
* Validates command argument
|
|
290
|
+
*/
|
|
291
|
+
static validateCommandArg(arg: string): string;
|
|
292
|
+
/**
|
|
293
|
+
* Validates login request
|
|
294
|
+
*/
|
|
295
|
+
static validateLoginRequest(data: unknown): z.infer<typeof LoginRequestSchema>;
|
|
296
|
+
/**
|
|
297
|
+
* Validates user creation request
|
|
298
|
+
*/
|
|
299
|
+
static validateCreateUser(data: unknown): z.infer<typeof CreateUserSchema>;
|
|
300
|
+
/**
|
|
301
|
+
* Validates task input
|
|
302
|
+
*/
|
|
303
|
+
static validateTaskInput(data: unknown): z.infer<typeof TaskInputSchema>;
|
|
304
|
+
}
|
|
305
|
+
export { z, PATTERNS, LIMITS, };
|
|
306
|
+
//# sourceMappingURL=input-validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-validator.d.ts","sourceRoot":"","sources":["../src/input-validator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA8BxB;;GAEG;AACH,QAAA,MAAM,QAAQ;;;;;;CAeb,CAAC;AAEF;;GAEG;AACH,QAAA,MAAM,MAAM;;;;;;;;;CASX,CAAC;AAMF;;GAEG;AACH,eAAO,MAAM,gBAAgB,aAG0C,CAAC;AAExE;;GAEG;AACH,eAAO,MAAM,gBAAgB,aAGkC,CAAC;AAEhE;;GAEG;AACH,eAAO,MAAM,cAAc,aAGgC,CAAC;AAE5D;;GAEG;AACH,eAAO,MAAM,WAAW,aAGR,CAAC;AAEjB;;GAEG;AACH,eAAO,MAAM,cAAc,uGAKsC,CAAC;AAElE;;GAEG;AACH,eAAO,MAAM,UAAU,aAAyC,CAAC;AAEjE;;GAEG;AACH,eAAO,MAAM,cAAc,2CAKxB,CAAC;AAEJ;;GAEG;AACH,eAAO,MAAM,SAAS,aACM,CAAC;AAE7B;;GAEG;AACH,eAAO,MAAM,YAAY,aACmC,CAAC;AAE7D;;GAEG;AACH,eAAO,MAAM,UAAU,aAGoB,CAAC;AAE5C;;GAEG;AACH,eAAO,MAAM,UAAU,aACkC,CAAC;AAE1D;;GAEG;AACH,eAAO,MAAM,QAAQ,aACmB,CAAC;AAMzC;;GAEG;AACH,eAAO,MAAM,cAAc,oEAMzB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,gBAAgB,mOAe3B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;EAI7B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;EAM3B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;EAI7B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