@node9/policy-engine 2.37.1 → 2.39.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/index.d.mts +203 -15
- package/dist/index.d.ts +203 -15
- package/dist/index.js +1682 -441
- package/dist/index.mjs +1656 -440
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -30,9 +30,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
|
-
|
|
33
|
+
ACTION_CHECKS: () => ACTION_CHECKS,
|
|
34
|
+
ACTION_TEMPLATES: () => ACTION_TEMPLATES,
|
|
34
35
|
AGENT_INSTRUCTION_DIRS: () => AGENT_INSTRUCTION_DIRS,
|
|
35
36
|
AGENT_INSTRUCTION_FILES: () => AGENT_INSTRUCTION_FILES,
|
|
37
|
+
APP_SERVER_GLOB: () => APP_SERVER_GLOB,
|
|
38
|
+
APP_SHIELD_NAMES: () => APP_SHIELD_NAMES,
|
|
39
|
+
APP_SHIELD_SPECS: () => APP_SHIELD_SPECS,
|
|
36
40
|
ARGUMENT_SCAN_LIMITS: () => ARGUMENT_SCAN_LIMITS,
|
|
37
41
|
AST_FS_REGEX_RULES: () => AST_FS_REGEX_RULES,
|
|
38
42
|
BASH_TOOL_NAMES: () => BASH_TOOL_NAMES,
|
|
@@ -59,17 +63,21 @@ __export(src_exports, {
|
|
|
59
63
|
FILE_TOOLS: () => FILE_TOOLS,
|
|
60
64
|
FLAGS_WITH_VALUES: () => FLAGS_WITH_VALUES,
|
|
61
65
|
FS_READ_TOOLS: () => FS_READ_TOOLS,
|
|
66
|
+
GENERAL_ACTION_RULES: () => GENERAL_ACTION_RULES,
|
|
62
67
|
KNOB_GOVERNED: () => KNOB_GOVERNED,
|
|
68
|
+
LEVELS: () => LEVELS,
|
|
63
69
|
LONG_OUTPUT_THRESHOLD_BYTES: () => LONG_OUTPUT_THRESHOLD_BYTES,
|
|
64
70
|
LOOP_MAX_RECORDS: () => LOOP_MAX_RECORDS,
|
|
65
71
|
LOOP_THRESHOLD_FOR_WASTE: () => LOOP_THRESHOLD_FOR_WASTE,
|
|
66
72
|
MAP_GOVERNED: () => MAP_GOVERNED,
|
|
67
73
|
MAX_BLAST_PATH: () => MAX_BLAST_PATH,
|
|
68
74
|
MAX_DESTINATIONS: () => MAX_DESTINATIONS,
|
|
75
|
+
MODE_VALUES: () => MODE_VALUES,
|
|
69
76
|
NET_BINARIES: () => NET_BINARIES,
|
|
70
77
|
PATTERN_VERB_NAMES: () => PATTERN_VERB_NAMES,
|
|
71
78
|
PRIVILEGE_ESCALATION_RE: () => PRIVILEGE_ESCALATION_RE,
|
|
72
79
|
REALTIME_PII_PATTERNS: () => REALTIME_PII_PATTERNS,
|
|
80
|
+
REPLACED_SHIELDS: () => REPLACED_SHIELDS,
|
|
73
81
|
SCAN_SIGNAL_WEIGHTS: () => SCAN_SIGNAL_WEIGHTS,
|
|
74
82
|
SENSITIVE_PATH_RE: () => SENSITIVE_PATH_RE,
|
|
75
83
|
SENSITIVE_PATH_REGEXES: () => SENSITIVE_PATH_REGEXES,
|
|
@@ -130,6 +138,7 @@ __export(src_exports, {
|
|
|
130
138
|
extractShellDestTokens: () => extractShellDestTokens,
|
|
131
139
|
extractShellDestinations: () => extractShellDestinations,
|
|
132
140
|
extractToolDestinations: () => extractToolDestinations,
|
|
141
|
+
fileAccessView: () => fileAccessView,
|
|
133
142
|
fileOperandFlagsOf: () => fileOperandFlagsOf,
|
|
134
143
|
fileToolOperation: () => fileToolOperation,
|
|
135
144
|
foldHomoglyphs: () => foldHomoglyphs,
|
|
@@ -140,11 +149,15 @@ __export(src_exports, {
|
|
|
140
149
|
hashDestination: () => hashDestination,
|
|
141
150
|
hostMatches: () => hostMatches,
|
|
142
151
|
incompleteFileVerdict: () => incompleteFileVerdict,
|
|
152
|
+
inlineExecDescription: () => inlineExecDescription,
|
|
153
|
+
inlineExecReason: () => inlineExecReason,
|
|
154
|
+
inlineExecReview: () => inlineExecReview,
|
|
143
155
|
inspectArgumentSecrets: () => inspectArgumentSecrets,
|
|
144
156
|
inspectionEntry: () => inspectionEntry,
|
|
145
157
|
inspectionLayers: () => inspectionLayers,
|
|
146
158
|
isAgentInstructionPath: () => isAgentInstructionPath,
|
|
147
159
|
isBashTool: () => isBashTool,
|
|
160
|
+
isBlockAll: () => isBlockAll,
|
|
148
161
|
isDestructiveToolName: () => isDestructiveToolName,
|
|
149
162
|
isHashedEntry: () => isHashedEntry,
|
|
150
163
|
isIgnoredTool: () => isIgnoredTool,
|
|
@@ -154,13 +167,20 @@ __export(src_exports, {
|
|
|
154
167
|
isLockedCheck: () => isLockedCheck,
|
|
155
168
|
isLoopbackHost: () => isLoopbackHost,
|
|
156
169
|
isMaskedKind: () => isMaskedKind,
|
|
170
|
+
isModeValue: () => isModeValue,
|
|
157
171
|
isPasswordHashPath: () => isPasswordHashPath,
|
|
158
172
|
isPrivateHost: () => isPrivateHost,
|
|
159
173
|
isProtectedHomePath: () => isProtectedHomePath,
|
|
174
|
+
isRecordOnly: () => isRecordOnly,
|
|
160
175
|
isShellShapedTool: () => isShellShapedTool,
|
|
161
176
|
isShieldVerdict: () => isShieldVerdict,
|
|
162
177
|
isStrictGatedTier: () => isStrictGatedTier,
|
|
163
178
|
isVerdict: () => isVerdict,
|
|
179
|
+
knobStatedChecks: () => knobStatedChecks,
|
|
180
|
+
levelCheckValue: () => levelCheckValue,
|
|
181
|
+
levelChecks: () => levelChecks,
|
|
182
|
+
levelOf: () => levelOf,
|
|
183
|
+
levelPackageSignals: () => levelPackageSignals,
|
|
164
184
|
maskDestination: () => maskDestination,
|
|
165
185
|
maskPersonalData: () => maskPersonalData,
|
|
166
186
|
maskPersonalValue: () => maskPersonalValue,
|
|
@@ -170,6 +190,7 @@ __export(src_exports, {
|
|
|
170
190
|
matchesPattern: () => matchesPattern,
|
|
171
191
|
matchesTrustedEntry: () => matchesTrustedEntry,
|
|
172
192
|
matchesTrustedList: () => matchesTrustedList,
|
|
193
|
+
mcpServerFromToolName: () => mcpServerFromToolName,
|
|
173
194
|
narrativeRuleLabel: () => narrativeRuleLabel,
|
|
174
195
|
normalizeCommandForPolicy: () => normalizeCommandForPolicy,
|
|
175
196
|
normalizeDestination: () => normalizeDestination,
|
|
@@ -190,6 +211,8 @@ __export(src_exports, {
|
|
|
190
211
|
resolveCheckMap: () => resolveCheckMap,
|
|
191
212
|
resolvePinned: () => resolvePinned,
|
|
192
213
|
resolveShellInput: () => resolveShellInput,
|
|
214
|
+
reviewsEveryInline: () => reviewsEveryInline,
|
|
215
|
+
ruleServerMatches: () => ruleServerMatches,
|
|
193
216
|
safeMessage: () => safeMessage,
|
|
194
217
|
sampleCopyCommand: () => sampleCopyCommand,
|
|
195
218
|
scanArgs: () => scanArgs,
|
|
@@ -208,6 +231,7 @@ __export(src_exports, {
|
|
|
208
231
|
stripControlChars: () => stripControlChars,
|
|
209
232
|
stripInvisible: () => stripInvisible,
|
|
210
233
|
stripTerminalEscapes: () => stripTerminalEscapes,
|
|
234
|
+
suggestFromApprovals: () => suggestFromApprovals,
|
|
211
235
|
summarizeBlast: () => summarizeBlast,
|
|
212
236
|
summarizeScan: () => summarizeScan,
|
|
213
237
|
toScanFinding: () => toScanFinding,
|
|
@@ -217,6 +241,7 @@ __export(src_exports, {
|
|
|
217
241
|
tuningFromLegacyPolicy: () => tuningFromLegacyPolicy,
|
|
218
242
|
tuningToLegacyPolicy: () => tuningToLegacyPolicy,
|
|
219
243
|
unwrapCommandHead: () => unwrapCommandHead,
|
|
244
|
+
unwrapRuleLabel: () => unwrapRuleLabel,
|
|
220
245
|
validateOverrides: () => validateOverrides,
|
|
221
246
|
validateRegex: () => validateRegex,
|
|
222
247
|
validateShieldDefinition: () => validateShieldDefinition
|
|
@@ -226,8 +251,45 @@ module.exports = __toCommonJS(src_exports);
|
|
|
226
251
|
// src/files/protected-access.ts
|
|
227
252
|
var import_picomatch2 = __toESM(require("picomatch"));
|
|
228
253
|
|
|
229
|
-
// src/
|
|
254
|
+
// src/utils/regex.ts
|
|
230
255
|
var import_safe_regex2 = __toESM(require("safe-regex2"));
|
|
256
|
+
var MAX_REGEX_LENGTH = 256;
|
|
257
|
+
var REGEX_CACHE_MAX = 500;
|
|
258
|
+
var regexCache = /* @__PURE__ */ new Map();
|
|
259
|
+
function validateRegex(pattern) {
|
|
260
|
+
if (!pattern) return "Pattern is required";
|
|
261
|
+
if (pattern.length > MAX_REGEX_LENGTH) return `Pattern exceeds max length of ${MAX_REGEX_LENGTH}`;
|
|
262
|
+
try {
|
|
263
|
+
new RegExp(pattern);
|
|
264
|
+
} catch (e) {
|
|
265
|
+
return `Invalid regex syntax: ${e.message}`;
|
|
266
|
+
}
|
|
267
|
+
if (/\\\d+[*+{]/.test(pattern)) return "Quantified backreferences are forbidden (ReDoS risk)";
|
|
268
|
+
if (!(0, import_safe_regex2.default)(pattern)) return "Pattern rejected: potential ReDoS vulnerability detected";
|
|
269
|
+
return null;
|
|
270
|
+
}
|
|
271
|
+
function getCompiledRegex(pattern, flags = "") {
|
|
272
|
+
if (flags && !/^[gimsuy]+$/.test(flags)) return null;
|
|
273
|
+
const key = `${pattern}\0${flags}`;
|
|
274
|
+
if (regexCache.has(key)) {
|
|
275
|
+
const cached = regexCache.get(key);
|
|
276
|
+
regexCache.delete(key);
|
|
277
|
+
regexCache.set(key, cached);
|
|
278
|
+
return cached;
|
|
279
|
+
}
|
|
280
|
+
if (validateRegex(pattern) !== null) return null;
|
|
281
|
+
try {
|
|
282
|
+
const re = new RegExp(pattern, flags);
|
|
283
|
+
if (regexCache.size >= REGEX_CACHE_MAX) {
|
|
284
|
+
const oldest = regexCache.keys().next().value;
|
|
285
|
+
if (oldest) regexCache.delete(oldest);
|
|
286
|
+
}
|
|
287
|
+
regexCache.set(key, re);
|
|
288
|
+
return re;
|
|
289
|
+
} catch {
|
|
290
|
+
return null;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
231
293
|
|
|
232
294
|
// src/shields/builtin/aws.json
|
|
233
295
|
var aws_default = {
|
|
@@ -538,79 +600,6 @@ var filesystem_default = {
|
|
|
538
600
|
dangerousWords: ["wipefs"]
|
|
539
601
|
};
|
|
540
602
|
|
|
541
|
-
// src/shields/builtin/finance.json
|
|
542
|
-
var finance_default = {
|
|
543
|
-
name: "finance",
|
|
544
|
-
description: "Asks before money moves through a payment or banking app (refunds, payouts, transfers, charges, invoices), whatever the request said. Reads are never asked about.",
|
|
545
|
-
aliases: ["payments", "money"],
|
|
546
|
-
smartRules: [
|
|
547
|
-
{
|
|
548
|
-
name: "shield:finance:review-refund",
|
|
549
|
-
tool: "{,mcp__*__}{create_refund,refund_payment,refund_charge,refund_order,issue_refund}",
|
|
550
|
-
conditions: [],
|
|
551
|
-
verdict: "review",
|
|
552
|
-
reason: "A refund returns money to a customer. node9 asks before money moves, whatever the request said (Finance shield)."
|
|
553
|
-
},
|
|
554
|
-
{
|
|
555
|
-
name: "shield:finance:review-payout",
|
|
556
|
-
tool: "{,mcp__*__}{create_payout,send_payout,payout,create_payouts_batch}",
|
|
557
|
-
conditions: [],
|
|
558
|
-
verdict: "review",
|
|
559
|
-
reason: "A payout moves the balance to a bank account. node9 asks before money moves (Finance shield)."
|
|
560
|
-
},
|
|
561
|
-
{
|
|
562
|
-
name: "shield:finance:review-transfer",
|
|
563
|
-
tool: "{,mcp__*__}{transfer_create,transfer_authorization_create,create_transfer,transfer_money,transfer_funds,send_money,wire_transfer,create_wire,schedule_transaction,update_scheduled_transaction,create_transaction}",
|
|
564
|
-
conditions: [],
|
|
565
|
-
verdict: "review",
|
|
566
|
-
reason: "A transfer moves money between accounts. node9 asks before money moves (Finance shield)."
|
|
567
|
-
},
|
|
568
|
-
{
|
|
569
|
-
name: "shield:finance:review-charge",
|
|
570
|
-
tool: "{,mcp__*__}{create_payment_intent,confirm_payment_intent,capture_payment_intent,create_charge,create_payment,capture_payment,capture_order,create_order,authorize_order,create_checkout_session}",
|
|
571
|
-
conditions: [],
|
|
572
|
-
verdict: "review",
|
|
573
|
-
reason: "This charges a card or captures a payment. node9 asks before money moves (Finance shield)."
|
|
574
|
-
},
|
|
575
|
-
{
|
|
576
|
-
name: "shield:finance:review-payment-link",
|
|
577
|
-
tool: "{,mcp__*__}{create_payment_link,create_invoice,finalize_invoice,send_invoice,pay_invoice,create_invoice_item}",
|
|
578
|
-
conditions: [],
|
|
579
|
-
verdict: "review",
|
|
580
|
-
reason: "This bills someone or creates a link that charges a card. node9 asks before money moves (Finance shield)."
|
|
581
|
-
},
|
|
582
|
-
{
|
|
583
|
-
name: "shield:finance:review-subscription",
|
|
584
|
-
tool: "{,mcp__*__}{create_subscription,cancel_subscription,update_subscription,pause_subscription,resume_subscription}",
|
|
585
|
-
conditions: [],
|
|
586
|
-
verdict: "review",
|
|
587
|
-
reason: "A subscription starts or stops recurring charges. node9 asks before money moves (Finance shield)."
|
|
588
|
-
},
|
|
589
|
-
{
|
|
590
|
-
name: "shield:finance:review-dispute",
|
|
591
|
-
tool: "{,mcp__*__}{update_dispute,accept_dispute,close_dispute}",
|
|
592
|
-
conditions: [],
|
|
593
|
-
verdict: "review",
|
|
594
|
-
reason: "This answers or concedes a chargeback. node9 asks before money moves (Finance shield)."
|
|
595
|
-
},
|
|
596
|
-
{
|
|
597
|
-
name: "shield:finance:review-card",
|
|
598
|
-
tool: "{,mcp__*__}{issue_card,create_virtual_card,create_issuing_card,update_card_limit}",
|
|
599
|
-
conditions: [],
|
|
600
|
-
verdict: "review",
|
|
601
|
-
reason: "This issues a card or changes its limit. node9 asks before money moves (Finance shield)."
|
|
602
|
-
},
|
|
603
|
-
{
|
|
604
|
-
name: "shield:finance:review-withdraw",
|
|
605
|
-
tool: "{,mcp__*__}{withdraw,withdraw_funds,create_withdrawal,request_withdrawal}",
|
|
606
|
-
conditions: [],
|
|
607
|
-
verdict: "review",
|
|
608
|
-
reason: "A withdrawal moves money out. node9 asks before money moves (Finance shield)."
|
|
609
|
-
}
|
|
610
|
-
],
|
|
611
|
-
dangerousWords: []
|
|
612
|
-
};
|
|
613
|
-
|
|
614
603
|
// src/shields/builtin/github.json
|
|
615
604
|
var github_default = {
|
|
616
605
|
name: "github",
|
|
@@ -639,58 +628,6 @@ var github_default = {
|
|
|
639
628
|
dangerousWords: []
|
|
640
629
|
};
|
|
641
630
|
|
|
642
|
-
// src/shields/builtin/identity.json
|
|
643
|
-
var identity_default = {
|
|
644
|
-
name: "identity",
|
|
645
|
-
description: "Asks before a password, a key, a token, a role or a user changes in an identity or admin app, whatever the request said. Reads are never asked about.",
|
|
646
|
-
aliases: ["access", "iam"],
|
|
647
|
-
smartRules: [
|
|
648
|
-
{
|
|
649
|
-
name: "shield:identity:review-password",
|
|
650
|
-
tool: "{,mcp__*__}{change_password,update_password,reset_password,set_password,expire_password,force_password_reset}",
|
|
651
|
-
conditions: [],
|
|
652
|
-
verdict: "review",
|
|
653
|
-
reason: "This changes or resets a password. node9 asks before credentials change, whatever the request said (Identity shield)."
|
|
654
|
-
},
|
|
655
|
-
{
|
|
656
|
-
name: "shield:identity:review-key",
|
|
657
|
-
tool: "{,mcp__*__}{rotate_key,rotate_api_key,create_api_key,create_token,create_access_token,create_personal_access_token,regenerate_secret,rotate_secret,create_service_account_key,create_credential}",
|
|
658
|
-
conditions: [],
|
|
659
|
-
verdict: "review",
|
|
660
|
-
reason: "This creates or rotates a key, token or secret. node9 asks before credentials change (Identity shield)."
|
|
661
|
-
},
|
|
662
|
-
{
|
|
663
|
-
name: "shield:identity:review-access",
|
|
664
|
-
tool: "{,mcp__*__}{grant_access,grant_permission,grant_role,revoke_access,revoke_permission,revoke_role,revoke_token,set_permission,set_permissions,set_role,assign_role,update_role,add_permission,remove_permission,attach_policy,detach_policy}",
|
|
665
|
-
conditions: [],
|
|
666
|
-
verdict: "review",
|
|
667
|
-
reason: "This grants or revokes access. node9 asks before access changes (Identity shield)."
|
|
668
|
-
},
|
|
669
|
-
{
|
|
670
|
-
name: "shield:identity:review-membership",
|
|
671
|
-
tool: "{,mcp__*__}{add_member,remove_member,add_user_to_group,remove_user_from_group,add_collaborator,remove_collaborator,invite_user,invite_member,invite_user_to_slack,invite_users,add_org_member,remove_org_member,add_team_member,remove_team_member}",
|
|
672
|
-
conditions: [],
|
|
673
|
-
verdict: "review",
|
|
674
|
-
reason: "This changes who belongs where. node9 asks before membership changes (Identity shield)."
|
|
675
|
-
},
|
|
676
|
-
{
|
|
677
|
-
name: "shield:identity:review-user",
|
|
678
|
-
tool: "{,mcp__*__}{create_user,delete_user,deactivate_user,suspend_user,activate_user,unlock_user,make_admin,promote_user,demote_user,update_user_role}",
|
|
679
|
-
conditions: [],
|
|
680
|
-
verdict: "review",
|
|
681
|
-
reason: "This creates, removes or promotes an account. node9 asks before accounts change (Identity shield)."
|
|
682
|
-
},
|
|
683
|
-
{
|
|
684
|
-
name: "shield:identity:review-mfa",
|
|
685
|
-
tool: "{,mcp__*__}{reset_mfa,reset_factors,disable_mfa,enroll_factor,deactivate_factor}",
|
|
686
|
-
conditions: [],
|
|
687
|
-
verdict: "review",
|
|
688
|
-
reason: "This changes a second factor. node9 asks before credentials change (Identity shield)."
|
|
689
|
-
}
|
|
690
|
-
],
|
|
691
|
-
dangerousWords: []
|
|
692
|
-
};
|
|
693
|
-
|
|
694
631
|
// src/shields/builtin/k8s.json
|
|
695
632
|
var k8s_default = {
|
|
696
633
|
name: "k8s",
|
|
@@ -950,7 +887,7 @@ var project_jail_default = {
|
|
|
950
887
|
{
|
|
951
888
|
field: "command",
|
|
952
889
|
op: "matches",
|
|
953
|
-
value: "(cat|less|head|tail|bat|more|open|print|nano|vim
|
|
890
|
+
value: "(cat|less|head|tail|bat|more|open|print|nano|vim?|emacs|code|type|[ef]?grep|rg|ag|ack|g?awk|sed|cut|tr|[jy]q|od|xxd|hexdump|strings|base64|sort|uniq|tac|nl|dd)\\s+.*?\\.env(\\.(local|production|staging|development)){0,2}(?=[\\s;&|>)<]|$)",
|
|
954
891
|
flags: "i"
|
|
955
892
|
}
|
|
956
893
|
],
|
|
@@ -964,7 +901,7 @@ var project_jail_default = {
|
|
|
964
901
|
{
|
|
965
902
|
field: "command",
|
|
966
903
|
op: "matches",
|
|
967
|
-
value: "(cat|less|head|tail|bat|more|open|print|nano|vim
|
|
904
|
+
value: "(cat|less|head|tail|bat|more|open|print|nano|vim?|emacs|code|type|[ef]?grep|rg|ag|ack|g?awk|sed|cut|tr|[jy]q|od|xxd|hexdump|strings|base64|sort|uniq|tac|nl|dd)\\s+.*(credentials\\.json|\\.netrc|\\.npmrc|\\.docker[\\/\\\\]config\\.json|gcloud[\\/\\\\]credentials)",
|
|
968
905
|
flags: "i"
|
|
969
906
|
}
|
|
970
907
|
],
|
|
@@ -1031,6 +968,212 @@ var project_jail_default = {
|
|
|
1031
968
|
dangerousWords: []
|
|
1032
969
|
};
|
|
1033
970
|
|
|
971
|
+
// src/shields/builtin/redis.json
|
|
972
|
+
var redis_default = {
|
|
973
|
+
name: "redis",
|
|
974
|
+
description: "Protects Redis instances from destructive AI operations",
|
|
975
|
+
aliases: [],
|
|
976
|
+
_scopeNote: "Every rule requires Redis to actually be involved: a client in the command (redis-cli / valkey-cli, in either order \u2014 `redis-cli FLUSHALL` and `echo FLUSHALL | redis-cli` are both real), OR the command field holding the bare keyword, which is what the MCP redis_command tool sends ({ command: 'FLUSHALL', args: [] }). Without the client requirement these rules matched the WORD anywhere \u2014 including prose in a heredoc writing a file \u2014 which produced two observed false positives: a test fixture describing the shield, and a commit message naming the rule. Every other builtin shield already scopes this way (aws s3, docker system prune, kubectl delete, gh repo delete). See redis-scope.spec.ts.",
|
|
977
|
+
smartRules: [
|
|
978
|
+
{
|
|
979
|
+
name: "shield:redis:block-flushall",
|
|
980
|
+
tool: "*",
|
|
981
|
+
conditions: [
|
|
982
|
+
{
|
|
983
|
+
field: "command",
|
|
984
|
+
op: "matches",
|
|
985
|
+
value: "(redis|valkey)-cli.*\\bFLUSHALL\\b|\\bFLUSHALL\\b.*(redis|valkey)-cli|^ ?FLUSHALL\\b|\\.flushall\\s*\\(",
|
|
986
|
+
flags: "i"
|
|
987
|
+
}
|
|
988
|
+
],
|
|
989
|
+
verdict: "block",
|
|
990
|
+
reason: "FLUSHALL deletes every key in every database \u2014 blocked by Redis shield"
|
|
991
|
+
},
|
|
992
|
+
{
|
|
993
|
+
name: "shield:redis:block-flushdb",
|
|
994
|
+
tool: "*",
|
|
995
|
+
conditions: [
|
|
996
|
+
{
|
|
997
|
+
field: "command",
|
|
998
|
+
op: "matches",
|
|
999
|
+
value: "(redis|valkey)-cli.*\\bFLUSHDB\\b|\\bFLUSHDB\\b.*(redis|valkey)-cli|^ ?FLUSHDB\\b|\\.flushdb\\s*\\(",
|
|
1000
|
+
flags: "i"
|
|
1001
|
+
}
|
|
1002
|
+
],
|
|
1003
|
+
verdict: "block",
|
|
1004
|
+
reason: "FLUSHDB deletes all keys in the current database \u2014 blocked by Redis shield"
|
|
1005
|
+
},
|
|
1006
|
+
{
|
|
1007
|
+
name: "shield:redis:block-config-resetstat",
|
|
1008
|
+
tool: "*",
|
|
1009
|
+
conditions: [
|
|
1010
|
+
{
|
|
1011
|
+
field: "command",
|
|
1012
|
+
op: "matches",
|
|
1013
|
+
value: "(redis|valkey)-cli.*CONFIG\\s+RESETSTAT|^ ?CONFIG\\s+RESETSTAT",
|
|
1014
|
+
flags: "i"
|
|
1015
|
+
}
|
|
1016
|
+
],
|
|
1017
|
+
verdict: "block",
|
|
1018
|
+
reason: "CONFIG RESETSTAT resets server statistics irreversibly \u2014 blocked by Redis shield"
|
|
1019
|
+
},
|
|
1020
|
+
{
|
|
1021
|
+
name: "shield:redis:review-config-set",
|
|
1022
|
+
tool: "*",
|
|
1023
|
+
conditions: [
|
|
1024
|
+
{
|
|
1025
|
+
field: "command",
|
|
1026
|
+
op: "matches",
|
|
1027
|
+
value: "(redis|valkey)-cli.*\\bCONFIG\\s+SET\\b|\\bCONFIG\\s+SET\\b.*(redis|valkey)-cli|^ ?CONFIG\\s+SET\\b",
|
|
1028
|
+
flags: "i"
|
|
1029
|
+
}
|
|
1030
|
+
],
|
|
1031
|
+
verdict: "review",
|
|
1032
|
+
reason: "CONFIG SET changes live server configuration and requires human approval (Redis shield)"
|
|
1033
|
+
},
|
|
1034
|
+
{
|
|
1035
|
+
name: "shield:redis:review-del-wildcard",
|
|
1036
|
+
tool: "*",
|
|
1037
|
+
conditions: [
|
|
1038
|
+
{
|
|
1039
|
+
field: "command",
|
|
1040
|
+
op: "matches",
|
|
1041
|
+
value: "(redis|valkey)-cli.*\\bDEL\\b.*[*?\\[]|^ ?DEL\\b.*[*?\\[]|-cli.*--scan.*xargs.*del",
|
|
1042
|
+
flags: "i"
|
|
1043
|
+
}
|
|
1044
|
+
],
|
|
1045
|
+
verdict: "review",
|
|
1046
|
+
reason: "Wildcard key deletion requires human approval (Redis shield)"
|
|
1047
|
+
}
|
|
1048
|
+
],
|
|
1049
|
+
dangerousWords: ["FLUSHALL", "FLUSHDB"]
|
|
1050
|
+
};
|
|
1051
|
+
|
|
1052
|
+
// src/shields/builtin/finance.json
|
|
1053
|
+
var finance_default = {
|
|
1054
|
+
name: "finance",
|
|
1055
|
+
description: "Asks before money moves through a payment or banking app (refunds, payouts, transfers, charges, invoices), whatever the request said. Reads are never asked about.",
|
|
1056
|
+
aliases: ["payments", "money"],
|
|
1057
|
+
smartRules: [
|
|
1058
|
+
{
|
|
1059
|
+
name: "shield:finance:review-refund",
|
|
1060
|
+
tool: "{,mcp__*__}{create_refund,refund_payment,refund_charge,refund_order,issue_refund}",
|
|
1061
|
+
conditions: [],
|
|
1062
|
+
verdict: "review",
|
|
1063
|
+
reason: "A refund returns money to a customer. node9 asks before money moves, whatever the request said (Finance shield)."
|
|
1064
|
+
},
|
|
1065
|
+
{
|
|
1066
|
+
name: "shield:finance:review-payout",
|
|
1067
|
+
tool: "{,mcp__*__}{create_payout,send_payout,payout,create_payouts_batch}",
|
|
1068
|
+
conditions: [],
|
|
1069
|
+
verdict: "review",
|
|
1070
|
+
reason: "A payout moves the balance to a bank account. node9 asks before money moves (Finance shield)."
|
|
1071
|
+
},
|
|
1072
|
+
{
|
|
1073
|
+
name: "shield:finance:review-transfer",
|
|
1074
|
+
tool: "{,mcp__*__}{transfer_create,transfer_authorization_create,create_transfer,transfer_money,transfer_funds,send_money,wire_transfer,create_wire,schedule_transaction,update_scheduled_transaction}",
|
|
1075
|
+
conditions: [],
|
|
1076
|
+
verdict: "review",
|
|
1077
|
+
reason: "A transfer moves money between accounts. node9 asks before money moves (Finance shield)."
|
|
1078
|
+
},
|
|
1079
|
+
{
|
|
1080
|
+
name: "shield:finance:review-charge",
|
|
1081
|
+
tool: "{,mcp__*__}{create_payment_intent,confirm_payment_intent,capture_payment_intent,create_charge,create_payment,capture_payment,capture_order,create_order,authorize_order,create_checkout_session}",
|
|
1082
|
+
conditions: [],
|
|
1083
|
+
verdict: "review",
|
|
1084
|
+
reason: "This charges a card or captures a payment. node9 asks before money moves (Finance shield)."
|
|
1085
|
+
},
|
|
1086
|
+
{
|
|
1087
|
+
name: "shield:finance:review-payment-link",
|
|
1088
|
+
tool: "{,mcp__*__}{create_payment_link,create_invoice,finalize_invoice,send_invoice,pay_invoice,create_invoice_item}",
|
|
1089
|
+
conditions: [],
|
|
1090
|
+
verdict: "review",
|
|
1091
|
+
reason: "This bills someone or creates a link that charges a card. node9 asks before money moves (Finance shield)."
|
|
1092
|
+
},
|
|
1093
|
+
{
|
|
1094
|
+
name: "shield:finance:review-subscription",
|
|
1095
|
+
tool: "{,mcp__*__}{create_subscription,cancel_subscription,update_subscription,pause_subscription,resume_subscription}",
|
|
1096
|
+
conditions: [],
|
|
1097
|
+
verdict: "review",
|
|
1098
|
+
reason: "A subscription starts or stops recurring charges. node9 asks before money moves (Finance shield)."
|
|
1099
|
+
},
|
|
1100
|
+
{
|
|
1101
|
+
name: "shield:finance:review-dispute",
|
|
1102
|
+
tool: "{,mcp__*__}{update_dispute,accept_dispute,close_dispute}",
|
|
1103
|
+
conditions: [],
|
|
1104
|
+
verdict: "review",
|
|
1105
|
+
reason: "This answers or concedes a chargeback. node9 asks before money moves (Finance shield)."
|
|
1106
|
+
},
|
|
1107
|
+
{
|
|
1108
|
+
name: "shield:finance:review-card",
|
|
1109
|
+
tool: "{,mcp__*__}{issue_card,create_virtual_card,create_issuing_card,update_card_limit}",
|
|
1110
|
+
conditions: [],
|
|
1111
|
+
verdict: "review",
|
|
1112
|
+
reason: "This issues a card or changes its limit. node9 asks before money moves (Finance shield)."
|
|
1113
|
+
},
|
|
1114
|
+
{
|
|
1115
|
+
name: "shield:finance:review-withdraw",
|
|
1116
|
+
tool: "{,mcp__*__}{withdraw,withdraw_funds,create_withdrawal,request_withdrawal}",
|
|
1117
|
+
conditions: [],
|
|
1118
|
+
verdict: "review",
|
|
1119
|
+
reason: "A withdrawal moves money out. node9 asks before money moves (Finance shield)."
|
|
1120
|
+
}
|
|
1121
|
+
],
|
|
1122
|
+
dangerousWords: []
|
|
1123
|
+
};
|
|
1124
|
+
|
|
1125
|
+
// src/shields/builtin/identity.json
|
|
1126
|
+
var identity_default = {
|
|
1127
|
+
name: "identity",
|
|
1128
|
+
description: "Asks before a password, a key, a token, a role or a user changes in an identity or admin app, whatever the request said. Reads are never asked about.",
|
|
1129
|
+
aliases: ["access", "iam"],
|
|
1130
|
+
smartRules: [
|
|
1131
|
+
{
|
|
1132
|
+
name: "shield:identity:review-password",
|
|
1133
|
+
tool: "{,mcp__*__}{change_password,update_password,reset_password,set_password,expire_password,force_password_reset}",
|
|
1134
|
+
conditions: [],
|
|
1135
|
+
verdict: "review",
|
|
1136
|
+
reason: "This changes or resets a password. node9 asks before credentials change, whatever the request said (Identity shield)."
|
|
1137
|
+
},
|
|
1138
|
+
{
|
|
1139
|
+
name: "shield:identity:review-key",
|
|
1140
|
+
tool: "{,mcp__*__}{rotate_key,rotate_api_key,create_api_key,create_token,create_access_token,create_personal_access_token,regenerate_secret,rotate_secret,create_service_account_key,create_credential}",
|
|
1141
|
+
conditions: [],
|
|
1142
|
+
verdict: "review",
|
|
1143
|
+
reason: "This creates or rotates a key, token or secret. node9 asks before credentials change (Identity shield)."
|
|
1144
|
+
},
|
|
1145
|
+
{
|
|
1146
|
+
name: "shield:identity:review-access",
|
|
1147
|
+
tool: "{,mcp__*__}{grant_access,grant_permission,grant_role,revoke_access,revoke_permission,revoke_role,revoke_token,set_permission,set_permissions,set_role,assign_role,update_role,add_permission,remove_permission,attach_policy,detach_policy,share_file}",
|
|
1148
|
+
conditions: [],
|
|
1149
|
+
verdict: "review",
|
|
1150
|
+
reason: "This grants or revokes access. node9 asks before access changes (Identity shield)."
|
|
1151
|
+
},
|
|
1152
|
+
{
|
|
1153
|
+
name: "shield:identity:review-membership",
|
|
1154
|
+
tool: "{,mcp__*__}{add_member,remove_member,add_user_to_group,remove_user_from_group,add_collaborator,remove_collaborator,invite_user,invite_member,invite_user_to_slack,invite_users,add_org_member,remove_org_member,add_team_member,remove_team_member,add_user_to_channel,remove_user_from_slack}",
|
|
1155
|
+
conditions: [],
|
|
1156
|
+
verdict: "review",
|
|
1157
|
+
reason: "This changes who belongs where. node9 asks before membership changes (Identity shield)."
|
|
1158
|
+
},
|
|
1159
|
+
{
|
|
1160
|
+
name: "shield:identity:review-user",
|
|
1161
|
+
tool: "{,mcp__*__}{create_user,delete_user,delete_deactivated_user,deactivate_user,suspend_user,activate_user,unlock_user,make_admin,promote_user,demote_user,update_user_role}",
|
|
1162
|
+
conditions: [],
|
|
1163
|
+
verdict: "review",
|
|
1164
|
+
reason: "This creates, removes or promotes an account. node9 asks before accounts change (Identity shield)."
|
|
1165
|
+
},
|
|
1166
|
+
{
|
|
1167
|
+
name: "shield:identity:review-mfa",
|
|
1168
|
+
tool: "{,mcp__*__}{reset_mfa,reset_factors,disable_mfa,enroll_factor,deactivate_factor}",
|
|
1169
|
+
conditions: [],
|
|
1170
|
+
verdict: "review",
|
|
1171
|
+
reason: "This changes a second factor. node9 asks before credentials change (Identity shield)."
|
|
1172
|
+
}
|
|
1173
|
+
],
|
|
1174
|
+
dangerousWords: []
|
|
1175
|
+
};
|
|
1176
|
+
|
|
1034
1177
|
// src/shields/builtin/publishing.json
|
|
1035
1178
|
var publishing_default = {
|
|
1036
1179
|
name: "publishing",
|
|
@@ -1202,85 +1345,554 @@ var publishing_default = {
|
|
|
1202
1345
|
dangerousWords: []
|
|
1203
1346
|
};
|
|
1204
1347
|
|
|
1205
|
-
// src/shields/
|
|
1206
|
-
var
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1348
|
+
// src/shields/apps.ts
|
|
1349
|
+
var ACTION_TEMPLATES = {
|
|
1350
|
+
finance: finance_default.smartRules,
|
|
1351
|
+
identity: identity_default.smartRules,
|
|
1352
|
+
publishing: publishing_default.smartRules
|
|
1353
|
+
};
|
|
1354
|
+
var ACTION_CHECKS = {
|
|
1355
|
+
finance: { checkId: "actions.money", slug: "money", label: "Money check" },
|
|
1356
|
+
identity: { checkId: "actions.access", slug: "access", label: "Accounts and access check" },
|
|
1357
|
+
publishing: { checkId: "actions.publish", slug: "publish", label: "Publishing check" }
|
|
1358
|
+
};
|
|
1359
|
+
function isToolRule(rule) {
|
|
1360
|
+
return rule.tool.startsWith("{,mcp__*__}");
|
|
1361
|
+
}
|
|
1362
|
+
function actionPart(ruleName) {
|
|
1363
|
+
const m = /^shield:[^:]+:(.+)$/.exec(ruleName ?? "");
|
|
1364
|
+
return m ? m[1] : ruleName ?? "rule";
|
|
1365
|
+
}
|
|
1366
|
+
function ownReason(reason, owner) {
|
|
1367
|
+
if (!reason) return reason;
|
|
1368
|
+
return reason.replace(/\((?:Finance|Identity|Publishing) shield\)\.?$/, `(${owner}).`);
|
|
1369
|
+
}
|
|
1370
|
+
var GAP = "[^;&|]{0,200}?";
|
|
1371
|
+
var prog = (alt) => `(?:^|[^\\w-])(?:${alt})(?![\\w-])`;
|
|
1372
|
+
var httpTo = (host2) => prog("curl|wget|http|https|xh") + "[^;&|]{0,400}?" + host2;
|
|
1373
|
+
var httpWrite = (methods) => ({
|
|
1374
|
+
field: "command",
|
|
1375
|
+
op: "matches",
|
|
1376
|
+
value: `-X\\s*(?:${methods})|--(?:request|method)[=\\s]+(?:${methods})|--post-(?:data|file)|\\s(?:${methods}|${methods.toLowerCase()})\\s|^(?!.*\\s(?:-[a-zA-Z]*G|--get)(?![\\w-])).*(?:\\s-d[\\s'"@]|\\s--data|\\s--json\\s|\\s-F\\s|\\s--form\\s)`
|
|
1377
|
+
});
|
|
1378
|
+
var HTTP_WRITE = httpWrite("POST|DELETE");
|
|
1379
|
+
var HTTP_WRITE_ANY = httpWrite("POST|PUT|PATCH|DELETE");
|
|
1380
|
+
var NOT_STRIPE_TEST = {
|
|
1381
|
+
field: "command",
|
|
1382
|
+
op: "notMatches",
|
|
1383
|
+
value: "\\b[sr]k_test_"
|
|
1384
|
+
};
|
|
1385
|
+
var postTo = (host2) => `\\.post\\(\\s*["'\`][^"'\`]{0,80}${host2}`;
|
|
1386
|
+
var STRIPE_OBJECTS = "refunds|payouts|charges|transfers|payment_intents|payment_links|invoices|subscriptions|topups";
|
|
1387
|
+
var APP_SHIELD_SPECS = [
|
|
1388
|
+
{
|
|
1389
|
+
name: "stripe",
|
|
1390
|
+
label: "Stripe",
|
|
1391
|
+
description: "Asks before money moves in Stripe (refunds, payouts, charges, invoices, subscriptions), whether the agent uses the Stripe MCP server, the stripe CLI, the API or the Stripe library in a script. Reads are never asked about.",
|
|
1392
|
+
template: "finance",
|
|
1393
|
+
server: "*stripe*",
|
|
1394
|
+
doors: [
|
|
1395
|
+
{
|
|
1396
|
+
name: "shield:stripe:review-cli",
|
|
1397
|
+
tool: "bash",
|
|
1398
|
+
conditions: [
|
|
1399
|
+
{
|
|
1400
|
+
field: "command",
|
|
1401
|
+
op: "matches",
|
|
1402
|
+
value: prog("stripe") + GAP + `\\s(?:${STRIPE_OBJECTS})\\s+(?:create|cancel|capture|confirm|update|pay|finalize_invoice|send_invoice|void_invoice)(?![\\w-])`,
|
|
1403
|
+
flags: "i"
|
|
1404
|
+
},
|
|
1405
|
+
{
|
|
1406
|
+
field: "command",
|
|
1407
|
+
op: "matches",
|
|
1408
|
+
// The stripe CLI works in test mode unless told otherwise.
|
|
1409
|
+
value: "\\s--live(?![\\w-])|\\b[sr]k_live_"
|
|
1410
|
+
}
|
|
1411
|
+
],
|
|
1412
|
+
conditionMode: "all",
|
|
1413
|
+
verdict: "review",
|
|
1414
|
+
reason: "The stripe CLI is about to move money. node9 asks before money moves (Stripe)."
|
|
1415
|
+
},
|
|
1416
|
+
{
|
|
1417
|
+
name: "shield:stripe:review-cli-request",
|
|
1418
|
+
tool: "bash",
|
|
1419
|
+
conditions: [
|
|
1420
|
+
{
|
|
1421
|
+
field: "command",
|
|
1422
|
+
op: "matches",
|
|
1423
|
+
value: prog("stripe") + GAP + `\\s(?:post|delete)\\s+/?v1/(?:${STRIPE_OBJECTS})(?![\\w-])`,
|
|
1424
|
+
flags: "i"
|
|
1425
|
+
},
|
|
1426
|
+
{
|
|
1427
|
+
field: "command",
|
|
1428
|
+
op: "matches",
|
|
1429
|
+
// The stripe CLI works in test mode unless told otherwise.
|
|
1430
|
+
value: "\\s--live(?![\\w-])|\\b[sr]k_live_"
|
|
1431
|
+
}
|
|
1432
|
+
],
|
|
1433
|
+
conditionMode: "all",
|
|
1434
|
+
verdict: "review",
|
|
1435
|
+
reason: "A raw stripe CLI request is about to move money. node9 asks before money moves (Stripe)."
|
|
1436
|
+
},
|
|
1437
|
+
{
|
|
1438
|
+
name: "shield:stripe:review-api",
|
|
1439
|
+
tool: "bash",
|
|
1440
|
+
conditions: [
|
|
1441
|
+
{
|
|
1442
|
+
field: "command",
|
|
1443
|
+
op: "matches",
|
|
1444
|
+
value: httpTo(`api\\.stripe\\.com/v1/(?:${STRIPE_OBJECTS})(?![\\w-])`),
|
|
1445
|
+
flags: "i"
|
|
1446
|
+
},
|
|
1447
|
+
HTTP_WRITE,
|
|
1448
|
+
NOT_STRIPE_TEST
|
|
1449
|
+
],
|
|
1450
|
+
conditionMode: "all",
|
|
1451
|
+
verdict: "review",
|
|
1452
|
+
reason: "A request to the Stripe API is about to move money. node9 asks before money moves (Stripe)."
|
|
1453
|
+
},
|
|
1454
|
+
{
|
|
1455
|
+
name: "shield:stripe:review-code",
|
|
1456
|
+
tool: "bash",
|
|
1457
|
+
conditions: [
|
|
1458
|
+
{
|
|
1459
|
+
field: "command",
|
|
1460
|
+
op: "matches",
|
|
1461
|
+
// Python: stripe.Refund.create(...)
|
|
1462
|
+
value: "\\bstripe\\.(?:Refund|Payout|Transfer|Charge|PaymentIntent|PaymentLink|Invoice|Subscription|Topup)\\.(?:create|cancel|capture|confirm|modify|pay|finalize_invoice|send_invoice|void_invoice)\\b"
|
|
1463
|
+
},
|
|
1464
|
+
NOT_STRIPE_TEST
|
|
1465
|
+
],
|
|
1466
|
+
conditionMode: "all",
|
|
1467
|
+
verdict: "review",
|
|
1468
|
+
reason: "This code moves money through the Stripe library. node9 asks before money moves (Stripe)."
|
|
1469
|
+
},
|
|
1470
|
+
{
|
|
1471
|
+
name: "shield:stripe:review-code-node",
|
|
1472
|
+
tool: "bash",
|
|
1473
|
+
conditions: [
|
|
1474
|
+
{
|
|
1475
|
+
field: "command",
|
|
1476
|
+
op: "matches",
|
|
1477
|
+
// Node: stripe.refunds.create(...)
|
|
1478
|
+
value: "\\bstripe\\.(?:refunds|payouts|transfers|charges|paymentIntents|paymentLinks|invoices|subscriptions|topups)\\.(?:create|cancel|capture|confirm|update|pay|finalizeInvoice|sendInvoice|voidInvoice)\\s*\\("
|
|
1479
|
+
},
|
|
1480
|
+
NOT_STRIPE_TEST
|
|
1481
|
+
],
|
|
1482
|
+
conditionMode: "all",
|
|
1483
|
+
verdict: "review",
|
|
1484
|
+
reason: "This code moves money through the Stripe library. node9 asks before money moves (Stripe)."
|
|
1485
|
+
},
|
|
1486
|
+
{
|
|
1487
|
+
name: "shield:stripe:review-code-http",
|
|
1488
|
+
tool: "bash",
|
|
1489
|
+
conditions: [
|
|
1490
|
+
{
|
|
1491
|
+
field: "command",
|
|
1492
|
+
op: "matches",
|
|
1493
|
+
// requests.post("https://api.stripe.com/v1/refunds", ...)
|
|
1494
|
+
value: `\\.post\\(\\s*["'\`][^"'\`]{0,80}api\\.stripe\\.com/v1/(?:${STRIPE_OBJECTS})`
|
|
1495
|
+
},
|
|
1496
|
+
NOT_STRIPE_TEST
|
|
1497
|
+
],
|
|
1498
|
+
conditionMode: "all",
|
|
1499
|
+
verdict: "review",
|
|
1500
|
+
reason: "This code posts to the Stripe API. node9 asks before money moves (Stripe)."
|
|
1501
|
+
}
|
|
1502
|
+
]
|
|
1503
|
+
},
|
|
1504
|
+
{
|
|
1505
|
+
name: "paypal",
|
|
1506
|
+
label: "PayPal",
|
|
1507
|
+
description: "Asks before money moves in PayPal (refunds, payouts, captured orders, invoices, subscriptions), whether the agent uses a PayPal MCP server, the API or the PayPal SDK in a script. The sandbox is never asked about, and neither are reads.",
|
|
1508
|
+
template: "finance",
|
|
1509
|
+
server: "*paypal*",
|
|
1510
|
+
doors: [
|
|
1511
|
+
{
|
|
1512
|
+
name: "shield:paypal:review-api",
|
|
1513
|
+
tool: "bash",
|
|
1514
|
+
conditions: [
|
|
1515
|
+
{
|
|
1516
|
+
field: "command",
|
|
1517
|
+
op: "matches",
|
|
1518
|
+
// The live hosts only: api.paypal.com and api-m.paypal.com. The
|
|
1519
|
+
// sandbox (api-m.sandbox.paypal.com) moves no money.
|
|
1520
|
+
value: httpTo("api(?:-m)?\\.paypal\\.com/v[12]/"),
|
|
1521
|
+
flags: "i"
|
|
1522
|
+
},
|
|
1523
|
+
{
|
|
1524
|
+
field: "command",
|
|
1525
|
+
op: "matches",
|
|
1526
|
+
// The endpoints that move money.
|
|
1527
|
+
value: "\\.paypal\\.com/v[12]/(?:payments/(?:captures|authorizations|sale|payouts|payment|referenced-payouts)|checkout/orders/[^\\s/]{1,64}/(?:capture|authorize)|invoicing/invoices|billing/subscriptions)",
|
|
1528
|
+
flags: "i"
|
|
1529
|
+
},
|
|
1530
|
+
HTTP_WRITE
|
|
1531
|
+
],
|
|
1532
|
+
conditionMode: "all",
|
|
1533
|
+
verdict: "review",
|
|
1534
|
+
reason: "A request to the PayPal API is about to move money. node9 asks before money moves (PayPal)."
|
|
1535
|
+
},
|
|
1536
|
+
{
|
|
1537
|
+
name: "shield:paypal:review-code",
|
|
1538
|
+
tool: "bash",
|
|
1539
|
+
conditions: [
|
|
1540
|
+
{
|
|
1541
|
+
field: "command",
|
|
1542
|
+
op: "matches",
|
|
1543
|
+
// The Node SDKs (checkout-server-sdk, paypal-server-sdk) and the
|
|
1544
|
+
// Python paypalrestsdk.
|
|
1545
|
+
value: "\\b(?:CapturesRefundRequest|OrdersCaptureRequest|AuthorizationsCaptureRequest|PayoutsPostRequest)\\b|\\b(?:captureOrder|refundCapturedPayment|captureAuthorizedPayment|createBatchPayout)\\s*\\(|\\bpaypalrestsdk\\.(?:Payout|Sale|Capture|Invoice|BillingAgreement)\\b"
|
|
1546
|
+
}
|
|
1547
|
+
],
|
|
1548
|
+
verdict: "review",
|
|
1549
|
+
reason: "This code moves money through PayPal. node9 asks before money moves (PayPal)."
|
|
1550
|
+
},
|
|
1551
|
+
{
|
|
1552
|
+
name: "shield:paypal:review-code-http",
|
|
1553
|
+
tool: "bash",
|
|
1554
|
+
conditions: [
|
|
1555
|
+
{
|
|
1556
|
+
field: "command",
|
|
1557
|
+
op: "matches",
|
|
1558
|
+
// The endpoints that move money; the token call every script
|
|
1559
|
+
// starts with (/v1/oauth2/token) is not one.
|
|
1560
|
+
value: postTo(
|
|
1561
|
+
"api(?:-m)?\\.paypal\\.com/v[12]/(?:payments/(?:captures|authorizations|sale|payouts|payment|referenced-payouts)|checkout/orders/[^\\s/\"'`]{1,64}/(?:capture|authorize)|invoicing/invoices|billing/subscriptions)"
|
|
1562
|
+
)
|
|
1563
|
+
}
|
|
1564
|
+
],
|
|
1565
|
+
verdict: "review",
|
|
1566
|
+
reason: "This code posts to the PayPal API. node9 asks before money moves (PayPal)."
|
|
1567
|
+
}
|
|
1568
|
+
]
|
|
1569
|
+
},
|
|
1570
|
+
{
|
|
1571
|
+
name: "square",
|
|
1572
|
+
label: "Square",
|
|
1573
|
+
description: "Asks before money moves in Square (refunds, payments, paid orders, invoices, subscriptions), whether the agent uses a Square MCP server, the API or the Square SDK in a script. The sandbox host is never asked about, and neither are reads.",
|
|
1574
|
+
template: "finance",
|
|
1575
|
+
// Square's servers, never Squarespace (a website builder).
|
|
1576
|
+
server: "{*square,*square[-_]*,*squareup*}",
|
|
1577
|
+
mcpTools: [
|
|
1578
|
+
{
|
|
1579
|
+
// Square's official MCP server has one tool for every API call; the
|
|
1580
|
+
// service and method name what it does.
|
|
1581
|
+
name: "shield:square:review-mcp-request",
|
|
1582
|
+
tool: "{,mcp__*__}make_api_request",
|
|
1583
|
+
conditions: [
|
|
1584
|
+
{
|
|
1585
|
+
field: "service",
|
|
1586
|
+
op: "matches",
|
|
1587
|
+
value: "^(?:refunds|payments|orders|invoices|subscriptions|disputes|gift_cards|gift_card_activities|checkout|terminal)$",
|
|
1588
|
+
flags: "i"
|
|
1589
|
+
},
|
|
1590
|
+
{
|
|
1591
|
+
field: "method",
|
|
1592
|
+
op: "notMatches",
|
|
1593
|
+
value: "^(?:list|get|retrieve|search|batch_?retrieve|calculate)",
|
|
1594
|
+
flags: "i"
|
|
1595
|
+
}
|
|
1596
|
+
],
|
|
1597
|
+
conditionMode: "all",
|
|
1598
|
+
verdict: "review",
|
|
1599
|
+
reason: "A request through the Square MCP server is about to move money. node9 asks before money moves (Square)."
|
|
1600
|
+
}
|
|
1601
|
+
],
|
|
1602
|
+
doors: [
|
|
1603
|
+
{
|
|
1604
|
+
name: "shield:square:review-api",
|
|
1605
|
+
tool: "bash",
|
|
1606
|
+
conditions: [
|
|
1607
|
+
{
|
|
1608
|
+
field: "command",
|
|
1609
|
+
op: "matches",
|
|
1610
|
+
// The live host only; the sandbox is connect.squareupsandbox.com.
|
|
1611
|
+
value: httpTo(
|
|
1612
|
+
"connect\\.squareup\\.com/v2/(?:refunds|payments|orders/[^\\s/?]{1,64}/pay|invoices|subscriptions|disputes|gift-cards/activities)(?![\\w-]|/search)"
|
|
1613
|
+
),
|
|
1614
|
+
flags: "i"
|
|
1615
|
+
},
|
|
1616
|
+
HTTP_WRITE_ANY
|
|
1617
|
+
],
|
|
1618
|
+
conditionMode: "all",
|
|
1619
|
+
verdict: "review",
|
|
1620
|
+
reason: "A request to the Square API is about to move money. node9 asks before money moves (Square)."
|
|
1621
|
+
},
|
|
1622
|
+
{
|
|
1623
|
+
name: "shield:square:review-code",
|
|
1624
|
+
tool: "bash",
|
|
1625
|
+
conditions: [
|
|
1626
|
+
{
|
|
1627
|
+
field: "command",
|
|
1628
|
+
op: "matches",
|
|
1629
|
+
// The Square SDK in the script: Node (`square`) or Python (`square`, `squareup`).
|
|
1630
|
+
value: `\\bSquareClient\\b|\\bsquare\\.client\\b|from\\s+square[.\\s]|from\\s+["']square["']|require\\(\\s*["']square["']`
|
|
1631
|
+
},
|
|
1632
|
+
{
|
|
1633
|
+
field: "command",
|
|
1634
|
+
op: "matches",
|
|
1635
|
+
value: "\\.refunds(?:Api)?\\.refund(?:Payment|_payment)\\s*\\(|\\.payments(?:Api)?\\.(?:create|complete)(?:Payment|_payment)?\\s*\\(|\\.orders(?:Api)?\\.pay(?:Order|_order)?\\s*\\(|\\.invoices(?:Api)?\\.publish(?:Invoice|_invoice)?\\s*\\("
|
|
1636
|
+
}
|
|
1637
|
+
],
|
|
1638
|
+
conditionMode: "all",
|
|
1639
|
+
verdict: "review",
|
|
1640
|
+
reason: "This code moves money through the Square SDK. node9 asks before money moves (Square)."
|
|
1641
|
+
},
|
|
1642
|
+
{
|
|
1643
|
+
name: "shield:square:review-code-http",
|
|
1644
|
+
tool: "bash",
|
|
1645
|
+
conditions: [
|
|
1646
|
+
{
|
|
1647
|
+
field: "command",
|
|
1648
|
+
op: "matches",
|
|
1649
|
+
value: postTo(
|
|
1650
|
+
"connect\\.squareup\\.com/v2/(?:refunds|payments|orders/[^\\s/?\"'`]{1,64}/pay|invoices|subscriptions|disputes|gift-cards/activities)(?![\\w-]|/search)"
|
|
1651
|
+
)
|
|
1652
|
+
}
|
|
1653
|
+
],
|
|
1654
|
+
verdict: "review",
|
|
1655
|
+
reason: "This code posts to the Square API. node9 asks before money moves (Square)."
|
|
1656
|
+
}
|
|
1657
|
+
]
|
|
1658
|
+
},
|
|
1659
|
+
{
|
|
1660
|
+
name: "plaid",
|
|
1661
|
+
label: "Plaid",
|
|
1662
|
+
description: "Asks before money moves through Plaid (transfers, transfer authorizations, payment initiation), whether the agent uses a Plaid MCP server, the API or the Plaid SDK in a script. The sandbox host is never asked about, and neither are reads such as balances or transactions.",
|
|
1663
|
+
template: "finance",
|
|
1664
|
+
server: "*plaid*",
|
|
1665
|
+
doors: [
|
|
1666
|
+
{
|
|
1667
|
+
name: "shield:plaid:review-api",
|
|
1668
|
+
tool: "bash",
|
|
1669
|
+
conditions: [
|
|
1670
|
+
{
|
|
1671
|
+
field: "command",
|
|
1672
|
+
op: "matches",
|
|
1673
|
+
// Every Plaid endpoint is a POST, so the path is what tells a
|
|
1674
|
+
// write; the live host only, never sandbox.plaid.com. A script
|
|
1675
|
+
// that posts to the URL meets this door too.
|
|
1676
|
+
value: httpTo(
|
|
1677
|
+
"production\\.plaid\\.com/(?:transfer/(?:create|authorization/create|recurring/create)|payment_initiation/payment/create|bank_transfer/create)(?![\\w-])"
|
|
1678
|
+
),
|
|
1679
|
+
flags: "i"
|
|
1680
|
+
}
|
|
1681
|
+
],
|
|
1682
|
+
verdict: "review",
|
|
1683
|
+
reason: "A request to the Plaid API is about to move money. node9 asks before money moves (Plaid)."
|
|
1684
|
+
},
|
|
1685
|
+
{
|
|
1686
|
+
name: "shield:plaid:review-code",
|
|
1687
|
+
tool: "bash",
|
|
1688
|
+
conditions: [
|
|
1689
|
+
{ field: "command", op: "matches", value: "\\bplaid", flags: "i" },
|
|
1690
|
+
{
|
|
1691
|
+
field: "command",
|
|
1692
|
+
op: "matches",
|
|
1693
|
+
value: "\\b(?:transfer(?:Authorization|Recurring)?Create|paymentInitiationPaymentCreate|bankTransferCreate|transfer_(?:authorization_|recurring_)?create|payment_initiation_payment_create|bank_transfer_create)\\s*\\("
|
|
1694
|
+
}
|
|
1695
|
+
],
|
|
1696
|
+
conditionMode: "all",
|
|
1697
|
+
verdict: "review",
|
|
1698
|
+
reason: "This code moves money through Plaid. node9 asks before money moves (Plaid)."
|
|
1699
|
+
}
|
|
1700
|
+
]
|
|
1701
|
+
},
|
|
1702
|
+
{
|
|
1703
|
+
name: "okta",
|
|
1704
|
+
label: "Okta",
|
|
1705
|
+
description: "Asks before a user, a group member, a role, a password or a key changes in Okta, whether the agent uses an Okta MCP server, the API or the Okta SDK in a script. Reads and signing in are never asked about.",
|
|
1706
|
+
template: "identity",
|
|
1707
|
+
server: "*okta*",
|
|
1708
|
+
doors: [
|
|
1709
|
+
{
|
|
1710
|
+
name: "shield:okta:review-api",
|
|
1711
|
+
tool: "bash",
|
|
1712
|
+
conditions: [
|
|
1713
|
+
{
|
|
1714
|
+
field: "command",
|
|
1715
|
+
op: "matches",
|
|
1716
|
+
// The management API only: sign-in (/api/v1/authn, /sessions,
|
|
1717
|
+
// /oauth2) is not under these paths.
|
|
1718
|
+
value: httpTo(
|
|
1719
|
+
"[\\w-]+\\.okta(?:-emea)?\\.com/api/v1/(?:users|groups|apps|iam|api-tokens|idps|authorizationServers|policies)(?![\\w-])"
|
|
1720
|
+
),
|
|
1721
|
+
flags: "i"
|
|
1722
|
+
},
|
|
1723
|
+
HTTP_WRITE_ANY
|
|
1724
|
+
],
|
|
1725
|
+
conditionMode: "all",
|
|
1726
|
+
verdict: "review",
|
|
1727
|
+
reason: "A request to the Okta API is about to change who has access. node9 asks before access changes (Okta)."
|
|
1728
|
+
},
|
|
1729
|
+
{
|
|
1730
|
+
name: "shield:okta:review-code",
|
|
1731
|
+
tool: "bash",
|
|
1732
|
+
conditions: [
|
|
1733
|
+
{
|
|
1734
|
+
field: "command",
|
|
1735
|
+
op: "matches",
|
|
1736
|
+
// The Okta SDK in the script: a method named createUser alone is
|
|
1737
|
+
// in half the applications ever written.
|
|
1738
|
+
value: "@okta/okta-sdk|\\bokta\\.Client\\b|from\\s+okta[.\\s]|\\bimport\\s+okta\\b"
|
|
1739
|
+
},
|
|
1740
|
+
{
|
|
1741
|
+
field: "command",
|
|
1742
|
+
op: "matches",
|
|
1743
|
+
value: "\\b(?:(?:create|delete|deactivate|suspend|unlock|activate)User|(?:reset|expire)Password|resetFactors|(?:assign|unassign)User(?:To|From)Group|assignRoleTo(?:User|Group))\\s*\\("
|
|
1744
|
+
}
|
|
1745
|
+
],
|
|
1746
|
+
conditionMode: "all",
|
|
1747
|
+
verdict: "review",
|
|
1748
|
+
reason: "This code changes who has access in Okta. node9 asks before access changes (Okta)."
|
|
1749
|
+
},
|
|
1750
|
+
{
|
|
1751
|
+
name: "shield:okta:review-code-py",
|
|
1752
|
+
tool: "bash",
|
|
1753
|
+
conditions: [
|
|
1754
|
+
{
|
|
1755
|
+
field: "command",
|
|
1756
|
+
op: "matches",
|
|
1757
|
+
value: "@okta/okta-sdk|\\bokta\\.Client\\b|from\\s+okta[.\\s]|\\bimport\\s+okta\\b"
|
|
1758
|
+
},
|
|
1759
|
+
{
|
|
1760
|
+
field: "command",
|
|
1761
|
+
op: "matches",
|
|
1762
|
+
value: "\\b(?:(?:create|delete|deactivate|deactivate_or_delete|suspend|unlock|activate)_user|(?:reset|expire)_password|reset_factors|(?:add|remove)_user_(?:to|from)_group|assign_role_to_(?:user|group))\\s*\\("
|
|
1763
|
+
}
|
|
1764
|
+
],
|
|
1765
|
+
conditionMode: "all",
|
|
1766
|
+
verdict: "review",
|
|
1767
|
+
reason: "This code changes who has access in Okta. node9 asks before access changes (Okta)."
|
|
1768
|
+
}
|
|
1769
|
+
]
|
|
1770
|
+
},
|
|
1771
|
+
{
|
|
1772
|
+
name: "auth0",
|
|
1773
|
+
label: "Auth0",
|
|
1774
|
+
description: "Asks before a user, a role, an application or its permissions change in Auth0, whether the agent uses an Auth0 MCP server, the auth0 CLI, the Management API or the Auth0 SDK in a script. Reads and signing in are never asked about.",
|
|
1775
|
+
template: "identity",
|
|
1776
|
+
server: "*auth0*",
|
|
1777
|
+
mcpTools: [
|
|
1778
|
+
{
|
|
1779
|
+
// Auth0's official MCP server: applications (their secrets and
|
|
1780
|
+
// callbacks), APIs and their scopes, and Actions (code that runs at
|
|
1781
|
+
// every sign-in).
|
|
1782
|
+
name: "shield:auth0:review-tenant-config",
|
|
1783
|
+
tool: "{,mcp__*__}{auth0_create_application,auth0_update_application,auth0_create_resource_server,auth0_update_resource_server,auth0_create_action,auth0_update_action,auth0_deploy_action}",
|
|
1784
|
+
conditions: [],
|
|
1785
|
+
verdict: "review",
|
|
1786
|
+
reason: "This changes an Auth0 application, API or sign-in Action. node9 asks before access changes (Auth0)."
|
|
1787
|
+
}
|
|
1788
|
+
],
|
|
1789
|
+
doors: [
|
|
1790
|
+
{
|
|
1791
|
+
name: "shield:auth0:review-cli",
|
|
1792
|
+
tool: "bash",
|
|
1793
|
+
conditions: [
|
|
1794
|
+
{
|
|
1795
|
+
field: "command",
|
|
1796
|
+
op: "matches",
|
|
1797
|
+
value: prog("auth0") + GAP + "\\s(?:(?:users|roles|apps|orgs)\\s+(?:create|update|delete|rm)|users\\s+roles\\s+(?:assign|add|remove|rm)|roles\\s+permissions\\s+(?:add|remove|rm)|users\\s+blocks\\s+unblock|api\\s+(?:post|put|patch|delete))(?![\\w-])",
|
|
1798
|
+
flags: "i"
|
|
1799
|
+
}
|
|
1800
|
+
],
|
|
1801
|
+
verdict: "review",
|
|
1802
|
+
reason: "The auth0 CLI is about to change who has access. node9 asks before access changes (Auth0)."
|
|
1803
|
+
},
|
|
1804
|
+
{
|
|
1805
|
+
name: "shield:auth0:review-api",
|
|
1806
|
+
tool: "bash",
|
|
1807
|
+
conditions: [
|
|
1808
|
+
{
|
|
1809
|
+
field: "command",
|
|
1810
|
+
op: "matches",
|
|
1811
|
+
// The Management API only; /oauth/token is signing in.
|
|
1812
|
+
value: httpTo(
|
|
1813
|
+
"\\.auth0\\.com/api/v2/(?:users|roles|clients|grants|client-grants|organizations|tickets|jobs/users-imports|device-credentials)(?![\\w-])"
|
|
1814
|
+
),
|
|
1815
|
+
flags: "i"
|
|
1816
|
+
},
|
|
1817
|
+
HTTP_WRITE_ANY
|
|
1818
|
+
],
|
|
1819
|
+
conditionMode: "all",
|
|
1820
|
+
verdict: "review",
|
|
1821
|
+
reason: "A request to the Auth0 Management API is about to change who has access. node9 asks before access changes (Auth0)."
|
|
1822
|
+
},
|
|
1823
|
+
{
|
|
1824
|
+
name: "shield:auth0:review-code",
|
|
1825
|
+
tool: "bash",
|
|
1826
|
+
conditions: [
|
|
1827
|
+
{
|
|
1828
|
+
field: "command",
|
|
1829
|
+
op: "matches",
|
|
1830
|
+
// The Auth0 SDK in the script (Node `auth0`, Python `auth0`).
|
|
1831
|
+
value: `\\bManagementClient\\b|from\\s+auth0[.\\s]|from\\s+["']auth0["']|require\\(\\s*["']auth0["']`
|
|
1832
|
+
},
|
|
1833
|
+
{
|
|
1834
|
+
field: "command",
|
|
1835
|
+
op: "matches",
|
|
1836
|
+
value: "\\.(?:users|roles|organizations|clients)\\.(?:create|delete|update|assignRoles|deleteRoles|assignUsers|addPermissions|deletePermissions|addMembers|deleteMembers|add_roles|remove_roles|add_users|add_permissions|remove_permissions)\\s*\\("
|
|
1837
|
+
}
|
|
1838
|
+
],
|
|
1839
|
+
conditionMode: "all",
|
|
1840
|
+
verdict: "review",
|
|
1841
|
+
reason: "This code changes who has access in Auth0. node9 asks before access changes (Auth0)."
|
|
1842
|
+
}
|
|
1843
|
+
]
|
|
1844
|
+
}
|
|
1845
|
+
];
|
|
1846
|
+
function buildAppShield(spec) {
|
|
1847
|
+
const owner = spec.label;
|
|
1848
|
+
const toolRules = ACTION_TEMPLATES[spec.template].filter(isToolRule).map((rule) => ({
|
|
1849
|
+
...rule,
|
|
1850
|
+
name: `shield:${spec.name}:${actionPart(rule.name)}`,
|
|
1851
|
+
server: spec.server,
|
|
1852
|
+
reason: ownReason(rule.reason, owner)
|
|
1853
|
+
}));
|
|
1854
|
+
const ownTools = (spec.mcpTools ?? []).map((rule) => ({
|
|
1855
|
+
...rule,
|
|
1856
|
+
server: spec.server
|
|
1857
|
+
}));
|
|
1858
|
+
return {
|
|
1859
|
+
name: spec.name,
|
|
1860
|
+
description: spec.description,
|
|
1861
|
+
aliases: [],
|
|
1862
|
+
smartRules: [...toolRules, ...ownTools, ...spec.doors],
|
|
1863
|
+
dangerousWords: []
|
|
1864
|
+
};
|
|
1865
|
+
}
|
|
1866
|
+
var APP_SHIELDS = APP_SHIELD_SPECS.map(buildAppShield);
|
|
1867
|
+
var APP_SHIELD_NAMES = new Set(APP_SHIELD_SPECS.map((s) => s.name));
|
|
1868
|
+
var APP_SERVER_GLOB = `{${APP_SHIELD_SPECS.map((s) => s.server).join(",")}}`;
|
|
1869
|
+
function buildGeneralRules() {
|
|
1870
|
+
const out = [];
|
|
1871
|
+
for (const name of Object.keys(ACTION_TEMPLATES)) {
|
|
1872
|
+
const { slug, label } = ACTION_CHECKS[name];
|
|
1873
|
+
for (const rule of ACTION_TEMPLATES[name].filter(isToolRule)) {
|
|
1874
|
+
const part = actionPart(rule.name).replace(/^review-/, "");
|
|
1875
|
+
out.push({
|
|
1876
|
+
...rule,
|
|
1877
|
+
name: `review-action-${slug}-${part}`,
|
|
1878
|
+
notServer: APP_SERVER_GLOB,
|
|
1879
|
+
reason: ownReason(rule.reason, label)
|
|
1880
|
+
});
|
|
1281
1881
|
}
|
|
1282
|
-
|
|
1283
|
-
|
|
1882
|
+
}
|
|
1883
|
+
return out;
|
|
1884
|
+
}
|
|
1885
|
+
var GENERAL_ACTION_RULES = buildGeneralRules();
|
|
1886
|
+
function generalActionRuleNames(template) {
|
|
1887
|
+
const { slug } = ACTION_CHECKS[template];
|
|
1888
|
+
return GENERAL_ACTION_RULES.filter((r) => r.name?.startsWith(`review-action-${slug}-`)).map(
|
|
1889
|
+
(r) => r.name
|
|
1890
|
+
);
|
|
1891
|
+
}
|
|
1892
|
+
var REPLACED_SHIELDS = {
|
|
1893
|
+
finance: "finance is now the Money check (actions.money), on by default. For an app: node9 shield enable stripe (or paypal).",
|
|
1894
|
+
identity: "identity is now the Accounts and access check (actions.access), on by default.",
|
|
1895
|
+
publishing: "publishing is now the Publishing check (actions.publish), on by default."
|
|
1284
1896
|
};
|
|
1285
1897
|
|
|
1286
1898
|
// src/shields/index.ts
|
|
@@ -1325,36 +1937,36 @@ var BUILTIN_SHIELDS = {
|
|
|
1325
1937
|
[bash_safe_default.name]: bash_safe_default,
|
|
1326
1938
|
[docker_default.name]: docker_default,
|
|
1327
1939
|
[filesystem_default.name]: filesystem_default,
|
|
1328
|
-
// Dangerous actions as category shields (node9Firewall#385): an MCP app's
|
|
1329
|
-
// money, credential and publishing tools, asked about whatever the request
|
|
1330
|
-
// said. One glob per rule covers the bare name the gateway sends and the
|
|
1331
|
-
// mcp__<server>__ name the agent hook sends.
|
|
1332
|
-
[finance_default.name]: finance_default,
|
|
1333
1940
|
[github_default.name]: github_default,
|
|
1334
|
-
[identity_default.name]: identity_default,
|
|
1335
1941
|
[k8s_default.name]: k8s_default,
|
|
1336
1942
|
[mongodb_default.name]: mongodb_default,
|
|
1337
1943
|
[postgres_default.name]: postgres_default,
|
|
1338
1944
|
[project_jail_default.name]: project_jail_default,
|
|
1339
|
-
[
|
|
1340
|
-
|
|
1945
|
+
[redis_default.name]: redis_default,
|
|
1946
|
+
// App shields generated from the action templates (node9Firewall#390): one
|
|
1947
|
+
// per app, every door (MCP server, CLI, API, library), off by default.
|
|
1948
|
+
...Object.fromEntries(APP_SHIELDS.map((s) => [s.name, s]))
|
|
1341
1949
|
};
|
|
1342
|
-
var ACTION_SHIELD_NAMES = /* @__PURE__ */ new Set([
|
|
1343
|
-
"finance",
|
|
1344
|
-
"identity",
|
|
1345
|
-
"publishing"
|
|
1346
|
-
]);
|
|
1347
1950
|
function assertBuiltinShieldRegexesAreSafe() {
|
|
1348
|
-
|
|
1951
|
+
const sets = [
|
|
1952
|
+
...Object.values(BUILTIN_SHIELDS).map((sh) => ({
|
|
1953
|
+
name: sh.name,
|
|
1954
|
+
smartRules: sh.smartRules
|
|
1955
|
+
})),
|
|
1956
|
+
...Object.entries(ACTION_TEMPLATES).map(([name, smartRules]) => ({ name, smartRules })),
|
|
1957
|
+
{ name: "general-action-checks", smartRules: GENERAL_ACTION_RULES }
|
|
1958
|
+
];
|
|
1959
|
+
for (const shield of sets) {
|
|
1349
1960
|
for (const rule of shield.smartRules) {
|
|
1350
1961
|
const conditions = rule.conditions ?? [];
|
|
1351
1962
|
for (const cond of conditions) {
|
|
1352
1963
|
if (cond.op !== "matches" && cond.op !== "notMatches") continue;
|
|
1353
1964
|
const pattern = cond.value;
|
|
1354
1965
|
if (!pattern) continue;
|
|
1355
|
-
|
|
1966
|
+
const problem = validateRegex(pattern);
|
|
1967
|
+
if (problem) {
|
|
1356
1968
|
throw new Error(
|
|
1357
|
-
`[node9 engine] Shield '${shield.name}' rule '${rule.name ?? rule.tool}' has
|
|
1969
|
+
`[node9 engine] Shield '${shield.name}' rule '${rule.name ?? rule.tool}' has a regex the runtime refuses (${problem}): ${pattern}`
|
|
1358
1970
|
);
|
|
1359
1971
|
}
|
|
1360
1972
|
}
|
|
@@ -1648,9 +2260,9 @@ var CHECK_TEXT = {
|
|
|
1648
2260
|
},
|
|
1649
2261
|
// ── Commands ──────────────────────────────────────────────────────────────
|
|
1650
2262
|
"commands.inline-exec": {
|
|
1651
|
-
plain: "The agent runs a small program written inside the command itself.",
|
|
2263
|
+
plain: "The agent runs a small program written inside the command itself, and node9 reads it: ordinary code runs, code that deletes, sends data out, runs other commands or reads protected files is held, and so is code node9 cannot read.",
|
|
1652
2264
|
example: `node -e "require('fs').rmSync('dist', {recursive: true})"`,
|
|
1653
|
-
advice: "
|
|
2265
|
+
advice: "Keep Review. Strict mode reviews every inline call, harmless or not; Log or Off only if inline code never reaches anything that matters."
|
|
1654
2266
|
},
|
|
1655
2267
|
"commands.eval-dynamic": {
|
|
1656
2268
|
plain: "The agent runs code whose content is built at run time, so node9 cannot read it in advance.",
|
|
@@ -1682,6 +2294,21 @@ var CHECK_TEXT = {
|
|
|
1682
2294
|
example: "chmod 777 deploy.sh",
|
|
1683
2295
|
advice: "Keep Review. A narrower permission (755, 644) almost always does the job."
|
|
1684
2296
|
},
|
|
2297
|
+
"actions.money": {
|
|
2298
|
+
plain: "The agent moves money (a refund, a payout, a transfer, a charge) through an app node9 has no protection for, such as an internal billing server.",
|
|
2299
|
+
example: "refund_order on a server called acme-billing",
|
|
2300
|
+
advice: "Keep Review. When the app is Stripe or PayPal, turn on its own protection instead: it covers the CLI, the API and scripts too, and a call from it no longer comes here."
|
|
2301
|
+
},
|
|
2302
|
+
"actions.access": {
|
|
2303
|
+
plain: "The agent changes a password, a key, a role or who belongs to a team, through an app node9 has no protection for.",
|
|
2304
|
+
example: "invite_user or grant_role on a company admin server",
|
|
2305
|
+
advice: "Keep Review. Set Log on a sandbox workspace where agents manage test users all day."
|
|
2306
|
+
},
|
|
2307
|
+
"actions.publish": {
|
|
2308
|
+
plain: "The agent publishes something outside the organisation (a release, a package, a deploy, a public post) through an app node9 has no protection for.",
|
|
2309
|
+
example: "create_release or deploy_to_production on a company MCP server",
|
|
2310
|
+
advice: "Keep Review. Set Log on a release machine whose pipeline publishes on purpose, never on a developer laptop."
|
|
2311
|
+
},
|
|
1685
2312
|
"commands.sudo": {
|
|
1686
2313
|
plain: "The agent runs a command as the administrator (root).",
|
|
1687
2314
|
example: "sudo apt-get install -y nginx",
|
|
@@ -1842,12 +2469,86 @@ var CHECK_TEXT = {
|
|
|
1842
2469
|
advice: "Fixed at Block. A person accepts the change on the machine (node9 mcp pin update)."
|
|
1843
2470
|
},
|
|
1844
2471
|
"loading.malicious-package": {
|
|
1845
|
-
plain: "The agent installs a package that the public malicious-package database (OSV) lists, or one published minutes ago. Covers npm, PyPI, RubyGems, crates.io, Go, NuGet, Maven, Packagist and VS Code extensions; the publish-age and install-script signals are npm and PyPI only.",
|
|
2472
|
+
plain: "The agent installs a package that the public malicious-package database (OSV) lists, or one published minutes ago. Covers npm, PyPI, RubyGems, crates.io, Go, NuGet, Maven, Packagist and VS Code extensions; the publish-age and install-script signals are npm and PyPI only. A new release built from the same repository as the one before it (registry provenance) and an install script the package has always run do not stop; a release that lost the provenance its previous release had does.",
|
|
1846
2473
|
example: "npm install of a package flagged as malware",
|
|
1847
2474
|
advice: "Keep Block for known-malicious packages; brand-new packages already stop for Review."
|
|
1848
2475
|
}
|
|
1849
2476
|
};
|
|
1850
2477
|
|
|
2478
|
+
// src/levels.ts
|
|
2479
|
+
var LEVELS = ["audit", "soft", "standard", "strict", "block-all"];
|
|
2480
|
+
var MODE_VALUES = ["observe", ...LEVELS];
|
|
2481
|
+
function isModeValue(v) {
|
|
2482
|
+
return typeof v === "string" && MODE_VALUES.includes(v);
|
|
2483
|
+
}
|
|
2484
|
+
function levelOf(mode) {
|
|
2485
|
+
if (mode === "observe") return "audit";
|
|
2486
|
+
return LEVELS.includes(mode ?? "") ? mode : "standard";
|
|
2487
|
+
}
|
|
2488
|
+
function isRecordOnly(mode) {
|
|
2489
|
+
return levelOf(mode) === "audit";
|
|
2490
|
+
}
|
|
2491
|
+
function reviewsEveryInline(mode) {
|
|
2492
|
+
const level = levelOf(mode);
|
|
2493
|
+
return level === "strict" || level === "block-all";
|
|
2494
|
+
}
|
|
2495
|
+
function isBlockAll(mode) {
|
|
2496
|
+
return levelOf(mode) === "block-all";
|
|
2497
|
+
}
|
|
2498
|
+
var SOFT = {
|
|
2499
|
+
"commands.inline-exec": "log",
|
|
2500
|
+
"commands.eval-dynamic": "log",
|
|
2501
|
+
"commands.rm": "log",
|
|
2502
|
+
"commands.chmod": "log",
|
|
2503
|
+
"commands.sudo": "log",
|
|
2504
|
+
"commands.git-destructive": "log",
|
|
2505
|
+
"commands.sql-ddl": "log",
|
|
2506
|
+
"commands.sql-no-where": "log",
|
|
2507
|
+
"commands.temp-binary": "log",
|
|
2508
|
+
"commands.disk-destroy": "log",
|
|
2509
|
+
"commands.dangerous-word": "log",
|
|
2510
|
+
"files.system-dirs": "log",
|
|
2511
|
+
"files.shell-startup": "log",
|
|
2512
|
+
"files.password-hashes": "log",
|
|
2513
|
+
"data.pipe-chain": "log",
|
|
2514
|
+
"behavior.untrusted-content": "log"
|
|
2515
|
+
};
|
|
2516
|
+
var STRICT = {
|
|
2517
|
+
"commands.sql-ddl": "block",
|
|
2518
|
+
"commands.disk-destroy": "block",
|
|
2519
|
+
"commands.node9-disarm": "block",
|
|
2520
|
+
"files.system-dirs": "block",
|
|
2521
|
+
"files.shell-startup": "block",
|
|
2522
|
+
"files.password-hashes": "block",
|
|
2523
|
+
"data.secrets-weak": "block",
|
|
2524
|
+
"data.pipe-chain": "block",
|
|
2525
|
+
"network.unknown-host": "review",
|
|
2526
|
+
"network.internal-addresses": "block",
|
|
2527
|
+
"behavior.prompt-injection": "log",
|
|
2528
|
+
"loading.skill-tamper": "block"
|
|
2529
|
+
};
|
|
2530
|
+
var BLOCK_ALL = {
|
|
2531
|
+
...STRICT,
|
|
2532
|
+
"commands.unknown": "review",
|
|
2533
|
+
"commands.temp-binary": "block"
|
|
2534
|
+
};
|
|
2535
|
+
var LEVEL_CHECKS = {
|
|
2536
|
+
audit: {},
|
|
2537
|
+
soft: SOFT,
|
|
2538
|
+
standard: {},
|
|
2539
|
+
strict: STRICT,
|
|
2540
|
+
"block-all": BLOCK_ALL
|
|
2541
|
+
};
|
|
2542
|
+
function levelCheckValue(mode, id) {
|
|
2543
|
+
return LEVEL_CHECKS[levelOf(mode)][id];
|
|
2544
|
+
}
|
|
2545
|
+
function levelChecks(mode) {
|
|
2546
|
+
return LEVEL_CHECKS[levelOf(mode)];
|
|
2547
|
+
}
|
|
2548
|
+
function levelPackageSignals(mode) {
|
|
2549
|
+
return levelOf(mode) === "soft" ? { newPackage: "off", installScript: "off" } : void 0;
|
|
2550
|
+
}
|
|
2551
|
+
|
|
1851
2552
|
// src/catalog.ts
|
|
1852
2553
|
var VERDICTS = ["off", "log", "review", "block"];
|
|
1853
2554
|
var CHECK_VERDICT_RANK = { off: 0, log: 1, review: 2, block: 3 };
|
|
@@ -1860,7 +2561,8 @@ var CHECK_GROUPS = [
|
|
|
1860
2561
|
{ id: "network", title: "Network" },
|
|
1861
2562
|
{ id: "files", title: "Files" },
|
|
1862
2563
|
{ id: "behavior", title: "Agent behavior" },
|
|
1863
|
-
{ id: "loading", title: "What the agent loads" }
|
|
2564
|
+
{ id: "loading", title: "What the agent loads" },
|
|
2565
|
+
{ id: "actions", title: "Actions in apps" }
|
|
1864
2566
|
];
|
|
1865
2567
|
var ALL = VERDICTS;
|
|
1866
2568
|
var BUILTIN_DANGEROUS_WORDS = ["mkfs", "shred"];
|
|
@@ -1907,7 +2609,7 @@ var PRODUCT_CHECKS = [
|
|
|
1907
2609
|
id: "commands.inline-exec",
|
|
1908
2610
|
group: "commands",
|
|
1909
2611
|
title: "Inline code execution",
|
|
1910
|
-
catches: "
|
|
2612
|
+
catches: "inline code (python -c, node -e, a heredoc into an interpreter) that deletes, sends, opens a socket, runs commands, reads protected files or decodes and runs; unreadable inline code",
|
|
1911
2613
|
values: ALL,
|
|
1912
2614
|
defaultValue: "review",
|
|
1913
2615
|
legacy: ["Node9 Standard (Inline Execution)"]
|
|
@@ -2264,6 +2966,38 @@ var PRODUCT_CHECKS = [
|
|
|
2264
2966
|
values: ALL,
|
|
2265
2967
|
defaultValue: "block",
|
|
2266
2968
|
legacy: ["\u{1F4E6} Node9 Package Check (Malicious)", "\u{1F4E6} Node9 Package Check (Review)"]
|
|
2969
|
+
},
|
|
2970
|
+
// ── Actions in apps (node9Firewall#390) ──────────────────────────────────
|
|
2971
|
+
// The safety net under the app shields: an action that moves money, changes
|
|
2972
|
+
// access or publishes, on an MCP server no app shield claims (an internal
|
|
2973
|
+
// billing server, a vendor with no shield, Zapier). Review by default; the
|
|
2974
|
+
// rules come from the action templates (shields/apps.ts).
|
|
2975
|
+
{
|
|
2976
|
+
id: "actions.money",
|
|
2977
|
+
group: "actions",
|
|
2978
|
+
title: "Money moves",
|
|
2979
|
+
catches: "a refund, payout, transfer, charge or withdrawal through an app with no protection of its own",
|
|
2980
|
+
values: ALL,
|
|
2981
|
+
defaultValue: "review",
|
|
2982
|
+
legacy: generalActionRuleNames("finance")
|
|
2983
|
+
},
|
|
2984
|
+
{
|
|
2985
|
+
id: "actions.access",
|
|
2986
|
+
group: "actions",
|
|
2987
|
+
title: "Accounts and access change",
|
|
2988
|
+
catches: "a password, key, role, permission or user changed through an app with no protection of its own",
|
|
2989
|
+
values: ALL,
|
|
2990
|
+
defaultValue: "review",
|
|
2991
|
+
legacy: generalActionRuleNames("identity")
|
|
2992
|
+
},
|
|
2993
|
+
{
|
|
2994
|
+
id: "actions.publish",
|
|
2995
|
+
group: "actions",
|
|
2996
|
+
title: "Something is published",
|
|
2997
|
+
catches: "a release, package, deploy or public post through an app with no protection of its own",
|
|
2998
|
+
values: ALL,
|
|
2999
|
+
defaultValue: "review",
|
|
3000
|
+
legacy: generalActionRuleNames("publishing")
|
|
2267
3001
|
}
|
|
2268
3002
|
];
|
|
2269
3003
|
var SHIELD_RULE_NAME = /^shield:([^:]+):(block|review|allow)-(.+)$/;
|
|
@@ -2325,7 +3059,7 @@ function ssrfCheckId(tier) {
|
|
|
2325
3059
|
var PROJECT_JAIL_BLOCK_READ = /^shield:project-jail:block-read-(ssh|aws|env)(-any-tool)?$/;
|
|
2326
3060
|
var OVERRIDE_PREFIX = "Override block rule:";
|
|
2327
3061
|
var LABEL_WRAPPERS = ["Smart Rule:", "Node9 (AST):", "project-jail (AST):"];
|
|
2328
|
-
function
|
|
3062
|
+
function ruleNameInLabel(s) {
|
|
2329
3063
|
let rest = s;
|
|
2330
3064
|
const override = rest.lastIndexOf(OVERRIDE_PREFIX);
|
|
2331
3065
|
if (override >= 0) rest = rest.slice(override + OVERRIDE_PREFIX.length).trimStart();
|
|
@@ -2341,7 +3075,7 @@ function checkIdForRule(nameOrLabel) {
|
|
|
2341
3075
|
const s = nameOrLabel.trim();
|
|
2342
3076
|
const exact = LEGACY_TO_ID.get(s);
|
|
2343
3077
|
if (exact) return exact;
|
|
2344
|
-
const unwrapped =
|
|
3078
|
+
const unwrapped = ruleNameInLabel(s);
|
|
2345
3079
|
if (unwrapped !== void 0) return checkIdForRule(unwrapped);
|
|
2346
3080
|
if (s.startsWith("shield:project-jail:")) {
|
|
2347
3081
|
return PROJECT_JAIL_BLOCK_READ.test(s) ? "data.credential-files" : "data.credential-files-other";
|
|
@@ -2421,7 +3155,7 @@ var LEGACY_READERS = {
|
|
|
2421
3155
|
"commands.rm": (s) => knob(s.commandChecks?.rmAdvisory),
|
|
2422
3156
|
"commands.chmod": (s) => knob(s.commandChecks?.chmod),
|
|
2423
3157
|
"commands.sql-ddl": (s) => knob(s.commandChecks?.sqlDdl),
|
|
2424
|
-
"commands.unknown": (s) => s.mode === void 0 ? void 0 : s.mode
|
|
3158
|
+
"commands.unknown": (s) => s.mode === void 0 ? void 0 : isBlockAll(s.mode) ? "review" : "off",
|
|
2425
3159
|
"data.secrets": (s) => enabledOr(s.dlp?.enabled, "block"),
|
|
2426
3160
|
"data.secrets-weak": (s) => {
|
|
2427
3161
|
if (s.dlp?.enabled === false) return "off";
|
|
@@ -2460,19 +3194,21 @@ function resolveCheck(settings, id) {
|
|
|
2460
3194
|
if (!def) return void 0;
|
|
2461
3195
|
if (isLockedCheck(def)) return { id, value: "block", source: "locked" };
|
|
2462
3196
|
const floor = def.floor ? CHECK_VERDICT_RANK[def.floor] : 0;
|
|
3197
|
+
const levelDefault = levelCheckValue(settings.mode, id) ?? def.defaultValue;
|
|
3198
|
+
const sourceOf = (value2) => value2 === levelDefault ? "default" : "configured";
|
|
2463
3199
|
const explicit = settings.checks?.[id];
|
|
2464
3200
|
if (isVerdict(explicit)) {
|
|
2465
3201
|
const value2 = CHECK_VERDICT_RANK[explicit] < floor ? def.floor : explicit;
|
|
2466
|
-
return { id, value: value2, source: value2
|
|
3202
|
+
return { id, value: value2, source: sourceOf(value2) };
|
|
2467
3203
|
}
|
|
2468
3204
|
if (def.pack) {
|
|
2469
3205
|
const on = settings.appliedShields?.includes(def.pack) ?? false;
|
|
2470
3206
|
return { id, value: on ? def.defaultValue : "off", source: "default" };
|
|
2471
3207
|
}
|
|
2472
3208
|
const read = LEGACY_READERS[id]?.(settings);
|
|
2473
|
-
if (read === void 0) return { id, value:
|
|
3209
|
+
if (read === void 0) return { id, value: levelDefault, source: "default" };
|
|
2474
3210
|
const value = CHECK_VERDICT_RANK[read] < floor ? def.floor : read;
|
|
2475
|
-
return { id, value, source: value
|
|
3211
|
+
return { id, value, source: sourceOf(value) };
|
|
2476
3212
|
}
|
|
2477
3213
|
function resolveAllChecks(settings) {
|
|
2478
3214
|
return CHECKS.map((c) => resolveCheck(settings, c.id));
|
|
@@ -2584,45 +3320,356 @@ function looksLikeText(buf) {
|
|
|
2584
3320
|
}
|
|
2585
3321
|
return printable / buf.length >= 0.9;
|
|
2586
3322
|
}
|
|
2587
|
-
var BASE64_RUN_RE = /[A-Za-z0-9+/]{32,}={0,2}|[A-Za-z0-9_-]{32,}/g;
|
|
2588
|
-
function decodeEmbeddedBase64(text) {
|
|
2589
|
-
const out = [];
|
|
2590
|
-
for (const m of text.matchAll(BASE64_RUN_RE)) {
|
|
2591
|
-
if (out.length >= MAX_BLOBS) break;
|
|
2592
|
-
const run = m[0];
|
|
2593
|
-
if (/^[0-9a-fA-F]+$/.test(run)) continue;
|
|
2594
|
-
const buf = Buffer.from(run, "base64");
|
|
2595
|
-
if (looksLikeText(buf)) out.push(buf.toString("utf8"));
|
|
3323
|
+
var BASE64_RUN_RE = /[A-Za-z0-9+/]{32,}={0,2}|[A-Za-z0-9_-]{32,}/g;
|
|
3324
|
+
function decodeEmbeddedBase64(text) {
|
|
3325
|
+
const out = [];
|
|
3326
|
+
for (const m of text.matchAll(BASE64_RUN_RE)) {
|
|
3327
|
+
if (out.length >= MAX_BLOBS) break;
|
|
3328
|
+
const run = m[0];
|
|
3329
|
+
if (/^[0-9a-fA-F]+$/.test(run)) continue;
|
|
3330
|
+
const buf = Buffer.from(run, "base64");
|
|
3331
|
+
if (looksLikeText(buf)) out.push(buf.toString("utf8"));
|
|
3332
|
+
}
|
|
3333
|
+
return out;
|
|
3334
|
+
}
|
|
3335
|
+
var HEX_RUN_RE = /\b(?:[0-9a-fA-F]{2}){24,}\b/g;
|
|
3336
|
+
var HEX_ESCAPE_RUN_RE = /(?:\\x[0-9a-fA-F]{2}){16,}/g;
|
|
3337
|
+
function decodeEmbeddedHex(text) {
|
|
3338
|
+
const out = [];
|
|
3339
|
+
for (const m of text.matchAll(HEX_RUN_RE)) {
|
|
3340
|
+
if (out.length >= MAX_BLOBS) break;
|
|
3341
|
+
const buf = Buffer.from(m[0], "hex");
|
|
3342
|
+
if (looksLikeText(buf)) out.push(buf.toString("utf8"));
|
|
3343
|
+
}
|
|
3344
|
+
for (const m of text.matchAll(HEX_ESCAPE_RUN_RE)) {
|
|
3345
|
+
if (out.length >= MAX_BLOBS) break;
|
|
3346
|
+
const buf = Buffer.from(m[0].replace(/\\x/g, ""), "hex");
|
|
3347
|
+
if (looksLikeText(buf)) out.push(buf.toString("utf8"));
|
|
3348
|
+
}
|
|
3349
|
+
return out;
|
|
3350
|
+
}
|
|
3351
|
+
function scanViews(text) {
|
|
3352
|
+
const views = [{ kind: "original", text }];
|
|
3353
|
+
const normalized = normalizeForScan(text);
|
|
3354
|
+
if (normalized !== text) views.push({ kind: "normalized", text: normalized });
|
|
3355
|
+
for (const t of decodeEmbeddedBase64(normalized)) {
|
|
3356
|
+
views.push({ kind: "base64", text: normalizeForScan(t) });
|
|
3357
|
+
}
|
|
3358
|
+
for (const t of decodeEmbeddedHex(normalized)) {
|
|
3359
|
+
views.push({ kind: "hex", text: normalizeForScan(t) });
|
|
3360
|
+
}
|
|
3361
|
+
return views;
|
|
3362
|
+
}
|
|
3363
|
+
|
|
3364
|
+
// src/files/paths.ts
|
|
3365
|
+
var SYSTEM_AUTH_FILES = [
|
|
3366
|
+
"/etc/passwd",
|
|
3367
|
+
"/etc/shadow",
|
|
3368
|
+
"/etc/group",
|
|
3369
|
+
"/etc/gshadow",
|
|
3370
|
+
"/etc/sudoers"
|
|
3371
|
+
];
|
|
3372
|
+
var SYSTEM_AUTH_DIRS = ["/etc/security", "/etc/pam.d", "/etc/sudoers.d"];
|
|
3373
|
+
var PASSWORD_HASH_FILES = ["/etc/shadow", "/etc/gshadow"];
|
|
3374
|
+
var STARTUP_NAMES = [".bashrc", ".zshrc", ".profile", ".bash_profile"];
|
|
3375
|
+
var SYSTEM_DIRS = [
|
|
3376
|
+
"/usr",
|
|
3377
|
+
"/etc",
|
|
3378
|
+
"/boot",
|
|
3379
|
+
"/bin",
|
|
3380
|
+
"/sbin",
|
|
3381
|
+
"/lib",
|
|
3382
|
+
"/lib64",
|
|
3383
|
+
"/var/log"
|
|
3384
|
+
];
|
|
3385
|
+
var SYSTEM_DIRS_EXEMPT = ["/usr/local", "/usr/src"];
|
|
3386
|
+
var UPLOAD_SYSTEM_DIRS = [...SYSTEM_DIRS, "/proc", "/sys", "/root"];
|
|
3387
|
+
var AGENT_INSTRUCTION_FILES = [
|
|
3388
|
+
".gitlab-ci.yml",
|
|
3389
|
+
"CLAUDE.md",
|
|
3390
|
+
"AGENTS.md",
|
|
3391
|
+
".cursorrules",
|
|
3392
|
+
".mcp.json",
|
|
3393
|
+
".vscode/settings.json",
|
|
3394
|
+
"package.json"
|
|
3395
|
+
];
|
|
3396
|
+
var AGENT_INSTRUCTION_DIRS = [
|
|
3397
|
+
".github/workflows",
|
|
3398
|
+
".claude",
|
|
3399
|
+
".cursor",
|
|
3400
|
+
".git/hooks",
|
|
3401
|
+
".husky"
|
|
3402
|
+
];
|
|
3403
|
+
function isAgentInstructionPath(absPath, root) {
|
|
3404
|
+
const r = root.replace(/\/$/, "");
|
|
3405
|
+
if (!(absPath === r || absPath.startsWith(r + "/"))) return false;
|
|
3406
|
+
const rel = absPath.slice(r.length + 1);
|
|
3407
|
+
if (AGENT_INSTRUCTION_FILES.includes(rel)) return true;
|
|
3408
|
+
return AGENT_INSTRUCTION_DIRS.some((d) => rel === d || rel.startsWith(d + "/"));
|
|
3409
|
+
}
|
|
3410
|
+
function isInside(root, p) {
|
|
3411
|
+
const r = root.replace(/\/$/, "") || "/";
|
|
3412
|
+
return p === r || p.startsWith(r === "/" ? "/" : r + "/");
|
|
3413
|
+
}
|
|
3414
|
+
var LEGACY_SYSTEM_PATH_RE = /^(?:[a-zA-Z]:)?\/etc\/(?:passwd|shadow|sudoers)$/;
|
|
3415
|
+
function isPasswordHashPath(p) {
|
|
3416
|
+
return PASSWORD_HASH_FILES.includes(p);
|
|
3417
|
+
}
|
|
3418
|
+
function isLegacySystemPath(p) {
|
|
3419
|
+
return LEGACY_SYSTEM_PATH_RE.test(p);
|
|
3420
|
+
}
|
|
3421
|
+
function normalizeFilePath(p, cwd = "", home = "~") {
|
|
3422
|
+
if (!p.startsWith("/") && !p.startsWith("~") && cwd) p = `${cwd}/${p}`;
|
|
3423
|
+
if (p === "~" || p.startsWith("~/")) p = home + p.slice(1);
|
|
3424
|
+
const rooted = p.startsWith("/");
|
|
3425
|
+
const parts = [];
|
|
3426
|
+
for (const part of p.split("/")) {
|
|
3427
|
+
if (!part || part === ".") continue;
|
|
3428
|
+
if (part === ".." && parts.length && parts.at(-1) !== "..") parts.pop();
|
|
3429
|
+
else if (part !== ".." || !rooted) parts.push(part);
|
|
3430
|
+
}
|
|
3431
|
+
return (rooted ? "/" : "") + parts.join("/");
|
|
3432
|
+
}
|
|
3433
|
+
|
|
3434
|
+
// src/shell/inline-code.ts
|
|
3435
|
+
var MAX_INLINE_CODE = 64 * 1024;
|
|
3436
|
+
var WHAT = {
|
|
3437
|
+
deletes: "deletes files",
|
|
3438
|
+
"writes-outside": "writes a file outside the project",
|
|
3439
|
+
sends: "sends data over the network",
|
|
3440
|
+
listens: "opens a listening socket or a shell",
|
|
3441
|
+
"runs-commands": "runs other commands or processes",
|
|
3442
|
+
"reads-protected": "reads a protected file",
|
|
3443
|
+
"builds-code": "runs code it builds at run time",
|
|
3444
|
+
permissions: "changes permissions or ownership",
|
|
3445
|
+
monitors: "captures the screen, the clipboard or the keyboard",
|
|
3446
|
+
amplifies: "writes or sends in an endless loop"
|
|
3447
|
+
};
|
|
3448
|
+
var OUTSIDE = String.raw`(?:~|\.\.[\\/]|/(?!(?:tmp|var/tmp)/(?![^'"\n]*\.\.)|dev/(?:null|stdout|stderr)\b))`;
|
|
3449
|
+
var pyImport = (mods) => new RegExp(String.raw`\b(?:import\s+(?:[\w.]+(?:\s+as\s+\w+)?\s*,\s*)*|from\s+)(?:${mods})\b`);
|
|
3450
|
+
var either = (...res) => new RegExp(res.map((r) => `(?:${r.source})`).join("|"), "m");
|
|
3451
|
+
var PYTHON = [
|
|
3452
|
+
[
|
|
3453
|
+
"deletes",
|
|
3454
|
+
/\bos\.(?:remove|unlink|rmdir|removedirs)\s*\(|\bshutil\.rmtree\s*\(|\.(?:unlink|rmdir)\s*\(|\bfrom\s+(?:os|shutil)\s+import\s+[^\n]*\b(?:remove|unlink|rmdir|removedirs|rmtree)\b/
|
|
3455
|
+
],
|
|
3456
|
+
[
|
|
3457
|
+
"writes-outside",
|
|
3458
|
+
new RegExp(
|
|
3459
|
+
String.raw`\bopen\s*\(\s*[rRbBuU]?['"]${OUTSIDE}[^'"\n]*['"]\s*,\s*(?:mode\s*=\s*)?[rRbB]?['"][^'"\n]*[wax+]|\bPath\s*\(\s*[rR]?['"]${OUTSIDE}[^'"\n]*['"]\s*\)\s*\.(?:write_text|write_bytes|touch|mkdir|symlink_to)\s*\(|\bshutil\.(?:copy\w*|move)\s*\([^)\n]*['"]${OUTSIDE}|\bos\.(?:rename|replace|symlink|link|truncate|makedirs|mkdir)\s*\([^)\n]*['"]${OUTSIDE}`
|
|
3460
|
+
)
|
|
3461
|
+
],
|
|
3462
|
+
[
|
|
3463
|
+
"sends",
|
|
3464
|
+
either(
|
|
3465
|
+
pyImport(
|
|
3466
|
+
String.raw`socket|requests|urllib2|urllib3|http\.client|httplib|smtplib|ftplib|paramiko|telnetlib|aiohttp|httpx|websockets?|xmlrpc|poplib|imaplib|pycurl|scapy`
|
|
3467
|
+
),
|
|
3468
|
+
/\burllib\.request\b|\burlopen\s*\(|\bfrom\s+urllib\s+import\s+[^\n;]*\brequest\b|\basyncio\.open_connection\s*\(/
|
|
3469
|
+
)
|
|
3470
|
+
],
|
|
3471
|
+
[
|
|
3472
|
+
"listens",
|
|
3473
|
+
either(
|
|
3474
|
+
pyImport(String.raw`pty|socketserver|http\.server`),
|
|
3475
|
+
/\bpty\.spawn\s*\(|\.bind\s*\(\s*\(|\basyncio\.start_server\s*\(/
|
|
3476
|
+
)
|
|
3477
|
+
],
|
|
3478
|
+
[
|
|
3479
|
+
"runs-commands",
|
|
3480
|
+
either(
|
|
3481
|
+
pyImport("subprocess|pexpect|commands|psutil"),
|
|
3482
|
+
/\bos\.(?:system|popen|exec\w*|spawn\w*|posix_spawn\w*|fork|forkpty|kill|killpg)\s*\(|\bfrom\s+os\s+import\s+[^\n;]*\b(?:system|popen|exec\w*|spawn\w*|fork|kill)\b|\bfrom\s+(?:os|shutil|pty|ctypes)\s+import\s+\*/
|
|
3483
|
+
)
|
|
3484
|
+
],
|
|
3485
|
+
[
|
|
3486
|
+
"builds-code",
|
|
3487
|
+
/(?<![\w.])(?:exec|eval|compile|execfile)\s*\(|\b__import__\s*\(|\bimportlib\b|\b(?:c?pickle|dill|marshal|shelve)\.loads?\s*\(|\byaml\.(?:unsafe_)?load\s*\((?![^)\n]*SafeLoader)|\bctypes\b|\b(?:getattr|vars)\s*\(\s*(?:os|subprocess|shutil|socket|sys|pty|builtins|__builtins__)\b|\b(?:os|subprocess|shutil|socket|sys|pty|builtins)\.__dict__\b|\b__builtins__\b|\bsys\.modules\b|\bglobals\s*\(\s*\)\s*\[/
|
|
3488
|
+
],
|
|
3489
|
+
[
|
|
3490
|
+
// Spyware shapes: a screenshot, the clipboard, a key logger.
|
|
3491
|
+
"monitors",
|
|
3492
|
+
either(
|
|
3493
|
+
pyImport(String.raw`pyperclip|pynput|keyboard|pyautogui|pyscreenshot|mss|clipboard`),
|
|
3494
|
+
/\bImageGrab\b|\bpyautogui\.screenshot\b|\bscreencapture\b/
|
|
3495
|
+
)
|
|
3496
|
+
],
|
|
3497
|
+
[
|
|
3498
|
+
"permissions",
|
|
3499
|
+
/\bos\.(?:chmod|lchmod|fchmod|chown|lchown|fchown|setuid|setgid|seteuid|setegid|setreuid|setregid|setresuid)\s*\(|\.chmod\s*\(|\bshutil\.chown\s*\(/
|
|
3500
|
+
]
|
|
3501
|
+
];
|
|
3502
|
+
var NODE = [
|
|
3503
|
+
[
|
|
3504
|
+
"deletes",
|
|
3505
|
+
/\.(?:rm|rmSync|rmdir|rmdirSync|unlink|unlinkSync)\s*\(|\brimraf\b|\bDeno\.remove(?:Sync)?\s*\(/
|
|
3506
|
+
],
|
|
3507
|
+
[
|
|
3508
|
+
"writes-outside",
|
|
3509
|
+
new RegExp(
|
|
3510
|
+
String.raw`(?:\.(?:writeFile|writeFileSync|appendFile|appendFileSync|createWriteStream|copyFile|copyFileSync|cp|cpSync|rename|renameSync|truncate|truncateSync|symlink|symlinkSync|mkdir|mkdirSync)|\bDeno\.(?:writeTextFile|writeFile|rename|mkdir)(?:Sync)?|\bBun\.write)\s*\(\s*['"\x60]${OUTSIDE}`
|
|
3511
|
+
)
|
|
3512
|
+
],
|
|
3513
|
+
[
|
|
3514
|
+
"sends",
|
|
3515
|
+
/\bfetch\s*\(|(?:\brequire\s*\(\s*|\bfrom\s+|\bimport\s+)['"\x60](?:node:)?(?:http|https|http2|net|dgram|tls|axios|node-fetch|ws|request|got|undici|nodemailer)['"\x60]|\bnew\s+WebSocket\b|\bXMLHttpRequest\b|\b(?:Deno|Bun)\.connect\w*\s*\(/
|
|
3516
|
+
],
|
|
3517
|
+
["listens", /\bcreateServer\s*\(|\b(?:Deno\.(?:listen\w*|serve)|Bun\.(?:listen|serve))\s*\(/],
|
|
3518
|
+
[
|
|
3519
|
+
"runs-commands",
|
|
3520
|
+
/\bchild_process\b|\bprocess\.(?:binding|dlopen|kill)\s*\(|\bDeno\.(?:run|Command)\b|\bBun\.(?:spawn|spawnSync|\$)\b|\bexecSync\s*\(|\bspawnSync\s*\(/
|
|
3521
|
+
],
|
|
3522
|
+
[
|
|
3523
|
+
"builds-code",
|
|
3524
|
+
/(?<![\w.])eval\s*\(|\bnew\s+Function\s*\(|(?<![\w.])Function\s*\(|(?:\brequire\s*\(\s*|\bfrom\s+)['"\x60](?:node:)?vm['"\x60]|\bvm\.\w+|\brequire\s*\(\s*[^'"\x60\s)]|\bimport\s*\(\s*[^'"\x60\s)]/
|
|
3525
|
+
],
|
|
3526
|
+
[
|
|
3527
|
+
"permissions",
|
|
3528
|
+
/\.(?:chmod|chmodSync|chown|chownSync|lchown|lchownSync|fchmod|fchmodSync|fchown|fchownSync)\s*\(|\bprocess\.set(?:e)?[ug]id\s*\(|\bDeno\.(?:chmod|chown)(?:Sync)?\s*\(/
|
|
3529
|
+
]
|
|
3530
|
+
];
|
|
3531
|
+
var PERL = [
|
|
3532
|
+
["deletes", /\b(?:unlink|rmdir|rmtree|remove_tree)\b/],
|
|
3533
|
+
[
|
|
3534
|
+
"writes-outside",
|
|
3535
|
+
new RegExp(
|
|
3536
|
+
String.raw`['"]\s*(?:\+?>>?|\+<)\s*['"]?\s*,?\s*['"]?${OUTSIDE}|\b(?:rename|symlink|link|copy|move)\s*\(?[^;\n]*['"]${OUTSIDE}`
|
|
3537
|
+
)
|
|
3538
|
+
],
|
|
3539
|
+
[
|
|
3540
|
+
"sends",
|
|
3541
|
+
/\b(?:IO::Socket|Socket|LWP|HTTP::Tiny|Net::\w+|Mojo::UserAgent|WWW::Mechanize|IO::Socket::INET)\b/
|
|
3542
|
+
],
|
|
3543
|
+
[
|
|
3544
|
+
"runs-commands",
|
|
3545
|
+
/\b(?:system|exec|fork|kill|syscall)\b|`[^`]*`|\bqx\s*[{([/|!'"]|\bopen\s*\(?[^;\n]*(?:['"]\s*\||\|\s*['"]|['"]-\|['"])/
|
|
3546
|
+
],
|
|
3547
|
+
["builds-code", /\beval\b|\bStorable::thaw\b|\bdo\s+['"]/],
|
|
3548
|
+
["permissions", /\b(?:chmod|chown)\b/]
|
|
3549
|
+
];
|
|
3550
|
+
var RUBY = [
|
|
3551
|
+
[
|
|
3552
|
+
"deletes",
|
|
3553
|
+
/\bFile\.(?:delete|unlink)\b|\bFileUtils\.(?:rm\w*|remove\w*)\b|\bDir\.(?:rmdir|delete|unlink)\b|\.(?:rmtree|delete_all)\b/
|
|
3554
|
+
],
|
|
3555
|
+
[
|
|
3556
|
+
"writes-outside",
|
|
3557
|
+
new RegExp(
|
|
3558
|
+
String.raw`\bFile\.(?:write|binwrite|symlink|rename)\s*\(?\s*['"]${OUTSIDE}|\bFile\.open\s*\(?\s*['"]${OUTSIDE}[^'"\n]*['"]\s*,\s*['"][wa+]|\bFileUtils\.(?:cp\w*|mv|install|ln\w*|mkdir_p|touch)\s*\(?[^\n]*['"]${OUTSIDE}`
|
|
3559
|
+
)
|
|
3560
|
+
],
|
|
3561
|
+
[
|
|
3562
|
+
"sends",
|
|
3563
|
+
/\bNet::\w+|\b(?:TCPSocket|UDPSocket|UNIXSocket|Socket)\b|\bopen-uri\b|\bURI\.open\b|\b(?:HTTParty|Faraday|RestClient|Excon|Typhoeus)\b|\brequire\s+['"](?:socket|net\/\w+|open-uri)['"]/
|
|
3564
|
+
],
|
|
3565
|
+
["listens", /\b(?:TCPServer|UNIXServer|WEBrick|PTY)\b/],
|
|
3566
|
+
[
|
|
3567
|
+
"runs-commands",
|
|
3568
|
+
/(?<![\w.])(?:system|exec|spawn|fork)\b|`[^`]*`|%x[{([|!]|(?<![\w.])open\s*\(?\s*['"]\||\bIO\.popen\b|\bOpen3\b|\bProcess\.(?:spawn|kill|exec)\b|\bKernel\.(?:system|exec|spawn|open)\b/
|
|
3569
|
+
],
|
|
3570
|
+
[
|
|
3571
|
+
"builds-code",
|
|
3572
|
+
/(?<![\w.])eval\b|\b(?:instance|class|module)_eval\b|\b(?:send|public_send)\s*\(?\s*:?['"]?(?:system|eval|exec|spawn)\b|\bMarshal\.load\b|\bYAML\.(?:unsafe_)?load\b|\bconst_get\b/
|
|
3573
|
+
],
|
|
3574
|
+
["permissions", /\b(?:File|FileUtils)\.(?:chmod|chown|lchmod|lchown)\w*\b/]
|
|
3575
|
+
];
|
|
3576
|
+
var PHP = [
|
|
3577
|
+
["deletes", /\b(?:unlink|rmdir)\s*\(/],
|
|
3578
|
+
[
|
|
3579
|
+
"writes-outside",
|
|
3580
|
+
new RegExp(
|
|
3581
|
+
String.raw`\b(?:file_put_contents|symlink|link|copy|rename|mkdir|touch)\s*\([^)\n]*['"]${OUTSIDE}|\bfopen\s*\(\s*['"]${OUTSIDE}[^'"\n]*['"]\s*,\s*['"][waxc+]`
|
|
3582
|
+
)
|
|
3583
|
+
],
|
|
3584
|
+
[
|
|
3585
|
+
"sends",
|
|
3586
|
+
/\b(?:curl_exec|curl_init|fsockopen|pfsockopen|stream_socket_client|socket_create|socket_connect|mail|ftp_connect)\s*\(|\b(?:file_get_contents|fopen|file|readfile)\s*\(\s*['"](?:https?|ftp):/
|
|
3587
|
+
],
|
|
3588
|
+
["listens", /\b(?:stream_socket_server|socket_bind|socket_listen)\s*\(/],
|
|
3589
|
+
[
|
|
3590
|
+
"runs-commands",
|
|
3591
|
+
/\b(?:system|exec|shell_exec|passthru|proc_open|popen|pcntl_exec|pcntl_fork|posix_kill)\s*\(|`[^`]*`/
|
|
3592
|
+
],
|
|
3593
|
+
[
|
|
3594
|
+
"builds-code",
|
|
3595
|
+
/\b(?:eval|assert|create_function|unserialize|call_user_func(?:_array)?)\s*\(|\bbase64_decode\b/
|
|
3596
|
+
],
|
|
3597
|
+
["permissions", /\b(?:chmod|chown|chgrp|lchown|lchgrp)\s*\(/]
|
|
3598
|
+
];
|
|
3599
|
+
var TABLES = {
|
|
3600
|
+
python: PYTHON,
|
|
3601
|
+
node: NODE,
|
|
3602
|
+
perl: PERL,
|
|
3603
|
+
ruby: RUBY,
|
|
3604
|
+
php: PHP
|
|
3605
|
+
};
|
|
3606
|
+
function inlineLanguageOf(interp) {
|
|
3607
|
+
const i = interp.toLowerCase();
|
|
3608
|
+
if (/^python[\d.]*$/.test(i)) return "python";
|
|
3609
|
+
if (/^(?:node|tsx|ts-node|deno|bun)$/.test(i)) return "node";
|
|
3610
|
+
if (i === "perl") return "perl";
|
|
3611
|
+
if (i === "ruby" || i === "irb") return "ruby";
|
|
3612
|
+
if (i === "php") return "php";
|
|
3613
|
+
return null;
|
|
3614
|
+
}
|
|
3615
|
+
function resolvePythonAliases(code) {
|
|
3616
|
+
const aliases = [...code.matchAll(/\bimport\s+([\w.]+)\s+as\s+(\w+)/g)].slice(0, 32);
|
|
3617
|
+
let out = code;
|
|
3618
|
+
for (const [, mod, alias] of aliases) {
|
|
3619
|
+
if (alias === mod) continue;
|
|
3620
|
+
out = out.replace(new RegExp(String.raw`(?<![\w.])${alias}\b`, "g"), mod);
|
|
2596
3621
|
}
|
|
2597
3622
|
return out;
|
|
2598
3623
|
}
|
|
2599
|
-
var
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
const
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
if (looksLikeText(buf)) out.push(buf.toString("utf8"));
|
|
2607
|
-
}
|
|
2608
|
-
for (const m of text.matchAll(HEX_ESCAPE_RUN_RE)) {
|
|
2609
|
-
if (out.length >= MAX_BLOBS) break;
|
|
2610
|
-
const buf = Buffer.from(m[0].replace(/\\x/g, ""), "hex");
|
|
2611
|
-
if (looksLikeText(buf)) out.push(buf.toString("utf8"));
|
|
3624
|
+
var STRING_LITERAL = /(['"`])((?:\\.|(?!\1)[^\\\n]){1,4096})\1/g;
|
|
3625
|
+
function protectedLiteral(code, isProtected) {
|
|
3626
|
+
let n = 0;
|
|
3627
|
+
for (const m of code.matchAll(STRING_LITERAL)) {
|
|
3628
|
+
if (++n > 2048) break;
|
|
3629
|
+
const value = m[2].trim();
|
|
3630
|
+
if (value && isProtected(value)) return value;
|
|
2612
3631
|
}
|
|
2613
|
-
return
|
|
3632
|
+
return null;
|
|
2614
3633
|
}
|
|
2615
|
-
function
|
|
2616
|
-
const
|
|
2617
|
-
const
|
|
2618
|
-
if (
|
|
2619
|
-
|
|
2620
|
-
|
|
3634
|
+
function amplifies(language, code) {
|
|
3635
|
+
const loop = language === "python" ? /\bwhile\s+(?:True|1)\s*:/ : language === "node" ? /\bwhile\s*\(\s*(?:true|1)\s*\)|\bfor\s*\(\s*;\s*;\s*\)|\bsetInterval\s*\(/ : /\bwhile\s*\(?\s*(?:1|true)\s*\)?|\bloop\s+do\b|\bfor\s*\(\s*;\s*;\s*\)/;
|
|
3636
|
+
const m = loop.exec(code);
|
|
3637
|
+
if (!m) return null;
|
|
3638
|
+
const body = code.slice(m.index);
|
|
3639
|
+
return /\.write\s*\(|\.(?:append|write)File(?:Sync)?\s*\(|\bopen\s*\(|\bprint\s*\(\s*[^)\n]*\bfile\s*=|\.send(?:all|to)?\s*\(|\bfwrite\s*\(|\bfile_put_contents\s*\(|\bsyswrite\b/.test(
|
|
3640
|
+
body
|
|
3641
|
+
) ? m[0] : null;
|
|
3642
|
+
}
|
|
3643
|
+
function judgeInlineCode(language, code, isProtected) {
|
|
3644
|
+
if (code.length > MAX_INLINE_CODE) {
|
|
3645
|
+
return { outcome: "unreadable", what: "is too long for node9 to read" };
|
|
3646
|
+
}
|
|
3647
|
+
const text = language === "python" ? resolvePythonAliases(code) : code;
|
|
3648
|
+
for (const [category, re] of TABLES[language]) {
|
|
3649
|
+
const m = re.exec(text);
|
|
3650
|
+
if (!m) continue;
|
|
3651
|
+
const evidence = m[0].trim().replace(/\s+/g, " ").slice(0, 60);
|
|
3652
|
+
return {
|
|
3653
|
+
outcome: category === "builds-code" ? "unreadable" : "dangerous",
|
|
3654
|
+
what: WHAT[category],
|
|
3655
|
+
evidence,
|
|
3656
|
+
category
|
|
3657
|
+
};
|
|
2621
3658
|
}
|
|
2622
|
-
|
|
2623
|
-
|
|
3659
|
+
const path = protectedLiteral(text, isProtected);
|
|
3660
|
+
if (path) {
|
|
3661
|
+
return {
|
|
3662
|
+
outcome: "dangerous",
|
|
3663
|
+
what: WHAT["reads-protected"],
|
|
3664
|
+
evidence: path.slice(0, 60),
|
|
3665
|
+
category: "reads-protected"
|
|
3666
|
+
};
|
|
2624
3667
|
}
|
|
2625
|
-
|
|
3668
|
+
const loop = amplifies(language, text);
|
|
3669
|
+
if (loop) {
|
|
3670
|
+
return { outcome: "dangerous", what: WHAT.amplifies, evidence: loop, category: "amplifies" };
|
|
3671
|
+
}
|
|
3672
|
+
return null;
|
|
2626
3673
|
}
|
|
2627
3674
|
|
|
2628
3675
|
// src/shell/index.ts
|
|
@@ -2731,6 +3778,59 @@ function cachedNormalize(command, compute) {
|
|
|
2731
3778
|
function normalizeCommandForPolicy(command) {
|
|
2732
3779
|
return commandReadingsImpl(command).posix;
|
|
2733
3780
|
}
|
|
3781
|
+
var INTERPRETER_LINE = /^#![ \t]*[\w./+-]+(?:[ \t]+[\w./+=:-]+)*[ \t]*\r?(?=\n|$)/;
|
|
3782
|
+
function fileAccessView(command) {
|
|
3783
|
+
const hit = accessViewCache.get(command);
|
|
3784
|
+
if (hit !== void 0) return hit;
|
|
3785
|
+
const view = fileAccessViewImpl(command);
|
|
3786
|
+
if (accessViewCache.size >= ACCESS_VIEW_CACHE_MAX) {
|
|
3787
|
+
const oldest = accessViewCache.keys().next().value;
|
|
3788
|
+
if (oldest !== void 0) accessViewCache.delete(oldest);
|
|
3789
|
+
}
|
|
3790
|
+
accessViewCache.set(command, view);
|
|
3791
|
+
return view;
|
|
3792
|
+
}
|
|
3793
|
+
var PROGRAM_DIR = /^(?:\/usr(?:\/local)?|\/opt\/homebrew|\/home\/linuxbrew\/\.linuxbrew)?\/s?bin\/[^/]+$|^\/snap\/bin\/[^/]+$|^(?![/~\\]|[A-Za-z]:|.*\.\.)/;
|
|
3794
|
+
var ACCESS_VIEW_CACHE_MAX = 1e3;
|
|
3795
|
+
var accessViewCache = /* @__PURE__ */ new Map();
|
|
3796
|
+
function fileAccessViewImpl(command) {
|
|
3797
|
+
const text = command.replace(INTERPRETER_LINE, "");
|
|
3798
|
+
const f = parseShared(text);
|
|
3799
|
+
if (f === PARSE_FAIL) return text;
|
|
3800
|
+
const toCharIndex = byteOffsetToCharIndex(text);
|
|
3801
|
+
const at = (byteOffset) => toCharIndex === null ? byteOffset : toCharIndex(byteOffset);
|
|
3802
|
+
const edits = [];
|
|
3803
|
+
try {
|
|
3804
|
+
syntax.Walk(f, (node) => {
|
|
3805
|
+
if (!node) return false;
|
|
3806
|
+
const n = node;
|
|
3807
|
+
if (syntax.NodeType(n) !== "CallExpr") return true;
|
|
3808
|
+
const args = n.Args || [];
|
|
3809
|
+
const words = args.map((a) => resolveWordLiteral(a));
|
|
3810
|
+
const head = unwrapCommandHead(words);
|
|
3811
|
+
for (const i of /* @__PURE__ */ new Set([0, head])) {
|
|
3812
|
+
const word = words[i];
|
|
3813
|
+
if (i >= args.length || word === null || word === void 0 || !/[\\/]/.test(word)) {
|
|
3814
|
+
continue;
|
|
3815
|
+
}
|
|
3816
|
+
if (!PROGRAM_DIR.test(word)) continue;
|
|
3817
|
+
const name = word.split(/[\\/]/).pop() ?? "";
|
|
3818
|
+
if (!name) continue;
|
|
3819
|
+
const s = at(args[i].Pos().Offset());
|
|
3820
|
+
const e = at(args[i].End().Offset());
|
|
3821
|
+
if (s < 0 || e < 0) continue;
|
|
3822
|
+
edits.push([s, e, name]);
|
|
3823
|
+
}
|
|
3824
|
+
return true;
|
|
3825
|
+
});
|
|
3826
|
+
} catch {
|
|
3827
|
+
return text;
|
|
3828
|
+
}
|
|
3829
|
+
edits.sort((a, b) => b[0] - a[0]);
|
|
3830
|
+
let out = text;
|
|
3831
|
+
for (const [s, e, rep] of edits) out = out.slice(0, s) + rep + out.slice(e);
|
|
3832
|
+
return out;
|
|
3833
|
+
}
|
|
2734
3834
|
function commandReadings(command) {
|
|
2735
3835
|
const r = commandReadingsImpl(command);
|
|
2736
3836
|
const out = /* @__PURE__ */ new Set([r.posix, r.separator, r.folded]);
|
|
@@ -3896,53 +4996,119 @@ function unwrapCommandHead(words, stopAtFind = false, stopAtDynamic = false) {
|
|
|
3896
4996
|
}
|
|
3897
4997
|
return i;
|
|
3898
4998
|
}
|
|
3899
|
-
function
|
|
4999
|
+
function heredocText(word) {
|
|
5000
|
+
const parts = word?.Parts ?? [];
|
|
5001
|
+
let out = "";
|
|
5002
|
+
for (const p of parts) {
|
|
5003
|
+
if (syntax.NodeType(p) !== "Lit") return null;
|
|
5004
|
+
out += p.Value ?? "";
|
|
5005
|
+
}
|
|
5006
|
+
return out;
|
|
5007
|
+
}
|
|
5008
|
+
function stdinCodeOf(redirs) {
|
|
5009
|
+
const heredoc = /* @__PURE__ */ new Set([deriveRedirOp("cat <<X\nX"), deriveRedirOp("cat <<-X\nX")]);
|
|
5010
|
+
const herestring = deriveRedirOp("cat <<< x");
|
|
5011
|
+
for (const r of redirs) {
|
|
5012
|
+
if (!r || !redirStdinOps().has(r.Op)) continue;
|
|
5013
|
+
if (heredoc.has(r.Op)) {
|
|
5014
|
+
const text = heredocText(r.Hdoc);
|
|
5015
|
+
return text === null ? { code: null, source: "variable" } : { code: text };
|
|
5016
|
+
}
|
|
5017
|
+
if (r.Op === herestring) {
|
|
5018
|
+
const text = resolveWordLiteral(r.Word);
|
|
5019
|
+
return text === null ? { code: null, source: "variable" } : { code: text };
|
|
5020
|
+
}
|
|
5021
|
+
return { code: null, source: "file" };
|
|
5022
|
+
}
|
|
5023
|
+
return { code: null, source: "file" };
|
|
5024
|
+
}
|
|
5025
|
+
function attachedCode(interp, flag) {
|
|
5026
|
+
const eq = flag.indexOf("=");
|
|
5027
|
+
if (flag.startsWith("--")) return eq >= 0 ? flag.slice(eq + 1) : null;
|
|
5028
|
+
if (/^(pwsh|powershell)/.test(interp)) return null;
|
|
5029
|
+
const letters = /^(perl|ruby|lua|bun|osascript|rscript|irb)$/.test(interp) ? "e" : /^(node|tsx|ts-node)$/.test(interp) ? "ep" : interp === "php" ? "r" : "c";
|
|
5030
|
+
const body = flag.slice(1);
|
|
5031
|
+
const at = [...body].findIndex((ch) => letters.includes(ch.toLowerCase()));
|
|
5032
|
+
if (at < 0) return null;
|
|
5033
|
+
let rest = body.slice(at + 1);
|
|
5034
|
+
if (letters === "ep" && /^[ep]*$/i.test(rest)) rest = "";
|
|
5035
|
+
return rest === "" ? null : rest;
|
|
5036
|
+
}
|
|
5037
|
+
function inlineExecCall(stmt, pipeFed) {
|
|
3900
5038
|
const cmd = stmt?.Cmd;
|
|
3901
|
-
if (!cmd || syntax.NodeType(cmd) !== "CallExpr") return
|
|
5039
|
+
if (!cmd || syntax.NodeType(cmd) !== "CallExpr") return null;
|
|
3902
5040
|
const words = (cmd.Args || []).map((a) => resolveWordLiteral(a));
|
|
3903
|
-
if (words.length === 0) return
|
|
5041
|
+
if (words.length === 0) return null;
|
|
3904
5042
|
const headIdx = unwrapCommandHead(words);
|
|
3905
5043
|
const rawHead = words[headIdx];
|
|
3906
|
-
if (rawHead == null) return
|
|
5044
|
+
if (rawHead == null) return null;
|
|
3907
5045
|
const interp = (rawHead.split("/").pop() ?? "").toLowerCase();
|
|
3908
|
-
if (!INLINE_INTERPRETER.test(interp)) return
|
|
5046
|
+
if (!INLINE_INTERPRETER.test(interp)) return null;
|
|
3909
5047
|
let args = words.slice(headIdx + 1);
|
|
3910
|
-
if (interp === "deno" && (args[0] ?? "").toLowerCase() === "eval")
|
|
5048
|
+
if (interp === "deno" && (args[0] ?? "").toLowerCase() === "eval") {
|
|
5049
|
+
const code = args[1] ?? null;
|
|
5050
|
+
return { interp, code: [code], source: code === null ? "variable" : void 0 };
|
|
5051
|
+
}
|
|
3911
5052
|
if (INTERP_LEADING_TARGET.has(interp)) {
|
|
3912
5053
|
const firstFlag = args.findIndex((a) => a == null || a.startsWith("-"));
|
|
3913
5054
|
args = firstFlag >= 0 ? args.slice(firstFlag) : [];
|
|
3914
5055
|
}
|
|
5056
|
+
const redirs = stmt.Redirs || cmd.Redirs || [];
|
|
5057
|
+
const stdinFed = redirs.some((r) => r && redirStdinOps().has(r.Op));
|
|
5058
|
+
const fromStdin = () => {
|
|
5059
|
+
if (stdinFed) {
|
|
5060
|
+
const { code, source } = stdinCodeOf(redirs);
|
|
5061
|
+
return { interp, code: [code], source };
|
|
5062
|
+
}
|
|
5063
|
+
return { interp, code: [null], source: "pipe" };
|
|
5064
|
+
};
|
|
3915
5065
|
let positionals2 = 0;
|
|
3916
5066
|
let selectedProgram = false;
|
|
5067
|
+
const codes = [];
|
|
3917
5068
|
for (let i = 0; i < args.length; i++) {
|
|
3918
5069
|
const a = args[i];
|
|
3919
5070
|
if (a == null) {
|
|
5071
|
+
if (codes.length > 0) break;
|
|
3920
5072
|
positionals2++;
|
|
3921
5073
|
selectedProgram = true;
|
|
3922
5074
|
continue;
|
|
3923
5075
|
}
|
|
3924
5076
|
if (!selectedProgram && isInlineCodeFlag(interp, a)) {
|
|
3925
|
-
if (
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
5077
|
+
if (/^(bash|sh|zsh|dash|ksh)$/.test(interp)) {
|
|
5078
|
+
const payload = args[i + 1];
|
|
5079
|
+
if (payload == null) return { interp, code: [null], source: "variable" };
|
|
5080
|
+
return shellPayloadNeedsReview(payload) ? { interp, code: [null], source: "payload" } : null;
|
|
5081
|
+
}
|
|
5082
|
+
const attached = attachedCode(interp, a);
|
|
5083
|
+
if (attached !== null) {
|
|
5084
|
+
codes.push(attached);
|
|
5085
|
+
} else {
|
|
5086
|
+
codes.push(args[i + 1] ?? null);
|
|
5087
|
+
i++;
|
|
5088
|
+
}
|
|
5089
|
+
continue;
|
|
5090
|
+
}
|
|
5091
|
+
if (codes.length > 0) {
|
|
5092
|
+
if (a.startsWith("-")) continue;
|
|
5093
|
+
break;
|
|
3929
5094
|
}
|
|
3930
5095
|
if (a === "-m") {
|
|
3931
5096
|
selectedProgram = true;
|
|
3932
5097
|
continue;
|
|
3933
5098
|
}
|
|
3934
|
-
if (a === "-" && !selectedProgram) return
|
|
5099
|
+
if (a === "-" && !selectedProgram) return fromStdin();
|
|
3935
5100
|
if (!a.startsWith("-")) {
|
|
3936
5101
|
positionals2++;
|
|
3937
5102
|
selectedProgram = true;
|
|
3938
5103
|
}
|
|
3939
5104
|
}
|
|
3940
|
-
|
|
3941
|
-
|
|
5105
|
+
if (codes.length > 0) {
|
|
5106
|
+
return { interp, code: codes, source: codes.includes(null) ? "variable" : void 0 };
|
|
5107
|
+
}
|
|
3942
5108
|
if (positionals2 === 0 && (stdinFed || pipeFed)) {
|
|
3943
|
-
if (!/^(bash|sh|zsh)$/i.test(interp)) return
|
|
5109
|
+
if (!/^(bash|sh|zsh)$/i.test(interp)) return fromStdin();
|
|
3944
5110
|
}
|
|
3945
|
-
return
|
|
5111
|
+
return null;
|
|
3946
5112
|
}
|
|
3947
5113
|
var MAX_PAYLOAD_NESTING = 8;
|
|
3948
5114
|
var payloadNesting = 0;
|
|
@@ -3977,7 +5143,7 @@ function shellPayloadNeedsReview(payload) {
|
|
|
3977
5143
|
payload
|
|
3978
5144
|
))
|
|
3979
5145
|
review = true;
|
|
3980
|
-
if (!review &&
|
|
5146
|
+
if (!review && inlineExecReview(payload) !== null) review = true;
|
|
3981
5147
|
} catch {
|
|
3982
5148
|
review = true;
|
|
3983
5149
|
} finally {
|
|
@@ -3985,35 +5151,85 @@ function shellPayloadNeedsReview(payload) {
|
|
|
3985
5151
|
}
|
|
3986
5152
|
return review;
|
|
3987
5153
|
}
|
|
3988
|
-
|
|
5154
|
+
var MAX_INLINE_CALLS = 16;
|
|
5155
|
+
function inlineExecCalls(command) {
|
|
3989
5156
|
const f = parseShared(command);
|
|
3990
|
-
if (f === PARSE_FAIL)
|
|
3991
|
-
|
|
3992
|
-
command
|
|
3993
|
-
);
|
|
3994
|
-
}
|
|
3995
|
-
let found = false;
|
|
5157
|
+
if (f === PARSE_FAIL) return PARSE_FAIL;
|
|
5158
|
+
const calls = [];
|
|
3996
5159
|
try {
|
|
3997
5160
|
syntax.Walk(f, (node) => {
|
|
3998
|
-
if (!node ||
|
|
5161
|
+
if (!node || calls.length >= MAX_INLINE_CALLS) return false;
|
|
3999
5162
|
const n = node;
|
|
4000
5163
|
const t = syntax.NodeType(n);
|
|
4001
5164
|
if (t === "BinaryCmd" && n.Y && !listOps().has(n.Op)) {
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
return false;
|
|
4005
|
-
}
|
|
5165
|
+
const call = inlineExecCall(n.Y, true);
|
|
5166
|
+
if (call) calls.push(call);
|
|
4006
5167
|
}
|
|
4007
|
-
if (t === "Stmt"
|
|
4008
|
-
|
|
4009
|
-
|
|
5168
|
+
if (t === "Stmt") {
|
|
5169
|
+
const call = inlineExecCall(n, false);
|
|
5170
|
+
if (call) calls.push(call);
|
|
4010
5171
|
}
|
|
4011
5172
|
return true;
|
|
4012
5173
|
});
|
|
4013
5174
|
} catch {
|
|
4014
|
-
return found;
|
|
4015
5175
|
}
|
|
4016
|
-
return
|
|
5176
|
+
return calls;
|
|
5177
|
+
}
|
|
5178
|
+
var INLINE_EXEC_FALLBACK = /(^|[|;&]|&&)\s*(?:[\w./-]*\/)?(python[\d.]*|perl|ruby|node|php|lua|deno|bun|pwsh|osascript|rscript|bash|sh|zsh)\s+-{1,2}[a-z]*[ceEr]/i;
|
|
5179
|
+
function detectInlineExec(command) {
|
|
5180
|
+
const calls = inlineExecCalls(command);
|
|
5181
|
+
if (calls === PARSE_FAIL) return INLINE_EXEC_FALLBACK.test(command);
|
|
5182
|
+
return calls.length > 0;
|
|
5183
|
+
}
|
|
5184
|
+
var UNREADABLE_SOURCE = {
|
|
5185
|
+
pipe: "reads its code from another program through a pipe",
|
|
5186
|
+
file: "reads its code from a file on stdin",
|
|
5187
|
+
variable: "runs code the shell fills in at run time",
|
|
5188
|
+
payload: "runs a shell payload that evaluates, sources or runs further code"
|
|
5189
|
+
};
|
|
5190
|
+
function isProtectedCodePath(p) {
|
|
5191
|
+
if (matchSensitivePath(p) !== null) return true;
|
|
5192
|
+
return SYSTEM_AUTH_FILES.includes(p) || SYSTEM_AUTH_DIRS.some((d) => p === d || p.startsWith(d + "/"));
|
|
5193
|
+
}
|
|
5194
|
+
function inlineExecDescription(r) {
|
|
5195
|
+
const lead = r ? `The AI is running code directly from the command line: ${inlineExecReason(r).replace(/^This/, "this")}.` : "The AI is running code directly from the command line.";
|
|
5196
|
+
return `${lead} Review the full script below before allowing it to execute.`;
|
|
5197
|
+
}
|
|
5198
|
+
function inlineExecReason(r) {
|
|
5199
|
+
const who = r.interp ? `This inline ${r.interp} code` : "This inline code";
|
|
5200
|
+
return r.evidence ? `${who} ${r.what} (${r.evidence})` : `${who} ${r.what}`;
|
|
5201
|
+
}
|
|
5202
|
+
function inlineExecReview(command) {
|
|
5203
|
+
const calls = inlineExecCalls(command);
|
|
5204
|
+
if (calls === PARSE_FAIL) {
|
|
5205
|
+
return INLINE_EXEC_FALLBACK.test(command) ? { outcome: "unreadable", interp: "", what: "could not be parsed" } : null;
|
|
5206
|
+
}
|
|
5207
|
+
let unreadable = calls.length >= MAX_INLINE_CALLS ? { outcome: "unreadable", interp: "", what: "runs more inline programs than node9 reads" } : null;
|
|
5208
|
+
for (const call of calls) {
|
|
5209
|
+
const language = inlineLanguageOf(call.interp);
|
|
5210
|
+
for (const code of call.code) {
|
|
5211
|
+
let finding = null;
|
|
5212
|
+
if (code === null) {
|
|
5213
|
+
finding = {
|
|
5214
|
+
outcome: "unreadable",
|
|
5215
|
+
interp: call.interp,
|
|
5216
|
+
what: UNREADABLE_SOURCE[call.source ?? "variable"]
|
|
5217
|
+
};
|
|
5218
|
+
} else if (language === null) {
|
|
5219
|
+
finding = {
|
|
5220
|
+
outcome: "unreadable",
|
|
5221
|
+
interp: call.interp,
|
|
5222
|
+
what: `is ${call.interp} code, which node9 does not read`
|
|
5223
|
+
};
|
|
5224
|
+
} else {
|
|
5225
|
+
const judged = judgeInlineCode(language, code, isProtectedCodePath);
|
|
5226
|
+
if (judged) finding = { ...judged, interp: call.interp };
|
|
5227
|
+
}
|
|
5228
|
+
if (finding?.outcome === "dangerous") return finding;
|
|
5229
|
+
if (finding && !unreadable) unreadable = finding;
|
|
5230
|
+
}
|
|
5231
|
+
}
|
|
5232
|
+
return unreadable;
|
|
4017
5233
|
}
|
|
4018
5234
|
function analyzeChmod777(command) {
|
|
4019
5235
|
if (!/chmod/i.test(command.replace(/[\\'"]/g, ""))) return null;
|
|
@@ -5481,46 +6697,6 @@ function analyzeShellCommand(command) {
|
|
|
5481
6697
|
return { actions, paths, allTokens };
|
|
5482
6698
|
}
|
|
5483
6699
|
|
|
5484
|
-
// src/utils/regex.ts
|
|
5485
|
-
var import_safe_regex22 = __toESM(require("safe-regex2"));
|
|
5486
|
-
var MAX_REGEX_LENGTH = 256;
|
|
5487
|
-
var REGEX_CACHE_MAX = 500;
|
|
5488
|
-
var regexCache = /* @__PURE__ */ new Map();
|
|
5489
|
-
function validateRegex(pattern) {
|
|
5490
|
-
if (!pattern) return "Pattern is required";
|
|
5491
|
-
if (pattern.length > MAX_REGEX_LENGTH) return `Pattern exceeds max length of ${MAX_REGEX_LENGTH}`;
|
|
5492
|
-
try {
|
|
5493
|
-
new RegExp(pattern);
|
|
5494
|
-
} catch (e) {
|
|
5495
|
-
return `Invalid regex syntax: ${e.message}`;
|
|
5496
|
-
}
|
|
5497
|
-
if (/\\\d+[*+{]/.test(pattern)) return "Quantified backreferences are forbidden (ReDoS risk)";
|
|
5498
|
-
if (!(0, import_safe_regex22.default)(pattern)) return "Pattern rejected: potential ReDoS vulnerability detected";
|
|
5499
|
-
return null;
|
|
5500
|
-
}
|
|
5501
|
-
function getCompiledRegex(pattern, flags = "") {
|
|
5502
|
-
if (flags && !/^[gimsuy]+$/.test(flags)) return null;
|
|
5503
|
-
const key = `${pattern}\0${flags}`;
|
|
5504
|
-
if (regexCache.has(key)) {
|
|
5505
|
-
const cached = regexCache.get(key);
|
|
5506
|
-
regexCache.delete(key);
|
|
5507
|
-
regexCache.set(key, cached);
|
|
5508
|
-
return cached;
|
|
5509
|
-
}
|
|
5510
|
-
if (validateRegex(pattern) !== null) return null;
|
|
5511
|
-
try {
|
|
5512
|
-
const re = new RegExp(pattern, flags);
|
|
5513
|
-
if (regexCache.size >= REGEX_CACHE_MAX) {
|
|
5514
|
-
const oldest = regexCache.keys().next().value;
|
|
5515
|
-
if (oldest) regexCache.delete(oldest);
|
|
5516
|
-
}
|
|
5517
|
-
regexCache.set(key, re);
|
|
5518
|
-
return re;
|
|
5519
|
-
} catch {
|
|
5520
|
-
return null;
|
|
5521
|
-
}
|
|
5522
|
-
}
|
|
5523
|
-
|
|
5524
6700
|
// src/rules/index.ts
|
|
5525
6701
|
function matchesPattern(text, patterns) {
|
|
5526
6702
|
const p = Array.isArray(patterns) ? patterns : [patterns];
|
|
@@ -5532,6 +6708,18 @@ function matchesPattern(text, patterns) {
|
|
|
5532
6708
|
const withoutDotSlash = text.replace(/^\.\//, "");
|
|
5533
6709
|
return isMatch(withoutDotSlash) || isMatch(`./${withoutDotSlash}`);
|
|
5534
6710
|
}
|
|
6711
|
+
function mcpServerFromToolName(toolName) {
|
|
6712
|
+
const match = toolName.match(/^mcp__([^_](?:[^_]|_(?!_))*?)__/i);
|
|
6713
|
+
return match?.[1];
|
|
6714
|
+
}
|
|
6715
|
+
function ruleServerMatches(rule, serverLabel) {
|
|
6716
|
+
const label = typeof serverLabel === "string" ? serverLabel.trim().replace(/[\\/]/g, "-") || void 0 : void 0;
|
|
6717
|
+
if (rule.server) {
|
|
6718
|
+
if (!label || !matchesPattern(label, rule.server)) return false;
|
|
6719
|
+
}
|
|
6720
|
+
if (rule.notServer && label && matchesPattern(label, rule.notServer)) return false;
|
|
6721
|
+
return true;
|
|
6722
|
+
}
|
|
5535
6723
|
var FORBIDDEN_PATH_SEGMENTS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
5536
6724
|
function getNestedValue(obj, path) {
|
|
5537
6725
|
if (!obj || typeof obj !== "object") return null;
|
|
@@ -5555,23 +6743,26 @@ function evaluateSmartConditions(args, rule) {
|
|
|
5555
6743
|
return val;
|
|
5556
6744
|
};
|
|
5557
6745
|
const readingsCache = /* @__PURE__ */ new Map();
|
|
5558
|
-
const resolveFieldReadings = (field) => {
|
|
5559
|
-
const
|
|
6746
|
+
const resolveFieldReadings = (field, reading) => {
|
|
6747
|
+
const access = reading === "access" && field === "command";
|
|
6748
|
+
const key = access ? `${field}\0access` : field;
|
|
6749
|
+
const cached = readingsCache.get(key);
|
|
5560
6750
|
if (cached) return cached;
|
|
5561
6751
|
const primary = resolveField(field);
|
|
5562
6752
|
if (primary === null) {
|
|
5563
|
-
readingsCache.set(
|
|
6753
|
+
readingsCache.set(key, []);
|
|
5564
6754
|
return [];
|
|
5565
6755
|
}
|
|
5566
6756
|
let out = [primary];
|
|
5567
6757
|
if (field === "command") {
|
|
5568
6758
|
const raw = getNestedValue(args, field);
|
|
5569
6759
|
if (typeof raw === "string") {
|
|
5570
|
-
const
|
|
5571
|
-
|
|
6760
|
+
const text = access ? fileAccessView(raw) : raw;
|
|
6761
|
+
const collapsed = commandReadings(text).map((r) => r.replace(/\s+/g, " ").trim());
|
|
6762
|
+
out = access ? [...new Set(collapsed)] : [.../* @__PURE__ */ new Set([primary, ...collapsed])];
|
|
5572
6763
|
}
|
|
5573
6764
|
}
|
|
5574
|
-
readingsCache.set(
|
|
6765
|
+
readingsCache.set(key, out);
|
|
5575
6766
|
return out;
|
|
5576
6767
|
};
|
|
5577
6768
|
const results = rule.conditions.map((cond) => {
|
|
@@ -5589,14 +6780,14 @@ function evaluateSmartConditions(args, rule) {
|
|
|
5589
6780
|
if (val === null || !cond.value) return false;
|
|
5590
6781
|
const reM = getCompiledRegex(cond.value, cond.flags ?? "");
|
|
5591
6782
|
if (!reM) return false;
|
|
5592
|
-
return resolveFieldReadings(cond.field).some((v) => reM.test(v));
|
|
6783
|
+
return resolveFieldReadings(cond.field, cond.reading).some((v) => reM.test(v));
|
|
5593
6784
|
}
|
|
5594
6785
|
case "notMatches": {
|
|
5595
6786
|
if (!cond.value) return false;
|
|
5596
6787
|
if (val === null) return true;
|
|
5597
6788
|
const reN = getCompiledRegex(cond.value, cond.flags ?? "");
|
|
5598
6789
|
if (!reN) return false;
|
|
5599
|
-
return !resolveFieldReadings(cond.field).some((v) => reN.test(v));
|
|
6790
|
+
return !resolveFieldReadings(cond.field, cond.reading).some((v) => reN.test(v));
|
|
5600
6791
|
}
|
|
5601
6792
|
case "matchesGlob":
|
|
5602
6793
|
return val !== null && cond.value ? import_picomatch.default.isMatch(val, cond.value) : false;
|
|
@@ -6557,76 +7748,6 @@ function collectShellFileAccesses(command, context = {}) {
|
|
|
6557
7748
|
return out;
|
|
6558
7749
|
}
|
|
6559
7750
|
|
|
6560
|
-
// src/files/paths.ts
|
|
6561
|
-
var SYSTEM_AUTH_FILES = [
|
|
6562
|
-
"/etc/passwd",
|
|
6563
|
-
"/etc/shadow",
|
|
6564
|
-
"/etc/group",
|
|
6565
|
-
"/etc/gshadow",
|
|
6566
|
-
"/etc/sudoers"
|
|
6567
|
-
];
|
|
6568
|
-
var SYSTEM_AUTH_DIRS = ["/etc/security", "/etc/pam.d", "/etc/sudoers.d"];
|
|
6569
|
-
var PASSWORD_HASH_FILES = ["/etc/shadow", "/etc/gshadow"];
|
|
6570
|
-
var STARTUP_NAMES = [".bashrc", ".zshrc", ".profile", ".bash_profile"];
|
|
6571
|
-
var SYSTEM_DIRS = [
|
|
6572
|
-
"/usr",
|
|
6573
|
-
"/etc",
|
|
6574
|
-
"/boot",
|
|
6575
|
-
"/bin",
|
|
6576
|
-
"/sbin",
|
|
6577
|
-
"/lib",
|
|
6578
|
-
"/lib64",
|
|
6579
|
-
"/var/log"
|
|
6580
|
-
];
|
|
6581
|
-
var SYSTEM_DIRS_EXEMPT = ["/usr/local", "/usr/src"];
|
|
6582
|
-
var UPLOAD_SYSTEM_DIRS = [...SYSTEM_DIRS, "/proc", "/sys", "/root"];
|
|
6583
|
-
var AGENT_INSTRUCTION_FILES = [
|
|
6584
|
-
".gitlab-ci.yml",
|
|
6585
|
-
"CLAUDE.md",
|
|
6586
|
-
"AGENTS.md",
|
|
6587
|
-
".cursorrules",
|
|
6588
|
-
".mcp.json",
|
|
6589
|
-
".vscode/settings.json",
|
|
6590
|
-
"package.json"
|
|
6591
|
-
];
|
|
6592
|
-
var AGENT_INSTRUCTION_DIRS = [
|
|
6593
|
-
".github/workflows",
|
|
6594
|
-
".claude",
|
|
6595
|
-
".cursor",
|
|
6596
|
-
".git/hooks",
|
|
6597
|
-
".husky"
|
|
6598
|
-
];
|
|
6599
|
-
function isAgentInstructionPath(absPath, root) {
|
|
6600
|
-
const r = root.replace(/\/$/, "");
|
|
6601
|
-
if (!(absPath === r || absPath.startsWith(r + "/"))) return false;
|
|
6602
|
-
const rel = absPath.slice(r.length + 1);
|
|
6603
|
-
if (AGENT_INSTRUCTION_FILES.includes(rel)) return true;
|
|
6604
|
-
return AGENT_INSTRUCTION_DIRS.some((d) => rel === d || rel.startsWith(d + "/"));
|
|
6605
|
-
}
|
|
6606
|
-
function isInside(root, p) {
|
|
6607
|
-
const r = root.replace(/\/$/, "") || "/";
|
|
6608
|
-
return p === r || p.startsWith(r === "/" ? "/" : r + "/");
|
|
6609
|
-
}
|
|
6610
|
-
var LEGACY_SYSTEM_PATH_RE = /^(?:[a-zA-Z]:)?\/etc\/(?:passwd|shadow|sudoers)$/;
|
|
6611
|
-
function isPasswordHashPath(p) {
|
|
6612
|
-
return PASSWORD_HASH_FILES.includes(p);
|
|
6613
|
-
}
|
|
6614
|
-
function isLegacySystemPath(p) {
|
|
6615
|
-
return LEGACY_SYSTEM_PATH_RE.test(p);
|
|
6616
|
-
}
|
|
6617
|
-
function normalizeFilePath(p, cwd = "", home = "~") {
|
|
6618
|
-
if (!p.startsWith("/") && !p.startsWith("~") && cwd) p = `${cwd}/${p}`;
|
|
6619
|
-
if (p === "~" || p.startsWith("~/")) p = home + p.slice(1);
|
|
6620
|
-
const rooted = p.startsWith("/");
|
|
6621
|
-
const parts = [];
|
|
6622
|
-
for (const part of p.split("/")) {
|
|
6623
|
-
if (!part || part === ".") continue;
|
|
6624
|
-
if (part === ".." && parts.length && parts.at(-1) !== "..") parts.pop();
|
|
6625
|
-
else if (part !== ".." || !rooted) parts.push(part);
|
|
6626
|
-
}
|
|
6627
|
-
return (rooted ? "/" : "") + parts.join("/");
|
|
6628
|
-
}
|
|
6629
|
-
|
|
6630
7751
|
// src/files/protected-access.ts
|
|
6631
7752
|
function incompleteFileVerdict(operation = "write") {
|
|
6632
7753
|
return {
|
|
@@ -6809,7 +7930,7 @@ function evaluateProtectedFileAccess(accesses, context, settings) {
|
|
|
6809
7930
|
}
|
|
6810
7931
|
|
|
6811
7932
|
// src/dlp/index.ts
|
|
6812
|
-
var
|
|
7933
|
+
var import_safe_regex22 = __toESM(require("safe-regex2"));
|
|
6813
7934
|
|
|
6814
7935
|
// src/dlp/mnemonic.ts
|
|
6815
7936
|
var import_node_crypto = require("crypto");
|
|
@@ -10542,14 +11663,14 @@ var SENSITIVE_PATH_REGEXES = [
|
|
|
10542
11663
|
];
|
|
10543
11664
|
function assertBuiltinPatternsAreSafe() {
|
|
10544
11665
|
for (const p of DLP_PATTERNS) {
|
|
10545
|
-
if (!(0,
|
|
11666
|
+
if (!(0, import_safe_regex22.default)(p.regex.source)) {
|
|
10546
11667
|
throw new Error(
|
|
10547
11668
|
`[node9 engine] Builtin DLP pattern '${p.name}' is vulnerable to ReDoS: ${p.regex.source}`
|
|
10548
11669
|
);
|
|
10549
11670
|
}
|
|
10550
11671
|
}
|
|
10551
11672
|
for (const re of SENSITIVE_PATH_PATTERNS) {
|
|
10552
|
-
if (!(0,
|
|
11673
|
+
if (!(0, import_safe_regex22.default)(re.source)) {
|
|
10553
11674
|
throw new Error(
|
|
10554
11675
|
`[node9 engine] Builtin sensitive-path pattern is vulnerable to ReDoS: ${re.source}`
|
|
10555
11676
|
);
|
|
@@ -11882,7 +13003,7 @@ function checksFromLegacyPolicy(policy, mode) {
|
|
|
11882
13003
|
if (uc?.enabled === false) out["behavior.untrusted-content"] = "off";
|
|
11883
13004
|
else if (uc?.enabled === true)
|
|
11884
13005
|
out["behavior.untrusted-content"] = uc.afterExposure === "log-only" ? "log" : "review";
|
|
11885
|
-
if (mode
|
|
13006
|
+
if (isBlockAll(mode)) out["commands.unknown"] = "review";
|
|
11886
13007
|
return out;
|
|
11887
13008
|
}
|
|
11888
13009
|
function checkToLegacyPolicy(policy, id, v) {
|
|
@@ -11974,6 +13095,25 @@ function checkToLegacyPolicy(policy, id, v) {
|
|
|
11974
13095
|
return false;
|
|
11975
13096
|
}
|
|
11976
13097
|
}
|
|
13098
|
+
function knobStatedChecks(policy) {
|
|
13099
|
+
const out = /* @__PURE__ */ new Set();
|
|
13100
|
+
const has = (o, key) => !!o && typeof o === "object" && o[key] !== void 0;
|
|
13101
|
+
const { dlp, egress, loopDetection, injectionScan, skillPinning, packageCheck } = policy;
|
|
13102
|
+
const uc = policy.untrustedContent;
|
|
13103
|
+
if (has(dlp, "enabled")) out.add("data.secrets");
|
|
13104
|
+
if (has(dlp, "reviewAction") || dlp?.enabled === false) out.add("data.secrets-weak");
|
|
13105
|
+
if (has(dlp, "pii")) out.add("data.pii");
|
|
13106
|
+
if (has(egress, "enabled") || has(egress, "mode")) out.add("network.unknown-host");
|
|
13107
|
+
if (has(egress, "ssrfStrict")) out.add("network.internal-addresses");
|
|
13108
|
+
if (has(loopDetection, "enabled")) out.add("behavior.loops");
|
|
13109
|
+
if (has(injectionScan, "enabled")) out.add("behavior.prompt-injection");
|
|
13110
|
+
if (has(skillPinning, "enabled") || has(skillPinning, "mode")) out.add("loading.skill-tamper");
|
|
13111
|
+
if (has(packageCheck, "enabled") || has(packageCheck, "onMalicious"))
|
|
13112
|
+
out.add("loading.malicious-package");
|
|
13113
|
+
if (uc && typeof uc === "object" && (uc.enabled === false || has(uc, "afterExposure")))
|
|
13114
|
+
out.add("behavior.untrusted-content");
|
|
13115
|
+
return out;
|
|
13116
|
+
}
|
|
11977
13117
|
var MAP_GOVERNED = /* @__PURE__ */ new Set([
|
|
11978
13118
|
"files.shell-startup",
|
|
11979
13119
|
"files.password-hashes",
|
|
@@ -11991,7 +13131,11 @@ var MAP_GOVERNED = /* @__PURE__ */ new Set([
|
|
|
11991
13131
|
"commands.disk-destroy",
|
|
11992
13132
|
"commands.dangerous-word",
|
|
11993
13133
|
"commands.node9-disarm",
|
|
11994
|
-
"data.pipe-chain"
|
|
13134
|
+
"data.pipe-chain",
|
|
13135
|
+
// The general action checks (node9Firewall#390): smart rules the map governs.
|
|
13136
|
+
"actions.money",
|
|
13137
|
+
"actions.access",
|
|
13138
|
+
"actions.publish"
|
|
11995
13139
|
]);
|
|
11996
13140
|
var KNOB_GOVERNED = {
|
|
11997
13141
|
"data.secrets": ["off", "block"],
|
|
@@ -12940,11 +14084,15 @@ async function evaluatePolicyCore(config, toolName, args, context = {}, hooks =
|
|
|
12940
14084
|
};
|
|
12941
14085
|
const ruleCheck = (rule) => {
|
|
12942
14086
|
if (rule.verdict === "allow") return void 0;
|
|
12943
|
-
if (!rule.builtin
|
|
14087
|
+
if (!rule.builtin) return void 0;
|
|
12944
14088
|
const id = checkIdForRule(rule.name);
|
|
12945
14089
|
if (!id) return void 0;
|
|
12946
14090
|
const def = getCheck(id);
|
|
12947
14091
|
if (!def) return void 0;
|
|
14092
|
+
if (rule.pinned) {
|
|
14093
|
+
const explicit = config.policy.checks?.[id];
|
|
14094
|
+
return def.pack && config.policy.checkSources?.[id] === "workspace" && isVerdict(explicit) ? { id, value: explicit } : void 0;
|
|
14095
|
+
}
|
|
12948
14096
|
if (rule.name?.startsWith("shield:") && !def.pack) return void 0;
|
|
12949
14097
|
if (def.pack) {
|
|
12950
14098
|
const explicit = config.policy.checks?.[id];
|
|
@@ -12952,8 +14100,10 @@ async function evaluatePolicyCore(config, toolName, args, context = {}, hooks =
|
|
|
12952
14100
|
}
|
|
12953
14101
|
return { id, value: cv(id) };
|
|
12954
14102
|
};
|
|
14103
|
+
const serverLabel = context.mcpServer ?? mcpServerFromToolName(toolName);
|
|
12955
14104
|
const matches = config.policy.smartRules.filter((rule) => {
|
|
12956
14105
|
if (!toolMatchesRule(toolName, rule.tool, layers)) return false;
|
|
14106
|
+
if (!ruleServerMatches(rule, serverLabel)) return false;
|
|
12957
14107
|
if (astSuppressed(rule)) return false;
|
|
12958
14108
|
if (rmCleanupWaiver && rule.name === "review-rm" && rule.verdict === "review") return false;
|
|
12959
14109
|
if (!evaluateSmartConditions(shellRuleArgs(toolName, args, rule.tool, layers), rule))
|
|
@@ -13030,11 +14180,13 @@ async function evaluatePolicyCore(config, toolName, args, context = {}, hooks =
|
|
|
13030
14180
|
if (v?.logged) noteLogged(v);
|
|
13031
14181
|
else if (v) candidates.push(v);
|
|
13032
14182
|
};
|
|
13033
|
-
|
|
14183
|
+
const inline = reviewsEveryInline(config.settings.mode) ? detectInlineExec(shellCommand) ? void 0 : null : inlineExecReview(shellCommand);
|
|
14184
|
+
if (inline !== null) {
|
|
13034
14185
|
consider("commands.inline-exec", {
|
|
13035
14186
|
decision: "review",
|
|
13036
14187
|
blockedByLabel: "Node9 Standard (Inline Execution)",
|
|
13037
|
-
|
|
14188
|
+
...inline ? { reason: inlineExecReason(inline) } : {},
|
|
14189
|
+
ruleDescription: inlineExecDescription(inline),
|
|
13038
14190
|
tier: 3,
|
|
13039
14191
|
checkId: "commands.inline-exec"
|
|
13040
14192
|
});
|
|
@@ -13088,21 +14240,17 @@ async function evaluatePolicyCore(config, toolName, args, context = {}, hooks =
|
|
|
13088
14240
|
if (firstToken && firstToken.startsWith("/") && checkProvenance) {
|
|
13089
14241
|
const prov = checkProvenance(firstToken, cwd);
|
|
13090
14242
|
if (prov.trustLevel === "suspect") {
|
|
13091
|
-
const
|
|
13092
|
-
|
|
13093
|
-
|
|
13094
|
-
{
|
|
13095
|
-
|
|
13096
|
-
|
|
13097
|
-
|
|
13098
|
-
tier: 3,
|
|
13099
|
-
checkId: "commands.temp-binary"
|
|
13100
|
-
}
|
|
13101
|
-
);
|
|
14243
|
+
const v = applyCheckValue(cv("commands.temp-binary"), {
|
|
14244
|
+
decision: "review",
|
|
14245
|
+
blockedByLabel: "Node9: Suspect Binary",
|
|
14246
|
+
reason: `Binary "${firstToken}" resolved to ${prov.resolvedPath} \u2014 ${prov.reason}`,
|
|
14247
|
+
tier: 3,
|
|
14248
|
+
checkId: "commands.temp-binary"
|
|
14249
|
+
});
|
|
13102
14250
|
if (v?.logged) noteLogged(v);
|
|
13103
14251
|
else if (v) return v;
|
|
13104
14252
|
}
|
|
13105
|
-
if (prov.trustLevel === "unknown" && config.settings.mode
|
|
14253
|
+
if (prov.trustLevel === "unknown" && isBlockAll(config.settings.mode)) {
|
|
13106
14254
|
return {
|
|
13107
14255
|
decision: "review",
|
|
13108
14256
|
blockedByLabel: "Node9: Unknown Binary (strict mode)",
|
|
@@ -13193,7 +14341,7 @@ async function evaluatePolicyCore(config, toolName, args, context = {}, hooks =
|
|
|
13193
14341
|
if (v?.logged) noteLogged(v);
|
|
13194
14342
|
else if (v) return v;
|
|
13195
14343
|
}
|
|
13196
|
-
if (config.settings.mode
|
|
14344
|
+
if (isBlockAll(config.settings.mode)) {
|
|
13197
14345
|
if (activeEnvironment?.requireApproval === false) return allowed();
|
|
13198
14346
|
return {
|
|
13199
14347
|
decision: "review",
|
|
@@ -14249,6 +15397,74 @@ function safeMessage(value, max = 300) {
|
|
|
14249
15397
|
return s.length > max ? s.slice(0, max - 1) + "\u2026" : s;
|
|
14250
15398
|
}
|
|
14251
15399
|
|
|
15400
|
+
// src/suggest.ts
|
|
15401
|
+
function unwrapRuleLabel(label) {
|
|
15402
|
+
return ruleNameInLabel(label.trim()) ?? label.trim();
|
|
15403
|
+
}
|
|
15404
|
+
var SHIELD_RULE = /^shield:([a-z0-9-]+):((?:review|block)-[a-z0-9-]+)$/;
|
|
15405
|
+
var ACTION_RULE = /^review-action-(money|access|publish)-/;
|
|
15406
|
+
function packRowOf(ruleName, shield) {
|
|
15407
|
+
const id = checkIdForRule(ruleName);
|
|
15408
|
+
const def = id ? CHECK_BY_ID.get(id) : void 0;
|
|
15409
|
+
return def?.pack === shield && def.legacy?.includes(ruleName) ? id : void 0;
|
|
15410
|
+
}
|
|
15411
|
+
function suggestFromApprovals(rows, opts = {}) {
|
|
15412
|
+
const minApprovals = opts.minApprovals ?? 3;
|
|
15413
|
+
const minSessions = opts.minSessions ?? 2;
|
|
15414
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
15415
|
+
for (const r of rows) {
|
|
15416
|
+
const ruleName = unwrapRuleLabel(r.ruleName);
|
|
15417
|
+
const action = ACTION_RULE.exec(ruleName);
|
|
15418
|
+
if (action && checkIdForRule(ruleName) !== `actions.${action[1]}`) continue;
|
|
15419
|
+
if (action && !r.server) continue;
|
|
15420
|
+
const key = action ? `server:${r.server.toLowerCase()}:${action[1]}` : `rule:${ruleName}`;
|
|
15421
|
+
const isAction = action !== null;
|
|
15422
|
+
const acc = byKey.get(key) ?? {
|
|
15423
|
+
ruleName,
|
|
15424
|
+
server: isAction ? r.server : void 0,
|
|
15425
|
+
approvals: 0,
|
|
15426
|
+
sessions: /* @__PURE__ */ new Set(),
|
|
15427
|
+
denied: false
|
|
15428
|
+
};
|
|
15429
|
+
if (r.decision === "denied") acc.denied = true;
|
|
15430
|
+
else {
|
|
15431
|
+
acc.approvals += 1;
|
|
15432
|
+
if (r.sessionId) acc.sessions.add(r.sessionId);
|
|
15433
|
+
}
|
|
15434
|
+
byKey.set(key, acc);
|
|
15435
|
+
}
|
|
15436
|
+
const out = [];
|
|
15437
|
+
for (const acc of byKey.values()) {
|
|
15438
|
+
if (acc.denied || acc.approvals < minApprovals || acc.sessions.size < minSessions) continue;
|
|
15439
|
+
const shieldRule = SHIELD_RULE.exec(acc.ruleName);
|
|
15440
|
+
if (shieldRule) {
|
|
15441
|
+
const checkId = packRowOf(acc.ruleName, shieldRule[1]);
|
|
15442
|
+
if (!checkId) continue;
|
|
15443
|
+
out.push({
|
|
15444
|
+
kind: "quiet-rule",
|
|
15445
|
+
ruleName: acc.ruleName,
|
|
15446
|
+
shield: shieldRule[1],
|
|
15447
|
+
rule: shieldRule[2],
|
|
15448
|
+
checkId,
|
|
15449
|
+
approvals: acc.approvals,
|
|
15450
|
+
sessions: acc.sessions.size
|
|
15451
|
+
});
|
|
15452
|
+
continue;
|
|
15453
|
+
}
|
|
15454
|
+
const action = ACTION_RULE.exec(acc.ruleName);
|
|
15455
|
+
if (action && acc.server) {
|
|
15456
|
+
out.push({
|
|
15457
|
+
kind: "link-server",
|
|
15458
|
+
server: acc.server,
|
|
15459
|
+
checkId: `actions.${action[1]}`,
|
|
15460
|
+
approvals: acc.approvals,
|
|
15461
|
+
sessions: acc.sessions.size
|
|
15462
|
+
});
|
|
15463
|
+
}
|
|
15464
|
+
}
|
|
15465
|
+
return out.sort((a, b) => b.approvals - a.approvals);
|
|
15466
|
+
}
|
|
15467
|
+
|
|
14252
15468
|
// src/loop/index.ts
|
|
14253
15469
|
var import_crypto3 = __toESM(require("crypto"));
|
|
14254
15470
|
var LOOP_MAX_RECORDS = 500;
|
|
@@ -14720,8 +15936,8 @@ function matchCanaryArgs(args, values) {
|
|
|
14720
15936
|
|
|
14721
15937
|
// src/scan/canonical.ts
|
|
14722
15938
|
var LONG_OUTPUT_THRESHOLD_BYTES = 100 * 1024;
|
|
14723
|
-
var CANONICAL_EXTRACTOR_VERSION = "canonical-
|
|
14724
|
-
var CANONICAL_EXTRACTOR_HASH = "
|
|
15939
|
+
var CANONICAL_EXTRACTOR_VERSION = "canonical-v30";
|
|
15940
|
+
var CANONICAL_EXTRACTOR_HASH = "d55f1f9e5bee7e41";
|
|
14725
15941
|
var DEDUPE_PREVIEW_LEN = 120;
|
|
14726
15942
|
function extractCanonicalFindings(call, ctx) {
|
|
14727
15943
|
const out = [];
|
|
@@ -15092,9 +16308,13 @@ function* stringValues(obj, depth = 0) {
|
|
|
15092
16308
|
var ENGINE_VERSION = "1.4.0";
|
|
15093
16309
|
// Annotate the CommonJS export names for ESM import in node:
|
|
15094
16310
|
0 && (module.exports = {
|
|
15095
|
-
|
|
16311
|
+
ACTION_CHECKS,
|
|
16312
|
+
ACTION_TEMPLATES,
|
|
15096
16313
|
AGENT_INSTRUCTION_DIRS,
|
|
15097
16314
|
AGENT_INSTRUCTION_FILES,
|
|
16315
|
+
APP_SERVER_GLOB,
|
|
16316
|
+
APP_SHIELD_NAMES,
|
|
16317
|
+
APP_SHIELD_SPECS,
|
|
15098
16318
|
ARGUMENT_SCAN_LIMITS,
|
|
15099
16319
|
AST_FS_REGEX_RULES,
|
|
15100
16320
|
BASH_TOOL_NAMES,
|
|
@@ -15121,17 +16341,21 @@ var ENGINE_VERSION = "1.4.0";
|
|
|
15121
16341
|
FILE_TOOLS,
|
|
15122
16342
|
FLAGS_WITH_VALUES,
|
|
15123
16343
|
FS_READ_TOOLS,
|
|
16344
|
+
GENERAL_ACTION_RULES,
|
|
15124
16345
|
KNOB_GOVERNED,
|
|
16346
|
+
LEVELS,
|
|
15125
16347
|
LONG_OUTPUT_THRESHOLD_BYTES,
|
|
15126
16348
|
LOOP_MAX_RECORDS,
|
|
15127
16349
|
LOOP_THRESHOLD_FOR_WASTE,
|
|
15128
16350
|
MAP_GOVERNED,
|
|
15129
16351
|
MAX_BLAST_PATH,
|
|
15130
16352
|
MAX_DESTINATIONS,
|
|
16353
|
+
MODE_VALUES,
|
|
15131
16354
|
NET_BINARIES,
|
|
15132
16355
|
PATTERN_VERB_NAMES,
|
|
15133
16356
|
PRIVILEGE_ESCALATION_RE,
|
|
15134
16357
|
REALTIME_PII_PATTERNS,
|
|
16358
|
+
REPLACED_SHIELDS,
|
|
15135
16359
|
SCAN_SIGNAL_WEIGHTS,
|
|
15136
16360
|
SENSITIVE_PATH_RE,
|
|
15137
16361
|
SENSITIVE_PATH_REGEXES,
|
|
@@ -15192,6 +16416,7 @@ var ENGINE_VERSION = "1.4.0";
|
|
|
15192
16416
|
extractShellDestTokens,
|
|
15193
16417
|
extractShellDestinations,
|
|
15194
16418
|
extractToolDestinations,
|
|
16419
|
+
fileAccessView,
|
|
15195
16420
|
fileOperandFlagsOf,
|
|
15196
16421
|
fileToolOperation,
|
|
15197
16422
|
foldHomoglyphs,
|
|
@@ -15202,11 +16427,15 @@ var ENGINE_VERSION = "1.4.0";
|
|
|
15202
16427
|
hashDestination,
|
|
15203
16428
|
hostMatches,
|
|
15204
16429
|
incompleteFileVerdict,
|
|
16430
|
+
inlineExecDescription,
|
|
16431
|
+
inlineExecReason,
|
|
16432
|
+
inlineExecReview,
|
|
15205
16433
|
inspectArgumentSecrets,
|
|
15206
16434
|
inspectionEntry,
|
|
15207
16435
|
inspectionLayers,
|
|
15208
16436
|
isAgentInstructionPath,
|
|
15209
16437
|
isBashTool,
|
|
16438
|
+
isBlockAll,
|
|
15210
16439
|
isDestructiveToolName,
|
|
15211
16440
|
isHashedEntry,
|
|
15212
16441
|
isIgnoredTool,
|
|
@@ -15216,13 +16445,20 @@ var ENGINE_VERSION = "1.4.0";
|
|
|
15216
16445
|
isLockedCheck,
|
|
15217
16446
|
isLoopbackHost,
|
|
15218
16447
|
isMaskedKind,
|
|
16448
|
+
isModeValue,
|
|
15219
16449
|
isPasswordHashPath,
|
|
15220
16450
|
isPrivateHost,
|
|
15221
16451
|
isProtectedHomePath,
|
|
16452
|
+
isRecordOnly,
|
|
15222
16453
|
isShellShapedTool,
|
|
15223
16454
|
isShieldVerdict,
|
|
15224
16455
|
isStrictGatedTier,
|
|
15225
16456
|
isVerdict,
|
|
16457
|
+
knobStatedChecks,
|
|
16458
|
+
levelCheckValue,
|
|
16459
|
+
levelChecks,
|
|
16460
|
+
levelOf,
|
|
16461
|
+
levelPackageSignals,
|
|
15226
16462
|
maskDestination,
|
|
15227
16463
|
maskPersonalData,
|
|
15228
16464
|
maskPersonalValue,
|
|
@@ -15232,6 +16468,7 @@ var ENGINE_VERSION = "1.4.0";
|
|
|
15232
16468
|
matchesPattern,
|
|
15233
16469
|
matchesTrustedEntry,
|
|
15234
16470
|
matchesTrustedList,
|
|
16471
|
+
mcpServerFromToolName,
|
|
15235
16472
|
narrativeRuleLabel,
|
|
15236
16473
|
normalizeCommandForPolicy,
|
|
15237
16474
|
normalizeDestination,
|
|
@@ -15252,6 +16489,8 @@ var ENGINE_VERSION = "1.4.0";
|
|
|
15252
16489
|
resolveCheckMap,
|
|
15253
16490
|
resolvePinned,
|
|
15254
16491
|
resolveShellInput,
|
|
16492
|
+
reviewsEveryInline,
|
|
16493
|
+
ruleServerMatches,
|
|
15255
16494
|
safeMessage,
|
|
15256
16495
|
sampleCopyCommand,
|
|
15257
16496
|
scanArgs,
|
|
@@ -15270,6 +16509,7 @@ var ENGINE_VERSION = "1.4.0";
|
|
|
15270
16509
|
stripControlChars,
|
|
15271
16510
|
stripInvisible,
|
|
15272
16511
|
stripTerminalEscapes,
|
|
16512
|
+
suggestFromApprovals,
|
|
15273
16513
|
summarizeBlast,
|
|
15274
16514
|
summarizeScan,
|
|
15275
16515
|
toScanFinding,
|
|
@@ -15279,6 +16519,7 @@ var ENGINE_VERSION = "1.4.0";
|
|
|
15279
16519
|
tuningFromLegacyPolicy,
|
|
15280
16520
|
tuningToLegacyPolicy,
|
|
15281
16521
|
unwrapCommandHead,
|
|
16522
|
+
unwrapRuleLabel,
|
|
15282
16523
|
validateOverrides,
|
|
15283
16524
|
validateRegex,
|
|
15284
16525
|
validateShieldDefinition
|