Skip to content

Commit 2b89196

Browse files
authored
Revert "[RDS-1041] Prevent leaking secrets in logs (#5399)" (#5585)
due to SO https://redstone-oracles.slack.com/archives/C07N1UR9256/p1744793988319079
1 parent 9c14ef2 commit 2b89196

File tree

2 files changed

+1
-218
lines changed

2 files changed

+1
-218
lines changed

packages/utils/src/logger/index.ts

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,12 @@ export const loggerFactory = (moduleName: string): RedstoneLogger => {
2323
? new JSONReporter()
2424
: new FancyReporter();
2525

26-
const logger = consola
26+
return consola
2727
.create({
2828
reporters: [mainReporter],
2929
level: getLogLevel(),
3030
})
3131
.withTag(moduleName);
32-
33-
return createSanitizedLogger(logger);
3432
} else {
3533
return console;
3634
}
@@ -42,50 +40,3 @@ export const getLogLevel = () => {
4240
z.nativeEnum(LogLevel).default(DEFAULT_LOG_LEVEL)
4341
);
4442
};
45-
46-
export function createSanitizedLogger(logger: RedstoneLogger): RedstoneLogger {
47-
const methods = ["log", "info", "warn", "error", "debug"] as const;
48-
const sanitizedLogger = { ...logger } as RedstoneLogger;
49-
methods.forEach((method) => {
50-
if (typeof logger[method] === "function") {
51-
const original = logger[method].bind(logger);
52-
sanitizedLogger[method] = (...args: unknown[]) => {
53-
const sanitizedArgs = args.map((arg) => sanitizeValue(arg));
54-
original.apply(logger, sanitizedArgs);
55-
};
56-
}
57-
});
58-
return sanitizedLogger;
59-
}
60-
61-
export function sanitizeValue(value: unknown): unknown {
62-
if (typeof value === "string") {
63-
return sanitizeLogMessage(value);
64-
} else if (Array.isArray(value)) {
65-
return value.map((item) => sanitizeValue(item));
66-
} else if (value !== null && typeof value === "object") {
67-
const result: Record<string, unknown> = {};
68-
for (const [key, val] of Object.entries(value)) {
69-
result[key] = sanitizeValue(val);
70-
}
71-
return result;
72-
}
73-
return value;
74-
}
75-
76-
export function sanitizeLogMessage(message: string): string {
77-
// Regex to find HTTP, HTTPS, and WSS URLs in a log message
78-
const urlRegex = /(https?|wss):\/\/[^\s]+/g;
79-
80-
return message.replace(urlRegex, (match) => {
81-
try {
82-
const parsedUrl = new URL(match);
83-
const protocol = parsedUrl.protocol;
84-
const host = parsedUrl.hostname;
85-
const lastFour = match.slice(-4);
86-
return `${protocol}//${host}/...${lastFour}`;
87-
} catch (err) {
88-
return match;
89-
}
90-
});
91-
}

packages/utils/test/logger/index.test.ts

Lines changed: 0 additions & 168 deletions
This file was deleted.

0 commit comments

Comments
 (0)