@fanboynz/network-scanner 3.1.0 → 3.2.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.
@@ -806,7 +806,6 @@ function cleanRulesetFile(filePath, outputPath = null, options = {}) {
806
806
  } = options;
807
807
 
808
808
  const fs = require('fs');
809
- const path = require('path');
810
809
 
811
810
  let content;
812
811
  try {
@@ -1118,6 +1117,7 @@ const KNOWN_SITE_CONFIG_KEYS = new Set([
1118
1117
  'ignore_similar_threshold', 'interact', 'interact_click_count', 'interact_clicks',
1119
1118
  'interact_duration', 'interact_intensity', 'interact_scrolling', 'isBrave',
1120
1119
  'js_redirect_timeout', 'localhost', 'max_redirects', 'openvpn', 'pihole',
1120
+ 'output_regex',
1121
1121
  'plain', 'privoxy', 'proxy', 'proxy_bypass', 'proxy_debug', 'proxy_remote_dns',
1122
1122
  'realistic_click', 'referrer_disable', 'referrer_headers', 'regex_and',
1123
1123
  'reload', 'resourceTypes', 'screenshot', 'searchstring', 'searchstring_and',
@@ -1307,6 +1307,21 @@ function normalizeSiteConfig(siteConfig, siteIndex = 0) {
1307
1307
  }
1308
1308
  }
1309
1309
 
1310
+ // 2b. output_regex must be a compilable regex. An invalid one is silently
1311
+ // disabled at runtime (the use-site try/catch falls back to ||host^), so
1312
+ // surface it here at load time where the user can fix it.
1313
+ if ('output_regex' in siteConfig && siteConfig.output_regex != null && siteConfig.output_regex !== '') {
1314
+ if (typeof siteConfig.output_regex !== 'string') {
1315
+ warnings.push(`${tag}: 'output_regex' should be a string regex, got ${JSON.stringify(siteConfig.output_regex)} — will be ignored`);
1316
+ } else {
1317
+ try {
1318
+ new RegExp(siteConfig.output_regex);
1319
+ } catch (e) {
1320
+ warnings.push(`${tag}: 'output_regex' is not a valid regex (${e.message}) — will be ignored, output falls back to ||host^`);
1321
+ }
1322
+ }
1323
+ }
1324
+
1310
1325
  // 3. String → single-element array coercion for fields that accept both
1311
1326
  // forms (dig, dig-or, whois, whois-or). Downstream consumers all gate on
1312
1327
  // Array.isArray(), so a bare string value previously silently disabled
package/nwss.1 CHANGED
@@ -72,10 +72,6 @@ Output as \fB(^|\\.)domain\\.com$\fR format for Pi-hole regex filters.
72
72
  Generate adblock filter rules with resource type modifiers (requires \fB\-o\fR).
73
73
 
74
74
  .SS General Options
75
- .TP
76
- .B \--verbose
77
- Enable verbose output globally for all sites.
78
-
79
75
  .TP
80
76
  .B \--debug
81
77
  Enable debug mode with detailed logging of all network requests.
@@ -104,6 +100,10 @@ Output full subdomains instead of collapsing to root domains.
104
100
  .B \--no-interact
105
101
  Disable mouse simulation and page interaction globally.
106
102
 
103
+ .TP
104
+ .B \--ghost-cursor
105
+ Use ghost-cursor Bezier mouse movements globally (requires \fBnpm i ghost-cursor\fR). See \fBGhost Cursor Options\fR. Equivalent to per-site \fBcursor_mode: "ghost"\fR.
106
+
107
107
  .TP
108
108
  .BR \--custom-json " \fIFILE\fR"
109
109
  Use \fIFILE\fR instead of \fBconfig.json\fR for configuration.
@@ -136,10 +136,23 @@ Remove Chrome/Puppeteer temporary files before exit.
136
136
  .BR \--max-concurrent " \fINUMBER\fR"
137
137
  Maximum concurrent site processing (1-50, overrides config/default).
138
138
 
139
+ .TP
140
+ .BR \--dns " \fIIP\fR[,\fIIP\fR...]"
141
+ Nameserver(s) for the DNS pre-check AND nettools' dig \(em does not affect Chrome
142
+ navigation or whois. A single address pins all queries to it; several are
143
+ rotated per query (each leading once, the rest as failover) to spread the
144
+ load. Routing dig through these avoids dig timeouts on a flaky system resolver
145
+ silently dropping dig-gated domains. Overrides /etc/resolv.conf. Invalid
146
+ entries are warned and dropped.
147
+
139
148
  .TP
140
149
  .BR \--cleanup-interval " \fINUMBER\fR"
141
150
  Browser restart interval in URLs processed (1-1000, overrides config/default).
142
151
 
152
+ .TP
153
+ .B \--show-dead-domains
154
+ At end of scan, list hostnames that did not resolve or were unreachable (\fBNXDOMAIN\fR/\fBENODATA\fR plus \fBERR_NAME_NOT_RESOLVED\fR/\fBERR_ADDRESS_UNREACHABLE\fR). Excludes blocks and timeouts, since those mean the domain is alive. Useful for pruning dead URLs.
155
+
143
156
  .TP
144
157
  .BR \-h ", " \--help
145
158
  Show help message and exit.
@@ -249,6 +262,10 @@ Regex pattern(s) to match suspicious requests.
249
262
  .B regex_and
250
263
  Boolean. Use AND logic for multiple filterRegex patterns - ALL patterns must match the same URL (default: false).
251
264
 
265
+ .TP
266
+ .B output_regex
267
+ String. Regex applied to each matched URL to build the rule body: capture group 1 (or the whole match) becomes \fB||<capture>\fR instead of \fB||host^\fR. For example \fB^https?://([^/]+/[^/]+/)\fR turns \fBhttps://host.com/script/abc.js\fR into \fB||host.com/script/\fR, collapsing randomized filenames under a path into one rule. The capture must include the host. If the regex does not match a URL, output falls back to \fB||host^\fR. Adblock-only; domain-based formats (dnsmasq, pihole, hosts, plain) emit the bare host.
268
+
252
269
  .TP
253
270
  .B comments
254
271
  Documentation strings or notes - completely ignored by the scanner. Can be a single string or array of strings. Used for adding context, URLs, timestamps, or any documentation notes to configuration files.
@@ -293,6 +310,14 @@ Boolean. Simulate mouse movements and clicks.
293
310
  .B interact_intensity
294
311
  String. Interaction simulation intensity: \fB"low"\fR, \fB"medium"\fR, \fB"high"\fR (default: "medium").
295
312
 
313
+ .TP
314
+ .B interact_click_count
315
+ Integer. Number of random content-zone clicks per load, capped at 20 (default: 3). The default of 3 is a primary click plus two backups, since some ad SDKs suppress the first or second click as warmup.
316
+
317
+ .TP
318
+ .B realistic_click
319
+ Boolean. Higher click fidelity: denser mouse approach (15 steps), sub-pixel hand-tremor micro-moves during the press, and a small mouseup drift so the mousedown and mouseup coordinates differ. For sites that score click realism. Costs roughly 80-120ms per click (default: false).
320
+
296
321
  .TP
297
322
  .B delay
298
323
  Milliseconds to wait after page load (default: 4000).
@@ -419,7 +444,7 @@ Object. Custom page.goto() options for Puppeteer navigation. Available options:
419
444
  .IP \(bu 4
420
445
  \fB"networkidle0"\fR - Wait until 0 network requests for 500ms
421
446
  .IP \(bu 4
422
- \fB"networkidle2"\fR - Wait until 2 network requests for 500ms
447
+ \fB"networkidle2"\fR - Wait until \(<=2 network requests for 500ms
423
448
  .RE
424
449
  .IP \(bu 4
425
450
  \fBtimeout\fR: Maximum navigation time in milliseconds (overrides site timeout)
@@ -479,15 +504,28 @@ Both modes wait 16 seconds before cleanup to allow final operations to complete,
479
504
 
480
505
  .TP
481
506
 
482
- .SS Redirect Handling Options
507
+ .SS Popup Capture Options
508
+ .TP
509
+ .B capture_popups
510
+ Boolean. Capture popup windows opened during the scan and evaluate their landing URL and in-popup requests against \fBfilterRegex\fR/\fBdig\fR/\fBwhois\fR. Requires \fBinteract\fR plus interaction clicks to fire the user-gesture click that opens popups; \fBcapture_popups\fR alone registers the listener but no popups will fire (default: false).
511
+
512
+ .TP
513
+ .B interact_popups
514
+ Boolean. Mouse-click inside captured popups (content-zone clicks) so the chain cascades to its next redirect or ad. Requires \fBcapture_popups\fR. Clicks popups up to \fBcapture_popups_max_depth\fR minus 1 \(em the deepest captured popup is observed, not clicked (default: false).
483
515
 
484
516
  .TP
485
- .B follow_redirects
486
- Boolean. Follow redirects to new domains (default: true).
517
+ .B capture_popups_max_depth
518
+ Integer. Maximum popup-chain depth to capture, e.g. \fBsite -> p1 -> p2 -> p3 -> destination\fR. Each extra level multiplies popups and time (default: 4).
519
+
520
+ .TP
521
+ .B capture_popups_window_ms
522
+ Integer. Per-popup capture window in milliseconds before the popup is auto-closed (default: 5000).
523
+
524
+ .SS Redirect Handling Options
487
525
 
488
526
  .TP
489
527
  .B max_redirects
490
- Number. Maximum number of redirects to follow (default: 10).
528
+ Number. Maximum number of redirects to follow (default: 10; 0 = follow none).
491
529
 
492
530
  .TP
493
531
  .B js_redirect_timeout
@@ -501,6 +539,29 @@ Boolean. Analyze page source for redirect patterns (default: true).
501
539
  .B redirect_timeout_multiplier
502
540
  Number. Increase timeout for redirected URLs (default: 1.5).
503
541
 
542
+ .SS Ghost Cursor Options
543
+ Optional Bezier-curve mouse engine (the \fBghost-cursor\fR npm package, install
544
+ with \fBnpm i ghost-cursor\fR). Falls back to the built-in mouse if not
545
+ installed. Enable per-site with \fBcursor_mode\fR or globally with the
546
+ \fB\-\-ghost-cursor\fR flag.
547
+ .TP
548
+ .B cursor_mode
549
+ String. Set to \fB"ghost"\fR to use ghost-cursor Bezier mouse movements for this site.
550
+ .TP
551
+ .B ghost_cursor_speed
552
+ Number. Movement speed multiplier (default: auto).
553
+ .TP
554
+ .B ghost_cursor_hesitate
555
+ Number. Delay in milliseconds before a click (default: 50).
556
+ .TP
557
+ .B ghost_cursor_overshoot
558
+ Number. Maximum overshoot distance in pixels before correcting back to the target (default: auto).
559
+ .TP
560
+ .B ghost_cursor_duration
561
+ Number. How long the Bezier movement loop runs, in milliseconds (default: \fBinteract_duration\fR or 2000). Part of this budget (up to half) is reserved for clicks.
562
+ .PP
563
+ Ghost-cursor only \fIclicks\fR when both \fBinteract\fR and \fBinteract_clicks\fR are true. With \fBrealistic_click\fR set, each press adds hand-tremor during the hold plus a mouseup drift so mousedown and mouseup coordinates differ. Ghost mode honors \fBinteract_click_count\fR (default 3, cap 20); since realistic clicks take roughly 600-700ms each, raise \fBghost_cursor_duration\fR (about \fBinteract_click_count\fR x 700 plus movement, e.g. 5000-8000) to fit all of them \(em the default 2000 fits about one click.
564
+
504
565
  .SS Cloudflare Protection Options
505
566
 
506
567
  .TP
@@ -678,15 +739,15 @@ Global and per-site boolean to enable similarity filtering against ignoreDomains
678
739
  With default settings (\fBignore_similar_threshold: 80\fR):
679
740
  .RS
680
741
  .IP \(bu 4
681
- \fBanimerco.com\fR vs \fBanimerco.org\fR 100% similar Ignored
742
+ \fBanimerco.com\fR vs \fBanimerco.org\fR \(-> 100% similar \(-> Ignored
682
743
  .IP \(bu 4
683
- \fBgoogle.com\fR vs \fBgoogle.co.uk\fR 100% similar Ignored
744
+ \fBgoogle.com\fR vs \fBgoogle.co.uk\fR \(-> 100% similar \(-> Ignored
684
745
  .IP \(bu 4
685
- \fBamazon.com\fR vs \fBamazon2.org\fR 89% similar Ignored
746
+ \fBamazon.com\fR vs \fBamazon2.org\fR \(-> 89% similar \(-> Ignored
686
747
  .IP \(bu 4
687
- \fBfacebook.com\fR vs \fBfaceboook.com\fR 91% similar Ignored
748
+ \fBfacebook.com\fR vs \fBfaceboook.com\fR \(-> 91% similar \(-> Ignored
688
749
  .IP \(bu 4
689
- \fBapple.com\fR vs \fBmicrosoft.com\fR 0% similar Kept
750
+ \fBapple.com\fR vs \fBmicrosoft.com\fR \(-> 0% similar \(-> Kept
690
751
  .RE
691
752
 
692
753
  .SH EXAMPLES
@@ -844,7 +905,7 @@ With default settings (\fBignore_similar_threshold: 80\fR):
844
905
 
845
906
  .SS Run with debug mode and similarity filtering:
846
907
  .EX
847
- node nwss.js --debug --dry-run --verbose
908
+ node nwss.js --debug --dry-run
848
909
  .EE
849
910
 
850
911
  .SS Run with adblock output format: