diff --git a/desktop_env/evaluators/getters/__init__.py b/desktop_env/evaluators/getters/__init__.py index d4b2cb6..e966d9f 100644 --- a/desktop_env/evaluators/getters/__init__.py +++ b/desktop_env/evaluators/getters/__init__.py @@ -16,6 +16,7 @@ from .chrome import ( get_active_tab_info, get_enable_do_not_track, get_enable_enhanced_safety_browsing, + get_enable_safe_browsing, get_new_startup_page, get_find_unpacked_extension_path, get_data_delete_automacally, diff --git a/desktop_env/evaluators/getters/chrome.py b/desktop_env/evaluators/getters/chrome.py index 7d6d4d7..f498ae9 100644 --- a/desktop_env/evaluators/getters/chrome.py +++ b/desktop_env/evaluators/getters/chrome.py @@ -1304,6 +1304,40 @@ def get_enable_enhanced_safety_browsing(env, config: Dict[str, str]): return "Google" +def get_enable_safe_browsing(env, config: Dict[str, str]): + os_type = env.vm_platform + if os_type == 'Windows': + preference_file_path = env.controller.execute_python_command("""import os; print(os.path.join(os.getenv('LOCALAPPDATA'), + 'Google\\Chrome\\User Data\\Default\\Preferences'))""")['output'].strip() + elif os_type == 'Darwin': + preference_file_path = env.controller.execute_python_command( + "import os; print(os.path.join(os.getenv('HOME'), 'Library/Application Support/Google/Chrome/Default/Preferences'))")[ + 'output'].strip() + elif os_type == 'Linux': + if "arm" in platform.machine(): + preference_file_path = env.controller.execute_python_command( + "import os; print(os.path.join(os.getenv('HOME'), 'snap/chromium/common/chromium/Default/Preferences'))")[ + 'output'].strip() + else: + preference_file_path = env.controller.execute_python_command( + "import os; print(os.path.join(os.getenv('HOME'), '.config/google-chrome/Default/Preferences'))")[ + 'output'].strip() + + else: + raise Exception('Unsupported operating system') + + try: + content = env.controller.get_file(preference_file_path) + data = json.loads(content) + + safebrowsing = data.get('safebrowsing', {}) + is_enhanced = bool(safebrowsing.get('enhanced', False)) + is_enabled = bool(safebrowsing.get('enabled', False)) + return "true" if (is_enhanced or is_enabled) else "false" + except Exception as e: + logger.error(f"Error: {e}") + return "false" + def get_new_startup_page(env, config: Dict[str, str]): os_type = env.vm_platform if os_type == 'Windows': diff --git a/evaluation_examples/examples/chrome/35253b65-1c19-4304-8aa4-6884b8218fc0.json b/evaluation_examples/examples/chrome/35253b65-1c19-4304-8aa4-6884b8218fc0.json index 99d3683..aa2189d 100644 --- a/evaluation_examples/examples/chrome/35253b65-1c19-4304-8aa4-6884b8218fc0.json +++ b/evaluation_examples/examples/chrome/35253b65-1c19-4304-8aa4-6884b8218fc0.json @@ -1,7 +1,7 @@ { "id": "35253b65-1c19-4304-8aa4-6884b8218fc0", "snapshot": "chrome", - "instruction": "Hey, I need a quick way back to this site. Could you whip up a shortcut on my desktop for me?", + "instruction": "Hey, I need a quick way back to this site. Could you whip up a shortcut on my desktop for me using Chrome's built-in feature?", "source": "https://www.laptopmag.com/articles/how-to-create-desktop-shortcuts-for-web-pages-using-chrome", "config": [ { diff --git a/evaluation_examples/examples/chrome/9656a811-9b5b-4ddf-99c7-5117bcef0626.json b/evaluation_examples/examples/chrome/9656a811-9b5b-4ddf-99c7-5117bcef0626.json index 1db5215..c5da75e 100644 --- a/evaluation_examples/examples/chrome/9656a811-9b5b-4ddf-99c7-5117bcef0626.json +++ b/evaluation_examples/examples/chrome/9656a811-9b5b-4ddf-99c7-5117bcef0626.json @@ -4,6 +4,20 @@ "instruction": "I want Chrome to warn me whenever I visit a potentially harmful or unsafe website. Can you enable this safety feature?", "source": "https://www.quora.com/How-do-I-set-the-security-settings-for-the-Google-Chrome-browser-for-the-best-security#:~:text=Enable%20Safe%20Browsing:%20Chrome%20has%20a%20built%2Din,Security%20%3E%20Security%20%3E%20Enable%20Safe%20Browsing.", "config": [ + { + "type": "execute", + "parameters": { + "command": "echo {CLIENT_PASSWORD} | sudo -S apt update -y && echo {CLIENT_PASSWORD} | sudo -S apt install jq -y", + "shell": true + } + }, + { + "type": "execute", + "parameters": { + "command": "mkdir -p /home/user/.config/google-chrome/Default && if [ ! -f /home/user/.config/google-chrome/Default/Preferences ]; then echo '{}' > /home/user/.config/google-chrome/Default/Preferences; fi && cd /home/user/.config/google-chrome/Default && jq '. + {\"safebrowsing\":{\"enabled\":false,\"enhanced\":false}}' Preferences > temp && mv temp Preferences", + "shell": true + } + }, { "type": "launch", "parameters": { @@ -57,7 +71,7 @@ ], "func": "exact_match", "result": { - "type": "enable_enhanced_safety_browsing" + "type": "enable_safe_browsing" }, "expected": { "type": "rule",