Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(GH-145) Improve DSC secrets redaction #150

Merged
merged 1 commit into from
Jun 18, 2021
Merged

(GH-145) Improve DSC secrets redaction #150

merged 1 commit into from
Jun 18, 2021

Conversation

michaeltlombardi
Copy link
Contributor

@michaeltlombardi michaeltlombardi commented Jun 14, 2021

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:

  1. Not munging the formatted PowerShell string to move the #PuppetSensitive secret identifier to the outside of a hash.
  2. Reworking redaction to work within a string instead of only for the last string in a hash declaration.

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 #PuppetSensitive appended to it). This is done via the new remove_secret_identifiers method, which must be called immediately prior to passing the script string to ps_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.

@michaeltlombardi michaeltlombardi added the enhancement New feature or request label Jun 14, 2021
@michaeltlombardi michaeltlombardi requested a review from a team as a code owner June 14, 2021 22:35
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:

1. Not munging the formatted PowerShell string to move the PuppetSensitive secret
   identifier to the outside of a hash.
2. Reworking redaction to work *within* a string instead of only for the last string
   in a hash declaration.

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 #PuppetSensitive appended to it). This is done via the new
remove_secret_identifiers method, which must be called immediately prior to passing
the script string to ps_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.
@david22swan david22swan merged commit 12a15a7 into puppetlabs:main Jun 18, 2021
@michaeltlombardi michaeltlombardi deleted the gh-145/main/improve-redaction branch June 22, 2021 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DSC Base Provider: Improve sensitive string redaction
2 participants