Debian Codegraph @

ansible_collections/community/general/plugins/modules/utm_proxy_exception.py

raw
1 #!/usr/bin/python
2
3 # Copyright (c) 2018, Sebastian Schenzel <[email protected]>
4 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
5 # SPDX-License-Identifier: GPL-3.0-or-later
6
7 from __future__ import annotations
8
9 DOCUMENTATION = r"""
10 module: utm_proxy_exception
11
12 author:
13 - Sebastian Schenzel (@RickS-C137)
14
15 short_description: Create, update or destroy reverse_proxy exception entry in Sophos UTM
16
17 description:
18 - Create, update or destroy a reverse_proxy exception entry in SOPHOS UTM.
19 - This module needs to have the REST Ability of the UTM to be activated.
20 attributes:
21 check_mode:
22 support: none
23 diff_mode:
24 support: none
25
26 options:
27 name:
28 description:
29 - The name of the object that identifies the entry.
30 required: true
31 type: str
32 op:
33 description:
34 - The operand to be used with the entries of the path parameter.
35 default: 'AND'
36 choices:
37 - 'AND'
38 - 'OR'
39 type: str
40 path:
41 description:
42 - The paths the exception in the reverse proxy is defined for.
43 type: list
44 elements: str
45 default: []
46 skip_custom_threats_filters:
47 description:
48 - A list of threats to be skipped.
49 type: list
50 elements: str
51 default: []
52 skip_threats_filter_categories:
53 description:
54 - Define which categories of threats are skipped.
55 type: list
56 elements: str
57 default: []
58 skipav:
59 description:
60 - Skip the Antivirus Scanning.
61 default: false
62 type: bool
63 skipbadclients:
64 description:
65 - Block clients with bad reputation.
66 default: false
67 type: bool
68 skipcookie:
69 description:
70 - Skip the Cookie Signing check.
71 default: false
72 type: bool
73 skipform:
74 description:
75 - Enable form hardening.
76 default: false
77 type: bool
78 skipform_missingtoken:
79 description:
80 - Enable form hardening with missing tokens.
81 default: false
82 type: bool
83 skiphtmlrewrite:
84 description:
85 - Protection against SQL.
86 default: false
87 type: bool
88 skiptft:
89 description:
90 - Enable true file type control.
91 default: false
92 type: bool
93 skipurl:
94 description:
95 - Enable static URL hardening.
96 default: false
97 type: bool
98 source:
99 description:
100 - Define which categories of threats are skipped.
101 type: list
102 elements: str
103 default: []
104 status:
105 description:
106 - Status of the exception rule set.
107 default: true
108 type: bool
109
110 extends_documentation_fragment:
111 - community.general._utm
112 - community.general._attributes
113 """
114
115 EXAMPLES = r"""
116 - name: Create UTM proxy_exception
117 community.general.utm_proxy_exception:
118 utm_host: sophos.host.name
119 utm_token: abcdefghijklmno1234
120 name: TestExceptionEntry
121 backend: REF_OBJECT_STRING
122 state: present
123
124 - name: Remove UTM proxy_exception
125 community.general.utm_proxy_exception:
126 utm_host: sophos.host.name
127 utm_token: abcdefghijklmno1234
128 name: TestExceptionEntry
129 state: absent
130 """
131
132 RETURN = r"""
133 result:
134 description: The utm object that was created.
135 returned: success
136 type: complex
137 contains:
138 _ref:
139 description: The reference name of the object.
140 type: str
141 _locked:
142 description: Whether or not the object is currently locked.
143 type: bool
144 _type:
145 description: The type of the object.
146 type: str
147 name:
148 description: The name of the object.
149 type: str
150 comment:
151 description: The optional comment string.
152 type: str
153 op:
154 description: The operand to be used with the entries of the path parameter.
155 type: str
156 path:
157 description: The paths the exception in the reverse proxy is defined for.
158 type: list
159 skip_custom_threats_filters:
160 description: A list of threats to be skipped.
161 type: list
162 skip_threats_filter_categories:
163 description: Define which categories of threats are skipped.
164 type: list
165 skipav:
166 description: Skip the Antivirus Scanning.
167 type: bool
168 skipbadclients:
169 description: Block clients with bad reputation.
170 type: bool
171 skipcookie:
172 description: Skip the Cookie Signing check.
173 type: bool
174 skipform:
175 description: Enable form hardening.
176 type: bool
177 skipform_missingtoken:
178 description: Enable form hardening with missing tokens.
179 type: bool
180 skiphtmlrewrite:
181 description: Protection against SQL.
182 type: bool
183 skiptft:
184 description: Enable true file type control.
185 type: bool
186 skipurl:
187 description: Enable static URL hardening.
188 type: bool
189 source:
190 description: Define which categories of threats are skipped.
191 type: list
192 """
193
194 from ansible_collections.community.general.plugins.module_utils._utm_utils import UTM, UTMModule
195
196
197 def main():
198 endpoint = "reverse_proxy/exception"
199 key_to_check_for_changes = [
200 "op",
201 "path",
202 "skip_custom_threats_filters",
203 "skip_threats_filter_categories",
204 "skipav",
205 "comment",
206 "skipbadclients",
207 "skipcookie",
208 "skipform",
209 "status",
210 "skipform_missingtoken",
211 "skiphtmlrewrite",
212 "skiptft",
213 "skipurl",
214 "source",
215 ]
216 module = UTMModule(
217 argument_spec=dict(
218 name=dict(type="str", required=True),
219 op=dict(type="str", default="AND", choices=["AND", "OR"]),
220 path=dict(type="list", elements="str", default=[]),
221 skip_custom_threats_filters=dict(type="list", elements="str", default=[]),
222 skip_threats_filter_categories=dict(type="list", elements="str", default=[]),
223 skipav=dict(type="bool", default=False),
224 skipbadclients=dict(type="bool", default=False),
225 skipcookie=dict(type="bool", default=False),
226 skipform=dict(type="bool", default=False),
227 skipform_missingtoken=dict(type="bool", default=False),
228 skiphtmlrewrite=dict(type="bool", default=False),
229 skiptft=dict(type="bool", default=False),
230 skipurl=dict(type="bool", default=False),
231 source=dict(type="list", elements="str", default=[]),
232 status=dict(type="bool", default=True),
233 )
234 )
235 try:
236 UTM(module, endpoint, key_to_check_for_changes).execute()
237 except Exception as e:
238 module.fail_json(msg=f"{e}")
239
240
241 if __name__ == "__main__":
242 main()