-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
removed debug function and package and updated use of debug logs thro…
…ughout cli to use new logger; added masking to the payload logged to obfuscate secret information
- Loading branch information
Showing
22 changed files
with
121 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import cloneDeep from 'lodash.clonedeep' | ||
|
||
const DEFAULT_MASKED_FIELDS = [ | ||
'seed', | ||
'secretKey', | ||
'addressRaw', | ||
]; | ||
|
||
export function maskPayload (payload: any): any { | ||
const clonedPayload = cloneDeep(payload); | ||
const maskedPayload = {} | ||
|
||
if (!clonedPayload) { | ||
return clonedPayload; | ||
} | ||
|
||
// maskJSONFields doesn't handle nested objects very well so we'll | ||
// need to recursively walk to object and mask them one by one | ||
for (const [property, value] of Object.entries(clonedPayload)) { | ||
console.log(property, typeof value); | ||
|
||
if (value && typeof value === 'object') { | ||
if (Object.keys(clonedPayload[property]).filter(key => isNaN(parseInt(key))).length === 0) { | ||
const reconstructedUintArr: number[] = Object.values(clonedPayload[property]) | ||
maskedPayload[property] = "base64:" + Buffer.from(reconstructedUintArr).toString("base64"); | ||
} else { | ||
maskedPayload[property] = maskPayload(value); | ||
} | ||
} else if (value && typeof value === 'string' && DEFAULT_MASKED_FIELDS.includes(property)) { | ||
maskedPayload[property] = "*".repeat(clonedPayload[property].length) | ||
} else { | ||
maskedPayload[property] = value | ||
} | ||
} | ||
|
||
return maskedPayload; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.