Skip to content

Commit

Permalink
Test the last sorted condition (rather than any) for open endedness
Browse files Browse the repository at this point in the history
  • Loading branch information
errm committed Nov 16, 2017
1 parent 4b4956a commit 47f4629
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion gems/actionpack/CVE-2016-2097.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,5 @@ unaffected_versions:

patched_versions:
- "~> 3.2.22.2"
- "~> 4.1.14, >= 4.1.14.2"
- "~> 4.1.14"
- ">= 4.1.14.2"
2 changes: 1 addition & 1 deletion gems/actionpack/OSVDB-103440.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ description: |
cvss_v2: 5.0

unaffected_versions:
- ~> 4.0.0
- ">= 4.0.0"

patched_versions:
- ">= 3.2.17"
6 changes: 4 additions & 2 deletions spec/gem_example.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@
unaffected_versions = advisory['unaffected_versions'] || []
patched_versions = advisory['patched_versions'] || []

versions = unaffected_versions + patched_versions
versions = (unaffected_versions + patched_versions).sort_by do |v|
Gem::Version.new(v.match(/[0-9.]+\.\d+/)[0])
end

# If a gem is unpatched this test makes no sense
unless patched_versions.none?
expect(versions.any? { |version| version.match(/^>=|^>/)}).to be_truthy
expect(versions.last.match(/^>=|^>/)).to be_truthy
end
end
end
Expand Down

0 comments on commit 47f4629

Please sign in to comment.