@node9/policy-engine 2.37.1 → 2.38.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.mjs CHANGED
@@ -1,8 +1,45 @@
1
1
  // src/files/protected-access.ts
2
2
  import picomatch from "picomatch";
3
3
 
4
- // src/shields/index.ts
4
+ // src/utils/regex.ts
5
5
  import safeRegex from "safe-regex2";
6
+ var MAX_REGEX_LENGTH = 256;
7
+ var REGEX_CACHE_MAX = 500;
8
+ var regexCache = /* @__PURE__ */ new Map();
9
+ function validateRegex(pattern) {
10
+ if (!pattern) return "Pattern is required";
11
+ if (pattern.length > MAX_REGEX_LENGTH) return `Pattern exceeds max length of ${MAX_REGEX_LENGTH}`;
12
+ try {
13
+ new RegExp(pattern);
14
+ } catch (e) {
15
+ return `Invalid regex syntax: ${e.message}`;
16
+ }
17
+ if (/\\\d+[*+{]/.test(pattern)) return "Quantified backreferences are forbidden (ReDoS risk)";
18
+ if (!safeRegex(pattern)) return "Pattern rejected: potential ReDoS vulnerability detected";
19
+ return null;
20
+ }
21
+ function getCompiledRegex(pattern, flags = "") {
22
+ if (flags && !/^[gimsuy]+$/.test(flags)) return null;
23
+ const key = `${pattern}\0${flags}`;
24
+ if (regexCache.has(key)) {
25
+ const cached = regexCache.get(key);
26
+ regexCache.delete(key);
27
+ regexCache.set(key, cached);
28
+ return cached;
29
+ }
30
+ if (validateRegex(pattern) !== null) return null;
31
+ try {
32
+ const re = new RegExp(pattern, flags);
33
+ if (regexCache.size >= REGEX_CACHE_MAX) {
34
+ const oldest = regexCache.keys().next().value;
35
+ if (oldest) regexCache.delete(oldest);
36
+ }
37
+ regexCache.set(key, re);
38
+ return re;
39
+ } catch {
40
+ return null;
41
+ }
42
+ }
6
43
 
7
44
  // src/shields/builtin/aws.json
8
45
  var aws_default = {
@@ -313,79 +350,6 @@ var filesystem_default = {
313
350
  dangerousWords: ["wipefs"]
314
351
  };
315
352
 
316
- // src/shields/builtin/finance.json
317
- var finance_default = {
318
- name: "finance",
319
- 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.",
320
- aliases: ["payments", "money"],
321
- smartRules: [
322
- {
323
- name: "shield:finance:review-refund",
324
- tool: "{,mcp__*__}{create_refund,refund_payment,refund_charge,refund_order,issue_refund}",
325
- conditions: [],
326
- verdict: "review",
327
- reason: "A refund returns money to a customer. node9 asks before money moves, whatever the request said (Finance shield)."
328
- },
329
- {
330
- name: "shield:finance:review-payout",
331
- tool: "{,mcp__*__}{create_payout,send_payout,payout,create_payouts_batch}",
332
- conditions: [],
333
- verdict: "review",
334
- reason: "A payout moves the balance to a bank account. node9 asks before money moves (Finance shield)."
335
- },
336
- {
337
- name: "shield:finance:review-transfer",
338
- 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}",
339
- conditions: [],
340
- verdict: "review",
341
- reason: "A transfer moves money between accounts. node9 asks before money moves (Finance shield)."
342
- },
343
- {
344
- name: "shield:finance:review-charge",
345
- 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}",
346
- conditions: [],
347
- verdict: "review",
348
- reason: "This charges a card or captures a payment. node9 asks before money moves (Finance shield)."
349
- },
350
- {
351
- name: "shield:finance:review-payment-link",
352
- tool: "{,mcp__*__}{create_payment_link,create_invoice,finalize_invoice,send_invoice,pay_invoice,create_invoice_item}",
353
- conditions: [],
354
- verdict: "review",
355
- reason: "This bills someone or creates a link that charges a card. node9 asks before money moves (Finance shield)."
356
- },
357
- {
358
- name: "shield:finance:review-subscription",
359
- tool: "{,mcp__*__}{create_subscription,cancel_subscription,update_subscription,pause_subscription,resume_subscription}",
360
- conditions: [],
361
- verdict: "review",
362
- reason: "A subscription starts or stops recurring charges. node9 asks before money moves (Finance shield)."
363
- },
364
- {
365
- name: "shield:finance:review-dispute",
366
- tool: "{,mcp__*__}{update_dispute,accept_dispute,close_dispute}",
367
- conditions: [],
368
- verdict: "review",
369
- reason: "This answers or concedes a chargeback. node9 asks before money moves (Finance shield)."
370
- },
371
- {
372
- name: "shield:finance:review-card",
373
- tool: "{,mcp__*__}{issue_card,create_virtual_card,create_issuing_card,update_card_limit}",
374
- conditions: [],
375
- verdict: "review",
376
- reason: "This issues a card or changes its limit. node9 asks before money moves (Finance shield)."
377
- },
378
- {
379
- name: "shield:finance:review-withdraw",
380
- tool: "{,mcp__*__}{withdraw,withdraw_funds,create_withdrawal,request_withdrawal}",
381
- conditions: [],
382
- verdict: "review",
383
- reason: "A withdrawal moves money out. node9 asks before money moves (Finance shield)."
384
- }
385
- ],
386
- dangerousWords: []
387
- };
388
-
389
353
  // src/shields/builtin/github.json
390
354
  var github_default = {
391
355
  name: "github",
@@ -414,58 +378,6 @@ var github_default = {
414
378
  dangerousWords: []
415
379
  };
416
380
 
417
- // src/shields/builtin/identity.json
418
- var identity_default = {
419
- name: "identity",
420
- 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.",
421
- aliases: ["access", "iam"],
422
- smartRules: [
423
- {
424
- name: "shield:identity:review-password",
425
- tool: "{,mcp__*__}{change_password,update_password,reset_password,set_password,expire_password,force_password_reset}",
426
- conditions: [],
427
- verdict: "review",
428
- reason: "This changes or resets a password. node9 asks before credentials change, whatever the request said (Identity shield)."
429
- },
430
- {
431
- name: "shield:identity:review-key",
432
- 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}",
433
- conditions: [],
434
- verdict: "review",
435
- reason: "This creates or rotates a key, token or secret. node9 asks before credentials change (Identity shield)."
436
- },
437
- {
438
- name: "shield:identity:review-access",
439
- 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}",
440
- conditions: [],
441
- verdict: "review",
442
- reason: "This grants or revokes access. node9 asks before access changes (Identity shield)."
443
- },
444
- {
445
- name: "shield:identity:review-membership",
446
- 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}",
447
- conditions: [],
448
- verdict: "review",
449
- reason: "This changes who belongs where. node9 asks before membership changes (Identity shield)."
450
- },
451
- {
452
- name: "shield:identity:review-user",
453
- tool: "{,mcp__*__}{create_user,delete_user,deactivate_user,suspend_user,activate_user,unlock_user,make_admin,promote_user,demote_user,update_user_role}",
454
- conditions: [],
455
- verdict: "review",
456
- reason: "This creates, removes or promotes an account. node9 asks before accounts change (Identity shield)."
457
- },
458
- {
459
- name: "shield:identity:review-mfa",
460
- tool: "{,mcp__*__}{reset_mfa,reset_factors,disable_mfa,enroll_factor,deactivate_factor}",
461
- conditions: [],
462
- verdict: "review",
463
- reason: "This changes a second factor. node9 asks before credentials change (Identity shield)."
464
- }
465
- ],
466
- dangerousWords: []
467
- };
468
-
469
381
  // src/shields/builtin/k8s.json
470
382
  var k8s_default = {
471
383
  name: "k8s",
@@ -725,7 +637,7 @@ var project_jail_default = {
725
637
  {
726
638
  field: "command",
727
639
  op: "matches",
728
- value: "(cat|less|head|tail|bat|more|open|print|nano|vim|vi|emacs|code|type|grep|egrep|fgrep|rg|ag|ack|awk|gawk|sed|cut|tr|jq|yq|od|xxd|hexdump|strings|base64|sort|uniq|tac|nl|dd)\\s+.*?\\.env(\\.(local|production|staging|development|production\\.local|staging\\.local|development\\.local))?(?=\\s|$|[;&|>)<])",
640
+ 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;&|>)<]|$)",
729
641
  flags: "i"
730
642
  }
731
643
  ],
@@ -739,7 +651,7 @@ var project_jail_default = {
739
651
  {
740
652
  field: "command",
741
653
  op: "matches",
742
- value: "(cat|less|head|tail|bat|more|open|print|nano|vim|vi|emacs|code|type|grep|egrep|fgrep|rg|ag|ack|awk|gawk|sed|cut|tr|jq|yq|od|xxd|hexdump|strings|base64|sort|uniq|tac|nl|dd)\\s+.*(credentials\\.json|\\.netrc|\\.npmrc|\\.docker[\\/\\\\]config\\.json|gcloud[\\/\\\\]credentials)",
654
+ 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)",
743
655
  flags: "i"
744
656
  }
745
657
  ],
@@ -806,6 +718,212 @@ var project_jail_default = {
806
718
  dangerousWords: []
807
719
  };
808
720
 
721
+ // src/shields/builtin/redis.json
722
+ var redis_default = {
723
+ name: "redis",
724
+ description: "Protects Redis instances from destructive AI operations",
725
+ aliases: [],
726
+ _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.",
727
+ smartRules: [
728
+ {
729
+ name: "shield:redis:block-flushall",
730
+ tool: "*",
731
+ conditions: [
732
+ {
733
+ field: "command",
734
+ op: "matches",
735
+ value: "(redis|valkey)-cli.*\\bFLUSHALL\\b|\\bFLUSHALL\\b.*(redis|valkey)-cli|^ ?FLUSHALL\\b|\\.flushall\\s*\\(",
736
+ flags: "i"
737
+ }
738
+ ],
739
+ verdict: "block",
740
+ reason: "FLUSHALL deletes every key in every database \u2014 blocked by Redis shield"
741
+ },
742
+ {
743
+ name: "shield:redis:block-flushdb",
744
+ tool: "*",
745
+ conditions: [
746
+ {
747
+ field: "command",
748
+ op: "matches",
749
+ value: "(redis|valkey)-cli.*\\bFLUSHDB\\b|\\bFLUSHDB\\b.*(redis|valkey)-cli|^ ?FLUSHDB\\b|\\.flushdb\\s*\\(",
750
+ flags: "i"
751
+ }
752
+ ],
753
+ verdict: "block",
754
+ reason: "FLUSHDB deletes all keys in the current database \u2014 blocked by Redis shield"
755
+ },
756
+ {
757
+ name: "shield:redis:block-config-resetstat",
758
+ tool: "*",
759
+ conditions: [
760
+ {
761
+ field: "command",
762
+ op: "matches",
763
+ value: "(redis|valkey)-cli.*CONFIG\\s+RESETSTAT|^ ?CONFIG\\s+RESETSTAT",
764
+ flags: "i"
765
+ }
766
+ ],
767
+ verdict: "block",
768
+ reason: "CONFIG RESETSTAT resets server statistics irreversibly \u2014 blocked by Redis shield"
769
+ },
770
+ {
771
+ name: "shield:redis:review-config-set",
772
+ tool: "*",
773
+ conditions: [
774
+ {
775
+ field: "command",
776
+ op: "matches",
777
+ value: "(redis|valkey)-cli.*\\bCONFIG\\s+SET\\b|\\bCONFIG\\s+SET\\b.*(redis|valkey)-cli|^ ?CONFIG\\s+SET\\b",
778
+ flags: "i"
779
+ }
780
+ ],
781
+ verdict: "review",
782
+ reason: "CONFIG SET changes live server configuration and requires human approval (Redis shield)"
783
+ },
784
+ {
785
+ name: "shield:redis:review-del-wildcard",
786
+ tool: "*",
787
+ conditions: [
788
+ {
789
+ field: "command",
790
+ op: "matches",
791
+ value: "(redis|valkey)-cli.*\\bDEL\\b.*[*?\\[]|^ ?DEL\\b.*[*?\\[]|-cli.*--scan.*xargs.*del",
792
+ flags: "i"
793
+ }
794
+ ],
795
+ verdict: "review",
796
+ reason: "Wildcard key deletion requires human approval (Redis shield)"
797
+ }
798
+ ],
799
+ dangerousWords: ["FLUSHALL", "FLUSHDB"]
800
+ };
801
+
802
+ // src/shields/builtin/finance.json
803
+ var finance_default = {
804
+ name: "finance",
805
+ 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.",
806
+ aliases: ["payments", "money"],
807
+ smartRules: [
808
+ {
809
+ name: "shield:finance:review-refund",
810
+ tool: "{,mcp__*__}{create_refund,refund_payment,refund_charge,refund_order,issue_refund}",
811
+ conditions: [],
812
+ verdict: "review",
813
+ reason: "A refund returns money to a customer. node9 asks before money moves, whatever the request said (Finance shield)."
814
+ },
815
+ {
816
+ name: "shield:finance:review-payout",
817
+ tool: "{,mcp__*__}{create_payout,send_payout,payout,create_payouts_batch}",
818
+ conditions: [],
819
+ verdict: "review",
820
+ reason: "A payout moves the balance to a bank account. node9 asks before money moves (Finance shield)."
821
+ },
822
+ {
823
+ name: "shield:finance:review-transfer",
824
+ tool: "{,mcp__*__}{transfer_create,transfer_authorization_create,create_transfer,transfer_money,transfer_funds,send_money,wire_transfer,create_wire,schedule_transaction,update_scheduled_transaction}",
825
+ conditions: [],
826
+ verdict: "review",
827
+ reason: "A transfer moves money between accounts. node9 asks before money moves (Finance shield)."
828
+ },
829
+ {
830
+ name: "shield:finance:review-charge",
831
+ 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}",
832
+ conditions: [],
833
+ verdict: "review",
834
+ reason: "This charges a card or captures a payment. node9 asks before money moves (Finance shield)."
835
+ },
836
+ {
837
+ name: "shield:finance:review-payment-link",
838
+ tool: "{,mcp__*__}{create_payment_link,create_invoice,finalize_invoice,send_invoice,pay_invoice,create_invoice_item}",
839
+ conditions: [],
840
+ verdict: "review",
841
+ reason: "This bills someone or creates a link that charges a card. node9 asks before money moves (Finance shield)."
842
+ },
843
+ {
844
+ name: "shield:finance:review-subscription",
845
+ tool: "{,mcp__*__}{create_subscription,cancel_subscription,update_subscription,pause_subscription,resume_subscription}",
846
+ conditions: [],
847
+ verdict: "review",
848
+ reason: "A subscription starts or stops recurring charges. node9 asks before money moves (Finance shield)."
849
+ },
850
+ {
851
+ name: "shield:finance:review-dispute",
852
+ tool: "{,mcp__*__}{update_dispute,accept_dispute,close_dispute}",
853
+ conditions: [],
854
+ verdict: "review",
855
+ reason: "This answers or concedes a chargeback. node9 asks before money moves (Finance shield)."
856
+ },
857
+ {
858
+ name: "shield:finance:review-card",
859
+ tool: "{,mcp__*__}{issue_card,create_virtual_card,create_issuing_card,update_card_limit}",
860
+ conditions: [],
861
+ verdict: "review",
862
+ reason: "This issues a card or changes its limit. node9 asks before money moves (Finance shield)."
863
+ },
864
+ {
865
+ name: "shield:finance:review-withdraw",
866
+ tool: "{,mcp__*__}{withdraw,withdraw_funds,create_withdrawal,request_withdrawal}",
867
+ conditions: [],
868
+ verdict: "review",
869
+ reason: "A withdrawal moves money out. node9 asks before money moves (Finance shield)."
870
+ }
871
+ ],
872
+ dangerousWords: []
873
+ };
874
+
875
+ // src/shields/builtin/identity.json
876
+ var identity_default = {
877
+ name: "identity",
878
+ 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.",
879
+ aliases: ["access", "iam"],
880
+ smartRules: [
881
+ {
882
+ name: "shield:identity:review-password",
883
+ tool: "{,mcp__*__}{change_password,update_password,reset_password,set_password,expire_password,force_password_reset}",
884
+ conditions: [],
885
+ verdict: "review",
886
+ reason: "This changes or resets a password. node9 asks before credentials change, whatever the request said (Identity shield)."
887
+ },
888
+ {
889
+ name: "shield:identity:review-key",
890
+ 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}",
891
+ conditions: [],
892
+ verdict: "review",
893
+ reason: "This creates or rotates a key, token or secret. node9 asks before credentials change (Identity shield)."
894
+ },
895
+ {
896
+ name: "shield:identity:review-access",
897
+ 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}",
898
+ conditions: [],
899
+ verdict: "review",
900
+ reason: "This grants or revokes access. node9 asks before access changes (Identity shield)."
901
+ },
902
+ {
903
+ name: "shield:identity:review-membership",
904
+ 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}",
905
+ conditions: [],
906
+ verdict: "review",
907
+ reason: "This changes who belongs where. node9 asks before membership changes (Identity shield)."
908
+ },
909
+ {
910
+ name: "shield:identity:review-user",
911
+ 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}",
912
+ conditions: [],
913
+ verdict: "review",
914
+ reason: "This creates, removes or promotes an account. node9 asks before accounts change (Identity shield)."
915
+ },
916
+ {
917
+ name: "shield:identity:review-mfa",
918
+ tool: "{,mcp__*__}{reset_mfa,reset_factors,disable_mfa,enroll_factor,deactivate_factor}",
919
+ conditions: [],
920
+ verdict: "review",
921
+ reason: "This changes a second factor. node9 asks before credentials change (Identity shield)."
922
+ }
923
+ ],
924
+ dangerousWords: []
925
+ };
926
+
809
927
  // src/shields/builtin/publishing.json
