@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.
- package/dist/analyzers/code-analyzer.d.ts +24 -0
- package/dist/analyzers/code-analyzer.d.ts.map +1 -0
- package/dist/analyzers/code-analyzer.js +73 -0
- package/dist/analyzers/code-analyzer.js.map +1 -0
- package/dist/analyzers/exfiltration-detector.d.ts +40 -0
- package/dist/analyzers/exfiltration-detector.d.ts.map +1 -0
- package/dist/analyzers/exfiltration-detector.js +220 -0
- package/dist/analyzers/exfiltration-detector.js.map +1 -0
- package/dist/analyzers/index.d.ts +26 -0
- package/dist/analyzers/index.d.ts.map +1 -0
- package/dist/analyzers/index.js +61 -0
- package/dist/analyzers/index.js.map +1 -0
- package/dist/analyzers/injection-detector.d.ts +36 -0
- package/dist/analyzers/injection-detector.d.ts.map +1 -0
- package/dist/analyzers/injection-detector.js +165 -0
- package/dist/analyzers/injection-detector.js.map +1 -0
- package/dist/analyzers/pii-detector.d.ts +44 -0
- package/dist/analyzers/pii-detector.d.ts.map +1 -0
- package/dist/analyzers/pii-detector.js +190 -0
- package/dist/analyzers/pii-detector.js.map +1 -0
- package/dist/analyzers/secret-scanner.d.ts +32 -0
- package/dist/analyzers/secret-scanner.d.ts.map +1 -0
- package/dist/analyzers/secret-scanner.js +119 -0
- package/dist/analyzers/secret-scanner.js.map +1 -0
- package/dist/constants.d.ts +18 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +580 -0
- package/dist/constants.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +242 -0
- package/dist/index.js.map +1 -0
- package/dist/notifications/email.d.ts +18 -0
- package/dist/notifications/email.d.ts.map +1 -0
- package/dist/notifications/email.js +192 -0
- package/dist/notifications/email.js.map +1 -0
- package/dist/notifications/index.d.ts +51 -0
- package/dist/notifications/index.d.ts.map +1 -0
- package/dist/notifications/index.js +107 -0
- package/dist/notifications/index.js.map +1 -0
- package/dist/notifications/slack.d.ts +17 -0
- package/dist/notifications/slack.d.ts.map +1 -0
- package/dist/notifications/slack.js +128 -0
- package/dist/notifications/slack.js.map +1 -0
- package/dist/notifications/teams.d.ts +17 -0
- package/dist/notifications/teams.d.ts.map +1 -0
- package/dist/notifications/teams.js +136 -0
- package/dist/notifications/teams.js.map +1 -0
- package/dist/notifications/webhook.d.ts +15 -0
- package/dist/notifications/webhook.d.ts.map +1 -0
- package/dist/notifications/webhook.js +67 -0
- package/dist/notifications/webhook.js.map +1 -0
- package/dist/storage/index.d.ts +11 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +26 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/memory.d.ts +35 -0
- package/dist/storage/memory.d.ts.map +1 -0
- package/dist/storage/memory.js +144 -0
- package/dist/storage/memory.js.map +1 -0
- package/dist/tools/configuration.d.ts +8 -0
- package/dist/tools/configuration.d.ts.map +1 -0
- package/dist/tools/configuration.js +399 -0
- package/dist/tools/configuration.js.map +1 -0
- package/dist/tools/index.d.ts +15 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +16 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/monitoring.d.ts +10 -0
- package/dist/tools/monitoring.d.ts.map +1 -0
- package/dist/tools/monitoring.js +476 -0
- package/dist/tools/monitoring.js.map +1 -0
- package/dist/types.d.ts +207 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/package.json +62 -0
- package/rules/default.yaml +189 -0
- package/src/analyzers/code-analyzer.ts +88 -0
- package/src/analyzers/exfiltration-detector.ts +257 -0
- package/src/analyzers/index.ts +74 -0
- package/src/analyzers/injection-detector.ts +191 -0
- package/src/analyzers/pii-detector.ts +220 -0
- package/src/analyzers/secret-scanner.ts +142 -0
- package/src/constants.ts +603 -0
- package/src/index.ts +285 -0
- package/src/notifications/email.ts +211 -0
- package/src/notifications/index.ts +136 -0
- package/src/notifications/slack.ts +170 -0
- package/src/notifications/teams.ts +200 -0
- package/src/notifications/webhook.ts +80 -0
- package/src/storage/index.ts +29 -0
- package/src/storage/memory.ts +181 -0
- package/src/tools/configuration.ts +478 -0
- package/src/tools/index.ts +29 -0
- package/src/tools/monitoring.ts +559 -0
- package/src/types.ts +300 -0
- package/tsconfig.json +24 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mund - The Guardian Protocol
|
|
3
|
+
* Core type definitions
|
|
4
|
+
*/
|
|
5
|
+
export type Severity = 'critical' | 'high' | 'medium' | 'low' | 'info';
|
|
6
|
+
export type ActionType = 'alert' | 'block' | 'log' | 'quarantine' | 'redact' | 'none';
|
|
7
|
+
export type DetectorType = 'secret' | 'pii' | 'code_pattern' | 'injection' | 'exfiltration' | 'behavioral' | 'custom';
|
|
8
|
+
export interface DetectionRule {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
type: string;
|
|
13
|
+
pattern?: string;
|
|
14
|
+
condition?: string;
|
|
15
|
+
severity: Severity;
|
|
16
|
+
action: ActionType;
|
|
17
|
+
enabled: boolean;
|
|
18
|
+
metadata?: Record<string, unknown>;
|
|
19
|
+
}
|
|
20
|
+
export interface SecretRule extends DetectionRule {
|
|
21
|
+
type: 'secret';
|
|
22
|
+
pattern: string;
|
|
23
|
+
entropy_threshold?: number;
|
|
24
|
+
}
|
|
25
|
+
export interface BehavioralRule extends DetectionRule {
|
|
26
|
+
type: 'behavioral';
|
|
27
|
+
condition: string;
|
|
28
|
+
time_window_seconds: number;
|
|
29
|
+
threshold: number;
|
|
30
|
+
}
|
|
31
|
+
export interface SecurityEvent {
|
|
32
|
+
id: string;
|
|
33
|
+
timestamp: Date;
|
|
34
|
+
rule_id: string;
|
|
35
|
+
rule_name: string;
|
|
36
|
+
severity: Severity;
|
|
37
|
+
type: string;
|
|
38
|
+
action_taken: ActionType;
|
|
39
|
+
content_snippet: string;
|
|
40
|
+
full_content_hash: string;
|
|
41
|
+
context: EventContext;
|
|
42
|
+
acknowledged: boolean;
|
|
43
|
+
acknowledged_by?: string;
|
|
44
|
+
acknowledged_at?: Date;
|
|
45
|
+
metadata?: Record<string, unknown>;
|
|
46
|
+
}
|
|
47
|
+
export interface EventContext {
|
|
48
|
+
tool_name?: string;
|
|
49
|
+
tool_args?: Record<string, unknown>;
|
|
50
|
+
source?: string;
|
|
51
|
+
agent_id?: string;
|
|
52
|
+
session_id?: string;
|
|
53
|
+
user_id?: string;
|
|
54
|
+
ip_address?: string;
|
|
55
|
+
}
|
|
56
|
+
export interface ScanResult {
|
|
57
|
+
id: string;
|
|
58
|
+
timestamp: Date;
|
|
59
|
+
content_hash: string;
|
|
60
|
+
issues: SecurityIssue[];
|
|
61
|
+
scan_duration_ms: number;
|
|
62
|
+
rules_checked: number;
|
|
63
|
+
}
|
|
64
|
+
export interface SecurityIssue {
|
|
65
|
+
rule_id: string;
|
|
66
|
+
rule_name: string;
|
|
67
|
+
type: string;
|
|
68
|
+
severity: Severity;
|
|
69
|
+
action: ActionType;
|
|
70
|
+
match: string;
|
|
71
|
+
location?: IssueLocation;
|
|
72
|
+
suggestion?: string;
|
|
73
|
+
}
|
|
74
|
+
export interface IssueLocation {
|
|
75
|
+
start: number;
|
|
76
|
+
end: number;
|
|
77
|
+
line?: number;
|
|
78
|
+
column?: number;
|
|
79
|
+
}
|
|
80
|
+
export interface MundConfig {
|
|
81
|
+
port: number;
|
|
82
|
+
host: string;
|
|
83
|
+
transport: 'stdio' | 'http';
|
|
84
|
+
log_level: 'debug' | 'info' | 'warn' | 'error';
|
|
85
|
+
storage_type: 'memory' | 'sqlite' | 'postgres';
|
|
86
|
+
database_url?: string;
|
|
87
|
+
block_mode: boolean;
|
|
88
|
+
api_key?: string;
|
|
89
|
+
notifications: NotificationConfig;
|
|
90
|
+
rules_path?: string;
|
|
91
|
+
custom_rules?: DetectionRule[];
|
|
92
|
+
}
|
|
93
|
+
export interface NotificationConfig {
|
|
94
|
+
slack?: SlackConfig;
|
|
95
|
+
teams?: TeamsConfig;
|
|
96
|
+
email?: EmailConfig;
|
|
97
|
+
webhooks?: WebhookConfig[];
|
|
98
|
+
}
|
|
99
|
+
export interface SlackConfig {
|
|
100
|
+
webhook_url: string;
|
|
101
|
+
channel?: string;
|
|
102
|
+
username?: string;
|
|
103
|
+
icon_emoji?: string;
|
|
104
|
+
min_severity?: Severity;
|
|
105
|
+
}
|
|
106
|
+
export interface TeamsConfig {
|
|
107
|
+
webhook_url: string;
|
|
108
|
+
min_severity?: Severity;
|
|
109
|
+
}
|
|
110
|
+
export interface EmailConfig {
|
|
111
|
+
smtp_host: string;
|
|
112
|
+
smtp_port: number;
|
|
113
|
+
smtp_secure: boolean;
|
|
114
|
+
smtp_user?: string;
|
|
115
|
+
smtp_pass?: string;
|
|
116
|
+
from_address: string;
|
|
117
|
+
to_addresses: string[];
|
|
118
|
+
min_severity?: Severity;
|
|
119
|
+
}
|
|
120
|
+
export interface WebhookConfig {
|
|
121
|
+
url: string;
|
|
122
|
+
method: 'POST' | 'PUT';
|
|
123
|
+
headers?: Record<string, string>;
|
|
124
|
+
min_severity?: Severity;
|
|
125
|
+
}
|
|
126
|
+
export interface NotificationPayload {
|
|
127
|
+
event: SecurityEvent;
|
|
128
|
+
config: MundConfig;
|
|
129
|
+
formatted_message: string;
|
|
130
|
+
}
|
|
131
|
+
export interface ApiResponse<T> {
|
|
132
|
+
success: boolean;
|
|
133
|
+
data?: T;
|
|
134
|
+
error?: string;
|
|
135
|
+
timestamp: Date;
|
|
136
|
+
}
|
|
137
|
+
export interface PaginatedResponse<T> extends ApiResponse<T[]> {
|
|
138
|
+
total: number;
|
|
139
|
+
offset: number;
|
|
140
|
+
limit: number;
|
|
141
|
+
has_more: boolean;
|
|
142
|
+
}
|
|
143
|
+
export interface ScanContentInput {
|
|
144
|
+
content: string;
|
|
145
|
+
content_type?: 'text' | 'code' | 'json' | 'yaml';
|
|
146
|
+
context?: EventContext;
|
|
147
|
+
}
|
|
148
|
+
export interface CheckUrlInput {
|
|
149
|
+
url: string;
|
|
150
|
+
context?: EventContext;
|
|
151
|
+
}
|
|
152
|
+
export interface ValidateCommandInput {
|
|
153
|
+
command: string;
|
|
154
|
+
context?: EventContext;
|
|
155
|
+
}
|
|
156
|
+
export interface GetEventsInput {
|
|
157
|
+
limit?: number;
|
|
158
|
+
offset?: number;
|
|
159
|
+
severity?: Severity;
|
|
160
|
+
type?: DetectorType;
|
|
161
|
+
start_time?: Date;
|
|
162
|
+
end_time?: Date;
|
|
163
|
+
acknowledged?: boolean;
|
|
164
|
+
}
|
|
165
|
+
export interface AddRuleInput {
|
|
166
|
+
id: string;
|
|
167
|
+
name: string;
|
|
168
|
+
description?: string;
|
|
169
|
+
type: string;
|
|
170
|
+
pattern?: string;
|
|
171
|
+
condition?: string;
|
|
172
|
+
severity: Severity;
|
|
173
|
+
action: ActionType;
|
|
174
|
+
metadata?: Record<string, unknown>;
|
|
175
|
+
}
|
|
176
|
+
export interface ConfigureNotificationInput {
|
|
177
|
+
type: 'slack' | 'teams' | 'email' | 'webhook';
|
|
178
|
+
config: SlackConfig | TeamsConfig | EmailConfig | WebhookConfig;
|
|
179
|
+
}
|
|
180
|
+
export interface IStorage {
|
|
181
|
+
saveEvent(event: SecurityEvent): Promise<void>;
|
|
182
|
+
getEvent(id: string): Promise<SecurityEvent | null>;
|
|
183
|
+
getEvents(query: GetEventsInput): Promise<SecurityEvent[]>;
|
|
184
|
+
countEvents(query: GetEventsInput): Promise<number>;
|
|
185
|
+
acknowledgeEvent(id: string, by?: string): Promise<void>;
|
|
186
|
+
saveRule(rule: DetectionRule): Promise<void>;
|
|
187
|
+
getRule(id: string): Promise<DetectionRule | null>;
|
|
188
|
+
getRules(): Promise<DetectionRule[]>;
|
|
189
|
+
deleteRule(id: string): Promise<void>;
|
|
190
|
+
addToAllowlist(pattern: string, type: DetectorType): Promise<void>;
|
|
191
|
+
addToBlocklist(pattern: string, type: DetectorType): Promise<void>;
|
|
192
|
+
getAllowlist(type?: DetectorType): Promise<string[]>;
|
|
193
|
+
getBlocklist(type?: DetectorType): Promise<string[]>;
|
|
194
|
+
removeFromAllowlist(pattern: string): Promise<void>;
|
|
195
|
+
removeFromBlocklist(pattern: string): Promise<void>;
|
|
196
|
+
close(): Promise<void>;
|
|
197
|
+
}
|
|
198
|
+
export interface IAnalyzer {
|
|
199
|
+
name: string;
|
|
200
|
+
type: string;
|
|
201
|
+
analyze(content: string, rules: DetectionRule[]): Promise<SecurityIssue[]>;
|
|
202
|
+
}
|
|
203
|
+
export interface INotifier {
|
|
204
|
+
name: string;
|
|
205
|
+
send(payload: NotificationPayload): Promise<boolean>;
|
|
206
|
+
}
|
|
207
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,MAAM,MAAM,QAAQ,GAAG,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAC;AAEvE,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG,KAAK,GAAG,YAAY,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEtF,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,KAAK,GAAG,cAAc,GAAG,WAAW,GAAG,cAAc,GAAG,YAAY,GAAG,QAAQ,CAAC;AAOtH,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;IACnB,MAAM,EAAE,UAA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,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpD,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAGpD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAMD,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;CAC5E;AAMD,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACtD"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@weave_protocol/mund",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "The Guardian Protocol - MCP-based security monitoring for agentic AI systems",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"mund-mcp": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"start": "node dist/index.js",
|
|
13
|
+
"dev": "tsx watch src/index.ts",
|
|
14
|
+
"lint": "eslint src/**/*.ts",
|
|
15
|
+
"test": "vitest",
|
|
16
|
+
"prepublishOnly": "npm run build"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"mcp",
|
|
20
|
+
"ai",
|
|
21
|
+
"security",
|
|
22
|
+
"monitoring",
|
|
23
|
+
"agent",
|
|
24
|
+
"claude",
|
|
25
|
+
"llm",
|
|
26
|
+
"guardian",
|
|
27
|
+
"secrets",
|
|
28
|
+
"scanning"
|
|
29
|
+
],
|
|
30
|
+
"author": "",
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "https://github.com/your-org/mund-mcp.git"
|
|
35
|
+
},
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=20.0.0"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
41
|
+
"express": "^4.21.0",
|
|
42
|
+
"zod": "^3.23.8",
|
|
43
|
+
"yaml": "^2.5.0",
|
|
44
|
+
"better-sqlite3": "^11.3.0",
|
|
45
|
+
"nodemailer": "^6.9.15",
|
|
46
|
+
"winston": "^3.14.2",
|
|
47
|
+
"uuid": "^10.0.0"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@types/better-sqlite3": "^7.6.11",
|
|
51
|
+
"@types/express": "^4.17.21",
|
|
52
|
+
"@types/node": "^22.5.5",
|
|
53
|
+
"@types/nodemailer": "^6.4.16",
|
|
54
|
+
"@types/uuid": "^10.0.0",
|
|
55
|
+
"tsx": "^4.19.1",
|
|
56
|
+
"typescript": "^5.6.2",
|
|
57
|
+
"vitest": "^2.1.1",
|
|
58
|
+
"@typescript-eslint/eslint-plugin": "^8.6.0",
|
|
59
|
+
"@typescript-eslint/parser": "^8.6.0",
|
|
60
|
+
"eslint": "^9.10.0"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# Mund Default Detection Rules
|
|
2
|
+
# Version: 1.0
|
|
3
|
+
#
|
|
4
|
+
# This file contains the default security detection rules for Mund.
|
|
5
|
+
# You can customize these rules or create your own rule files.
|
|
6
|
+
#
|
|
7
|
+
# Rule Structure:
|
|
8
|
+
# id: Unique identifier (lowercase, alphanumeric, underscores)
|
|
9
|
+
# name: Human-readable name
|
|
10
|
+
# description: What this rule detects
|
|
11
|
+
# type: secret | pii | code_pattern | injection | exfiltration | behavioral
|
|
12
|
+
# pattern: Regular expression (use single quotes to avoid escaping)
|
|
13
|
+
# severity: critical | high | medium | low | info
|
|
14
|
+
# action: alert | block | log | quarantine
|
|
15
|
+
# enabled: true | false
|
|
16
|
+
|
|
17
|
+
version: "1.0"
|
|
18
|
+
name: "Mund Default Rules"
|
|
19
|
+
|
|
20
|
+
secrets:
|
|
21
|
+
# Cloud Provider Keys
|
|
22
|
+
- id: aws_access_key_id
|
|
23
|
+
name: "AWS Access Key ID"
|
|
24
|
+
description: "Amazon Web Services access key identifier"
|
|
25
|
+
type: secret
|
|
26
|
+
pattern: '(?<![A-Z0-9])AKIA[0-9A-Z]{16}(?![A-Z0-9])'
|
|
27
|
+
severity: critical
|
|
28
|
+
action: alert
|
|
29
|
+
enabled: true
|
|
30
|
+
|
|
31
|
+
- id: github_token
|
|
32
|
+
name: "GitHub Token"
|
|
33
|
+
description: "GitHub personal access token"
|
|
34
|
+
type: secret
|
|
35
|
+
pattern: 'gh[pousr]_[A-Za-z0-9_]{36,}'
|
|
36
|
+
severity: critical
|
|
37
|
+
action: alert
|
|
38
|
+
enabled: true
|
|
39
|
+
|
|
40
|
+
- id: openai_api_key
|
|
41
|
+
name: "OpenAI API Key"
|
|
42
|
+
description: "OpenAI API key"
|
|
43
|
+
type: secret
|
|
44
|
+
pattern: 'sk-[A-Za-z0-9]{20}T3BlbkFJ[A-Za-z0-9]{20}'
|
|
45
|
+
severity: critical
|
|
46
|
+
action: alert
|
|
47
|
+
enabled: true
|
|
48
|
+
|
|
49
|
+
- id: anthropic_api_key
|
|
50
|
+
name: "Anthropic API Key"
|
|
51
|
+
description: "Anthropic Claude API key"
|
|
52
|
+
type: secret
|
|
53
|
+
pattern: 'sk-ant-[A-Za-z0-9_-]{90,}'
|
|
54
|
+
severity: critical
|
|
55
|
+
action: alert
|
|
56
|
+
enabled: true
|
|
57
|
+
|
|
58
|
+
# Google/Gemini Keys
|
|
59
|
+
- id: gemini_api_key
|
|
60
|
+
name: "Gemini API Key"
|
|
61
|
+
description: "Google Gemini API key"
|
|
62
|
+
type: secret
|
|
63
|
+
pattern: '(?i)(GEMINI_API_KEY|GOOGLE_API_KEY)[\s]*[=:][\s]*["\']?AIza[0-9A-Za-z_-]{35}["\']?'
|
|
64
|
+
severity: critical
|
|
65
|
+
action: alert
|
|
66
|
+
enabled: true
|
|
67
|
+
|
|
68
|
+
- id: firebase_api_key
|
|
69
|
+
name: "Firebase/Google API Key"
|
|
70
|
+
description: "Firebase or Google Cloud API key"
|
|
71
|
+
type: secret
|
|
72
|
+
pattern: 'AIza[0-9A-Za-z_-]{35}'
|
|
73
|
+
severity: high
|
|
74
|
+
action: alert
|
|
75
|
+
enabled: true
|
|
76
|
+
|
|
77
|
+
- id: gcp_service_account
|
|
78
|
+
name: "GCP Service Account"
|
|
79
|
+
description: "Google Cloud service account JSON key"
|
|
80
|
+
type: secret
|
|
81
|
+
pattern: '"type"\s*:\s*"service_account"'
|
|
82
|
+
severity: critical
|
|
83
|
+
action: alert
|
|
84
|
+
enabled: true
|
|
85
|
+
|
|
86
|
+
- id: private_key
|
|
87
|
+
name: "Private Key"
|
|
88
|
+
description: "RSA, EC, DSA, or OpenSSH private key"
|
|
89
|
+
type: secret
|
|
90
|
+
pattern: '-----BEGIN (RSA |EC |DSA |OPENSSH )?PRIVATE KEY-----'
|
|
91
|
+
severity: critical
|
|
92
|
+
action: alert
|
|
93
|
+
enabled: true
|
|
94
|
+
|
|
95
|
+
- id: jwt_token
|
|
96
|
+
name: "JWT Token"
|
|
97
|
+
description: "JSON Web Token"
|
|
98
|
+
type: secret
|
|
99
|
+
pattern: 'eyJ[A-Za-z0-9_-]*\.eyJ[A-Za-z0-9_-]*\.[A-Za-z0-9_-]*'
|
|
100
|
+
severity: high
|
|
101
|
+
action: alert
|
|
102
|
+
enabled: true
|
|
103
|
+
|
|
104
|
+
pii:
|
|
105
|
+
- id: ssn_us
|
|
106
|
+
name: "US Social Security Number"
|
|
107
|
+
description: "US Social Security Number"
|
|
108
|
+
type: pii
|
|
109
|
+
pattern: '(?<!\d)\d{3}-\d{2}-\d{4}(?!\d)'
|
|
110
|
+
severity: high
|
|
111
|
+
action: alert
|
|
112
|
+
enabled: true
|
|
113
|
+
|
|
114
|
+
- id: credit_card
|
|
115
|
+
name: "Credit Card Number"
|
|
116
|
+
description: "Credit card number (major providers)"
|
|
117
|
+
type: pii
|
|
118
|
+
pattern: '(?<!\d)(4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|3[47][0-9]{13})(?!\d)'
|
|
119
|
+
severity: high
|
|
120
|
+
action: alert
|
|
121
|
+
enabled: true
|
|
122
|
+
|
|
123
|
+
code_patterns:
|
|
124
|
+
- id: rm_rf
|
|
125
|
+
name: "Recursive Force Delete"
|
|
126
|
+
description: "Potentially dangerous rm -rf command"
|
|
127
|
+
type: code_pattern
|
|
128
|
+
pattern: 'rm\s+-[rf]{1,2}\s+(/|\$|~|\.\.|\*)'
|
|
129
|
+
severity: high
|
|
130
|
+
action: alert
|
|
131
|
+
enabled: true
|
|
132
|
+
|
|
133
|
+
- id: curl_bash
|
|
134
|
+
name: "Curl to Bash"
|
|
135
|
+
description: "Piping curl output to bash"
|
|
136
|
+
type: code_pattern
|
|
137
|
+
pattern: 'curl\s+.*\|\s*(ba)?sh'
|
|
138
|
+
severity: high
|
|
139
|
+
action: alert
|
|
140
|
+
enabled: true
|
|
141
|
+
|
|
142
|
+
- id: disable_ssl_verify
|
|
143
|
+
name: "SSL Verification Disabled"
|
|
144
|
+
description: "Code that disables SSL certificate verification"
|
|
145
|
+
type: code_pattern
|
|
146
|
+
pattern: '(?i)(verify\s*=\s*False|rejectUnauthorized\s*:\s*false)'
|
|
147
|
+
severity: medium
|
|
148
|
+
action: alert
|
|
149
|
+
enabled: true
|
|
150
|
+
|
|
151
|
+
injection:
|
|
152
|
+
- id: prompt_injection_ignore
|
|
153
|
+
name: "Prompt Injection - Ignore Instructions"
|
|
154
|
+
description: "Attempts to make AI ignore previous instructions"
|
|
155
|
+
type: injection
|
|
156
|
+
pattern: '(?i)(ignore\s+(all\s+)?(previous|prior|above)\s+(instructions?|prompts?))'
|
|
157
|
+
severity: high
|
|
158
|
+
action: alert
|
|
159
|
+
enabled: true
|
|
160
|
+
|
|
161
|
+
- id: prompt_injection_jailbreak
|
|
162
|
+
name: "Prompt Injection - Jailbreak"
|
|
163
|
+
description: "Common jailbreak patterns"
|
|
164
|
+
type: injection
|
|
165
|
+
pattern: '(?i)(DAN\s+mode|do\s+anything\s+now|pretend\s+you\s+(are|have)\s+no\s+restrictions)'
|
|
166
|
+
severity: high
|
|
167
|
+
action: alert
|
|
168
|
+
enabled: true
|
|
169
|
+
|
|
170
|
+
exfiltration:
|
|
171
|
+
- id: suspicious_webhook
|
|
172
|
+
name: "Suspicious Webhook URL"
|
|
173
|
+
description: "POST to known data capture services"
|
|
174
|
+
type: exfiltration
|
|
175
|
+
pattern: '(?i)(fetch|axios|request|http\.post).*\b(ngrok|webhook\.site|requestbin)\b'
|
|
176
|
+
severity: high
|
|
177
|
+
action: alert
|
|
178
|
+
enabled: true
|
|
179
|
+
|
|
180
|
+
# Custom rules can be added below
|
|
181
|
+
# custom:
|
|
182
|
+
# - id: my_custom_rule
|
|
183
|
+
# name: "My Custom Rule"
|
|
184
|
+
# description: "Detects my company's internal secrets"
|
|
185
|
+
# type: secret
|
|
186
|
+
# pattern: 'mycompany_[a-zA-Z0-9]{32}'
|
|
187
|
+
# severity: critical
|
|
188
|
+
# action: alert
|
|
189
|
+
# enabled: true
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mund - The Guardian Protocol
|
|
3
|
+
* Code Analyzer - Detects dangerous code patterns
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
type DetectionRule,
|
|
8
|
+
type SecurityIssue,
|
|
9
|
+
type IAnalyzer,
|
|
10
|
+
type IssueLocation
|
|
11
|
+
} from '../types.js';
|
|
12
|
+
|
|
13
|
+
export class CodeAnalyzer implements IAnalyzer {
|
|
14
|
+
name = 'CodeAnalyzer';
|
|
15
|
+
type = 'code_pattern';
|
|
16
|
+
|
|
17
|
+
async analyze(content: string, rules: DetectionRule[]): Promise<SecurityIssue[]> {
|
|
18
|
+
const issues: SecurityIssue[] = [];
|
|
19
|
+
const codeRules = rules.filter(r => r.type === 'code_pattern' && r.enabled);
|
|
20
|
+
|
|
21
|
+
for (const rule of codeRules) {
|
|
22
|
+
if (!rule.pattern) continue;
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
const regex = new RegExp(rule.pattern, 'gm');
|
|
26
|
+
let match: RegExpExecArray | null;
|
|
27
|
+
|
|
28
|
+
while ((match = regex.exec(content)) !== null) {
|
|
29
|
+
const matchText = match[0];
|
|
30
|
+
const location = this.getLocation(content, match.index, matchText.length);
|
|
31
|
+
|
|
32
|
+
issues.push({
|
|
33
|
+
rule_id: rule.id,
|
|
34
|
+
rule_name: rule.name,
|
|
35
|
+
type: rule.type,
|
|
36
|
+
severity: rule.severity,
|
|
37
|
+
action: rule.action,
|
|
38
|
+
match: this.truncateMatch(matchText),
|
|
39
|
+
location,
|
|
40
|
+
suggestion: this.getSuggestion(rule.id, matchText)
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
} catch (error) {
|
|
44
|
+
console.error(`Invalid regex pattern in rule ${rule.id}:`, error);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return issues;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Calculate location within content
|
|
53
|
+
*/
|
|
54
|
+
private getLocation(content: string, start: number, length: number): IssueLocation {
|
|
55
|
+
const end = start + length;
|
|
56
|
+
const lines = content.substring(0, start).split('\n');
|
|
57
|
+
const line = lines.length;
|
|
58
|
+
const column = lines[lines.length - 1].length + 1;
|
|
59
|
+
return { start, end, line, column };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Truncate match for display
|
|
64
|
+
*/
|
|
65
|
+
private truncateMatch(match: string, maxLength = 100): string {
|
|
66
|
+
if (match.length <= maxLength) return match;
|
|
67
|
+
return match.substring(0, maxLength) + '...';
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Get context-aware suggestion
|
|
72
|
+
*/
|
|
73
|
+
private getSuggestion(ruleId: string, _match: string): string {
|
|
74
|
+
const suggestions: Record<string, string> = {
|
|
75
|
+
shell_injection: 'Avoid using string interpolation in shell commands. Use parameterized commands or escape inputs properly.',
|
|
76
|
+
sql_injection_pattern: 'Use parameterized queries or prepared statements instead of string concatenation for SQL.',
|
|
77
|
+
dangerous_chmod: 'Avoid overly permissive file permissions. Use the minimum required permissions (e.g., 644 for files, 755 for directories).',
|
|
78
|
+
rm_rf: 'Be extremely careful with recursive deletion. Consider using trash/recycle functionality instead.',
|
|
79
|
+
curl_bash: 'Piping curl to bash is dangerous. Download the script first, review it, then execute.',
|
|
80
|
+
base64_decode_exec: 'Decoding and executing arbitrary content is dangerous. Validate the source and content first.',
|
|
81
|
+
disable_ssl_verify: 'Disabling SSL verification exposes you to man-in-the-middle attacks. Fix certificate issues instead.',
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
return suggestions[ruleId] || 'Review this code pattern for potential security issues.';
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export default CodeAnalyzer;
|