johnpapa / vscode-cloak

Cloak allows you to hide/show environment keys, to avoid accidentally sharing them with everyone who sees your screen.
MIT License
105 stars 7 forks source link

Proposal how to detect secrets in other files #58

Open sassdawe opened 10 months ago

sassdawe commented 10 months ago

I just realized that Cloak can't hide secrets I might store in other file formats. And before I go down into a rabbit hole I wanted to write down my idea.

Could we detect lines with value assignments to variables or to properties and when the variable/propery name matches a the (configurable) list of pattern it would cloak the value part of the line.

Basically a very similar logic how we can set PSReadLine of PowerShell to exclude sensitive stuffs from the history:

Set-PSReadLineOption -AddToHistoryHandler {
    param([string]$line)

    $sensitive = "password|asplaintext|token|key|secret"
    return ($line -notmatch $sensitive)
}

Would this be possible to do?