You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(shell)!: run commands as argv lists, closing shell injection (GHSA-798h-hpph-m24j)
shell_exec() now requires the command as a list of arguments and always runs
with shell=False, so argument values are never interpreted by a shell. It no
longer accepts a command string, a shell= parameter or | pipelines, and
get_command_output() has been removed.
- shell: list-only argv, no shell, no shlex, no pipe split; raises TypeError on
a string. Add safe_cli_value() to reject option-like values (leading "-") for
positional or target arguments (ssh destination, ping target, ...).
- ssh: build_options()/target() return argv tokens; run()/scp()/rsync() build
argv lists, drop use_shell, and reject an option-like host or username.
- distro, version: read /etc/os-release directly instead of sourcing via a shell.
- base: oao() and cu() normalize CRLF/CR to LF so Windows output is not rendered
with doubled line breaks in pre-wrap web UIs.
- shell: decode Windows pipe output with the console/OEM code page instead of
UTF-8, fixing UnicodeDecodeError and mangled umlauts
(Linuxfabrik/monitoring-plugins#681).
BREAKING CHANGE: lib.shell.shell_exec() requires an argv list and drops the
shell= parameter, the | pipeline split and get_command_output(); lib.ssh
helpers return and accept argv lists and drop use_shell.
Copy file name to clipboardExpand all lines: CHANGELOG.md
+13Lines changed: 13 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,10 +8,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8
8
9
9
## [Unreleased]
10
10
11
+
### Changed
12
+
13
+
* distro.py, version.py: read the OS name and version directly from `/etc/os-release` instead of sourcing it through a shell
14
+
* shell.py: `shell_exec()` requires the command as a list of arguments (argv) and always runs with `shell=False`. It no longer accepts a command string, a `shell=` parameter, or `|` pipelines. This is a breaking change: pass `['df', '-h', path]` instead of `'df -h ' + path`
15
+
* shell.py: new `safe_cli_value()` rejects a value that a called program could misread as an option (leading `-`), to guard positional or target arguments (such as an ssh destination or a `ping` target) against option injection
16
+
* ssh.py: `build_options()` and `target()` return argument lists/tokens instead of pre-quoted strings; `run()`, `scp()` and `rsync()` build argument lists, drop the `use_shell` parameter, and reject an option-like host or username
17
+
18
+
### Removed
19
+
20
+
* shell.py: removed `get_command_output()` (it had no consumers; use `shell_exec()` directly)
21
+
11
22
### Fixed
12
23
24
+
* base.py: `oao()` normalizes CRLF and stray CR in the plugin message to LF, so Windows command output is no longer rendered with doubled line breaks in web UIs that use `white-space: pre-wrap`
13
25
* endoflifedate.py: the Apache httpd and Rocket.Chat offline data is keyed under their current endoflife.date URLs (`apache-http-server`, `rocket-chat`), so version checks still work when the endoflife.date API is unreachable
14
26
* lftest.py: use the classic `with a, b:` form instead of parenthesized context managers (Python 3.10+ syntax), so the module parses under RHEL 8's default Python 3.6
27
+
* shell.py: on Windows, a subprocess's piped output is decoded with the console / OEM code page instead of UTF-8, so non-ASCII characters such as umlauts in usernames are no longer mangled ([monitoring-plugins#681](https://github.com/Linuxfabrik/monitoring-plugins/issues/681))
15
28
* url.py: use the classic `with a, b:` form instead of parenthesized context managers (Python 3.10+ syntax), so `import lib.url` no longer raises a SyntaxError under RHEL 8's default Python 3.6
0 commit comments