Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_antivirus_profile_mapi.py

raw symbols SCIP
1 #!/usr/bin/python
2 from __future__ import absolute_import, division, print_function
3 # Copyright 2019-2024 Fortinet, Inc.
4 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
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_mapi
15 short_description: Configure MAPI 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_mapi:
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 emulator:
52 type: str
53 description: Enable/disable the virus emulator.
54 choices: ['disable', 'enable']
55 executables:
56 type: str
57 description: Treat Windows executable files as viruses for the purpose of blocking or monitoring.
58 choices: ['default', 'virus']
59 options:
60 type: list
61 elements: str
62 description: Enable/disable MAPI AntiVirus scanning, monitoring, and quarantine.
63 choices: ['scan', 'quarantine', 'avquery', 'avmonitor']
64 outbreak_prevention:
65 aliases: ['outbreak-prevention']
66 type: str
67 description: Enable FortiGuard Virus Outbreak Prevention service.
68 choices: ['disabled', 'files', 'full-archive', 'disable', 'block', 'monitor']
69 av_scan:
70 aliases: ['av-scan']
71 type: str
72 description: Enable AntiVirus scan service.
73 choices: ['disable', 'monitor', 'block']
74 external_blocklist:
75 aliases: ['external-blocklist']
76 type: str
77 description: Enable external-blocklist.
78 choices: ['disable', 'monitor', 'block']
79 quarantine:
80 type: str
81 description: Enable/disable quarantine for infected files.
82 choices: ['disable', 'enable']
83 fortindr:
84 type: str
85 description: Enable scanning of files by FortiNDR.
86 choices: ['disable', 'block', 'monitor']
87 fortisandbox:
88 type: str
89 description: Enable scanning of files by FortiSandbox.
90 choices: ['disable', 'block', 'monitor']
91 fortiai:
92 type: str
93 description: Enable/disable scanning of files by FortiAI.
94 choices: ['disable', 'monitor', 'block']
95 malware_stream:
96 aliases: ['malware-stream']
97 type: str
98 description: Enable 0-day malware-stream scanning.
99 choices: ['disable', 'monitor', 'block']
100 '''
101
102 EXAMPLES = '''
103 - name: Example playbook (generated based on argument schema)
104 hosts: fortimanagers
105 connection: httpapi
106 gather_facts: false
107 tasks:
108 - name: Configure MAPI AntiVirus options.
109 fortinet.fortimanager.fmgr_antivirus_profile_mapi:
110 # workspace_locking_adom: <global or your adom name>
111 adom: <your own value>
112 profile: <your own value>
113 antivirus_profile_mapi:
114 # archive_block: ["encrypted", "corrupted", "multipart", "nested", "mailbomb",
115 # "unhandled", "partiallycorrupted", "fileslimit", "timeout"]
116 # archive_log: ["encrypted", "corrupted", "multipart", "nested", "mailbomb",
117 # "unhandled", "partiallycorrupted", "fileslimit", "timeout"]
118 # emulator: <value in [disable, enable]>
119 # executables: <value in [default, virus]>
120 # options: ["scan", "quarantine", "avquery", "avmonitor"]
121 # outbreak_prevention: <value in [disabled, files, full-archive, ...]>
122 # av_scan: <value in [disable, monitor, block]>
123 # external_blocklist: <value in [disable, monitor, block]>
124 # quarantine: <value in [disable, enable]>
125 # fortindr: <value in [disable, block, monitor]>
126 # fortisandbox: <value in [disable, block, monitor]>
127 # fortiai: <value in [disable, monitor, block]>
128 # malware_stream: <value in [disable, monitor, block]>
129 '''
130
131 RETURN = '''
132 meta:
133 description: The result of the request.
134 type: dict
135 returned: always
136 contains:
137 request_url:
138 description: The full url requested.
139 returned: always
140 type: str
141 sample: /sys/login/user
142 response_code:
143 description: The status of api request.
144 returned: always
145 type: int
146 sample: 0
147 response_data:
148 description: The api response.
149 type: list
150 returned: always
151 response_message:
152 description: The descriptive message of the api response.
153 type: str
154 returned: always
155 sample: OK.
156 system_information:
157 description: The information of the target system.
158 type: dict
159 returned: always
160 rc:
161 description: The status the request.
162 type: int
163 returned: always
164 sample: 0
165 version_check_warning:
166 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
167 type: list
168 returned: complex
169 '''
170 from ansible.module_utils.basic import AnsibleModule
171 from ansible.module_utils.connection import Connection
172 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
173 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
174
175
176 def main():
177 urls_list = [
178 '/pm/config/adom/{adom}/obj/antivirus/profile/{profile}/mapi',
179 '/pm/config/global/obj/antivirus/profile/{profile}/mapi'
180 ]
181 module_arg_spec = {
182 'adom': {'required': True, 'type': 'str'},
183 'profile': {'required': True, 'type': 'str'},
184 'revision_note': {'type': 'str'},
185 'antivirus_profile_mapi': {
186 'type': 'dict', 'v_range': [['6.0.0', '']],
187 'options': {
188 'archive-block': {
189 'type': 'list',
190 'choices': ['encrypted', 'corrupted', 'multipart', 'nested', 'mailbomb', 'unhandled', 'partiallycorrupted', 'fileslimit', 'timeout'],
191 'elements': 'str'
192 },
193 'archive-log': {
194 'type': 'list',
195 'choices': ['encrypted', 'corrupted', 'multipart', 'nested', 'mailbomb', 'unhandled', 'partiallycorrupted', 'fileslimit', 'timeout'],
196 'elements': 'str'
197 },
198 'emulator': {'choices': ['disable', 'enable'], 'type': 'str'},
199 'executables': {'choices': ['default', 'virus'], 'type': 'str'},
200 'options': {'type': 'list', 'choices': ['scan', 'quarantine', 'avquery', 'avmonitor'], 'elements': 'str'},
201 'outbreak-prevention': {'choices': ['disabled', 'files', 'full-archive', 'disable', 'block', 'monitor'], 'type': 'str'},
202 'av-scan': {'v_range': [['7.0.0', '']], 'choices': ['disable', 'monitor', 'block'], 'type': 'str'},
203 'external-blocklist': {'v_range': [['7.0.0', '']], 'choices': ['disable', 'monitor', 'block'], 'type': 'str'},
204 'quarantine': {'v_range': [['7.0.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
205 'fortindr': {'v_range': [['7.2.0', '']], 'choices': ['disable', 'block', 'monitor'], 'type': 'str'},
206 'fortisandbox': {'v_range': [['7.2.0', '']], 'choices': ['disable', 'block', 'monitor'], 'type': 'str'},
207 'fortiai': {'v_range': [['7.0.1', '']], 'choices': ['disable', 'monitor', 'block'], 'type': 'str'},
208 'malware-stream': {'v_range': [['7.6.3', '']], 'choices': ['disable', 'monitor', 'block'], 'type': 'str'}
209 }
210 }
211 }
212
213 module_option_spec = get_module_arg_spec('partial crud')
214 module_arg_spec.update(module_option_spec)
215 check_galaxy_version(module_arg_spec)
216 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'antivirus_profile_mapi'),
217 supports_check_mode=True)
218 if not module._socket_path:
219 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
220 connection = Connection(module._socket_path)
221 fmgr = NAPIManager('partial crud', module_arg_spec, urls_list,
222 None, 'data', module, connection)
223 fmgr.process_partial_crud()
224 module.exit_json(meta=module.params)
225
226
227 if __name__ == '__main__':
228 main()