INNER CODE UNIT · Python
verify
WMAL/kodachios · Kodachi-OS-10-stable/open/dock/lib/kodachi_countries.py:172
def verify(path=None):
"""Compare this cache against the Rust function it mirrors."""
path = path or os.environ.get(TOR_RS_ENV)
if not path:
return [("<source>", f"NO SOURCE GIVEN, set {TOR_RS_ENV} or pass a path "
"to tor-switch/src/tor.rs")]
import re
# Same discipline as every other text read in this payload: a source file
# from another tree is a third-party byte stream to this one.
src = open(path, encoding="utf-8", errors="replace").read()
seg = src[src.index("pub async fn get_country_groups"):][:60000]
found = {n: re.findall(r'"([A-Z]{2})"', b) for n, b in re.findall(
r'groups\.insert\(\s*"([a-z0-9\-]+)"\.to_string\(\),\s*vec!\[(.*?)\],\s*\);',
seg, re.S)}
# 9eyes and 14eyes are built by cloning the previous group and extending
# it, so the literal groups.insert parser above cannot see either one.