Skip to content

Commit 73b74a9

Browse files
committed
Change https2https whitelist to be included in ruleset-whitelist.csv
1 parent 67c5727 commit 73b74a9

File tree

4 files changed

+3791
-3805
lines changed

4 files changed

+3791
-3805
lines changed

test/validations/relaxng/https2https_whitelist.json

Lines changed: 0 additions & 43 deletions
This file was deleted.

test/validations/relaxng/run.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44
import argparse
55
import glob
66
import hashlib
7-
import json
87
import os
98

109
from lxml import etree
1110

1211
parser = argparse.ArgumentParser(description="Validate rulesets against relaxng schema.xml")
1312
parser.add_argument("--source_dir", default="src/chrome/content/rules")
14-
parser.add_argument("--https2https_whitelist", default="test/validations/relaxng/https2https_whitelist.json")
13+
parser.add_argument("--https2https_whitelist", default="utils/ruleset-whitelist.csv")
1514

1615
args = parser.parse_args()
1716

@@ -23,10 +22,14 @@
2322
relaxng_doc_https2https = etree.parse("test/validations/relaxng/schema_https2https.xml")
2423
relaxng_https2https = etree.RelaxNG(relaxng_doc_https2https)
2524

26-
https2https_whitelist = None
25+
https2https_whitelist = {}
2726

28-
with open(args.https2https_whitelist, "r") as file:
29-
https2https_whitelist = json.load(file)
27+
with open(args.https2https_whitelist) as f:
28+
f.readline()
29+
for line in f:
30+
fileHash, _, _, fileSkip, fileName = line.strip().split(",")
31+
if fileSkip == "1":
32+
https2https_whitelist[fileName] = fileHash
3033

3134
exit_code = 0
3235

utils/ruleset-whitelist-cleanup.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@ cd src/chrome/content/rules
1717
WLIST=../../../../utils/ruleset-whitelist.csv
1818
DELIM=","
1919

20-
(read; while IFS=$DELIM read listed_hash coverage_flag fetch_flag file; do
20+
(read; while IFS=$DELIM read listed_hash coverage_flag fetch_flag https_flag file; do
2121
display_hash=$(echo $listed_hash | cut -c-7)
2222
# Remove those that no longer exist
2323
if [ ! -f $file ]; then
24-
sed -i "/$listed_hash$DELIM$coverage_flag$DELIM$fetch_flag$DELIM$file/d" $WLIST
24+
sed -i "/$listed_hash$DELIM$coverage_flag$DELIM$fetch_flag$DELIM$https_flag$DELIM$file/d" $WLIST
2525
echo >&2 "Removed $file ($display_hash): file no longer exists"
26-
elif [ "$coverage_flag" == "0" -a "$fetch_flag" == "0" ]; then
27-
sed -i "/$listed_hash$DELIM$coverage_flag$DELIM$fetch_flag$DELIM$file/d" $WLIST
26+
elif [ "$coverage_flag" == "0" -a "$fetch_flag" == "0" -a "$https_flag" == "0" ]; then
27+
sed -i "/$listed_hash$DELIM$coverage_flag$DELIM$fetch_flag$DELIM$https_flag$DELIM$file/d" $WLIST
2828
echo >&2 "Removed $file ($display_hash): obsolete, all flags set to false"
2929
else
3030
actual_hash=$(sha256sum $file | cut -c-64)
3131
# Remove those whose hashes do not match
3232
if [ "$listed_hash" != "$actual_hash" ]; then
33-
sed -i "/$listed_hash$DELIM$coverage_flag$DELIM$fetch_flag$DELIM$file/d" $WLIST
33+
sed -i "/$listed_hash$DELIM$coverage_flag$DELIM$fetch_flag$DELIM$https_flag$DELIM$file/d" $WLIST
3434
echo >&2 "Removed $file ($display_hash): listed hash does not match actual hash"
3535
fi
3636
fi

0 commit comments

Comments
 (0)