Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_antivirus_profile_http.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_http
15 short_description: Configure HTTP 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_http:
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 options:
61 type: list
62 elements: str
63 description: Enable/disable HTTP AntiVirus scanning, monitoring, and quarantine.
64 choices: ['scan', 'file-filter', 'quarantine', 'avquery', 'avmonitor',
65 'strict-file']
66 outbreak_prevention:
67 aliases: ['outbreak-prevention']
68 type: str
69 description: Enable FortiGuard Virus Outbreak Prevention service.
70 choices: ['disabled', 'files', 'full-archive', 'disable', 'block', 'monitor']
71 av_optimize:
72 aliases: ['av-optimize']
73 type: str
74 description: Enable/disable AV optimization for this protocol.
75 choices: ['disable', 'enable']
76 av_scan:
77 aliases: ['av-scan']
78 type: str
79 description: Enable AntiVirus scan service.
80 choices: ['disable', 'monitor', 'block']
81 external_blocklist:
82 aliases: ['external-blocklist']
83 type: str
84 description: Enable external-blocklist.
85 choices: ['disable', 'monitor', 'block']
86 quarantine:
87 type: str
88 description: Enable/disable quarantine for infected files.
89 choices: ['disable', 'enable']
90 fortindr:
91 type: str
92 description: Enable scanning of files by FortiNDR.
93 choices: ['disable', 'block', 'monitor']
94 fortisandbox:
95 type: str
96 description: Enable scanning of files by FortiSandbox.
97 choices: ['disable', 'block', 'monitor']
98 fortiai:
99 type: str
100 description: Enable/disable scanning of files by FortiAI.
101 choices: ['disable', 'monitor', 'block']
102 unknown_content_encoding:
103 aliases: ['unknown-content-encoding']
104 type: str
105 description: Configure the action the FortiGate unit will take on unknown content-encoding.
106 choices: ['block', 'inspect', 'bypass']
107 malware_stream:
108 aliases: ['malware-stream']
109 type: str
110 description: Enable 0-day malware-stream scanning.
111 choices: ['disable', 'monitor', 'block']
112 '''
113
114 EXAMPLES = '''
115 - name: Example playbook (generated based on argument schema)
116 hosts: fortimanagers
117 connection: httpapi
118 gather_facts: false
119 tasks:
120 - name: Configure HTTP AntiVirus options.
121 fortinet.fortimanager.fmgr_antivirus_profile_http:
122 # workspace_locking_adom: <global or your adom name>
123 adom: <your own value>
124 profile: <your own value>
125 antivirus_profile_http:
126 # archive_block: ["encrypted", "corrupted", "multipart", "nested", "mailbomb",
127 # "unhandled", "partiallycorrupted", "fileslimit", "timeout"]
128 # archive_log: ["encrypted", "corrupted", "multipart", "nested", "mailbomb",
129 # "unhandled", "partiallycorrupted", "fileslimit", "timeout"]
130 # content_disarm: <value in [disable, enable]>
131 # emulator: <value in [disable, enable]>
132 # options: ["scan", "file-filter", "quarantine", "avquery", "avmonitor", "strict-file"]
133 # outbreak_prevention: <value in [disabled, files, full-archive, ...]>
134 # av_optimize: <value in [disable, enable]>
135 # av_scan: <value in [disable, monitor, block]>
136 # external_blocklist: <value in [disable, monitor, block]>
137 # quarantine: <value in [disable, enable]>
138 # fortindr: <value in [disable, block, monitor]>
139 # fortisandbox: <value in [disable, block, monitor]>
140 # fortiai: <value in [disable, monitor, block]>
141 # unknown_content_encoding: <value in [block, inspect, bypass]>
142 # malware_stream: <value in [disable, monitor, block]>
143 '''
144
145 RETURN = '''
146 meta:
147 description: The result of the request.
148 type: dict
149 returned: always
150 contains:
151 request_url:
152 description: The full url requested.
153 returned: always
154 type: str
155 sample: /sys/login/user
156 response_code:
157 description: The status of api request.
158 returned: always
159 type: int
160 sample: 0
161 response_data:
162 description: The api response.
163 type: list
164 returned: always
165 response_message:
166 description: The descriptive message of the api response.
167 type: str
168 returned: always
169 sample: OK.
170 system_information:
171 description: The information of the target system.
172 type: dict
173 returned: always
174 rc:
175 description: The status the request.
176 type: int
177 returned: always
178 sample: 0
179 version_check_warning:
180 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
181 type: list
182 returned: complex
183 '''
184 from ansible.module_utils.basic import AnsibleModule
185 from ansible.module_utils.connection import Connection
186 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
187 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
188
189
190 def main():
191 urls_list = [
192 '/pm/config/adom/{adom}/obj/antivirus/profile/{profile}/http',
193 '/pm/config/global/obj/antivirus/profile/{profile}/http'
194 ]
195 module_arg_spec = {
196 'adom': {'required': True, 'type': 'str'},
197 'profile': {'required': True, 'type': 'str'},
198 'revision_note': {'type': 'str'},
199 'antivirus_profile_http': {
200 'type': 'dict', 'v_range': [['6.0.0', '']],
201 'options': {
202 'archive-block': {
203 'type': 'list',
204 'choices': ['encrypted', 'corrupted', 'multipart', 'nested', 'mailbomb', 'unhandled', 'partiallycorrupted', 'fileslimit', 'timeout'],
205 'elements': 'str'
206 },
207 'archive-log': {
208 'type': 'list',
209 'choices': ['encrypted', 'corrupted', 'multipart', 'nested', 'mailbomb', 'unhandled', 'partiallycorrupted', 'fileslimit', 'timeout'],
210 'elements': 'str'
211 },
212 'content-disarm': {'choices': ['disable', 'enable'], 'type': 'str'},
213 'emulator': {'choices': ['disable', 'enable'], 'type': 'str'},
214 'options': {'type': 'list', 'choices': ['scan', 'file-filter', 'quarantine', 'avquery', 'avmonitor', 'strict-file'], 'elements': 'str'},
215 'outbreak-prevention': {'choices': ['disabled', 'files', 'full-archive', 'disable', 'block', 'monitor'], 'type': 'str'},
216 'av-optimize': {'v_range': [['6.2.0', '7.6.2']], 'choices': ['disable', 'enable'], 'type': 'str'},
217 'av-scan': {'v_range': [['7.0.0', '']], 'choices': ['disable', 'monitor', 'block'], 'type': 'str'},
218 'external-blocklist': {'v_range': [['7.0.0', '']], 'choices': ['disable', 'monitor', 'block'], 'type': 'str'},
219 'quarantine': {'v_range': [['7.0.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
220 'fortindr': {'v_range': [['7.0.5', '']], 'choices': ['disable', 'block', 'monitor'], 'type': 'str'},
221 'fortisandbox': {'v_range': [['7.2.0', '']], 'choices': ['disable', 'block', 'monitor'], 'type': 'str'},
222 'fortiai': {'v_range': [['7.0.1', '']], 'choices': ['disable', 'monitor', 'block'], 'type': 'str'},
223 'unknown-content-encoding': {'v_range': [['7.0.5', '7.0.16'], ['7.2.1', '']], 'choices': ['block', 'inspect', 'bypass'], 'type': 'str'},
224 'malware-stream': {'v_range': [['7.6.3', '']], 'choices': ['disable', 'monitor', 'block'], 'type': 'str'}
225 }
226 }
227 }
228
229 module_option_spec = get_module_arg_spec('partial crud')
230 module_arg_spec.update(module_option_spec)
231 check_galaxy_version(module_arg_spec)
232 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'antivirus_profile_http'),
233 supports_check_mode=True)
234 if not module._socket_path:
235 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
236 connection = Connection(module._socket_path)
237 fmgr = NAPIManager('partial crud', module_arg_spec, urls_list,
238 None, 'data', module, connection)
239 fmgr.process_partial_crud()
240 module.exit_json(meta=module.params)
241
242
243 if __name__ == '__main__':
244 main()