Skip to content

Commit b0e1f67

Browse files
committed
Harden root_password class
Prior to this commit there was a possibility that malformed strings could be passed in to the resource. This could lead to unsafe executions on a remote system. The parameters that are susceptible are `install_secret_file`. This commit fixes the above by adding validation to ensure the given values confirm to expectation. `secret_file` is validated with a regular expresion that ensures the given value is a valid path.
1 parent 1469fbf commit b0e1f67

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

manifests/server/root_password.pp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919
$secret_file = $mysql::server::install_secret_file
2020
$login_file = $mysql::server::login_file
2121

22+
# Validate that the given secret_file value is a valid path
23+
if $secret_file !~ /^\/(.?)(?:[A-Za-z0-9_-]+\/?+)+(?:.[A-Za-z0-9]+)$/ {
24+
$message = "Invalid value provided for parameter install_secret_file. '${secret_file}' is not a valid path."
25+
fail($message)
26+
}
27+
2228
# New installations of MySQL will configure a default random password for the root user
2329
# with an expiration. No actions can be performed until this password is changed. The
2430
# below exec will remove this default password. If the user has supplied a root

0 commit comments

Comments
 (0)