web module

Module to manage Web configuration (Protect -> Web) on Sophos Firewall.

class web.UserActivity(api_client)[source]

Bases: object

Manages User Activities.

create(name, description: str = None, category_list: list[dict] = None, debug: bool = False)[source]

Creates a new User Activity.

Parameters:
  • name (str) – Specify a name for the User Activity. Max 50 chars.

  • description (str, optional) – Specify a description for the User Activity. Defaults to None.

  • category_list (list of dict, optional) –

    List of categories to apply to this User Activity. Defaults to None. Category dict format below:

    Each category dict should contain:
    • id (str): Category Name

    • type (str): Category type. Supports ‘web category’, ‘file type’, or ‘url group’.

get(name=None)[source]

Retrieves User Activities. If name is provided, filters by name. Otherwise, retrieves all policies.

Parameters:

name (str, optional) – Name of the User Activity to filter by. Defaults to None

class web.WebFilterPolicy(api_client)[source]

Bases: object

Manages Web Filter Policies

create(name, default_action, download_file_size_restriction, enable_reporting='Enable', download_file_size_restriction_enabled=None, goog_app_domain_list=None, goog_app_domain_list_enabled=None, youtube_filter_is_strict=None, youtube_filter_enabled=None, enforce_safe_search=None, enforce_image_licensing=None, xff_enabled=None, office_365_tenants_list=None, office_365_directory_id=None, office_365_enabled=None, quota_limit=60, description=None, rules=None, debug: bool = False)[source]

Creates a new web filter policy.

Parameters:
  • name (str) – Specify a name for the Web Filter Policy. Max 50 chars.

  • default_action (str) – Default action of the policy (‘Allow’ or ‘Deny’).

  • download_file_size_restriction (int) – Specify maximum allowed file download size in MB (0-1536).

  • enable_reporting (str, optional) – Select to enable reporting of policy. Defaults to “Enable”. (API Default: Enable)

  • download_file_size_restriction_enabled (str, optional) – Enable (‘1’) or disable (‘0’) checking for maximum allowed file download size. Defaults to None.

  • goog_app_domain_list (str, optional) – Comma-separated list of domains allowed to access Google services. Max 256 chars. Defaults to None.

  • goog_app_domain_list_enabled (str, optional) – Enable (‘1’) or disable (‘0’) specifying domains for Google services. Defaults to None.

  • youtube_filter_is_strict (str, optional) – Adjust the policy used for YouTube Restricted Mode (‘1’ for strict, ‘0’ for moderate). Defaults to None.

  • youtube_filter_enabled (str, optional) – Enable (‘1’) or disable (‘0’) YouTube Restricted Mode. Defaults to None.

  • enforce_safe_search (str, optional) – Enable (‘1’) or disable (‘0’) blocking of pornography and explicit content in search results. Defaults to None.

  • enforce_image_licensing (str, optional) – Enable (‘1’) or disable (‘0’) limiting search results to Creative Commons licensed images. Defaults to None.

  • xff_enabled (str, optional) – Enable (‘1’) or disable (‘0’) X-Forwarded-For header. Defaults to None.

  • office_365_tenants_list (str, optional) – Comma-separated list of domain names and domain IDs allowed to access Microsoft 365. Max 4096 chars. Defaults to None.

  • office_365_directory_id (str, optional) – Domain ID allowed to access the Microsoft 365 service. Max 50 chars. Defaults to None.

  • office_365_enabled (str, optional) – Turn on (‘1’) or off (‘0’) specifying domains/IDs for Microsoft 365. Defaults to None.

  • quota_limit (int, optional) – Maximum allowed time (1-1440 minutes) for browsing restricted web content under quota policy action. Defaults to 60. (API Default: 60)

  • description (str, optional) – Specify Policy description. Max 255 chars. Defaults to None.

  • rules (list of dict, optional) –

    Specify the rules contained in this policy. Defaults to None. See rule list structure below: - categories (list of dict): List of rule categories containing:

    • id (str): Category Name

    • type (str): Category type

    • http_action (str, optional): HTTP action (Allow/Deny). Defaults to Deny.

    • https_action (str, optional): HTTPS action (Allow/Deny). Defaults to Deny.

    • follow_http_action (str, optional): ‘1’ to enable, ‘0’ to disable. Defaults to 1.

    • schedule (str, optional): Schedule name. Defaults to ‘All The Time’

    • policy_rule_enabled (str, optional): ‘1’ to enable, ‘0’ to disable. Defaults to 1.

    • ccl_rule_enabled (str, optional): ‘1’ to enable, ‘0’ to disable. Defaults to 0.

    • user_list (list of str, optional): List of users to apply this rule to. Defaults to None.

