Skip to content

Commit

Permalink
When a blockpage isn't country consistent we consider it a "down" mea…
Browse files Browse the repository at this point in the history
…surement
  • Loading branch information
hellais committed Apr 24, 2024
1 parent 207c371 commit 64342c2
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,21 +214,23 @@ def calculate_web_loni(
blocked_key = "dns.confirmed"
blocking_scope = web_analysis.dns_consistency_system_answer_fp_scope
blocked_value = 0.9
down_value = 0.0
if (
web_analysis.dns_consistency_system_is_answer_fp_country_consistent
== True
):
blocked_key = "dns.confirmed.country_consistent"
blocked_value = 1.0
down_value = 0.0
elif (
web_analysis.dns_consistency_system_is_answer_fp_country_consistent
== False
):
# We let the blocked value be slightly less for cases where the fingerprint is not country consistent
# If the fingerprint is not country consistent, we consider it down to avoid false positives
blocked_key = "dns.confirmed.not_country_consistent"
blocked_value = 0.8
ok_value = 0
down_value = 0
down_value = 0.8
blocked_value = 0.2
ok_value = 0.0
elif web_analysis.dns_consistency_system_is_answer_bogon == True:
# Bogons are always fishy, yet we don't know if we see it because
# the site is misconfigured.
Expand Down
1 change: 1 addition & 0 deletions oonipipeline/tests/_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"20240302000048.790188_RU_webconnectivity_e7ffd3bc0f525eb7", # connection reset RU
"20240302000050.000654_SN_webconnectivity_fe4221088fbdcb0a", # nxdomain down
"20240302000305.316064_EG_webconnectivity_397bca9091b07444", # nxdomain blocked, unknown_failure and from the future
"20240309112858.009725_SE_webconnectivity_dce757ef4ec9b6c8", # blockpage for Iran in Sweden
]

SAMPLE_POSTCANS = ["2024030100_AM_webconnectivity.n1.0.tar.gz"]
Expand Down
25 changes: 25 additions & 0 deletions oonipipeline/tests/test_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,3 +435,28 @@ def test_website_web_analysis_nxdomain_blocked(measurements, netinfodb, fingerpr

assert sum(down_dict.values()) < sum(blocked_dict.values())
assert blocked_dict["dns.nxdomain"] > 0.7


def test_website_web_analysis_blocked_inconsistent_country(
measurements, netinfodb, fingerprintdb
):
msmt_path = measurements[
"20240309112858.009725_SE_webconnectivity_dce757ef4ec9b6c8"
]
msmt = load_measurement(msmt_path=msmt_path)
er, web_analysis, web_obs, web_ctrl_obs = make_web_er_from_msmt(
msmt, fingerprintdb=fingerprintdb, netinfodb=netinfodb
)
assert len(web_analysis) == len(web_obs)
assert len(web_ctrl_obs) == 3

assert len(er) == 1
assert er[0].loni_ok_value < 0.2

ok_dict = dict(zip(er[0].loni_ok_keys, er[0].loni_ok_values))
assert ok_dict["dns"] == 0

down_dict = dict(zip(er[0].loni_down_keys, er[0].loni_down_values))
blocked_dict = dict(zip(er[0].loni_blocked_keys, er[0].loni_blocked_values))

assert sum(down_dict.values()) > sum(blocked_dict.values())

0 comments on commit 64342c2

Please sign in to comment.