Skip to content
This repository was archived by the owner on Nov 6, 2023. It is now read-only.

Commit 1dcbae7

Browse files
authored
Amend check rules python for Fetch Test (#18865)
* Amend Rule Checker - More granular detail like time and if whole ruleset was disabled - Amend the config to check for TLS 1.2 or above * Amend message for disabling rulesets in both cases * Change variable name to be more consistent * Adjust timestamp
1 parent 735f234 commit 1dcbae7

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

test/rules/disable-broken-rulesets.checker.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ read_timeout = 30
1818
redirect_depth = 10
1919
threads = 20
2020
fetch_in_subprocess = false
21+
ssl_version = TLSv1_2
2122

2223
[log]
2324
logfile = -

test/rules/src/https_everywhere_checker/check_rules.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
import urllib.parse
2424
from rules import Ruleset
2525
from rule_trie import RuleTrie
26+
from datetime import datetime
2627

28+
timestamp = datetime.now().replace(microsecond=0)
2729

2830
def convertLoglevel(levelString):
2931
"""Converts string 'debug', 'info', etc. into corresponding
@@ -143,7 +145,7 @@ def fetchUrl(self, plainUrl, transformedUrl, fetcherPlain, fetcherRewriting, rul
143145
except Exception as e:
144146
errno, message = e.args
145147
if errno == 6:
146-
message = "Fetch error: {} => {}: {}".format(
148+
message = "Time: {}\n Fetch error: {} => {}: {}".format(timestamp,
147149
plainUrl, transformedUrl, e)
148150
self.queue_result("error", "fetch-error {}".format(e),
149151
ruleFname, plainUrl, https_url=transformedUrl)
@@ -226,11 +228,13 @@ def disableRuleset(ruleset, problemRules, urlCount):
226228
# Go ahead and disable rulset if all targets are problematic
227229
if urlCount == len(problemRules):
228230
logging.info("Disabling ruleset {}".format(ruleset.filename))
231+
disableMessage = "Entire ruleset disabled at {}\n".format(timestamp)
229232
contents = re.sub("(<ruleset [^>]*)>",
230233
"\\1 default_off=\"failed ruleset test\">", contents);
231234
# If not all targets, just the target
232235
else:
233236
for rule in rules:
237+
disableMessage = "The following targets have been disabled at {}:\n".format(timestamp)
234238
host = urllib.parse.urlparse(rule)
235239
logging.info("Disabling target {}".format(host.netloc))
236240
contents = re.sub('<[ \n]*target[ \n]+host[ \n]*=[ \n]*"{}"[ \n]*\/?[ \n]*>'.format(host.netloc),
@@ -245,9 +249,9 @@ def disableRuleset(ruleset, problemRules, urlCount):
245249
contents = "<!--\n-->\n" + contents
246250
problemStatement = ("""
247251
<!--
248-
Disabled by https-everywhere-checker because:
249252
{}
250-
""".format("\n".join(problems)))
253+
{}
254+
""".format(disableMessage, "\n".join(problems)))
251255
contents = re.sub("^<!--", problemStatement, contents)
252256
with open(ruleset.filename, "w") as f:
253257
f.write(contents)

0 commit comments

Comments
 (0)