(GH-145) Improve DSC secrets redaction #150
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prior to this commit, the DSC base provider only properly handled secrets when passed as part of a credential and always assumed that the sensitive data was the last string value in a hash.
This commit reworks the handling of sensitive data by:
#PuppetSensitivesecret identifier to the outside of a hash.As a result, a new method was required for removing the sensitive string identifier prior to passing the script string to PowerShell for invocation (lest a password erroneously get
#PuppetSensitiveappended to it). This is done via the newremove_secret_identifiersmethod, which must be called immediately prior to passing the script string tops_manager.execute().This commit also updates unit tests to validate the redaction and identifier stripping behavior. This change allows for secret strings to be arbitrarily embedded in a script, including any position in a hash, array, or complexly nested enumerable as well as standalone.
It does not update the PowerShell handling of sensitive values (ie, converting them to secure strings), only the Puppet handling of sensitive values from the manifest.
Currently, only passwords in credentials will be converted to secure strings for the creation of PSCredential objects in the script; all other sensitive strings will be standard String objects.