Skip to content

Bug: Value masking modifies the original object provided to args #180

Description

@prescience-data

Describe the bug
During the value masking process, objects passed to the logger are run through this function:

obj[key] = this.settings.maskPlaceholder;

As you can see, it directly modifies the source object, meaning the original value is replaced with the placeholder.

After an object containing masked keys is passed to the logger the original secret is destroyed, which throws errors when using the secret elsewhere in code.

To Reproduce
Steps to reproduce the behavior:

  1. Add maskValuesOfKeys: ["foo"] rule to options.
{
  // ...
  maskValuesOfKeys: ["foo"]
}
  1. Instantiate a logger.
  2. Run
const test = { foo: "bar" } 
logger.info(test)

if(test.foo !== "bar") {
 throw Error(`Test value was modified by logger.`)
}
  1. See error

Expected behavior
A deep clone of any objects should be performed prior to masking.

Node.js Version
e.g. 18.x

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions