Skip to content

Commit

Permalink
(PUP-11846) Handle unprocessed, deferred sensitive
Browse files Browse the repository at this point in the history
Prior to this commit, evaluating a deferred resource that includes a
Sensitive value would fail during munging.  This commit marks these
resources as sensitive and unwraps them during catalog application.
  • Loading branch information
m0dular authored and joshcooper committed Jul 6, 2023
1 parent c8bba06 commit b92e4d3
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/puppet/pops/evaluator/deferred_resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ def initialize(proc)
end

def resolve
@proc.call
val = @proc.call
# Deferred sensitive values will be marked as such in resolve_futures()
if val.is_a?(Puppet::Pops::Types::PSensitiveType::Sensitive)
val.unwrap
else
val
end
end
end

Expand Down Expand Up @@ -90,6 +96,12 @@ def resolve_futures(catalog)
unless r.sensitive_parameters.include?(k.to_sym)
r.sensitive_parameters = (r.sensitive_parameters + [k.to_sym]).freeze
end
# If the value is a DeferredValue and it has an argument of type PSensitiveType, mark it as sensitive
# The DeferredValue.resolve method will unwrap it during catalog application
elsif resolved.is_a?(Puppet::Pops::Evaluator::DeferredValue)
if v.arguments.any? {|arg| arg.is_a?(Puppet::Pops::Types::PSensitiveType)} and not r.sensitive_parameters.include?(k.to_sym)
r.sensitive_parameters = (r.sensitive_parameters + [k.to_sym]).freeze
end
end
overrides[ k ] = resolved
end
Expand Down

0 comments on commit b92e4d3

Please sign in to comment.