@riotprompt/riotprompt 0.0.20 → 1.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 (73) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/MIGRATION.md +235 -0
  3. package/README.md +2 -0
  4. package/SECURITY.md +132 -0
  5. package/dist/builder.js +6 -0
  6. package/dist/builder.js.map +1 -1
  7. package/dist/{cli.cjs → cli.js} +658 -216
  8. package/dist/context-manager.js +1 -1
  9. package/dist/conversation-logger.d.ts +17 -1
  10. package/dist/conversation-logger.js +21 -17
  11. package/dist/conversation-logger.js.map +1 -1
  12. package/dist/conversation.js +1 -1
  13. package/dist/error-handling.d.ts +52 -0
  14. package/dist/error-handling.js +132 -0
  15. package/dist/error-handling.js.map +1 -0
  16. package/dist/formatter.js +1 -1
  17. package/dist/iteration-strategy.js +1 -1
  18. package/dist/loader.js +60 -12
  19. package/dist/loader.js.map +1 -1
  20. package/dist/logger.d.ts +52 -0
  21. package/dist/logger.js +114 -14
  22. package/dist/logger.js.map +1 -1
  23. package/dist/logging-config.d.ts +84 -0
  24. package/dist/logging-config.js +116 -0
  25. package/dist/logging-config.js.map +1 -0
  26. package/dist/message-builder.js +1 -1
  27. package/dist/model-config.js +1 -1
  28. package/dist/override.js +10 -4
  29. package/dist/override.js.map +1 -1
  30. package/dist/recipes.js +6 -0
  31. package/dist/recipes.js.map +1 -1
  32. package/dist/reflection.js +1 -1
  33. package/dist/riotprompt.d.ts +9 -0
  34. package/dist/riotprompt.js +8 -0
  35. package/dist/riotprompt.js.map +1 -1
  36. package/dist/security/audit-logger.d.ts +61 -0
  37. package/dist/security/audit-logger.js +281 -0
  38. package/dist/security/audit-logger.js.map +1 -0
  39. package/dist/security/cli-security.d.ts +143 -0
  40. package/dist/security/cli-security.js +302 -0
  41. package/dist/security/cli-security.js.map +1 -0
  42. package/dist/security/defaults.d.ts +31 -0
  43. package/dist/security/defaults.js +72 -0
  44. package/dist/security/defaults.js.map +1 -0
  45. package/dist/security/events.d.ts +8 -0
  46. package/dist/security/index.d.ts +27 -0
  47. package/dist/security/index.js +22 -0
  48. package/dist/security/index.js.map +1 -0
  49. package/dist/security/path-guard.d.ts +161 -0
  50. package/dist/security/path-guard.js +327 -0
  51. package/dist/security/path-guard.js.map +1 -0
  52. package/dist/security/rate-limiter.d.ts +117 -0
  53. package/dist/security/rate-limiter.js +165 -0
  54. package/dist/security/rate-limiter.js.map +1 -0
  55. package/dist/security/serialization-schemas.d.ts +183 -0
  56. package/dist/security/serialization-schemas.js +174 -0
  57. package/dist/security/serialization-schemas.js.map +1 -0
  58. package/dist/security/timeout-guard.d.ts +123 -0
  59. package/dist/security/timeout-guard.js +223 -0
  60. package/dist/security/timeout-guard.js.map +1 -0
  61. package/dist/security/types.d.ts +86 -0
  62. package/dist/security/types.js +80 -0
  63. package/dist/security/types.js.map +1 -0
  64. package/dist/token-budget.js +1 -1
  65. package/dist/tools.js +1 -1
  66. package/dist/util/storage.js.map +1 -1
  67. package/guide/index.md +2 -0
  68. package/guide/integration.md +1109 -0
  69. package/guide/security.md +237 -0
  70. package/package.json +23 -17
  71. package/vite.config.cli.ts +9 -18
  72. package/dist/riotprompt.cjs +0 -6169
  73. package/dist/riotprompt.cjs.map +0 -1
