Skip to content

Commit

Permalink
Ensure that we don't have a vulnerability from cabal
Browse files Browse the repository at this point in the history
This makes sure we don't get a homepage URL from cabal that's too
long and causes a performance issue leading to a denial of service.

Fixes https://github.com/github/licensed/security/code-scanning/1
  • Loading branch information
dangoor committed Aug 13, 2024
1 parent b83dac6 commit 4ec6b5a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/licensed/sources/cabal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ def package_docs_dirs(package)
# Returns a homepage url that enforces https and removes url fragments
def safe_homepage(homepage)
return unless homepage
# Ensure there's no denial of service issue with a long homepage
# 1000 characters is likely enough for any real project homepage
# See https://github.com/github/licensed/security/code-scanning/1
if homepage.length > 1000
raise ArgumentError, "Input too long"
end
# use https and remove url fragment
homepage.gsub(/http:/, "https:")
.gsub(/#[^?]*\z/, "")
Expand Down

0 comments on commit 4ec6b5a

Please sign in to comment.