Skip to content

Commit

Permalink
Add support for generating summary results for more tests (#738)
Browse files Browse the repository at this point in the history
* Add support for generating summary results for more tests

It's now possible to see from the measurement list if the following
tests presents anomalies:
* http_header_field_manipulation
* http_invalid_request_line
* facebook_messenger
* whatsapp
* vanilla_tor

* Add .DS_Store to gitignore

* Improve debug level output
  • Loading branch information
hellais committed Mar 20, 2017
1 parent 4d84fe4 commit d738d2b
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
*.pyc

ENV/*
Expand Down
2 changes: 1 addition & 1 deletion ooni/backend_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def errback(err, attempts):
# We we will recursively keep trying to perform a request until
# we have reached the retry count.
if attempts < retries:
log.err("Lookup failed. Retrying.")
log.err("Lookup {} failed. Retrying.".format(uri))
attempts += 1
perform_request(attempts)
else:
Expand Down
74 changes: 73 additions & 1 deletion ooni/measurements.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,80 @@ class MeasurementTypes():
supported_tests = [
"web_connectivity",
"http_requests",
"tcp_connect"
"tcp_connect",
"http_invalid_request_line",
"http_header_field_manipulation",
"facebook_messenger",
"whatsapp",
"vanilla_tor"
]

@staticmethod
def vanilla_tor(entry):
result = {}
result['anomaly'] = False
if entry['test_keys'].get('success', None) == False:
result['anomaly'] = True
return result

@staticmethod
def whatsapp(entry):
result = {}
result['anomaly'] = False
for key in ['registration_server_status', 'whatsapp_endpoints_status', 'whatsapp_web_status']:
if entry['test_keys'][key] != 'ok':
result['anomaly'] = True
return result

@staticmethod
def facebook_messenger(entry):
result = {}
result['anomaly'] = False
true_calc_keys = [
'facebook_b_api_dns_consistent',
'facebook_b_api_reachable',
'facebook_b_graph_dns_consistent',
'facebook_b_graph_reachable',
'facebook_edge_dns_consistent',
'facebook_edge_reachable',
'facebook_external_cdn_dns_consistent',
'facebook_external_cdn_reachable',
'facebook_scontent_cdn_dns_consistent',
'facebook_scontent_cdn_reachable',
'facebook_star_dns_consistent',
'facebook_star_reachable',
'facebook_stun_dns_consistent',
# facebook_stun_reachable',
]
false_calc_keys = [
'facebook_tcp_blocking',
'facebook_dns_blocking'
]
for key in false_calc_keys:
if entry['test_keys'][key] == True:
result['anomaly'] = True
for key in true_calc_keys:
if entry['test_keys'][key] == False:
result['anomaly'] = True
return result

@staticmethod
def http_invalid_request_line(entry):
result = {}
result['anomaly'] = False
if entry['test_keys']['tampering'] == True:
result['anomaly'] = True
return result

@staticmethod
def http_header_field_manipulation(entry):
result = {}
result['anomaly'] = False
for t in entry['test_keys'].get('tampering', {}).values():
if t == True:
result['anomaly'] = True
return result

@staticmethod
def web_connectivity(entry):
result = {}
Expand Down

0 comments on commit d738d2b

Please sign in to comment.