fix(ping): quote the destination and source in the ping command

ping() typed its arguments into the interactive shell as they came, so a
destination such as "1.2.3.4; id" ran the command after the semicolon as
the login user. destination and source now go through shlex.quote, and
count, timeout, size and ttl are coerced with int(), which refuses
anything that is not a number before a command is sent.

The command is built in _ping.py, next to its parser, which keeps
linux.py within its recorded length.

Closes #55
This commit is contained in:
Christian Manivong committed 2026-11-02 08:37:15 +01:00
1 parent 5687f5d9a1
commit c2d7c4d1b4
5 files changed
+51 -6

No files matched your search

+4
View File
@@ -45,6 +45,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
on 3.12, so 3.10 and 3.11 are no longer tested (NAPALM/driver-standard#6).
### Fixed
- `ping()` passes `destination` and `source` to the host's shell as one quoted word
each (#55). A destination such as `192.0.2.1; id` ran the command after the `;` as
the login user. `count`, `timeout`, `size` and `ttl` must be numbers; anything else
raises `ValueError` before a command is sent.
- dnf and yum hosts read pending updates and security advisories from the cached
metadata only (`--cacheonly`), as apt reads its local index (#59). With an expired
cache `check-update` downloaded the repositories' metadata first, and on an Oracle