-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: introduce support for generating observations for circumvention nettests #48
Draft
DecFox
wants to merge
5
commits into
ooni:main
Choose a base branch
from
DecFox:issue-32-psiphon
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a2d4f02
feat: add support for generating psiphon and facebook_messenger obser…
DecFox 5dfe693
fix: import issues and typos
DecFox cf0e70f
feat: add CircumventionToolObservation and vanilla_tor
DecFox 33e6c3f
Merge branch 'main' into issue-32-psiphon
DecFox 89e39e2
refactor: remove facebook_messenger diff
DecFox File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from dataclasses import dataclass | ||
from typing import List, Optional | ||
from oonidata.compat import add_slots | ||
from oonidata.models.base_model import BaseModel | ||
from oonidata.models.dataformats import ( | ||
DNSQuery, | ||
Failure, | ||
HTTPTransaction, | ||
NetworkEvent, | ||
TLSHandshake, | ||
) | ||
|
||
from .base_measurement import BaseMeasurement | ||
|
||
|
||
@add_slots | ||
@dataclass | ||
class PsiphonTestKeys(BaseModel): | ||
failure: Failure = None | ||
max_runtime: Optional[int] = None | ||
bootstrap_time: Optional[int] = None | ||
|
||
socksproxy: Optional[str] = None | ||
network_events: Optional[List[NetworkEvent]] = None | ||
tls_handshakes: Optional[List[TLSHandshake]] = None | ||
queries: Optional[List[DNSQuery]] = None | ||
requests: Optional[List[HTTPTransaction]] = None | ||
|
||
|
||
@add_slots | ||
@dataclass | ||
class Psiphon(BaseMeasurement): | ||
__test_name__ = "psiphon" | ||
|
||
test_keys: PsiphonTestKeys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from dataclasses import dataclass | ||
from typing import List, Optional | ||
from oonidata.compat import add_slots | ||
from oonidata.models.base_model import BaseModel | ||
from oonidata.models.dataformats import ( | ||
DNSQuery, | ||
Failure, | ||
HTTPTransaction, | ||
NetworkEvent, | ||
TLSHandshake, | ||
) | ||
|
||
from .base_measurement import BaseMeasurement | ||
|
||
|
||
@add_slots | ||
@dataclass | ||
class VanillaTorTestKeys(BaseModel): | ||
failure: Failure = None | ||
error: Optional[str] = None | ||
success: Optional[bool] = None | ||
bootstrap_time: Optional[int] = None | ||
timeout: Optional[int] = None | ||
|
||
tor_logs: Optional[List[str]] = None | ||
tor_progress: Optional[int] = None | ||
tor_progress_tag: Optional[str] = None | ||
tor_progress_summary: Optional[str] = None | ||
tor_version: Optional[str] = None | ||
transport_name: Optional[str] = None | ||
|
||
|
||
@add_slots | ||
@dataclass | ||
class VanillaTor(BaseMeasurement): | ||
__test_name__ = "vanila_tor" | ||
|
||
test_keys: VanillaTorTestKeys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from typing import List, Tuple | ||
from oonidata.models.nettests import Psiphon | ||
from oonidata.models.observations import WebObservation | ||
from oonidata.transforms.nettests.measurement_transformer import MeasurementTransformer | ||
|
||
|
||
class PsiphonTransformer(MeasurementTransformer): | ||
def make_observations(self, msmt: Psiphon) -> Tuple[List[WebObservation]]: | ||
|
||
dns_observations = self.make_dns_observations(msmt.test_keys.queries) | ||
tls_observations = self.make_tls_observations( | ||
msmt.test_keys.tls_handshakes, | ||
msmt.test_keys.network_events | ||
) | ||
http_observations = self.make_http_observations(msmt.test_keys.requests) | ||
|
||
return ( | ||
self.consume_web_observations( | ||
dns_observations=dns_observations, | ||
tls_observations=tls_observations, | ||
http_observations=http_observations, | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import dataclasses | ||
from typing import List, Tuple | ||
from oonidata.models.nettests import VanillaTor | ||
from oonidata.models.observations import CircumventionToolObservation | ||
from oonidata.transforms.nettests.measurement_transformer import MeasurementTransformer | ||
|
||
|
||
class VanillaTorTransformer(MeasurementTransformer): | ||
def make_observations(self, msmt: VanillaTor) -> Tuple[List[CircumventionToolObservation]]: | ||
ct_obs = CircumventionToolObservation( | ||
observation_id=f"{msmt.measurement_uid}_0", | ||
created_at=datetime.utcnow().replace(microsecond=0), | ||
**dataclasses.asdict(self.measurement_meta), | ||
) | ||
|
||
ct_obs.bootstrap_time = msmt.test_keys.bootstrap_time, | ||
ct.tor_failure = msmt.test_keys.failure | ||
ct.tor_error = msmt.test_keys.error | ||
ct.tor_success = msmt.test_keys.success | ||
ct.tor_timeout = msmt.test_keys.timeout | ||
|
||
ct.tor_logs = msmt.test_keys.tor_logs | ||
ct.tor_progress = msmt.test_keys.tor_progress | ||
ct.tor_progress_tag = msmt.test_keys.tor_progress_tag | ||
ct.tor_progress_summary = msmt.test_keys.tor_progress_summary | ||
ct.tor_version = msmt.test_keys.tor_version | ||
ct.tor_transport_name = msmt.test_keys.transport_name | ||
|
||
return ([ct_obs],) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this looks really good, I think we should invest a bit of time to define this Observation data model such that's flexible enough for all future circumvention tools.
Ideally it would be something that can adapt nicely to new circumvention tools as we put them out and it's probably worth checking with @ainghazal what his thoughts are on the topic.
Some of the considerations to keep in mind are the following:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I lack broader context about data design for observations, but in principle, I think I'd go for a generic circumvention observation (with perhaps method family and optional flavor or configuration parameters) rather than a flat observation table that tries to accommodate all of them.
A couple of quick thoughts though:
south
). I guess basically we'd need version and a way to convert semantically equivalent data for each field, plus the ability to mark a change as backwards incompatible (NA before a version cut).is_vpn=True
butproto=wireguard
&&transport=tcp
&&obfuscation=foo
.