Skip to content

Commit 59a61cb

Browse files
authored
Merge pull request EFForg#6246 from jeremyn/update-whitelist-cleanup-script-issue-4975
Update whitelist cleanup script (issue EFForg#4975)
2 parents 3848f11 + 83d2966 commit 59a61cb

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

utils/ruleset-coverage-whitelist-cleanup.sh

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,20 @@ fi
1515
# Run from ruleset folder to simplify sha256sum output
1616
cd src/chrome/content/rules
1717
WLIST=../../../../utils/ruleset-coverage-whitelist.txt
18-
WLISTFILES=$(cut -f3 -d " " $WLIST)
18+
DELIM=" "
1919

20-
for file in $WLISTFILES; do
20+
while IFS=$DELIM read listed_hash file; do
21+
display_hash=$(echo $listed_hash | cut -c-7)
2122
# Remove those that no longer exist
2223
if [ ! -f $file ]; then
23-
sed -i "/ $file/d" $WLIST
24-
echo >&2 "Removed $file: file no longer exists"
25-
# Remove those whose hashes no longer match
26-
elif ! grep -q $(sha256sum $file) $WLIST; then
27-
sed -i "/ $file/d" $WLIST
28-
echo >&2 "Removed $file: file no longer matches the whitelist hash"
24+
sed -i "/$listed_hash$DELIM$file/d" $WLIST
25+
echo >&2 "Removed $file ($display_hash): file no longer exists"
26+
else
27+
actual_hash=$(sha256sum $file | cut -c-64)
28+
# Remove those whose hashes do not match
29+
if [ "$listed_hash" != "$actual_hash" ]; then
30+
sed -i "/$listed_hash$DELIM$file/d" $WLIST
31+
echo >&2 "Removed $file ($display_hash): listed hash does not match actual hash"
32+
fi
2933
fi
30-
done
34+
done < "$WLIST"

0 commit comments

Comments
 (0)