Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_profileprotocoloptions_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_firewall_profileprotocoloptions_http
15 short_description: Configure HTTP protocol 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-protocol-options:
29 description: Deprecated, please use "profile_protocol_options"
30 type: str
31 profile_protocol_options:
32 description: The parameter (profile-protocol-options) in requested url.
33 type: str
34 firewall_profileprotocoloptions_http:
35 description: The top level parameters set.
36 required: false
37 type: dict
38 suboptions:
39 block_page_status_code:
40 aliases: ['block-page-status-code']
41 type: int
42 description: Code number returned for blocked HTTP pages
43 comfort_amount:
44 aliases: ['comfort-amount']
45 type: int
46 description: Amount of data to send in a transmission for client comforting
47 comfort_interval:
48 aliases: ['comfort-interval']
49 type: int
50 description: Period of time between start, or last transmission, and the next client comfort transmission of data
51 fortinet_bar:
52 aliases: ['fortinet-bar']
53 type: str
54 description: Enable/disable Fortinet bar on HTML content.
55 choices: ['disable', 'enable']
56 fortinet_bar_port:
57 aliases: ['fortinet-bar-port']
58 type: int
59 description: Port for use by Fortinet Bar
60 http_policy:
61 aliases: ['http-policy']
62 type: str
63 description: Enable/disable HTTP policy check.
64 choices: ['disable', 'enable']
65 inspect_all:
66 aliases: ['inspect-all']
67 type: str
68 description: Enable/disable the inspection of all ports for the protocol.
69 choices: ['disable', 'enable']
70 options:
71 type: list
72 elements: str
73 description: One or more options that can be applied to the session.
74 choices: ['oversize', 'chunkedbypass', 'clientcomfort', 'no-content-summary',
75 'servercomfort']
76 oversize_limit:
77 aliases: ['oversize-limit']
78 type: int
79 description: Maximum in-memory file size that can be scanned
80 ports:
81 type: raw
82 description: (list) Ports to scan for content
83 post_lang:
84 aliases: ['post-lang']
85 type: list
86 elements: str
87 description: ID codes for character sets to be used to convert to UTF-8 for banned words and DLP on HTTP posts
88 choices: ['jisx0201', 'jisx0208', 'jisx0212', 'gb2312', 'ksc5601-ex', 'euc-jp',
89 'sjis', 'iso2022-jp', 'iso2022-jp-1', 'iso2022-jp-2', 'euc-cn',
90 'ces-gbk', 'hz', 'ces-big5', 'euc-kr', 'iso2022-jp-3', 'iso8859-1',
91 'tis620', 'cp874', 'cp1252', 'cp1251']
92 range_block:
93 aliases: ['range-block']
94 type: str
95 description: Enable/disable blocking of partial downloads.
96 choices: ['disable', 'enable']
97 retry_count:
98 aliases: ['retry-count']
99 type: int
100 description: Number of attempts to retry HTTP connection
101 scan_bzip2:
102 aliases: ['scan-bzip2']
103 type: str
104 description: Enable/disable scanning of BZip2 compressed files.
105 choices: ['disable', 'enable']
106 status:
107 type: str
108 description: Enable/disable the active status of scanning for this protocol.
109 choices: ['disable', 'enable']
110 streaming_content_bypass:
111 aliases: ['streaming-content-bypass']
112 type: str
113 description: Enable/disable bypassing of streaming content from buffering.
114 choices: ['disable', 'enable']
115 strip_x_forwarded_for:
116 aliases: ['strip-x-forwarded-for']
117 type: str
118 description: Enable/disable stripping of HTTP X-Forwarded-For header.
119 choices: ['disable', 'enable']
120 switching_protocols:
121 aliases: ['switching-protocols']
122 type: str
123 description: Bypass from scanning, or block a connection that attempts to switch protocol.
124 choices: ['bypass', 'block']
125 uncompressed_nest_limit:
126 aliases: ['uncompressed-nest-limit']
127 type: int
128 description: Maximum nested levels of compression that can be uncompressed and scanned
129 uncompressed_oversize_limit:
130 aliases: ['uncompressed-oversize-limit']
131 type: int
132 description: Maximum in-memory uncompressed file size that can be scanned
133 tcp_window_maximum:
134 aliases: ['tcp-window-maximum']
135 type: int
136 description: Maximum dynamic TCP window size
137 tcp_window_minimum:
138 aliases: ['tcp-window-minimum']
139 type: int
140 description: Minimum dynamic TCP window size
141 tcp_window_size:
142 aliases: ['tcp-window-size']
143 type: int
144 description: Set TCP static window size
145 tcp_window_type:
146 aliases: ['tcp-window-type']
147 type: str
148 description: Specify type of TCP window to use for this protocol.
149 choices: ['system', 'static', 'dynamic', 'auto-tuning']
150 ssl_offloaded:
151 aliases: ['ssl-offloaded']
152 type: str
153 description: SSL decryption and encryption performed by an external device.
154 choices: ['no', 'yes']
155 stream_based_uncompressed_limit:
156 aliases: ['stream-based-uncompressed-limit']
157 type: int
158 description: Maximum stream-based uncompressed data size that will be scanned
159 proxy_after_tcp_handshake:
160 aliases: ['proxy-after-tcp-handshake']
161 type: str
162 description: Proxy traffic after the TCP 3-way handshake has been established
163 choices: ['disable', 'enable']
164 tunnel_non_http:
165 aliases: ['tunnel-non-http']
166 type: str
167 description: Configure how to process non-HTTP traffic when a profile configured for HTTP traffic accepts a non-HTTP session.
168 choices: ['disable', 'enable']
169 unknown_http_version:
170 aliases: ['unknown-http-version']
171 type: str
172 description: How to handle HTTP sessions that do not comply with HTTP 0.
173 choices: ['best-effort', 'reject', 'tunnel']
174 address_ip_rating:
175 aliases: ['address-ip-rating']
176 type: str
177 description: Enable/disable IP based URL rating.
178 choices: ['disable', 'enable']
179 h2c:
180 type: str
181 description: Enable/disable h2c HTTP connection upgrade.
182 choices: ['disable', 'enable']
183 verify_dns_for_policy_matching:
184 aliases: ['verify-dns-for-policy-matching']
185 type: str
186 description: Enable/disable verification of DNS for policy matching.
187 choices: ['disable', 'enable']
188 unknown_content_encoding:
189 aliases: ['unknown-content-encoding']
190 type: str
191 description: Configure the action the FortiGate unit will take on unknown content-encoding.
192 choices: ['block', 'inspect', 'bypass']
193 domain_fronting:
194 aliases: ['domain-fronting']
195 type: str
196 description: Configure HTTP domain fronting
197 choices: ['block', 'monitor', 'allow', 'disable', 'enable', 'strict']
198 http_0_9:
199 aliases: ['http-0.9']
200 type: str
201 description: Configure action to take upon receipt of HTTP 0.
202 choices: ['block', 'allow']
203 dns_protection:
204 aliases: ['dns-protection']
205 type: str
206 description: Enable/disable DNS protection for HTTP/HTTPS traffic.
207 choices: ['disable', 'enable']
208 encrypted_file:
209 aliases: ['encrypted-file']
210 type: str
211 description: Encrypted file.
212 choices: ['block', 'pass', 'inspect']
213 encrypted_file_log:
214 aliases: ['encrypted-file-log']
215 type: str
216 description: Encrypted file log.
217 choices: ['disable', 'enable']
218 '''
219
220 EXAMPLES = '''
221 - name: Example playbook (generated based on argument schema)
222 hosts: fortimanagers
223 connection: httpapi
224 gather_facts: false
225 tasks:
226 - name: Configure HTTP protocol options.
227 fortinet.fortimanager.fmgr_firewall_profileprotocoloptions_http:
228 # workspace_locking_adom: <global or your adom name>
229 adom: <your own value>
230 profile_protocol_options: <your own value>
231 firewall_profileprotocoloptions_http:
232 # block_page_status_code: <integer>
233 # comfort_amount: <integer>
234 # comfort_interval: <integer>
235 # fortinet_bar: <value in [disable, enable]>
236 # fortinet_bar_port: <integer>
237 # http_policy: <value in [disable, enable]>
238 # inspect_all: <value in [disable, enable]>
239 # options: ["oversize", "chunkedbypass", "clientcomfort", "no-content-summary",
240 # "servercomfort"]
241 # oversize_limit: <integer>
242 # ports: <list or integer>
243 # post_lang: ["jisx0201", "jisx0208", "jisx0212", "gb2312", "ksc5601-ex", "euc-jp",
244 # "sjis", "iso2022-jp", "iso2022-jp-1", "iso2022-jp-2", "euc-cn", "ces-gbk",
245 # "hz", "ces-big5", "euc-kr", "iso2022-jp-3", "iso8859-1", "tis620",
246 # "cp874", "cp1252", "cp1251"]
247 # range_block: <value in [disable, enable]>
248 # retry_count: <integer>
249 # scan_bzip2: <value in [disable, enable]>
250 # status: <value in [disable, enable]>
251 # streaming_content_bypass: <value in [disable, enable]>
252 # strip_x_forwarded_for: <value in [disable, enable]>
253 # switching_protocols: <value in [bypass, block]>
254 # uncompressed_nest_limit: <integer>
255 # uncompressed_oversize_limit: <integer>
256 # tcp_window_maximum: <integer>
257 # tcp_window_minimum: <integer>
258 # tcp_window_size: <integer>
259 # tcp_window_type: <value in [system, static, dynamic, ...]>
260 # ssl_offloaded: <value in [no, yes]>
261 # stream_based_uncompressed_limit: <integer>
262 # proxy_after_tcp_handshake: <value in [disable, enable]>
263 # tunnel_non_http: <value in [disable, enable]>
264 # unknown_http_version: <value in [best-effort, reject, tunnel]>
265 # address_ip_rating: <value in [disable, enable]>
266 # h2c: <value in [disable, enable]>
267 # verify_dns_for_policy_matching: <value in [disable, enable]>
268 # unknown_content_encoding: <value in [block, inspect, bypass]>
269 # domain_fronting: <value in [block, monitor, allow, ...]>
270 # http_0_9: <value in [block, allow]>
271 # dns_protection: <value in [disable, enable]>
272 # encrypted_file: <value in [block, pass, inspect]>
273 # encrypted_file_log: <value in [disable, enable]>
274 '''
275
276 RETURN = '''
277 meta:
278 description: The result of the request.
279 type: dict
280 returned: always
281 contains:
282 request_url:
283 description: The full url requested.
284 returned: always
285 type: str
286 sample: /sys/login/user
287 response_code:
288 description: The status of api request.
289 returned: always
290 type: int
291 sample: 0
292 response_data:
293 description: The api response.
294 type: list
295 returned: always
296 response_message:
297 description: The descriptive message of the api response.
298 type: str
299 returned: always
300 sample: OK.
301 system_information:
302 description: The information of the target system.
303 type: dict
304 returned: always
305 rc:
306 description: The status the request.
307 type: int
308 returned: always
309 sample: 0
310 version_check_warning:
311 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
312 type: list
313 returned: complex
314 '''
315 from ansible.module_utils.basic import AnsibleModule
316 from ansible.module_utils.connection import Connection
317 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
318 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
319
320
321 def main():
322 urls_list = [
323 '/pm/config/adom/{adom}/obj/firewall/profile-protocol-options/{profile-protocol-options}/http',
324 '/pm/config/global/obj/firewall/profile-protocol-options/{profile-protocol-options}/http'
325 ]
326 module_arg_spec = {
327 'adom': {'required': True, 'type': 'str'},
328 'profile-protocol-options': {'type': 'str', 'api_name': 'profile_protocol_options'},
329 'profile_protocol_options': {'type': 'str'},
330 'revision_note': {'type': 'str'},
331 'firewall_profileprotocoloptions_http': {
332 'type': 'dict', 'v_range': [['6.0.0', '']],
333 'options': {
334 'block-page-status-code': {'type': 'int'},
335 'comfort-amount': {'type': 'int'},
336 'comfort-interval': {'type': 'int'},
337 'fortinet-bar': {'choices': ['disable', 'enable'], 'type': 'str'},
338 'fortinet-bar-port': {'type': 'int'},
339 'http-policy': {'v_range': [['6.0.0', '7.2.1']], 'choices': ['disable', 'enable'], 'type': 'str'},
340 'inspect-all': {'choices': ['disable', 'enable'], 'type': 'str'},
341 'options': {
342 'type': 'list',
343 'choices': ['oversize', 'chunkedbypass', 'clientcomfort', 'no-content-summary', 'servercomfort'],
344 'elements': 'str'
345 },
346 'oversize-limit': {'type': 'int'},
347 'ports': {'type': 'raw'},
348 'post-lang': {
349 'type': 'list',
350 'choices': [
351 'jisx0201', 'jisx0208', 'jisx0212', 'gb2312', 'ksc5601-ex', 'euc-jp', 'sjis', 'iso2022-jp', 'iso2022-jp-1', 'iso2022-jp-2',
352 'euc-cn', 'ces-gbk', 'hz', 'ces-big5', 'euc-kr', 'iso2022-jp-3', 'iso8859-1', 'tis620', 'cp874', 'cp1252', 'cp1251'
353 ],
354 'elements': 'str'
355 },
356 'range-block': {'choices': ['disable', 'enable'], 'type': 'str'},
357 'retry-count': {'type': 'int'},
358 'scan-bzip2': {'choices': ['disable', 'enable'], 'type': 'str'},
359 'status': {'choices': ['disable', 'enable'], 'type': 'str'},
360 'streaming-content-bypass': {'choices': ['disable', 'enable'], 'type': 'str'},
361 'strip-x-forwarded-for': {'choices': ['disable', 'enable'], 'type': 'str'},
362 'switching-protocols': {'choices': ['bypass', 'block'], 'type': 'str'},
363 'uncompressed-nest-limit': {'type': 'int'},
364 'uncompressed-oversize-limit': {'type': 'int'},
365 'tcp-window-maximum': {'v_range': [['6.2.0', '']], 'type': 'int'},
366 'tcp-window-minimum': {'v_range': [['6.2.0', '']], 'type': 'int'},
367 'tcp-window-size': {'v_range': [['6.2.0', '']], 'type': 'int'},
368 'tcp-window-type': {'v_range': [['6.2.0', '']], 'choices': ['system', 'static', 'dynamic', 'auto-tuning'], 'type': 'str'},
369 'ssl-offloaded': {'v_range': [['6.2.2', '']], 'choices': ['no', 'yes'], 'type': 'str'},
370 'stream-based-uncompressed-limit': {'v_range': [['6.2.2', '']], 'type': 'int'},
371 'proxy-after-tcp-handshake': {'v_range': [['6.4.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
372 'tunnel-non-http': {'v_range': [['6.4.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
373 'unknown-http-version': {'v_range': [['6.4.0', '']], 'choices': ['best-effort', 'reject', 'tunnel'], 'type': 'str'},
374 'address-ip-rating': {'v_range': [['7.0.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
375 'h2c': {'v_range': [['7.2.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
376 'verify-dns-for-policy-matching': {'v_range': [['7.2.1', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
377 'unknown-content-encoding': {'v_range': [['7.2.2', '']], 'choices': ['block', 'inspect', 'bypass'], 'type': 'str'},
378 'domain-fronting': {'v_range': [['7.4.8', '']], 'choices': ['block', 'monitor', 'allow', 'disable', 'enable', 'strict'], 'type': 'str'},
379 'http-0.9': {'v_range': [['7.6.2', '']], 'choices': ['block', 'allow'], 'type': 'str'},
380 'dns-protection': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
381 'encrypted-file': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'choices': ['block', 'pass', 'inspect'], 'type': 'str'},
382 'encrypted-file-log': {'v_range': [['7.4.8', '7.4.10'], ['7.6.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'}
383 }
384 }
385 }
386
387 module_option_spec = get_module_arg_spec('partial crud')
388 module_arg_spec.update(module_option_spec)
389 check_galaxy_version(module_arg_spec)
390 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_profileprotocoloptions_http'),
391 supports_check_mode=True)
392 if not module._socket_path:
393 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
394 connection = Connection(module._socket_path)
395 fmgr = NAPIManager('partial crud', module_arg_spec, urls_list,
396 None, 'data', module, connection)
397 fmgr.process_partial_crud()
398 module.exit_json(meta=module.params)
399
400
401 if __name__ == '__main__':
402 main()