-
Notifications
You must be signed in to change notification settings - Fork 42
(PA-8346) Preserve sensitive parameters #388
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -498,6 +498,33 @@ def set(_context, _changes); end | |
| instance[:secret] = Puppet::Pops::Types::PSensitiveType::Sensitive.new('a new password') | ||
| instance.flush | ||
| end | ||
|
|
||
| it 'marks the sensitive property with sensitive=true so it is excluded from the transaction store' do | ||
| expect(instance.parameter(:secret).sensitive).to be true | ||
| end | ||
| end | ||
|
|
||
| context 'when loading from a Puppet::Resource with no sensitive parameters' do | ||
| let(:params) { instance_double('Puppet::Resource', 'resource') } | ||
| let(:provider_instance) { instance_double(provider_class, 'provider_instance') } | ||
| let(:catalog) { instance_double('Unknown', 'catalog') } | ||
|
|
||
| before do | ||
| allow(provider_class).to receive(:new).with(no_args).and_return(provider_instance) | ||
| allow(provider_instance).to receive(:get).and_return([]) | ||
| allow(params).to receive(:is_a?).with(Puppet::Resource).and_return(true) | ||
| allow(params).to receive(:title).with(no_args).and_return('a title') | ||
| allow(params).to receive(:catalog).with(no_args).and_return(catalog) | ||
| allow(params).to receive(:sensitive_parameters).with(no_args).and_return([]) | ||
| allow(params).to receive(:to_hash).with(no_args) | ||
| .and_return(title: 'test', | ||
| secret: Puppet::Pops::Types::PSensitiveType::Sensitive.new('a password value')) | ||
| allow(catalog).to receive(:host_config?).and_return(true) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Finding 3 (Low): This test stubs an impossible state This test creates a The test passes but doesn't verify meaningful behavior — it's testing a code path that can't be reached in production. Consider either:
|
||
| end | ||
|
|
||
| it 'does not mark the property as sensitive' do | ||
| expect(instance.parameter(:secret).sensitive).not_to be true | ||
| end | ||
| end | ||
| end | ||
| end | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finding 1 (Medium): Fix couples to
hash2resourceundocumented internalsThis line works because
Puppet::Type#hash2resourceexplicitly deletes:sensitive_parametersfrom the hash before processing remaining keys (puppet/type.rb:1213). That deletion behavior is an undocumented internal — if Puppet core changes howhash2resourcehandles this key, this fix silently breaks.A more robust alternative would set
sensitive_parametersexplicitly aftersupercompletes, using Puppet's public API:set_sensitive_parametersis a public method onPuppet::Typethat iterates the list and marks each parameter as sensitive. This removes the dependency onhash2resource's internal key-deletion behavior.Note: you can't remove
set_sensitive_parametersfromhash2resourceitself — that's Puppet core code shared by all type implementations (native types, defined types, etc.), not just Resource API types. But the Resource API can safely add its own post-super call. The double-call (once insidehash2resource, once explicitly) is idempotent and harmless.Trade-off is minimal — robustness over a negligible duplicate call.