-
Notifications
You must be signed in to change notification settings - Fork 567
fix: systemd Checker #1289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: systemd Checker #1289
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1289 +/- ##
==========================================
+ Coverage 78.96% 80.31% +1.35%
==========================================
Files 262 264 +2
Lines 4801 4801
Branches 578 575 -3
==========================================
+ Hits 3791 3856 +65
+ Misses 856 797 -59
+ Partials 154 148 -6
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good. Let's try to help out our future selves with pre-documenting the slightly unusual strings for systemd.
@@ -38,20 +38,3 @@ class SystemdChecker(Checker): | |||
The reason behind this is that these might depend on who packages the file (like it | |||
might work on fedora but not on ubuntu) | |||
""" | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's put a note right in the checker somewhere (maybe here at the bottom) describing the way systemd's version patterns occur, preferably showing the list of strings like was done in #1155. This is just to help us out in the future in case further refactoring breaks this again.
Equally, we could do something more clever with getting all possible results and sorting them explicitly to make this more robust against changes. The original cve-bin-tool code actually had something like that in it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrote some explanation on what's happening.
Also it seems like the changes in #1227 didn't actually detect the versions in the package from #1155 (but it did work on packages of same version but different releases from Fedora 33). So I made changes in the first regex pattern.
I didn't want to bring back what we did in the older fix(reversing the list), since it means we can't use any other utility functions and would have to split, sort and detect versions in the strings in here (due to the changes in #1227). If there was no other way or if systemd suddenly decides to change the way they present their version strings then we might have to do it that way.
But fortunately the changes I made in the 1st pattern detects the correct version string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have also added that certain package as a condensed download.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we'd actually have to split, you'd just have to use re.findall for systemd and then sort the results. (You'd do this in an overridden get_version()
function so we weren't wasting time doing findall on other checkers.) But I think what you've got right now works and the comment is clear about the multiple version strings, so let's go with the cleaner solution first and save over-riding idea only if they change the sorting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aah. That could've been more readable than the current implementation.
Using findall didn't pass through my mind.
I wrote the commit messages with "docs" as prefix since I'm not sure what to write instead. (Comments maybe? 😅 ) |
Offtopic |
Yep, we were trying out conventional commits to make the commit history more readable. We made the decision during a weekly meet and decided we'll try it out. And I think it's time we add it to the docs about conventional commits in the README.
Yep.
Not sure if we'll be adding this but looks really helpful for @terriko . |
@@ -38,20 +38,3 @@ class SystemdChecker(Checker): | |||
The reason behind this is that these might depend on who packages the file (like it | |||
might work on fedora but not on ubuntu) | |||
""" | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we'd actually have to split, you'd just have to use re.findall for systemd and then sort the results. (You'd do this in an overridden get_version()
function so we weren't wasting time doing findall on other checkers.) But I think what you've got right now works and the comment is clear about the multiple version strings, so let's go with the cleaner solution first and save over-riding idea only if they change the sorting.
#1227 (comment)
systemd checker wasn't working at #1155 and was fixed in #1156 but we don't need that fix anymore due to the changes in #1227.
Also enabled the commented out test for systemd v246.