Skip to content

fix(scanner/redhatbase): support for empty release in rpm -qa #2101

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

Merged
merged 1 commit into from
Jan 10, 2025

Conversation

MaineK00n
Copy link
Collaborator

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 and strings.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

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

unit test

Checklist:

You don't have to satisfy all of the following.

  • Write tests
  • Write documentation
  • Check that there aren't other open pull requests for the same issue/feature
  • Format your source code by make fmt
  • Pass the test by make test
  • Provide verification config / commands
  • Enable "Allow edits from maintainers" for this PR
  • Update the messages below

Is this ready for review?: YES

Reference

@MaineK00n MaineK00n self-assigned this Jan 6, 2025
@MaineK00n MaineK00n force-pushed the MaineK00n/patch-2 branch 2 times, most recently from 1bd3a18 to 857a076 Compare January 6, 2025 08:50
@MaineK00n MaineK00n requested a review from shino January 6, 2025 09:11
@MaineK00n MaineK00n force-pushed the MaineK00n/patch-2 branch 2 times, most recently from f024ad9 to 8a0ddb0 Compare January 6, 2025 15:45
@MaineK00n
Copy link
Collaborator Author

When building an rpm package normally, it is difficult to omit the Release tag, and I had difficulty reproducing the issue. Instead, I will submit the output of rpm -qa, which led to this fix.

$ rpm -qa --queryformat "%{NAME} %{EPOCHNUM} %{VERSION} %{RELEASE} %{ARCH} %{SOURCERPM}\n" --root=/broot  | grep "\-\-src.rpm"
extension-subscription-data-export-interface 1 1.0.0.33  x86_64 extension-subscription-data-export-interface-1.0.0.33--src.rpm

Copy link
Collaborator

@shino shino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎊

@MaineK00n MaineK00n merged commit 0ec945d into master Jan 10, 2025
7 checks passed
@MaineK00n MaineK00n deleted the MaineK00n/patch-2 branch January 10, 2025 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants