You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+92-23Lines changed: 92 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,41 +4,110 @@ This repository contains all code for our paper `Head(er)s Up! Detecting Securit
4
4
5
5
This repository is a fork of [WPT](https://github.com/web-platform-tests/wpt), the original README can be found [here](./README_original.md).
6
6
All test and analysis code for our paper can be found in the [_hp](./_hp/README.md) directory.
7
-
Our modified version of the wptserve HTTP server implementation can be found in `tools/serve` and `tools/wptserve`. All other directories are untouched and required for `wptserve` to run, we removed the other WPT test directories for better clarity.
7
+
Our modified version of the wptserve HTTP server implementation can be found in the `tools/serve` and `tools/wptserve` directories. All other directories are untouched and required for `wptserve` to run, we removed the other WPT test directories for better clarity.
8
8
9
-
## Setup
10
-
- Create a fresh Ubuntu22 container/VM: `lxc launch ubuntu:22.04 <name>` and connect to it `lxc exec <name> bash`
9
+
## Setup and Start the Header Testing Server
10
+
- Create a fresh Ubuntu22 container/VM: `lxc launch ubuntu:22.04 <name>` and connect to it `lxc exec <name> bash` (Other environments might also work but are not tested)
11
11
- Switch to the ubuntu user: `su - ubuntu`
12
12
- Clone this repository: `git clone [email protected]:header-testing/header-testing.git`
13
13
- Run the setup file: `cd header-testing/_hp`, `./setup.bash` (reopen all terminals or run `source ~/.bashrc` afterwards)
14
-
- Configure DB settings in [config.json](_hp/tools/config.json); Make sure to create a database with the correct name
14
+
- Start a postgres instance somewhere that is reachable from this container.
15
+
- Configure DB settings in [config.json](_hp/hp/tools/config.json); Make sure that a database with the correct name already exists
15
16
- Setup the database: `cd _hp/hp/tools && poetry run python models.py`
16
17
- Setup certs: either remove `.demo` from the files in `_hp/hp/tools/certs/` to use self-signed certs or add your own certs here
18
+
- Create the basic and parsing responses: Run `cd _hp/hp/tools && poetry run python create_responses.py` (basic), run `cd analysis && poetry run jupyter-lab` and execute `response_header_generation.ipynb` to generate the parsing responses.
19
+
- Start the WPT server first (from the top-most folder): `poetry run -C _hp python wpt serve --config _hp/wpt-config.json`
20
+
- Manually check if the server and the tests are working: Visit http://sub.headers.websec.saarland:80/_hp/tests/framing.sub.html and confirm that tests are loaded and executed.
21
+
- Optional: Run tests to check that everything is working correctly: `poetry run -C _hp pytest _hp`
22
+
- (TODO Optional: Change the used domains in [_hp/wpt-config.json](_hp/wpt-config.json) and [_hp/host-config.txt](_hp/host-config.txt); domains are hardcoded at several places and thus this is not enough at the moment.)
17
23
18
-
## Run Instructions
19
-
- Always start the WPT server first (from the top-most folder): `poetry run -C _hp python wpt serve --config _hp/wpt-config.json`
20
-
- Create the basic and parsing responses: Run `cd _hp/hp/tools && poetry run python create_responses.py` (basic), run `cd analysis` and execute `response_header_generation.ipynb` to generate the parsing responses.
21
-
- Manually check if the server and the tests are working: Visit http://sub.headers.websec.saarland:80/_hp/tests/framing.sub.html
22
-
- Automatic testrunners:
23
-
-`cd _hp/hp/tools/crawler`
24
-
- Android: `poetry run python android_intent.py` (TODO: Additional config required; solve android_intent and more?!)
25
-
- MacOS/Ubuntu: `poetry run python desktop_selenium.py` (For a quick test run: `poetry run python desktop_selenium.py --debug_browsers --resp_type debug --ignore_certs`)
26
-
- iPadOS/iOS: `poetry run python desktop_selenium.py ----gen_page_runner --page_runner_json urls.json --max_urls_until_restart 10000"`, then visit the URLs in that file manually
27
-
- TODO: Exact settings of the runs for our experiment:
28
-
- TODO: some information about how to exactly reproduce our results?
29
-
- TODO: repeat to ensure each test has 5x repetitions (`poetry run python create_repeat ...`)
30
-
- ...
31
-
- Optional configuration to run headfull browsers on linux server:
24
+
25
+
## Reproduce or Enhance our Results
26
+
In the following, we describe our to reproduce all our results from the paper.
27
+
By slightly adapting the configuration and updating the used browsers, it is also possible to run our tool chain on new/other browser configurations.
28
+
29
+
### Desktop Browsers (Linux Ubuntu)
30
+
- Execute `cd _hp/hp/tools/crawler`
31
+
- If using self-signed certs, add `--ignore_certs` to all commands.
32
+
- Run the following for a quick test run to check that everything is working: `poetry run python desktop_selenium.py --debug_browsers --resp_type debug`
33
+
- Full run:
34
+
- If the test environment cannot support 50 parallel browsers, reduce the `num_browsers` parameter.
35
+
- Run all basic tests: `for i in {1..5}; do poetry run python desktop_selenium.py --num_browsers 50 --resp_type basic; done`
36
+
- Run all parsing tests: `for i in {1..5}; do poetry run python desktop_selenium.py --num_browsers 50 --resp_type parsing; done`
37
+
- It can happen that some tests do not have 5 results after the above commands due to timeouts and similar, to ensure that all tests have at least 5 results run the below commands.
38
+
- Run missing basic tests: `poetry run python create_repeat.py --selection_str "\"Response\".resp_type = 'basic' and \"Browser\".os = 'Ubuntu 22.04'` and `poetry run python desktop_selenium.py --num_browsers 50 --run_mode repeat --max_urls_until_restart 50`
39
+
- Run missing parsing tests: `poetry run python create_repeat.py --selection_str "\"Response\".resp_type = 'parsing' and \"Browser\".os = 'Ubuntu 22.04'` and `poetry run python desktop_selenium.py --num_browsers 50 --run_mode repeat --max_urls_until_restart 50`
40
+
- Optional configuration to debug headfull browsers on the Ubuntu container:
- Run `cd _hp/hp/tools/analysis && poetry run jupyter-lab`
39
-
- Open `_hp/hp/tools/analysis/main_analysis_desktop_basic+parsing.ipynb`
40
-
- TODO: rename: (Also contains the mobile analysis)
41
-
- TODO: check analysis code and improve
46
+
47
+
### Desktop Browsers (MacOS)
48
+
- Have to be run on a real MacOS device, we used version 17.3 and 17.5 (adjust the browser configuration in `desktop_selenium.py` if using another version).
49
+
- Make sure that the MacOS device can reach the Header Testing server. (Alternatively it could also work to run the header testing server and the database locally on the MacOS device).
50
+
- If using self-signed certs, add `--ignore_certs` to all commands.
51
+
- Execute `cd _hp/hp/tools/crawler`
52
+
- Full run:
53
+
- On the Header Testing Server:
54
+
- Create test-page-runner pages for basic tests: `poetry run python desktop_selenium.py --resp_type basic --gen_page_runner --max_urls_until_restart 100`
55
+
- Create test-page-runner pages for parsing tests: `poetry run python desktop_selenium.py --resp_type parsing --gen_page_runner --max_urls_until_restart 1000`
56
+
- The above two commands output a path similar to `basic-MaxURLs100-MaxResps10-MaxPopups100-53332b.json`, make sure to copy the files to the MacOS device and replace the file name in the following commands.
57
+
- On the MacOS device:
58
+
- Run the basic tests: `for i in {1..5}; do poetry run python desktop_selenium.py --num_browsers 1 --page_runner_json <basic-test-json> --timeout_task 1000; done`
59
+
- Run the parsing tests: `for i in {1..5}; do poetry run python desktop_selenium.py --num_browsers 1 --page_runner_json <parsing-test-json> --timeout_task 10000; done`
60
+
- It can happen that not all tests recorded 5 results, thus run the following to ensure that all tests are executed at least 5 times:
61
+
- For the basic tests: `poetry run python create_repeat.py --selection_str "\"Response\".resp_type = 'basic' and \"Browser\".os != 'Android 11'"` and `poetry run python desktop_selenium.py --num_browsers 1 --run_mode repeat --timeout_task 10000`
62
+
- For the parsing tests: `poetry run python create_repeat.py --selection_str "\"Response\".resp_type = 'parsing' and \"Browser\".os != 'Android 11'"` and `poetry run python desktop_selenium.py --num_browsers 1 --run_mode repeat --timeout_task 10000`
63
+
64
+
### Mobile Browsers (Android)
65
+
- Execute `cd _hp/hp/tools/crawler`
66
+
- To run the tests on Android devices, first some emulators have to be set up and the browsers have to be installed and configured:
- Additional browser config (popups need to be allowed):
71
+
- Chrome: By default, Pop-ups and redirects are blocked. To allow, go to Settings/Site Settings/ Turn on the Pop-Ups and Redirects option
72
+
- Brave: By default, the pop-ups are blocked by the Privacy Shields setting. To enable, go to Settings/Brave Shields & privacy/ Allow all trackers and ads
73
+
- To allow popups, to go about:config, and then set dom.disable_open_during_load to false.
74
+
- The emulators also need to be able to reach the Header Testing server.
75
+
- Issue: currently does not work with the self-signed certs, make sure to have correct certs setup
76
+
- Full run:
77
+
- Run the basic tests: `for i in {1..5}; do timeout 15m poetry run python android_intent.py -browsers chrome -repeat 1 -num_devices 30 -type basic -auto_restart; done` (@Tin can we simply use `-browsers all` or do we have to run it three times?)
78
+
- Run the parsing tests: `for i in {1..5}; do timeout 6h poetry run python android_intent.py -browsers chrome -repeat 1 -num_devices 30 -type parsing -auto_restart; done`
79
+
- Similarly to the other tests, it could happen that not all tests collected 5 results, thus run the following to rerun some tests.
80
+
- Create the repeat file for the basic tests: `poetry run python create_repeat.py --selection_str "\"Response\".resp_type = 'basic' and \"Browser\".os = 'Android 11'"`
81
+
- Run them: `poetry run python android_intent.py -browsers all -repeat 1 -num_devices 30 -url_json repeat.json -auto_restart`
82
+
- Create the repeat file for the parsing tests: `poetry run python create_repeat.py --selection_str "\"Response\".resp_type = 'parsing' and \"Browser\".os = 'Android 11'"`
83
+
- Run them: `poetry run python android_intent.py -browsers all -repeat 1 -num_devices 30 -url_json repeat.json -auto_restart`
84
+
85
+
86
+
### Mobile Browsers (iPadOS)
87
+
- To run the tests on iPadOS a real iPad is required. The iPad also needs to be able to reach the Header Testing Server.
88
+
- Issue: currently does not work with the self-signed certs, make sure tho have correct certs setup
89
+
- On the iPad install Chrome (uses WebKit) and allow popups (Open Settings -> Content-Settings -> Block Pop-Ups -> Off)
90
+
- Full run:
91
+
- On the Header Testing server:
92
+
- Execute `cd _hp/hp/tools/crawler`
93
+
- Add the DB entry: adjust the browser/os version info and then run `poetry run python create_ipados_browser.py` and note the returned browser_id
- Visit the URLs generated by the above commands and add `?browser_id=<browser_id>` to the URL, example: `https://sub.headers.websec.saarland/_hp/tests/test-page-runner-1_ed4f3b-0.html?browser_id=16`
99
+
- To ensure that all tests have at least 5 results run the following:
100
+
- On the server:
101
+
- Generate the repeats: `poetry run python create_repeat.py --selection_str "\"Response\".resp_type = 'parsing' and \"Browser\".os != 'Android 11'"`
102
+
- Create a page-runner URL containing all URLs: `poetry run python create_page_runner_repeats.py --browser_id <browser_id>`
103
+
- On the iPad:
104
+
- Visit the page-runner URL
105
+
106
+
### Analysis:
107
+
- Execute `cd _hp/hp/tools/analysis && poetry run jupyter-lab`
108
+
- Open and run `_hp/hp/tools/analysis/analysis_may_2024.ipynb`
109
+
- Note that the analysis is tailored towards our results from May 2024 and some small changes might be required if run on new data
110
+
- TODO: update with updated browser analysis (e.g., `analysis_august_2024_new_chrome.ipynb`)
42
111
43
112
## Inventory
44
113
-`_hp/`: All test and analysis code for the paper:
0 commit comments