Skip to content

Commit 6ce2cb1

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 880a6f7 commit 6ce2cb1

File tree

6 files changed

+31
-6
lines changed

6 files changed

+31
-6
lines changed

REFERENCE.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -3319,7 +3319,7 @@ Default value: `'none'`
33193319

33203320
##### <a name="-postgresql--server--pg_hba_rule--auth_option"></a>`auth_option`
33213321

3322-
Data type: `Optional[String]`
3322+
Data type: `Optional[Variant[Sensitive[String], String]]`
33233323

33243324
For certain auth_method settings there are extra options that can be passed. Consult the PostgreSQL pg_hba.conf documentation for
33253325
further details.
@@ -4844,7 +4844,7 @@ Struct[{
48444844
user => String,
48454845
Optional[address] => Optional[Postgresql::Pg_hba_rule_address],
48464846
auth_method => String,
4847-
Optional[auth_option] => Optional[String],
4847+
Optional[auth_option] => Optional[Variant[Sensitive[String], String]],
48484848
Optional[order] => Variant[String,Integer],
48494849
Optional[target] => Stdlib::Absolutepath,
48504850
Optional[postgresql_version] => String,

manifests/server/instance/service.pp

+2-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@
5959
require => Service["postgresqld_instance_${name}"],
6060
before => Anchor["postgresql::server::service::end::${name}"],
6161
}
62-
Postgresql::Server::Database <| title == $default_database |> -> Postgresql_conn_validator["validate_service_is_running_instance_${name}"]
62+
Postgresql::Server::Database <| title == $default_database |>
63+
-> Postgresql_conn_validator["validate_service_is_running_instance_${name}"]
6364
}
6465
}
6566

manifests/server/pg_hba_rule.pp

+1-1
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

+24
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

+1-1
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

+1-1
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)