Code Monkey home page Code Monkey logo

Comments (7)

hckhanh avatar hckhanh commented on June 16, 2024 1

Hi @kirillgroshkov, I no longer use this package. I think it's ok to close this issue. Thank you for asking

from scrubber-lib.

fernandobrito avatar fernandobrito commented on June 16, 2024

@hckhanh can you post a snippet of your code?

When I try

import { ScrubberConfig, Scrubber } from '@naturalcycles/scrubber-lib'

const scrubberConfig : ScrubberConfig = {
    fields: {
        password: {
            scrubber: "staticScrubber",
            params: {
                replacement: "***"
            }
        },
        secret: {
            scrubber: "staticScrubber",
            params: {
                replacement: "***"
            }
        }
    },
    throwOnError: true, // default: false,
    preserveFalsy: false // default: true
};

const object = {
    "created_at": "2020-06-09T07:51:58.000Z",
    "password": "abcd",
    "secret": "secret",
    "project_id": 1,
    "updated_at": "2020-06-09T07:51:58.000Z"
}

const scrubber = new Scrubber(scrubberConfig)
const scrubbedObject = scrubber.scrub(object)

console.log(scrubbedObject)

I get the expected output:

{
  created_at: '2020-06-09T07:51:58.000Z',
  password: '***',
  secret: '***',
  project_id: 1,
  updated_at: '2020-06-09T07:51:58.000Z'
}

Maybe the created_at and updated_at fields on your object are not really strings, but Date objects? This library will work the best if you pass strings to it.

from scrubber-lib.

hckhanh avatar hckhanh commented on June 16, 2024

Perhaps, I am using Sequelize ORM for my database. I will check the type of created_at.

from scrubber-lib.

fernandobrito avatar fernandobrito commented on June 16, 2024

Another suggestion would be to improve scrubber-lib to check if the field that it is processing is an object that has a toString() function and use that if it is available. If you are interested in making such contribution, let me know! :)

from scrubber-lib.

hckhanh avatar hckhanh commented on June 16, 2024

I already checked the date fields, it's literally object (Date)

{
  created_at: new Date('2020-06-09T07:51:58.000Z'),
  password: '***',
  secret: '***',
  project_id: 1,
  updated_at: new Date('2020-06-09T07:51:58.000Z')
}

I guess that it will return {}

from scrubber-lib.

hckhanh avatar hckhanh commented on June 16, 2024

This is my code:

const { Scrubber } = require("@naturalcycles/scrubber-lib");

const scrubberConfig = {
  fields: {
    password: {
      scrubber: "staticScrubber",
      params: {
        replacement: "[SCRUBBED]"
      }
    },
    passphrase: {
      scrubber: "staticScrubber",
      params: {
        replacement: "[SCRUBBED]"
      }
    },
    json_credentials: {
      scrubber: "staticScrubber",
      params: {
        replacement: "[SCRUBBED]"
      }
    }
  },
  throwOnError: true, // default: false,
  preserveFalsy: false // default: true
};

const scrubber = new Scrubber(scrubberConfig);

module.exports.scrubberData = function (data) {
  return scrubber.scrub(data);
};

from scrubber-lib.

kirillgroshkov avatar kirillgroshkov commented on June 16, 2024

Just checking-in, is it still an issue?

from scrubber-lib.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.