-
Notifications
You must be signed in to change notification settings - Fork 890
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redacting still modifies original data #1997
Comments
Can you create a complete example? Thanks |
Here's a full example. It's kinda weird. This breaks: import pino from "pino";
const data = {
customer: {
name: "John",
age: 23,
address: "221B Baker Street",
things: [
{
name: "Phone",
},
{
name: "Laptop",
},
"bloop",
],
},
};
const logger = pino({
redact: {
paths: [
"data.customer.things[*].name",
"data.customer.things[*]",
],
censor: (value, path) => {
if (path[path.length - 1] === "name") {
return value.substring(0, 2) + "_REDACTED";
}
return "[REDACTED]";
},
},
});
logger.info({ data }, "Data");
console.log(JSON.stringify(data));
// {"customer":{"name":"John","age":23,"address":"221B Baker Street","things":[{"name":"Ph_REDACTED"},{"name":"La_REDACTED"},"bloop"]}} If you swap the order of the redact definitions then all is good: import pino from "pino";
const data = {
customer: {
name: "John",
age: 23,
address: "221B Baker Street",
things: [
{
name: "Phone",
},
{
name: "Laptop",
},
"bloop",
],
},
};
const logger = pino({
redact: {
paths: [
"data.customer.things[*]",
"data.customer.things[*].name",
],
censor: (value, path) => {
if (path[path.length - 1] === "name") {
return value.substring(0, 2) + "_REDACTED";
}
return "[REDACTED]";
},
},
});
logger.info({ data }, "Data");
console.log(JSON.stringify(data));
// {"customer":{"name":"John","age":23,"address":"221B Baker Street","things":[{"name":"Phone"},{"name":"Laptop"},"bloop"]}} In both cases, the log output is: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Version:
"pino": "^8.7.0",
"pino-pretty": "^9.1.1"
Hi. I'm not sure if this was fixed or not but I'm still facing the issue where redacting modifies the original data. Here is an example:
Redaction: ['.customer.name', '.customer.age', '*.customer.address'].
Output:
Can someone please tell me if this was fixed and which version is it available from?
The text was updated successfully, but these errors were encountered: