Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 1x | import http from 'http';
import {RequestResponseRecord} from 'swagger-stats';
/**
* Modifies the `RequestResponseRecord`, which is used to store metrics,
* to obfuscate credentials and other sensitive data of the user.
* @param req - The incoming request
* @param res - The outgoing response
* @param rrr - The record
*/
export function obfuscateMetrics(
req: http.IncomingMessage,
res: http.ServerResponse,
rrr: RequestResponseRecord,
): void {
if (req.url) {
if (req.url === '/auth/login' || req.url === '/auth/sign-up') {
if (rrr.http.request.headers) {
rrr.http.request.headers['xsfr-token'] = '******';
}
if (rrr.http.request.body && rrr.http.request.body.password) {
rrr.http.request.body.password = '******';
}
}
}
}
|