get(name=None)[source]

Retrieves web filter policies. If name is provided, filters by name. Otherwise, retrieves all policies.

update(name, default_action=None, enable_reporting=None, download_file_size_restriction=None, download_file_size_restriction_enabled=None, goog_app_domain_list=None, goog_app_domain_list_enabled=None, youtube_filter_is_strict=None, youtube_filter_enabled=None, enforce_safe_search=None, enforce_image_licensing=None, xff_enabled=None, office_365_tenants_list=None, office_365_directory_id=None, office_365_enabled=None, quota_limit=None, description=None, rules=None, rule_action='add', debug: bool = False)[source]

Updates an existing web filter policy. Fetches the existing policy and applies changes only for provided arguments. Handles ‘add’ or ‘replace’ actions for rules. To remove specific rules, use rule_action=’replace’ with the desired final list of rules. The full policy object is sent in the update payload.

Parameters:
  • name (str) – Specify a name for the Web Filter Policy. Max 50 chars. (Mandatory for identification)

  • default_action (str, optional) – Default action of the policy (‘Allow’ or ‘Deny’).

  • enable_reporting (str, optional) – Select to enable reporting of policy.

  • download_file_size_restriction (int, optional) – Specify maximum allowed file download size in MB (0-1536).

  • download_file_size_restriction_enabled (str, optional) – Enable (‘1’) or disable (‘0’) checking for maximum allowed file download size.

  • goog_app_domain_list (str, optional) – Comma-separated list of domains allowed to access Google services. Max 256 chars.

  • goog_app_domain_list_enabled (str, optional) – Enable (‘1’) or disable (‘0’) specifying domains for Google services.

  • youtube_filter_is_strict (str, optional) – Adjust the policy used for YouTube Restricted Mode (‘1’ for strict, ‘0’ for moderate).

  • youtube_filter_enabled (str, optional) – Enable (‘1’) or disable (‘0’) YouTube Restricted Mode.

  • enforce_safe_search (str, optional) – Enable (‘1’) or disable (‘0’) blocking of pornography and explicit content in search results.

  • enforce_image_licensing (str, optional) – Enable (‘1’) or disable (‘0’) limiting search results to Creative Commons licensed images.

  • xff_enabled (str, optional) – Enable (‘1’) or disable (‘0’) X-Forwarded-For header.

  • office_365_tenants_list (str, optional) – Comma-separated list of domain names and domain IDs allowed to access Microsoft 365. Max 4096 chars.

  • office_365_directory_id (str, optional) – Domain ID allowed to access the Microsoft 365 service. Max 50 chars.

  • office_365_enabled (str, optional) – Turn on (‘1’) or off (‘0’) specifying domains/IDs for Microsoft 365.

  • quota_limit (int, optional) – Maximum allowed time (1-1440 minutes) for browsing restricted web content under quota policy action.

  • description (str, optional) – Specify Policy description. Max 255 chars.

  • rules (list of dict, optional) –

    Specify the rules contained in this policy. Defaults to None. See rule list structure below: - categories (list of dict): List of rule categories containing:

    • id (str): Category Name

    • type (str): Category type. Valid options are ‘WebCategory’, ‘FileType’, ‘URLGroup’, or ‘UserActivity’.

    • http_action (str, optional): HTTP action (Allow/Deny). Defaults to Deny.

    • https_action (str, optional): HTTPS action (Allow/Deny). Defaults to Deny.

    • follow_http_action (str, optional): ‘1’ to enable, ‘0’ to disable. Defaults to 1.

    • schedule (str, optional): Schedule name. Defaults to ‘All The Time’

    • policy_rule_enabled (str, optional): ‘1’ to enable, ‘0’ to disable. Defaults to 1.

    • ccl_rule_enabled (str, optional): ‘1’ to enable, ‘0’ to disable. Defaults to 0.

    • user_list (str, optional): List of users to apply this policy to. Defaults to “None”.

  • rule_action (str, optional) – Action for rules (‘add’ or ‘replace’). Defaults to “add”.