From acf9176e561d0f4dd312b9ad4891789664b42a62 Mon Sep 17 00:00:00 2001 From: Maxwell Weru Date: Mon, 27 Feb 2023 13:24:35 +0300 Subject: [PATCH] Remove use of blank method in filtering (#540) --- updater/bin/update-script.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/updater/bin/update-script.rb b/updater/bin/update-script.rb index 6639b130..ebbfbd08 100644 --- a/updater/bin/update-script.rb +++ b/updater/bin/update-script.rb @@ -305,14 +305,14 @@ def security_advisories_for(dep) safe_versions = (adv["patched-versions"] || []) + (adv["unaffected-versions"] || []) - # Filter out nil (blank objects) and empty strings which is necessary for situations + # Filter out nil (using .compact), white spaces and empty strings which is necessary for situations # where the API response contains null that is converted to nil, or it is an empty # string. For example, npm package named faker does not have patched version as of 2023-01-16 # See: https://github.com/advisories/GHSA-5w9c-rv96-fr7g for npm package # This ideally fixes # https://github.com/tinglesoftware/dependabot-azure-devops/issues/453#issuecomment-1383587644 - vulnerable_versions = vulnerable_versions.reject(&:blank?).reject(&:empty?) - safe_versions = safe_versions.reject(&:blank?).reject(&:empty?) + vulnerable_versions = vulnerable_versions.compact.reject { |v| v.strip.empty? } + safe_versions = safe_versions.compact.reject { |v| v.strip.empty? } next if vulnerable_versions.empty? && safe_versions.empty? Dependabot::SecurityAdvisory.new(