@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-
|
|
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-
|
|
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
|
-
|
|
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
|
}
|
package/dist/mcp/index.js
CHANGED
package/dist/server/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
startScheduler,
|
|
9
9
|
structuredLogPayloadToEntries,
|
|
10
10
|
validateStructuredLogReferences
|
|
11
|
-
} from "../index-
|
|
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-
|
|
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
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
return
|
|
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;
|