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

(PUP-12050) Check for nested Sensitive arguments #9410

Merged
merged 2 commits into from
Jul 12, 2024

Conversation

joshcooper
Copy link
Contributor

@joshcooper joshcooper commented Jul 4, 2024

Previously, a manifest containing nested Deferred values did not mark the corresponding parameter as sensitive, resulting in the following:

$ cat manifest.pp
$vars = {'token' => Deferred('new', [Sensitive, "password"])}
file { '/tmp/a.sh':
  ensure  => file,
  content => Deferred('inline_epp', ['<%= $token %>', $vars])
}
$ truncate --size 0 /tmp/a.sh
$ puppet apply --show_diff manifest.pp
Notice: Compiled catalog for localhost in environment production in 0.01 seconds
Notice: /Stage[main]/Main/File[/tmp/a.sh]/content:
--- /tmp/a.sh	2024-07-03 17:30:37.024543314 -0700
+++ /tmp/puppet-file20240703-1784698-2cu5s9	2024-07-03 17:30:41.880572413 -0700
@@ -0,0 +1 @@
+password
\ No newline at end of file

The issue occurred because we were only checking if the outermost DeferredValue contained any Sensitive arguments, in this case the arguments passed to inline_epp function, but not the password passed to the new function.

This is not an issue when deferred values are preprocessed, because Deferred values are completely resolved and we can check if resolved value is Sensitive.

The problem was introduced in b92e4d3 which added the ability to lazily call a deferred function when its respective resource is evaluated. It should be backported to 7.x

With this change we get:

$ puppet apply --show_diff manifest.pp
Notice: Compiled catalog for localhost in environment production in 0.01 seconds
Notice: /Stage[main]/Main/File[/tmp/a.sh]/content: [diff redacted]
Notice: /Stage[main]/Main/File[/tmp/a.sh]/content: changed [redacted] to [redacted]
Notice: Applied catalog in 0.04 seconds

Fixes #9384

@joshcooper
Copy link
Contributor Author

Rubocop failures should be fixed in #9413

Previously, a manifest containing nested Deferred values did not mark
the corresponding parameter as sensitive, resulting in the following:

    $ cat manifest.pp
    $vars = {'token' => Deferred('new', [Sensitive, "password"])}
    file { '/tmp/a.sh':
      ensure  => file,
      content => Deferred('inline_epp', ['<%= $token %>', $vars])
    }
    $ truncate --size 0 /tmp/a.sh
    $ puppet apply --show_diff manifest.pp
    Notice: Compiled catalog for localhost in environment production in 0.01 seconds
    Notice: /Stage[main]/Main/File[/tmp/a.sh]/content:
    --- /tmp/a.sh	2024-07-03 17:30:37.024543314 -0700
    +++ /tmp/puppet-file20240703-1784698-2cu5s9	2024-07-03 17:30:41.880572413 -0700
    @@ -0,0 +1 @@
    +password
    \ No newline at end of file

The issue occurred because we were only checking if the outermost DeferredValue
contained any Sensitive arguments, in this case the arguments passed to
`inline_epp` function, but not the `password` passed to the `new` function.

This is not an issue when deferred values are preprocessed, because Deferred
values are completely resolved and we can check if resolved value is Sensitive.
@joshcooper joshcooper marked this pull request as ready for review July 11, 2024 17:41
@joshcooper joshcooper requested a review from a team as a code owner July 11, 2024 17:41
@cthorn42 cthorn42 merged commit 637ef2a into puppetlabs:main Jul 12, 2024
9 checks passed
@joshcooper joshcooper deleted the deferred_sensitive_12050 branch July 12, 2024 16:58
@joshcooper joshcooper added the bug Something isn't working label Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

file resource type displays Sensitive information in clear text in output when Deferred
2 participants