Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_dlp_sensor.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_dlp_sensor
15 short_description: Configure DLP sensors.
16 version_added: "2.0.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.full_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 dlp_sensor:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 comment:
34 type: str
35 description: Comment.
36 dlp_log:
37 aliases: ['dlp-log']
38 type: str
39 description: Enable/disable DLP logging.
40 choices: ['disable', 'enable']
41 extended_log:
42 aliases: ['extended-log']
43 type: str
44 description: Enable/disable extended logging for data leak prevention.
45 choices: ['disable', 'enable']
46 filter:
47 type: list
48 elements: dict
49 description: Filter.
50 suboptions:
51 action:
52 type: str
53 description: Action to take with content that this DLP sensor matches.
54 choices: ['log-only', 'block', 'exempt', 'ban', 'ban-sender',
55 'quarantine-ip', 'quarantine-port', 'none', 'allow']
56 archive:
57 type: str
58 description: Enable/disable DLP archiving.
59 choices: ['disable', 'enable', 'summary-only']
60 company_identifier:
61 aliases: ['company-identifier']
62 type: str
63 description: Enter a company identifier watermark to match.
64 expiry:
65 type: str
66 description: Quarantine duration in days, hours, minutes format
67 file_size:
68 aliases: ['file-size']
69 type: int
70 description: Match files this size or larger
71 file_type:
72 aliases: ['file-type']
73 type: str
74 description: Select the number of a DLP file pattern table to match.
75 filter_by:
76 aliases: ['filter-by']
77 type: str
78 description: Select the type of content to match.
79 choices: ['credit-card', 'ssn', 'regexp', 'file-type', 'file-size',
80 'fingerprint', 'watermark', 'encrypted', 'file-type-and-size']
81 fp_sensitivity:
82 aliases: ['fp-sensitivity']
83 type: raw
84 description: (list or str) Select a DLP file pattern sensitivity to match.
85 id:
86 type: int
87 description: ID.
88 match_percentage:
89 aliases: ['match-percentage']
90 type: int
91 description: Percentage of fingerprints in the fingerprint databases designated with the selected fp-sensitivity to match.
92 name:
93 type: str
94 description: Filter name.
95 proto:
96 type: list
97 elements: str
98 description: Check messages or files over one or more of these protocols.
99 choices: ['imap', 'smtp', 'pop3', 'ftp', 'nntp', 'mm1', 'mm3', 'mm4',
100 'mm7', 'mapi', 'aim', 'icq', 'msn', 'yahoo', 'http-get',
101 'http-post', 'ssh', 'cifs']
102 regexp:
103 type: str
104 description: Enter a regular expression to match
105 severity:
106 type: str
107 description: Select the severity or threat level that matches this filter.
108 choices: ['info', 'low', 'medium', 'high', 'critical']
109 type:
110 type: str
111 description: Select whether to check the content of messages
112 choices: ['file', 'message']
113 sensitivity:
114 type: raw
115 description: (list or str) Select a DLP file pattern sensitivity to match.
116 flow_based:
117 aliases: ['flow-based']
118 type: str
119 description: Enable/disable flow-based DLP.
120 choices: ['disable', 'enable']
121 full_archive_proto:
122 aliases: ['full-archive-proto']
123 type: list
124 elements: str
125 description: Protocols to always content archive.
126 choices: ['imap', 'smtp', 'pop3', 'ftp', 'nntp', 'mm1', 'mm3', 'mm4', 'mm7',
127 'mapi', 'aim', 'icq', 'msn', 'yahoo', 'http-get', 'http-post', 'ssh',
128 'cifs']
129 nac_quar_log:
130 aliases: ['nac-quar-log']
131 type: str
132 description: Enable/disable NAC quarantine logging.
133 choices: ['disable', 'enable']
134 name:
135 type: str
136 description: Name of the DLP sensor.
137 required: true
138 options:
139 type: str
140 description: Configure DLP options.
141 choices: ['strict-file']
142 replacemsg_group:
143 aliases: ['replacemsg-group']
144 type: str
145 description: Replacement message group used by this DLP sensor.
146 summary_proto:
147 aliases: ['summary-proto']
148 type: list
149 elements: str
150 description: Protocols to always log summary.
151 choices: ['imap', 'smtp', 'pop3', 'ftp', 'nntp', 'mm1', 'mm3', 'mm4', 'mm7',
152 'mapi', 'aim', 'icq', 'msn', 'yahoo', 'http-get', 'http-post', 'ssh',
153 'cifs']
154 feature_set:
155 aliases: ['feature-set']
156 type: str
157 description: Flow/proxy feature set.
158 choices: ['proxy', 'flow']
159 entries:
160 type: list
161 elements: dict
162 description: Entries.
163 suboptions:
164 count:
165 type: int
166 description: Count of dictionary matches to trigger sensor entry match
167 dictionary:
168 type: str
169 description: Select a DLP dictionary.
170 id:
171 type: int
172 description: ID.
173 status:
174 type: str
175 description: Enable/disable this entry.
176 choices: ['disable', 'enable']
177 eval:
178 type: str
179 description: Expression to evaluate.
180 match_type:
181 aliases: ['match-type']
182 type: str
183 description: Logical relation between entries
184 choices: ['match-all', 'match-any', 'match-eval']
185 fgd_id:
186 aliases: ['fgd-id']
187 type: int
188 description: ID of object in FortiGuard database.
189 '''
190
191 EXAMPLES = '''
192 - name: Example playbook (generated based on argument schema)
193 hosts: fortimanagers
194 connection: httpapi
195 gather_facts: false
196 tasks:
197 - name: Configure DLP sensors.
198 fortinet.fortimanager.fmgr_dlp_sensor:
199 # workspace_locking_adom: <global or your adom name>
200 adom: <your own value>
201 state: present # <value in [present, absent]>
202 dlp_sensor:
203 name: "your value" # Required variable, string
204 # comment: <string>
205 # dlp_log: <value in [disable, enable]>
206 # extended_log: <value in [disable, enable]>
207 # filter:
208 # - action: <value in [log-only, block, exempt, ...]>
209 # archive: <value in [disable, enable, summary-only]>
210 # company_identifier: <string>
211 # expiry: <string>
212 # file_size: <integer>
213 # file_type: <string>
214 # filter_by: <value in [credit-card, ssn, regexp, ...]>
215 # fp_sensitivity: <list or string>
216 # id: <integer>
217 # match_percentage: <integer>
218 # name: <string>
219 # proto: ["imap", "smtp", "pop3", "ftp", "nntp", "mm1", "mm3", "mm4", "mm7", "mapi",
220 # "aim", "icq", "msn", "yahoo", "http-get", "http-post", "ssh", "cifs"]
221 # regexp: <string>
222 # severity: <value in [info, low, medium, ...]>
223 # type: <value in [file, message]>
224 # sensitivity: <list or string>
225 # flow_based: <value in [disable, enable]>
226 # full_archive_proto: ["imap", "smtp", "pop3", "ftp", "nntp", "mm1", "mm3", "mm4",
227 # "mm7", "mapi", "aim", "icq", "msn", "yahoo", "http-get",
228 # "http-post", "ssh", "cifs"]
229 # nac_quar_log: <value in [disable, enable]>
230 # options: <value in [strict-file]>
231 # replacemsg_group: <string>
232 # summary_proto: ["imap", "smtp", "pop3", "ftp", "nntp", "mm1", "mm3", "mm4", "mm7",
233 # "mapi", "aim", "icq", "msn", "yahoo", "http-get", "http-post", "ssh",
234 # "cifs"]
235 # feature_set: <value in [proxy, flow]>
236 # entries:
237 # - count: <integer>
238 # dictionary: <string>
239 # id: <integer>
240 # status: <value in [disable, enable]>
241 # eval: <string>
242 # match_type: <value in [match-all, match-any, match-eval]>
243 # fgd_id: <integer>
244 '''
245
246 RETURN = '''
247 meta:
248 description: The result of the request.
249 type: dict
250 returned: always
251 contains:
252 request_url:
253 description: The full url requested.
254 returned: always
255 type: str
256 sample: /sys/login/user
257 response_code:
258 description: The status of api request.
259 returned: always
260 type: int
261 sample: 0
262 response_data:
263 description: The api response.
264 type: list
265 returned: always
266 response_message:
267 description: The descriptive message of the api response.
268 type: str
269 returned: always
270 sample: OK.
271 system_information:
272 description: The information of the target system.
273 type: dict
274 returned: always
275 rc:
276 description: The status the request.
277 type: int
278 returned: always
279 sample: 0
280 version_check_warning:
281 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
282 type: list
283 returned: complex
284 '''
285 from ansible.module_utils.basic import AnsibleModule
286 from ansible.module_utils.connection import Connection
287 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
288 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
289
290
291 def main():
292 urls_list = [
293 '/pm/config/adom/{adom}/obj/dlp/sensor',
294 '/pm/config/global/obj/dlp/sensor'
295 ]
296 module_arg_spec = {
297 'adom': {'required': True, 'type': 'str'},
298 'revision_note': {'type': 'str'},
299 'dlp_sensor': {
300 'type': 'dict', 'v_range': [['6.0.0', '']],
301 'options': {
302 'comment': {'type': 'str'},
303 'dlp-log': {'choices': ['disable', 'enable'], 'type': 'str'},
304 'extended-log': {'choices': ['disable', 'enable'], 'type': 'str'},
305 'filter': {
306 'type': 'list',
307 'options': {
308 'action': {
309 'choices': ['log-only', 'block', 'exempt', 'ban', 'ban-sender', 'quarantine-ip', 'quarantine-port', 'none', 'allow'],
310 'type': 'str'
311 },
312 'archive': {'choices': ['disable', 'enable', 'summary-only'], 'type': 'str'},
313 'company-identifier': {'type': 'str'},
314 'expiry': {'type': 'str'},
315 'file-size': {'type': 'int'},
316 'file-type': {'type': 'str'},
317 'filter-by': {
318 'choices': [
319 'credit-card', 'ssn', 'regexp', 'file-type', 'file-size', 'fingerprint', 'watermark', 'encrypted', 'file-type-and-size'
320 ],
321 'type': 'str'
322 },
323 'fp-sensitivity': {'v_range': [['6.0.0', '7.2.1'], ['7.4.8', '7.4.10']], 'type': 'raw'},
324 'id': {'type': 'int'},
325 'match-percentage': {'type': 'int'},
326 'name': {'type': 'str'},
327 'proto': {
328 'type': 'list',
329 'choices': [
330 'imap', 'smtp', 'pop3', 'ftp', 'nntp', 'mm1', 'mm3', 'mm4', 'mm7', 'mapi', 'aim', 'icq', 'msn', 'yahoo', 'http-get',
331 'http-post', 'ssh', 'cifs'
332 ],
333 'elements': 'str'
334 },
335 'regexp': {'type': 'str'},
336 'severity': {'choices': ['info', 'low', 'medium', 'high', 'critical'], 'type': 'str'},
337 'type': {'choices': ['file', 'message'], 'type': 'str'},
338 'sensitivity': {'v_range': [['6.2.0', '']], 'type': 'raw'}
339 },
340 'elements': 'dict'
341 },
342 'flow-based': {'v_range': [['6.0.0', '7.2.1']], 'choices': ['disable', 'enable'], 'type': 'str'},
343 'full-archive-proto': {
344 'type': 'list',
345 'choices': [
346 'imap', 'smtp', 'pop3', 'ftp', 'nntp', 'mm1', 'mm3', 'mm4', 'mm7', 'mapi', 'aim', 'icq', 'msn', 'yahoo', 'http-get', 'http-post',
347 'ssh', 'cifs'
348 ],
349 'elements': 'str'
350 },
351 'nac-quar-log': {'choices': ['disable', 'enable'], 'type': 'str'},
352 'name': {'required': True, 'type': 'str'},
353 'options': {'v_range': [['6.0.0', '7.2.0']], 'choices': ['strict-file'], 'type': 'str'},
354 'replacemsg-group': {'type': 'str'},
355 'summary-proto': {
356 'type': 'list',
357 'choices': [
358 'imap', 'smtp', 'pop3', 'ftp', 'nntp', 'mm1', 'mm3', 'mm4', 'mm7', 'mapi', 'aim', 'icq', 'msn', 'yahoo', 'http-get', 'http-post',
359 'ssh', 'cifs'
360 ],
361 'elements': 'str'
362 },
363 'feature-set': {'v_range': [['6.4.0', '']], 'choices': ['proxy', 'flow'], 'type': 'str'},
364 'entries': {
365 'v_range': [['7.2.0', '']],
366 'type': 'list',
367 'options': {
368 'count': {'v_range': [['7.2.0', '']], 'type': 'int'},
369 'dictionary': {'v_range': [['7.2.0', '']], 'type': 'str'},
370 'id': {'v_range': [['7.2.0', '']], 'type': 'int'},
371 'status': {'v_range': [['7.2.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'}
372 },
373 'elements': 'dict'
374 },
375 'eval': {'v_range': [['7.2.0', '']], 'type': 'str'},
376 'match-type': {'v_range': [['7.2.0', '']], 'choices': ['match-all', 'match-any', 'match-eval'], 'type': 'str'},
377 'fgd-id': {'v_range': [['7.6.0', '']], 'type': 'int'}
378 }
379 }
380 }
381
382 module_option_spec = get_module_arg_spec('full crud')
383 module_arg_spec.update(module_option_spec)
384 check_galaxy_version(module_arg_spec)
385 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'dlp_sensor'),
386 supports_check_mode=True)
387 if not module._socket_path:
388 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
389 connection = Connection(module._socket_path)
390 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
391 'name', 'data', module, connection)
392 fmgr.process_crud()
393 module.exit_json(meta=module.params)
394
395
396 if __name__ == '__main__':
397 main()