@weave_protocol/mund 0.1.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 (98) hide show
  1. package/dist/analyzers/code-analyzer.d.ts +24 -0
  2. package/dist/analyzers/code-analyzer.d.ts.map +1 -0
  3. package/dist/analyzers/code-analyzer.js +73 -0
  4. package/dist/analyzers/code-analyzer.js.map +1 -0
  5. package/dist/analyzers/exfiltration-detector.d.ts +40 -0
  6. package/dist/analyzers/exfiltration-detector.d.ts.map +1 -0
  7. package/dist/analyzers/exfiltration-detector.js +220 -0
  8. package/dist/analyzers/exfiltration-detector.js.map +1 -0
  9. package/dist/analyzers/index.d.ts +26 -0
  10. package/dist/analyzers/index.d.ts.map +1 -0
  11. package/dist/analyzers/index.js +61 -0
  12. package/dist/analyzers/index.js.map +1 -0
  13. package/dist/analyzers/injection-detector.d.ts +36 -0
  14. package/dist/analyzers/injection-detector.d.ts.map +1 -0
  15. package/dist/analyzers/injection-detector.js +165 -0
  16. package/dist/analyzers/injection-detector.js.map +1 -0
  17. package/dist/analyzers/pii-detector.d.ts +44 -0
  18. package/dist/analyzers/pii-detector.d.ts.map +1 -0
  19. package/dist/analyzers/pii-detector.js +190 -0
  20. package/dist/analyzers/pii-detector.js.map +1 -0
  21. package/dist/analyzers/secret-scanner.d.ts +32 -0
  22. package/dist/analyzers/secret-scanner.d.ts.map +1 -0
  23. package/dist/analyzers/secret-scanner.js +119 -0
  24. package/dist/analyzers/secret-scanner.js.map +1 -0
  25. package/dist/constants.d.ts +18 -0
  26. package/dist/constants.d.ts.map +1 -0
  27. package/dist/constants.js +580 -0
  28. package/dist/constants.js.map +1 -0
  29. package/dist/index.d.ts +9 -0
  30. package/dist/index.d.ts.map +1 -0
  31. package/dist/index.js +242 -0
  32. package/dist/index.js.map +1 -0
  33. package/dist/notifications/email.d.ts +18 -0
  34. package/dist/notifications/email.d.ts.map +1 -0
  35. package/dist/notifications/email.js +192 -0
  36. package/dist/notifications/email.js.map +1 -0
  37. package/dist/notifications/index.d.ts +51 -0
  38. package/dist/notifications/index.d.ts.map +1 -0
  39. package/dist/notifications/index.js +107 -0
  40. package/dist/notifications/index.js.map +1 -0
  41. package/dist/notifications/slack.d.ts +17 -0
  42. package/dist/notifications/slack.d.ts.map +1 -0
  43. package/dist/notifications/slack.js +128 -0
  44. package/dist/notifications/slack.js.map +1 -0
  45. package/dist/notifications/teams.d.ts +17 -0
  46. package/dist/notifications/teams.d.ts.map +1 -0
  47. package/dist/notifications/teams.js +136 -0
  48. package/dist/notifications/teams.js.map +1 -0
  49. package/dist/notifications/webhook.d.ts +15 -0
  50. package/dist/notifications/webhook.d.ts.map +1 -0
  51. package/dist/notifications/webhook.js +67 -0
  52. package/dist/notifications/webhook.js.map +1 -0
  53. package/dist/storage/index.d.ts +11 -0
  54. package/dist/storage/index.d.ts.map +1 -0
  55. package/dist/storage/index.js +26 -0
  56. package/dist/storage/index.js.map +1 -0
  57. package/dist/storage/memory.d.ts +35 -0
  58. package/dist/storage/memory.d.ts.map +1 -0
  59. package/dist/storage/memory.js +144 -0
  60. package/dist/storage/memory.js.map +1 -0
  61. package/dist/tools/configuration.d.ts +8 -0
  62. package/dist/tools/configuration.d.ts.map +1 -0
  63. package/dist/tools/configuration.js +399 -0
  64. package/dist/tools/configuration.js.map +1 -0
  65. package/dist/tools/index.d.ts +15 -0
  66. package/dist/tools/index.d.ts.map +1 -0
  67. package/dist/tools/index.js +16 -0
  68. package/dist/tools/index.js.map +1 -0
  69. package/dist/tools/monitoring.d.ts +10 -0
  70. package/dist/tools/monitoring.d.ts.map +1 -0
  71. package/dist/tools/monitoring.js +476 -0
  72. package/dist/tools/monitoring.js.map +1 -0
  73. package/dist/types.d.ts +207 -0
  74. package/dist/types.d.ts.map +1 -0
  75. package/dist/types.js +6 -0
  76. package/dist/types.js.map +1 -0
  77. package/package.json +62 -0
  78. package/rules/default.yaml +189 -0
  79. package/src/analyzers/code-analyzer.ts +88 -0
  80. package/src/analyzers/exfiltration-detector.ts +257 -0
  81. package/src/analyzers/index.ts +74 -0
  82. package/src/analyzers/injection-detector.ts +191 -0
  83. package/src/analyzers/pii-detector.ts +220 -0
  84. package/src/analyzers/secret-scanner.ts +142 -0
  85. package/src/constants.ts +603 -0
  86. package/src/index.ts +285 -0
  87. package/src/notifications/email.ts +211 -0
  88. package/src/notifications/index.ts +136 -0
  89. package/src/notifications/slack.ts +170 -0
  90. package/src/notifications/teams.ts +200 -0
  91. package/src/notifications/webhook.ts +80 -0
  92. package/src/storage/index.ts +29 -0
  93. package/src/storage/memory.ts +181 -0
  94. package/src/tools/configuration.ts +478 -0
  95. package/src/tools/index.ts +29 -0
  96. package/src/tools/monitoring.ts +559 -0
  97. package/src/types.ts +300 -0
  98. package/tsconfig.json +24 -0
