@q32/signal-scanner 0.1.0 → 0.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.
Files changed (100) hide show
  1. package/COPYING +674 -0
  2. package/COPYING.LESSER +165 -0
  3. package/README.md +57 -9
  4. package/dist/cli.d.ts +26 -0
  5. package/dist/cli.d.ts.map +1 -0
  6. package/dist/cli.js +592 -0
  7. package/dist/cli.js.map +1 -0
  8. package/dist/dynamic.d.ts +43 -0
  9. package/dist/dynamic.d.ts.map +1 -0
  10. package/{src/dynamic.ts → dist/dynamic.js} +133 -156
  11. package/dist/dynamic.js.map +1 -0
  12. package/dist/feeds.d.ts +66 -0
  13. package/dist/feeds.d.ts.map +1 -0
  14. package/dist/feeds.js +259 -0
  15. package/dist/feeds.js.map +1 -0
  16. package/dist/index.d.ts +110 -0
  17. package/dist/index.d.ts.map +1 -0
  18. package/dist/index.js +1251 -0
  19. package/dist/index.js.map +1 -0
  20. package/dist/intel.d.ts +72 -0
  21. package/dist/intel.d.ts.map +1 -0
  22. package/dist/intel.js +480 -0
  23. package/dist/intel.js.map +1 -0
  24. package/dist/node-tls.d.ts +8 -0
  25. package/dist/node-tls.d.ts.map +1 -0
  26. package/dist/node-tls.js +48 -0
  27. package/dist/node-tls.js.map +1 -0
  28. package/dist/render-isolate/entry.d.ts +2 -0
  29. package/dist/render-isolate/entry.d.ts.map +1 -0
  30. package/dist/render-isolate/entry.js +3 -0
  31. package/dist/render-isolate/entry.js.map +1 -0
  32. package/dist/render-isolate/polyfills.d.ts +2 -0
  33. package/dist/render-isolate/polyfills.d.ts.map +1 -0
  34. package/dist/render-isolate/polyfills.js +41 -0
  35. package/dist/render-isolate/polyfills.js.map +1 -0
  36. package/dist/render-isolate/run.d.ts +3 -0
  37. package/dist/render-isolate/run.d.ts.map +1 -0
  38. package/dist/render-isolate/run.js +88 -0
  39. package/dist/render-isolate/run.js.map +1 -0
  40. package/dist/render.d.ts +26 -0
  41. package/dist/render.d.ts.map +1 -0
  42. package/dist/render.js +248 -0
  43. package/dist/render.js.map +1 -0
  44. package/dist/rules/packs/binary.d.ts +4 -0
  45. package/dist/rules/packs/binary.d.ts.map +1 -0
  46. package/dist/rules/packs/binary.js +101 -0
  47. package/dist/rules/packs/binary.js.map +1 -0
  48. package/dist/rules/packs/css.d.ts +3 -0
  49. package/dist/rules/packs/css.d.ts.map +1 -0
  50. package/dist/rules/packs/css.js +43 -0
  51. package/dist/rules/packs/css.js.map +1 -0
  52. package/dist/rules/packs/decoders.d.ts +3 -0
  53. package/dist/rules/packs/decoders.d.ts.map +1 -0
  54. package/dist/rules/packs/decoders.js +46 -0
  55. package/dist/rules/packs/decoders.js.map +1 -0
  56. package/dist/rules/packs/html.d.ts +4 -0
  57. package/dist/rules/packs/html.d.ts.map +1 -0
  58. package/dist/rules/packs/html.js +227 -0
  59. package/dist/rules/packs/html.js.map +1 -0
  60. package/dist/rules/packs/index.d.ts +24 -0
  61. package/dist/rules/packs/index.d.ts.map +1 -0
  62. package/dist/rules/packs/index.js +75 -0
  63. package/dist/rules/packs/index.js.map +1 -0
  64. package/dist/rules/packs/script-risk.d.ts +4 -0
  65. package/dist/rules/packs/script-risk.d.ts.map +1 -0
  66. package/dist/rules/packs/script-risk.js +231 -0
  67. package/dist/rules/packs/script-risk.js.map +1 -0
  68. package/dist/rules/packs/source-code.d.ts +3 -0
  69. package/dist/rules/packs/source-code.d.ts.map +1 -0
  70. package/dist/rules/packs/source-code.js +179 -0
  71. package/dist/rules/packs/source-code.js.map +1 -0
  72. package/dist/rules/packs/urls.d.ts +3 -0
  73. package/dist/rules/packs/urls.d.ts.map +1 -0
  74. package/dist/rules/packs/urls.js +123 -0
  75. package/dist/rules/packs/urls.js.map +1 -0
  76. package/dist/rules/types.d.ts +34 -0
  77. package/dist/rules/types.d.ts.map +1 -0
  78. package/dist/rules/types.js +2 -0
  79. package/dist/rules/types.js.map +1 -0
  80. package/package.json +33 -18
  81. package/scripts/check-coverage.ts +0 -33
  82. package/scripts/eval.ts +0 -311
  83. package/scripts/render-isolate/entry.ts +0 -2
  84. package/scripts/render-isolate/polyfills.ts +0 -33
  85. package/scripts/render-isolate/run.ts +0 -63
  86. package/scripts/scan.ts +0 -612
  87. package/src/feeds.ts +0 -334
  88. package/src/index.ts +0 -1366
  89. package/src/intel.ts +0 -561
  90. package/src/node-tls.ts +0 -55
  91. package/src/render.ts +0 -233
  92. package/src/rules/packs/binary.ts +0 -103
  93. package/src/rules/packs/css.ts +0 -44
  94. package/src/rules/packs/decoders.ts +0 -47
  95. package/src/rules/packs/html.ts +0 -255
  96. package/src/rules/packs/index.ts +0 -76
  97. package/src/rules/packs/script-risk.ts +0 -236
  98. package/src/rules/packs/source-code.ts +0 -180
  99. package/src/rules/packs/urls.ts +0 -138
  100. package/src/rules/types.ts +0 -56
