aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-02-13 10:33:41 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-02-13 10:33:41 +0100
commit8e0ac3eeb2f2f64b5e5b2c599aefd32548ae310e (patch)
tree468338a1ae39ca88cad133bca912255c5dd21fc7
parent17f448cef0ca813e9cf4c38c07b6ac3d3cc27107 (diff)
downloadvulns-8e0ac3eeb2f2f64b5e5b2c599aefd32548ae310e.tar.gz
cve_update: only update the files if something changed
Filter out unneeded bippy-VERSION lines, and only update the files if something really changed. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rwxr-xr-xscripts/cve_update33
1 files changed, 32 insertions, 1 deletions
diff --git a/scripts/cve_update b/scripts/cve_update
index 5f9655ca..f519d683 100755
--- a/scripts/cve_update
+++ b/scripts/cve_update
@@ -42,11 +42,42 @@ cd "${DIR}"/../ || exit 1
for id in cve/published/*/*.sha1 ; do
#for id in $(ls cve/published/*/*.sha1) ; do
+ tmp_json=$(mktemp "${TMPDIR}/${SCRIPT}XXXX.json" || exit 1)
+ tmp_mbox=$(mktemp "${TMPDIR}/${SCRIPT}XXXX.mbox" || exit 1)
sha=$(cat "${id}")
cve=$(echo "${id}" | cut -f 1 -d '.' | cut -f 4 -d '/')
root=$(echo "${id}" | cut -f 1 -d '.')
#echo "id=${id} sha=${sha} cve=${cve}"
echo "Updating ${cve}..."
- "${DIR}"/bippy --cve="${cve}" --sha="${sha}" --json="${root}.json" --mbox="${root}.mbox"
+
+ # Create the new json and mbox files
+ "${DIR}"/bippy --cve="${cve}" --sha="${sha}" --json="${tmp_json}" --mbox="${tmp_mbox}"
+
+ # see if the json and/or mbox files actually changed, EXCEPT for the bippy-VERSIONINFO string
+ changed=0
+ diff=$(diff -u "${root}.json" "${tmp_json}" | grep -v "${tmp_json}" | grep -v "${root}.json" | grep -v "bippy-" | grep -v "^@@ " | grep "^+")
+ #echo "diff json=${diff}"
+ if [[ "${diff}" != "" ]] ; then
+ mv -f "${tmp_json}" "${root}.json"
+ echo " Updated ${root}.json"
+ changed=1
+ else
+ rm "${tmp_json}"
+ #echo "diff for json was empty"
+ fi
+
+ diff=$(diff -u "${root}.mbox" "${tmp_mbox}" | grep -v "${tmp_mbox}" | grep -v "${root}.mbox" | grep -v "bippy-" | grep -v "^@@ " | grep "^+")
+ #echo "diff mbox=${diff}"
+ if [[ "${diff}" != "" ]] ; then
+ mv -f "${tmp_mbox}" "${root}.mbox"
+ echo " Updated ${root}.mbox"
+ changed=1
+ else
+ rm "${tmp_mbox}"
+ #echo "diff for mbox was empty"
+ fi
+ if [[ "${changed}" == "0" ]] ; then
+ echo " nothing changed"
+ fi
done