Skip to content

Commit 6e4fe65

Browse files
fix: install react-object as dependency (#37)
* feat(security): use new version of bufflog in publish to automatically redact sensitive data * clean up * fully redact res/req * redact req/res from pino-http
1 parent 01fb07f commit 6e4fe65

File tree

5 files changed

+32
-23
lines changed

5 files changed

+32
-23
lines changed

CHANGELOG.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# Changelog
22

3-
## [0.5.3] - 2024-09-11
4-
- Will redact sensitive information by default
3+
## [0.5.8] - 2024-10-23
4+
- Redact req, res, context.req and context.res from logs - req and res at root level are added by pinot-http middleware
5+
6+
## [0.5.3 - 0.5.7] - 2024-10-23
7+
- Do not use
58

69
## [0.5.2] - 2024-09-11
710
- Upgraded `dd-trace` to latest version

bufflog.ts

+17-9
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,13 @@ const pinoLogger = require('pino')({
1515
error: 400,
1616
fatal: 500
1717
},
18-
// necessary if we want to override the level "number"
19-
useOnlyCustomLevels: true,
18+
// necessary if we want to override the level "number"
19+
useOnlyCustomLevels: true,
2020

21+
redact: {
22+
paths: ['req', 'res', 'context.req', 'context.res'],
23+
censor: '[ REDACTED ]',
24+
},
2125
});
2226

2327
import redact from 'redact-object'
@@ -60,13 +64,17 @@ export function getLogger() {
6064
}
6165

6266
function sanitizeContext(context?: object): object | undefined {
63-
if (!context) {
64-
return
65-
}
66-
67-
return redact(context, KEYS_TO_REDACT, '[ REDACTED ]', {
68-
ignoreUnknown: true,
69-
})
67+
// For now, to keep the change limited, disabling this
68+
return context
69+
70+
// Will re-enable this after Campsite decision
71+
// if (!context) {
72+
// return
73+
// }
74+
//
75+
// return redact(context, KEYS_TO_REDACT, '[ REDACTED ]', {
76+
// ignoreUnknown: true,
77+
// })
7078
}
7179

7280
export function debug(message: string, context?: object) {

index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ app.get('/', (req, res) => {
3535
BuffLog.warning('hello warning');
3636
BuffLog.error('hello error');
3737
BuffLog.critical('hello critical');
38+
BuffLog.notice("Notice log via endpoint with req and res in context", {req ,res});
3839
res.send({'hello': 'world'})
3940
});
4041

package-lock.json

+5-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
{
22
"name": "@bufferapp/bufflog",
3-
"version": "0.5.3",
3+
"version": "0.5.8",
44
"description": "logger for all javascript and typescript Buffer services",
55
"main": "dist/bufflog.js",
66
"scripts": {
77
"start": "./node_modules/typescript/bin/tsc --pretty && node ./dist/index.js",
8-
"build": "tsc",
9-
"pre-publish": "tsc",
8+
"build": "./node_modules/typescript/bin/tsc",
109
"test": "echo \"Error: no test specified\" && exit 1"
1110
},
1211
"repository": {
@@ -25,12 +24,12 @@
2524
"@types/pino": "^5.15.5",
2625
"dd-trace": "5.22.0",
2726
"express": "4.20.0",
28-
"redact-object": "3.0.1",
2927
"typescript": "4.9.5"
3028
},
3129
"dependencies": {
3230
"pino": "^5.16.0",
33-
"pino-http": "~5.0.0"
31+
"pino-http": "~5.0.0",
32+
"redact-object": "3.0.1"
3433
},
3534
"types": "dist/bufflog.d.ts",
3635
"prepublish": "./node_modules/typescript/bin/tsc"

0 commit comments

Comments
 (0)