810
928
  var publishing_default = {
811
929
  name: "publishing",
@@ -977,85 +1095,554 @@ var publishing_default = {
977
1095
  dangerousWords: []
978
1096
  };
979
1097
 
980
- // src/shields/builtin/redis.json
981
- var redis_default = {
982
- name: "redis",
983
- description: "Protects Redis instances from destructive AI operations",
984
- aliases: [],
985
- _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.",
986
- smartRules: [
987
- {
988
- name: "shield:redis:block-flushall",
989
- tool: "*",
990
- conditions: [
991
- {
992
- field: "command",
993
- op: "matches",
994
- value: "(redis|valkey)-cli.*\\bFLUSHALL\\b|\\bFLUSHALL\\b.*(redis|valkey)-cli|^ ?FLUSHALL\\b|\\.flushall\\s*\\(",
995
- flags: "i"
996
- }
997
- ],
998
- verdict: "block",
999
- reason: "FLUSHALL deletes every key in every database \u2014 blocked by Redis shield"
1000
- },
1001
- {
1002
- name: "shield:redis:block-flushdb",
1003
- tool: "*",
1004
- conditions: [
1005
- {
1006
- field: "command",
1007
- op: "matches",
1008
- value: "(redis|valkey)-cli.*\\bFLUSHDB\\b|\\bFLUSHDB\\b.*(redis|valkey)-cli|^ ?FLUSHDB\\b|\\.flushdb\\s*\\(",
1009
- flags: "i"
1010
- }
1011
- ],
1012
- verdict: "block",
1013
- reason: "FLUSHDB deletes all keys in the current database \u2014 blocked by Redis shield"
1014
- },
1015
- {
1016
- name: "shield:redis:block-config-resetstat",
1017
- tool: "*",
1018
- conditions: [
1019
- {
1020
- field: "command",
1021
- op: "matches",
1022
- value: "(redis|valkey)-cli.*CONFIG\\s+RESETSTAT|^ ?CONFIG\\s+RESETSTAT",
1023
- flags: "i"
1024
- }
1025
- ],
1026
- verdict: "block",
1027
- reason: "CONFIG RESETSTAT resets server statistics irreversibly \u2014 blocked by Redis shield"
1028
- },
1029
- {
1030
- name: "shield:redis:review-config-set",
1031
- tool: "*",
1032
- conditions: [
1033
- {
1034
- field: "command",
1035
- op: "matches",
1036
- value: "(redis|valkey)-cli.*\\bCONFIG\\s+SET\\b|\\bCONFIG\\s+SET\\b.*(redis|valkey)-cli|^ ?CONFIG\\s+SET\\b",
1037
- flags: "i"
1038
- }
1039
- ],
1040
- verdict: "review",
1041
- reason: "CONFIG SET changes live server configuration and requires human approval (Redis shield)"
1042
- },
1043
- {
1044
- name: "shield:redis:review-del-wildcard",
1045
- tool: "*",
1046
- conditions: [
1047
- {
1048
- field: "command",
1049
- op: "matches",
1050
- value: "(redis|valkey)-cli.*\\bDEL\\b.*[*?\\[]|^ ?DEL\\b.*[*?\\[]|-cli.*--scan.*xargs.*del",
1051
- flags: "i"
1052
- }
1053
- ],
1054
- verdict: "review",
1055
- reason: "Wildcard key deletion requires human approval (Redis shield)"
1098
+ // src/shields/apps.ts
1099
+ var ACTION_TEMPLATES = {
1100
+ finance: finance_default.smartRules,
1101
+ identity: identity_default.smartRules,
1102
+ publishing: publishing_default.smartRules
1103
+ };
1104
+ var ACTION_CHECKS = {
1105
+ finance: { checkId: "actions.money", slug: "money", label: "Money check" },
1106
+ identity: { checkId: "actions.access", slug: "access", label: "Accounts and access check" },
1107
+ publishing: { checkId: "actions.publish", slug: "publish", label: "Publishing check" }
1108
+ };
1109
+ function isToolRule(rule) {
1110
+ return rule.tool.startsWith("{,mcp__*__}");
1111
+ }
1112
+ function actionPart(ruleName) {
1113
+ const m = /^shield:[^:]+:(.+)$/.exec(ruleName ?? "");
1114
+ return m ? m[1] : ruleName ?? "rule";
1115
+ }
1116
+ function ownReason(reason, owner) {
1117
+ if (!reason) return reason;
1118
+ return reason.replace(/\((?:Finance|Identity|Publishing) shield\)\.?$/, `(${owner}).`);
1119
+ }
1120
+ var GAP = "[^;&|]{0,200}?";
1121
+ var prog = (alt) => `(?:^|[^\\w-])(?:${alt})(?![\\w-])`;
1122
+ var httpTo = (host2) => prog("curl|wget|http|https|xh") + "[^;&|]{0,400}?" + host2;
1123
+ var httpWrite = (methods) => ({
1124
+ field: "command",
1125
+ op: "matches",
1126
+ 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)`
1127
+ });
1128
+ var HTTP_WRITE = httpWrite("POST|DELETE");
1129
+ var HTTP_WRITE_ANY = httpWrite("POST|PUT|PATCH|DELETE");
1130
+ var NOT_STRIPE_TEST = {
1131
+ field: "command",
1132
+ op: "notMatches",
1133
+ value: "\\b[sr]k_test_"
1134
+ };
1135
+ var postTo = (host2) => `\\.post\\(\\s*["'\`][^"'\`]{0,80}${host2}`;
1136
+ var STRIPE_OBJECTS = "refunds|payouts|charges|transfers|payment_intents|payment_links|invoices|subscriptions|topups";
1137
+ var APP_SHIELD_SPECS = [
1138
+ {
1139
+ name: "stripe",
1140
+ label: "Stripe",
1141
+ 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.",
1142
+ template: "finance",
1143
+ server: "*stripe*",
1144
+ doors: [
1145
+ {
1146
+ name: "shield:stripe:review-cli",
1147
+ tool: "bash",
1148
+ conditions: [
1149
+ {
1150
+ field: "command",
1151
+ op: "matches",
1152
+ value: prog("stripe") + GAP + `\\s(?:${STRIPE_OBJECTS})\\s+(?:create|cancel|capture|confirm|update|pay|finalize_invoice|send_invoice|void_invoice)(?![\\w-])`,
1153
+ flags: "i"
1154
+ },
1155
+ {
1156
+ field: "command",
1157
+ op: "matches",
1158
+ // The stripe CLI works in test mode unless told otherwise.
1159
+ value: "\\s--live(?![\\w-])|\\b[sr]k_live_"
1160
+ }
1161
+ ],
1162
+ conditionMode: "all",
1163
+ verdict: "review",
1164
+ reason: "The stripe CLI is about to move money. node9 asks before money moves (Stripe)."
1165
+ },
1166
+ {
1167
+ name: "shield:stripe:review-cli-request",
1168
+ tool: "bash",
1169
+ conditions: [
1170
+ {
1171
+ field: "command",
1172
+ op: "matches",
1173
+ value: prog("stripe") + GAP + `\\s(?:post|delete)\\s+/?v1/(?:${STRIPE_OBJECTS})(?![\\w-])`,
1174
+ flags: "i"
1175
+ },
1176
+ {
1177
+ field: "command",
1178
+ op: "matches",
1179
+ // The stripe CLI works in test mode unless told otherwise.
1180
+ value: "\\s--live(?![\\w-])|\\b[sr]k_live_"
1181
+ }
1182
+ ],
1183
+ conditionMode: "all",
1184
+ verdict: "review",
1185
+ reason: "A raw stripe CLI request is about to move money. node9 asks before money moves (Stripe)."
1186
+ },
1187
+ {
1188
+ name: "shield:stripe:review-api",
1189
+ tool: "bash",
1190
+ conditions: [
1191
+ {
1192
+ field: "command",
1193
+ op: "matches",
1194
+ value: httpTo(`api\\.stripe\\.com/v1/(?:${STRIPE_OBJECTS})(?![\\w-])`),
1195
+ flags: "i"
1196
+ },
1197
+ HTTP_WRITE,
1198
+ NOT_STRIPE_TEST
1199
+ ],
1200
+ conditionMode: "all",
1201
+ verdict: "review",
1202
+ reason: "A request to the Stripe API is about to move money. node9 asks before money moves (Stripe)."
1203
+ },
1204
+ {
1205
+ name: "shield:stripe:review-code",
1206
+ tool: "bash",
1207
+ conditions: [
1208
+ {
1209
+ field: "command",
1210
+ op: "matches",
1211
+ // Python: stripe.Refund.create(...)
1212
+ value: "\\bstripe\\.(?:Refund|Payout|Transfer|Charge|PaymentIntent|PaymentLink|Invoice|Subscription|Topup)\\.(?:create|cancel|capture|confirm|modify|pay|finalize_invoice|send_invoice|void_invoice)\\b"
1213
+ },
1214
+ NOT_STRIPE_TEST
1215
+ ],
1216
+ conditionMode: "all",
1217
+ verdict: "review",
1218
+ reason: "This code moves money through the Stripe library. node9 asks before money moves (Stripe)."
1219
+ },
1220
+ {
1221
+ name: "shield:stripe:review-code-node",
1222
+ tool: "bash",
1223
+ conditions: [
1224
+ {
1225
+ field: "command",
1226
+ op: "matches",
1227
+ // Node: stripe.refunds.create(...)
1228
+ value: "\\bstripe\\.(?:refunds|payouts|transfers|charges|paymentIntents|paymentLinks|invoices|subscriptions|topups)\\.(?:create|cancel|capture|confirm|update|pay|finalizeInvoice|sendInvoice|voidInvoice)\\s*\\("
1229
+ },
1230
+ NOT_STRIPE_TEST
1231
+ ],
1232
+ conditionMode: "all",
1233
+ verdict: "review",
1234
+ reason: "This code moves money through the Stripe library. node9 asks before money moves (Stripe)."
1235
+ },
1236
+ {
1237
+ name: "shield:stripe:review-code-http",
1238
+ tool: "bash",
1239
+ conditions: [
1240
+ {
1241
+ field: "command",
1242
+ op: "matches",
1243
+ // requests.post("https://api.stripe.com/v1/refunds", ...)
1244
+ value: `\\.post\\(\\s*["'\`][^"'\`]{0,80}api\\.stripe\\.com/v1/(?:${STRIPE_OBJECTS})`
1245
+ },
1246
+ NOT_STRIPE_TEST
1247
+ ],
1248
+ conditionMode: "all",
1249
+ verdict: "review",
1250
+ reason: "This code posts to the Stripe API. node9 asks before money moves (Stripe)."
1251
+ }
1252
+ ]
1253
+ },
1254
+ {
1255
+ name: "paypal",
1256
+ label: "PayPal",
1257
+ 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.",
1258
+ template: "finance",
1259
+ server: "*paypal*",
1260
+ doors: [
1261
+ {
1262
+ name: "shield:paypal:review-api",
1263
+ tool: "bash",
1264
+ conditions: [
1265
+ {
1266
+ field: "command",
1267
+ op: "matches",
1268
+ // The live hosts only: api.paypal.com and api-m.paypal.com. The
1269
+ // sandbox (api-m.sandbox.paypal.com) moves no money.
1270
+ value: httpTo("api(?:-m)?\\.paypal\\.com/v[12]/"),
1271
+ flags: "i"
1272
+ },
1273
+ {
1274
+ field: "command",
1275
+ op: "matches",
1276
+ // The endpoints that move money.
1277
+ value: "\\.paypal\\.com/v[12]/(?:payments/(?:captures|authorizations|sale|payouts|payment|referenced-payouts)|checkout/orders/[^\\s/]{1,64}/(?:capture|authorize)|invoicing/invoices|billing/subscriptions)",
1278
+ flags: "i"
1279
+ },
1280
+ HTTP_WRITE
1281
+ ],
1282
+ conditionMode: "all",
1283
+ verdict: "review",
1284
+ reason: "A request to the PayPal API is about to move money. node9 asks before money moves (PayPal)."
1285
+ },
1286
+ {
1287
+ name: "shield:paypal:review-code",
1288
+ tool: "bash",
1289
+ conditions: [
1290
+ {
1291
+ field: "command",
1292
+ op: "matches",
1293
+ // The Node SDKs (checkout-server-sdk, paypal-server-sdk) and the
1294
+ // Python paypalrestsdk.
1295
+ value: "\\b(?:CapturesRefundRequest|OrdersCaptureRequest|AuthorizationsCaptureRequest|PayoutsPostRequest)\\b|\\b(?:captureOrder|refundCapturedPayment|captureAuthorizedPayment|createBatchPayout)\\s*\\(|\\bpaypalrestsdk\\.(?:Payout|Sale|Capture|Invoice|BillingAgreement)\\b"
1296
+ }
1297
+ ],
1298
+ verdict: "review",
1299
+ reason: "This code moves money through PayPal. node9 asks before money moves (PayPal)."
1300
+ },
1301
+ {
1302
+ name: "shield:paypal:review-code-http",
1303
+ tool: "bash",
1304
+ conditions: [
1305
+ {
1306
+ field: "command",
1307
+ op: "matches",
1308
+ // The endpoints that move money; the token call every script
1309
+ // starts with (/v1/oauth2/token) is not one.
1310
+ value: postTo(
1311
+ "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)"
1312
+ )
1313
+ }
1314
+ ],
1315
+ verdict: "review",
1316
+ reason: "This code posts to the PayPal API. node9 asks before money moves (PayPal)."
1317
+ }
1318
+ ]
1319
+ },
1320
+ {
1321
+ name: "square",
1322
+ label: "Square",
1323
+ 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.",
1324
+ template: "finance",
1325
+ // Square's servers, never Squarespace (a website builder).
1326
+ server: "{*square,*square[-_]*,*squareup*}",
1327
+ mcpTools: [
1328
+ {
1329
+ // Square's official MCP server has one tool for every API call; the
1330
+ // service and method name what it does.
1331
+ name: "shield:square:review-mcp-request",
1332
+ tool: "{,mcp__*__}make_api_request",
1333
+ conditions: [
1334
+ {
1335
+ field: "service",
1336
+ op: "matches",
1337
+ value: "^(?:refunds|payments|orders|invoices|subscriptions|disputes|gift_cards|gift_card_activities|checkout|terminal)$",
1338
+ flags: "i"
1339
+ },
1340
+ {
1341
+ field: "method",
1342
+ op: "notMatches",
1343
+ value: "^(?:list|get|retrieve|search|batch_?retrieve|calculate)",
1344
+ flags: "i"
1345
+ }
1346
+ ],
1347
+ conditionMode: "all",
1348
+ verdict: "review",
1349
+ reason: "A request through the Square MCP server is about to move money. node9 asks before money moves (Square)."
1350
+ }
1351
+ ],
1352
+ doors: [
1353
+ {
1354
+ name: "shield:square:review-api",
1355
+ tool: "bash",
1356
+ conditions: [
1357
+ {
1358
+ field: "command",
1359
+ op: "matches",
1360
+ // The live host only; the sandbox is connect.squareupsandbox.com.
1361
+ value: httpTo(
1362
+ "connect\\.squareup\\.com/v2/(?:refunds|payments|orders/[^\\s/?]{1,64}/pay|invoices|subscriptions|disputes|gift-cards/activities)(?![\\w-]|/search)"
1363
+ ),
1364
+ flags: "i"
1365
+ },
1366
+ HTTP_WRITE_ANY
1367
+ ],
1368
+ conditionMode: "all",
1369
+ verdict: "review",
1370
+ reason: "A request to the Square API is about to move money. node9 asks before money moves (Square)."
1371
+ },
1372
+ {
1373
+ name: "shield:square:review-code",
1374
+ tool: "bash",
1375
+ conditions: [
1376
+ {
1377
+ field: "command",
1378
+ op: "matches",
1379
+ // The Square SDK in the script: Node (`square`) or Python (`square`, `squareup`).
1380
+ value: `\\bSquareClient\\b|\\bsquare\\.client\\b|from\\s+square[.\\s]|from\\s+["']square["']|require\\(\\s*["']square["']`
1381
+ },
1382
+ {
1383
+ field: "command",
1384
+ op: "matches",
1385
+ 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*\\("
1386
+ }
1387
+ ],
1388
+ conditionMode: "all",
1389
+ verdict: "review",
1390
+ reason: "This code moves money through the Square SDK. node9 asks before money moves (Square)."
1391
+ },
1392
+ {
1393
+ name: "shield:square:review-code-http",
1394
+ tool: "bash",
1395
+ conditions: [
1396
+ {
1397
+ field: "command",
1398
+ op: "matches",
1399
+ value: postTo(
1400
+ "connect\\.squareup\\.com/v2/(?:refunds|payments|orders/[^\\s/?\"'`]{1,64}/pay|invoices|subscriptions|disputes|gift-cards/activities)(?![\\w-]|/search)"
1401
+ )
1402
+ }
1403
+ ],
1404
+ verdict: "review",
1405
+ reason: "This code posts to the Square API. node9 asks before money moves (Square)."
1406
+ }
1407
+ ]
1408
+ },
1409
+ {
1410
+ name: "plaid",
1411
+ label: "Plaid",
1412
+ 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.",
1413
+ template: "finance",
1414
+ server: "*plaid*",
1415
+ doors: [
1416
+ {
1417
+ name: "shield:plaid:review-api",
1418
+ tool: "bash",
1419
+ conditions: [
1420
+ {
1421
+ field: "command",
1422
+ op: "matches",
1423
+ // Every Plaid endpoint is a POST, so the path is what tells a
1424
+ // write; the live host only, never sandbox.plaid.com. A script
1425
+ // that posts to the URL meets this door too.
1426
+ value: httpTo(
1427
+ "production\\.plaid\\.com/(?:transfer/(?:create|authorization/create|recurring/create)|payment_initiation/payment/create|bank_transfer/create)(?![\\w-])"
1428
+ ),
1429
+ flags: "i"
1430
+ }
1431
+ ],
1432
+ verdict: "review",
1433
+ reason: "A request to the Plaid API is about to move money. node9 asks before money moves (Plaid)."
1434
+ },
1435
+ {
1436
+ name: "shield:plaid:review-code",
1437
+ tool: "bash",
1438
+ conditions: [
1439
+ { field: "command", op: "matches", value: "\\bplaid", flags: "i" },
1440
+ {
1441
+ field: "command",
1442
+ op: "matches",
1443
+ value: "\\b(?:transfer(?:Authorization|Recurring)?Create|paymentInitiationPaymentCreate|bankTransferCreate|transfer_(?:authorization_|recurring_)?create|payment_initiation_payment_create|bank_transfer_create)\\s*\\("
1444
+ }
1445
+ ],
1446
+ conditionMode: "all",
1447
+ verdict: "review",
1448
+ reason: "This code moves money through Plaid. node9 asks before money moves (Plaid)."
1449
+ }
1450
+ ]
1451
+ },
1452
+ {
1453
+ name: "okta",
1454
+ label: "Okta",
1455
+ 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.",
1456
+ template: "identity",
1457
+ server: "*okta*",
1458
+ doors: [
1459
+ {
1460
+ name: "shield:okta:review-api",
1461
+ tool: "bash",
1462
+ conditions: [
1463
+ {
1464
+ field: "command",
1465
+ op: "matches",
1466
+ // The management API only: sign-in (/api/v1/authn, /sessions,
1467
+ // /oauth2) is not under these paths.
1468
+ value: httpTo(
1469
+ "[\\w-]+\\.okta(?:-emea)?\\.com/api/v1/(?:users|groups|apps|iam|api-tokens|idps|authorizationServers|policies)(?![\\w-])"
1470
+ ),
1471
+ flags: "i"
1472
+ },
1473
+ HTTP_WRITE_ANY
1474
+ ],
1475
+ conditionMode: "all",
1476
+ verdict: "review",
1477
+ reason: "A request to the Okta API is about to change who has access. node9 asks before access changes (Okta)."
1478
+ },
1479
+ {
1480
+ name: "shield:okta:review-code",
1481
+ tool: "bash",
1482
+ conditions: [
1483
+ {
1484
+ field: "command",
1485
+ op: "matches",
1486
+ // The Okta SDK in the script: a method named createUser alone is
1487
+ // in half the applications ever written.
1488
+ value: "@okta/okta-sdk|\\bokta\\.Client\\b|from\\s+okta[.\\s]|\\bimport\\s+okta\\b"
1489
+ },
1490
+ {
1491
+ field: "command",
1492
+ op: "matches",
1493
+ value: "\\b(?:(?:create|delete|deactivate|suspend|unlock|activate)User|(?:reset|expire)Password|resetFactors|(?:assign|unassign)User(?:To|From)Group|assignRoleTo(?:User|Group))\\s*\\("
1494
+ }
1495
+ ],
1496
+ conditionMode: "all",
1497
+ verdict: "review",
1498
+ reason: "This code changes who has access in Okta. node9 asks before access changes (Okta)."
1499
+ },
1500
+ {
1501
+ name: "shield:okta:review-code-py",
1502
+ tool: "bash",
1503
+ conditions: [
1504
+ {
1505
+ field: "command",
1506
+ op: "matches",
1507
+ value: "@okta/okta-sdk|\\bokta\\.Client\\b|from\\s+okta[.\\s]|\\bimport\\s+okta\\b"
1508
+ },
1509
+ {
1510
+ field: "command",
1511
+ op: "matches",
1512
+ 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*\\("
1513
+ }
1514
+ ],
1515
+ conditionMode: "all",
1516
+ verdict: "review",
1517
+ reason: "This code changes who has access in Okta. node9 asks before access changes (Okta)."
1518
+ }
1519
+ ]
1520
+ },
1521
+ {
1522
+ name: "auth0",
1523
+ label: "Auth0",
1524
+ 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.",
1525
+ template: "identity",
1526
+ server: "*auth0*",
1527
+ mcpTools: [
1528
+ {
1529
+ // Auth0's official MCP server: applications (their secrets and
1530
+ // callbacks), APIs and their scopes, and Actions (code that runs at
1531
+ // every sign-in).
1532
+ name: "shield:auth0:review-tenant-config",
1533
+ 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}",
1534
+ conditions: [],
1535
+ verdict: "review",
1536
+ reason: "This changes an Auth0 application, API or sign-in Action. node9 asks before access changes (Auth0)."
1537
+ }
1538
+ ],
1539
+ doors: [
1540
+ {
1541
+ name: "shield:auth0:review-cli",
1542
+ tool: "bash",
1543
+ conditions: [
1544
+ {
1545
+ field: "command",
1546
+ op: "matches",
1547
+ 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-])",
1548
+ flags: "i"
1549
+ }
1550
+ ],
1551
+ verdict: "review",
1552
+ reason: "The auth0 CLI is about to change who has access. node9 asks before access changes (Auth0)."
1553
+ },
1554
+ {
1555
+ name: "shield:auth0:review-api",
1556
+ tool: "bash",
1557
+ conditions: [
1558
+ {
1559
+ field: "command",
1560
+ op: "matches",
1561
+ // The Management API only; /oauth/token is signing in.
1562
+ value: httpTo(
1563
+ "\\.auth0\\.com/api/v2/(?:users|roles|clients|grants|client-grants|organizations|tickets|jobs/users-imports|device-credentials)(?![\\w-])"
1564
+ ),
1565
+ flags: "i"
1566
+ },
1567
+ HTTP_WRITE_ANY
1568
+ ],
1569
+ conditionMode: "all",
1570
+ verdict: "review",
1571
+ reason: "A request to the Auth0 Management API is about to change who has access. node9 asks before access changes (Auth0)."
1572
+ },
1573
+ {
1574
+ name: "shield:auth0:review-code",
1575
+ tool: "bash",
1576
+ conditions: [
1577
+ {
1578
+ field: "command",
1579
+ op: "matches",
1580
+ // The Auth0 SDK in the script (Node `auth0`, Python `auth0`).
1581
+ value: `\\bManagementClient\\b|from\\s+auth0[.\\s]|from\\s+["']auth0["']|require\\(\\s*["']auth0["']`
1582
+ },
1583
+ {
1584
+ field: "command",
1585
+ op: "matches",
1586
+ 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*\\("
1587
+ }
1588
+ ],
1589
+ conditionMode: "all",
1590
+ verdict: "review",
1591
+ reason: "This code changes who has access in Auth0. node9 asks before access changes (Auth0)."
1592
+ }
1593
+ ]
1594
+ }
1595
+ ];
1596
+ function buildAppShield(spec) {
1597
+ const owner = spec.label;
1598
+ const toolRules = ACTION_TEMPLATES[spec.template].filter(isToolRule).map((rule) => ({
1599
+ ...rule,
1600
+ name: `shield:${spec.name}:${actionPart(rule.name)}`,
1601
+ server: spec.server,
1602
+ reason: ownReason(rule.reason, owner)
1603
+ }));
1604
+ const ownTools = (spec.mcpTools ?? []).map((rule) => ({
1605
+ ...rule,
1606
+ server: spec.server
1607
+ }));
1608
+ return {
1609
+ name: spec.name,
1610
+ description: spec.description,
1611
+ aliases: [],
1612
+ smartRules: [...toolRules, ...ownTools, ...spec.doors],
1613
+ dangerousWords: []
1614
+ };
1615
+ }
1616
+ var APP_SHIELDS = APP_SHIELD_SPECS.map(buildAppShield);
1617
+ var APP_SHIELD_NAMES = new Set(APP_SHIELD_SPECS.map((s) => s.name));
1618
+ var APP_SERVER_GLOB = `{${APP_SHIELD_SPECS.map((s) => s.server).join(",")}}`;
1619
+ function buildGeneralRules() {
1620
+ const out = [];
1621
+ for (const name of Object.keys(ACTION_TEMPLATES)) {
1622
+ const { slug, label } = ACTION_CHECKS[name];
1623
+ for (const rule of ACTION_TEMPLATES[name].filter(isToolRule)) {
1624
+ const part = actionPart(rule.name).replace(/^review-/, "");
1625
+ out.push({
1626
+ ...rule,
1627
+ name: `review-action-${slug}-${part}`,
1628
+ notServer: APP_SERVER_GLOB,
1629
+ reason: ownReason(rule.reason, label)
1630
+ });
1056
1631
  }
1057
- ],
1058
- dangerousWords: ["FLUSHALL", "FLUSHDB"]
1632
+ }
1633
+ return out;
1634
+ }
1635
+ var GENERAL_ACTION_RULES = buildGeneralRules();
1636
+ function generalActionRuleNames(template) {
1637
+ const { slug } = ACTION_CHECKS[template];
1638
+ return GENERAL_ACTION_RULES.filter((r) => r.name?.startsWith(`review-action-${slug}-`)).map(
1639
+ (r) => r.name
1640
+ );
1641
+ }
1642
+ var REPLACED_SHIELDS = {
1643
+ finance: "finance is now the Money check (actions.money), on by default. For an app: node9 shield enable stripe (or paypal).",
1644
+ identity: "identity is now the Accounts and access check (actions.access), on by default.",
1645
+ publishing: "publishing is now the Publishing check (actions.publish), on by default."
1059
1646
  };
1060
1647
 
1061
1648
  // src/shields/index.ts
@@ -1100,36 +1687,36 @@ var BUILTIN_SHIELDS = {
1100
1687
  [bash_safe_default.name]: bash_safe_default,
1101
1688
  [docker_default.name]: docker_default,
1102
1689
  [filesystem_default.name]: filesystem_default,
1103
- // Dangerous actions as category shields (node9Firewall#385): an MCP app's
1104
- // money, credential and publishing tools, asked about whatever the request
1105
- // said. One glob per rule covers the bare name the gateway sends and the
1106
- // mcp__<server>__ name the agent hook sends.
1107
- [finance_default.name]: finance_default,
1108
1690
  [github_default.name]: github_default,
1109
- [identity_default.name]: identity_default,
1110
1691
  [k8s_default.name]: k8s_default,
1111
1692
  [mongodb_default.name]: mongodb_default,
1112
1693
  [postgres_default.name]: postgres_default,
1113
1694
  [project_jail_default.name]: project_jail_default,
1114
- [publishing_default.name]: publishing_default,
1115
- [redis_default.name]: redis_default
1695
+ [redis_default.name]: redis_default,
1696
+ // App shields generated from the action templates (node9Firewall#390): one
1697
+ // per app, every door (MCP server, CLI, API, library), off by default.
1698
+ ...Object.fromEntries(APP_SHIELDS.map((s) => [s.name, s]))
1116
1699
  };
1117
- var ACTION_SHIELD_NAMES = /* @__PURE__ */ new Set([
1118
- "finance",
1119
- "identity",
1120
- "publishing"
1121
- ]);
1122
1700
  function assertBuiltinShieldRegexesAreSafe() {
1123
- for (const shield of Object.values(BUILTIN_SHIELDS)) {
1701
+ const sets = [
1702
+ ...Object.values(BUILTIN_SHIELDS).map((sh) => ({
1703
+ name: sh.name,
1704
+ smartRules: sh.smartRules
1705
+ })),
1706
+ ...Object.entries(ACTION_TEMPLATES).map(([name, smartRules]) => ({ name, smartRules })),
1707
+ { name: "general-action-checks", smartRules: GENERAL_ACTION_RULES }
1708
+ ];
1709
+ for (const shield of sets) {
1124
1710
  for (const rule of shield.smartRules) {
1125
1711
  const conditions = rule.conditions ?? [];
1126
1712
  for (const cond of conditions) {
1127
1713
  if (cond.op !== "matches" && cond.op !== "notMatches") continue;
1128
1714
  const pattern = cond.value;
1129
1715
  if (!pattern) continue;
1130
- if (!safeRegex(pattern)) {
1716
+ const problem = validateRegex(pattern);
1717
+ if (problem) {
1131
1718
  throw new Error(
1132
- `[node9 engine] Shield '${shield.name}' rule '${rule.name ?? rule.tool}' has unsafe regex: ${pattern}`
1719
+ `[node9 engine] Shield '${shield.name}' rule '${rule.name ?? rule.tool}' has a regex the runtime refuses (${problem}): ${pattern}`
1133
1720
  );
1134
1721
  }
1135
1722
  }
@@ -1423,9 +2010,9 @@ var CHECK_TEXT = {
1423
2010
  },
1424
2011
  // ── Commands ──────────────────────────────────────────────────────────────
1425
2012
  "commands.inline-exec": {
1426
- plain: "The agent runs a small program written inside the command itself.",
2013
+ 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.",
1427
2014
  example: `node -e "require('fs').rmSync('dist', {recursive: true})"`,
1428
- advice: "Agents do this often for harmless tasks. Set Log if your team finds the review prompts noisy; keep Review if agents work near production."
2015
+ advice: "Keep Review. Strict mode reviews every inline call, harmless or not; Log or Off only if inline code never reaches anything that matters."
1429
2016
  },
1430
2017
  "commands.eval-dynamic": {
1431
2018
  plain: "The agent runs code whose content is built at run time, so node9 cannot read it in advance.",
@@ -1457,6 +2044,21 @@ var CHECK_TEXT = {
1457
2044
  example: "chmod 777 deploy.sh",
1458
2045
  advice: "Keep Review. A narrower permission (755, 644) almost always does the job."
1459
2046
  },
2047
+ "actions.money": {
2048
+ 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.",
2049
+ example: "refund_order on a server called acme-billing",
2050
+ 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."
2051
+ },
2052
+ "actions.access": {
2053
+ plain: "The agent changes a password, a key, a role or who belongs to a team, through an app node9 has no protection for.",
2054
+ example: "invite_user or grant_role on a company admin server",
2055
+ advice: "Keep Review. Set Log on a sandbox workspace where agents manage test users all day."
2056
+ },
2057
+ "actions.publish": {
2058
+ 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.",
2059
+ example: "create_release or deploy_to_production on a company MCP server",
2060
+ advice: "Keep Review. Set Log on a release machine whose pipeline publishes on purpose, never on a developer laptop."
2061
+ },
1460
2062
  "commands.sudo": {
1461
2063
  plain: "The agent runs a command as the administrator (root).",
1462
2064
  example: "sudo apt-get install -y nginx",
@@ -1617,7 +2219,7 @@ var CHECK_TEXT = {
1617
2219
  advice: "Fixed at Block. A person accepts the change on the machine (node9 mcp pin update)."
1618
2220
  },
1619
2221
  "loading.malicious-package": {
1620
- 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.",
2222
+ 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.",
1621
2223
  example: "npm install of a package flagged as malware",
1622
2224
  advice: "Keep Block for known-malicious packages; brand-new packages already stop for Review."
1623
2225
  }
@@ -1635,7 +2237,8 @@ var CHECK_GROUPS = [
1635
2237
  { id: "network", title: "Network" },
1636
2238
  { id: "files", title: "Files" },
1637
2239
  { id: "behavior", title: "Agent behavior" },
1638
- { id: "loading", title: "What the agent loads" }
2240
+ { id: "loading", title: "What the agent loads" },
2241
+ { id: "actions", title: "Actions in apps" }
1639
2242
  ];
1640
2243
  var ALL = VERDICTS;
1641
2244
  var BUILTIN_DANGEROUS_WORDS = ["mkfs", "shred"];
@@ -1682,7 +2285,7 @@ var PRODUCT_CHECKS = [
1682
2285
  id: "commands.inline-exec",
1683
2286
  group: "commands",
1684
2287
  title: "Inline code execution",
1685
- catches: "node -e, python -c, bash -c, a heredoc into an interpreter",
2288
+ 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",
1686
2289
  values: ALL,
1687
2290
  defaultValue: "review",
1688
2291
  legacy: ["Node9 Standard (Inline Execution)"]
@@ -2039,6 +2642,38 @@ var PRODUCT_CHECKS = [
2039
2642
  values: ALL,
2040
2643
  defaultValue: "block",
2041
2644
  legacy: ["\u{1F4E6} Node9 Package Check (Malicious)", "\u{1F4E6} Node9 Package Check (Review)"]
2645
+ },
2646
+ // ── Actions in apps (node9Firewall#390) ──────────────────────────────────
2647
+ // The safety net under the app shields: an action that moves money, changes
2648
+ // access or publishes, on an MCP server no app shield claims (an internal
2649
+ // billing server, a vendor with no shield, Zapier). Review by default; the
2650
+ // rules come from the action templates (shields/apps.ts).
2651
+ {
2652
+ id: "actions.money",
2653
+ group: "actions",
2654
+ title: "Money moves",
2655
+ catches: "a refund, payout, transfer, charge or withdrawal through an app with no protection of its own",
2656
+ values: ALL,
2657
+ defaultValue: "review",
2658
+ legacy: generalActionRuleNames("finance")
2659
+ },
2660
+ {
2661
+ id: "actions.access",
2662
+ group: "actions",
2663
+ title: "Accounts and access change",
2664
+ catches: "a password, key, role, permission or user changed through an app with no protection of its own",
2665
+ values: ALL,
2666
+ defaultValue: "review",
2667
+ legacy: generalActionRuleNames("identity")
2668
+ },
2669
+ {
2670
+ id: "actions.publish",
2671
+ group: "actions",
2672
+ title: "Something is published",
2673
+ catches: "a release, package, deploy or public post through an app with no protection of its own",
2674
+ values: ALL,
2675
+ defaultValue: "review",
2676
+ legacy: generalActionRuleNames("publishing")
2042
2677
  }
2043
2678
  ];
2044
2679
  var SHIELD_RULE_NAME = /^shield:([^:]+):(block|review|allow)-(.+)$/;
@@ -2100,7 +2735,7 @@ function ssrfCheckId(tier) {
2100
2735
  var PROJECT_JAIL_BLOCK_READ = /^shield:project-jail:block-read-(ssh|aws|env)(-any-tool)?$/;
2101
2736
  var OVERRIDE_PREFIX = "Override block rule:";
2102
2737
  var LABEL_WRAPPERS = ["Smart Rule:", "Node9 (AST):", "project-jail (AST):"];
2103
- function unwrapRuleLabel(s) {
2738
+ function ruleNameInLabel(s) {
2104
2739
  let rest = s;
2105
2740
  const override = rest.lastIndexOf(OVERRIDE_PREFIX);
2106
2741
  if (override >= 0) rest = rest.slice(override + OVERRIDE_PREFIX.length).trimStart();
@@ -2116,7 +2751,7 @@ function checkIdForRule(nameOrLabel) {
2116
2751
  const s = nameOrLabel.trim();
2117
2752
  const exact = LEGACY_TO_ID.get(s);
2118
2753
  if (exact) return exact;
2119
- const unwrapped = unwrapRuleLabel(s);
2754
+ const unwrapped = ruleNameInLabel(s);
2120
2755
  if (unwrapped !== void 0) return checkIdForRule(unwrapped);
2121
2756
  if (s.startsWith("shield:project-jail:")) {
2122
2757
  return PROJECT_JAIL_BLOCK_READ.test(s) ? "data.credential-files" : "data.credential-files-other";
@@ -2359,45 +2994,356 @@ function looksLikeText(buf) {
2359
2994
  }
2360
2995
  return printable / buf.length >= 0.9;
2361
2996
  }
2362
- var BASE64_RUN_RE = /[A-Za-z0-9+/]{32,}={0,2}|[A-Za-z0-9_-]{32,}/g;
2363
- function decodeEmbeddedBase64(text) {
2364
- const out = [];
2365
- for (const m of text.matchAll(BASE64_RUN_RE)) {
2366
- if (out.length >= MAX_BLOBS) break;
2367
- const run = m[0];
2368
- if (/^[0-9a-fA-F]+$/.test(run)) continue;
2369
- const buf = Buffer.from(run, "base64");
2370
- if (looksLikeText(buf)) out.push(buf.toString("utf8"));
2997
+ var BASE64_RUN_RE = /[A-Za-z0-9+/]{32,}={0,2}|[A-Za-z0-9_-]{32,}/g;
2998
+ function decodeEmbeddedBase64(text) {
2999
+ const out = [];
3000
+ for (const m of text.matchAll(BASE64_RUN_RE)) {
3001
+ if (out.length >= MAX_BLOBS) break;
3002
+ const run = m[0];
3003
+ if (/^[0-9a-fA-F]+$/.test(run)) continue;
3004
+ const buf = Buffer.from(run, "base64");
3005
+ if (looksLikeText(buf)) out.push(buf.toString("utf8"));
3006
+ }
3007
+ return out;
3008
+ }
3009
+ var HEX_RUN_RE = /\b(?:[0-9a-fA-F]{2}){24,}\b/g;
3010
+ var HEX_ESCAPE_RUN_RE = /(?:\\x[0-9a-fA-F]{2}){16,}/g;
3011
+ function decodeEmbeddedHex(text) {
3012
+ const out = [];
3013
+ for (const m of text.matchAll(HEX_RUN_RE)) {
3014
+ if (out.length >= MAX_BLOBS) break;
3015
+ const buf = Buffer.from(m[0], "hex");
3016
+ if (looksLikeText(buf)) out.push(buf.toString("utf8"));
3017
+ }
3018
+ for (const m of text.matchAll(HEX_ESCAPE_RUN_RE)) {
3019
+ if (out.length >= MAX_BLOBS) break;
3020
+ const buf = Buffer.from(m[0].replace(/\\x/g, ""), "hex");
3021
+ if (looksLikeText(buf)) out.push(buf.toString("utf8"));
3022
+ }
3023
+ return out;
3024
+ }
3025
+ function scanViews(text) {
3026
+ const views = [{ kind: "original", text }];
3027
+ const normalized = normalizeForScan(text);
3028
+ if (normalized !== text) views.push({ kind: "normalized", text: normalized });
3029
+ for (const t of decodeEmbeddedBase64(normalized)) {
3030
+ views.push({ kind: "base64", text: normalizeForScan(t) });
3031
+ }
3032
+ for (const t of decodeEmbeddedHex(normalized)) {
3033
+ views.push({ kind: "hex", text: normalizeForScan(t) });
3034
+ }
3035
+ return views;
3036
+ }
3037
+
3038
+ // src/files/paths.ts
3039
+ var SYSTEM_AUTH_FILES = [
3040
+ "/etc/passwd",
3041
+ "/etc/shadow",
3042
+ "/etc/group",
3043
+ "/etc/gshadow",
3044
+ "/etc/sudoers"
3045
+ ];
3046
+ var SYSTEM_AUTH_DIRS = ["/etc/security", "/etc/pam.d", "/etc/sudoers.d"];
3047
+ var PASSWORD_HASH_FILES = ["/etc/shadow", "/etc/gshadow"];
3048
+ var STARTUP_NAMES = [".bashrc", ".zshrc", ".profile", ".bash_profile"];
3049
+ var SYSTEM_DIRS = [
3050
+ "/usr",
3051
+ "/etc",
3052
+ "/boot",
3053
+ "/bin",
3054
+ "/sbin",
3055
+ "/lib",
3056
+ "/lib64",
3057
+ "/var/log"
3058
+ ];
3059
+ var SYSTEM_DIRS_EXEMPT = ["/usr/local", "/usr/src"];
3060
+ var UPLOAD_SYSTEM_DIRS = [...SYSTEM_DIRS, "/proc", "/sys", "/root"];
3061
+ var AGENT_INSTRUCTION_FILES = [
3062
+ ".gitlab-ci.yml",
3063
+ "CLAUDE.md",
3064
+ "AGENTS.md",
3065
+ ".cursorrules",
3066
+ ".mcp.json",
3067
+ ".vscode/settings.json",
3068
+ "package.json"
3069
+ ];
3070
+ var AGENT_INSTRUCTION_DIRS = [
3071
+ ".github/workflows",
3072
+ ".claude",
3073
+ ".cursor",
3074
+ ".git/hooks",
3075
+ ".husky"
3076
+ ];
3077
+ function isAgentInstructionPath(absPath, root) {
3078
+ const r = root.replace(/\/$/, "");
3079
+ if (!(absPath === r || absPath.startsWith(r + "/"))) return false;
3080
+ const rel = absPath.slice(r.length + 1);
3081
+ if (AGENT_INSTRUCTION_FILES.includes(rel)) return true;
3082
+ return AGENT_INSTRUCTION_DIRS.some((d) => rel === d || rel.startsWith(d + "/"));
3083
+ }
3084
+ function isInside(root, p) {
3085
+ const r = root.replace(/\/$/, "") || "/";
3086
+ return p === r || p.startsWith(r === "/" ? "/" : r + "/");
3087
+ }
3088
+ var LEGACY_SYSTEM_PATH_RE = /^(?:[a-zA-Z]:)?\/etc\/(?:passwd|shadow|sudoers)$/;
3089
+ function isPasswordHashPath(p) {
3090
+ return PASSWORD_HASH_FILES.includes(p);
3091
+ }
3092
+ function isLegacySystemPath(p) {
3093
+ return LEGACY_SYSTEM_PATH_RE.test(p);
3094
+ }
3095
+ function normalizeFilePath(p, cwd = "", home = "~") {
3096
+ if (!p.startsWith("/") && !p.startsWith("~") && cwd) p = `${cwd}/${p}`;
3097
+ if (p === "~" || p.startsWith("~/")) p = home + p.slice(1);
3098
+ const rooted = p.startsWith("/");
3099
+ const parts = [];
3100
+ for (const part of p.split("/")) {
3101
+ if (!part || part === ".") continue;
3102
+ if (part === ".." && parts.length && parts.at(-1) !== "..") parts.pop();
3103
+ else if (part !== ".." || !rooted) parts.push(part);
3104
+ }
3105
+ return (rooted ? "/" : "") + parts.join("/");
3106
+ }
3107
+
3108
+ // src/shell/inline-code.ts
3109
+ var MAX_INLINE_CODE = 64 * 1024;
3110
+ var WHAT = {
3111
+ deletes: "deletes files",
3112
+ "writes-outside": "writes a file outside the project",
3113
+ sends: "sends data over the network",
3114
+ listens: "opens a listening socket or a shell",
3115
+ "runs-commands": "runs other commands or processes",
3116
+ "reads-protected": "reads a protected file",
3117
+ "builds-code": "runs code it builds at run time",
3118
+ permissions: "changes permissions or ownership",
3119
+ monitors: "captures the screen, the clipboard or the keyboard",
3120
+ amplifies: "writes or sends in an endless loop"
3121
+ };
3122
+ var OUTSIDE = String.raw`(?:~|\.\.[\\/]|/(?!(?:tmp|var/tmp)/(?![^'"\n]*\.\.)|dev/(?:null|stdout|stderr)\b))`;
3123
+ var pyImport = (mods) => new RegExp(String.raw`\b(?:import\s+(?:[\w.]+(?:\s+as\s+\w+)?\s*,\s*)*|from\s+)(?:${mods})\b`);
3124
+ var either = (...res) => new RegExp(res.map((r) => `(?:${r.source})`).join("|"), "m");
3125
+ var PYTHON = [
3126
+ [
3127
+ "deletes",
3128
+ /\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/
3129
+ ],
3130
+ [
3131
+ "writes-outside",
3132
+ new RegExp(
3133
+ 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}`
3134
+ )
3135
+ ],
3136
+ [
3137
+ "sends",
3138
+ either(
3139
+ pyImport(
3140
+ String.raw`socket|requests|urllib2|urllib3|http\.client|httplib|smtplib|ftplib|paramiko|telnetlib|aiohttp|httpx|websockets?|xmlrpc|poplib|imaplib|pycurl|scapy`
3141
+ ),
3142
+ /\burllib\.request\b|\burlopen\s*\(|\bfrom\s+urllib\s+import\s+[^\n;]*\brequest\b|\basyncio\.open_connection\s*\(/
3143
+ )
3144
+ ],
3145
+ [
3146
+ "listens",
3147
+ either(
3148
+ pyImport(String.raw`pty|socketserver|http\.server`),
3149
+ /\bpty\.spawn\s*\(|\.bind\s*\(\s*\(|\basyncio\.start_server\s*\(/
3150
+ )
3151
+ ],
3152
+ [
3153
+ "runs-commands",
3154
+ either(
3155
+ pyImport("subprocess|pexpect|commands|psutil"),
3156
+ /\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+\*/
3157
+ )
3158
+ ],
3159
+ [
3160
+ "builds-code",
3161
+ /(?<![\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*\[/
3162
+ ],
3163
+ [
3164
+ // Spyware shapes: a screenshot, the clipboard, a key logger.
3165
+ "monitors",
3166
+ either(
3167
+ pyImport(String.raw`pyperclip|pynput|keyboard|pyautogui|pyscreenshot|mss|clipboard`),
3168
+ /\bImageGrab\b|\bpyautogui\.screenshot\b|\bscreencapture\b/
3169
+ )
3170
+ ],
3171
+ [
3172
+ "permissions",
3173
+ /\bos\.(?:chmod|lchmod|fchmod|chown|lchown|fchown|setuid|setgid|seteuid|setegid|setreuid|setregid|setresuid)\s*\(|\.chmod\s*\(|\bshutil\.chown\s*\(/
3174
+ ]
3175
+ ];
3176
+ var NODE = [
3177
+ [
3178
+ "deletes",
3179
+ /\.(?:rm|rmSync|rmdir|rmdirSync|unlink|unlinkSync)\s*\(|\brimraf\b|\bDeno\.remove(?:Sync)?\s*\(/
3180
+ ],
3181
+ [
3182
+ "writes-outside",
3183
+ new RegExp(
3184
+ 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}`
3185
+ )
3186
+ ],
3187
+ [
3188
+ "sends",
3189
+ /\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*\(/
3190
+ ],
3191
+ ["listens", /\bcreateServer\s*\(|\b(?:Deno\.(?:listen\w*|serve)|Bun\.(?:listen|serve))\s*\(/],
3192
+ [
3193
+ "runs-commands",
3194
+ /\bchild_process\b|\bprocess\.(?:binding|dlopen|kill)\s*\(|\bDeno\.(?:run|Command)\b|\bBun\.(?:spawn|spawnSync|\$)\b|\bexecSync\s*\(|\bspawnSync\s*\(/
3195
+ ],
3196
+ [
3197
+ "builds-code",
3198
+ /(?<![\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)]/
3199
+ ],
3200
+ [
3201
+ "permissions",
3202
+ /\.(?:chmod|chmodSync|chown|chownSync|lchown|lchownSync|fchmod|fchmodSync|fchown|fchownSync)\s*\(|\bprocess\.set(?:e)?[ug]id\s*\(|\bDeno\.(?:chmod|chown)(?:Sync)?\s*\(/
3203
+ ]
3204
+ ];
3205
+ var PERL = [
3206
+ ["deletes", /\b(?:unlink|rmdir|rmtree|remove_tree)\b/],
3207
+ [
3208
+ "writes-outside",
3209
+ new RegExp(
3210
+ String.raw`['"]\s*(?:\+?>>?|\+<)\s*['"]?\s*,?\s*['"]?${OUTSIDE}|\b(?:rename|symlink|link|copy|move)\s*\(?[^;\n]*['"]${OUTSIDE}`
3211
+ )
3212
+ ],
3213
+ [
3214
+ "sends",
3215
+ /\b(?:IO::Socket|Socket|LWP|HTTP::Tiny|Net::\w+|Mojo::UserAgent|WWW::Mechanize|IO::Socket::INET)\b/
3216
+ ],
3217
+ [
3218
+ "runs-commands",
3219
+ /\b(?:system|exec|fork|kill|syscall)\b|`[^`]*`|\bqx\s*[{([/|!'"]|\bopen\s*\(?[^;\n]*(?:['"]\s*\||\|\s*['"]|['"]-\|['"])/
3220
+ ],
3221
+ ["builds-code", /\beval\b|\bStorable::thaw\b|\bdo\s+['"]/],
3222
+ ["permissions", /\b(?:chmod|chown)\b/]
3223
+ ];
3224
+ var RUBY = [
3225
+ [
3226
+ "deletes",
3227
+ /\bFile\.(?:delete|unlink)\b|\bFileUtils\.(?:rm\w*|remove\w*)\b|\bDir\.(?:rmdir|delete|unlink)\b|\.(?:rmtree|delete_all)\b/
3228
+ ],
3229
+ [
3230
+ "writes-outside",
3231
+ new RegExp(
3232
+ 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}`
3233
+ )
3234
+ ],
3235
+ [
3236
+ "sends",
3237
+ /\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)['"]/
3238
+ ],
3239
+ ["listens", /\b(?:TCPServer|UNIXServer|WEBrick|PTY)\b/],
3240
+ [
3241
+ "runs-commands",
3242
+ /(?<![\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/
3243
+ ],
3244
+ [
3245
+ "builds-code",
3246
+ /(?<![\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/
3247
+ ],
3248
+ ["permissions", /\b(?:File|FileUtils)\.(?:chmod|chown|lchmod|lchown)\w*\b/]
3249
+ ];
3250
+ var PHP = [
3251
+ ["deletes", /\b(?:unlink|rmdir)\s*\(/],
3252
+ [
3253
+ "writes-outside",
3254
+ new RegExp(
3255
+ String.raw`\b(?:file_put_contents|symlink|link|copy|rename|mkdir|touch)\s*\([^)\n]*['"]${OUTSIDE}|\bfopen\s*\(\s*['"]${OUTSIDE}[^'"\n]*['"]\s*,\s*['"][waxc+]`
3256
+ )
3257
+ ],
3258
+ [
3259
+ "sends",
3260
+ /\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):/
3261
+ ],
3262
+ ["listens", /\b(?:stream_socket_server|socket_bind|socket_listen)\s*\(/],
3263
+ [
3264
+ "runs-commands",
3265
+ /\b(?:system|exec|shell_exec|passthru|proc_open|popen|pcntl_exec|pcntl_fork|posix_kill)\s*\(|`[^`]*`/
3266
+ ],
3267
+ [
3268
+ "builds-code",
3269
+ /\b(?:eval|assert|create_function|unserialize|call_user_func(?:_array)?)\s*\(|\bbase64_decode\b/
3270
+ ],
3271
+ ["permissions", /\b(?:chmod|chown|chgrp|lchown|lchgrp)\s*\(/]
3272
+ ];
3273
+ var TABLES = {
3274
+ python: PYTHON,
3275
+ node: NODE,
3276
+ perl: PERL,
3277
+ ruby: RUBY,
3278
+ php: PHP
3279
+ };
3280
+ function inlineLanguageOf(interp) {
3281
+ const i = interp.toLowerCase();
3282
+ if (/^python[\d.]*$/.test(i)) return "python";
3283
+ if (/^(?:node|tsx|ts-node|deno|bun)$/.test(i)) return "node";
3284
+ if (i === "perl") return "perl";
3285
+ if (i === "ruby" || i === "irb") return "ruby";
3286
+ if (i === "php") return "php";
3287
+ return null;
3288
+ }
3289
+ function resolvePythonAliases(code) {
3290
+ const aliases = [...code.matchAll(/\bimport\s+([\w.]+)\s+as\s+(\w+)/g)].slice(0, 32);
3291
+ let out = code;
3292
+ for (const [, mod, alias] of aliases) {
3293
+ if (alias === mod) continue;
3294
+ out = out.replace(new RegExp(String.raw`(?<![\w.])${alias}\b`, "g"), mod);
2371
3295
  }
2372
3296
  return out;
2373
3297
  }
2374
- var HEX_RUN_RE = /\b(?:[0-9a-fA-F]{2}){24,}\b/g;
2375
- var HEX_ESCAPE_RUN_RE = /(?:\\x[0-9a-fA-F]{2}){16,}/g;
2376
- function decodeEmbeddedHex(text) {
2377
- const out = [];
2378
- for (const m of text.matchAll(HEX_RUN_RE)) {
2379
- if (out.length >= MAX_BLOBS) break;
2380
- const buf = Buffer.from(m[0], "hex");
2381
- if (looksLikeText(buf)) out.push(buf.toString("utf8"));
2382
- }
2383
- for (const m of text.matchAll(HEX_ESCAPE_RUN_RE)) {
2384
- if (out.length >= MAX_BLOBS) break;
2385
- const buf = Buffer.from(m[0].replace(/\\x/g, ""), "hex");
2386
- if (looksLikeText(buf)) out.push(buf.toString("utf8"));
3298
+ var STRING_LITERAL = /(['"`])((?:\\.|(?!\1)[^\\\n]){1,4096})\1/g;
3299
+ function protectedLiteral(code, isProtected) {
3300
+ let n = 0;
3301
+ for (const m of code.matchAll(STRING_LITERAL)) {
3302
+ if (++n > 2048) break;
3303
+ const value = m[2].trim();
3304
+ if (value && isProtected(value)) return value;
2387
3305
  }
2388
- return out;
3306
+ return null;
2389
3307
  }
2390
- function scanViews(text) {
2391
- const views = [{ kind: "original", text }];
2392
- const normalized = normalizeForScan(text);
2393
- if (normalized !== text) views.push({ kind: "normalized", text: normalized });
2394
- for (const t of decodeEmbeddedBase64(normalized)) {
2395
- views.push({ kind: "base64", text: normalizeForScan(t) });
3308
+ function amplifies(language, code) {
3309
+ 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*\)/;
3310
+ const m = loop.exec(code);
3311
+ if (!m) return null;
3312
+ const body = code.slice(m.index);
3313
+ 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(
3314
+ body
3315
+ ) ? m[0] : null;
3316
+ }
3317
+ function judgeInlineCode(language, code, isProtected) {
3318
+ if (code.length > MAX_INLINE_CODE) {
3319
+ return { outcome: "unreadable", what: "is too long for node9 to read" };
3320
+ }
3321
+ const text = language === "python" ? resolvePythonAliases(code) : code;
3322
+ for (const [category, re] of TABLES[language]) {
3323
+ const m = re.exec(text);
3324
+ if (!m) continue;
3325
+ const evidence = m[0].trim().replace(/\s+/g, " ").slice(0, 60);
3326
+ return {
3327
+ outcome: category === "builds-code" ? "unreadable" : "dangerous",
3328
+ what: WHAT[category],
3329
+ evidence,
3330
+ category
3331
+ };
2396
3332
  }
2397
- for (const t of decodeEmbeddedHex(normalized)) {
2398
- views.push({ kind: "hex", text: normalizeForScan(t) });
3333
+ const path = protectedLiteral(text, isProtected);
3334
+ if (path) {
3335
+ return {
3336
+ outcome: "dangerous",
3337
+ what: WHAT["reads-protected"],
3338
+ evidence: path.slice(0, 60),
3339
+ category: "reads-protected"
3340
+ };
2399
3341
  }
2400
- return views;
3342
+ const loop = amplifies(language, text);
3343
+ if (loop) {
3344
+ return { outcome: "dangerous", what: WHAT.amplifies, evidence: loop, category: "amplifies" };
3345
+ }
3346
+ return null;
2401
3347
  }
2402
3348
 
2403
3349
  // src/shell/index.ts
@@ -2506,6 +3452,59 @@ function cachedNormalize(command, compute) {
2506
3452
  function normalizeCommandForPolicy(command) {
2507
3453
  return commandReadingsImpl(command).posix;
2508
3454
  }
3455
+ var INTERPRETER_LINE = /^#![ \t]*[\w./+-]+(?:[ \t]+[\w./+=:-]+)*[ \t]*\r?(?=\n|$)/;
3456
+ function fileAccessView(command) {
3457
+ const hit = accessViewCache.get(command);
3458
+ if (hit !== void 0) return hit;
3459
+ const view = fileAccessViewImpl(command);
3460
+ if (accessViewCache.size >= ACCESS_VIEW_CACHE_MAX) {
3461
+ const oldest = accessViewCache.keys().next().value;
3462
+ if (oldest !== void 0) accessViewCache.delete(oldest);
3463
+ }
3464
+ accessViewCache.set(command, view);
3465
+ return view;
3466
+ }
3467
+ var PROGRAM_DIR = /^(?:\/usr(?:\/local)?|\/opt\/homebrew|\/home\/linuxbrew\/\.linuxbrew)?\/s?bin\/[^/]+$|^\/snap\/bin\/[^/]+$|^(?![/~\\]|[A-Za-z]:|.*\.\.)/;
3468
+ var ACCESS_VIEW_CACHE_MAX = 1e3;
3469
+ var accessViewCache = /* @__PURE__ */ new Map();
3470
+ function fileAccessViewImpl(command) {
3471
+ const text = command.replace(INTERPRETER_LINE, "");
3472
+ const f = parseShared(text);
3473
+ if (f === PARSE_FAIL) return text;
3474
+ const toCharIndex = byteOffsetToCharIndex(text);
3475
+ const at = (byteOffset) => toCharIndex === null ? byteOffset : toCharIndex(byteOffset);
3476
+ const edits = [];
3477
+ try {
3478
+ syntax.Walk(f, (node) => {
3479
+ if (!node) return false;
3480
+ const n = node;
3481
+ if (syntax.NodeType(n) !== "CallExpr") return true;
3482
+ const args = n.Args || [];
3483
+ const words = args.map((a) => resolveWordLiteral(a));
3484
+ const head = unwrapCommandHead(words);
3485
+ for (const i of /* @__PURE__ */ new Set([0, head])) {
3486
+ const word = words[i];
3487
+ if (i >= args.length || word === null || word === void 0 || !/[\\/]/.test(word)) {
3488
+ continue;
3489
+ }
3490
+ if (!PROGRAM_DIR.test(word)) continue;
3491
+ const name = word.split(/[\\/]/).pop() ?? "";
3492
+ if (!name) continue;
3493
+ const s = at(args[i].Pos().Offset());
3494
+ const e = at(args[i].End().Offset());
3495
+ if (s < 0 || e < 0) continue;
3496
+ edits.push([s, e, name]);
3497
+ }
3498
+ return true;
3499
+ });
3500
+ } catch {
3501
+ return text;
3502
+ }
3503
+ edits.sort((a, b) => b[0] - a[0]);
3504
+ let out = text;
3505
+ for (const [s, e, rep] of edits) out = out.slice(0, s) + rep + out.slice(e);
3506
+ return out;
3507
+ }
2509
3508
  function commandReadings(command) {
2510
3509
  const r = commandReadingsImpl(command);
2511
3510
  const out = /* @__PURE__ */ new Set([r.posix, r.separator, r.folded]);
@@ -3671,53 +4670,119 @@ function unwrapCommandHead(words, stopAtFind = false, stopAtDynamic = false) {
3671
4670
  }
3672
4671
  return i;
3673
4672
  }
3674
- function inlineExecStmt(stmt, pipeFed) {
4673
+ function heredocText(word) {
4674
+ const parts = word?.Parts ?? [];
4675
+ let out = "";
4676
+ for (const p of parts) {
4677
+ if (syntax.NodeType(p) !== "Lit") return null;
4678
+ out += p.Value ?? "";
4679
+ }
4680
+ return out;
4681
+ }
4682
+ function stdinCodeOf(redirs) {
4683
+ const heredoc = /* @__PURE__ */ new Set([deriveRedirOp("cat <<X\nX"), deriveRedirOp("cat <<-X\nX")]);
4684
+ const herestring = deriveRedirOp("cat <<< x");
4685
+ for (const r of redirs) {
4686
+ if (!r || !redirStdinOps().has(r.Op)) continue;
4687
+ if (heredoc.has(r.Op)) {
4688
+ const text = heredocText(r.Hdoc);
4689
+ return text === null ? { code: null, source: "variable" } : { code: text };
4690
+ }
4691
+ if (r.Op === herestring) {
4692
+ const text = resolveWordLiteral(r.Word);
4693
+ return text === null ? { code: null, source: "variable" } : { code: text };
4694
+ }
4695
+ return { code: null, source: "file" };
4696
+ }
4697
+ return { code: null, source: "file" };
4698
+ }
4699
+ function attachedCode(interp, flag) {
4700
+ const eq = flag.indexOf("=");
4701
+ if (flag.startsWith("--")) return eq >= 0 ? flag.slice(eq + 1) : null;
4702
+ if (/^(pwsh|powershell)/.test(interp)) return null;
4703
+ const letters = /^(perl|ruby|lua|bun|osascript|rscript|irb)$/.test(interp) ? "e" : /^(node|tsx|ts-node)$/.test(interp) ? "ep" : interp === "php" ? "r" : "c";
4704
+ const body = flag.slice(1);
4705
+ const at = [...body].findIndex((ch) => letters.includes(ch.toLowerCase()));
4706
+ if (at < 0) return null;
4707
+ let rest = body.slice(at + 1);
4708
+ if (letters === "ep" && /^[ep]*$/i.test(rest)) rest = "";
4709
+ return rest === "" ? null : rest;
4710
+ }
4711
+ function inlineExecCall(stmt, pipeFed) {
3675
4712
  const cmd = stmt?.Cmd;
3676
- if (!cmd || syntax.NodeType(cmd) !== "CallExpr") return false;
4713
+ if (!cmd || syntax.NodeType(cmd) !== "CallExpr") return null;
3677
4714
  const words = (cmd.Args || []).map((a) => resolveWordLiteral(a));
3678
- if (words.length === 0) return false;
4715
+ if (words.length === 0) return null;
3679
4716
  const headIdx = unwrapCommandHead(words);
3680
4717
  const rawHead = words[headIdx];
3681
- if (rawHead == null) return false;
4718
+ if (rawHead == null) return null;
3682
4719
  const interp = (rawHead.split("/").pop() ?? "").toLowerCase();
3683
- if (!INLINE_INTERPRETER.test(interp)) return false;
4720
+ if (!INLINE_INTERPRETER.test(interp)) return null;
3684
4721
  let args = words.slice(headIdx + 1);
3685
- if (interp === "deno" && (args[0] ?? "").toLowerCase() === "eval") return true;
4722
+ if (interp === "deno" && (args[0] ?? "").toLowerCase() === "eval") {
4723
+ const code = args[1] ?? null;
4724
+ return { interp, code: [code], source: code === null ? "variable" : void 0 };
4725
+ }
3686
4726
  if (INTERP_LEADING_TARGET.has(interp)) {
3687
4727
  const firstFlag = args.findIndex((a) => a == null || a.startsWith("-"));
3688
4728
  args = firstFlag >= 0 ? args.slice(firstFlag) : [];
3689
4729
  }
4730
+ const redirs = stmt.Redirs || cmd.Redirs || [];
4731
+ const stdinFed = redirs.some((r) => r && redirStdinOps().has(r.Op));
4732
+ const fromStdin = () => {
4733
+ if (stdinFed) {
4734
+ const { code, source } = stdinCodeOf(redirs);
4735
+ return { interp, code: [code], source };
4736
+ }
4737
+ return { interp, code: [null], source: "pipe" };
4738
+ };
3690
4739
  let positionals2 = 0;
3691
4740
  let selectedProgram = false;
4741
+ const codes = [];
3692
4742
  for (let i = 0; i < args.length; i++) {
3693
4743
  const a = args[i];
3694
4744
  if (a == null) {
4745
+ if (codes.length > 0) break;
3695
4746
  positionals2++;
3696
4747
  selectedProgram = true;
3697
4748
  continue;
3698
4749
  }
3699
4750
  if (!selectedProgram && isInlineCodeFlag(interp, a)) {
3700
- if (!/^(bash|sh|zsh|dash|ksh)$/.test(interp)) return true;
3701
- const payload = args[i + 1];
3702
- if (payload == null) return true;
3703
- return shellPayloadNeedsReview(payload);
4751
+ if (/^(bash|sh|zsh|dash|ksh)$/.test(interp)) {
4752
+ const payload = args[i + 1];
4753
+ if (payload == null) return { interp, code: [null], source: "variable" };
4754
+ return shellPayloadNeedsReview(payload) ? { interp, code: [null], source: "payload" } : null;
4755
+ }
4756
+ const attached = attachedCode(interp, a);
4757
+ if (attached !== null) {
4758
+ codes.push(attached);
4759
+ } else {
4760
+ codes.push(args[i + 1] ?? null);
4761
+ i++;
4762
+ }
4763
+ continue;
4764
+ }
4765
+ if (codes.length > 0) {
4766
+ if (a.startsWith("-")) continue;
4767
+ break;
3704
4768
  }
3705
4769
  if (a === "-m") {
3706
4770
  selectedProgram = true;
3707
4771
  continue;
3708
4772
  }
3709
- if (a === "-" && !selectedProgram) return true;
4773
+ if (a === "-" && !selectedProgram) return fromStdin();
3710
4774
  if (!a.startsWith("-")) {
3711
4775
  positionals2++;
3712
4776
  selectedProgram = true;
3713
4777
  }
3714
4778
  }
3715
- const redirs = stmt.Redirs || cmd.Redirs || [];
3716
- const stdinFed = redirs.some((r) => r && redirStdinOps().has(r.Op));
4779
+ if (codes.length > 0) {
4780
+ return { interp, code: codes, source: codes.includes(null) ? "variable" : void 0 };
4781
+ }
3717
4782
  if (positionals2 === 0 && (stdinFed || pipeFed)) {
3718
- if (!/^(bash|sh|zsh)$/i.test(interp)) return true;
4783
+ if (!/^(bash|sh|zsh)$/i.test(interp)) return fromStdin();
3719
4784
  }
3720
- return false;
4785
+ return null;
3721
4786
  }
3722
4787
  var MAX_PAYLOAD_NESTING = 8;
3723
4788
  var payloadNesting = 0;
@@ -3752,7 +4817,7 @@ function shellPayloadNeedsReview(payload) {
3752
4817
  payload
3753
4818
  ))
3754
4819
  review = true;
3755
- if (!review && detectInlineExec(payload)) review = true;
4820
+ if (!review && inlineExecReview(payload) !== null) review = true;
3756
4821
  } catch {
3757
4822
  review = true;
3758
4823
  } finally {
@@ -3760,35 +4825,85 @@ function shellPayloadNeedsReview(payload) {
3760
4825
  }
3761
4826
  return review;
3762
4827
  }
3763
- function detectInlineExec(command) {
4828
+ var MAX_INLINE_CALLS = 16;
4829
+ function inlineExecCalls(command) {
3764
4830
  const f = parseShared(command);
3765
- if (f === PARSE_FAIL) {
3766
- return /(^|[|;&]|&&)\s*(?:[\w./-]*\/)?(python[\d.]*|perl|ruby|node|php|lua|deno|bun|pwsh|osascript|rscript|bash|sh|zsh)\s+-{1,2}[a-z]*[ceEr]/i.test(
3767
- command
3768
- );
3769
- }
3770
- let found = false;
4831
+ if (f === PARSE_FAIL) return PARSE_FAIL;
4832
+ const calls = [];
3771
4833
  try {
3772
4834
  syntax.Walk(f, (node) => {
3773
- if (!node || found) return false;
4835
+ if (!node || calls.length >= MAX_INLINE_CALLS) return false;
3774
4836
  const n = node;
3775
4837
  const t = syntax.NodeType(n);
3776
4838
  if (t === "BinaryCmd" && n.Y && !listOps().has(n.Op)) {
3777
- if (inlineExecStmt(n.Y, true)) {
3778
- found = true;
3779
- return false;
3780
- }
4839
+ const call = inlineExecCall(n.Y, true);
4840
+ if (call) calls.push(call);
3781
4841
  }
3782
- if (t === "Stmt" && inlineExecStmt(n, false)) {
3783
- found = true;
3784
- return false;
4842
+ if (t === "Stmt") {
4843
+ const call = inlineExecCall(n, false);
4844
+ if (call) calls.push(call);
3785
4845
  }
3786
4846
  return true;
3787
4847
  });
3788
4848
  } catch {
3789
- return found;
3790
4849
  }
3791
- return found;
4850
+ return calls;
4851
+ }
4852
+ 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;
4853
+ function detectInlineExec(command) {
4854
+ const calls = inlineExecCalls(command);
4855
+ if (calls === PARSE_FAIL) return INLINE_EXEC_FALLBACK.test(command);
4856
+ return calls.length > 0;
4857
+ }
4858
+ var UNREADABLE_SOURCE = {
4859
+ pipe: "reads its code from another program through a pipe",
4860
+ file: "reads its code from a file on stdin",
4861
+ variable: "runs code the shell fills in at run time",
4862
+ payload: "runs a shell payload that evaluates, sources or runs further code"
4863
+ };
4864
+ function isProtectedCodePath(p) {
4865
+ if (matchSensitivePath(p) !== null) return true;
4866
+ return SYSTEM_AUTH_FILES.includes(p) || SYSTEM_AUTH_DIRS.some((d) => p === d || p.startsWith(d + "/"));
4867
+ }
4868
+ function inlineExecDescription(r) {
4869
+ 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.";
4870
+ return `${lead} Review the full script below before allowing it to execute.`;
4871
+ }
4872
+ function inlineExecReason(r) {
4873
+ const who = r.interp ? `This inline ${r.interp} code` : "This inline code";
4874
+ return r.evidence ? `${who} ${r.what} (${r.evidence})` : `${who} ${r.what}`;
4875
+ }
4876
+ function inlineExecReview(command) {
4877
+ const calls = inlineExecCalls(command);
4878
+ if (calls === PARSE_FAIL) {
4879
+ return INLINE_EXEC_FALLBACK.test(command) ? { outcome: "unreadable", interp: "", what: "could not be parsed" } : null;
4880
+ }
4881
+ let unreadable = calls.length >= MAX_INLINE_CALLS ? { outcome: "unreadable", interp: "", what: "runs more inline programs than node9 reads" } : null;
4882
+ for (const call of calls) {
4883
+ const language = inlineLanguageOf(call.interp);
4884
+ for (const code of call.code) {
4885
+ let finding = null;
4886
+ if (code === null) {
4887
+ finding = {
4888
+ outcome: "unreadable",
4889
+ interp: call.interp,
4890
+ what: UNREADABLE_SOURCE[call.source ?? "variable"]
4891
+ };
4892
+ } else if (language === null) {
4893
+ finding = {
4894
+ outcome: "unreadable",
4895
+ interp: call.interp,
4896
+ what: `is ${call.interp} code, which node9 does not read`
4897
+ };
4898
+ } else {
4899
+ const judged = judgeInlineCode(language, code, isProtectedCodePath);
4900
+ if (judged) finding = { ...judged, interp: call.interp };
4901
+ }
4902
+ if (finding?.outcome === "dangerous") return finding;
4903
+ if (finding && !unreadable) unreadable = finding;
4904
+ }
4905
+ }
4906
+ return unreadable;
3792
4907
  }
3793
4908
  function analyzeChmod777(command) {
3794
4909
  if (!/chmod/i.test(command.replace(/[\\'"]/g, ""))) return null;
@@ -5256,46 +6371,6 @@ function analyzeShellCommand(command) {
5256
6371
  return { actions, paths, allTokens };
5257
6372
  }
5258
6373
 
5259
- // src/utils/regex.ts
5260
- import safeRegex2 from "safe-regex2";
5261
- var MAX_REGEX_LENGTH = 256;
5262
- var REGEX_CACHE_MAX = 500;
5263
- var regexCache = /* @__PURE__ */ new Map();
5264
- function validateRegex(pattern) {
5265
- if (!pattern) return "Pattern is required";
5266
- if (pattern.length > MAX_REGEX_LENGTH) return `Pattern exceeds max length of ${MAX_REGEX_LENGTH}`;
5267
- try {
5268
- new RegExp(pattern);
5269
- } catch (e) {
5270
- return `Invalid regex syntax: ${e.message}`;
5271
- }
5272
- if (/\\\d+[*+{]/.test(pattern)) return "Quantified backreferences are forbidden (ReDoS risk)";
5273
- if (!safeRegex2(pattern)) return "Pattern rejected: potential ReDoS vulnerability detected";
5274
- return null;
5275
- }
5276
- function getCompiledRegex(pattern, flags = "") {
5277
- if (flags && !/^[gimsuy]+$/.test(flags)) return null;
5278
- const key = `${pattern}\0${flags}`;
5279
- if (regexCache.has(key)) {
5280
- const cached = regexCache.get(key);
5281
- regexCache.delete(key);
5282
- regexCache.set(key, cached);
5283
- return cached;
5284
- }
5285
- if (validateRegex(pattern) !== null) return null;
5286
- try {
5287
- const re = new RegExp(pattern, flags);
5288
- if (regexCache.size >= REGEX_CACHE_MAX) {
5289
- const oldest = regexCache.keys().next().value;
5290
- if (oldest) regexCache.delete(oldest);
5291
- }
5292
- regexCache.set(key, re);
5293
- return re;
5294
- } catch {
5295
- return null;
5296
- }
5297
- }
5298
-
5299
6374
  // src/rules/index.ts
5300
6375
  function matchesPattern(text, patterns) {
5301
6376
  const p = Array.isArray(patterns) ? patterns : [patterns];
@@ -5307,6 +6382,18 @@ function matchesPattern(text, patterns) {
5307
6382
  const withoutDotSlash = text.replace(/^\.\//, "");
5308
6383
  return isMatch(withoutDotSlash) || isMatch(`./${withoutDotSlash}`);
5309
6384
  }
6385
+ function mcpServerFromToolName(toolName) {
6386
+ const match = toolName.match(/^mcp__([^_](?:[^_]|_(?!_))*?)__/i);
6387
+ return match?.[1];
6388
+ }
6389
+ function ruleServerMatches(rule, serverLabel) {
6390
+ const label = typeof serverLabel === "string" ? serverLabel.trim().replace(/[\\/]/g, "-") || void 0 : void 0;
6391
+ if (rule.server) {
6392
+ if (!label || !matchesPattern(label, rule.server)) return false;
6393
+ }
6394
+ if (rule.notServer && label && matchesPattern(label, rule.notServer)) return false;
6395
+ return true;
6396
+ }
5310
6397
  var FORBIDDEN_PATH_SEGMENTS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
5311
6398
  function getNestedValue(obj, path) {
5312
6399
  if (!obj || typeof obj !== "object") return null;
@@ -5330,23 +6417,26 @@ function evaluateSmartConditions(args, rule) {
5330
6417
  return val;
5331
6418
  };
5332
6419
  const readingsCache = /* @__PURE__ */ new Map();
5333
- const resolveFieldReadings = (field) => {
5334
- const cached = readingsCache.get(field);
6420
+ const resolveFieldReadings = (field, reading) => {
6421
+ const access = reading === "access" && field === "command";
6422
+ const key = access ? `${field}\0access` : field;
6423
+ const cached = readingsCache.get(key);
5335
6424
  if (cached) return cached;
5336
6425
  const primary = resolveField(field);
5337
6426
  if (primary === null) {
5338
- readingsCache.set(field, []);
6427
+ readingsCache.set(key, []);
5339
6428
  return [];
5340
6429
  }
5341
6430
  let out = [primary];
5342
6431
  if (field === "command") {
5343
6432
  const raw = getNestedValue(args, field);
5344
6433
  if (typeof raw === "string") {
5345
- const collapsed = commandReadings(raw).map((r) => r.replace(/\s+/g, " ").trim());
5346
- out = [.../* @__PURE__ */ new Set([primary, ...collapsed])];
6434
+ const text = access ? fileAccessView(raw) : raw;
6435
+ const collapsed = commandReadings(text).map((r) => r.replace(/\s+/g, " ").trim());
6436
+ out = access ? [...new Set(collapsed)] : [.../* @__PURE__ */ new Set([primary, ...collapsed])];
5347
6437
  }
5348
6438
  }
5349
- readingsCache.set(field, out);
6439
+ readingsCache.set(key, out);
5350
6440
  return out;
5351
6441
  };
5352
6442
  const results = rule.conditions.map((cond) => {
@@ -5364,14 +6454,14 @@ function evaluateSmartConditions(args, rule) {
5364
6454
  if (val === null || !cond.value) return false;
5365
6455
  const reM = getCompiledRegex(cond.value, cond.flags ?? "");
5366
6456
  if (!reM) return false;
5367
- return resolveFieldReadings(cond.field).some((v) => reM.test(v));
6457
+ return resolveFieldReadings(cond.field, cond.reading).some((v) => reM.test(v));
5368
6458
  }
5369
6459
  case "notMatches": {
5370
6460
  if (!cond.value) return false;
5371
6461
  if (val === null) return true;
5372
6462
  const reN = getCompiledRegex(cond.value, cond.flags ?? "");
5373
6463
  if (!reN) return false;
5374
- return !resolveFieldReadings(cond.field).some((v) => reN.test(v));
6464
+ return !resolveFieldReadings(cond.field, cond.reading).some((v) => reN.test(v));
5375
6465
  }
5376
6466
  case "matchesGlob":
5377
6467
  return val !== null && cond.value ? pm.isMatch(val, cond.value) : false;
@@ -6332,76 +7422,6 @@ function collectShellFileAccesses(command, context = {}) {
6332
7422
  return out;
6333
7423
  }
6334
7424
 
6335
- // src/files/paths.ts
6336
- var SYSTEM_AUTH_FILES = [
6337
- "/etc/passwd",
6338
- "/etc/shadow",
6339
- "/etc/group",
6340
- "/etc/gshadow",
6341
- "/etc/sudoers"
6342
- ];
6343
- var SYSTEM_AUTH_DIRS = ["/etc/security", "/etc/pam.d", "/etc/sudoers.d"];
6344
- var PASSWORD_HASH_FILES = ["/etc/shadow", "/etc/gshadow"];
6345
- var STARTUP_NAMES = [".bashrc", ".zshrc", ".profile", ".bash_profile"];
6346
- var SYSTEM_DIRS = [
6347
- "/usr",
6348
- "/etc",
6349
- "/boot",
6350
- "/bin",
6351
- "/sbin",
6352
- "/lib",
6353
- "/lib64",
6354
- "/var/log"
6355
- ];
6356
- var SYSTEM_DIRS_EXEMPT = ["/usr/local", "/usr/src"];
6357
- var UPLOAD_SYSTEM_DIRS = [...SYSTEM_DIRS, "/proc", "/sys", "/root"];
6358
- var AGENT_INSTRUCTION_FILES = [
6359
- ".gitlab-ci.yml",
6360
- "CLAUDE.md",
6361
- "AGENTS.md",
6362
- ".cursorrules",
6363
- ".mcp.json",
6364
- ".vscode/settings.json",
6365
- "package.json"
6366
- ];
6367
- var AGENT_INSTRUCTION_DIRS = [
6368
- ".github/workflows",
6369
- ".claude",
6370
- ".cursor",
6371
- ".git/hooks",
6372
- ".husky"
6373
- ];
6374
- function isAgentInstructionPath(absPath, root) {
6375
- const r = root.replace(/\/$/, "");
6376
- if (!(absPath === r || absPath.startsWith(r + "/"))) return false;
6377
- const rel = absPath.slice(r.length + 1);
6378
- if (AGENT_INSTRUCTION_FILES.includes(rel)) return true;
6379
- return AGENT_INSTRUCTION_DIRS.some((d) => rel === d || rel.startsWith(d + "/"));
6380
- }
6381
- function isInside(root, p) {
6382
- const r = root.replace(/\/$/, "") || "/";
6383
- return p === r || p.startsWith(r === "/" ? "/" : r + "/");
6384
- }
6385
- var LEGACY_SYSTEM_PATH_RE = /^(?:[a-zA-Z]:)?\/etc\/(?:passwd|shadow|sudoers)$/;
6386
- function isPasswordHashPath(p) {
6387
- return PASSWORD_HASH_FILES.includes(p);
6388
- }
6389
- function isLegacySystemPath(p) {
6390
- return LEGACY_SYSTEM_PATH_RE.test(p);
6391
- }
6392
- function normalizeFilePath(p, cwd = "", home = "~") {
6393
- if (!p.startsWith("/") && !p.startsWith("~") && cwd) p = `${cwd}/${p}`;
6394
- if (p === "~" || p.startsWith("~/")) p = home + p.slice(1);
6395
- const rooted = p.startsWith("/");
6396
- const parts = [];
6397
- for (const part of p.split("/")) {
6398
- if (!part || part === ".") continue;
6399
- if (part === ".." && parts.length && parts.at(-1) !== "..") parts.pop();
6400
- else if (part !== ".." || !rooted) parts.push(part);
6401
- }
6402
- return (rooted ? "/" : "") + parts.join("/");
6403
- }
6404
-
6405
7425
  // src/files/protected-access.ts
6406
7426
  function incompleteFileVerdict(operation = "write") {
6407
7427
  return {
@@ -6584,7 +7604,7 @@ function evaluateProtectedFileAccess(accesses, context, settings) {
6584
7604
  }
6585
7605
 
6586
7606
  // src/dlp/index.ts
6587
- import safeRegex3 from "safe-regex2";
7607
+ import safeRegex2 from "safe-regex2";
6588
7608
 
6589
7609
  // src/dlp/mnemonic.ts
6590
7610
  import { createHash } from "crypto";
@@ -10317,14 +11337,14 @@ var SENSITIVE_PATH_REGEXES = [
10317
11337
  ];
10318
11338
  function assertBuiltinPatternsAreSafe() {
10319
11339
  for (const p of DLP_PATTERNS) {
10320
- if (!safeRegex3(p.regex.source)) {
11340
+ if (!safeRegex2(p.regex.source)) {
10321
11341
  throw new Error(
10322
11342
  `[node9 engine] Builtin DLP pattern '${p.name}' is vulnerable to ReDoS: ${p.regex.source}`
10323
11343
  );
10324
11344
  }
10325
11345
  }
10326
11346
  for (const re of SENSITIVE_PATH_PATTERNS) {
10327
- if (!safeRegex3(re.source)) {
11347
+ if (!safeRegex2(re.source)) {
10328
11348
  throw new Error(
10329
11349
  `[node9 engine] Builtin sensitive-path pattern is vulnerable to ReDoS: ${re.source}`
10330
11350
  );
@@ -11766,7 +12786,11 @@ var MAP_GOVERNED = /* @__PURE__ */ new Set([
11766
12786
  "commands.disk-destroy",
11767
12787
  "commands.dangerous-word",
11768
12788
  "commands.node9-disarm",
11769
- "data.pipe-chain"
12789
+ "data.pipe-chain",
12790
+ // The general action checks (node9Firewall#390): smart rules the map governs.
12791
+ "actions.money",
12792
+ "actions.access",
12793
+ "actions.publish"
11770
12794
  ]);
11771
12795
  var KNOB_GOVERNED = {
11772
12796
  "data.secrets": ["off", "block"],
@@ -12715,11 +13739,15 @@ async function evaluatePolicyCore(config, toolName, args, context = {}, hooks =
12715
13739
  };
12716
13740
  const ruleCheck = (rule) => {
12717
13741
  if (rule.verdict === "allow") return void 0;
12718
- if (!rule.builtin || rule.pinned) return void 0;
13742
+ if (!rule.builtin) return void 0;
12719
13743
  const id = checkIdForRule(rule.name);
12720
13744
  if (!id) return void 0;
12721
13745
  const def = getCheck(id);
12722
13746
  if (!def) return void 0;
13747
+ if (rule.pinned) {
13748
+ const explicit = config.policy.checks?.[id];
13749
+ return def.pack && config.policy.checkSources?.[id] === "workspace" && isVerdict(explicit) ? { id, value: explicit } : void 0;
13750
+ }
12723
13751
  if (rule.name?.startsWith("shield:") && !def.pack) return void 0;
12724
13752
  if (def.pack) {
12725
13753
  const explicit = config.policy.checks?.[id];
@@ -12727,8 +13755,10 @@ async function evaluatePolicyCore(config, toolName, args, context = {}, hooks =
12727
13755
  }
12728
13756
  return { id, value: cv(id) };
12729
13757
  };
13758
+ const serverLabel = context.mcpServer ?? mcpServerFromToolName(toolName);
12730
13759
  const matches = config.policy.smartRules.filter((rule) => {
12731
13760
  if (!toolMatchesRule(toolName, rule.tool, layers)) return false;
13761
+ if (!ruleServerMatches(rule, serverLabel)) return false;
12732
13762
  if (astSuppressed(rule)) return false;
12733
13763
  if (rmCleanupWaiver && rule.name === "review-rm" && rule.verdict === "review") return false;
12734
13764
  if (!evaluateSmartConditions(shellRuleArgs(toolName, args, rule.tool, layers), rule))
@@ -12805,11 +13835,13 @@ async function evaluatePolicyCore(config, toolName, args, context = {}, hooks =
12805
13835
  if (v?.logged) noteLogged(v);
12806
13836
  else if (v) candidates.push(v);
12807
13837
  };
12808
- if (detectInlineExec(shellCommand)) {
13838
+ const inline = config.settings.mode === "strict" ? detectInlineExec(shellCommand) ? void 0 : null : inlineExecReview(shellCommand);
13839
+ if (inline !== null) {
12809
13840
  consider("commands.inline-exec", {
12810
13841
  decision: "review",
12811
13842
  blockedByLabel: "Node9 Standard (Inline Execution)",
12812
- ruleDescription: "The AI is running code directly from the command line. Review the full script below before allowing it to execute.",
13843
+ ...inline ? { reason: inlineExecReason(inline) } : {},
13844
+ ruleDescription: inlineExecDescription(inline),
12813
13845
  tier: 3,
12814
13846
  checkId: "commands.inline-exec"
12815
13847
  });
@@ -14024,6 +15056,74 @@ function safeMessage(value, max = 300) {
14024
15056
  return s.length > max ? s.slice(0, max - 1) + "\u2026" : s;
14025
15057
  }
14026
15058
 
15059
+ // src/suggest.ts
15060
+ function unwrapRuleLabel(label) {
15061
+ return ruleNameInLabel(label.trim()) ?? label.trim();
15062
+ }
15063
+ var SHIELD_RULE = /^shield:([a-z0-9-]+):((?:review|block)-[a-z0-9-]+)$/;
15064
+ var ACTION_RULE = /^review-action-(money|access|publish)-/;
15065
+ function packRowOf(ruleName, shield) {
15066
+ const id = checkIdForRule(ruleName);
15067
+ const def = id ? CHECK_BY_ID.get(id) : void 0;
15068
+ return def?.pack === shield && def.legacy?.includes(ruleName) ? id : void 0;
15069
+ }
15070
+ function suggestFromApprovals(rows, opts = {}) {
15071
+ const minApprovals = opts.minApprovals ?? 3;
15072
+ const minSessions = opts.minSessions ?? 2;
15073
+ const byKey = /* @__PURE__ */ new Map();
15074
+ for (const r of rows) {
15075
+ const ruleName = unwrapRuleLabel(r.ruleName);
15076
+ const action = ACTION_RULE.exec(ruleName);
15077
+ if (action && checkIdForRule(ruleName) !== `actions.${action[1]}`) continue;
15078
+ if (action && !r.server) continue;
15079
+ const key = action ? `server:${r.server.toLowerCase()}:${action[1]}` : `rule:${ruleName}`;
15080
+ const isAction = action !== null;
15081
+ const acc = byKey.get(key) ?? {
15082
+ ruleName,
15083
+ server: isAction ? r.server : void 0,
15084
+ approvals: 0,
15085
+ sessions: /* @__PURE__ */ new Set(),
15086
+ denied: false
15087
+ };
15088
+ if (r.decision === "denied") acc.denied = true;
15089
+ else {
15090
+ acc.approvals += 1;
15091
+ if (r.sessionId) acc.sessions.add(r.sessionId);
15092
+ }
15093
+ byKey.set(key, acc);
15094
+ }
15095
+ const out = [];
15096
+ for (const acc of byKey.values()) {
15097
+ if (acc.denied || acc.approvals < minApprovals || acc.sessions.size < minSessions) continue;
15098
+ const shieldRule = SHIELD_RULE.exec(acc.ruleName);
15099
+ if (shieldRule) {
15100
+ const checkId = packRowOf(acc.ruleName, shieldRule[1]);
15101
+ if (!checkId) continue;
15102
+ out.push({
15103
+ kind: "quiet-rule",
15104
+ ruleName: acc.ruleName,
15105
+ shield: shieldRule[1],
15106
+ rule: shieldRule[2],
15107
+ checkId,
15108
+ approvals: acc.approvals,
15109
+ sessions: acc.sessions.size
15110
+ });
15111
+ continue;
15112
+ }
15113
+ const action = ACTION_RULE.exec(acc.ruleName);
15114
+ if (action && acc.server) {
15115
+ out.push({
15116
+ kind: "link-server",
15117
+ server: acc.server,
15118
+ checkId: `actions.${action[1]}`,
15119
+ approvals: acc.approvals,
15120
+ sessions: acc.sessions.size
15121
+ });
15122
+ }
15123
+ }
15124
+ return out.sort((a, b) => b.approvals - a.approvals);
15125
+ }
15126
+
14027
15127
  // src/loop/index.ts
14028
15128
  import crypto from "crypto";
14029
15129
  var LOOP_MAX_RECORDS = 500;
@@ -14495,8 +15595,8 @@ function matchCanaryArgs(args, values) {
14495
15595
 
14496
15596
  // src/scan/canonical.ts
14497
15597
  var LONG_OUTPUT_THRESHOLD_BYTES = 100 * 1024;
14498
- var CANONICAL_EXTRACTOR_VERSION = "canonical-v29";
14499
- var CANONICAL_EXTRACTOR_HASH = "3b936dab47d27942";
15598
+ var CANONICAL_EXTRACTOR_VERSION = "canonical-v30";
15599
+ var CANONICAL_EXTRACTOR_HASH = "d55f1f9e5bee7e41";
14500
15600
  var DEDUPE_PREVIEW_LEN = 120;
14501
15601
  function extractCanonicalFindings(call, ctx) {
14502
15602
  const out = [];
@@ -14866,9 +15966,13 @@ function* stringValues(obj, depth = 0) {
14866
15966
  // src/index.ts
14867
15967
  var ENGINE_VERSION = "1.4.0";
14868
15968
  export {
14869
- ACTION_SHIELD_NAMES,
15969
+ ACTION_CHECKS,
15970
+ ACTION_TEMPLATES,
14870
15971
  AGENT_INSTRUCTION_DIRS,
14871
15972
  AGENT_INSTRUCTION_FILES,
15973
+ APP_SERVER_GLOB,
15974
+ APP_SHIELD_NAMES,
15975
+ APP_SHIELD_SPECS,
14872
15976
  ARGUMENT_SCAN_LIMITS,
14873
15977
  AST_FS_REGEX_RULES,
14874
15978
  BASH_TOOL_NAMES,
@@ -14895,6 +15999,7 @@ export {
14895
15999
  FILE_TOOLS,
14896
16000
  FLAGS_WITH_VALUES,
14897
16001
  FS_READ_TOOLS,
16002
+ GENERAL_ACTION_RULES,
14898
16003
  KNOB_GOVERNED,
14899
16004
  LONG_OUTPUT_THRESHOLD_BYTES,
14900
16005
  LOOP_MAX_RECORDS,
@@ -14906,6 +16011,7 @@ export {
14906
16011
  PATTERN_VERB_NAMES,
14907
16012
  PRIVILEGE_ESCALATION_RE,
14908
16013
  REALTIME_PII_PATTERNS,
16014
+ REPLACED_SHIELDS,
14909
16015
  SCAN_SIGNAL_WEIGHTS,
14910
16016
  SENSITIVE_PATH_RE,
14911
16017
  SENSITIVE_PATH_REGEXES,
@@ -14966,6 +16072,7 @@ export {
14966
16072
  extractShellDestTokens,
14967
16073
  extractShellDestinations,
14968
16074
  extractToolDestinations,
16075
+ fileAccessView,
14969
16076
  fileOperandFlagsOf,
14970
16077
  fileToolOperation,
14971
16078
  foldHomoglyphs,
@@ -14976,6 +16083,9 @@ export {
14976
16083
  hashDestination,
14977
16084
  hostMatches,
14978
16085
  incompleteFileVerdict,
16086
+ inlineExecDescription,
16087
+ inlineExecReason,
16088
+ inlineExecReview,
14979
16089
  inspectArgumentSecrets,
14980
16090
  inspectionEntry,
14981
16091
  inspectionLayers,
@@ -15006,6 +16116,7 @@ export {
15006
16116
  matchesPattern,
15007
16117
  matchesTrustedEntry,
15008
16118
  matchesTrustedList,
16119
+ mcpServerFromToolName,
15009
16120
  narrativeRuleLabel,
15010
16121
  normalizeCommandForPolicy,
15011
16122
  normalizeDestination,
@@ -15026,6 +16137,7 @@ export {
15026
16137
  resolveCheckMap,
15027
16138
  resolvePinned,
15028
16139
  resolveShellInput,
16140
+ ruleServerMatches,
15029
16141
  safeMessage,
15030
16142
  sampleCopyCommand,
15031
16143
  scanArgs,
@@ -15044,6 +16156,7 @@ export {
15044
16156
  stripControlChars,
15045
16157
  stripInvisible,
15046
16158
  stripTerminalEscapes,
16159
+ suggestFromApprovals,
15047
16160
  summarizeBlast,
15048
16161
  summarizeScan,
15049
16162
  toScanFinding,
@@ -15053,6 +16166,7 @@ export {
15053
16166
  tuningFromLegacyPolicy,
15054
16167
  tuningToLegacyPolicy,
15055
16168
  unwrapCommandHead,
16169
+ unwrapRuleLabel,
15056
16170
  validateOverrides,
15057
16171
  validateRegex,
15058
16172
  validateShieldDefinition