From 05eeab7c9c1bf3b8e61af0b724c7883fcc776457 Mon Sep 17 00:00:00 2001 From: Alex Kelly Date: Fri, 2 Dec 2022 11:20:30 -0500 Subject: [PATCH] add abuseipdb and crowdsec cti links for IP --- matrix_webhook/formatters/crowdsec.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/matrix_webhook/formatters/crowdsec.py b/matrix_webhook/formatters/crowdsec.py index 7bd1eab..b5f398f 100644 --- a/matrix_webhook/formatters/crowdsec.py +++ b/matrix_webhook/formatters/crowdsec.py @@ -1,11 +1,16 @@ def formatter(data, headers): - """ format a message sent with crowdsec http endpoints""" + """format a message sent with crowdsec http endpoints""" data_out = "" for row in data["body"]: - if "crowdsecurity" in row['scenario']: - source, scenario, *_ = row['scenario'].split('/') - row['scenario'] = f"[{scenario}](https://hub.crowdsec.net/author/crowdsecurity/configurations/{scenario})" - data_out += f"{row['host']} has been banned {row['duration']} due to {row['scenario']}\n\n[AbuseIPDB](https://www.abuseipdb.com/check{row['host'])" + if "crowdsecurity" in row["scenario"]: + source, scenario, *_ = row["scenario"].split("/") + row[ + "scenario" + ] = f"[{scenario}](https://hub.crowdsec.net/author/crowdsecurity/configurations/{scenario})" + data_out += ( + f"{row['host']} has been banned {row['duration']} due to {row['scenario']}\n\n" + f"[AbuseIPDB](https://www.abuseipdb.com/check/{row['host']})|" + f"[Crowdsec](https://app.crowdsec.net/cti/{row['host']})\n\n" + ) data["body"] = data_out return data -