From d016ea043089418a199cac2261da2f6bf5f6455c Mon Sep 17 00:00:00 2001 From: Michal Hocko Date: Mar 22 2024 15:32:05 +0000 Subject: scripts/common-functions: implement cve2sha and sha2cve --- diff --git a/scripts/common-functions b/scripts/common-functions index d606d68..fb45223 100644 --- a/scripts/common-functions +++ b/scripts/common-functions @@ -58,6 +58,28 @@ cve2cvss() echo ${cvss##*:} } +cve2sha() +{ + local arg=$1 + sha="$(cd $VULNS_GIT_PATH; scripts/cve_search $arg 2>/dev/null | cut -d" " -f7)" + + if [ $(echo $sha | wc -c) -eq 41 ] + then + echo $sha + fi +} + +sha2cve() +{ + local arg=$1 + cve_sha="$(cd $VULNS_GIT_PATH; scripts/cve_search $arg 2>/dev/null | cut -d" " -f1,7)" + + if [ $(echo ${cve_sha##* } | wc -c) -eq 41 ] + then + echo ${cve_sha%% *} + fi +} + current_branch() { git branch --show-current