| 1 |
|
| 2 |
from __future__ import absolute_import, division, print_function |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
__metaclass__ = type |
| 7 |
|
| 8 |
ANSIBLE_METADATA = {'status': ['preview'], |
| 9 |
'supported_by': 'community', |
| 10 |
'metadata_version': '1.1'} |
| 11 |
|
| 12 |
DOCUMENTATION = ''' |
| 13 |
--- |
| 14 |
module: fmgr_antivirus_profile_pop3 |
| 15 |
short_description: Configure POP3 AntiVirus options. |
| 16 |
version_added: "2.0.0" |
| 17 |
extends_documentation_fragment: |
| 18 |
- fortinet.fortimanager.general |
| 19 |
- fortinet.fortimanager.general.partial_crud |
| 20 |
options: |
| 21 |
revision_note: |
| 22 |
description: The change note that can be specified when an object is created or updated. |
| 23 |
type: str |
| 24 |
adom: |
| 25 |
description: The parameter (adom) in requested url. |
| 26 |
type: str |
| 27 |
required: true |
| 28 |
profile: |
| 29 |
description: The parameter (profile) in requested url. |
| 30 |
type: str |
| 31 |
required: true |
| 32 |
antivirus_profile_pop3: |
| 33 |
description: The top level parameters set. |
| 34 |
required: false |
| 35 |
type: dict |
| 36 |
suboptions: |
| 37 |
archive_block: |
| 38 |
aliases: ['archive-block'] |
| 39 |
type: list |
| 40 |
elements: str |
| 41 |
description: Select the archive types to block. |
| 42 |
choices: ['encrypted', 'corrupted', 'multipart', 'nested', 'mailbomb', |
| 43 |
'unhandled', 'partiallycorrupted', 'fileslimit', 'timeout'] |
| 44 |
archive_log: |
| 45 |
aliases: ['archive-log'] |
| 46 |
type: list |
| 47 |
elements: str |
| 48 |
description: Select the archive types to log. |
| 49 |
choices: ['encrypted', 'corrupted', 'multipart', 'nested', 'mailbomb', |
| 50 |
'unhandled', 'partiallycorrupted', 'fileslimit', 'timeout'] |
| 51 |
content_disarm: |
| 52 |
aliases: ['content-disarm'] |
| 53 |
type: str |
| 54 |
description: Enable Content Disarm and Reconstruction for this protocol. |
| 55 |
choices: ['disable', 'enable'] |
| 56 |
emulator: |
| 57 |
type: str |
| 58 |
description: Enable/disable the virus emulator. |
| 59 |
choices: ['disable', 'enable'] |
| 60 |
executables: |
| 61 |
type: str |
| 62 |
description: Treat Windows executable files as viruses for the purpose of blocking or monitoring. |
| 63 |
choices: ['default', 'virus'] |
| 64 |
options: |
| 65 |
type: list |
| 66 |
elements: str |
| 67 |
description: Enable/disable POP3 AntiVirus scanning, monitoring, and quarantine. |
| 68 |
choices: ['scan', 'file-filter', 'quarantine', 'avquery', 'avmonitor'] |
| 69 |
outbreak_prevention: |
| 70 |
aliases: ['outbreak-prevention'] |
| 71 |
type: str |
| 72 |
description: Enable FortiGuard Virus Outbreak Prevention service. |
| 73 |
choices: ['disabled', 'files', 'full-archive', 'disable', 'block', 'monitor'] |
| 74 |
av_scan: |
| 75 |
aliases: ['av-scan'] |
| 76 |
type: str |
| 77 |
description: Enable AntiVirus scan service. |
| 78 |
choices: ['disable', 'monitor', 'block'] |
| 79 |
external_blocklist: |
| 80 |
aliases: ['external-blocklist'] |
| 81 |
type: str |
| 82 |
description: Enable external-blocklist. |
| 83 |
choices: ['disable', 'monitor', 'block'] |
| 84 |
quarantine: |
| 85 |
type: str |
| 86 |
description: Enable/disable quarantine for infected files. |
| 87 |
choices: ['disable', 'enable'] |
| 88 |
fortindr: |
| 89 |
type: str |
| 90 |
description: Enable scanning of files by FortiNDR. |
| 91 |
choices: ['disable', 'block', 'monitor'] |
| 92 |
fortisandbox: |
| 93 |
type: str |
| 94 |
description: Enable scanning of files by FortiSandbox. |
| 95 |
choices: ['disable', 'block', 'monitor'] |
| 96 |
fortiai: |
| 97 |
type: str |
| 98 |
description: Enable/disable scanning of files by FortiAI. |
| 99 |
choices: ['disable', 'monitor', 'block'] |
| 100 |
malware_stream: |
| 101 |
aliases: ['malware-stream'] |
| 102 |
type: str |
| 103 |
description: Enable 0-day malware-stream scanning. |
| 104 |
choices: ['disable', 'monitor', 'block'] |
| 105 |
''' |
| 106 |
|
| 107 |
EXAMPLES = ''' |
| 108 |
- name: Example playbook (generated based on argument schema) |
| 109 |
hosts: fortimanagers |
| 110 |
connection: httpapi |
| 111 |
gather_facts: false |
| 112 |
tasks: |
| 113 |
- name: Configure POP3 AntiVirus options. |
| 114 |
fortinet.fortimanager.fmgr_antivirus_profile_pop3: |
| 115 |
# workspace_locking_adom: <global or your adom name> |
| 116 |
adom: <your own value> |
| 117 |
profile: <your own value> |
| 118 |
antivirus_profile_pop3: |
| 119 |
# archive_block: ["encrypted", "corrupted", "multipart", "nested", "mailbomb", |
| 120 |
# "unhandled", "partiallycorrupted", "fileslimit", "timeout"] |
| 121 |
# archive_log: ["encrypted", "corrupted", "multipart", "nested", "mailbomb", |
| 122 |
# "unhandled", "partiallycorrupted", "fileslimit", "timeout"] |
| 123 |
# content_disarm: <value in [disable, enable]> |
| 124 |
# emulator: <value in [disable, enable]> |
| 125 |
# executables: <value in [default, virus]> |
| 126 |
# options: ["scan", "file-filter", "quarantine", "avquery", "avmonitor"] |
| 127 |
# outbreak_prevention: <value in [disabled, files, full-archive, ...]> |
| 128 |
# av_scan: <value in [disable, monitor, block]> |
| 129 |
# external_blocklist: <value in [disable, monitor, block]> |
| 130 |
# quarantine: <value in [disable, enable]> |
| 131 |
# fortindr: <value in [disable, block, monitor]> |
| 132 |
# fortisandbox: <value in [disable, block, monitor]> |
| 133 |
# fortiai: <value in [disable, monitor, block]> |
| 134 |
# malware_stream: <value in [disable, monitor, block]> |
| 135 |
''' |
| 136 |
|
| 137 |
RETURN = ''' |
| 138 |
meta: |
| 139 |
description: The result of the request. |
| 140 |
type: dict |
| 141 |
returned: always |
| 142 |
contains: |
| 143 |
request_url: |
| 144 |
description: The full url requested. |
| 145 |
returned: always |
| 146 |
type: str |
| 147 |
sample: /sys/login/user |
| 148 |
response_code: |
| 149 |
description: The status of api request. |
| 150 |
returned: always |
| 151 |
type: int |
| 152 |
sample: 0 |
| 153 |
response_data: |
| 154 |
description: The api response. |
| 155 |
type: list |
| 156 |
returned: always |
| 157 |
response_message: |
| 158 |
description: The descriptive message of the api response. |
| 159 |
type: str |
| 160 |
returned: always |
| 161 |
sample: OK. |
| 162 |
system_information: |
| 163 |
description: The information of the target system. |
| 164 |
type: dict |
| 165 |
returned: always |
| 166 |
rc: |
| 167 |
description: The status the request. |
| 168 |
type: int |
| 169 |
returned: always |
| 170 |
sample: 0 |
| 171 |
version_check_warning: |
| 172 |
description: Warning if the parameters used in the playbook are not supported by the current FortiManager version. |
| 173 |
type: list |
| 174 |
returned: complex |
| 175 |
''' |
| 176 |
from ansible.module_utils.basic import AnsibleModule |
| 177 |
from ansible.module_utils.connection import Connection |
| 178 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass |
| 179 |
from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec |
| 180 |
|
| 181 |
|
| 182 |
def main(): |
| 183 |
urls_list = [ |
| 184 |
'/pm/config/adom/{adom}/obj/antivirus/profile/{profile}/pop3', |
| 185 |
'/pm/config/global/obj/antivirus/profile/{profile}/pop3' |
| 186 |
] |
| 187 |
module_arg_spec = { |
| 188 |
'adom': {'required': True, 'type': 'str'}, |
| 189 |
'profile': {'required': True, 'type': 'str'}, |
| 190 |
'revision_note': {'type': 'str'}, |
| 191 |
'antivirus_profile_pop3': { |
| 192 |
'type': 'dict', 'v_range': [['6.0.0', '']], |
| 193 |
'options': { |
| 194 |
'archive-block': { |
| 195 |
'type': 'list', |
| 196 |
'choices': ['encrypted', 'corrupted', 'multipart', 'nested', 'mailbomb', 'unhandled', 'partiallycorrupted', 'fileslimit', 'timeout'], |
| 197 |
'elements': 'str' |
| 198 |
}, |
| 199 |
'archive-log': { |
| 200 |
'type': 'list', |
| 201 |
'choices': ['encrypted', 'corrupted', 'multipart', 'nested', 'mailbomb', 'unhandled', 'partiallycorrupted', 'fileslimit', 'timeout'], |
| 202 |
'elements': 'str' |
| 203 |
}, |
| 204 |
'content-disarm': {'choices': ['disable', 'enable'], 'type': 'str'}, |
| 205 |
'emulator': {'choices': ['disable', 'enable'], 'type': 'str'}, |
| 206 |
'executables': {'choices': ['default', 'virus'], 'type': 'str'}, |
| 207 |
'options': {'type': 'list', 'choices': ['scan', 'file-filter', 'quarantine', 'avquery', 'avmonitor'], 'elements': 'str'}, |
| 208 |
'outbreak-prevention': {'choices': ['disabled', 'files', 'full-archive', 'disable', 'block', 'monitor'], 'type': 'str'}, |
| 209 |
'av-scan': {'v_range': [['7.0.0', '']], 'choices': ['disable', 'monitor', 'block'], 'type': 'str'}, |
| 210 |
'external-blocklist': {'v_range': [['7.0.0', '']], 'choices': ['disable', 'monitor', 'block'], 'type': 'str'}, |
| 211 |
'quarantine': {'v_range': [['7.0.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'}, |
| 212 |
'fortindr': {'v_range': [['7.0.5', '']], 'choices': ['disable', 'block', 'monitor'], 'type': 'str'}, |
| 213 |
'fortisandbox': {'v_range': [['7.2.0', '']], 'choices': ['disable', 'block', 'monitor'], 'type': 'str'}, |
| 214 |
'fortiai': {'v_range': [['7.0.1', '']], 'choices': ['disable', 'monitor', 'block'], 'type': 'str'}, |
| 215 |
'malware-stream': {'v_range': [['7.6.3', '']], 'choices': ['disable', 'monitor', 'block'], 'type': 'str'} |
| 216 |
} |
| 217 |
} |
| 218 |
} |
| 219 |
|
| 220 |
module_option_spec = get_module_arg_spec('partial crud') |
| 221 |
module_arg_spec.update(module_option_spec) |
| 222 |
check_galaxy_version(module_arg_spec) |
| 223 |
module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'antivirus_profile_pop3'), |
| 224 |
supports_check_mode=True) |
| 225 |
if not module._socket_path: |
| 226 |
module.fail_json(msg='MUST RUN IN HTTPAPI MODE') |
| 227 |
connection = Connection(module._socket_path) |
| 228 |
fmgr = NAPIManager('partial crud', module_arg_spec, urls_list, |
| 229 |
None, 'data', module, connection) |
| 230 |
fmgr.process_partial_crud() |
| 231 |
module.exit_json(meta=module.params) |
| 232 |
|
| 233 |
|
| 234 |
if __name__ == '__main__': |
| 235 |
main() |