d57c78bc71
This is how I did it: 1. `git clone https://github.com/ooni/probe-engine internal/engine` 2. ``` (cd internal/engine && git describe --tags) v0.23.0 ``` 3. `nvim go.mod` (merging `go.mod` with `internal/engine/go.mod` 4. `rm -rf internal/.git internal/engine/go.{mod,sum}` 5. `git add internal/engine` 6. `find . -type f -name \*.go -exec sed -i 's@/ooni/probe-engine@/ooni/probe-cli/v3/internal/engine@g' {} \;` 7. `go build ./...` (passes) 8. `go test -race ./...` (temporary failure on RiseupVPN) 9. `go mod tidy` 10. this commit message Once this piece of work is done, we can build a new version of `ooniprobe` that is using `internal/engine` directly. We need to do more work to ensure all the other functionality in `probe-engine` (e.g. making mobile packages) are still WAI. Part of https://github.com/ooni/probe/issues/1335
68 lines
1.8 KiB
Python
Executable File
68 lines
1.8 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
|
|
""" ./QA/hirl.py - main QA script for hirl
|
|
|
|
This script performs a bunch of hirl tests under censored
|
|
network conditions and verifies that the measurement is consistent
|
|
with the expectations, by parsing the resulting JSONL. """
|
|
|
|
import contextlib
|
|
import json
|
|
import os
|
|
import shlex
|
|
import socket
|
|
import subprocess
|
|
import sys
|
|
import time
|
|
import urllib.parse
|
|
|
|
sys.path.insert(0, ".")
|
|
import common
|
|
|
|
|
|
def execute_jafar_and_return_validated_test_keys(ooni_exe, outfile, tag, args):
|
|
""" Executes jafar and returns the validated parsed test keys, or throws
|
|
an AssertionError if the result is not valid. """
|
|
tk = common.execute_jafar_and_miniooni(
|
|
ooni_exe, outfile, "http_invalid_request_line", tag, args
|
|
)
|
|
# TODO(bassosimone): what checks to put here?
|
|
return tk
|
|
|
|
|
|
def hirl_transparent_proxy(ooni_exe, outfile):
|
|
""" Test case where we're passing through a transparent proxy """
|
|
args = ["-iptables-hijack-http-to", "127.0.0.1:80"]
|
|
tk = execute_jafar_and_return_validated_test_keys(
|
|
ooni_exe, outfile, "hirl_transparent_proxy", args,
|
|
)
|
|
count = 0
|
|
for entry in tk["failure_list"]:
|
|
if entry is None:
|
|
count += 1
|
|
elif entry == "eof_error":
|
|
count += 1e03
|
|
else:
|
|
count += 1e06
|
|
assert count == 3002
|
|
assert tk["tampering_list"] == [True, True, True, True, True]
|
|
assert tk["tampering"] == True
|
|
|
|
|
|
def main():
|
|
if len(sys.argv) != 2:
|
|
sys.exit("usage: %s /path/to/ooniprobelegacy-like/binary" % sys.argv[0])
|
|
outfile = "hirl.jsonl"
|
|
ooni_exe = sys.argv[1]
|
|
tests = [
|
|
hirl_transparent_proxy,
|
|
]
|
|
for test in tests:
|
|
test(ooni_exe, outfile)
|
|
time.sleep(7)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|