class Dependabot::Uv::MetadataFinder
def source_from_description
def source_from_description potential_source_urls = [] desc = pypi_listing.dig("info", "description") return unless desc desc.scan(Source::SOURCE_REGEX) do potential_source_urls << Regexp.last_match.to_s end # Looking for a source where the repo name exactly matches the # dependency name match_url = potential_source_urls.find do |url| repo = Source.from_url(url)&.repo repo&.downcase&.end_with?(normalised_dependency_name) end return match_url if match_url # Failing that, look for a source where the full dependency name is # mentioned when the link is followed @source_from_description ||= potential_source_urls.find do |url| full_url = Source.from_url(url)&.url next unless full_url response = Dependabot::RegistryClient.get(url: full_url) next unless response.status == 200 response.body.include?(normalised_dependency_name) end end