@hasna/logs 0.3.31 → 0.3.33

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-a0gz0zzc.js";
11
+ } from "../index-yt124maw.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-he072p17.js";
33
+ } from "../index-8tv6f2r9.js";
34
34
  import {
35
35
  getStorageStatus,
36
36
  storagePull,
@@ -511,6 +511,8 @@ var REDACTED = "[REDACTED]";
511
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
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
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
+ var SENSITIVE_PAIR_NAME_KEYS = new Set(["name", "key", "header"]);
515
+ var SENSITIVE_PAIR_VALUE_KEYS = new Set(["value", "values"]);
514
516
  var LOG_ENTRY_REDACTABLE_TOP_LEVEL_FIELDS = [
515
517
  "id",
516
518
  "source_event_id",
@@ -700,8 +702,15 @@ function redactValue(input, path = "$", depth = 0) {
700
702
  }
701
703
  const values = {};
702
704
  const reports = [];
703
- for (const [key, value] of Object.entries(input)) {
705
+ const record = input;
706
+ const pairName = sensitivePairName(record);
707
+ for (const [key, value] of Object.entries(record)) {
704
708
  const childPath = `${path}.${key}`;
709
+ if (shouldRedactSensitivePairValue(pairName, key, value)) {
710
+ values[key] = REDACTED;
711
+ reports.push({ applied: true, fields: [childPath], replacements: 1 });
712
+ continue;
713
+ }
705
714
  if (shouldRedactSensitiveKeyValue(key, value)) {
706
715
  values[key] = REDACTED;
707
716
  reports.push({ applied: true, fields: [childPath], replacements: 1 });
@@ -930,6 +939,30 @@ function shouldRedactSensitiveKeyValue(key, value) {
930
939
  return false;
931
940
  return !isKnownNonSecretCredentialMode(key, value);
932
941
  }
942
+ function shouldRedactSensitivePairValue(pairName, key, value) {
943
+ if (!pairName || value === null || value === undefined)
944
+ return false;
945
+ if (!SENSITIVE_PAIR_VALUE_KEYS.has(key.toLowerCase()))
946
+ return false;
947
+ return !isKnownNonSecretCredentialMode(pairName, value);
948
+ }
949
+ function sensitivePairName(record) {
950
+ for (const [key, value] of Object.entries(record)) {
951
+ if (!SENSITIVE_PAIR_NAME_KEYS.has(key.toLowerCase()))
952
+ continue;
953
+ if (typeof value !== "string")
954
+ continue;
955
+ if (isSensitiveNameValuePairName(value))
956
+ return value;
957
+ }
958
+ return null;
959
+ }
960
+ function isSensitiveNameValuePairName(value) {
961
+ const normalized = value.trim();
962
+ if (!normalized)
963
+ return false;
964
+ return isSensitiveFlag(normalized) || SENSITIVE_KEY.test(normalized.replace(/-/g, "_"));
965
+ }
933
966
  function isKnownNonSecretCredentialMode(key, value) {
934
967
  return key.toLowerCase() === "credentials" && typeof value === "string" && isKnownFetchCredentialMode(value);
935
968
  }
@@ -8,7 +8,7 @@ import {
8
8
  redactValue,
9
9
  saveSnapshot,
10
10
  touchPage
11
- } from "./index-he072p17.js";
11
+ } from "./index-8tv6f2r9.js";
12
12
  import {
13
13
  getEventStoreDataDir
14
14
  } from "./index-t3x838zw.js";
package/dist/mcp/index.js CHANGED
@@ -93,7 +93,7 @@ import {
93
93
  searchTestReports,
94
94
  summarizeLogs,
95
95
  validateUniversalEventInput
96
- } from "../index-he072p17.js";
96
+ } from "../index-8tv6f2r9.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-a0gz0zzc.js";
11
+ } from "../index-yt124maw.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-he072p17.js";
53
+ } from "../index-8tv6f2r9.js";
54
54
  import {
55
55
  getDb,
56
56
  getIssue,
@@ -2148,12 +2148,12 @@ function isLocalOpenModeEnabled() {
2148
2148
  }
2149
2149
  function isTrustedLocalRequest(c) {
2150
2150
  const url = new URL(c.req.url);
2151
- const host = forwardedHost(c.req.header("x-forwarded-host")) ?? hostWithoutPort(c.req.header("host")) ?? url.hostname;
2152
- return isLocalHost(host) && isLocalOrigin(c.req.header("origin"));
2153
- }
2154
- function forwardedHost(value) {
2155
- const first = value?.split(",")[0]?.trim();
2156
- return first ? hostWithoutPort(first) : null;
2151
+ const hosts = [
2152
+ hostWithoutPort(c.req.header("host")),
2153
+ url.hostname,
2154
+ ...forwardedHosts(c.req.header("x-forwarded-host"))
2155
+ ].filter((host) => Boolean(host));
2156
+ return hosts.length > 0 && hosts.every((host) => isLocalHost(host)) && isLocalOrigin(c.req.header("origin"));
2157
2157
  }
2158
2158
  function hostWithoutPort(value) {
2159
2159
  if (!value)
@@ -2162,6 +2162,9 @@ function hostWithoutPort(value) {
2162
2162
  return value.slice(1, value.indexOf("]"));
2163
2163
  return value.split(":")[0] || null;
2164
2164
  }
2165
+ function forwardedHosts(value) {
2166
+ return value?.split(",").map((host) => hostWithoutPort(host.trim())).filter((host) => Boolean(host)) ?? [];
2167
+ }
2165
2168
  function isLocalOrigin(origin) {
2166
2169
  if (!origin)
2167
2170
  return true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/logs",
3
- "version": "0.3.31",
3
+ "version": "0.3.33",
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",