@@ -0,0 +1,302 @@
1
+ import { z } from 'zod';
2
+ import { PathGuard } from './path-guard.js';
3
+ import { getAuditLogger } from './audit-logger.js';
4
+
5
+ function _define_property(obj, key, value) {
6
+ if (key in obj) {
7
+ Object.defineProperty(obj, key, {
8
+ value: value,
9
+ enumerable: true,
10
+ configurable: true,
11
+ writable: true
12
+ });
13
+ } else {
14
+ obj[key] = value;
15
+ }
16
+ return obj;
17
+ }
18
+ /**
19
+ * Default CLI security configuration
20
+ */ const DEFAULT_CLI_SECURITY = {
21
+ enabled: true,
22
+ paths: {
23
+ enabled: true,
24
+ allowAbsolute: false,
25
+ allowSymlinks: false,
26
+ denyPatterns: [
27
+ '\\.\\.',
28
+ '~',
29
+ '\\$\\{',
30
+ '\\$\\('
31
+ ]
32
+ },
33
+ allowedExtensions: [
34
+ '.md',
35
+ '.json',
36
+ '.xml',
37
+ '.yaml',
38
+ '.yml',
39
+ '.txt'
40
+ ],
41
+ maxStringLength: 10000,
42
+ allowNullBytes: false,
43
+ allowControlChars: false
44
+ };
45
+ /**
46
+ * CLIValidator provides security validation for CLI inputs.
47
+ *
48
+ * Features:
49
+ * - Path validation with traversal prevention
50
+ * - String sanitization
51
+ * - Extension filtering
52
+ * - Audit logging
53
+ *
54
+ * @example
55
+ * ```typescript
56
+ * const validator = new CLIValidator();
57
+ *
58
+ * // Validate a path argument
59
+ * const pathResult = validator.validatePath('../../../etc/passwd');
60
+ * if (!pathResult.valid) {
61
+ * console.error(pathResult.error);
62
+ * process.exit(1);
63
+ * }
64
+ *
65
+ * // Validate a string argument
66
+ * const stringResult = validator.validateString(userInput);
67
+ * ```
68
+ */ class CLIValidator {
69
+ /**
70
+ * Validate a path argument
71
+ *
72
+ * @param inputPath - The path to validate
73
+ * @param options - Additional validation options
74
+ * @returns Validation result
75
+ */ validatePath(inputPath, options = {}) {
76
+ if (!this.config.enabled) {
77
+ return {
78
+ valid: true,
79
+ normalizedPath: inputPath
80
+ };
81
+ }
82
+ // First, validate with PathGuard
83
+ const pathResult = this.pathGuard.validate(inputPath, options.operation || 'cli');
84
+ if (!pathResult.valid) {
85
+ return pathResult;
86
+ }
87
+ // Check extension if requested
88
+ if (options.checkExtension && this.config.allowedExtensions.length > 0) {
89
+ const ext = inputPath.toLowerCase().split('.').pop();
90
+ const hasAllowedExt = this.config.allowedExtensions.some((allowed)=>inputPath.toLowerCase().endsWith(allowed));
91
+ if (!hasAllowedExt) {
92
+ this.auditLogger.log({
93
+ type: 'path_traversal_blocked',
94
+ severity: 'warning',
95
+ message: `Invalid file extension: .${ext}`,
96
+ context: {
97
+ attemptedPath: inputPath
98
+ }
99
+ });
100
+ return {
101
+ valid: false,
102
+ error: `Invalid file extension. Allowed: ${this.config.allowedExtensions.join(', ')}`
103
+ };
104
+ }
105
+ }
106
+ return pathResult;
107
+ }
108
+ /**
109
+ * Validate a string argument
110
+ *
111
+ * @param input - The string to validate
112
+ * @returns Validation result with sanitized string
113
+ */ validateString(input) {
114
+ if (!this.config.enabled) {
115
+ return {
116
+ valid: true,
117
+ sanitized: input
118
+ };
119
+ }
120
+ // Check length
121
+ if (input.length > this.config.maxStringLength) {
122
+ return {
123
+ valid: false,
124
+ error: `String too long (max ${this.config.maxStringLength} characters)`,
125
+ violation: 'length'
126
+ };
127
+ }
128
+ // Check for null bytes
129
+ if (!this.config.allowNullBytes && input.includes('\0')) {
130
+ this.auditLogger.log({
131
+ type: 'path_validation_failed',
132
+ severity: 'warning',
133
+ message: 'Null byte detected in input'
134
+ });
135
+ return {
136
+ valid: false,
137
+ error: 'Input contains invalid characters (null byte)',
138
+ violation: 'null_byte'
139
+ };
140
+ }
141
+ // Check for control characters (except common whitespace)
142
+ // Note: null bytes are handled separately above
143
+ if (!this.config.allowControlChars) {
144
+ // eslint-disable-next-line no-control-regex
145
+ const controlCharRegex = /[\x01-\x08\x0B\x0C\x0E-\x1F\x7F]/;
146
+ if (controlCharRegex.test(input)) {
147
+ this.auditLogger.log({
148
+ type: 'path_validation_failed',
149
+ severity: 'warning',
150
+ message: 'Control character detected in input'
151
+ });
152
+ return {
153
+ valid: false,
154
+ error: 'Input contains invalid control characters',
155
+ violation: 'control_char'
156
+ };
157
+ }
158
+ }
159
+ return {
160
+ valid: true,
161
+ sanitized: input
162
+ };
163
+ }
164
+ /**
165
+ * Validate a numeric argument
166
+ *
167
+ * @param input - The number to validate
168
+ * @param options - Validation options
169
+ * @returns Validation result
170
+ */ validateNumber(input, options = {}) {
171
+ if (!this.config.enabled) {
172
+ return {
173
+ valid: true
174
+ };
175
+ }
176
+ // Check NaN
177
+ if (Number.isNaN(input)) {
178
+ if (!options.allowNaN) {
179
+ return {
180
+ valid: false,
181
+ error: 'Value cannot be NaN'
182
+ };
183
+ }
184
+ // If NaN is allowed, skip other checks since they don't apply
185
+ return {
186
+ valid: true
187
+ };
188
+ }
189
+ // Check Infinity (only for non-NaN values)
190
+ if (!options.allowInfinity && !Number.isFinite(input)) {
191
+ return {
192
+ valid: false,
193
+ error: 'Value cannot be infinite'
194
+ };
195
+ }
196
+ // Check integer
197
+ if (options.integer && !Number.isInteger(input)) {
198
+ return {
199
+ valid: false,
200
+ error: 'Value must be an integer'
201
+ };
202
+ }
203
+ // Check min
204
+ if (options.min !== undefined && input < options.min) {
205
+ return {
206
+ valid: false,
207
+ error: `Value must be at least ${options.min}`
208
+ };
209
+ }
210
+ // Check max
211
+ if (options.max !== undefined && input > options.max) {
212
+ return {
213
+ valid: false,
214
+ error: `Value must be at most ${options.max}`
215
+ };
216
+ }
217
+ return {
218
+ valid: true
219
+ };
220
+ }
221
+ /**
222
+ * Create a Zod schema for secure path validation
223
+ */ securePathSchema(options = {}) {
224
+ return z.string().refine((val)=>this.validatePath(val, options).valid, {
225
+ message: 'Invalid path'
226
+ });
227
+ }
228
+ /**
229
+ * Create a Zod schema for secure string validation
230
+ */ secureStringSchema() {
231
+ return z.string().refine((val)=>this.validateString(val).valid, {
232
+ message: 'Invalid string'
233
+ });
234
+ }
235
+ /**
236
+ * Create a Zod schema for secure number validation
237
+ */ secureNumberSchema(options = {}) {
238
+ return z.number().refine((val)=>this.validateNumber(val, options).valid, {
239
+ message: 'Invalid number'
240
+ });
241
+ }
242
+ /**
243
+ * Get the underlying PathGuard
244
+ */ getPathGuard() {
245
+ return this.pathGuard;
246
+ }
247
+ /**
248
+ * Add a base path for path validation
249
+ */ addBasePath(basePath) {
250
+ this.pathGuard.addBasePath(basePath);
251
+ }
252
+ constructor(config = {}){
253
+ _define_property(this, "config", void 0);
254
+ _define_property(this, "pathGuard", void 0);
255
+ _define_property(this, "auditLogger", void 0);
256
+ this.config = {
257
+ ...DEFAULT_CLI_SECURITY,
258
+ ...config,
259
+ paths: {
260
+ ...DEFAULT_CLI_SECURITY.paths,
261
+ ...config.paths
262
+ }
263
+ };
264
+ this.pathGuard = new PathGuard(this.config.paths);
265
+ this.auditLogger = getAuditLogger();
266
+ }
267
+ }
268
+ /**
269
+ * Create a CLI validator with RiotPrompt defaults
270
+ */ function createRiotPromptValidator(basePaths) {
271
+ const validator = new CLIValidator({
272
+ paths: {
273
+ basePaths: basePaths || [
274
+ process.cwd()
275
+ ]
276
+ }
277
+ });
278
+ return validator;
279
+ }
280
+ // Global instance
281
+ let globalCLIValidator = null;
282
+ /**
283
+ * Get the global CLI validator
284
+ */ function getCLIValidator() {
285
+ if (!globalCLIValidator) {
286
+ globalCLIValidator = new CLIValidator();
287
+ }
288
+ return globalCLIValidator;
289
+ }
290
+ /**
291
+ * Configure the global CLI validator
292
+ */ function configureCLIValidator(config) {
293
+ globalCLIValidator = new CLIValidator(config);
294
+ }
295
+ /**
296
+ * Reset the global CLI validator
297
+ */ function resetCLIValidator() {
298
+ globalCLIValidator = null;
299
+ }
300
+
301
+ export { CLIValidator, DEFAULT_CLI_SECURITY, configureCLIValidator, createRiotPromptValidator, getCLIValidator, resetCLIValidator };
302
+ //# sourceMappingURL=cli-security.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-security.js","sources":["../../src/security/cli-security.ts"],"sourcesContent":["/**\n * RiotPrompt - CLI Security\n *\n * Provides security validation for CLI inputs using the existing\n * security infrastructure.\n */\n\nimport { z } from 'zod';\nimport { PathGuard, type PathSecurityConfig } from './path-guard';\nimport { getAuditLogger, SecurityAuditLogger } from './audit-logger';\n\n/**\n * CLI Security configuration\n */\nexport interface CLISecurityConfig {\n /** Enable CLI security validation */\n enabled: boolean;\n /** Path security configuration */\n paths: Partial<PathSecurityConfig>;\n /** Allowed file extensions for input files */\n allowedExtensions: string[];\n /** Maximum string length for inputs */\n maxStringLength: number;\n /** Allow null bytes in strings */\n allowNullBytes: boolean;\n /** Allow control characters in strings */\n allowControlChars: boolean;\n}\n\n/**\n * Default CLI security configuration\n */\nexport const DEFAULT_CLI_SECURITY: CLISecurityConfig = {\n enabled: true,\n paths: {\n enabled: true,\n allowAbsolute: false,\n allowSymlinks: false,\n denyPatterns: [\n '\\\\.\\\\.', // Parent directory\n '~', // Home directory expansion\n '\\\\$\\\\{', // Variable expansion\n '\\\\$\\\\(', // Command substitution\n ],\n },\n allowedExtensions: ['.md', '.json', '.xml', '.yaml', '.yml', '.txt'],\n maxStringLength: 10000,\n allowNullBytes: false,\n allowControlChars: false,\n};\n\n/**\n * String validation result\n */\nexport interface StringValidationResult {\n valid: boolean;\n sanitized?: string;\n error?: string;\n violation?: string;\n}\n\n/**\n * CLIValidator provides security validation for CLI inputs.\n *\n * Features:\n * - Path validation with traversal prevention\n * - String sanitization\n * - Extension filtering\n * - Audit logging\n *\n * @example\n * ```typescript\n * const validator = new CLIValidator();\n *\n * // Validate a path argument\n * const pathResult = validator.validatePath('../../../etc/passwd');\n * if (!pathResult.valid) {\n * console.error(pathResult.error);\n * process.exit(1);\n * }\n *\n * // Validate a string argument\n * const stringResult = validator.validateString(userInput);\n * ```\n */\nexport class CLIValidator {\n private config: CLISecurityConfig;\n private pathGuard: PathGuard;\n private auditLogger: SecurityAuditLogger;\n\n constructor(config: Partial<CLISecurityConfig> = {}) {\n this.config = {\n ...DEFAULT_CLI_SECURITY,\n ...config,\n paths: { ...DEFAULT_CLI_SECURITY.paths, ...config.paths },\n };\n this.pathGuard = new PathGuard(this.config.paths);\n this.auditLogger = getAuditLogger();\n }\n\n /**\n * Validate a path argument\n *\n * @param inputPath - The path to validate\n * @param options - Additional validation options\n * @returns Validation result\n */\n validatePath(inputPath: string, options: {\n checkExtension?: boolean;\n operation?: string;\n } = {}): { valid: boolean; normalizedPath?: string; error?: string } {\n if (!this.config.enabled) {\n return { valid: true, normalizedPath: inputPath };\n }\n\n // First, validate with PathGuard\n const pathResult = this.pathGuard.validate(inputPath, options.operation || 'cli');\n if (!pathResult.valid) {\n return pathResult;\n }\n\n // Check extension if requested\n if (options.checkExtension && this.config.allowedExtensions.length > 0) {\n const ext = inputPath.toLowerCase().split('.').pop();\n const hasAllowedExt = this.config.allowedExtensions.some(\n allowed => inputPath.toLowerCase().endsWith(allowed)\n );\n\n if (!hasAllowedExt) {\n this.auditLogger.log({\n type: 'path_traversal_blocked',\n severity: 'warning',\n message: `Invalid file extension: .${ext}`,\n context: { attemptedPath: inputPath },\n });\n return {\n valid: false,\n error: `Invalid file extension. Allowed: ${this.config.allowedExtensions.join(', ')}`,\n };\n }\n }\n\n return pathResult;\n }\n\n /**\n * Validate a string argument\n *\n * @param input - The string to validate\n * @returns Validation result with sanitized string\n */\n validateString(input: string): StringValidationResult {\n if (!this.config.enabled) {\n return { valid: true, sanitized: input };\n }\n\n // Check length\n if (input.length > this.config.maxStringLength) {\n return {\n valid: false,\n error: `String too long (max ${this.config.maxStringLength} characters)`,\n violation: 'length',\n };\n }\n\n // Check for null bytes\n if (!this.config.allowNullBytes && input.includes('\\0')) {\n this.auditLogger.log({\n type: 'path_validation_failed',\n severity: 'warning',\n message: 'Null byte detected in input',\n });\n return {\n valid: false,\n error: 'Input contains invalid characters (null byte)',\n violation: 'null_byte',\n };\n }\n\n // Check for control characters (except common whitespace)\n // Note: null bytes are handled separately above\n if (!this.config.allowControlChars) {\n // eslint-disable-next-line no-control-regex\n const controlCharRegex = /[\\x01-\\x08\\x0B\\x0C\\x0E-\\x1F\\x7F]/;\n if (controlCharRegex.test(input)) {\n this.auditLogger.log({\n type: 'path_validation_failed',\n severity: 'warning',\n message: 'Control character detected in input',\n });\n return {\n valid: false,\n error: 'Input contains invalid control characters',\n violation: 'control_char',\n };\n }\n }\n\n return { valid: true, sanitized: input };\n }\n\n /**\n * Validate a numeric argument\n *\n * @param input - The number to validate\n * @param options - Validation options\n * @returns Validation result\n */\n validateNumber(input: number, options: {\n min?: number;\n max?: number;\n integer?: boolean;\n allowNaN?: boolean;\n allowInfinity?: boolean;\n } = {}): { valid: boolean; error?: string } {\n if (!this.config.enabled) {\n return { valid: true };\n }\n\n // Check NaN\n if (Number.isNaN(input)) {\n if (!options.allowNaN) {\n return { valid: false, error: 'Value cannot be NaN' };\n }\n // If NaN is allowed, skip other checks since they don't apply\n return { valid: true };\n }\n\n // Check Infinity (only for non-NaN values)\n if (!options.allowInfinity && !Number.isFinite(input)) {\n return { valid: false, error: 'Value cannot be infinite' };\n }\n\n // Check integer\n if (options.integer && !Number.isInteger(input)) {\n return { valid: false, error: 'Value must be an integer' };\n }\n\n // Check min\n if (options.min !== undefined && input < options.min) {\n return { valid: false, error: `Value must be at least ${options.min}` };\n }\n\n // Check max\n if (options.max !== undefined && input > options.max) {\n return { valid: false, error: `Value must be at most ${options.max}` };\n }\n\n return { valid: true };\n }\n\n /**\n * Create a Zod schema for secure path validation\n */\n securePathSchema(options: {\n checkExtension?: boolean;\n } = {}) {\n return z.string().refine(\n (val: string) => this.validatePath(val, options).valid,\n { message: 'Invalid path' }\n );\n }\n\n /**\n * Create a Zod schema for secure string validation\n */\n secureStringSchema() {\n return z.string().refine(\n (val: string) => this.validateString(val).valid,\n { message: 'Invalid string' }\n );\n }\n\n /**\n * Create a Zod schema for secure number validation\n */\n secureNumberSchema(options: {\n min?: number;\n max?: number;\n integer?: boolean;\n } = {}) {\n return z.number().refine(\n (val: number) => this.validateNumber(val, options).valid,\n { message: 'Invalid number' }\n );\n }\n\n /**\n * Get the underlying PathGuard\n */\n getPathGuard(): PathGuard {\n return this.pathGuard;\n }\n\n /**\n * Add a base path for path validation\n */\n addBasePath(basePath: string): void {\n this.pathGuard.addBasePath(basePath);\n }\n}\n\n/**\n * Create a CLI validator with RiotPrompt defaults\n */\nexport function createRiotPromptValidator(basePaths?: string[]): CLIValidator {\n const validator = new CLIValidator({\n paths: {\n basePaths: basePaths || [process.cwd()],\n },\n });\n return validator;\n}\n\n// Global instance\nlet globalCLIValidator: CLIValidator | null = null;\n\n/**\n * Get the global CLI validator\n */\nexport function getCLIValidator(): CLIValidator {\n if (!globalCLIValidator) {\n globalCLIValidator = new CLIValidator();\n }\n return globalCLIValidator;\n}\n\n/**\n * Configure the global CLI validator\n */\nexport function configureCLIValidator(config: Partial<CLISecurityConfig>): void {\n globalCLIValidator = new CLIValidator(config);\n}\n\n/**\n * Reset the global CLI validator\n */\nexport function resetCLIValidator(): void {\n globalCLIValidator = null;\n}\n\n"],"names":["DEFAULT_CLI_SECURITY","enabled","paths","allowAbsolute","allowSymlinks","denyPatterns","allowedExtensions","maxStringLength","allowNullBytes","allowControlChars","CLIValidator","validatePath","inputPath","options","config","valid","normalizedPath","pathResult","pathGuard","validate","operation","checkExtension","length","ext","toLowerCase","split","pop","hasAllowedExt","some","allowed","endsWith","auditLogger","log","type","severity","message","context","attemptedPath","error","join","validateString","input","sanitized","violation","includes","controlCharRegex","test","validateNumber","Number","isNaN","allowNaN","allowInfinity","isFinite","integer","isInteger","min","undefined","max","securePathSchema","z","string","refine","val","secureStringSchema","secureNumberSchema","number","getPathGuard","addBasePath","basePath","PathGuard","getAuditLogger","createRiotPromptValidator","basePaths","validator","process","cwd","globalCLIValidator","getCLIValidator","configureCLIValidator","resetCLIValidator"],"mappings":";;;;;;;;;;;;;;;;;AA6BA;;UAGaA,oBAAAA,GAA0C;IACnDC,OAAAA,EAAS,IAAA;IACTC,KAAAA,EAAO;QACHD,OAAAA,EAAS,IAAA;QACTE,aAAAA,EAAe,KAAA;QACfC,aAAAA,EAAe,KAAA;QACfC,YAAAA,EAAc;AACV,YAAA,QAAA;AACA,YAAA,GAAA;AACA,YAAA,QAAA;AACA,YAAA;AACH;AACL,KAAA;IACAC,iBAAAA,EAAmB;AAAC,QAAA,KAAA;AAAO,QAAA,OAAA;AAAS,QAAA,MAAA;AAAQ,QAAA,OAAA;AAAS,QAAA,MAAA;AAAQ,QAAA;AAAO,KAAA;IACpEC,eAAAA,EAAiB,KAAA;IACjBC,cAAAA,EAAgB,KAAA;IAChBC,iBAAAA,EAAmB;AACvB;AAYA;;;;;;;;;;;;;;;;;;;;;;;AAuBC,IACM,MAAMC,YAAAA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AAEA;;AAEC,IACM,SAASiE,iBAAAA,GAAAA;IACZH,kBAAAA,GAAqB,IAAA;AACzB;;;;"}
@@ -0,0 +1,31 @@
1
+ import { SecurityConfig, PathSecurityConfig, ToolSecurityConfig, SecretSecurityConfig, LogSecurityConfig, TimeoutConfig } from './types';
2
+ /**
3
+ * Deep partial type for recursive partial objects
4
+ */
5
+ export type DeepPartial<T> = {
6
+ [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
7
+ };
8
+ /**
9
+ * User configuration with all fields optional (including nested)
10
+ */
11
+ export type UserSecurityConfig = {
12
+ paths?: Partial<PathSecurityConfig>;
13
+ tools?: Partial<ToolSecurityConfig>;
14
+ secrets?: Partial<SecretSecurityConfig>;
15
+ logging?: Partial<LogSecurityConfig>;
16
+ timeouts?: Partial<TimeoutConfig>;
17
+ };
18
+ /**
19
+ * Secure default configuration
20
+ * All security features enabled by default
21
+ */
22
+ export declare const SECURE_DEFAULTS: SecurityConfig;
23
+ /**
24
+ * Permissive configuration for development/testing
25
+ * Security features disabled for convenience
26
+ */
27
+ export declare const PERMISSIVE_DEFAULTS: SecurityConfig;
28
+ /**
29
+ * Merge user configuration with defaults
30
+ */
31
+ export declare function mergeSecurityConfig(userConfig: UserSecurityConfig | undefined, defaults?: SecurityConfig): SecurityConfig;
@@ -0,0 +1,72 @@
1
+ import { SecurityConfigSchema } from './types.js';
2
+
3
+ /**
4
+ * Secure default configuration
5
+ * All security features enabled by default
6
+ */ const SECURE_DEFAULTS = SecurityConfigSchema.parse({});
7
+ /**
8
+ * Permissive configuration for development/testing
9
+ * Security features disabled for convenience
10
+ */ const PERMISSIVE_DEFAULTS = {
11
+ paths: {
12
+ enabled: false,
13
+ basePaths: [],
14
+ allowAbsolute: true,
15
+ allowSymlinks: true,
16
+ denyPatterns: []
17
+ },
18
+ tools: {
19
+ enabled: false,
20
+ validateParams: false,
21
+ sandboxExecution: false,
22
+ maxExecutionTime: 0,
23
+ maxConcurrentCalls: 0,
24
+ deniedTools: []
25
+ },
26
+ secrets: {
27
+ enabled: false,
28
+ redactInLogs: false,
29
+ redactInErrors: false,
30
+ patterns: [],
31
+ customPatterns: []
32
+ },
33
+ logging: {
34
+ enabled: false,
35
+ auditSecurityEvents: false,
36
+ sanitizeStackTraces: false,
37
+ maxContentLength: Number.MAX_SAFE_INTEGER
38
+ },
39
+ timeouts: {
40
+ enabled: false,
41
+ defaultTimeout: 0,
42
+ llmTimeout: 0,
43
+ toolTimeout: 0,
44
+ fileTimeout: 0
45
+ }
46
+ };
47
+ /**
48
+ * Merge user configuration with defaults
49
+ */ function mergeSecurityConfig(userConfig, defaults = SECURE_DEFAULTS) {
50
+ if (!userConfig) return defaults;
51
+ // Deep merge each section
52
+ const merged = {
53
+ paths: mergeSection(defaults.paths, userConfig.paths),
54
+ tools: mergeSection(defaults.tools, userConfig.tools),
55
+ secrets: mergeSection(defaults.secrets, userConfig.secrets),
56
+ logging: mergeSection(defaults.logging, userConfig.logging),
57
+ timeouts: mergeSection(defaults.timeouts, userConfig.timeouts)
58
+ };
59
+ return merged;
60
+ }
61
+ /**
62
+ * Helper to merge a single section
63
+ */ function mergeSection(defaultSection, userSection) {
64
+ if (!userSection) return defaultSection;
65
+ return {
66
+ ...defaultSection,
67
+ ...userSection
68
+ };
69
+ }
70
+
71
+ export { PERMISSIVE_DEFAULTS, SECURE_DEFAULTS, mergeSecurityConfig };
72
+ //# sourceMappingURL=defaults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.js","sources":["../../src/security/defaults.ts"],"sourcesContent":["import { \n SecurityConfig, \n SecurityConfigSchema,\n PathSecurityConfig,\n ToolSecurityConfig,\n SecretSecurityConfig,\n LogSecurityConfig,\n TimeoutConfig,\n} from './types';\n\n/**\n * Deep partial type for recursive partial objects\n */\nexport type DeepPartial<T> = {\n [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];\n};\n\n/**\n * User configuration with all fields optional (including nested)\n */\nexport type UserSecurityConfig = {\n paths?: Partial<PathSecurityConfig>;\n tools?: Partial<ToolSecurityConfig>;\n secrets?: Partial<SecretSecurityConfig>;\n logging?: Partial<LogSecurityConfig>;\n timeouts?: Partial<TimeoutConfig>;\n};\n\n/**\n * Secure default configuration\n * All security features enabled by default\n */\nexport const SECURE_DEFAULTS: SecurityConfig = SecurityConfigSchema.parse({});\n\n/**\n * Permissive configuration for development/testing\n * Security features disabled for convenience\n */\nexport const PERMISSIVE_DEFAULTS: SecurityConfig = {\n paths: { \n enabled: false, \n basePaths: [], \n allowAbsolute: true, \n allowSymlinks: true, \n denyPatterns: [] \n },\n tools: { \n enabled: false, \n validateParams: false, \n sandboxExecution: false, \n maxExecutionTime: 0, \n maxConcurrentCalls: 0, \n deniedTools: [] \n },\n secrets: { \n enabled: false, \n redactInLogs: false, \n redactInErrors: false, \n patterns: [], \n customPatterns: [] \n },\n logging: { \n enabled: false, \n auditSecurityEvents: false, \n sanitizeStackTraces: false, \n maxContentLength: Number.MAX_SAFE_INTEGER \n },\n timeouts: { \n enabled: false, \n defaultTimeout: 0, \n llmTimeout: 0, \n toolTimeout: 0, \n fileTimeout: 0 \n },\n};\n\n/**\n * Merge user configuration with defaults\n */\nexport function mergeSecurityConfig(\n userConfig: UserSecurityConfig | undefined,\n defaults: SecurityConfig = SECURE_DEFAULTS\n): SecurityConfig {\n if (!userConfig) return defaults;\n \n // Deep merge each section\n const merged: SecurityConfig = {\n paths: mergeSection(defaults.paths, userConfig.paths),\n tools: mergeSection(defaults.tools, userConfig.tools),\n secrets: mergeSection(defaults.secrets, userConfig.secrets),\n logging: mergeSection(defaults.logging, userConfig.logging),\n timeouts: mergeSection(defaults.timeouts, userConfig.timeouts),\n };\n \n return merged;\n}\n\n/**\n * Helper to merge a single section\n */\nfunction mergeSection<T extends Record<string, unknown>>(\n defaultSection: T,\n userSection: Partial<T> | undefined\n): T {\n if (!userSection) return defaultSection;\n return { ...defaultSection, ...userSection };\n}\n"],"names":["SECURE_DEFAULTS","SecurityConfigSchema","parse","PERMISSIVE_DEFAULTS","paths","enabled","basePaths","allowAbsolute","allowSymlinks","denyPatterns","tools","validateParams","sandboxExecution","maxExecutionTime","maxConcurrentCalls","deniedTools","secrets","redactInLogs","redactInErrors","patterns","customPatterns","logging","auditSecurityEvents","sanitizeStackTraces","maxContentLength","Number","MAX_SAFE_INTEGER","timeouts","defaultTimeout","llmTimeout","toolTimeout","fileTimeout","mergeSecurityConfig","userConfig","defaults","merged","mergeSection","defaultSection","userSection"],"mappings":";;AA4BA;;;AAGC,IACM,MAAMA,eAAAA,GAAkCC,qBAAqBC,KAAK,CAAC,EAAC;AAE3E;;;UAIaC,mBAAAA,GAAsC;IAC/CC,KAAAA,EAAO;QACHC,OAAAA,EAAS,KAAA;AACTC,QAAAA,SAAAA,EAAW,EAAE;QACbC,aAAAA,EAAe,IAAA;QACfC,aAAAA,EAAe,IAAA;AACfC,QAAAA,YAAAA,EAAc;AAClB,KAAA;IACAC,KAAAA,EAAO;QACHL,OAAAA,EAAS,KAAA;QACTM,cAAAA,EAAgB,KAAA;QAChBC,gBAAAA,EAAkB,KAAA;QAClBC,gBAAAA,EAAkB,CAAA;QAClBC,kBAAAA,EAAoB,CAAA;AACpBC,QAAAA,WAAAA,EAAa;AACjB,KAAA;IACAC,OAAAA,EAAS;QACLX,OAAAA,EAAS,KAAA;QACTY,YAAAA,EAAc,KAAA;QACdC,cAAAA,EAAgB,KAAA;AAChBC,QAAAA,QAAAA,EAAU,EAAE;AACZC,QAAAA,cAAAA,EAAgB;AACpB,KAAA;IACAC,OAAAA,EAAS;QACLhB,OAAAA,EAAS,KAAA;QACTiB,mBAAAA,EAAqB,KAAA;QACrBC,mBAAAA,EAAqB,KAAA;AACrBC,QAAAA,gBAAAA,EAAkBC,OAAOC;AAC7B,KAAA;IACAC,QAAAA,EAAU;QACNtB,OAAAA,EAAS,KAAA;QACTuB,cAAAA,EAAgB,CAAA;QAChBC,UAAAA,EAAY,CAAA;QACZC,WAAAA,EAAa,CAAA;QACbC,WAAAA,EAAa;AACjB;AACJ;AAEA;;AAEC,IACM,SAASC,mBAAAA,CACZC,UAA0C,EAC1CC,WAA2BlC,eAAe,EAAA;IAE1C,IAAI,CAACiC,YAAY,OAAOC,QAAAA;;AAGxB,IAAA,MAAMC,MAAAA,GAAyB;AAC3B/B,QAAAA,KAAAA,EAAOgC,YAAAA,CAAaF,QAAAA,CAAS9B,KAAK,EAAE6B,WAAW7B,KAAK,CAAA;AACpDM,QAAAA,KAAAA,EAAO0B,YAAAA,CAAaF,QAAAA,CAASxB,KAAK,EAAEuB,WAAWvB,KAAK,CAAA;AACpDM,QAAAA,OAAAA,EAASoB,YAAAA,CAAaF,QAAAA,CAASlB,OAAO,EAAEiB,WAAWjB,OAAO,CAAA;AAC1DK,QAAAA,OAAAA,EAASe,YAAAA,CAAaF,QAAAA,CAASb,OAAO,EAAEY,WAAWZ,OAAO,CAAA;AAC1DM,QAAAA,QAAAA,EAAUS,YAAAA,CAAaF,QAAAA,CAASP,QAAQ,EAAEM,WAAWN,QAAQ;AACjE,KAAA;IAEA,OAAOQ,MAAAA;AACX;AAEA;;AAEC,IACD,SAASC,YAAAA,CACLC,cAAiB,EACjBC,WAAmC,EAAA;IAEnC,IAAI,CAACA,aAAa,OAAOD,cAAAA;IACzB,OAAO;AAAE,QAAA,GAAGA,cAAc;AAAE,QAAA,GAAGC;AAAY,KAAA;AAC/C;;;;"}
@@ -0,0 +1,8 @@
1
+ export type SecurityEventType = 'path_validation_failed' | 'path_traversal_blocked' | 'tool_validation_failed' | 'tool_execution_blocked' | 'tool_timeout' | 'secret_redacted' | 'api_key_used' | 'deserialization_failed' | 'regex_timeout' | 'regex_blocked' | 'input_validation_failed' | 'request_timeout' | 'rate_limit_exceeded';
2
+ export interface SecurityEvent {
3
+ type: SecurityEventType;
4
+ timestamp: Date;
5
+ severity: 'info' | 'warning' | 'error' | 'critical';
6
+ message: string;
7
+ context?: Record<string, unknown>;
8
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Security module for RiotPrompt
3
+ *
4
+ * Provides security configuration, types, and utilities for:
5
+ * - Path validation and traversal prevention
6
+ * - Tool execution sandboxing
7
+ * - Secret redaction
8
+ * - Secure logging
9
+ * - Request timeouts
10
+ *
11
+ * @packageDocumentation
12
+ */
13
+ export { PathSecurityConfigSchema, ToolSecurityConfigSchema, SecretSecurityConfigSchema, LogSecurityConfigSchema, TimeoutConfigSchema, SecurityConfigSchema, } from './types';
14
+ export type { PathSecurityConfig, ToolSecurityConfig, SecretSecurityConfig, LogSecurityConfig, TimeoutConfig, SecurityConfig, } from './types';
15
+ export { SECURE_DEFAULTS, PERMISSIVE_DEFAULTS, mergeSecurityConfig, } from './defaults';
16
+ export type { SecurityEventType, SecurityEvent, } from './events';
17
+ export { SecurityAuditLogger, getAuditLogger, configureAuditLogger, resetAuditLogger, } from './audit-logger';
18
+ export type { AuditLoggerConfig, } from './audit-logger';
19
+ export { PathGuard, getPathGuard, configurePathGuard, resetPathGuard, sanitizeGlobPattern, isGlobSafe, validateGlobPattern, } from './path-guard';
20
+ export type { PathValidationResult, GlobValidationResult, } from './path-guard';
21
+ export { CLIValidator, getCLIValidator, configureCLIValidator, resetCLIValidator, createRiotPromptValidator, DEFAULT_CLI_SECURITY, } from './cli-security';
22
+ export type { CLISecurityConfig, StringValidationResult, } from './cli-security';
23
+ export { TimeoutGuard, TimeoutError, isTimeoutError, getTimeoutGuard, configureTimeoutGuard, resetTimeoutGuard, } from './timeout-guard';
24
+ export { SCHEMA_VERSION, SERIALIZATION_LIMITS, ToolCallSchema, ConversationMessageSchema, ConversationMetadataSchema, SerializedConversationSchema, SerializedPromptSchema, LoggedConversationSchema, validateConversation, validateLoggedConversation, safeJsonParse, } from './serialization-schemas';
25
+ export type { SerializedConversation, SerializedPrompt, LoggedConversation as SerializedLoggedConversation, } from './serialization-schemas';
26
+ export { NoOpRateLimiter, MemoryRateLimiter, createRateLimiter, createNoOpRateLimiter, getRateLimiter, configureRateLimiter, resetRateLimiter, } from './rate-limiter';
27
+ export type { RateLimiter, RateLimiterConfig, } from './rate-limiter';
@@ -0,0 +1,22 @@
1
+ export { LogSecurityConfigSchema, PathSecurityConfigSchema, SecretSecurityConfigSchema, SecurityConfigSchema, TimeoutConfigSchema, ToolSecurityConfigSchema } from './types.js';
2
+ export { PERMISSIVE_DEFAULTS, SECURE_DEFAULTS, mergeSecurityConfig } from './defaults.js';
3
+ export { SecurityAuditLogger, configureAuditLogger, getAuditLogger, resetAuditLogger } from './audit-logger.js';
4
+ export { PathGuard, configurePathGuard, getPathGuard, isGlobSafe, resetPathGuard, sanitizeGlobPattern, validateGlobPattern } from './path-guard.js';
5
+ export { CLIValidator, DEFAULT_CLI_SECURITY, configureCLIValidator, createRiotPromptValidator, getCLIValidator, resetCLIValidator } from './cli-security.js';
6
+ export { TimeoutError, TimeoutGuard, configureTimeoutGuard, getTimeoutGuard, isTimeoutError, resetTimeoutGuard } from './timeout-guard.js';
7
+ export { ConversationMessageSchema, ConversationMetadataSchema, LoggedConversationSchema, SCHEMA_VERSION, SERIALIZATION_LIMITS, SerializedConversationSchema, SerializedPromptSchema, ToolCallSchema, safeJsonParse, validateConversation, validateLoggedConversation } from './serialization-schemas.js';
8
+ export { MemoryRateLimiter, NoOpRateLimiter, configureRateLimiter, createNoOpRateLimiter, createRateLimiter, getRateLimiter, resetRateLimiter } from './rate-limiter.js';
9
+
10
+ /**
11
+ * Security module for RiotPrompt
12
+ *
13
+ * Provides security configuration, types, and utilities for:
14
+ * - Path validation and traversal prevention
15
+ * - Tool execution sandboxing
16
+ * - Secret redaction
17
+ * - Secure logging
18
+ * - Request timeouts
19
+ *
20
+ * @packageDocumentation
21
+ */ // Types and schemas
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/security/index.ts"],"sourcesContent":["/**\n * Security module for RiotPrompt\n * \n * Provides security configuration, types, and utilities for:\n * - Path validation and traversal prevention\n * - Tool execution sandboxing\n * - Secret redaction\n * - Secure logging\n * - Request timeouts\n * \n * @packageDocumentation\n */\n\n// Types and schemas\nexport {\n PathSecurityConfigSchema,\n ToolSecurityConfigSchema,\n SecretSecurityConfigSchema,\n LogSecurityConfigSchema,\n TimeoutConfigSchema,\n SecurityConfigSchema,\n} from './types';\n\nexport type {\n PathSecurityConfig,\n ToolSecurityConfig,\n SecretSecurityConfig,\n LogSecurityConfig,\n TimeoutConfig,\n SecurityConfig,\n} from './types';\n\n// Default configurations\nexport {\n SECURE_DEFAULTS,\n PERMISSIVE_DEFAULTS,\n mergeSecurityConfig,\n} from './defaults';\n\n// Security events\nexport type {\n SecurityEventType,\n SecurityEvent,\n} from './events';\n\n// Audit logging\nexport {\n SecurityAuditLogger,\n getAuditLogger,\n configureAuditLogger,\n resetAuditLogger,\n} from './audit-logger';\n\nexport type {\n AuditLoggerConfig,\n} from './audit-logger';\n\n// Path security\nexport {\n PathGuard,\n getPathGuard,\n configurePathGuard,\n resetPathGuard,\n // Glob pattern utilities\n sanitizeGlobPattern,\n isGlobSafe,\n validateGlobPattern,\n} from './path-guard';\n\nexport type {\n PathValidationResult,\n GlobValidationResult,\n} from './path-guard';\n\n// CLI security\nexport {\n CLIValidator,\n getCLIValidator,\n configureCLIValidator,\n resetCLIValidator,\n createRiotPromptValidator,\n DEFAULT_CLI_SECURITY,\n} from './cli-security';\n\nexport type {\n CLISecurityConfig,\n StringValidationResult,\n} from './cli-security';\n\n// Timeout protection\nexport {\n TimeoutGuard,\n TimeoutError,\n isTimeoutError,\n getTimeoutGuard,\n configureTimeoutGuard,\n resetTimeoutGuard,\n} from './timeout-guard';\n\n// Serialization security\nexport {\n SCHEMA_VERSION,\n SERIALIZATION_LIMITS,\n ToolCallSchema,\n ConversationMessageSchema,\n ConversationMetadataSchema,\n SerializedConversationSchema,\n SerializedPromptSchema,\n LoggedConversationSchema,\n validateConversation,\n validateLoggedConversation,\n safeJsonParse,\n} from './serialization-schemas';\n\nexport type {\n SerializedConversation,\n SerializedPrompt,\n LoggedConversation as SerializedLoggedConversation,\n} from './serialization-schemas';\n\n// Rate limiting\nexport {\n NoOpRateLimiter,\n MemoryRateLimiter,\n createRateLimiter,\n createNoOpRateLimiter,\n getRateLimiter,\n configureRateLimiter,\n resetRateLimiter,\n} from './rate-limiter';\n\nexport type {\n RateLimiter,\n RateLimiterConfig,\n} from './rate-limiter';\n"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;;;;;;;AAWC"}