@weave_protocol/mund 0.1.13 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +131 -17
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +73 -8
- package/dist/index.js.map +1 -1
- package/dist/threat-intel-index.d.ts +8 -0
- package/dist/threat-intel-index.d.ts.map +1 -0
- package/dist/threat-intel-index.js +11 -0
- package/dist/threat-intel-index.js.map +1 -0
- package/dist/threat-intel-manager.d.ts +41 -0
- package/dist/threat-intel-manager.d.ts.map +1 -0
- package/dist/threat-intel-manager.js +812 -0
- package/dist/threat-intel-manager.js.map +1 -0
- package/dist/threat-intel-tools.d.ts +208 -0
- package/dist/threat-intel-tools.d.ts.map +1 -0
- package/dist/threat-intel-tools.js +194 -0
- package/dist/threat-intel-tools.js.map +1 -0
- package/dist/threat-intel-types.d.ts +172 -0
- package/dist/threat-intel-types.d.ts.map +1 -0
- package/dist/threat-intel-types.js +6 -0
- package/dist/threat-intel-types.js.map +1 -0
- package/package.json +1 -1
- package/src/index.ts +99 -8
- package/src/threat-intel-index.ts +13 -0
- package/src/threat-intel-manager.ts +920 -0
- package/src/threat-intel-tools.ts +233 -0
- package/src/threat-intel-types.ts +233 -0
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Threat Intelligence MCP Tools
|
|
3
|
+
* @weave_protocol/mund
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import type { ThreatIntelManager } from './threat-intel-manager.js';
|
|
8
|
+
import type { IntelCategory, IntelSourceType } from './threat-intel-types.js';
|
|
9
|
+
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// Zod Schemas for Tool Inputs
|
|
12
|
+
// ============================================================================
|
|
13
|
+
|
|
14
|
+
export const UpdateThreatIntelSchema = {
|
|
15
|
+
source_id: z.string().optional().describe('Specific source to update (omit for all)'),
|
|
16
|
+
force: z.boolean().default(false).describe('Force update even if not due'),
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const ListIntelSourcesSchema = {
|
|
20
|
+
enabled_only: z.boolean().default(false).describe('Only show enabled sources'),
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const IntelStatusSchema = {
|
|
24
|
+
include_patterns: z.boolean().default(false).describe('Include pattern details'),
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const AddIntelSourceSchema = {
|
|
28
|
+
id: z.string().describe('Unique source identifier'),
|
|
29
|
+
name: z.string().describe('Human-readable name'),
|
|
30
|
+
type: z.enum(['mitre_attack', 'community_blocklist', 'custom', 'weave_official']).describe('Source type'),
|
|
31
|
+
url: z.string().optional().describe('URL for remote sources'),
|
|
32
|
+
description: z.string().describe('Source description'),
|
|
33
|
+
auto_update: z.boolean().default(true).describe('Enable auto-updates'),
|
|
34
|
+
update_interval_hours: z.number().default(24).describe('Update interval in hours'),
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const RemoveIntelSourceSchema = {
|
|
38
|
+
source_id: z.string().describe('Source ID to remove'),
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const ThreatScanSchema = {
|
|
42
|
+
content: z.string().describe('Content to scan'),
|
|
43
|
+
categories: z.array(z.enum([
|
|
44
|
+
'prompt_injection', 'jailbreak', 'data_exfiltration',
|
|
45
|
+
'privilege_escalation', 'social_engineering', 'malicious_code',
|
|
46
|
+
'pii_extraction', 'system_prompt_leak', 'dos_attack', 'mcp_exploit'
|
|
47
|
+
])).optional().describe('Filter by categories'),
|
|
48
|
+
min_severity: z.enum(['critical', 'high', 'medium', 'low']).optional().describe('Minimum severity'),
|
|
49
|
+
min_confidence: z.number().min(0).max(1).optional().describe('Minimum confidence (0-1)'),
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const ListPatternsSchema = {
|
|
53
|
+
source_id: z.string().optional().describe('Filter by source'),
|
|
54
|
+
category: z.enum([
|
|
55
|
+
'prompt_injection', 'jailbreak', 'data_exfiltration',
|
|
56
|
+
'privilege_escalation', 'social_engineering', 'malicious_code',
|
|
57
|
+
'pii_extraction', 'system_prompt_leak', 'dos_attack', 'mcp_exploit'
|
|
58
|
+
]).optional().describe('Filter by category'),
|
|
59
|
+
enabled_only: z.boolean().default(true).describe('Only show enabled patterns'),
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export const TogglePatternSchema = {
|
|
63
|
+
pattern_id: z.string().describe('Pattern ID to toggle'),
|
|
64
|
+
enabled: z.boolean().describe('Enable or disable'),
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// ============================================================================
|
|
68
|
+
// Tool Definitions (exported as threatIntelTools)
|
|
69
|
+
// ============================================================================
|
|
70
|
+
|
|
71
|
+
export const threatIntelTools = [
|
|
72
|
+
{
|
|
73
|
+
name: 'mund_update_threat_intel',
|
|
74
|
+
description: 'Pull latest threat patterns from configured intelligence feeds. Updates MITRE ATT&CK mappings and community blocklists.',
|
|
75
|
+
schema: UpdateThreatIntelSchema,
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: 'mund_list_intel_sources',
|
|
79
|
+
description: 'List all configured threat intelligence sources with their status, update intervals, and pattern counts.',
|
|
80
|
+
schema: ListIntelSourcesSchema,
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: 'mund_intel_status',
|
|
84
|
+
description: 'Get threat intelligence health status including source coverage, pattern counts by category, and MITRE ATT&CK technique coverage.',
|
|
85
|
+
schema: IntelStatusSchema,
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: 'mund_add_intel_source',
|
|
89
|
+
description: 'Add a custom threat intelligence feed. Supports URL, file, and API sources.',
|
|
90
|
+
schema: AddIntelSourceSchema,
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: 'mund_remove_intel_source',
|
|
94
|
+
description: 'Remove a custom threat intelligence source and all its patterns.',
|
|
95
|
+
schema: RemoveIntelSourceSchema,
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: 'mund_threat_scan',
|
|
99
|
+
description: 'Scan content using threat intelligence patterns. Returns findings with MITRE ATT&CK technique mappings.',
|
|
100
|
+
schema: ThreatScanSchema,
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: 'mund_list_patterns',
|
|
104
|
+
description: 'Browse threat detection patterns by source, category, or enabled status.',
|
|
105
|
+
schema: ListPatternsSchema,
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: 'mund_toggle_pattern',
|
|
109
|
+
description: 'Enable or disable a specific threat detection pattern.',
|
|
110
|
+
schema: TogglePatternSchema,
|
|
111
|
+
},
|
|
112
|
+
];
|
|
113
|
+
|
|
114
|
+
// ============================================================================
|
|
115
|
+
// Tool Handlers
|
|
116
|
+
// ============================================================================
|
|
117
|
+
|
|
118
|
+
export function createThreatIntelToolHandlers(manager: ThreatIntelManager) {
|
|
119
|
+
return {
|
|
120
|
+
mund_update_threat_intel: async (args: { source_id?: string; force?: boolean }) => {
|
|
121
|
+
if (args.source_id) {
|
|
122
|
+
return await manager.updateSource(args.source_id, args.force || false);
|
|
123
|
+
}
|
|
124
|
+
return await manager.updateAllSources(args.force || false);
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
mund_list_intel_sources: (args: { enabled_only?: boolean }) => {
|
|
128
|
+
let sources = manager.getSources();
|
|
129
|
+
if (args.enabled_only) {
|
|
130
|
+
sources = sources.filter(s => s.enabled);
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
sources: sources.map(s => ({
|
|
134
|
+
id: s.id,
|
|
135
|
+
name: s.name,
|
|
136
|
+
type: s.type,
|
|
137
|
+
enabled: s.enabled,
|
|
138
|
+
autoUpdate: s.autoUpdate,
|
|
139
|
+
patternCount: s.patternCount,
|
|
140
|
+
version: s.version,
|
|
141
|
+
lastUpdated: s.lastUpdated,
|
|
142
|
+
updateIntervalHours: s.updateIntervalHours,
|
|
143
|
+
lastError: s.lastError,
|
|
144
|
+
})),
|
|
145
|
+
};
|
|
146
|
+
},
|
|
147
|
+
|
|
148
|
+
mund_intel_status: (args: { include_patterns?: boolean }) => {
|
|
149
|
+
const status = manager.getStatus();
|
|
150
|
+
if (args.include_patterns) {
|
|
151
|
+
return {
|
|
152
|
+
...status,
|
|
153
|
+
patterns_detail: manager.getPatterns({ enabledOnly: true }).map(p => ({
|
|
154
|
+
id: p.id,
|
|
155
|
+
name: p.name,
|
|
156
|
+
category: p.category,
|
|
157
|
+
severity: p.severity,
|
|
158
|
+
sourceId: p.sourceId,
|
|
159
|
+
mitreId: p.mitreId,
|
|
160
|
+
})),
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
return status;
|
|
164
|
+
},
|
|
165
|
+
|
|
166
|
+
mund_add_intel_source: (args: {
|
|
167
|
+
id: string;
|
|
168
|
+
name: string;
|
|
169
|
+
type: IntelSourceType;
|
|
170
|
+
url?: string;
|
|
171
|
+
description: string;
|
|
172
|
+
auto_update?: boolean;
|
|
173
|
+
update_interval_hours?: number;
|
|
174
|
+
}) => {
|
|
175
|
+
return manager.addSource({
|
|
176
|
+
id: args.id,
|
|
177
|
+
name: args.name,
|
|
178
|
+
type: args.type,
|
|
179
|
+
url: args.url,
|
|
180
|
+
description: args.description,
|
|
181
|
+
autoUpdate: args.auto_update ?? true,
|
|
182
|
+
updateIntervalHours: args.update_interval_hours ?? 24,
|
|
183
|
+
});
|
|
184
|
+
},
|
|
185
|
+
|
|
186
|
+
mund_remove_intel_source: (args: { source_id: string }) => {
|
|
187
|
+
return manager.removeSource(args.source_id);
|
|
188
|
+
},
|
|
189
|
+
|
|
190
|
+
mund_threat_scan: (args: {
|
|
191
|
+
content: string;
|
|
192
|
+
categories?: IntelCategory[];
|
|
193
|
+
min_severity?: 'critical' | 'high' | 'medium' | 'low';
|
|
194
|
+
min_confidence?: number;
|
|
195
|
+
}) => {
|
|
196
|
+
return manager.scan(args.content, {
|
|
197
|
+
categories: args.categories,
|
|
198
|
+
minSeverity: args.min_severity,
|
|
199
|
+
minConfidence: args.min_confidence,
|
|
200
|
+
});
|
|
201
|
+
},
|
|
202
|
+
|
|
203
|
+
mund_list_patterns: (args: {
|
|
204
|
+
source_id?: string;
|
|
205
|
+
category?: IntelCategory;
|
|
206
|
+
enabled_only?: boolean;
|
|
207
|
+
}) => {
|
|
208
|
+
const patterns = manager.getPatterns({
|
|
209
|
+
sourceId: args.source_id,
|
|
210
|
+
category: args.category,
|
|
211
|
+
enabledOnly: args.enabled_only ?? true,
|
|
212
|
+
});
|
|
213
|
+
return {
|
|
214
|
+
count: patterns.length,
|
|
215
|
+
patterns: patterns.map(p => ({
|
|
216
|
+
id: p.id,
|
|
217
|
+
name: p.name,
|
|
218
|
+
category: p.category,
|
|
219
|
+
severity: p.severity,
|
|
220
|
+
confidence: p.confidence,
|
|
221
|
+
mitreId: p.mitreId,
|
|
222
|
+
mitreTactic: p.mitreTactic,
|
|
223
|
+
sourceId: p.sourceId,
|
|
224
|
+
enabled: p.enabled,
|
|
225
|
+
})),
|
|
226
|
+
};
|
|
227
|
+
},
|
|
228
|
+
|
|
229
|
+
mund_toggle_pattern: (args: { pattern_id: string; enabled: boolean }) => {
|
|
230
|
+
return manager.togglePattern(args.pattern_id, args.enabled);
|
|
231
|
+
},
|
|
232
|
+
};
|
|
233
|
+
}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Threat Intelligence Types
|
|
3
|
+
* @weave_protocol/mund
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// ============================================================================
|
|
7
|
+
// Intel Source Types
|
|
8
|
+
// ============================================================================
|
|
9
|
+
|
|
10
|
+
export type IntelSourceType =
|
|
11
|
+
| 'mitre_attack'
|
|
12
|
+
| 'community_blocklist'
|
|
13
|
+
| 'custom'
|
|
14
|
+
| 'weave_official';
|
|
15
|
+
|
|
16
|
+
export type IntelCategory =
|
|
17
|
+
| 'prompt_injection'
|
|
18
|
+
| 'jailbreak'
|
|
19
|
+
| 'data_exfiltration'
|
|
20
|
+
| 'privilege_escalation'
|
|
21
|
+
| 'social_engineering'
|
|
22
|
+
| 'malicious_code'
|
|
23
|
+
| 'pii_extraction'
|
|
24
|
+
| 'system_prompt_leak'
|
|
25
|
+
| 'dos_attack'
|
|
26
|
+
| 'mcp_exploit';
|
|
27
|
+
|
|
28
|
+
export type PatternType =
|
|
29
|
+
| 'regex'
|
|
30
|
+
| 'keyword'
|
|
31
|
+
| 'semantic'
|
|
32
|
+
| 'behavioral';
|
|
33
|
+
|
|
34
|
+
export type Severity = 'low' | 'medium' | 'high' | 'critical';
|
|
35
|
+
|
|
36
|
+
// ============================================================================
|
|
37
|
+
// Intel Source Configuration
|
|
38
|
+
// ============================================================================
|
|
39
|
+
|
|
40
|
+
export interface IntelSource {
|
|
41
|
+
id: string;
|
|
42
|
+
name: string;
|
|
43
|
+
type: IntelSourceType;
|
|
44
|
+
url?: string;
|
|
45
|
+
description: string;
|
|
46
|
+
enabled: boolean;
|
|
47
|
+
autoUpdate: boolean;
|
|
48
|
+
updateIntervalHours: number;
|
|
49
|
+
lastUpdated?: Date;
|
|
50
|
+
lastError?: string;
|
|
51
|
+
patternCount: number;
|
|
52
|
+
version: string;
|
|
53
|
+
categories: IntelCategory[];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface IntelSourceConfig {
|
|
57
|
+
id: string;
|
|
58
|
+
name: string;
|
|
59
|
+
type: IntelSourceType;
|
|
60
|
+
url?: string;
|
|
61
|
+
description: string;
|
|
62
|
+
enabled?: boolean;
|
|
63
|
+
autoUpdate?: boolean;
|
|
64
|
+
updateIntervalHours?: number;
|
|
65
|
+
apiKey?: string;
|
|
66
|
+
categories?: IntelCategory[];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// ============================================================================
|
|
70
|
+
// Threat Patterns
|
|
71
|
+
// ============================================================================
|
|
72
|
+
|
|
73
|
+
export interface ThreatPattern {
|
|
74
|
+
id: string;
|
|
75
|
+
sourceId: string;
|
|
76
|
+
category: IntelCategory;
|
|
77
|
+
name: string;
|
|
78
|
+
description: string;
|
|
79
|
+
patternType: PatternType;
|
|
80
|
+
pattern: string; // Regex string, keyword, or semantic descriptor
|
|
81
|
+
severity: Severity;
|
|
82
|
+
confidence: number; // 0-1
|
|
83
|
+
mitreId?: string; // e.g., "T1059.001"
|
|
84
|
+
mitreTactic?: string; // e.g., "Execution"
|
|
85
|
+
mitreTechnique?: string; // e.g., "Command and Scripting Interpreter"
|
|
86
|
+
tags: string[];
|
|
87
|
+
examples?: string[];
|
|
88
|
+
falsePositiveRate?: number; // 0-1
|
|
89
|
+
enabled: boolean;
|
|
90
|
+
version: string;
|
|
91
|
+
createdAt: Date;
|
|
92
|
+
updatedAt: Date;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface PatternMatch {
|
|
96
|
+
patternId: string;
|
|
97
|
+
patternName: string;
|
|
98
|
+
category: IntelCategory;
|
|
99
|
+
severity: Severity;
|
|
100
|
+
confidence: number;
|
|
101
|
+
matchedText: string;
|
|
102
|
+
position: { start: number; end: number };
|
|
103
|
+
mitreId?: string;
|
|
104
|
+
mitreTactic?: string;
|
|
105
|
+
recommendation: string;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// ============================================================================
|
|
109
|
+
// Update Results
|
|
110
|
+
// ============================================================================
|
|
111
|
+
|
|
112
|
+
export interface IntelUpdateResult {
|
|
113
|
+
sourceId: string;
|
|
114
|
+
sourceName: string;
|
|
115
|
+
success: boolean;
|
|
116
|
+
previousVersion: string;
|
|
117
|
+
newVersion: string;
|
|
118
|
+
patternsAdded: number;
|
|
119
|
+
patternsUpdated: number;
|
|
120
|
+
patternsRemoved: number;
|
|
121
|
+
totalPatterns: number;
|
|
122
|
+
timestamp: Date;
|
|
123
|
+
error?: string;
|
|
124
|
+
duration_ms: number;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface BulkUpdateResult {
|
|
128
|
+
totalSources: number;
|
|
129
|
+
successfulUpdates: number;
|
|
130
|
+
failedUpdates: number;
|
|
131
|
+
totalPatternsAdded: number;
|
|
132
|
+
totalPatternsUpdated: number;
|
|
133
|
+
totalPatternsRemoved: number;
|
|
134
|
+
results: IntelUpdateResult[];
|
|
135
|
+
timestamp: Date;
|
|
136
|
+
duration_ms: number;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// ============================================================================
|
|
140
|
+
// Intel Status
|
|
141
|
+
// ============================================================================
|
|
142
|
+
|
|
143
|
+
export interface IntelStatus {
|
|
144
|
+
initialized: boolean;
|
|
145
|
+
lastGlobalUpdate?: Date;
|
|
146
|
+
sources: {
|
|
147
|
+
total: number;
|
|
148
|
+
enabled: number;
|
|
149
|
+
autoUpdate: number;
|
|
150
|
+
};
|
|
151
|
+
patterns: {
|
|
152
|
+
total: number;
|
|
153
|
+
byCategory: Record<IntelCategory, number>;
|
|
154
|
+
bySeverity: Record<Severity, number>;
|
|
155
|
+
bySource: Record<string, number>;
|
|
156
|
+
};
|
|
157
|
+
coverage: {
|
|
158
|
+
mitreAttack: {
|
|
159
|
+
tactics: number;
|
|
160
|
+
techniques: number;
|
|
161
|
+
};
|
|
162
|
+
categories: IntelCategory[];
|
|
163
|
+
};
|
|
164
|
+
health: {
|
|
165
|
+
status: 'healthy' | 'degraded' | 'stale';
|
|
166
|
+
oldestUpdate?: Date;
|
|
167
|
+
staleSources: string[];
|
|
168
|
+
failedSources: string[];
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// ============================================================================
|
|
173
|
+
// MITRE ATT&CK Specific
|
|
174
|
+
// ============================================================================
|
|
175
|
+
|
|
176
|
+
export interface MitreAttackPattern {
|
|
177
|
+
id: string; // e.g., "T1059"
|
|
178
|
+
name: string;
|
|
179
|
+
tactic: string;
|
|
180
|
+
technique: string;
|
|
181
|
+
subtechnique?: string;
|
|
182
|
+
description: string;
|
|
183
|
+
aiRelevance: 'direct' | 'indirect' | 'adapted';
|
|
184
|
+
promptInjectionVariants: string[];
|
|
185
|
+
detectionPatterns: string[];
|
|
186
|
+
mitigations: string[];
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// ============================================================================
|
|
190
|
+
// Blocklist Types
|
|
191
|
+
// ============================================================================
|
|
192
|
+
|
|
193
|
+
export interface BlocklistEntry {
|
|
194
|
+
id: string;
|
|
195
|
+
sourceId: string;
|
|
196
|
+
type: 'domain' | 'ip' | 'phrase' | 'pattern' | 'hash';
|
|
197
|
+
value: string;
|
|
198
|
+
reason: string;
|
|
199
|
+
severity: Severity;
|
|
200
|
+
reportedBy?: string;
|
|
201
|
+
reportedAt: Date;
|
|
202
|
+
confirmedMalicious: boolean;
|
|
203
|
+
falsePositiveCount: number;
|
|
204
|
+
enabled: boolean;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// ============================================================================
|
|
208
|
+
// Scan Configuration
|
|
209
|
+
// ============================================================================
|
|
210
|
+
|
|
211
|
+
export interface ThreatScanConfig {
|
|
212
|
+
categories?: IntelCategory[];
|
|
213
|
+
minSeverity?: Severity;
|
|
214
|
+
minConfidence?: number;
|
|
215
|
+
includeMitre?: boolean;
|
|
216
|
+
maxMatches?: number;
|
|
217
|
+
timeout_ms?: number;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export interface ThreatScanResult {
|
|
221
|
+
scanned: boolean;
|
|
222
|
+
content_length: number;
|
|
223
|
+
matches: PatternMatch[];
|
|
224
|
+
summary: {
|
|
225
|
+
total_matches: number;
|
|
226
|
+
by_severity: Record<Severity, number>;
|
|
227
|
+
by_category: Record<string, number>;
|
|
228
|
+
highest_severity: Severity | null;
|
|
229
|
+
mitre_techniques: string[];
|
|
230
|
+
};
|
|
231
|
+
recommendations: string[];
|
|
232
|
+
scan_duration_ms: number;
|
|
233
|
+
}
|