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

(MODULES-8856) Redact debug #104

Merged
merged 1 commit into from
Apr 12, 2019
Merged

(MODULES-8856) Redact debug #104

merged 1 commit into from
Apr 12, 2019

Conversation

michaeltlombardi
Copy link
Contributor

@michaeltlombardi michaeltlombardi commented Apr 11, 2019

Prior to this commit the provider would output the full Powershell log to be executed during debug runs. This is to ensure that we can verify exactly what will be executed. However, this also meant that credentials and other secrets could leak into the debug output, and thus also into PuppetDB logs.

This commit modifies the provider, ERB templates, and a helper file to ensure that methods for formatting Puppet data to be PowerShell compliant are able to take a new parameter, redact.

Passing this parameter will cause the script builder to redact any sensitive data it is passed. This flag is forwarded along through several helpers. This implementation allows us to reuse the code for interpolating the correct values into the PowerShell script for the actual execution and for the debug messaging.

There is possibly a better implementation for this change.

This commit also includes updated spec and integration tests to verify the behavior when choosing to redact sensitive values.

@michaeltlombardi
Copy link
Contributor Author

These changes have passed in AdHoc.

@michaeltlombardi michaeltlombardi changed the title (WIP) (MODULES-8856) Redact debug (MODULES-8856) Redact debug Apr 11, 2019
lib/puppet/provider/base_dsc_lite/powershell.rb Outdated Show resolved Hide resolved
lib/puppet/provider/base_dsc_lite/powershell.rb Outdated Show resolved Hide resolved
Prior to this commit the provider would output the full PowerShell
log to be executed during debug runs. This was to ensure that we
could verify exactly what would be executed. However, this also
meant that credentials and other secrets could leak into the debug
output, and thus also into PuppetDB logs.

This commit modifies the provider and a helper to inject a PowerShell
comment after a secret as `# PuppetSensitive`. This does not interfere
with passing the data to PowerShell, but does allow us to redact the
sensitive information using a regex matcher prior to emitting via
debug logging.

That redaction is handled by a new class method on the provider called
`redact_content`.

This commit also includes updated spec tests to verify that sensitive
data, when present, can be both unwrapped *and* redacted prior to being
emitted.
@Iristyle
Copy link
Contributor

👍 This seems like a far less intrusive approach that will scale better should we add additional formatting logic, etc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants