Skip to content

Commit c9932ac

Browse files
authored
Merge pull request #412 from puppetlabs/fix/redact-iis-password
(MODULES-11595) Redact password and fix provider spec for iis_application_pool
2 parents a18d6c8 + 6543e68 commit c9932ac

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

lib/puppet/type/iis_application_pool.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,14 @@ module uses the token to impersonate the built-in account. When
382382
files, this uses AppCmd.exe. This encrypts the password automatically
383383
before it is written to the XML configuration files. This provides
384384
better password security than storing unencrypted passwords."
385+
386+
def should_to_s(_value)
387+
'[redacted sensitive information]'
388+
end
389+
390+
def is_to_s(_value) # rubocop:disable Naming/PredicateName
391+
'[redacted sensitive information]'
392+
end
385393
end
386394

387395
newproperty(:orphan_action_exe, parent: PuppetX::PuppetLabs::IIS::Property::String) do

spec/unit/puppet/provider/iis_application_pool/webadministration_spec.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,28 @@
3333
expect(provider_class.new).to respond_to(method)
3434
end
3535
end
36+
37+
describe '#update' do
38+
let(:resource) do
39+
Puppet::Type.type(:iis_application_pool).new(
40+
name: 'iis_application_pool',
41+
password: 'Sup3r$ecret!',
42+
)
43+
end
44+
let(:provider) { described_class.new(resource) }
45+
46+
it 'passes the password directly in the PowerShell command' do
47+
expect(described_class).to receive(:run)
48+
.with(a_string_including('processModel.password', 'Sup3r$ecret!'))
49+
.and_return({ exitcode: 0, errormessage: '' })
50+
51+
provider.update
52+
end
53+
54+
it 'redacts password in Puppet logs' do
55+
prop = resource.property(:password)
56+
expect(prop.should_to_s('Sup3r$ecret!')).to eq('[redacted sensitive information]')
57+
expect(prop.is_to_s('Sup3r$ecret!')).to eq('[redacted sensitive information]')
58+
end
59+
end
3660
end

0 commit comments

Comments
 (0)