@profullstack/threatcrush 0.13.51 → 0.13.53
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/README.md +9 -0
- package/dist/daemon.js +36 -0
- package/dist/daemon.js.map +1 -1
- package/dist/index.js +457 -259
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -165,6 +165,15 @@ threatcrush init --offline # Same, without signing in (scripts, CI, con
|
|
|
165
165
|
|
|
166
166
|
Config lives at `/etc/threatcrush/threatcrushd.conf` with module configs in `/etc/threatcrush/threatcrushd.conf.d/`.
|
|
167
167
|
|
|
168
|
+
### Usage counts
|
|
169
|
+
|
|
170
|
+
Each `threatcrush ai-scan` / `ai-scan-run` sends one anonymous count to the API
|
|
171
|
+
(`THREATCRUSH_API_URL`, default threatcrush.com): command, CLI version, OS, Node
|
|
172
|
+
version, CI or not, a random install ID (`~/.threatcrush/usage-ping.json`), and
|
|
173
|
+
probe/finding counts and run time. Never the target, prompts, responses or
|
|
174
|
+
finding text. Turn it off with `THREATCRUSH_TELEMETRY=0` or `DO_NOT_TRACK=1`.
|
|
175
|
+
Requests to our API also carry the user agent `threatcrush/<version>`.
|
|
176
|
+
|
|
168
177
|
## Cloud dashboard
|
|
169
178
|
|
|
170
179
|
The daemon reports to your ThreatCrush dashboard once the machine is logged in and linked to a server there:
|
package/dist/daemon.js
CHANGED
|
@@ -20128,7 +20128,43 @@ async function runDaemon() {
|
|
|
20128
20128
|
}, 1 << 30);
|
|
20129
20129
|
}
|
|
20130
20130
|
|
|
20131
|
+
// src/core/user-agent.ts
|
|
20132
|
+
var USER_AGENT = `threatcrush/${PKG_VERSION} (node ${process.version}; ${process.platform})`;
|
|
20133
|
+
function isOurHost(url, api = apiUrl()) {
|
|
20134
|
+
let host;
|
|
20135
|
+
try {
|
|
20136
|
+
host = new URL(url).hostname.toLowerCase();
|
|
20137
|
+
} catch {
|
|
20138
|
+
return false;
|
|
20139
|
+
}
|
|
20140
|
+
let apiHost = "";
|
|
20141
|
+
try {
|
|
20142
|
+
apiHost = new URL(api).hostname.toLowerCase();
|
|
20143
|
+
} catch {
|
|
20144
|
+
}
|
|
20145
|
+
return host === apiHost || host === "threatcrush.com" || host.endsWith(".threatcrush.com");
|
|
20146
|
+
}
|
|
20147
|
+
function urlOf(input) {
|
|
20148
|
+
if (typeof input === "string") return input;
|
|
20149
|
+
if (input instanceof URL) return input.href;
|
|
20150
|
+
return input.url;
|
|
20151
|
+
}
|
|
20152
|
+
function installUserAgent(target = globalThis) {
|
|
20153
|
+
const base = target.fetch;
|
|
20154
|
+
if (!base || base.__threatcrushUA) return;
|
|
20155
|
+
const wrapped = ((input, init) => {
|
|
20156
|
+
if (!isOurHost(urlOf(input))) return base(input, init);
|
|
20157
|
+
const headers = new Headers(init?.headers ?? (input instanceof Request ? input.headers : void 0));
|
|
20158
|
+
if (headers.has("user-agent")) return base(input, init);
|
|
20159
|
+
headers.set("user-agent", USER_AGENT);
|
|
20160
|
+
return base(input, { ...init, headers });
|
|
20161
|
+
});
|
|
20162
|
+
wrapped.__threatcrushUA = true;
|
|
20163
|
+
target.fetch = wrapped;
|
|
20164
|
+
}
|
|
20165
|
+
|
|
20131
20166
|
// src/daemon-entry.ts
|
|
20167
|
+
installUserAgent();
|
|
20132
20168
|
runDaemon().catch((err) => {
|
|
20133
20169
|
console.error("threatcrushd failed to start:", err);
|
|
20134
20170
|
process.exit(1);
|