Add safe browsing feature to Chrome evaluator
- Implemented `get_enable_safe_browsing` function to retrieve safe browsing settings based on the operating system. - Updated the `__init__.py` to include the new function. - Modified JSON examples to reflect the change from enabling enhanced safety browsing to enabling safe browsing. - Added necessary commands in the JSON examples for setting up preferences for safe browsing.
This commit is contained in:
@@ -16,6 +16,7 @@ from .chrome import (
|
|||||||
get_active_tab_info,
|
get_active_tab_info,
|
||||||
get_enable_do_not_track,
|
get_enable_do_not_track,
|
||||||
get_enable_enhanced_safety_browsing,
|
get_enable_enhanced_safety_browsing,
|
||||||
|
get_enable_safe_browsing,
|
||||||
get_new_startup_page,
|
get_new_startup_page,
|
||||||
get_find_unpacked_extension_path,
|
get_find_unpacked_extension_path,
|
||||||
get_data_delete_automacally,
|
get_data_delete_automacally,
|
||||||
|
|||||||
@@ -1304,6 +1304,40 @@ def get_enable_enhanced_safety_browsing(env, config: Dict[str, str]):
|
|||||||
return "Google"
|
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]):
|
def get_new_startup_page(env, config: Dict[str, str]):
|
||||||
os_type = env.vm_platform
|
os_type = env.vm_platform
|
||||||
if os_type == 'Windows':
|
if os_type == 'Windows':
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"id": "35253b65-1c19-4304-8aa4-6884b8218fc0",
|
"id": "35253b65-1c19-4304-8aa4-6884b8218fc0",
|
||||||
"snapshot": "chrome",
|
"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",
|
"source": "https://www.laptopmag.com/articles/how-to-create-desktop-shortcuts-for-web-pages-using-chrome",
|
||||||
"config": [
|
"config": [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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?",
|
"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.",
|
"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": [
|
"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",
|
"type": "launch",
|
||||||
"parameters": {
|
"parameters": {
|
||||||
@@ -57,7 +71,7 @@
|
|||||||
],
|
],
|
||||||
"func": "exact_match",
|
"func": "exact_match",
|
||||||
"result": {
|
"result": {
|
||||||
"type": "enable_enhanced_safety_browsing"
|
"type": "enable_safe_browsing"
|
||||||
},
|
},
|
||||||
"expected": {
|
"expected": {
|
||||||
"type": "rule",
|
"type": "rule",
|
||||||
|
|||||||
Reference in New Issue
Block a user