@profullstack/threatcrush 0.11.6 → 0.11.8

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/daemon.js CHANGED
@@ -2022,8 +2022,8 @@ var require_toml = __commonJS({
2022
2022
  });
2023
2023
 
2024
2024
  // src/daemon/index.ts
2025
- var import_node_fs17 = require("fs");
2026
- var import_node_path12 = require("path");
2025
+ var import_node_fs18 = require("fs");
2026
+ var import_node_path13 = require("path");
2027
2027
 
2028
2028
  // src/daemon/paths.ts
2029
2029
  var import_node_fs = require("fs");
@@ -3945,8 +3945,8 @@ function authHeaders() {
3945
3945
  }
3946
3946
 
3947
3947
  // src/commands/scan.ts
3948
- var import_node_fs14 = require("fs");
3949
- var import_node_path10 = require("path");
3948
+ var import_node_fs15 = require("fs");
3949
+ var import_node_path11 = require("path");
3950
3950
 
3951
3951
  // ../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/ansi-styles/index.js
3952
3952
  var ANSI_BACKGROUND_OFFSET = 10;
@@ -4443,6 +4443,22 @@ var chalk = createChalk();
4443
4443
  var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
4444
4444
  var source_default = chalk;
4445
4445
 
4446
+ // src/core/version.ts
4447
+ var import_node_fs12 = require("fs");
4448
+ var import_node_path7 = require("path");
4449
+ var FALLBACK_VERSION = "0.0.0";
4450
+ function readPackageVersion() {
4451
+ try {
4452
+ const pkg = JSON.parse(
4453
+ (0, import_node_fs12.readFileSync)((0, import_node_path7.join)(__dirname, "..", "package.json"), "utf-8")
4454
+ );
4455
+ return pkg.version || FALLBACK_VERSION;
4456
+ } catch {
4457
+ return FALLBACK_VERSION;
4458
+ }
4459
+ }
4460
+ var PKG_VERSION = readPackageVersion();
4461
+
4446
4462
  // src/core/logger.ts
