#!/bin/Bashsrc_path=/mnt/source/xx/xx# Merge All specfile forQuick Searchmergedspec="./allspec-"$(Date+%y%m%d). txtfunctionmerge_all_specs () {Allspec=$(Find$SRC _path-name *. Spec) forSpecfileinch$allSpec DoSpecname=$(basename$specFile) Specprefix=${specname%.*} #Echo$specName,Echo${specname%.*} prefix="${specprefix}":"${specfile}:" #Echo$prefix prefix=${prefix//\//\\\/}#Echo$prefixCat$specFile |sed 's/^/' "$prefix"'&/g'>>$mergedSpec Done}if[!-F"$mergedSpec"]; ThenMerge_all_specsfiResultfile=$1-confirmed:>$resultFileCat$1| whileRead Line Do #Echo$LINE |grep-ri CVE#if[$?-ne 0] # Then# continue #fiSA=`Echo$LINE |awk '{print $}'' CVEs=`Echo$LINE |awk '{for (i=2; i<=nf;i++) printf $i ""}'` forCveinch$cves Do #Echo$cvegrep-I $cve $mergedSpec >/dev/NULL 2>&1 if[$?-ne0 ] Then Echo-E"$sa $cve: \ t Pending confirmation" Echo-E"$sa $cve: \ t Pending confirmation">>$resultFileElseRecord=$(grep-ri $cve $mergedSpec) specfile=`Echo${record} |awk-F':' '{print $}'' Comm_dir=`dirname$specFile ' Comm_specfile=`basename$specFile ' Comm=${comm_specfile%.*} #Echo${comm_dir}" -"${comm_specfile}if[!-D"${comm_dir}" ] ThenContinuefipushd ${comm_dir}>/dev/NULL 2>&1 if[-D". Git" ] Thencommitmsg= ' git Blame ${comm_specfile} |grep-I. $CVE |Head-1|awk '{print $}'` #Echo "----ID---"${commitmsg}Else Echo-E"$sa $cve: \tno find git"popd>/dev/NULL 2>&1Continuefipopd>/dev/NULL 2>&1# Remove All space version=`Echo$version |sedS/[[:space:]]//G 'Release= 'Echo$release |sedS/[[:space:]]//G '# Special CasesEcho-E"$sa $cve: \tmerged","\ t"${comm%%:*}-${version##*:}-${release##*:} Echo-E"$sa $cve: \tmerged","\ t"${comm%%:*}-${version##*:}-${release##*:} >>$resultFilefi Done Done
Shell Script Instance