mirror of
https://github.com/morluto/rea.git
synced 2026-10-27 01:45:32 +00:00
fix(ci): redact authentication in case-insensitive URL schemes
This commit is contained in:
1 parent
1cd471487b
commit
95eb175457
2 files changed
+8
-1
No files matched your search
@@ -1,6 +1,6 @@
|
||||
/** Redact only HTTP URL authentication; keep paths, names, queries and other text. */
|
||||
export function redactTransportAuthentication(text) {
|
||||
return text.replace(/https?:\/\/[^\s"<>\\]+/gu, (value) => {
|
||||
return text.replace(/https?:\/\/[^\s"<>\\]+/giu, (value) => {
|
||||
try {
|
||||
const parsed = new URL(value);
|
||||
if (!parsed.username && !parsed.password) return value;
|
||||
|
||||
@@ -115,6 +115,13 @@ it("accepts only supported registry identities and redacts only transport authen
|
||||
expect(redactTransportAuthentication(text)).toBe(
|
||||
"name=secret token=caller-value /tmp/secret https://EXAMPLE.com/a?q=token#keep",
|
||||
);
|
||||
for (const scheme of ["HTTPS", "hTtPs", "HTTP"]) {
|
||||
expect(
|
||||
redactTransportAuthentication(
|
||||
`${scheme}://user:fixture-secret@EXAMPLE.com/a?q=token#keep`,
|
||||
),
|
||||
).toBe(`${scheme}://EXAMPLE.com/a?q=token#keep`);
|
||||
}
|
||||
expect(() =>
|
||||
lockedPackages({
|
||||
lockfileVersion: 3,
|
||||
|
||||
Reference in new issue
Block a user