4447
4463
  var SEVERITY_COLORS2 = {
4448
4464
  info: source_default.green,
@@ -7235,8 +7251,8 @@ function scanManifest(relativePath, filename, text) {
7235
7251
  }
7236
7252
 
7237
7253
  // ../../packages/scan/src/node/walk.ts
7238
- var import_node_fs12 = require("fs");
7239
- var import_node_path7 = require("path");
7254
+ var import_node_fs13 = require("fs");
7255
+ var import_node_path8 = require("path");
7240
7256
  function compileExcludes(patterns) {
7241
7257
  const matchers = patterns.map((p) => p.trim()).filter((p) => p.length > 0 && !p.startsWith("#")).map(compilePattern);
7242
7258
  if (matchers.length === 0) return () => false;
@@ -7307,7 +7323,7 @@ function matchPrefix(parts, segs) {
7307
7323
  }
7308
7324
  function readIgnoreFile(root) {
7309
7325
  try {
7310
- return (0, import_node_fs12.readFileSync)((0, import_node_path7.join)(root, ".threatcrushignore"), "utf-8").split("\n");
7326
+ return (0, import_node_fs13.readFileSync)((0, import_node_path8.join)(root, ".threatcrushignore"), "utf-8").split("\n");
7311
7327
  } catch {
7312
7328
  return [];
7313
7329
  }
@@ -7323,16 +7339,16 @@ function scanPath(targetPath, options = {}) {
7323
7339
  let excluded = 0;
7324
7340
  const rootIsDirectory = (() => {
7325
7341
  try {
7326
- return (0, import_node_fs12.statSync)(targetPath).isDirectory();
7342
+ return (0, import_node_fs13.statSync)(targetPath).isDirectory();
7327
7343
  } catch {
7328
7344
  return true;
7329
7345
  }
7330
7346
  })();
7331
- const walkRoot = rootIsDirectory ? targetPath : (0, import_node_path7.dirname)(targetPath);
7347
+ const walkRoot = rootIsDirectory ? targetPath : (0, import_node_path8.dirname)(targetPath);
7332
7348
  const isExcluded = compileExcludes([...options.exclude ?? [], ...readIgnoreFile(walkRoot)]);
7333
7349
  const scanFile = (fullPath, filename) => {
7334
7350
  const relativePath = toRelative(walkRoot, fullPath);
7335
- const extension = (0, import_node_path7.extname)(filename).toLowerCase();
7351
+ const extension = (0, import_node_path8.extname)(filename).toLowerCase();
7336
7352
  const isManifest = filename === "package.json" || filename === "requirements.txt";
7337
7353
  const scannable = SCAN_EXTENSIONS.has(extension) || filename.startsWith(".env");
7338
7354
  const mayDeclareInterpreter = !scannable && !isManifest && extension === "";
@@ -7344,26 +7360,26 @@ function scanPath(targetPath, options = {}) {
7344
7360
  let handle;
7345
7361
  let declared = null;
7346
7362
  try {
7347
- handle = (0, import_node_fs12.openSync)(fullPath, "r");
7363
+ handle = (0, import_node_fs13.openSync)(fullPath, "r");
7348
7364
  } catch {
7349
7365
  unreadable.push(relativePath);
7350
7366
  return;
7351
7367
  }
7352
7368
  try {
7353
- if ((0, import_node_fs12.fstatSync)(handle).size > maxFileBytes) return;
7369
+ if ((0, import_node_fs13.fstatSync)(handle).size > maxFileBytes) return;
7354
7370
  if (mayDeclareInterpreter) {
7355
7371
  const prefix = Buffer.alloc(128);
7356
- const read = (0, import_node_fs12.readSync)(handle, prefix, 0, prefix.length, 0);
7372
+ const read = (0, import_node_fs13.readSync)(handle, prefix, 0, prefix.length, 0);
7357
7373
  declared = languageOfShebang(prefix.subarray(0, read).toString("utf-8").split("\n", 1)[0] ?? "");
7358
7374
  if (!declared) return;
7359
7375
  }
7360
- text = (0, import_node_fs12.readFileSync)(handle, "utf-8");
7376
+ text = (0, import_node_fs13.readFileSync)(handle, "utf-8");
7361
7377
  } catch {
7362
7378
  unreadable.push(relativePath);
7363
7379
  return;
7364
7380
  } finally {
7365
7381
  try {
7366
- (0, import_node_fs12.closeSync)(handle);
7382
+ (0, import_node_fs13.closeSync)(handle);
7367
7383
  } catch {
7368
7384
  }
7369
7385
  }
@@ -7381,13 +7397,13 @@ function scanPath(targetPath, options = {}) {
7381
7397
  const walk = (currentPath) => {
7382
7398
  let entries;
7383
7399
  try {
7384
- entries = (0, import_node_fs12.readdirSync)(currentPath, { withFileTypes: true });
7400
+ entries = (0, import_node_fs13.readdirSync)(currentPath, { withFileTypes: true });
7385
7401
  } catch {
7386
7402
  unreadable.push(toRelative(walkRoot, currentPath));
7387
7403
  return;
7388
7404
  }
7389
7405
  for (const entry of entries) {
7390
- const fullPath = (0, import_node_path7.join)(currentPath, entry.name);
7406
+ const fullPath = (0, import_node_path8.join)(currentPath, entry.name);
7391
7407
  const relativePath = toRelative(walkRoot, fullPath);
7392
7408
  if (entry.isDirectory()) {
7393
7409
  if (SKIP_DIRS.has(entry.name)) continue;
@@ -7411,7 +7427,7 @@ function scanPath(targetPath, options = {}) {
7411
7427
  } else if (isExcluded(toRelative(walkRoot, targetPath))) {
7412
7428
  excluded += 1;
7413
7429
  } else {
7414
- scanFile(targetPath, (0, import_node_path7.basename)(targetPath));
7430
+ scanFile(targetPath, (0, import_node_path8.basename)(targetPath));
7415
7431
  }
7416
7432
  if (options.missingControls) findings.push(...controls.findings());
7417
7433
  const filtered = allowed ? findings.filter((f) => allowed.has(f.category)) : findings;
@@ -7443,22 +7459,22 @@ function recordSensitiveFile(filename, relativePath, sink, fileFindings) {
7443
7459
  }
7444
7460
  }
7445
7461
  function toRelative(base, target) {
7446
- const rel = (0, import_node_path7.relative)(base, target);
7447
- return (rel === "" ? target : rel).split(import_node_path7.sep).join("/");
7462
+ const rel = (0, import_node_path8.relative)(base, target);
7463
+ return (rel === "" ? target : rel).split(import_node_path8.sep).join("/");
7448
7464
  }
7449
7465
 
7450
7466
  // ../../packages/scan/src/node/dependencies.ts
7451
- var import_node_fs13 = require("fs");
7452
- var import_node_path8 = require("path");
7467
+ var import_node_fs14 = require("fs");
7468
+ var import_node_path9 = require("path");
7453
7469
  var MAX_DEPS_PER_LOCKFILE = 50;
7454
7470
  async function scanDependencies(targetPath) {
7455
7471
  const findings = [];
7456
7472
  for (const { file, ecosystem, parse } of LOCKFILES) {
7457
- const lockPath = (0, import_node_path8.join)(targetPath, file);
7458
- if (!(0, import_node_fs13.existsSync)(lockPath)) continue;
7473
+ const lockPath = (0, import_node_path9.join)(targetPath, file);
7474
+ if (!(0, import_node_fs14.existsSync)(lockPath)) continue;
7459
7475
  let deps;
7460
7476
  try {
7461
- deps = dedupe(parse((0, import_node_fs13.readFileSync)(lockPath, "utf-8")));
7477
+ deps = dedupe(parse((0, import_node_fs14.readFileSync)(lockPath, "utf-8")));
7462
7478
  } catch {
7463
7479
  continue;
7464
7480
  }
@@ -7673,22 +7689,22 @@ async function queryOsv(name, version, ecosystem) {
7673
7689
 
7674
7690
  // ../../packages/scan/src/node/sarif.ts
7675
7691
  var import_node_crypto3 = require("crypto");
7676
- var import_node_path9 = require("path");
7692
+ var import_node_path10 = require("path");
7677
7693
 
7678
7694
  // src/commands/scan.ts
7679
7695
  function readVersion() {
7680
7696
  for (const candidate of [
7681
- (0, import_node_path10.join)(__dirname, "..", "package.json"),
7682
- (0, import_node_path10.join)(__dirname, "..", "..", "package.json")
7697
+ (0, import_node_path11.join)(__dirname, "..", "package.json"),
7698
+ (0, import_node_path11.join)(__dirname, "..", "..", "package.json")
7683
7699
  ]) {
7684
7700
  try {
7685
- return JSON.parse((0, import_node_fs14.readFileSync)(candidate, "utf-8")).version ?? "0.0.0";
7701
+ return JSON.parse((0, import_node_fs15.readFileSync)(candidate, "utf-8")).version ?? "0.0.0";
7686
7702
  } catch {
7687
7703
  }
7688
7704
  }
7689
7705
  return "0.0.0";
7690
7706
  }
7691
- var PKG_VERSION = readVersion();
7707
+ var PKG_VERSION2 = readVersion();
7692
7708
  function toRunResult(targetPath, findings, filesScanned) {
7693
7709
  const structured = findings.map((finding) => ({
7694
7710
  type: finding.title,
@@ -8143,8 +8159,8 @@ var RuleEngine = class {
8143
8159
  };
8144
8160
 
8145
8161
  // src/daemon/rules/loader.ts
8146
- var import_node_fs15 = require("fs");
8147
- var import_node_path11 = require("path");
8162
+ var import_node_fs16 = require("fs");
8163
+ var import_node_path12 = require("path");
8148
8164
 
8149
8165
  // src/daemon/rules/default-rules.ts
8150
8166
  var DEFAULT_RULES = [
@@ -8428,11 +8444,11 @@ var RULES_DIR = "/etc/threatcrush/rules.d";
8428
8444
  function loadAllRules(customDir) {
8429
8445
  const rules = [...DEFAULT_RULES];
8430
8446
  const dir = customDir || RULES_DIR;
8431
- if ((0, import_node_fs15.existsSync)(dir)) {
8432
- const files = (0, import_node_fs15.readdirSync)(dir).filter((f) => f.endsWith(".json"));
8447
+ if ((0, import_node_fs16.existsSync)(dir)) {
8448
+ const files = (0, import_node_fs16.readdirSync)(dir).filter((f) => f.endsWith(".json"));
8433
8449
  for (const file of files) {
8434
8450
  try {
8435
- const raw = (0, import_node_fs15.readFileSync)((0, import_node_path11.join)(dir, file), "utf-8");
8451
+ const raw = (0, import_node_fs16.readFileSync)((0, import_node_path12.join)(dir, file), "utf-8");
8436
8452
  const parsed = JSON.parse(raw);
8437
8453
  const customRules = Array.isArray(parsed) ? parsed : [parsed];
8438
8454
  for (const rule of customRules) {
@@ -8595,7 +8611,7 @@ function detectFirewallAdapter() {
8595
8611
  }
8596
8612
 
8597
8613
  // src/daemon/firewall/remediation.ts
8598
- var import_node_fs16 = require("fs");
8614
+ var import_node_fs17 = require("fs");
8599
8615
  var DEFAULT_CONFIG2 = {
8600
8616
  enabled: true,
8601
8617
  dry_run: true,
@@ -8750,7 +8766,7 @@ var RemediationManager = class {
8750
8766
  }
8751
8767
  logLine(line) {
8752
8768
  try {
8753
- (0, import_node_fs16.appendFileSync)(PATHS.logFile, `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
8769
+ (0, import_node_fs17.appendFileSync)(PATHS.logFile, `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
8754
8770
  `);
8755
8771
  } catch {
8756
8772
  }
@@ -8806,7 +8822,7 @@ async function flushTelemetry(timeoutMs = 2e3) {
8806
8822
  // src/daemon/index.ts
8807
8823
  function readVersion2() {
8808
8824
  try {
8809
- const pkg = JSON.parse((0, import_node_fs17.readFileSync)((0, import_node_path12.join)(__dirname, "..", "package.json"), "utf-8"));
8825
+ const pkg = JSON.parse((0, import_node_fs18.readFileSync)((0, import_node_path13.join)(__dirname, "..", "package.json"), "utf-8"));
8810
8826
  return pkg.version || "0.0.0";
8811
8827
  } catch {
8812
8828
  return "0.0.0";
@@ -8814,7 +8830,7 @@ function readVersion2() {
8814
8830
  }
8815
8831
  function logLine(line) {
8816
8832
  try {
8817
- (0, import_node_fs17.appendFileSync)(PATHS.logFile, `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
8833
+ (0, import_node_fs18.appendFileSync)(PATHS.logFile, `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
8818
8834
  `);
8819
8835
  } catch {
8820
8836
  }
@@ -8842,7 +8858,7 @@ async function runDaemon() {
8842
8858
  } catch (err) {
8843
8859
  logLine(`[daemon] state db unavailable: ${err.message}`);
8844
8860
  }
8845
- const config = loadConfig((0, import_node_fs17.existsSync)(PATHS.configFile) ? PATHS.configFile : void 0);
8861
+ const config = loadConfig((0, import_node_fs18.existsSync)(PATHS.configFile) ? PATHS.configFile : void 0);
8846
8862
  bus.on("event", (event) => {
8847
8863
  logLine(`[event] ${event.severity} ${event.module} ${event.message}`);
8848
8864
  });