Repository navigation
Combine Ruby unaffected version ranges (#2536) - #2537
Open
kunaalxoxo wants to merge 1 commit into
Open
kunaalxoxo wants to merge 1 commit into
kunaalxoxo wants to merge 1 commit into
Conversation
RubyImporterPipeline previously emitted a separate AffectedPackageV2 for each inverted entry in unaffected_versions. When an advisory had two or more unaffected_versions entries, unfurl_version_range_v2 took their union and marked unaffected releases as affected. Unify all unaffected_versions entries into a single union of intervals before complementing into one affected GemVersionRange, and add unit and unfurl regression tests. Signed-off-by: Kunaal Prabhakar Singh Lala <[email protected]>
This branch has not been deployed
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.
Fixes #2536
Problem
RubyImporterPipeline(get_affected_packagesinvulnerabilities/pipelines/v2_importers/ruby_importer.py) iterated overunaffected_versionsand appended a separateAffectedPackageV2for each inverted entry. When an advisory had two or moreunaffected_versionsentries (such asgems/activerecord/CVE-2016-6317.ymlwith["< 4.2.0", ">= 5.0.0"]),unfurl_version_range_v2took their union acrossImpactedPackagerows and marked unaffected gem releases as affected.Fix
invert_unaffected_versions()and interval helpers to merge allunaffected_versionsentries as a union of safe intervals and take their complement as a single canonicalGemVersionRange.ruby-advisory-dbedge cases including compound/~>ranges, isolated exact-version ranges, single excluded versions (!=), empty complements,None/whitespace entries, andInvalidRequirementError.patched_versionsemittingfixed_version_rangeAffectedPackageV2entries unchanged.Tests
vulnerabilities/tests/pipelines/v2_importers/test_ruby_importer_v2.py(test_get_affected_packages_combines_unaffected_versions).test_ruby_multi_unaffected_versions_unfurl_does_not_mark_unaffectedverifying that4.1.16,5.0.0, and7.1.3are not marked affected forCVE-2016-6317.