|
| 1 | +<?xml version="1.0" encoding="UTF-8" ?> |
| 2 | + |
| 3 | +<Workflow name="NN-Universal-Alert-Updated" version="1.0" minimumRecurrence="180" xmlns="http://qradar.ibm.com/UniversalCloudRESTAPI/Workflow/V1"> |
| 4 | + <Parameters> |
| 5 | + <Parameter name="host" label="Host" required="true" /> |
| 6 | + <Parameter name="key_name" label="Key Name" required="true" /> |
| 7 | + <Parameter name="key_token" label="Key Token" required="true" secret="true" /> |
| 8 | + </Parameters> |
| 9 | + |
| 10 | + <Actions> |
| 11 | +<!-- <Initialize path="/bookmark_alert" value="0" />--> |
| 12 | + <Initialize path="/bookmark_alert" value="${time() - 36000000}" /> |
| 13 | + <Initialize path="/size" value="500" /> |
| 14 | + <Initialize path="/alert_page" value="1" /> |
| 15 | + |
| 16 | + <CallEndpoint url="https://${/host}/api/open/sign_in" method="POST" savePath="/sign_in"> |
| 17 | + <RequestBody type="application/json" encoding="UTF-8">{ "key_name": "${/key_name}", "key_token": "${/key_token}" }</RequestBody> |
| 18 | + </CallEndpoint> |
| 19 | + |
| 20 | + <Log type="INFO" message="NN Universal Alert Updated sign_in ${/sign_in/status_code}"/> |
| 21 | + |
| 22 | + <If condition="/sign_in/status_code != 200"> |
| 23 | + <Log type="ERROR" message="NN Universal Alert Updated sign_in fail ${/sign_in/status_code}" /> |
| 24 | + <Abort reason="${/sign_in/status_code}" /> |
| 25 | + </If> |
| 26 | + |
| 27 | + <Set path="/bearer_token" value="${/sign_in/headers/Authorization}"/> |
| 28 | + <If condition="/bearer_token = null"> |
| 29 | + <Set path="/bearer_token" value="${/sign_in/headers/authorization}"/> |
| 30 | + </If> |
| 31 | + |
| 32 | + <Log type="INFO" message="NN Universal Alert Updated Sign in successfully done alert bookmark ${/bookmark_alert}" /> |
| 33 | + |
| 34 | + <!-- GET ALERTS--> |
| 35 | + <DoWhile condition="${count(/alerts/body/result)} = ${/size}"> |
| 36 | + <CallEndpoint url="https://${/host}/api/open/query/do?query=alerts%20%7C%20select%20id%20type_id%20name%20protocol%20description%20ip_src%20ip_dst%20mac_src%20mac_dst%20time%20port_dst%20type_name%20appliance_host%20port_src%20port_dst%20severity%20risk%20src_roles%20dst_roles%20ack%20closed_time%20is_incident%20note%20transport_protocol%20is_security%20label_src%20label_dst%20created_time%20status%20zone_src%20zone_dst%20threat_name%20record_updated_at%20%7C%20where%20record_updated_at%20%3E%20${/bookmark_alert}%20%7C%20sort%20record_updated_at%20asc" method="GET" savePath="/alerts"> |
| 37 | + <QueryParameter name="count" value="${/size}"/> |
| 38 | + <QueryParameter name="page" value="${/alert_page}"/> |
| 39 | + <QueryParameter name="default_filters" value="false"/> |
| 40 | + <QueryParameter name="skip_total_count" value="true"/> |
| 41 | + <RequestHeader name="Authorization" value="${/bearer_token}"/> |
| 42 | + <RequestHeader name="nn-app" value="qradar-app"/> |
| 43 | + <RequestHeader name="nn-app-version" value="1.0.1"/> |
| 44 | + </CallEndpoint> |
| 45 | + |
| 46 | + <If condition="/alerts/status_code != 200"> |
| 47 | + <Log type="ERROR" message="NN Universal Alert Updated fail status code ${/alerts/status_code}" /> |
| 48 | + <Abort reason="${/alerts/status_code}"/> |
| 49 | + </If> |
| 50 | + |
| 51 | + <If condition="${count(/alerts/body/result)} != 0"> |
| 52 | + <PostEvents path="/alerts/body/result" source="${/host}_${/key_name}_Alert" /> |
| 53 | + |
| 54 | + <Set path="/alert_page" value="${/alert_page + 1}" /> |
| 55 | + |
| 56 | + <If condition="${count(/alerts/body/result)} != ${/size} or ${/alert_page} = 100"> |
| 57 | + <If condition="max(/alerts/body/result/record_updated_at) != null"> |
| 58 | + <Set path="/alert_page" value="1" /> |
| 59 | + <Set path="/bookmark_alert" value="${max(/alerts/body/result/record_updated_at)}" /> |
| 60 | + <Log type="INFO" message="NN Universal Alert Updated bookmark upgraded to ${/bookmark_alert}" /> |
| 61 | + </If> |
| 62 | + </If> |
| 63 | + </If> |
| 64 | + |
| 65 | + <Log type="INFO" message="NN Universal Alert Updated notified count => ${count(/alerts/body/result)} alert_page ${/alert_page} and bookmark ${/bookmark_alert}" /> |
| 66 | + </DoWhile> |
| 67 | + </Actions> |
| 68 | + <Tests> |
| 69 | + <DNSResolutionTest host="${/host}" /> |
| 70 | + <TCPConnectionTest host="${/host}" /> |
| 71 | + <SSLHandshakeTest host="${/host}" /> |
| 72 | + <HTTPConnectionThroughProxyTest url="https://${/host}" /> |
| 73 | + </Tests> |
| 74 | +</Workflow> |
0 commit comments