@hasna/logs 0.3.27 → 0.3.29

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/cli/index.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  runJob,
9
9
  structuredLogToEntry,
10
10
  validateStructuredLogReferences
11
- } from "../index-bnr19y0h.js";
11
+ } from "../index-89jb7jg9.js";
12
12
  import {
13
13
  PACKAGE_VERSION,
14
14
  createPage,
@@ -30,7 +30,7 @@ import {
30
30
  searchTestReports,
31
31
  summarizeLogs,
32
32
  validateUniversalEventInput
33
- } from "../index-p4dbdzx4.js";
33
+ } from "../index-dbhpykkz.js";
34
34
  import {
35
35
  getStorageStatus,
36
36
  storagePull,
@@ -8,7 +8,7 @@ import {
8
8
  redactValue,
9
9
  saveSnapshot,
10
10
  touchPage
11
- } from "./index-p4dbdzx4.js";
11
+ } from "./index-dbhpykkz.js";
12
12
  import {
13
13
  getEventStoreDataDir
14
14
  } from "./index-t3x838zw.js";
@@ -508,9 +508,9 @@ function readPositiveInt(name, fallback) {
508
508
 
509
509
  // src/lib/redaction.ts
510
510
  var REDACTED = "[REDACTED]";
511
- var SENSITIVE_KEY = /(?:authorization|cookie|set-cookie|api[_-]?key|token|secret|password|passwd|pwd|private[_-]?key|access[_-]?token|refresh[_-]?token|session[_-]?secret|client[_-]?secret)/i;
512
- var SENSITIVE_FLAG = /^(?:authorization|auth|api[-_]?key|token|secret|password|passwd|pwd|private[-_]?key|access[-_]?token|refresh[-_]?token|session[-_]?secret|client[-_]?secret)$/i;
513
- var SENSITIVE_FLAG_NAME = /(?:authorization|api[-_]?key|token|secret|password|passwd|pwd|private[-_]?key|access[-_]?token|refresh[-_]?token|session[-_]?secret|client[-_]?secret)/i;
511
+ var SENSITIVE_KEY = /(?:authorization|cookie|set-cookie|credentials?\b|api[_-]?key|token|secret|password|passwd|pwd|private[_-]?key|access[_-]?token|refresh[_-]?token|session[_-]?secret|client[_-]?(?:secret|credentials?))/i;
512
+ var SENSITIVE_FLAG = /^(?:authorization|auth|credentials?|api[-_]?key|token|secret|password|passwd|pwd|private[-_]?key|access[-_]?token|refresh[-_]?token|session[-_]?secret|client[-_]?(?:secret|credentials?))$/i;
513
+ var SENSITIVE_FLAG_NAME = /(?:authorization|credentials?\b|api[-_]?key|token|secret|password|passwd|pwd|private[-_]?key|access[-_]?token|refresh[-_]?token|session[-_]?secret|client[-_]?(?:secret|credentials?))/i;
514
514
  var STRING_PATTERNS = [
515
515
  {
516
516
  label: "openlogs_canary",
@@ -522,6 +522,16 @@ var STRING_PATTERNS = [
522
522
  pattern: /\bBearer\s+[A-Za-z0-9._~+/=-]+/gi,
523
523
  replacement: `Bearer ${REDACTED}`
524
524
  },
525
+ {
526
+ label: "basic_auth",
527
+ pattern: /\b([A-Za-z0-9_-]*Authorization\b\s*(?::|=|\\?["']\s*:\s*\\?["']?)\s*\\?["']?Basic\s+)[A-Za-z0-9+/=._~-]+/gi,
528
+ replacement: (_match, prefix) => `${prefix}${REDACTED}`
529
+ },
530
+ {
531
+ label: "url_userinfo",
532
+ pattern: /\b([A-Za-z][A-Za-z0-9+.-]*:\/\/)([^@\s/?#]+@)(?=[^\s/?#]+)/g,
533
+ replacement: (_match, scheme) => `${scheme}${REDACTED}@`
534
+ },
525
535
  {
526
536
  label: "github_token",
527
537
  pattern: /\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9_]{20,}\b/g,
@@ -554,12 +564,12 @@ var STRING_PATTERNS = [
554
564
  },
555
565
  {
556
566
  label: "secret_assignment",
557
- pattern: /\b(api[_-]?key|token|secret|password|passwd|pwd|access[_-]?token|refresh[_-]?token|client[_-]?secret)\s*[:=]\s*("[^"]*"|'[^']*'|[^\s,;&}]+)/gi,
558
- replacement: (_match, key) => `${key}=${REDACTED}`
567
+ pattern: /(?<![?&])\b(credentials?|api[_-]?key|token|secret|password|passwd|pwd|access[_-]?token|refresh[_-]?token|client[_-]?(?:secret|credentials?))\s*[:=]\s*("[^"]*"|'[^']*'|[^\s,;&}]+)/gi,
568
+ replacement: (match, key, value) => isKnownNonSecretCredentialAssignment(key, value) ? match : `${key}=${REDACTED}`
559
569
  },
560
570
  {
561
571
  label: "secret_flag_argument",
562
- pattern: /(--[A-Za-z0-9._-]*(?:authorization|api[-_]?key|token|secret|password|passwd|pwd|private[-_]?key|access[-_]?token|refresh[-_]?token|session[-_]?secret|client[-_]?secret)[A-Za-z0-9._-]*\s+)(?:"[^"]*"|'[^']*'|[^\s,;&}]+)/gi,
572
+ pattern: /(--[A-Za-z0-9._-]*(?:authorization|credentials?(?!ed)|api[-_]?key|token|secret|password|passwd|pwd|private[-_]?key|access[-_]?token|refresh[-_]?token|session[-_]?secret|client[-_]?(?:secret|credentials?(?!ed)))[A-Za-z0-9._-]*\s+)(?:"[^"]*"|'[^']*'|[^\s,;&}]+)/gi,
563
573
  replacement: (_match, prefix) => `${prefix}${REDACTED}`
564
574
  },
565
575
  {
@@ -569,7 +579,7 @@ var STRING_PATTERNS = [
569
579
  },
570
580
  {
571
581
  label: "secret_query_param",
572
- pattern: /([?&](?:api[_-]?key|token|secret|password|passwd|pwd|access[_-]?token|refresh[_-]?token|auth|code)=)[^&#\s]+/gi,
582
+ pattern: /([?&](?:credentials?|api[_-]?key|token|secret|password|passwd|pwd|access[_-]?token|refresh[_-]?token|client[_-]?credentials?|auth|code)=)[^&#\s]+/gi,
573
583
  replacement: (_match, prefix) => `${prefix}${REDACTED}`
574
584
  }
575
585
  ];
@@ -612,11 +622,13 @@ function redactString(input, path = "$") {
612
622
  for (const { label, pattern, replacement } of STRING_PATTERNS) {
613
623
  let matched = false;
614
624
  output = output.replace(pattern, (...args) => {
615
- matched = true;
616
- replacements += 1;
617
- if (typeof replacement === "function")
618
- return replacement(args[0] ?? "", ...args.slice(1));
619
- return replacement;
625
+ const original = args[0] ?? "";
626
+ const next = typeof replacement === "function" ? replacement(original, ...args.slice(1)) : replacement;
627
+ if (next !== original) {
628
+ matched = true;
629
+ replacements += 1;
630
+ }
631
+ return next;
620
632
  });
621
633
  if (matched)
622
634
  fields.push(`${path}:${label}`);
@@ -659,7 +671,7 @@ function redactValue(input, path = "$", depth = 0) {
659
671
  const reports = [];
660
672
  for (const [key, value] of Object.entries(input)) {
661
673
  const childPath = `${path}.${key}`;
662
- if (SENSITIVE_KEY.test(key) && value !== null && value !== undefined) {
674
+ if (shouldRedactSensitiveKeyValue(key, value)) {
663
675
  values[key] = REDACTED;
664
676
  reports.push({ applied: true, fields: [childPath], replacements: 1 });
665
677
  continue;
@@ -695,6 +707,24 @@ function isSensitiveFlag(value) {
695
707
  return false;
696
708
  return SENSITIVE_FLAG.test(normalized) || SENSITIVE_FLAG_NAME.test(normalized) || SENSITIVE_KEY.test(normalized.replace(/-/g, "_"));
697
709
  }
710
+ function shouldRedactSensitiveKeyValue(key, value) {
711
+ if (value === null || value === undefined)
712
+ return false;
713
+ if (!SENSITIVE_KEY.test(key))
714
+ return false;
715
+ return !isKnownNonSecretCredentialMode(key, value);
716
+ }
717
+ function isKnownNonSecretCredentialMode(key, value) {
718
+ return key.toLowerCase() === "credentials" && typeof value === "string" && isKnownFetchCredentialMode(value);
719
+ }
720
+ function isKnownNonSecretCredentialAssignment(key, value) {
721
+ return key.toLowerCase() === "credentials" && isKnownFetchCredentialMode(value);
722
+ }
723
+ function isKnownFetchCredentialMode(value) {
724
+ const trimmed = value.trim();
725
+ const unquoted = trimmed.startsWith('"') && trimmed.endsWith('"') || trimmed.startsWith("'") && trimmed.endsWith("'") ? trimmed.slice(1, -1) : trimmed;
726
+ return /^(?:include|omit|same-origin)$/i.test(unquoted);
727
+ }
698
728
 
699
729
  // src/lib/ingest.ts
700
730
  var ERROR_LEVELS = new Set(["warn", "error", "fatal"]);
package/dist/index.js CHANGED
@@ -2942,6 +2942,14 @@ var SDK_STRING_PATTERNS = [
2942
2942
  pattern: /\bBearer\s+[A-Za-z0-9._~+/=-]+/gi,
2943
2943
  replacement: "Bearer [REDACTED]"
2944
2944
  },
2945
+ {
2946
+ pattern: /\b([A-Za-z0-9_-]*Authorization\b\s*(?::|=|\\?["']\s*:\s*\\?["']?)\s*\\?["']?Basic\s+)[A-Za-z0-9+/=._~-]+/gi,
2947
+ replacement: (_match, prefix) => `${prefix}[REDACTED]`
2948
+ },
2949
+ {
2950
+ pattern: /\b([A-Za-z][A-Za-z0-9+.-]*:\/\/)([^@\s/?#]+@)(?=[^\s/?#]+)/g,
2951
+ replacement: (_match, scheme) => `${scheme}[REDACTED]@`
2952
+ },
2945
2953
  {
2946
2954
  pattern: /\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9_]{20,}\b/g,
2947
2955
  replacement: "[REDACTED]"
package/dist/mcp/index.js CHANGED
@@ -93,7 +93,7 @@ import {
93
93
  searchTestReports,
94
94
  summarizeLogs,
95
95
  validateUniversalEventInput
96
- } from "../index-p4dbdzx4.js";
96
+ } from "../index-dbhpykkz.js";
97
97
  import {
98
98
  getStoragePg,
99
99
  getStorageStatus,
@@ -8,7 +8,7 @@ import {
8
8
  startScheduler,
9
9
  structuredLogPayloadToEntries,
10
10
  validateStructuredLogReferences
11
- } from "../index-bnr19y0h.js";
11
+ } from "../index-89jb7jg9.js";
12
12
  import {
13
13
  countLogs
14
14
  } from "../index-gcd14q2f.js";
@@ -50,7 +50,7 @@ import {
50
50
  updateAlertRule,
51
51
  updateProject,
52
52
  validateUniversalEventInput
53
- } from "../index-p4dbdzx4.js";
53
+ } from "../index-dbhpykkz.js";
54
54
  import {
55
55
  getDb,
56
56
  getIssue,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/logs",
3
- "version": "0.3.27",
3
+ "version": "0.3.29",
4
4
  "description": "Log aggregation + browser script + headless page scanner + performance monitoring for AI agents",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -19,7 +19,10 @@
19
19
  "logs-mcp": "./dist/mcp/index.js",
20
20
  "logs-serve": "./dist/server/index.js"
21
21
  },
22
- "files": ["dist", "dashboard/dist"],
22
+ "files": [
23
+ "dist",
24
+ "dashboard/dist"
25
+ ],
23
26
  "scripts": {
24
27
  "build": "rm -rf dist && bun build src/cli/index.ts src/mcp/index.ts src/server/index.ts src/index.ts src/storage.ts --outdir dist --target bun --splitting --external playwright --external playwright-core --external electron --external chromium-bidi --external lighthouse",
25
28
  "build:dashboard": "cd dashboard && bun run build",