@profullstack/threatcrush 0.13.44 → 0.13.46

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.js CHANGED
@@ -31117,6 +31117,11 @@ var DEFAULT_EXCLUDED_RULE_IDS = [941130];
31117
31117
  var ARGUMENT_EXCLUSIONS = [
31118
31118
  { ruleIds: [942100], path: /^\/rest\/v1\//, arg: "select", value: /^[A-Za-z0-9_*,.:!()>-]+$/ }
31119
31119
  ];
31120
+ var COMMAND_WORD_RULE_IDS = /* @__PURE__ */ new Set([932260, 932340, 932370, 932380]);
31121
+ var PLAIN_WORDS = /^[\p{L}\p{N}][\p{L}\p{N} .,_+/-]*(?: & [\p{L}\p{N}][\p{L}\p{N} .,_+/-]*)*$/u;
31122
+ function isPlainWords(value) {
31123
+ return value.length <= 200 && PLAIN_WORDS.test(value);
31124
+ }
31120
31125
  var ATTACK_TYPES = {
31121
31126
  "attack-sqli": "sqli",
31122
31127
  "attack-xss": "xss",
@@ -31269,6 +31274,7 @@ var RequestContext = class {
31269
31274
  const exclusions = ARGUMENT_EXCLUSIONS.filter((e) => e.path.test(path));
31270
31275
  return parseArguments(query).map(({ name, value }) => {
31271
31276
  const ids = exclusions.filter((e) => e.arg === name && e.value.test(value)).flatMap((e) => e.ruleIds);
31277
+ if (isPlainWords(value)) ids.push(...COMMAND_WORD_RULE_IDS);
31272
31278
  return { value, cache: /* @__PURE__ */ new Map(), ...ids.length ? { excluded: new Set(ids) } : {} };
31273
31279
  });
31274
31280
  }
@@ -40723,6 +40729,38 @@ var DEFAULT_PROTECTED = [
40723
40729
  "fc00::/7",
40724
40730
  "fe80::/10"
40725
40731
  ];
40732
+ var SHARED_INFRASTRUCTURE = [
40733
+ "173.245.48.0/20",
40734
+ "103.21.244.0/22",
40735
+ "103.22.200.0/22",
40736
+ "103.31.4.0/22",
40737
+ "141.101.64.0/18",
40738
+ "108.162.192.0/18",
40739
+ "190.93.240.0/20",
40740
+ "188.114.96.0/20",
40741
+ "197.234.240.0/22",
40742
+ "198.41.128.0/17",
40743
+ "162.158.0.0/15",
40744
+ "104.16.0.0/13",
40745
+ "104.24.0.0/14",
40746
+ "172.64.0.0/13",
40747
+ "131.0.72.0/22",
40748
+ "2400:cb00::/32",
40749
+ "2606:4700::/32",
40750
+ "2803:f800::/32",
40751
+ "2405:b500::/32",
40752
+ "2405:8100::/32",
40753
+ "2a06:98c0::/29",
40754
+ "2c0f:f248::/32",
40755
+ "1.1.1.1/32",
40756
+ "1.0.0.1/32",
40757
+ "8.8.8.8/32",
40758
+ "8.8.4.4/32",
40759
+ "9.9.9.9/32",
40760
+ "149.112.112.112/32",
40761
+ "208.67.222.222/32",
40762
+ "208.67.220.220/32"
40763
+ ];
40726
40764
  function ipToBytes(ip) {
40727
40765
  const version = (0, import_node_net4.isIP)(ip);
40728
40766
  if (version === 4) return v4ToBytes(ip);
@@ -45041,7 +45079,7 @@ var RemediationManager = class {
45041
45079
  this.discovery = discovery;
45042
45080
  this.config = { ...DEFAULT_CONFIG2, ...config };
45043
45081
  this.config.allowlist = [...this.config.allowlist];
45044
- this.protectedList = [...DEFAULT_PROTECTED, ...this.config.allowlist];
45082
+ this.protectedList = [...DEFAULT_PROTECTED, ...SHARED_INFRASTRUCTURE, ...this.config.allowlist];
45045
45083
  for (const gateway of defaultGateways()) this.protectedList.push(gateway);
45046
45084
  if (this.adapter.enforces === false) this.config.dry_run = true;
45047
45085
  this.loadState();
@@ -45324,8 +45362,10 @@ var RemediationManager = class {
45324
45362
  */
45325
45363
  async reconcile() {
45326
45364
  const now = Date.now();
45327
- const live2 = this.blocklist.filter((b) => b.expires_at > now);
45328
- const stale = this.blocklist.filter((b) => b.expires_at <= now);
45365
+ const lifted = this.blocklist.filter((b) => this.isAllowlisted(b.ip));
45366
+ for (const entry of lifted) this.logLine(`[firewall] reconcile: lifting ban on protected ${entry.ip}`);
45367
+ const live2 = this.blocklist.filter((b) => b.expires_at > now && !this.isAllowlisted(b.ip));
45368
+ const stale = this.blocklist.filter((b) => b.expires_at <= now || this.isAllowlisted(b.ip));
45329
45369
  for (const entry of stale) {
45330
45370
  if (!entry.dry_run) {
45331
45371
  try {