package/COPYING.LESSER ADDED
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
package/README.md CHANGED
@@ -109,27 +109,44 @@ the rendered DOM.
109
109
  import { renderAndScan } from "@q32/signal-scanner/render";
110
110
  ```
111
111
 
112
+ This is the core of the scanner. Static crawling and URL extraction just feed
113
+ bytes in; the signal that matters comes from rendering a page in a real DOM,
114
+ executing its inline and external scripts under instrumentation, and folding the
115
+ rendered DOM plus recorded behaviors (exfil/redirect/eval, surfaced URLs) back
116
+ into the report. That catches credential forms injected by external scripts,
117
+ `document.write` payloads, and cloaking bouncers that inline-only analysis can't
118
+ see.
119
+
112
120
  `renderAndScan` runs in-process by default and is intended for trusted or
113
121
  synthetic inputs unless you provide an isolate. The included Node CLI runs this
114
122
  render step in `isolated-vm`, so untrusted page JavaScript cannot reach host
115
- `fetch`, `process`, or `fs`.
123
+ `fetch`, `process`, or `fs`. That sandbox guarantee is covered by an integration
124
+ test (`npm run test:isolate`).
116
125
 
117
126
  Cloudflare users can provide their own isolate or Worker-based invocation when
118
127
  embedding the library, but that is separate from the CLI.
119
128
 
120
129
  ## Node CLI
121
130
 
122
- The package includes a Node CLI for local URL checks, bounded crawling, and
123
- artifact/file scanning.
131
+ The package ships a `signal-scanner` binary for local URL checks, bounded
132
+ crawling, and artifact/file scanning.
124
133
 
125
134
  ```bash
