Repository navigation
fix(logsource.py): find_units() refuses arguments that are not unit names - #504
Merged
Merged
Conversation
…ames The lib guidelines treat every argument as hostile. find_units() took whatever it got: a bare string was searched character by character and found nothing, a candidate with a path separator was globbed outside the unit directories, and a non-string raised deep inside re.sub(). All three now raise before anything is looked up, also where systemd does not run the host, so the mistake shows on every test host. The candidates are consumed once up front, so a generator still works. Tests cover no candidates, a generator, a string, and candidates with a path, None and an int; the last two fail without the fix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The lib guidelines treat every argument as hostile. find_units() took
whatever it got: a bare string was searched character by character and
found nothing, a candidate with a path separator was globbed outside
the unit directories, and a non-string raised deep inside re.sub().
All three now raise before anything is looked up, also where systemd
does not run the host, so the mistake shows on every test host.
The candidates are consumed once up front, so a generator still works.
Tests cover no candidates, a generator, a string, and candidates with
a path, None and an int; the last two fail without the fix.
Checks: tests/logsource/unit-test/run (232 tests) and tox py39 to py314 passed locally.