fix: logs
This commit is contained in:
parent
895c1817ae
commit
e1bbceb9a6
3 changed files with 15 additions and 2 deletions
|
|
@ -142,6 +142,18 @@ export function isUserDisabled(user: {
|
||||||
return !!(user.deactivatedAt || user.deletedAt);
|
return !!(user.deactivatedAt || user.deletedAt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const SENSITIVE_URL_PREFIXES = ['/api/sso/'];
|
||||||
|
|
||||||
|
export function redactSensitiveUrl(url: string): string {
|
||||||
|
if (url && SENSITIVE_URL_PREFIXES.some((prefix) => url.includes(prefix))) {
|
||||||
|
const qsIndex = url.indexOf('?');
|
||||||
|
if (qsIndex !== -1) {
|
||||||
|
return url.substring(0, qsIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
export function createByteCountingStream(source: Readable) {
|
export function createByteCountingStream(source: Readable) {
|
||||||
let bytesRead = 0;
|
let bytesRead = 0;
|
||||||
const stream = new Transform({
|
const stream = new Transform({
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import { Params } from 'nestjs-pino';
|
import { Params } from 'nestjs-pino';
|
||||||
import { stdTimeFunctions } from 'pino';
|
import { stdTimeFunctions } from 'pino';
|
||||||
|
import { redactSensitiveUrl } from '../helpers/utils';
|
||||||
|
|
||||||
const CONTEXTS_TO_IGNORE = [
|
const CONTEXTS_TO_IGNORE = [
|
||||||
'InstanceLoader',
|
'InstanceLoader',
|
||||||
|
|
@ -52,7 +53,7 @@ export function createPinoConfig(): Params {
|
||||||
serializers: {
|
serializers: {
|
||||||
req: (req) => ({
|
req: (req) => ({
|
||||||
method: req.method,
|
method: req.method,
|
||||||
url: req.url,
|
url: redactSensitiveUrl(req.url),
|
||||||
ip: req.ip || req.remoteAddress,
|
ip: req.ip || req.remoteAddress,
|
||||||
userAgent: req.headers?.['user-agent'],
|
userAgent: req.headers?.['user-agent'],
|
||||||
}),
|
}),
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 38158a5ab6a4c12c90a3124604b88f05d76efd7d
|
Subproject commit dc7ae0e3b066df842248b2295ccfad190a0c5a93
|
||||||
Loading…
Add table
Reference in a new issue