* Combined log_directory and log_file to log_path

* Updated documentation

* Fixed tests

* Implemented test, need to change CSP

* Extension logging restored and tested

* Renamed extra to custom_params

* Reverting stackdump changes
This commit is contained in:
Stefan Zabka 2021-04-30 19:38:08 +02:00 коммит произвёл GitHub
Родитель 05e5dcb0a5
Коммит 9943a218ca
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
7 изменённых файлов: 29 добавлений и 3 удалений

Просмотреть файл

@ -9,7 +9,7 @@ repos:
- id: black - id: black
language_version: python3 language_version: python3
- repo: https://github.com/pre-commit/mirrors-mypy - repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.790 rev: v0.812
hooks: hooks:
- id: mypy - id: mypy
additional_dependencies: [pytest] additional_dependencies: [pytest]

Просмотреть файл

@ -53,6 +53,9 @@ async function main() {
config['logger_address'], config['logger_address'],
config['browser_id']); config['browser_id']);
if (config["custom_params"]["pre_instrumentation_code"]) {
eval(config["custom_params"]["pre_instrumentation_code"])
}
if (config["navigation_instrument"]) { if (config["navigation_instrument"]) {
loggingDB.logDebug("Navigation instrumentation enabled"); loggingDB.logDebug("Navigation instrumentation enabled");
let navigationInstrument = new NavigationInstrument(loggingDB); let navigationInstrument = new NavigationInstrument(loggingDB);

Просмотреть файл

@ -13,7 +13,7 @@
"strict_min_version": "60.0" "strict_min_version": "60.0"
} }
}, },
"content_security_policy":"script-src 'self' 'unsafe-eval'; object-src 'self';",
"permissions": [ "permissions": [
"<all_urls>", "<all_urls>",
"webRequest", "webRequest",

Просмотреть файл

@ -111,7 +111,7 @@ this.sockets = class extends ExtensionAPI {
try { try {
let socket = gManager.sendingSocketMap.get(id); let socket = gManager.sendingSocketMap.get(id);
var transport = socketService.createTransport([], host, port, null); var transport = socketService.createTransport([], host, port, null, null);
socket.stream = transport.openOutputStream(1, 4096, 1048575); socket.stream = transport.openOutputStream(1, 4096, 1048575);
socket.bOutputStream.setOutputStream(socket.stream); socket.bOutputStream.setOutputStream(socket.stream);
return true; return true;

Просмотреть файл

@ -103,6 +103,7 @@ class BrowserParams(DataClassJsonMixin):
recovery_tar: Optional[Path] = None recovery_tar: Optional[Path] = None
donottrack: bool = False donottrack: bool = False
tracking_protection: bool = False tracking_protection: bool = False
custom_params: Dict[Any, Any] = field(default_factory=lambda: {})
@dataclass @dataclass

Просмотреть файл

Просмотреть файл

@ -0,0 +1,22 @@
def test_extension_logging(task_manager_creator, default_params, tmp_path):
test_msg = "This is a test message from the extension"
log_path = tmp_path / "openwpm.log"
manager_params, browser_params = default_params
manager_params.log_path = log_path
for browser_param in browser_params:
browser_param.custom_params[
"pre_instrumentation_code"
] = f"""
// Weird name needed due to webpack name mangling
_loggingdb_js__WEBPACK_IMPORTED_MODULE_1__.logWarn("{test_msg}");
"""
task_manager, _ = task_manager_creator((manager_params, browser_params))
task_manager.close()
log_list = []
with open(log_path, "r") as log_file:
for log_line in log_file:
if test_msg in log_line:
log_list.append(log_line)
# We expect to see it once when printing the config and once when printing the log message
assert len(log_line) == 2 * manager_params.num_browsers