Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_dlp_profile.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_profile
15 short_description: Configure DLP profiles.
16 version_added: "2.1.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_profile:
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 feature_set:
47 aliases: ['feature-set']
48 type: str
49 description: Flow/proxy feature set.
50 choices: ['flow', 'proxy']
51 full_archive_proto:
52 aliases: ['full-archive-proto']
53 type: list
54 elements: str
55 description: Protocols to always content archive.
56 choices: ['smtp', 'pop3', 'imap', 'http-post', 'http-get', 'ftp', 'nntp', 'mapi',
57 'ssh', 'cifs']
58 nac_quar_log:
59 aliases: ['nac-quar-log']
60 type: str
61 description: Enable/disable NAC quarantine logging.
62 choices: ['disable', 'enable']
63 name:
64 type: str
65 description: Name of the DLP profile.
66 required: true
67 replacemsg_group:
68 aliases: ['replacemsg-group']
69 type: str
70 description: Replacement message group used by this DLP profile.
71 rule:
72 type: list
73 elements: dict
74 description: Rule.
75 suboptions:
76 action:
77 type: str
78 description: Action to take with content that this DLP profile matches.
79 choices: ['log-only', 'block', 'quarantine-ip', 'allow']
80 archive:
81 type: str
82 description: Enable/disable DLP archiving.
83 choices: ['disable', 'enable']
84 expiry:
85 type: str
86 description: Quarantine duration in days, hours, minutes
87 file_size:
88 aliases: ['file-size']
89 type: int
90 description: Match files this size or larger
91 file_type:
92 aliases: ['file-type']
93 type: str
94 description: Select the number of a DLP file pattern table to match.
95 filter_by:
96 aliases: ['filter-by']
97 type: str
98 description: Select the type of content to match.
99 choices: ['fingerprint', 'sensor', 'encrypted', 'none', 'mip', 'label']
100 id:
101 type: int
102 description: ID.
103 label:
104 type: str
105 description: MIP label dictionary.
106 match_percentage:
107 aliases: ['match-percentage']
108 type: int
109 description: Percentage of fingerprints in the fingerprint databases designated with the selected sensitivity to match.
110 name:
111 type: str
112 description: Filter name.
113 proto:
114 type: list
115 elements: str
116 description: Check messages or files over one or more of these protocols.
117 choices: ['smtp', 'pop3', 'imap', 'http-post', 'http-get', 'ftp', 'nntp',
118 'mapi', 'ssh', 'cifs']
119 sensitivity:
120 type: raw
121 description: (list) Select a DLP file pattern sensitivity to match.
122 sensor:
123 type: raw
124 description: (list) Select DLP sensors.
125 severity:
126 type: str
127 description: Select the severity or threat level that matches this filter.
128 choices: ['info', 'low', 'medium', 'high', 'critical']
129 type:
130 type: str
131 description: Select whether to check the content of messages
132 choices: ['file', 'message']
133 summary_proto:
134 aliases: ['summary-proto']
135 type: list
136 elements: str
137 description: Protocols to always log summary.
138 choices: ['smtp', 'pop3', 'imap', 'http-post', 'http-get', 'ftp', 'nntp', 'mapi',
139 'ssh', 'cifs']
140 fortidata_error_action:
141 aliases: ['fortidata-error-action']
142 type: str
143 description: Action to take if FortiData query fails.
144 choices: ['block', 'log-only', 'ignore']
145 '''
146
147 EXAMPLES = '''
148 - name: Example playbook (generated based on argument schema)
149 hosts: fortimanagers
150 connection: httpapi
151 gather_facts: false
152 tasks:
153 - name: Configure DLP profiles.
154 fortinet.fortimanager.fmgr_dlp_profile:
155 # workspace_locking_adom: <global or your adom name>
156 adom: <your own value>
157 state: present # <value in [present, absent]>
158 dlp_profile:
159 name: "your value" # Required variable, string
160 # comment: <string>
161 # dlp_log: <value in [disable, enable]>
162 # extended_log: <value in [disable, enable]>
163 # feature_set: <value in [flow, proxy]>
164 # full_archive_proto: ["smtp", "pop3", "imap", "http-post", "http-get", "ftp", "nntp",
165 # "mapi", "ssh", "cifs"]
166 # nac_quar_log: <value in [disable, enable]>
167 # replacemsg_group: <string>
168 # rule:
169 # - action: <value in [log-only, block, quarantine-ip, ...]>
170 # archive: <value in [disable, enable]>
171 # expiry: <string>
172 # file_size: <integer>
173 # file_type: <string>
174 # filter_by: <value in [fingerprint, sensor, encrypted, ...]>
175 # id: <integer>
176 # label: <string>
177 # match_percentage: <integer>
178 # name: <string>
179 # proto: ["smtp", "pop3", "imap", "http-post", "http-get", "ftp", "nntp", "mapi",
180 # "ssh", "cifs"]
181 # sensitivity: <list or string>
182 # sensor: <list or string>
183 # severity: <value in [info, low, medium, ...]>
184 # type: <value in [file, message]>
185 # summary_proto: ["smtp", "pop3", "imap", "http-post", "http-get", "ftp", "nntp",
186 # "mapi", "ssh", "cifs"]
187 # fortidata_error_action: <value in [block, log-only, ignore]>
188 '''
189
190 RETURN = '''
191 meta:
192 description: The result of the request.
193 type: dict
194 returned: always
195 contains:
196 request_url:
197 description: The full url requested.
198 returned: always
199 type: str
200 sample: /sys/login/user
201 response_code:
202 description: The status of api request.
203 returned: always
204 type: int
205 sample: 0
206 response_data:
207 description: The api response.
208 type: list
209 returned: always
210 response_message:
211 description: The descriptive message of the api response.
212 type: str
213 returned: always
214 sample: OK.
215 system_information:
216 description: The information of the target system.
217 type: dict
218 returned: always
219 rc:
220 description: The status the request.
221 type: int
222 returned: always
223 sample: 0
224 version_check_warning:
225 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
226 type: list
227 returned: complex
228 '''
229 from ansible.module_utils.basic import AnsibleModule
230 from ansible.module_utils.connection import Connection
231 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
232 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
233
234
235 def main():
236 urls_list = [
237 '/pm/config/adom/{adom}/obj/dlp/profile',
238 '/pm/config/global/obj/dlp/profile'
239 ]
240 module_arg_spec = {
241 'adom': {'required': True, 'type': 'str'},
242 'revision_note': {'type': 'str'},
243 'dlp_profile': {
244 'type': 'dict', 'v_range': [['7.2.0', '']],
245 'options': {
246 'comment': {'v_range': [['7.2.0', '']], 'type': 'str'},
247 'dlp-log': {'v_range': [['7.2.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
248 'extended-log': {'v_range': [['7.2.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
249 'feature-set': {'v_range': [['7.2.0', '']], 'choices': ['flow', 'proxy'], 'type': 'str'},
250 'full-archive-proto': {
251 'v_range': [['7.2.0', '']],
252 'type': 'list',
253 'choices': ['smtp', 'pop3', 'imap', 'http-post', 'http-get', 'ftp', 'nntp', 'mapi', 'ssh', 'cifs'],
254 'elements': 'str'
255 },
256 'nac-quar-log': {'v_range': [['7.2.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
257 'name': {'v_range': [['7.2.0', '']], 'required': True, 'type': 'str'},
258 'replacemsg-group': {'v_range': [['7.2.0', '']], 'type': 'str'},
259 'rule': {
260 'v_range': [['7.2.0', '']],
261 'type': 'list',
262 'options': {
263 'action': {'v_range': [['7.2.0', '']], 'choices': ['log-only', 'block', 'quarantine-ip', 'allow'], 'type': 'str'},
264 'archive': {'v_range': [['7.2.0', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
265 'expiry': {'v_range': [['7.2.0', '']], 'type': 'str'},
266 'file-size': {'v_range': [['7.2.0', '']], 'type': 'int'},
267 'file-type': {'v_range': [['7.2.0', '']], 'type': 'str'},
268 'filter-by': {
269 'v_range': [['7.2.0', '']],
270 'choices': ['fingerprint', 'sensor', 'encrypted', 'none', 'mip', 'label'],
271 'type': 'str'
272 },
273 'id': {'v_range': [['7.2.0', '']], 'type': 'int'},
274 'label': {'v_range': [['7.2.0', '']], 'type': 'str'},
275 'match-percentage': {'v_range': [['7.2.0', '']], 'type': 'int'},
276 'name': {'v_range': [['7.2.0', '']], 'type': 'str'},
277 'proto': {
278 'v_range': [['7.2.0', '']],
279 'type': 'list',
280 'choices': ['smtp', 'pop3', 'imap', 'http-post', 'http-get', 'ftp', 'nntp', 'mapi', 'ssh', 'cifs'],
281 'elements': 'str'
282 },
283 'sensitivity': {'v_range': [['7.2.0', '']], 'type': 'raw'},
284 'sensor': {'v_range': [['7.2.0', '']], 'type': 'raw'},
285 'severity': {'v_range': [['7.2.0', '']], 'choices': ['info', 'low', 'medium', 'high', 'critical'], 'type': 'str'},
286 'type': {'v_range': [['7.2.0', '']], 'choices': ['file', 'message'], 'type': 'str'}
287 },
288 'elements': 'dict'
289 },
290 'summary-proto': {
291 'v_range': [['7.2.0', '']],
292 'type': 'list',
293 'choices': ['smtp', 'pop3', 'imap', 'http-post', 'http-get', 'ftp', 'nntp', 'mapi', 'ssh', 'cifs'],
294 'elements': 'str'
295 },
296 'fortidata-error-action': {'v_range': [['7.6.4', '']], 'choices': ['block', 'log-only', 'ignore'], 'type': 'str'}
297 }
298 }
299 }
300
301 module_option_spec = get_module_arg_spec('full crud')
302 module_arg_spec.update(module_option_spec)
303 check_galaxy_version(module_arg_spec)
304 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'dlp_profile'),
305 supports_check_mode=True)
306 if not module._socket_path:
307 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
308 connection = Connection(module._socket_path)
309 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
310 'name', 'data', module, connection)
311 fmgr.process_crud()
312 module.exit_json(meta=module.params)
313
314
315 if __name__ == '__main__':
316 main()