@@ 150-186 (lines=37) @@ | ||
147 | alert_object = gmp.get_alerts(filter='name=%s' % alert_name) |
|
148 | alert_id = None |
|
149 | alert = alert_object.xpath('alert') |
|
150 | if len(alert) == 0: |
|
151 | gmp.create_alert( |
|
152 | alert_name, |
|
153 | event=gmp.types.AlertEvent.TASK_RUN_STATUS_CHANGED, |
|
154 | event_data={'status': 'Done'}, |
|
155 | condition=gmp.types.AlertCondition.ALWAYS, |
|
156 | method=gmp.types.AlertMethod.EMAIL, |
|
157 | method_data={ |
|
158 | """Task '$n': $e |
|
159 | ||
160 | After the event $e, |
|
161 | the following condition was met: $c |
|
162 | ||
163 | This email escalation is configured to attach report format '$r'. |
|
164 | Full details and other report formats are available on the scan engine. |
|
165 | ||
166 | $t |
|
167 | ||
168 | Note: |
|
169 | This email was sent to you as a configured security scan escalation. |
|
170 | Please contact your local system administrator if you think you |
|
171 | should not have received it. |
|
172 | """: "message", |
|
173 | "2": "notice", |
|
174 | sender_email: "from_address", |
|
175 | "[OpenVAS-Manager] Task": "subject", |
|
176 | "c402cc3e-b531-11e1-9163-406186ea4fc5": "notice_attach_format", |
|
177 | recipient_email: "to_address", |
|
178 | }, |
|
179 | ) |
|
180 | alert_object = gmp.get_alerts(filter='name=%s' % recipient_email) |
|
181 | alert = alert_object.xpath('alert') |
|
182 | alert_id = alert[0].get('id', 'no id found') |
|
183 | else: |
|
184 | alert_id = alert[0].get('id', 'no id found') |
|
185 | if debug: |
|
186 | print("alert_id: %s" % str(alert_id)) |
|
187 | ||
188 | # second configurable alert name |
|
189 | alert_name2 = "%s-2" % recipient_email |
|
@@ 195-230 (lines=36) @@ | ||
192 | alert_object2 = gmp.get_alerts(filter='name=%s' % alert_name2) |
|
193 | alert_id2 = None |
|
194 | alert2 = alert_object2.xpath('alert') |
|
195 | if len(alert2) == 0: |
|
196 | gmp.create_alert( |
|
197 | alert_name2, |
|
198 | event=gmp.types.AlertEvent.TASK_RUN_STATUS_CHANGED, |
|
199 | event_data={'status': 'Done'}, |
|
200 | condition=gmp.types.AlertCondition.ALWAYS, |
|
201 | method=gmp.types.AlertMethod.EMAIL, |
|
202 | method_data={ |
|
203 | """Task '$n': $e |
|
204 | ||
205 | After the event $e, |
|
206 | the following condition was met: $c |
|
207 | ||
208 | This email escalation is configured to attach report format '$r'. |
|
209 | Full details and other report formats are available on the scan engine. |
|
210 | ||
211 | $t |
|
212 | ||
213 | Note: |
|
214 | This email was sent to you as a configured security scan escalation. |
|
215 | Please contact your local system administrator if you think you |
|
216 | should not have received it. |
|
217 | """: "message", |
|
218 | "2": "notice", |
|
219 | sender_email: "from_address", |
|
220 | "[OpenVAS-Manager] Task": "subject", |
|
221 | recipient_email: "to_address", |
|
222 | }, |
|
223 | ) |
|
224 | alert_object2 = gmp.get_alerts(filter='name=%s' % recipient_email) |
|
225 | alert2 = alert_object2.xpath('alert') |
|
226 | alert_id2 = alert2[0].get('id', 'no id found') |
|
227 | else: |
|
228 | alert_id2 = alert2[0].get('id', 'no id found') |
|
229 | if debug: |
|
230 | print("alert_id2: %s" % str(alert_id2)) |
|
231 | ||
232 | return (alert_id, alert_id2) |
|
233 |