@smthrs/journal 1.0.0-rc.6 → 1.0.0-rc.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/README.md +3 -1
- package/dist/cjs/Redaction.d.ts.map +1 -1
- package/dist/cjs/Redaction.js +26 -2
- package/dist/cjs/Redaction.js.map +2 -2
- package/dist/esm/Redaction.d.ts.map +1 -1
- package/dist/esm/Redaction.js +32 -5
- package/dist/esm/Redaction.js.map +1 -1
- package/docs/README.md +3 -1
- package/docs/concepts/redaction.md +9 -5
- package/docs/installation.md +5 -1
- package/docs/quickstart.md +6 -3
- package/package.json +4 -4
- package/src/Redaction.ts +32 -5
package/dist/esm/Redaction.js
CHANGED
|
@@ -661,7 +661,14 @@ export const defaultRules = [
|
|
|
661
661
|
// of `aaaaaaaa-` cost 11 seconds, on the path every journal write and every
|
|
662
662
|
// log line takes. A scheme longer than 30 characters is not one this net is
|
|
663
663
|
// for, and the cap makes each start position cost a constant.
|
|
664
|
-
|
|
664
|
+
//
|
|
665
|
+
// The username may be empty (`redis://:password@host`), and the password
|
|
666
|
+
// runs to the LAST `@` before the authority ends, as a URL parser reads
|
|
667
|
+
// it: RFC 3986 allows `:` in a password and a raw `@` is common in
|
|
668
|
+
// connection strings. Stopping at the first `:` or `@` left the tail of
|
|
669
|
+
// such a password in the row. Quotes and backslashes end the scan so a
|
|
670
|
+
// URL inside JSON text never swallows the next string.
|
|
671
|
+
pattern: /\b([a-z][a-z0-9+.-]{0,30}:\/\/[^\s:@/]*):(?!\[REDACTED\]@)[^\s/?#"'`\\]*@/gi,
|
|
665
672
|
replace: "$1:[REDACTED]@"
|
|
666
673
|
},
|
|
667
674
|
{
|
|
@@ -717,6 +724,23 @@ export const defaultRules = [
|
|
|
717
724
|
pattern: /\bAIza[0-9A-Za-z_-]{35,}(?![0-9A-Za-z_-])/g,
|
|
718
725
|
replace: "[REDACTED]"
|
|
719
726
|
},
|
|
727
|
+
{
|
|
728
|
+
id: "gitlab-token",
|
|
729
|
+
pattern: /\bglpat-[A-Za-z0-9_-]{20,}(?![A-Za-z0-9_-])/g,
|
|
730
|
+
replace: "[REDACTED]"
|
|
731
|
+
},
|
|
732
|
+
{
|
|
733
|
+
id: "npm-token",
|
|
734
|
+
pattern: /\bnpm_[A-Za-z0-9]{36}(?![A-Za-z0-9])/g,
|
|
735
|
+
replace: "[REDACTED]"
|
|
736
|
+
},
|
|
737
|
+
{
|
|
738
|
+
// The webhook path is the whole credential: anyone holding it can post
|
|
739
|
+
// to the channel. The host stays so a failed delivery is still readable.
|
|
740
|
+
id: "slack-webhook",
|
|
741
|
+
pattern: /(\bhooks\.slack\.com\/services\/)T[A-Z0-9]+\/B[A-Z0-9]+\/[A-Za-z0-9]+/g,
|
|
742
|
+
replace: "$1[REDACTED]"
|
|
743
|
+
},
|
|
720
744
|
{
|
|
721
745
|
id: "assignment",
|
|
722
746
|
// A credential name, `:`, `=` or `=>`, and its whole value: quoted at any
|
|
@@ -925,12 +949,15 @@ const tokenCounterKeys = new Set([
|
|
|
925
949
|
"totaltoken"
|
|
926
950
|
]);
|
|
927
951
|
/**
|
|
928
|
-
*
|
|
929
|
-
*
|
|
930
|
-
*
|
|
952
|
+
* Any name ending in a plural `tokens` holds a count too, the rule the textual
|
|
953
|
+
* pass applies in {@link namesCredential}: `Envelope.budget.tokens` is the
|
|
954
|
+
* run's token ceiling, and `usage.cacheWriteTokens`, `maxTokens`, and
|
|
955
|
+
* `contextWindowTokens` are accounting; redacting them erased every journaled
|
|
956
|
+
* budget and cache-write count (#3846). A bare singular `token` stays bearer
|
|
957
|
+
* material even when it is numeric.
|
|
931
958
|
*/
|
|
932
959
|
const isTokenCount = (key, value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0 &&
|
|
933
|
-
(tokenCounterKeys.has(canonicalKey(key)) ||
|
|
960
|
+
(tokenCounterKeys.has(canonicalKey(key)) || /tokens$/i.test(key));
|
|
934
961
|
/**
|
|
935
962
|
* Whether a field name names a credential.
|
|
936
963
|
*
|