fix(scanner/redhatbase): support for empty release in rpm -qa #2101
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.
What did you implement:
In rpm -qa, release may be empty.
When release is empty, there will be two spaces, which are rpm-qa separators.
In this case,
strings.Split
andstrings.Fields
behave differently.Please refer to the following example.
https://go.dev/play/p/nc-MA6sPz4D
Since we expect the length to be constant (= we know which elements are empty), we should use
strings.Split
.Also, regarding
splitFileName
, if the name part has-
, the existing implementation passes it even if the filename is invalid.So, although it is not standard rpm style, I would like to change it to accept the pattern
...<release>-<arch>
.Type of change
How Has This Been Tested?
unit test
Checklist:
You don't have to satisfy all of the following.
make fmt
make test
Is this ready for review?: YES
Reference