Skip to content

Commit

Permalink
fix: removeSensibleValues now has its own npm package
Browse files Browse the repository at this point in the history
BREAKING CHANGE: removeSensibleValues() resides now in its own module remove-sensible-values
  • Loading branch information
arlac77 committed May 10, 2019
1 parent 0f0318c commit 4de5e97
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 52 deletions.
4 changes: 2 additions & 2 deletions src/expander.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import os from "os";
import { createContext } from "expression-expander";
import { ConfigParser } from "./grammar.mjs";
import { functions } from "./functions.mjs";
import { createValue, merge, removeSensibleValues } from "./util.mjs";
export { createValue, removeSensibleValues };
import { createValue, merge } from "./util.mjs";
export { createValue };

/**
* Predefined constants
Expand Down
36 changes: 0 additions & 36 deletions src/util.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -43,39 +43,3 @@ export function merge(a, b) {

return a;
}

/**
* genereates a new object tree by removing sensible values like credentials from it
* @param {Object} object
* @return {Object} object tree free of sensible data
*/
export function removeSensibleValues(
object,
toBeRemoved = key => key.match(/pass|auth|key|user|secret/)
) {
if (
object === undefined ||
object === null ||
typeof object === "number" ||
typeof object === "string" ||
object instanceof String
) {
return object;
}

const result = {};
for (const key of Object.keys(object)) {
const value = object[key];

if (typeof value === "string" || value instanceof String) {
if (toBeRemoved(key)) {
result[key] = "...";
continue;
}
}

result[key] = removeSensibleValues(value);
}

return result;
}
14 changes: 0 additions & 14 deletions tests/remove-sensible-test.mjs

This file was deleted.

0 comments on commit 4de5e97

Please sign in to comment.