@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
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Mund - The Guardian Protocol
3
+ * Code Analyzer - Detects dangerous code patterns
4
+ */
5
+ import { type DetectionRule, type SecurityIssue, type IAnalyzer } from '../types.js';
6
+ export declare class CodeAnalyzer implements IAnalyzer {
7
+ name: string;
8
+ type: string;
9
+ analyze(content: string, rules: DetectionRule[]): Promise<SecurityIssue[]>;
10
+ /**
11
+ * Calculate location within content
12
+ */
13
+ private getLocation;
14
+ /**
15
+ * Truncate match for display
16
+ */
17
+ private truncateMatch;
18
+ /**
19
+ * Get context-aware suggestion
20
+ */
21
+ private getSuggestion;
22
+ }
23
+ export default CodeAnalyzer;
24
+ //# sourceMappingURL=code-analyzer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-analyzer.d.ts","sourceRoot":"","sources":["../../src/analyzers/code-analyzer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,SAAS,EAEf,MAAM,aAAa,CAAC;AAErB,qBAAa,YAAa,YAAW,SAAS;IAC5C,IAAI,SAAkB;IACtB,IAAI,SAAkB;IAEhB,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAkChF;;OAEG;IACH,OAAO,CAAC,WAAW;IAQnB;;OAEG;IACH,OAAO,CAAC,aAAa;IAKrB;;OAEG;IACH,OAAO,CAAC,aAAa;CAatB;AAED,eAAe,YAAY,CAAC"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Mund - The Guardian Protocol
3
+ * Code Analyzer - Detects dangerous code patterns
4
+ */
5
+ export class CodeAnalyzer {
6
+ name = 'CodeAnalyzer';
7
+ type = 'code_pattern';
8
+ async analyze(content, rules) {
9
+ const issues = [];
10
+ const codeRules = rules.filter(r => r.type === 'code_pattern' && r.enabled);
11
+ for (const rule of codeRules) {
12
+ if (!rule.pattern)
13
+ continue;
14
+ try {
15
+ const regex = new RegExp(rule.pattern, 'gm');
16
+ let match;
17
+ while ((match = regex.exec(content)) !== null) {
18
+ const matchText = match[0];
19
+ const location = this.getLocation(content, match.index, matchText.length);
20
+ issues.push({
21
+ rule_id: rule.id,
22
+ rule_name: rule.name,
23
+ type: rule.type,
24
+ severity: rule.severity,
25
+ action: rule.action,
26
+ match: this.truncateMatch(matchText),
27
+ location,
28
+ suggestion: this.getSuggestion(rule.id, matchText)
29
+ });
30
+ }
31
+ }
32
+ catch (error) {
33
+ console.error(`Invalid regex pattern in rule ${rule.id}:`, error);
34
+ }
35
+ }
36
+ return issues;
37
+ }
38
+ /**
39
+ * Calculate location within content
40
+ */
41
+ getLocation(content, start, length) {
42
+ const end = start + length;
43
+ const lines = content.substring(0, start).split('\n');
44
+ const line = lines.length;
45
+ const column = lines[lines.length - 1].length + 1;
46
+ return { start, end, line, column };
47
+ }
48
+ /**
49
+ * Truncate match for display
50
+ */
51
+ truncateMatch(match, maxLength = 100) {
52
+ if (match.length <= maxLength)
53
+ return match;
54
+ return match.substring(0, maxLength) + '...';
55
+ }
56
+ /**
57
+ * Get context-aware suggestion
58
+ */
59
+ getSuggestion(ruleId, _match) {
60
+ const suggestions = {
61
+ shell_injection: 'Avoid using string interpolation in shell commands. Use parameterized commands or escape inputs properly.',
62
+ sql_injection_pattern: 'Use parameterized queries or prepared statements instead of string concatenation for SQL.',
63
+ dangerous_chmod: 'Avoid overly permissive file permissions. Use the minimum required permissions (e.g., 644 for files, 755 for directories).',
64
+ rm_rf: 'Be extremely careful with recursive deletion. Consider using trash/recycle functionality instead.',
65
+ curl_bash: 'Piping curl to bash is dangerous. Download the script first, review it, then execute.',
66
+ base64_decode_exec: 'Decoding and executing arbitrary content is dangerous. Validate the source and content first.',
67
+ disable_ssl_verify: 'Disabling SSL verification exposes you to man-in-the-middle attacks. Fix certificate issues instead.',
68
+ };
69
+ return suggestions[ruleId] || 'Review this code pattern for potential security issues.';
70
+ }
71
+ }
72
+ export default CodeAnalyzer;
73
+ //# sourceMappingURL=code-analyzer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-analyzer.js","sourceRoot":"","sources":["../../src/analyzers/code-analyzer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,MAAM,OAAO,YAAY;IACvB,IAAI,GAAG,cAAc,CAAC;IACtB,IAAI,GAAG,cAAc,CAAC;IAEtB,KAAK,CAAC,OAAO,CAAC,OAAe,EAAE,KAAsB;QACnD,MAAM,MAAM,GAAoB,EAAE,CAAC;QACnC,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,cAAc,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC;QAE5E,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE,CAAC;YAC7B,IAAI,CAAC,IAAI,CAAC,OAAO;gBAAE,SAAS;YAE5B,IAAI,CAAC;gBACH,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;gBAC7C,IAAI,KAA6B,CAAC;gBAElC,OAAO,CAAC,KAAK,GAAG,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E,IAAI,EAAE,MAAM,EAAE,CAAC;IACtC,CAAC;IAED;;OAEG;IACK,aAAa,CAAC,KAAa,EAAE,SAAS,GAAG,GAAG;QAClD,IAAI,KAAK,CAAC,MAAM,IAAI,SAAS;YAAE,OAAO,KAAK,CAAC;QAC5C,OAAO,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC;IAC/C,CAAC;IAED;;OAEG;IACK,aAAa,CAAC,MAAc,EAAE,MAAc;QAClD,MAAM,WAAW,GAA2B;YAC1C,eAAe,EAAE,2GAA2G;YAC5H,qBAAqB,EAAE,2FAA2F;YAClH,eAAe,EAAE,4HAA4H;YAC7I,KAAK,EAAE,mGAAmG;YAC1G,SAAS,EAAE,uFAAuF;YAClG,kBAAkB,EAAE,+FAA+F;YACnH,kBAAkB,EAAE,sGAAsG;SAC3H,CAAC;QAEF,OAAO,WAAW,CAAC,MAAM,CAAC,IAAI,yDAAyD,CAAC;IAC1F,CAAC;CACF;AAED,eAAe,YAAY,CAAC"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Mund - The Guardian Protocol
3
+ * Exfiltration Detector - Detects data exfiltration attempts
4
+ */
5
+ import { type DetectionRule, type SecurityIssue, type IAnalyzer } from '../types.js';
6
+ export declare class ExfiltrationDetector implements IAnalyzer {
7
+ name: string;
8
+ type: string;
9
+ analyze(content: string, rules: DetectionRule[]): Promise<SecurityIssue[]>;
10
+ /**
11
+ * Extract and analyze URLs in content
12
+ */
13
+ private analyzeURLs;
14
+ /**
15
+ * Detect suspicious data encoding patterns
16
+ */
17
+ private detectSuspiciousEncoding;
18
+ /**
19
+ * Check if string is likely base64
20
+ */
21
+ private isLikelyBase64;
22
+ /**
23
+ * Calculate location within content
24
+ */
25
+ private getLocation;
26
+ /**
27
+ * Truncate match for display
28
+ */
29
+ private truncateMatch;
30
+ /**
31
+ * Truncate URL for display (hide potential sensitive parts)
32
+ */
33
+ private truncateURL;
34
+ /**
35
+ * Get remediation suggestion
36
+ */
37
+ private getSuggestion;
38
+ }
39
+ export default ExfiltrationDetector;
40
+ //# sourceMappingURL=exfiltration-detector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exfiltration-detector.d.ts","sourceRoot":"","sources":["../../src/analyzers/exfiltration-detector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,SAAS,EAEf,MAAM,aAAa,CAAC;AAGrB,qBAAa,oBAAqB,YAAW,SAAS;IACpD,IAAI,SAA0B;IAC9B,IAAI,SAAkB;IAEhB,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IA2ChF;;OAEG;IACH,OAAO,CAAC,WAAW;IA4DnB;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAgDhC;;OAEG;IACH,OAAO,CAAC,cAAc;IAqBtB;;OAEG;IACH,OAAO,CAAC,WAAW;IAQnB;;OAEG;IACH,OAAO,CAAC,aAAa;IAKrB;;OAEG;IACH,OAAO,CAAC,WAAW;IAsBnB;;OAEG;IACH,OAAO,CAAC,aAAa;CAStB;AAED,eAAe,oBAAoB,CAAC"}
@@ -0,0 +1,220 @@
1
+ /**
2
+ * Mund - The Guardian Protocol
3
+ * Exfiltration Detector - Detects data exfiltration attempts
4
+ */
5
+ import { DANGEROUS_URL_PATTERNS } from '../constants.js';
6
+ export class ExfiltrationDetector {
7
+ name = 'ExfiltrationDetector';
8
+ type = 'exfiltration';
9
+ async analyze(content, rules) {
10
+ const issues = [];
11
+ const exfilRules = rules.filter(r => r.type === 'exfiltration' && r.enabled);
12
+ // Pattern-based detection
13
+ for (const rule of exfilRules) {
14
+ if (!rule.pattern)
15
+ continue;
16
+ try {
17
+ const regex = new RegExp(rule.pattern, 'gi');
18
+ let match;
19
+ while ((match = regex.exec(content)) !== null) {
20
+ const matchText = match[0];
21
+ const location = this.getLocation(content, match.index, matchText.length);
22
+ issues.push({
23
+ rule_id: rule.id,
24
+ rule_name: rule.name,
25
+ type: rule.type,
26
+ severity: rule.severity,
27
+ action: rule.action,
28
+ match: this.truncateMatch(matchText),
29
+ location,
30
+ suggestion: this.getSuggestion(rule.id)
31
+ });
32
+ }
33
+ }
34
+ catch (error) {
35
+ console.error(`Invalid regex pattern in rule ${rule.id}:`, error);
36
+ }
37
+ }
38
+ // URL extraction and analysis
39
+ const urlIssues = this.analyzeURLs(content);
40
+ issues.push(...urlIssues);
41
+ // Data encoding detection
42
+ const encodingIssues = this.detectSuspiciousEncoding(content);
43
+ issues.push(...encodingIssues);
44
+ return issues;
45
+ }
46
+ /**
47
+ * Extract and analyze URLs in content
48
+ */
49
+ analyzeURLs(content) {
50
+ const issues = [];
51
+ // URL regex pattern
52
+ const urlRegex = /https?:\/\/[^\s"'<>)}\]]+/gi;
53
+ let match;
54
+ while ((match = urlRegex.exec(content)) !== null) {
55
+ const url = match[0];
56
+ const location = this.getLocation(content, match.index, url.length);
57
+ // Check against dangerous patterns
58
+ for (const pattern of DANGEROUS_URL_PATTERNS) {
59
+ if (pattern.test(url)) {
60
+ issues.push({
61
+ rule_id: 'dangerous_url',
62
+ rule_name: 'Dangerous URL Detected',
63
+ type: 'exfiltration',
64
+ severity: 'high',
65
+ action: 'alert',
66
+ match: this.truncateURL(url),
67
+ location,
68
+ suggestion: 'This URL points to a service commonly used for data exfiltration. Verify the destination is legitimate.'
69
+ });
70
+ break;
71
+ }
72
+ }
73
+ // Check for IP-based URLs
74
+ if (/^https?:\/\/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/.test(url)) {
75
+ issues.push({
76
+ rule_id: 'ip_based_url',
77
+ rule_name: 'IP-Based URL',
78
+ type: 'exfiltration',
79
+ severity: 'medium',
80
+ action: 'alert',
81
+ match: this.truncateURL(url),
82
+ location,
83
+ suggestion: 'IP-based URLs can bypass domain-based security controls. Verify this is a legitimate destination.'
84
+ });
85
+ }
86
+ // Check for data URLs
87
+ if (/^data:/i.test(url)) {
88
+ issues.push({
89
+ rule_id: 'data_url',
90
+ rule_name: 'Data URL Detected',
91
+ type: 'exfiltration',
92
+ severity: 'medium',
93
+ action: 'alert',
94
+ match: this.truncateURL(url),
95
+ location,
96
+ suggestion: 'Data URLs can encode and transfer arbitrary content. Review the embedded data.'
97
+ });
98
+ }
99
+ }
100
+ return issues;
101
+ }
102
+ /**
103
+ * Detect suspicious data encoding patterns
104
+ */
105
+ detectSuspiciousEncoding(content) {
106
+ const issues = [];
107
+ // Large base64 blocks (potential data exfiltration)
108
+ const base64Regex = /[A-Za-z0-9+/]{100,}={0,2}/g;
109
+ let match;
110
+ while ((match = base64Regex.exec(content)) !== null) {
111
+ const encoded = match[0];
112
+ // Verify it's likely base64 (not just a long alphanumeric string)
113
+ if (this.isLikelyBase64(encoded)) {
114
+ const location = this.getLocation(content, match.index, encoded.length);
115
+ issues.push({
116
+ rule_id: 'large_base64_block',
117
+ rule_name: 'Large Base64 Block',
118
+ type: 'exfiltration',
119
+ severity: 'medium',
120
+ action: 'log',
121
+ match: `Base64 block (${encoded.length} chars)`,
122
+ location,
123
+ suggestion: 'Large base64 encoded blocks may contain exfiltrated data. Review the decoded content.'
124
+ });
125
+ }
126
+ }
127
+ // Hex-encoded data blocks
128
+ const hexRegex = /(?:0x)?[0-9a-fA-F]{200,}/g;
129
+ while ((match = hexRegex.exec(content)) !== null) {
130
+ const encoded = match[0];
131
+ const location = this.getLocation(content, match.index, encoded.length);
132
+ issues.push({
133
+ rule_id: 'large_hex_block',
134
+ rule_name: 'Large Hex-Encoded Block',
135
+ type: 'exfiltration',
136
+ severity: 'low',
137
+ action: 'log',
138
+ match: `Hex block (${encoded.length} chars)`,
139
+ location,
140
+ suggestion: 'Large hex-encoded blocks may contain encoded data. Review the decoded content.'
141
+ });
142
+ }
143
+ return issues;
144
+ }
145
+ /**
146
+ * Check if string is likely base64
147
+ */
148
+ isLikelyBase64(str) {
149
+ // Check character distribution
150
+ const chars = new Set(str.replace(/=/g, ''));
151
+ // Base64 uses a specific character set
152
+ const base64Chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
153
+ for (const char of chars) {
154
+ if (!base64Chars.includes(char))
155
+ return false;
156
+ }
157
+ // Check if it decodes to valid content
158
+ try {
159
+ const decoded = Buffer.from(str, 'base64').toString('utf8');
160
+ // Check if decoded content has a reasonable ratio of printable characters
161
+ const printable = decoded.replace(/[^\x20-\x7E]/g, '').length;
162
+ return printable / decoded.length > 0.7;
163
+ }
164
+ catch {
165
+ return false;
166
+ }
167
+ }
168
+ /**
169
+ * Calculate location within content
170
+ */
171
+ getLocation(content, start, length) {
172
+ const end = start + length;
173
+ const lines = content.substring(0, start).split('\n');
174
+ const line = lines.length;
175
+ const column = lines[lines.length - 1].length + 1;
176
+ return { start, end, line, column };
177
+ }
178
+ /**
179
+ * Truncate match for display
180
+ */
181
+ truncateMatch(match, maxLength = 100) {
182
+ if (match.length <= maxLength)
183
+ return match;
184
+ return match.substring(0, maxLength) + '...';
185
+ }
186
+ /**
187
+ * Truncate URL for display (hide potential sensitive parts)
188
+ */
189
+ truncateURL(url, maxLength = 80) {
190
+ try {
191
+ const parsed = new URL(url);
192
+ const base = `${parsed.protocol}//${parsed.host}`;
193
+ if (base.length >= maxLength) {
194
+ return base.substring(0, maxLength) + '...';
195
+ }
196
+ const remainingLength = maxLength - base.length;
197
+ const path = parsed.pathname + parsed.search;
198
+ if (path.length > remainingLength) {
199
+ return base + path.substring(0, remainingLength) + '...';
200
+ }
201
+ return base + path;
202
+ }
203
+ catch {
204
+ return url.substring(0, maxLength) + (url.length > maxLength ? '...' : '');
205
+ }
206
+ }
207
+ /**
208
+ * Get remediation suggestion
209
+ */
210
+ getSuggestion(ruleId) {
211
+ const suggestions = {
212
+ suspicious_url_post: 'This code sends data to a service commonly used for data capture. Verify the destination.',
213
+ dns_exfiltration: 'DNS queries with encoded data can be used for exfiltration. Monitor and restrict DNS access.',
214
+ data_encoding_suspicious: 'Encoding sensitive data before transmission may indicate exfiltration. Review the purpose.',
215
+ };
216
+ return suggestions[ruleId] || 'Review this pattern for potential data exfiltration.';
217
+ }
218
+ }
219
+ export default ExfiltrationDetector;
220
+ //# sourceMappingURL=exfiltration-detector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exfiltration-detector.js","sourceRoot":"","sources":["../../src/analyzers/exfiltration-detector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAEzD,MAAM,OAAO,oBAAoB;IAC/B,IAAI,GAAG,sBAAsB,CAAC;IAC9B,IAAI,GAAG,cAAc,CAAC;IAEtB,KAAK,CAAC,OAAO,CAAC,OAAe,EAAE,KAAsB;QACnD,MAAM,MAAM,GAAoB,EAAE,CAAC;QACnC,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,cAAc,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC;QAE7E,0BAA0B;QAC1B,KAAK,MAAM,IAAI,IAAI,UAAU,EAAE,CAAC;YAC9B,IAAI,CAAC,IAAI,CAAC,OAAO;gBAAE,SAAS;YAE5B,IAAI,CAAC;gBACH,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;gBAC7C,IAAI,KAA6B,CAAC;gBAElC,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;oBAC9C,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;oBAC3B,MAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;oBAE1E,MAAM,CAAC,IAAI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AC,CAAC,EAAE,CAAC,CAAC;QAC7E,CAAC;IACH,CAAC;IAED;;OAEG;IACK,aAAa,CAAC,MAAc;QAClC,MAAM,WAAW,GAA2B;YAC1C,mBAAmB,EAAE,2FAA2F;YAChH,gBAAgB,EAAE,8FAA8F;YAChH,wBAAwB,EAAE,4FAA4F;SACvH,CAAC;QAEF,OAAO,WAAW,CAAC,MAAM,CAAC,IAAI,sDAAsD,CAAC;IACvF,CAAC;CACF;AAED,eAAe,oBAAoB,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Mund - The Guardian Protocol
3
+ * Analyzers Index - Exports all analyzer modules
4
+ */
5
+ export { SecretScanner } from './secret-scanner.js';
6
+ export { PIIDetector } from './pii-detector.js';
7
+ export { CodeAnalyzer } from './code-analyzer.js';
8
+ export { InjectionDetector } from './injection-detector.js';
9
+ export { ExfiltrationDetector } from './exfiltration-detector.js';
10
+ import type { IAnalyzer } from '../types.js';
11
+ /**
12
+ * Get all available analyzers
13
+ */
14
+ export declare function getAnalyzers(): IAnalyzer[];
15
+ /**
16
+ * Create analyzer engine that runs all analyzers
17
+ */
18
+ export declare class AnalyzerEngine {
19
+ private analyzers;
20
+ constructor(analyzers?: IAnalyzer[]);
21
+ analyzeAll(content: string, rules: import('../types.js').DetectionRule[]): Promise<import('../types.js').SecurityIssue[]>;
22
+ addAnalyzer(analyzer: IAnalyzer): void;
23
+ removeAnalyzer(name: string): void;
24
+ getAnalyzerNames(): string[];
25
+ }
26
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/analyzers/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAOlE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;GAEG;AACH,wBAAgB,YAAY,IAAI,SAAS,EAAE,CAQ1C;AAED;;GAEG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,SAAS,CAAc;gBAEnB,SAAS,CAAC,EAAE,SAAS,EAAE;IAI7B,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,aAAa,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,OAAO,aAAa,EAAE,aAAa,EAAE,CAAC;IAqB/H,WAAW,CAAC,QAAQ,EAAE,SAAS,GAAG,IAAI;IAItC,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAIlC,gBAAgB,IAAI,MAAM,EAAE;CAG7B"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Mund - The Guardian Protocol
3
+ * Analyzers Index - Exports all analyzer modules
4
+ */
5
+ export { SecretScanner } from './secret-scanner.js';
6
+ export { PIIDetector } from './pii-detector.js';
7
+ export { CodeAnalyzer } from './code-analyzer.js';
8
+ export { InjectionDetector } from './injection-detector.js';
9
+ export { ExfiltrationDetector } from './exfiltration-detector.js';
10
+ import { SecretScanner } from './secret-scanner.js';
11
+ import { PIIDetector } from './pii-detector.js';
12
+ import { CodeAnalyzer } from './code-analyzer.js';
13
+ import { InjectionDetector } from './injection-detector.js';
14
+ import { ExfiltrationDetector } from './exfiltration-detector.js';
15
+ /**
16
+ * Get all available analyzers
17
+ */
18
+ export function getAnalyzers() {
19
+ return [
20
+ new SecretScanner(),
21
+ new PIIDetector(),
22
+ new CodeAnalyzer(),
23
+ new InjectionDetector(),
24
+ new ExfiltrationDetector()
25
+ ];
26
+ }
27
+ /**
28
+ * Create analyzer engine that runs all analyzers
29
+ */
30
+ export class AnalyzerEngine {
31
+ analyzers;
32
+ constructor(analyzers) {
33
+ this.analyzers = analyzers || getAnalyzers();
34
+ }
35
+ async analyzeAll(content, rules) {
36
+ const allIssues = [];
37
+ for (const analyzer of this.analyzers) {
38
+ try {
39
+ const issues = await analyzer.analyze(content, rules);
40
+ allIssues.push(...issues);
41
+ }
42
+ catch (error) {
43
+ console.error(`Error in analyzer ${analyzer.name}:`, error);
44
+ }
45
+ }
46
+ // Sort by severity (critical first)
47
+ const severityOrder = { critical: 0, high: 1, medium: 2, low: 3, info: 4 };
48
+ allIssues.sort((a, b) => (severityOrder[a.severity] || 4) - (severityOrder[b.severity] || 4));
49
+ return allIssues;
50
+ }
51
+ addAnalyzer(analyzer) {
52
+ this.analyzers.push(analyzer);
53
+ }
54
+ removeAnalyzer(name) {
55
+ this.analyzers = this.analyzers.filter(a => a.name !== name);
56
+ }
57
+ getAnalyzerNames() {
58
+ return this.analyzers.map(a => a.name);
59
+ }
60
+ }
61
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/analyzers/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAGlE;;GAEG;AACH,MAA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QAC7B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;IAED,cAAc,CAAC,IAAY;QACzB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IAC/D,CAAC;IAED,gBAAgB;QACd,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;CACF"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Mund - The Guardian Protocol
3
+ * Injection Detector - Detects prompt injection attempts
4
+ */
5
+ import { type DetectionRule, type SecurityIssue, type IAnalyzer } from '../types.js';
6
+ export declare class InjectionDetector implements IAnalyzer {
7
+ name: string;
8
+ type: string;
9
+ analyze(content: string, rules: DetectionRule[]): Promise<SecurityIssue[]>;
10
+ /**
11
+ * Normalize content to detect obfuscated injection attempts
12
+ */
13
+ private normalizeContent;
14
+ /**
15
+ * Heuristic analysis for injection patterns
16
+ */
17
+ private heuristicAnalysis;
18
+ /**
19
+ * Calculate ratio of special characters
20
+ */
21
+ private calculateSpecialCharRatio;
22
+ /**
23
+ * Calculate location within content
24
+ */
25
+ private getLocation;
26
+ /**
27
+ * Sanitize match for safe display
28
+ */
29
+ private sanitizeMatch;
30
+ /**
31
+ * Get remediation suggestion
32
+ */
33
+ private getSuggestion;
34
+ }
35
+ export default InjectionDetector;
36
+ //# sourceMappingURL=injection-detector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"injection-detector.d.ts","sourceRoot":"","sources":["../../src/analyzers/injection-detector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,SAAS,EAEf,MAAM,aAAa,CAAC;AAErB,qBAAa,iBAAkB,YAAW,SAAS;IACjD,IAAI,SAAuB;IAC3B,IAAI,SAAe;IAEb,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAyChF;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAYxB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAmEzB;;OAEG;IACH,OAAO,CAAC,yBAAyB;IAMjC;;OAEG;IACH,OAAO,CAAC,WAAW;IAQnB;;OAEG;IACH,OAAO,CAAC,aAAa;IAUrB;;OAEG;IACH,OAAO,CAAC,aAAa;CAUtB;AAED,eAAe,iBAAiB,CAAC"}