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

Fix Loofah version check #1607

Merged
merged 1 commit into from
Jun 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/brakeman/checks/check_sanitize_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ def check_cve_2018_8048
def loofah_vulnerable_cve_2018_8048?
loofah_version = tracker.config.gem_version(:loofah)

loofah_version and loofah_version < "2.2.1"
# 2.2.1 is fix version
loofah_version and version_between?("0.0.0", "2.2.0", loofah_version)
end

def warn_sanitizer_cve cve, link, upgrade_version
Expand Down
18 changes: 18 additions & 0 deletions test/tests/cves.rb
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,24 @@ def test_CVE_2018_3760_sprockets
assert_new 1 # CVE-2018-3760
end

def test_CVE_2018_8048_exact_fix_version
before_rescan_of "Gemfile.lock", "rails5.2" do
replace "Gemfile.lock", "loofah (2.1.1)", "loofah (2.2.1)"
end

assert_version "2.2.1", :loofah
assert_fixed 1
end

def test_CVE_2018_8048_newer_version
before_rescan_of "Gemfile.lock", "rails5.2" do
replace "Gemfile.lock", "loofah (2.1.1)", "loofah (2.10.1)"
end

assert_version "2.10.1", :loofah
assert_fixed 1
end

def test_CVE_2013_0276
before_rescan_of "app/models/protected.rb", "rails2", :collapse_mass_assignment => true do
replace "app/models/protected.rb", "attr_accessible nil", "attr_protected :admin"
Expand Down