126
- npm run scan -- crawl https://example.com
127
- npm run scan -- crawl --no-robots --parallel 10 --max-urls 50 --max-depth 2 https://example.com
128
- npm run scan -- files ./samples
135
+ npx @q32/signal-scanner crawl https://example.com
136
+ npx @q32/signal-scanner crawl --no-robots --parallel 10 --max-urls 50 --max-depth 2 https://example.com
137
+ npx @q32/signal-scanner files ./samples
129
138
  ```
130
139
 
131
- The CLI uses Node APIs for fetching and file IO. For dynamic rendering, it uses
132
- `isolated-vm`.
140
+ After a global install (`npm i -g @q32/signal-scanner`) the same commands are
141
+ available as `signal-scanner crawl …`. Inside this repo, `npm run scan -- …`
142
+ runs the CLI from source.
143
+
144
+ The CLI uses Node APIs for fetching and file IO. Dynamic rendering runs page
145
+ JavaScript inside `isolated-vm`; `isolated-vm` and `esbuild` are
146
+ **optional dependencies**. A default `npm install` pulls them in, but if they
147
+ are unavailable (e.g. installed with `--no-optional`, or a build toolchain for
148
+ the `isolated-vm` native addon is missing) the CLI logs a notice and continues
149
+ with static analysis only.
133
150
 
134
151
  Crawler behavior:
135
152
 
@@ -158,6 +175,9 @@ The CLI prints a normalized JSON summary to stdout.
158
175
 
159
176
  ## Rule Coverage
160
177
 
178
+ See [`docs/rule-packs.md`](docs/rule-packs.md) for the rule model (pattern vs.
179
+ analyzer-emitted rules), the score/tag system, and how to add a rule.
180
+
161
181
  - HTML signals for forms, password/payment fields, scripts, links, iframes,
162
182
  meta refresh redirects, hidden iframe patterns, login/payment language,
163
183
  page-model screenshot/login cues, crypto/DeFi landing language,
@@ -196,6 +216,34 @@ policy, and then applies explicit tag-based context multipliers such as
196
216
  credential plus suspicious hosting, wallet/payment plus exfiltration/redirect,
197
217
  decoded artifact plus script behavior, or binary plus URL evidence.
198
218
 
219
+ ## Development
220
+
221
+ Build and test:
222
+
223
+ ```bash
224
+ npm run build
225
+ npm test # unit suite (bun)
226
+ npm run coverage # unit suite + an 80% line-coverage gate
227
+ npm run test:isolate # the isolated-vm dynamic-render path, under Node
228
+ ```
229
+
230
+ See [`CONTRIBUTING.md`](CONTRIBUTING.md) for the full workflow,
231
+ [`docs/rule-packs.md`](docs/rule-packs.md) for the rule system, and
232
+ [`CHANGELOG.md`](CHANGELOG.md) for release history.
233
+
234
+ The eval harness (`npm run eval`) measures the detector against a labeled corpus
235
+ of live known-good and known-bad sites. It is dev-only and not shipped in the
236
+ package. Because many ISPs intercept known-bad hosts (which tanks recall), it
237
+ can route its crawl through an outbound proxy configured via a local `.env`.
238
+ Copy `.env.example` to `.env` and fill in proxy credentials if you need this;
239
+ leave it unset to crawl directly. `.env` is gitignored — never commit
240
+ credentials.
241
+
199
242
  ## License
200
243
 
201
- MIT
244
+ [GNU Lesser General Public License v3.0 or later](COPYING.LESSER) (LGPL-3.0-or-later).
245
+
246
+ Application code may link and use this library without itself becoming
247
+ LGPL/GPL; modifications to the library must be released under the LGPL. The
248
+ LGPL builds on the [GPL-3.0](COPYING); both license texts ship with the
249
+ package.
package/dist/cli.d.ts ADDED
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env node
2
+ import { type ScannerReport } from "./index.js";
3
+ export declare const DEFAULT_CRAWL_OPTIONS: CrawlOptions;
4
+ export interface TargetReport {
5
+ target: string;
6
+ kind: "url" | "file";
7
+ status?: number;
8
+ bytes: number;
9
+ report: ScannerReport;
10
+ error?: string;
11
+ /** Forced-navigation targets (location.href/assign/replace) — followed cross-origin. */
12
+ forcedNavUrls?: string[];
13
+ }
14
+ export interface CrawlOptions {
15
+ parallel: number;
16
+ maxUrls: number;
17
+ maxDepth: number;
18
+ maxBytes: number;
19
+ maxTotalBytes: number;
20
+ maxSitemapUrls: number;
21
+ timeoutMs: number;
22
+ robots: boolean;
23
+ userAgent: string;
24
+ }
25
+ export declare function crawlTargets(startUrls: string[], options: CrawlOptions): Promise<TargetReport[]>;
26
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAMA,OAAO,EAAiF,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AA+F/H,eAAO,MAAM,qBAAqB,EAAE,YAUnC,CAAC;AAEF,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,KAAK,GAAG,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,aAAa,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wFAAwF;IACxF,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AAwDD,wBAAsB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAmEtG"}