Skip to content

Commit c1d6149

Browse files
committed
Do not reveal sensitive Data
"auth_option" may contain sensitive Data, f.e. LDAP-Password. So let auth_option accept Puppet-Type Sensitive. The consuming EPP is able to handle sensitive Data natively, and will return the rendered Template as Sensitive[String] then, which the Resource "file" also is able to handle.
1 parent 51764e3 commit c1d6149

5 files changed

Lines changed: 29 additions & 5 deletions

File tree

REFERENCE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3328,7 +3328,7 @@ Default value: `'none'`
33283328

33293329
##### <a name="-postgresql--server--pg_hba_rule--auth_option"></a>`auth_option`
33303330

3331-
Data type: `Optional[String]`
3331+
Data type: `Optional[Variant[Sensitive[String], String]]`
33323332

33333333
For certain auth_method settings there are extra options that can be passed. Consult the PostgreSQL pg_hba.conf documentation for
33343334
further details.
@@ -4862,7 +4862,7 @@ Struct[{
48624862
user => String,
48634863
Optional[address] => Optional[Postgresql::Pg_hba_rule_address],
48644864
auth_method => String,
4865-
Optional[auth_option] => Optional[String],
4865+
Optional[auth_option] => Optional[Variant[Sensitive[String], String]],
48664866
Optional[order] => Variant[String,Integer],
48674867
Optional[target] => Stdlib::Absolutepath,
48684868
Optional[postgresql_version] => String,

manifests/server/pg_hba_rule.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
String[1] $auth_method,
3131
Optional[Postgresql::Pg_hba_rule_address] $address = undef,
3232
String[1] $description = 'none',
33-
Optional[String] $auth_option = undef,
33+
Optional[Variant[Sensitive[String], String]] $auth_option = undef,
3434
Variant[String, Integer] $order = 150,
3535
Stdlib::Absolutepath $target = $postgresql::server::pg_hba_conf_path,
3636
String $postgresql_version = $postgresql::server::_version

spec/defines/server/pg_hba_rule_spec.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,30 @@ class { 'postgresql::server': }
8080
end
8181
end
8282

83+
context 'test template 3 with sensitive Data' do
84+
let :pre_condition do
85+
<<-MANIFEST
86+
class { 'postgresql::server': }
87+
MANIFEST
88+
end
89+
90+
let :params do
91+
{
92+
type: 'host',
93+
database: 'all',
94+
user: 'all',
95+
address: '0.0.0.0/0',
96+
auth_method: 'ldap',
97+
auth_option: sensitive('foo=bar'),
98+
target: target
99+
}
100+
end
101+
102+
it do
103+
expect(subject).to contain_concat__fragment('pg_hba_rule_test').with(content: sensitive(%r{host\s+all\s+all\s+0\.0\.0\.0/0\s+ldap\s+foo=bar}))
104+
end
105+
end
106+
83107
context 'validation' do
84108
context 'validate supported auth_method' do
85109
let :pre_condition do

templates/pg_hba_rule.conf.epp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
String[1] $user,
88
Optional[Postgresql::Pg_hba_rule_address] $address,
99
String[1] $auth_method,
10-
Optional[String] $auth_option,
10+
Optional[Variant[Sensitive[String], String]] $auth_option,
1111
| -%>
1212
# Rule Name: <%= $name %>
1313
# Description: <%= $description %>

types/pg_hba_rule.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
user => String,
88
Optional[address] => Optional[Postgresql::Pg_hba_rule_address],
99
auth_method => String,
10-
Optional[auth_option] => Optional[String],
10+
Optional[auth_option] => Optional[Variant[Sensitive[String], String]],
1111
Optional[order] => Variant[String,Integer],
1212
Optional[target] => Stdlib::Absolutepath,
1313
Optional[postgresql_version] => String,

0 commit comments

Comments
 (0)