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_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,
|
||||
|
||||
@@ -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':
|
||||
|
||||
Reference in New Issue
Block a user