Puppet Function: sudo::safe_wildcard_cmd
- Defined in:
- modules/sudo/functions/safe_wildcard_cmd.pp
- Function type:
- Puppet Language
Summary
this function takes a command and a path containing a wildcard and returns a sudo command spec with additional negations to avoid path traversalOverview
SPDX-License-Identifier: Apache-2.0
8 9 10 11 12 13 14 15 16 |
# File 'modules/sudo/functions/safe_wildcard_cmd.pp', line 8
function sudo::safe_wildcard_cmd(Stdlib::Unixpath $cmd, Stdlib::Unixpath $wildpath) {
if $wildpath !~ /\*$/ {
"${cmd} ${wildpath}"
} else {
[' *', '..*'].reduce("${cmd} ${wildpath}") |$memo, $value| {
"${memo}, !${cmd} ${wildpath}${value}"
}
}
}
|