Skip to content
Draft
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
13 changes: 12 additions & 1 deletion lib/omnibus/fetchers/net_fetcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@
# @return [Symbol]
#
def digest_type
if source[:url].to_s.downcase.end_with?(".git")
return nil
end
DIGESTS.each do |digest|
return digest if source.key? digest
end
Expand All @@ -284,10 +287,18 @@
# if the checksum does not match
#
def verify_checksum!
return if digest_type.nil? # skip verification for git urls

log.info(log_key) { "Verifying checksum" }

# Check if the source is a Git repository
if source[:url] =~ %r{git@|https?:\/\/.*\.git}

Check failure

Code scanning / CodeQL

Polynomial regular expression used on uncontrolled data High

This
regular expression
that depends on a
library input
may run slow on strings starting with 'http://' and with many repetitions of 'http://'.
This
regular expression
that depends on a
library input
may run slow on strings starting with 'http://' and with many repetitions of 'http://'.
log.warn(log_key) { "Skipping checksum verification for Git source: #{source[:url]}" }
return
end

expected = checksum
actual = digest(downloaded_file, digest_type)
actual = digest(downloaded_file, digest_type)

if expected != actual
raise ChecksumMismatch.new(self, expected, actual)
Expand Down