Skip to content
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

Match affected and fixed-by Packages #1528

Merged
merged 11 commits into from
Sep 28, 2024

Conversation

johnmhoran
Copy link
Contributor

The initial commit in this PR adds CSS for the collapsed (< 1024px) responsive Bulma navbar and adjusts some template nesting. Substantive work on matching affected and fixed-by Packages to follow.

Reference: #1287

Reference: #1287
Signed-off-by: John M. Horan <johnmhoran@gmail.com>
@TG1999
Copy link
Contributor

TG1999 commented Aug 6, 2024

@johnmhoran thanks! please provide screenshots and let us know when it's good to be merged

Reference: #1287
- Matched affected/fixed-by Package data added to Vulnerability details.
- version_class-based sorting added to that data as well.
- Note that version_class-based Packages sorting still needs to be added
  to Package search results.
- Filter added to encode Package URLs.
- Next: will add tests.
Signed-off-by: John M. Horan <johnmhoran@gmail.com>
…m:nexB/vulnerablecode into 1287-resume-combining-affected-fixed-tabs
@johnmhoran
Copy link
Contributor Author

@TG1999 I just committed and tried to push my latest changes -- no tests yet, and I'm not yet able to properly sort the Package search results (but the immediate task, the new matched affected/fixed by records, look great and are properly sorted ;-) -- but immediately ran into a problem evidently because you had committed and pushed numerous changes of your own to this branch that I did not have locally. I followed the git instruction to run 'git pull' on this branch, it seems to have been merged automatically and without reported conflicts.

I then ran git push origin 1287-resume-combining-affected-fixed-tabs successfully, no errors. However, on this PR page, 1 test failed twice -- some codestyle test unrelated to my work -- and I see the warning This branch has conflicts that must be resolved. I'd feel comfortable resolving conflicts locally with my VSCode, but have not yet used the GH interface for that and am a bit reluctant to click one of the links for web editor or command line or Resolve conflicts.

Reference: #1287
- Fixed merge conflicts.
Signed-off-by: John M. Horan <johnmhoran@gmail.com>
@johnmhoran
Copy link
Contributor Author

@TG1999 I just updated main locally, merged into my branch, resolved a few conflicts and committed and pushed. Waiting for the GH checks to finish.

The primary goal of this issue and PR was matching the affected and fixed-by Packages, and that's now in place on the Vulnerability details page. (I'll add a screen shot or two in another comment below.) My next task will be to add some tests.

This PR also includes a few other items I encountered along the way:

  • Added version_class-based sorting to the matched affect/fixed-by records
  • Added a filter to encode Package URLs so that a link to a Package with a qualifiers value will properly recognize the qualifiers separator and following data.

Note: I also tried to update the PackageSearch class in views.py to incorporate my version_class-based sorting into the get_queryset() method but could not figure out how to do that. I tried to modify .order_by() directly and by adding a .annotate() clause (if that's the right word), but no luck. Please let me know if you have any suggestions on how I should approach.

@johnmhoran
Copy link
Contributor Author

@TG1999 A few screen shots of the new matched affect/fixed-by Package records on the Vulnerabilities details page.

The landing page showing the Essentials tab contents and next to it, the new Affected/Fixed by packages tab.

image

Scrolling down the Essentials content a bit, here are the first 3 records from the new tab (plus a link to that tab):

image

And this is the new Affected/Fixed by packages tab when selected:

image

@johnmhoran
Copy link
Contributor Author

@TG1999 @pombredanne While exploring the sorting of a variety of PURL types using purl_version_class = RANGE_CLASS_BY_SCHEMES[purl.type].version_class, I see that pkg:apk/alpine/apk@2.12.9-r3?arch=x86 is raising an exception: KeyError: 'apk'.

Although apk is listed as a PURL type (https://github.com/package-url/purl-spec/blob/master/PURL-TYPES.rst#apk), is it possible that univers handles alpine but does not yet handle apk, and thus a sort using version_class will fail for pkg:apk/*?

Not sure if this is still needed (or relevant to my question), but we import AlpineLinuxVersionRange separately from RANGE_CLASS_BY_SCHEMES and then update the latter with the former.

from univers.version_range import RANGE_CLASS_BY_SCHEMES
from univers.version_range import AlpineLinuxVersionRange

. . .

def purl_sort_key(purl: models.Package):
    RANGE_CLASS_BY_SCHEMES["alpine"] = AlpineLinuxVersionRange
    purl_version_class = RANGE_CLASS_BY_SCHEMES[purl.type].version_class
    return (purl.type, purl.namespace, purl.name, purl_version_class(purl.version), purl.qualifiers, purl.subpath)

AlpineLinuxVersionRange defines scheme as alpine but does not refer to apk. The only univers reference I see for apk
is in alpine_test.txt.NOTICE -- "Alpine Package Keeper (apk) is a package manager developed for Alpine Linux.".

@johnmhoran
Copy link
Contributor Author

Note that alpine_test.txt.ABOUT contains a reference to an alpine PURL type:

package_url: pkg:alpine/apk-tools@2.12.9#test/version.data

but alpine is not listed in purl-spec as a PURL type and appears only under the listing for 'apk'.

@johnmhoran
Copy link
Contributor Author

I'm seeing similar key errors for some other PURL types like bitbucket, bitnami and cocoapods, so perhaps these are just examples of PURL types that are not yet covered by univers?

Reference: #1287
Signed-off-by: John M. Horan <johnmhoran@gmail.com>
Reference: #1287
Signed-off-by: John M. Horan johnmhoran@gmail.com
@johnmhoran
Copy link
Contributor Author

@TG1999 @pombredanne This PR is ready for review. I've refactored the sort and version-class functions and added tests for these functions and for the custom quote filter.

Note: After learning that not all "known PURL types" -- https://github.com/package-url/purl-spec/blob/master/PURL-TYPES.rst#known-purl-types -- have a univers version_class, I revised the sort and version-class tests to test only PURL types currently supported by univers.

I see that once again the only failing check here is test_codestyle, which I think I've seen failing for other PRs recently as well -- no idea why it's failing or how to resolve.

Reference: #1287
Signed-off-by: John M. Horan <johnmhoran@gmail.com>
@TG1999
Copy link
Contributor

TG1999 commented Sep 12, 2024

Thanks @johnmhoran ! LGTM

Copy link
Contributor

@TG1999 TG1999 left a comment

Choose a reason for hiding this comment

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

LGTM!

@pombredanne pombredanne merged commit 433f2a9 into main Sep 28, 2024
9 checks passed
@pombredanne pombredanne deleted the 1287-resume-combining-affected-fixed-tabs branch September 28, 2024 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants