"128.0.0.1",
"::1",
"0.0.0.0 128.0.0.2",
- "0.0.0 google",
- "0.1.2.3.4 foo/bar",
+ "0.1.2.3 foo/bar",
"0.0.0.0 https",
"0.0.0.0 https..",
]:
def test_two_ips(self):
for target_ip in ("0.0.0.0", "127.0.0.1", "8.8.8.8"):
rule = "127.0.0.1 11.22.33.44 foo"
- expected = ("11.22.33.44", str(target_ip) + " 11.22.33.44\n")
actual = normalize_rule(
rule, target_ip=target_ip, keep_domain_comments=False
)
- self.assertEqual(actual, expected)
+ self.assertEqual(actual, (None, None))
- # Nothing gets printed if there's a match.
output = sys.stdout.getvalue()
- self.assertEqual(output, "")
+
+ expected = "==>" + rule + "<=="
+ self.assertIn(expected, output)
sys.stdout = StringIO()
is_ip(hostname)
or re.search(static_ip_regex, hostname)
or "." not in hostname
+ or ".." in hostname
or ":" in hostname
):
# Example: 0.0.0.0 127.0.0.1
if (
not re.search(static_ip_regex, split_rule[0])
and ":" not in split_rule[0]
+ and ".." not in split_rule[0]
and "." in split_rule[0]
):
- # Deny anything that looks like an IP & doesn't container dots.
+ # Deny anything that looks like an IP; doesn't container dots or INVALID.
try:
hostname, suffix = split_rule