Skip to content

Commit 6917dac

Browse files
committed
Downgrade warnings during validations can be less spammy
1 parent 23db4f9 commit 6917dac

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

utils/trivial-validate.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,16 @@ def test_unencrypted_to(tree):
8282
# Now warn if the rule author indicates they intended it, with the
8383
# downgrade attribute. Error if this attribute is not present.
8484
"""Rule redirects to something other than https."""
85+
down_warned = False
8586
for rule in tree.xpath("/ruleset/rule"):
8687
to, downgrade = rule.get("to"), rule.get("downgrade")
8788
if to[:6] != "https:" and to[:5] != "http:":
8889
return False
8990
elif to[:5] == "http:" and downgrade:
90-
sys.stdout.write("warning: downgrade rule in %s redirects " % fi)
91-
sys.stdout.write("to http.\n")
91+
if not down_warned:
92+
sys.stdout.write("warning: downgrade rule in %s redirects " %fi)
93+
sys.stdout.write("to http.\n")
94+
down_warned = True
9295
elif to[:5] == "http:":
9396
sys.stdout.write("error: rule in %s redirects to http and " % fi)
9497
sys.stdout.write("downgrade attribute not specified.\n")

0 commit comments

Comments
 (0)