From 83d2966432c03a9e0df2f21acfa60e5754cf850f Mon Sep 17 00:00:00 2001 From: Jeremy Nation Date: Sat, 13 Aug 2016 17:06:38 +0000 Subject: [PATCH] Update whitelist cleanup script (issue #4975) --- utils/ruleset-coverage-whitelist-cleanup.sh | 22 ++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/utils/ruleset-coverage-whitelist-cleanup.sh b/utils/ruleset-coverage-whitelist-cleanup.sh index aa09a65ba080..901b5a4230e2 100755 --- a/utils/ruleset-coverage-whitelist-cleanup.sh +++ b/utils/ruleset-coverage-whitelist-cleanup.sh @@ -15,16 +15,20 @@ fi # Run from ruleset folder to simplify sha256sum output cd src/chrome/content/rules WLIST=../../../../utils/ruleset-coverage-whitelist.txt -WLISTFILES=$(cut -f3 -d " " $WLIST) +DELIM=" " -for file in $WLISTFILES; do +while IFS=$DELIM read listed_hash file; do + display_hash=$(echo $listed_hash | cut -c-7) # Remove those that no longer exist if [ ! -f $file ]; then - sed -i "/ $file/d" $WLIST - echo >&2 "Removed $file: file no longer exists" - # Remove those whose hashes no longer match - elif ! grep -q $(sha256sum $file) $WLIST; then - sed -i "/ $file/d" $WLIST - echo >&2 "Removed $file: file no longer matches the whitelist hash" + sed -i "/$listed_hash$DELIM$file/d" $WLIST + echo >&2 "Removed $file ($display_hash): file no longer exists" + else + actual_hash=$(sha256sum $file | cut -c-64) + # Remove those whose hashes do not match + if [ "$listed_hash" != "$actual_hash" ]; then + sed -i "/$listed_hash$DELIM$file/d" $WLIST + echo >&2 "Removed $file ($display_hash): listed hash does not match actual hash" + fi fi -done +done < "$WLIST"