mirror of
https://github.com/docmost/docmost.git
synced 2026-05-07 06:23:06 +08:00
fix: logs
This commit is contained in:
@@ -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
Submodule apps/server/src/ee updated: 38158a5ab6...dc7ae0e3b0
Reference in New Issue
Block a user