forked from EFForg/https-everywhere
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathruleset-coverage-whitelist-cleanup.sh
More file actions
executable file
·34 lines (31 loc) · 1.11 KB
/
ruleset-coverage-whitelist-cleanup.sh
File metadata and controls
executable file
·34 lines (31 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
# Remove from ruleset whitelist the filenames of files that
# no longer exist or have no matching hash sums.
# Change directory to git root; taken from ../test/test.sh
if [ -n "$GIT_DIR" ]
then
# $GIT_DIR is set, so we're running as a hook.
cd $GIT_DIR
else
# Git command exists? Cool, let's CD to the right place.
git rev-parse && cd "$(git rev-parse --show-toplevel)"
fi
# Run from ruleset folder to simplify sha256sum output
cd src/chrome/content/rules
WLIST=../../../../utils/ruleset-coverage-whitelist.txt
DELIM=" "
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 "/$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 < "$WLIST"