Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,20 @@
"hide-my-secrets.secretKeys": {
"type": "array",
"default": [
"password",
"access_key",
"api_key",
"aws_secret_access_key",
"azure_client_secret",
"client_secret",
"connection_string",
"connectionstring",
"google_client_secret",
"jwt_token",
"oauth_token",
"password",
"private_key",
"secret_key",
"secret_token",
"token"
],
"description": "List of keywords that whose values you want to hide"
Expand Down Expand Up @@ -79,4 +91,4 @@
"dependencies": {
"yaml-ast-parser": "0.0.43"
}
}
}
4 changes: 3 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,16 @@ function FindRangesAndDecorate(editor: vscode.TextEditor, hide: boolean, secretK

export function traverseAndChange(node: yamlParser.YAMLNode, editor: vscode.TextEditor, ranges: vscode.Range[], secretKeys: string[]) {

let testRegEx = new RegExp(secretKeys.join("|"), "i");

if (node.kind === Kind.MAP) {
for (let childNode of node.mappings) {
traverseAndChange(childNode, editor, ranges, secretKeys);
}
} else {
if (node.kind === Kind.MAPPING) { //it's an object (key : object)
let keyValue = node.key.value;
if (secretKeys.includes(keyValue)) {
if (testRegEx.test(keyValue)) {
addSecretRange(node.value, editor, ranges);
} else {
if (node.value.kind === Kind.MAP) { //it's a mapping, it has a property called mappings (applies to Root)
Expand Down