package/src/types.ts ADDED
@@ -0,0 +1,300 @@
1
+ /**
2
+ * Mund - The Guardian Protocol
3
+ * Core type definitions
4
+ */
5
+
6
+ // ============================================================================
7
+ // Severity and Action Types
8
+ // ============================================================================
9
+
10
+ export type Severity = 'critical' | 'high' | 'medium' | 'low' | 'info';
11
+
12
+ export type ActionType = 'alert' | 'block' | 'log' | 'quarantine' | 'redact' | 'none';
13
+
14
+ export type DetectorType = 'secret' | 'pii' | 'code_pattern' | 'injection' | 'exfiltration' | 'behavioral' | 'custom';
15
+
16
+
17
+ // ============================================================================
18
+ // Detection Rules
19
+ // ============================================================================
20
+
21
+ export interface DetectionRule {
22
+ id: string;
23
+ name: string;
24
+ description?: string;
25
+ type: string;
26
+ pattern?: string;
27
+ condition?: string;
28
+ severity: Severity;
29
+ action: ActionType;
30
+ enabled: boolean;
31
+ metadata?: Record<string, unknown>;
32
+ }
33
+
34
+ export interface SecretRule extends DetectionRule {
35
+ type: 'secret';
36
+ pattern: string;
37
+ entropy_threshold?: number;
38
+ }
39
+
40
+ export interface BehavioralRule extends DetectionRule {
41
+ type: 'behavioral';
42
+ condition: string;
43
+ time_window_seconds: number;
44
+ threshold: number;
45
+ }
46
+
47
+ // ============================================================================
48
+ // Security Events
49
+ // ============================================================================
50
+
51
+ export interface SecurityEvent {
52
+ id: string;
53
+ timestamp: Date;
54
+ rule_id: string;
55
+ rule_name: string;
56
+ severity: Severity;
57
+ type: string;
58
+ action_taken: ActionType;
59
+ content_snippet: string;
60
+ full_content_hash: string;
61
+ context: EventContext;
62
+ acknowledged: boolean;
63
+ acknowledged_by?: string;
64
+ acknowledged_at?: Date;
65
+ metadata?: Record<string, unknown>;
66
+ }
67
+
68
+ export interface EventContext {
69
+ tool_name?: string;
70
+ tool_args?: Record<string, unknown>;
71
+ source?: string;
72
+ agent_id?: string;
73
+ session_id?: string;
74
+ user_id?: string;
75
+ ip_address?: string;
76
+ }
77
+
78
+ // ============================================================================
79
+ // Scan Results
80
+ // ============================================================================
81
+
82
+ export interface ScanResult {
83
+ id: string;
84
+ timestamp: Date;
85
+ content_hash: string;
86
+ issues: SecurityIssue[];
87
+ scan_duration_ms: number;
88
+ rules_checked: number;
89
+ }
90
+
91
+ export interface SecurityIssue {
92
+ rule_id: string;
93
+ rule_name: string;
94
+ type: string;
95
+ severity: Severity;
96
+ action: ActionType;
97
+ match: string;
98
+ location?: IssueLocation;
99
+ suggestion?: string;
100
+ }
101
+
102
+ export interface IssueLocation {
103
+ start: number;
104
+ end: number;
105
+ line?: number;
106
+ column?: number;
107
+ }
108
+
109
+ // ============================================================================
110
+ // Configuration
111
+ // ============================================================================
112
+
113
+ export interface MundConfig {
114
+ // Server settings
115
+ port: number;
116
+ host: string;
117
+ transport: 'stdio' | 'http';
118
+
119
+ // Logging
120
+ log_level: 'debug' | 'info' | 'warn' | 'error';
121
+
122
+ // Storage
123
+ storage_type: 'memory' | 'sqlite' | 'postgres';
124
+ database_url?: string;
125
+
126
+ // Security mode
127
+ block_mode: boolean;
128
+
129
+ // API
130
+ api_key?: string;
131
+
132
+ // Notifications
133
+ notifications: NotificationConfig;
134
+
135
+ // Rules
136
+ rules_path?: string;
137
+ custom_rules?: DetectionRule[];
138
+ }
139
+
140
+ export interface NotificationConfig {
141
+ slack?: SlackConfig;
142
+ teams?: TeamsConfig;
143
+ email?: EmailConfig;
144
+ webhooks?: WebhookConfig[];
145
+ }
146
+
147
+ export interface SlackConfig {
148
+ webhook_url: string;
149
+ channel?: string;
150
+ username?: string;
151
+ icon_emoji?: string;
152
+ min_severity?: Severity;
153
+ }
154
+
155
+ export interface TeamsConfig {
156
+ webhook_url: string;
157
+ min_severity?: Severity;
158
+ }
159
+
160
+ export interface EmailConfig {
161
+ smtp_host: string;
162
+ smtp_port: number;
163
+ smtp_secure: boolean;
164
+ smtp_user?: string;
165
+ smtp_pass?: string;
166
+ from_address: string;
167
+ to_addresses: string[];
168
+ min_severity?: Severity;
169
+ }
170
+
171
+ export interface WebhookConfig {
172
+ url: string;
173
+ method: 'POST' | 'PUT';
174
+ headers?: Record<string, string>;
175
+ min_severity?: Severity;
176
+ }
177
+
178
+ // ============================================================================
179
+ // Notification Payloads
180
+ // ============================================================================
181
+
182
+ export interface NotificationPayload {
183
+ event: SecurityEvent;
184
+ config: MundConfig;
185
+ formatted_message: string;
186
+ }
187
+
188
+ // ============================================================================
189
+ // API Types
190
+ // ============================================================================
191
+
192
+ export interface ApiResponse<T> {
193
+ success: boolean;
194
+ data?: T;
195
+ error?: string;
196
+ timestamp: Date;
197
+ }
198
+
199
+ export interface PaginatedResponse<T> extends ApiResponse<T[]> {
200
+ total: number;
201
+ offset: number;
202
+ limit: number;
203
+ has_more: boolean;
204
+ }
205
+
206
+ // ============================================================================
207
+ // Tool Input/Output Types
208
+ // ============================================================================
209
+
210
+ export interface ScanContentInput {
211
+ content: string;
212
+ content_type?: 'text' | 'code' | 'json' | 'yaml';
213
+ context?: EventContext;
214
+ }
215
+
216
+ export interface CheckUrlInput {
217
+ url: string;
218
+ context?: EventContext;
219
+ }
220
+
221
+ export interface ValidateCommandInput {
222
+ command: string;
223
+ context?: EventContext;
224
+ }
225
+
226
+ export interface GetEventsInput {
227
+ limit?: number;
228
+ offset?: number;
229
+ severity?: Severity;
230
+ type?: DetectorType;
231
+ start_time?: Date;
232
+ end_time?: Date;
233
+ acknowledged?: boolean;
234
+ }
235
+
236
+ export interface AddRuleInput {
237
+ id: string;
238
+ name: string;
239
+ description?: string;
240
+ type: string;
241
+ pattern?: string;
242
+ condition?: string;
243
+ severity: Severity;
244
+ action: ActionType;
245
+ metadata?: Record<string, unknown>;
246
+ }
247
+
248
+ export interface ConfigureNotificationInput {
249
+ type: 'slack' | 'teams' | 'email' | 'webhook';
250
+ config: SlackConfig | TeamsConfig | EmailConfig | WebhookConfig;
251
+ }
252
+
253
+ // ============================================================================
254
+ // Storage Interface
255
+ // ============================================================================
256
+
257
+ export interface IStorage {
258
+ // Events
259
+ saveEvent(event: SecurityEvent): Promise<void>;
260
+ getEvent(id: string): Promise<SecurityEvent | null>;
261
+ getEvents(query: GetEventsInput): Promise<SecurityEvent[]>;
262
+ countEvents(query: GetEventsInput): Promise<number>;
263
+ acknowledgeEvent(id: string, by?: string): Promise<void>;
264
+
265
+ // Rules
266
+ saveRule(rule: DetectionRule): Promise<void>;
267
+ getRule(id: string): Promise<DetectionRule | null>;
268
+ getRules(): Promise<DetectionRule[]>;
269
+ deleteRule(id: string): Promise<void>;
270
+
271
+ // Allowlist/Blocklist
272
+ addToAllowlist(pattern: string, type: DetectorType): Promise<void>;
273
+ addToBlocklist(pattern: string, type: DetectorType): Promise<void>;
274
+ getAllowlist(type?: DetectorType): Promise<string[]>;
275
+ getBlocklist(type?: DetectorType): Promise<string[]>;
276
+ removeFromAllowlist(pattern: string): Promise<void>;
277
+ removeFromBlocklist(pattern: string): Promise<void>;
278
+
279
+ // Cleanup
280
+ close(): Promise<void>;
281
+ }
282
+
283
+ // ============================================================================
284
+ // Analyzer Interface
285
+ // ============================================================================
286
+
287
+ export interface IAnalyzer {
288
+ name: string;
289
+ type: string;
290
+ analyze(content: string, rules: DetectionRule[]): Promise<SecurityIssue[]>;
291
+ }
292
+
293
+ // ============================================================================
294
+ // Notifier Interface
295
+ // ============================================================================
296
+
297
+ export interface INotifier {
298
+ name: string;
299
+ send(payload: NotificationPayload): Promise<boolean>;
300
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "NodeNext",
5
+ "moduleResolution": "NodeNext",
6
+ "lib": ["ES2022"],
7
+ "outDir": "./dist",
8
+ "rootDir": "./src",
9
+ "strict": true,
10
+ "esModuleInterop": true,
11
+ "skipLibCheck": true,
12
+ "forceConsistentCasingInFileNames": true,
13
+ "resolveJsonModule": true,
14
+ "declaration": true,
15
+ "declarationMap": true,
16
+ "sourceMap": true,
17
+ "noUnusedLocals": true,
18
+ "noUnusedParameters": true,
19
+ "noImplicitReturns": true,
20
+ "noFallthroughCasesInSwitch": true
21
+ },
22
+ "include": ["src/**/*"],
23
+ "exclude": ["node_modules", "dist", "tests"]
24
+ }