Skip to content

Commit bedd76b

Browse files
hellaisLDiazN
andauthored
Oonirun v2.1 (#301)
WIP specification update for OONI Run v2.1 implements ooni/backend#930 --------- Co-authored-by: Luis Díaz <ldiazn98@gmail.com> Co-authored-by: Luis Diaz <41093870+LDiazN@users.noreply.github.com>
1 parent fcbf470 commit bedd76b

File tree

1 file changed

+168
-55
lines changed

1 file changed

+168
-55
lines changed

backends/bk-005-ooni-run-v2.md

Lines changed: 168 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Below are definitions for important components of the system:
1919
with the OONI Probe app installed allows the user to instrument their probe to
2020
run the nettests configured by the link creator. If the OONI Probe app is not
2121
installed, it will display a web page asking them to download the app.
22-
22+
2323
* **OONI Run descriptor** contains the metadata for a specific OONI Run link and
2424
the nettest definitions: what nettests should be run and how they should be
2525
configured (ex. what URLs should be tested)
@@ -125,31 +125,20 @@ An OONI Run link descriptor is a JSON file with the following semantics:
125125
// `array` provides a JSON array of tests to be run.
126126
"nettests":[{
127127

128-
// (optional) `array` provides a JSON array of tests to be run.
128+
// (optional) `array` provides a JSON array of inputs for the specified test.
129129
"inputs": [
130130
"https://example.com/",
131131
"https://ooni.org/"
132132
],
133133

134-
// (optional) `map` options arguments provided to the specified test_name
135-
//
136-
// Note: this field is currently experimental. A future version of the specification
137-
// may modify the field name or its semantics if we discover it needs changes.
138-
"options": {
139-
"HTTP3Enabled": true
140-
},
141-
142-
// (optional) `map` settings which are sent to probe_services for retrieving the inputs vector
143-
// It's possible to reference user configured settings by accessing the
144-
// $settings special variable.
145-
// In particular the content of the backend_options will be sent to the /api/v1/check-in call nested
146-
// under the relative test_name.
147-
//
148-
// Note: this field is currently experimental. A future version of the specification
149-
// may modify the field name or its semantics if we discover it needs changes.
150-
"backend_options": {
151-
"category_codes": "$settings.category_codes"
152-
},
134+
// (optional) `array` provides a richer JSON array containing extra parameters for each input.
135+
// If provided, the length of inputs_extra should match the length of inputs.
136+
"inputs_extra": [{
137+
"category_code": "HUMR",
138+
}],
139+
140+
// (optional) string used to specify during creation that the input list should be dynamically generated. The semantics of each string is up to the backend implementation.
141+
"targets_name": "websites_list_prioritized",
153142

154143
// (optional) `bool` indicates if this test should be run as part of autoruns. Defaults to true.
155144
//
@@ -166,21 +155,30 @@ An OONI Run link descriptor is a JSON file with the following semantics:
166155
"test_name": "web_connectivity"
167156
}, {
168157
"test_name": "openvpn",
169-
"backend_options": {
170-
"provider": "riseupvpn"
171-
},
158+
"inputs": [
159+
"https://riseup-vpn-address.com/"
160+
],
161+
"inputs_extra": [{
162+
"provider": "riseupvpn",
163+
}],
172164
}]
173165
}
174166
```
175167

176-
In particular values starting with the `$settings` prefix should be mapped
177-
based on user-configured preferences in the app. (Note also that this is
178-
currently an experimental feature that we may change in the future.)
168+
In reality there are two different views onto an OONI Run link descriptor. One
169+
is the view from the perspective of the creator and owner of the link, the
170+
second is from the perspective of measurement applications that need to consume
171+
these links.
179172

180-
Currently the following `$settings` are defined:
173+
The reason for this is that certain target lists need to be generated
174+
dynamically and at runtime, while the parameters for generating these dynamic
175+
links are specified by the creator of the link.
181176

182-
* `$settings.category_codes` should be replaced with the list of category codes
183-
the user has enabled (ex. `["HUMR", "NEWS"]`.
177+
A prime example of this would be the OONI Run link for the stock OONI Websites
178+
card. The OONI Run descriptor, as specified from the link creator, is saying
179+
"run the test-lists with weights applied based on coverage", while the mobile
180+
application will then receive a prioritized and sorted list which will change
181+
every time a new run is performed.
184182

185183
Based on the above specification it would be possible to re-implement the cards for the OONI Probe
186184
dashboard as follows.
@@ -197,20 +195,17 @@ dashboard as follows.
197195
"nettests":
198196
[
199197
{
200-
"options": {
201-
"MaxRuntime": "$settings.max_runtime",
202-
},
203-
"backend_settings": {
204-
"category_codes": "$settings.category_codes"
205-
},
198+
"inputs": [
199+
"https://example.com/"
200+
],
201+
"inputs_extra": [{
202+
"category_code": "HUMR",
203+
}],
206204
"is_manual_run_enabled": true,
207205
"is_background_run_enabled": false,
208206
"test_name": "web_connectivity"
209207
},
210208
{
211-
"backend_settings": {
212-
"category_codes": "$settings.category_codes"
213-
},
214209
"is_manual_run_enabled": false,
215210
"is_background_run_enabled": true,
216211
"test_name": "web_connectivity"
@@ -358,7 +353,7 @@ authentication should be handled.
358353
When you `CREATE` a new OONI RUN link, the client sends a HTTP `POST`
359354
request conforming to the following:
360355

361-
`POST /api/v2/oonirun`
356+
`POST /api/v2/oonirun/links`
362357

363358
```JavaScript
364359
{
@@ -389,9 +384,10 @@ request conforming to the following:
389384
"https://example.com/",
390385
"https://ooni.org/"
391386
],
392-
"options": {
393-
"HTTP3Enabled": true,
394-
},
387+
"inputs_extra": [
388+
{},
389+
{}
390+
]
395391
"test_name": "web_connectivity"
396392
},
397393
{
@@ -401,13 +397,20 @@ request conforming to the following:
401397
}
402398
```
403399

400+
The `inputs_extra` field should be a list of JSON objects, with each object
401+
corresponding to an entry in the `inputs` list. This allows you to attach
402+
additional metadata to each input. The `targets_name` field specifies the name
403+
of a predefined target list that will be used to dynamically generate the inputs
404+
list. This name must be recognized by the backend and agreed upon in advance
405+
between the link creator and the backend system.
404406

405407
### Response status code
406408

407409
Upon receiving a request to create a link, the API will respond:
408410

409411
1. SHOULD fail with `4xx` if the request body does not parse, it is not a JSON object,
410-
any required field is missing and/or if any present field has an invalid value.
412+
any required field is missing and/or if any present field has an invalid value. In particular,
413+
note that it will error when `targets_name` and `inputs` are provided at the same time in any nettest
411414

412415
2. if everything is okay, MUST return a `200` response.
413416

@@ -465,7 +468,7 @@ To update an OONI Run Link, the client issues a request compliant the same as th
465468
Below we list the extra fields that are settable from the edit request that are
466469
not settable during CREATE.
467470

468-
`PUT /api/v2/oonirun/{ooni_run_link_id}`
471+
`PUT /api/v2/oonirun/links/{ooni_run_link_id}`
469472

470473
```JavaScript
471474
{
@@ -510,16 +513,16 @@ following JSON body:
510513

511514
## 4.3 GET the OONI Run descriptor
512515

513-
This operation is performed by OONI Probe clients to retrieve the descriptor of
514-
a certain OONI Run link given the ID.
516+
This operation is performed by OONI Probe clients to retrieve the latest
517+
revision for a descriptor of a certain OONI Run link given the ID.
515518

516519
As such, this request does not require any authentication.
517520

518521
### Request
519522

520523
To retrieve an OONI Run link descriptor, the client issues a request compliant with:
521524

522-
`GET /api/v2/oonirun/{oonirun_link_id}`
525+
`GET /api/v2/oonirun/links/{oonirun_link_id}`
523526

524527
### Response status code
525528

@@ -541,7 +544,120 @@ following JSON body:
541544
}
542545
```
543546

544-
## 4.4 LIST the OONI Run descriptors
547+
Note: This endpoint does not compute dynamic test lists. As a result,
548+
nettests with `target_name` will always have an empty `inputs` field.
549+
550+
551+
## 4.4 GET the OONI Run full descriptor by revision
552+
553+
This operation is performed by OONI Probe clients to retrieve the descriptor of
554+
a certain OONI Run link given the ID and revision
555+
556+
As such, this request does not require any authentication.
557+
558+
### Request
559+
560+
To retrieve an OONI Run link descriptor, the client issues a request compliant with:
561+
562+
`GET /api/v2/oonirun/links/{oonirun_link_id}/full-descriptor/{revision}`
563+
564+
### Response status code
565+
566+
Same as 4.3 GET the OONI Run descriptor
567+
568+
### Response body
569+
570+
Same as 4.3 GET the OONI Run descriptor
571+
572+
When the specified OONI Run link contains dynamic targets, the `inputs` list may
573+
contain different targets.
574+
575+
## 4.4 GET the OONI Run engine descriptor revision
576+
577+
This operation is performed by OONI Probe clients to retrieve the engine descriptor of
578+
a certain OONI Run link given the ID and revision
579+
580+
As such, this request does not require any authentication.
581+
582+
This method is used to return just the nettests, revision and date_created
583+
sections of a descriptor to be used by the measurement engine.
584+
585+
When the specified OONI Run link contains dynamic targets, the `inputs` list may
586+
contain different targets.
587+
588+
### Request
589+
590+
To retrieve an OONI Run link descriptor, the client issues a request compliant with:
591+
592+
`POST /api/v2/oonirun/links/{oonirun_link_id}/engine-descriptor/{revision}`
593+
```
594+
{
595+
"is_charging" : true, // `bool` if the probe is charging or not
596+
"run_type" : "manual", // `string` valid options: timed | manual
597+
598+
// The following fields are required for the dynamic tests list calculation
599+
"probe_cc" : "IT", // `string` country code of the probe
600+
"probe_asn" : "AS1234", // `string` ASN for the probe,
601+
"network_type" : "wifi", // `string`
602+
"website_category_codes" : ["NEWS"], // `array` of strings with category codes used for filtering
603+
}
604+
```
605+
Upon receiving this request, the OONI Run backend:
606+
607+
1. SHOULD check whether the `${oonirun_link_id}` exists and return 404 if it does
608+
not.
609+
610+
2. if everything is okay, returns `200` to the client (see below).
611+
612+
A client should also include the following headers to allow the server to
613+
properly generate dynamic target lists:
614+
615+
* `X-OONI-Credentials`: base64 encoded OONI anonymous credentials
616+
617+
The `platform`, `software_name`, `software_name`, `engine_name` and
618+
`engine_version` are encoded inside of the `User-Agent` string using the following
619+
format:
620+
```
621+
<software_name>/<software_version> (<platform>) <engine_name>/<engine_version> (<engine_version_full>)
622+
```
623+
624+
### Response body
625+
626+
In case of success (i.e. `200` response), the OONI Run Service MUST return the
627+
following JSON body:
628+
629+
```JavaScript
630+
{
631+
"revision": "1",
632+
"date_created": ""
633+
"nettests": [
634+
{
635+
// See CREATE response format for other fields
636+
"inputs": [
637+
"https://example.com/"
638+
],
639+
"inputs_extra": [{
640+
"category_code": "HUMR",
641+
}],
642+
"test_name": "web_connectivity"
643+
}
644+
]
645+
}
646+
```
647+
Note: While nettests can't include both `inputs` and `target_name` during creation,
648+
this endpoint may show both since the backend dynamically populates
649+
`inputs` based on `target_name`.
650+
651+
The backend computes dynamic test lists only for this request. Other requests will return an empty `inputs` list.
652+
653+
Additionally, the `Vary` header should specify the list of headers that affect
654+
the response body caching, which are all headers starting with the `X-OONI-`
655+
prefix.
656+
657+
The server might also return an updated version of the submitted anonymous
658+
credentials using the `X-OONI-Credentials` header.
659+
660+
## 4.7 LIST the OONI Run descriptors
545661

546662
This operation is performed by users of the OONI Run platform to list all the existing OONI Run links.
547663

@@ -551,13 +667,10 @@ Authentication for this endpoint is optional.
551667

552668
To retrieve an OONI Run link descriptor, the client issues a request compliant with:
553669

554-
`GET /api/v2/oonirun_links?only_latest=true&only_mine=true&include_archived=true`
670+
`GET /api/v2/oonirun/links?is_mine=true&is_expired=true`
555671

556-
- `only_latest`, boolean flag to filter only by the latest revision of an OONI
557-
Run link. If unset or set to false, it will instead include all revisions as
558-
separate entries.
559-
- `only_mine` , boolean flag to filter only the links of the logged in user. Will only work when the Authentication header is used.
560-
- `include_archived` , boolean flag used to indicate if the listing should include archived links as well.
672+
- `is_mine` , boolean flag to filter only the links of the logged in user. Will only work when the Authentication header is used.
673+
- `is_expired` , boolean flag used to indicate if the listing should include archived links as well.
561674

562675
### Response status code
563676

0 commit comments

Comments
 (0)