Anti-Malware: Python Examples
AntiMalwarePolicyExtension example
Create an AntiMalwarePolicyExtension
and set property values to configure the
state, identify the malware scan configurations to use, and the schedule for real-time
scans:
anti_malware_policy_config = api.AntiMalwarePolicyExtension()
anti_malware_policy_config.state = "on"
anti_malware_policy_config.real_time_scan_configuration_id = real_time_scan_config_id
anti_malware_policy_config.real_time_scan_schedule_id = schedule_id
Modify Anti-Malware policy example
Add the AntiMalwarePolicyExtension
object to a Policy
object, and then use a PoliciesApi
object to modify a policy on Deep Security
Manager.
policy = api.Policy()
policy.anti_malware = anti_malware_policy_config
policies_api = api.PoliciesApi(api.ApiClient(configuration))
return policies_api.modify_policy(policy_id, policy, api_version)
The policy_id
(or policyID
) parameter of
modifyPolicy
identifies the actual policy on Deep Security Manager that is to
be modified. This policy is modified according to the policy object that is used as the
policy
parameter. Any properties of the policy
parameter that
are not set remain unchanged on the actual policy.
Complete policy configuration example
The following example creates an AntiMalwarePolicyExtension
object and uses
it to turn on the Anti-Malware module, set the real-time scan configuration to use, and specify
the scan schedule for real-time scans.
# Create and configure the Anti-maware policy
anti_malware_policy_config = api.AntiMalwarePolicyExtension()
anti_malware_policy_config.state = "on"
anti_malware_policy_config.real_time_scan_configuration_id = real_time_scan_config_id
anti_malware_policy_config.real_time_scan_schedule_id = schedule_id
# Add the configuration to the policy
policy = api.Policy()
policy.anti_malware = anti_malware_policy_config
# Modify the policy on Deep Security Manager
policies_api = api.PoliciesApi(api.ApiClient(configuration))
return policies_api.modify_policy(policy_id, policy, api_version)
Example malware scan configuration
The following example sets the directory exclusions for a malware scan configuration and modifies the scan configuration on Deep Security Manager.
# Create an anti-malware scan configuration
real_time_config = api.AntiMalwareConfiguration()
# Set the exclusion
real_time_config.excluded_directory_list_id = dir_list_id
# Modify the anti-malware scan configuration on Deep Security Manager
am_configurations_api = api.AntiMalwareConfigurationsApi(api.ApiClient(configuration))
return am_configurations_api.modify_anti_malware(scan_config_id, real_time_config, api_version)
To use an HTTP client to interact with a malware scan configuration, use the /api/antimalwareconfigurations endpoint. (See the Anti Malware Configurations operations in the API Reference.)