Skip to content

Commit 019e281

Browse files
committed
Add ruleset whitelist maintenance script
1 parent c6a7504 commit 019e281

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
# Remove from ruleset whitelist the filenames of files that
3+
# no longer exist or have no matching hash sums.
4+
5+
# Change directory to git root; taken from ../test/test.sh
6+
if [ -n "$GIT_DIR" ]
7+
then
8+
# $GIT_DIR is set, so we're running as a hook.
9+
cd $GIT_DIR
10+
else
11+
# Git command exists? Cool, let's CD to the right place.
12+
git rev-parse && cd "$(git rev-parse --show-toplevel)"
13+
fi
14+
15+
# Run from ruleset folder to simplify sha256sum output
16+
cd src/chrome/content/rules
17+
WLIST=../../../../utils/ruleset-coverage-whitelist.txt
18+
WLISTFILES=$(cut -f3 -d " " $WLIST)
19+
20+
for file in $WLISTFILES; do
21+
# Remove those that no longer exist
22+
if [ ! -f $file ]; then
23+
sed -i "/ $file/d" $WLIST
24+
echo "$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 "$file no longer matches the whitelist hash"
29+
fi
30+
done

0 commit comments

Comments
 (0)