Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_firewall_sslsshprofile_https.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_sslsshprofile_https
15 short_description: Configure HTTPS 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 ssl-ssh-profile:
29 description: Deprecated, please use "ssl_ssh_profile"
30 type: str
31 ssl_ssh_profile:
32 description: The parameter (ssl-ssh-profile) in requested url.
33 type: str
34 firewall_sslsshprofile_https:
35 description: The top level parameters set.
36 required: false
37 type: dict
38 suboptions:
39 allow_invalid_server_cert:
40 aliases: ['allow-invalid-server-cert']
41 type: str
42 description: When enabled, allows SSL sessions whose server certificate validation failed.
43 choices: ['disable', 'enable']
44 client_cert_request:
45 aliases: ['client-cert-request']
46 type: str
47 description: Action based on client certificate request.
48 choices: ['bypass', 'inspect', 'block']
49 ports:
50 type: raw
51 description: (list) Ports to use for scanning
52 status:
53 type: str
54 description: Configure protocol inspection status.
55 choices: ['disable', 'certificate-inspection', 'deep-inspection']
56 unsupported_ssl:
57 aliases: ['unsupported-ssl']
58 type: str
59 description: Action based on the SSL encryption used being unsupported.
60 choices: ['bypass', 'inspect', 'block']
61 untrusted_cert:
62 aliases: ['untrusted-cert']
63 type: str
64 description: Allow, ignore, or block the untrusted SSL session server certificate.
65 choices: ['allow', 'block', 'ignore']
66 invalid_server_cert:
67 aliases: ['invalid-server-cert']
68 type: str
69 description: Allow or block the invalid SSL session server certificate.
70 choices: ['allow', 'block']
71 sni_server_cert_check:
72 aliases: ['sni-server-cert-check']
73 type: str
74 description: Check the SNI in the client hello message with the CN or SAN fields in the returned server certificate.
75 choices: ['disable', 'enable', 'strict']
76 untrusted_server_cert:
77 aliases: ['untrusted-server-cert']
78 type: str
79 description: Allow, ignore, or block the untrusted SSL session server certificate.
80 choices: ['allow', 'block', 'ignore']
81 cert_validation_failure:
82 aliases: ['cert-validation-failure']
83 type: str
84 description: Action based on certificate validation failure.
85 choices: ['allow', 'block', 'ignore']
86 cert_validation_timeout:
87 aliases: ['cert-validation-timeout']
88 type: str
89 description: Action based on certificate validation timeout.
90 choices: ['allow', 'block', 'ignore']
91 client_certificate:
92 aliases: ['client-certificate']
93 type: str
94 description: Action based on received client certificate.
95 choices: ['bypass', 'inspect', 'block', 'bypass-on-cert-req']
96 expired_server_cert:
97 aliases: ['expired-server-cert']
98 type: str
99 description: Action based on server certificate is expired.
100 choices: ['allow', 'block', 'ignore']
101 proxy_after_tcp_handshake:
102 aliases: ['proxy-after-tcp-handshake']
103 type: str
104 description: Proxy traffic after the TCP 3-way handshake has been established
105 choices: ['disable', 'enable']
106 revoked_server_cert:
107 aliases: ['revoked-server-cert']
108 type: str
109 description: Action based on server certificate is revoked.
110 choices: ['allow', 'block', 'ignore']
111 unsupported_ssl_cipher:
112 aliases: ['unsupported-ssl-cipher']
113 type: str
114 description: Action based on the SSL cipher used being unsupported.
115 choices: ['allow', 'block']
116 unsupported_ssl_negotiation:
117 aliases: ['unsupported-ssl-negotiation']
118 type: str
119 description: Action based on the SSL negotiation used being unsupported.
120 choices: ['allow', 'block']
121 cert_probe_failure:
122 aliases: ['cert-probe-failure']
123 type: str
124 description: Action based on certificate probe failure.
125 choices: ['block', 'allow']
126 min_allowed_ssl_version:
127 aliases: ['min-allowed-ssl-version']
128 type: str
129 description: Minimum SSL version to be allowed.
130 choices: ['ssl-3.0', 'tls-1.0', 'tls-1.1', 'tls-1.2', 'tls-1.3']
131 unsupported_ssl_version:
132 aliases: ['unsupported-ssl-version']
133 type: str
134 description: Action based on the SSL version used being unsupported.
135 choices: ['block', 'allow', 'inspect']
136 quic:
137 type: str
138 description: Enable/disable QUIC inspection
139 choices: ['disable', 'enable', 'bypass', 'block', 'inspect']
140 encrypted_client_hello:
141 aliases: ['encrypted-client-hello']
142 type: str
143 description: Block/allow session based on existence of encrypted-client-hello.
144 choices: ['block', 'allow']
145 udp_not_quic:
146 aliases: ['udp-not-quic']
147 type: str
148 description: Action to be taken when matched UDP packet is not QUIC.
149 choices: ['block', 'allow']
150 '''
151
152 EXAMPLES = '''
153 - name: Example playbook (generated based on argument schema)
154 hosts: fortimanagers
155 connection: httpapi
156 gather_facts: false
157 tasks:
158 - name: Configure HTTPS options.
159 fortinet.fortimanager.fmgr_firewall_sslsshprofile_https:
160 # workspace_locking_adom: <global or your adom name>
161 adom: <your own value>
162 ssl_ssh_profile: <your own value>
163 firewall_sslsshprofile_https:
164 # allow_invalid_server_cert: <value in [disable, enable]>
165 # client_cert_request: <value in [bypass, inspect, block]>
166 # ports: <list or integer>
167 # status: <value in [disable, certificate-inspection, deep-inspection]>
168 # unsupported_ssl: <value in [bypass, inspect, block]>
169 # untrusted_cert: <value in [allow, block, ignore]>
170 # invalid_server_cert: <value in [allow, block]>
171 # sni_server_cert_check: <value in [disable, enable, strict]>
172 # untrusted_server_cert: <value in [allow, block, ignore]>
173 # cert_validation_failure: <value in [allow, block, ignore]>
174 # cert_validation_timeout: <value in [allow, block, ignore]>
175 # client_certificate: <value in [bypass, inspect, block, ...]>
176 # expired_server_cert: <value in [allow, block, ignore]>
177 # proxy_after_tcp_handshake: <value in [disable, enable]>
178 # revoked_server_cert: <value in [allow, block, ignore]>
179 # unsupported_ssl_cipher: <value in [allow, block]>
180 # unsupported_ssl_negotiation: <value in [allow, block]>
181 # cert_probe_failure: <value in [block, allow]>
182 # min_allowed_ssl_version: <value in [ssl-3.0, tls-1.0, tls-1.1, ...]>
183 # unsupported_ssl_version: <value in [block, allow, inspect]>
184 # quic: <value in [disable, enable, bypass, ...]>
185 # encrypted_client_hello: <value in [block, allow]>
186 # udp_not_quic: <value in [block, allow]>
187 '''
188
189 RETURN = '''
190 meta:
191 description: The result of the request.
192 type: dict
193 returned: always
194 contains:
195 request_url:
196 description: The full url requested.
197 returned: always
198 type: str
199 sample: /sys/login/user
200 response_code:
201 description: The status of api request.
202 returned: always
203 type: int
204 sample: 0
205 response_data:
206 description: The api response.
207 type: list
208 returned: always
209 response_message:
210 description: The descriptive message of the api response.
211 type: str
212 returned: always
213 sample: OK.
214 system_information:
215 description: The information of the target system.
216 type: dict
217 returned: always
218 rc:
219 description: The status the request.
220 type: int
221 returned: always
222 sample: 0
223 version_check_warning:
224 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
225 type: list
226 returned: complex
227 '''
228 from ansible.module_utils.basic import AnsibleModule
229 from ansible.module_utils.connection import Connection
230 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
231 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
232
233
234 def main():
235 urls_list = [
236 '/pm/config/adom/{adom}/obj/firewall/ssl-ssh-profile/{ssl-ssh-profile}/https',
237 '/pm/config/global/obj/firewall/ssl-ssh-profile/{ssl-ssh-profile}/https'
238 ]
239 module_arg_spec = {
240 'adom': {'required': True, 'type': 'str'},
241 'ssl-ssh-profile': {'type': 'str', 'api_name': 'ssl_ssh_profile'},
242 'ssl_ssh_profile': {'type': 'str'},
243 'revision_note': {'type': 'str'},
244 'firewall_sslsshprofile_https': {
245 'type': 'dict', 'v_range': [['6.0.0', '']],
246 'options': {
247 'allow-invalid-server-cert': {'v_range': [['6.0.0', '7.2.1'], ['7.4.8', '7.4.10']], 'choices': ['disable', 'enable'], 'type': 'str'},
248 'client-cert-request': {'v_range': [['6.0.0', '7.6.2']], 'choices': ['bypass', 'inspect', 'block'], 'type': 'str'},
249 'ports': {'type': 'raw'},
250 'status': {'choices': ['disable', 'certificate-inspection', 'deep-inspection'], 'type': 'str'},
251 'unsupported-ssl': {'v_range': [['6.0.0', '7.6.2']], 'choices': ['bypass', 'inspect', 'block'], 'type': 'str'},
252 'untrusted-cert': {'v_range': [['6.0.0', '7.2.1'], ['7.4.8', '7.4.10']], 'choices': ['allow', 'block', 'ignore'], 'type': 'str'},
253 'invalid-server-cert': {'v_range': [['6.2.0', '7.6.2']], 'choices': ['allow', 'block'], 'type': 'str'},
254 'sni-server-cert-check': {'v_range': [['6.2.0', '']], 'choices': ['disable', 'enable', 'strict'], 'type': 'str'},
255 'untrusted-server-cert': {'v_range': [['6.2.0', '']], 'choices': ['allow', 'block', 'ignore'], 'type': 'str'},
256 'cert-validation-failure': {'v_range': [['6.4.0', '']], 'choices': ['allow', 'block', 'ignore'], 'type': 'str'},
257 'cert-validation-timeout': {'v_range': [['6.4.0', '']], 'choices': ['allow', 'block', 'ignore'], 'type': 'str'},
258 'client-certificate': {'v_range': [['6.4.0', '']], 'choices': ['bypass', 'inspect', 'block', 'bypass-on-cert-req'], 'type': 'str'},
259 'expired-server-cert': {'v_range': [['6.4.0', '']], 'choices': ['allow', 'block', 'ignore'], 'type': 'str'},
260 'proxy-after-tcp-handshake': {'v_range': [['6.4.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
261 'revoked-server-cert': {'v_range': [['6.4.0', '']], 'choices': ['allow', 'block', 'ignore'], 'type': 'str'},
262 'unsupported-ssl-cipher': {'v_range': [['6.4.0', '']], 'choices': ['allow', 'block'], 'type': 'str'},
263 'unsupported-ssl-negotiation': {'v_range': [['6.4.0', '']], 'choices': ['allow', 'block'], 'type': 'str'},
264 'cert-probe-failure': {'v_range': [['7.0.0', '']], 'choices': ['block', 'allow'], 'type': 'str'},
265 'min-allowed-ssl-version': {'v_range': [['7.0.3', '']], 'choices': ['ssl-3.0', 'tls-1.0', 'tls-1.1', 'tls-1.2', 'tls-1.3'], 'type': 'str'},
266 'unsupported-ssl-version': {'v_range': [['7.0.1', '']], 'choices': ['block', 'allow', 'inspect'], 'type': 'str'},
267 'quic': {'v_range': [['7.4.1', '']], 'choices': ['disable', 'enable', 'bypass', 'block', 'inspect'], 'type': 'str'},
268 'encrypted-client-hello': {'v_range': [['7.4.3', '']], 'choices': ['block', 'allow'], 'type': 'str'},
269 'udp-not-quic': {'v_range': [['7.6.2', '']], 'choices': ['block', 'allow'], 'type': 'str'}
270 }
271 }
272 }
273
274 module_option_spec = get_module_arg_spec('partial crud')
275 module_arg_spec.update(module_option_spec)
276 check_galaxy_version(module_arg_spec)
277 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'firewall_sslsshprofile_https'),
278 supports_check_mode=True)
279 if not module._socket_path:
280 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
281 connection = Connection(module._socket_path)
282 fmgr = NAPIManager('partial crud', module_arg_spec, urls_list,
283 None, 'data', module, connection)
284 fmgr.process_partial_crud()
285 module.exit_json(meta=module.params)
286
287
288 if __name__ == '__main__':
289 main()