%nJ d Z ddlZddlZddlmZ ddlmZ ddlmZ ddlm Z ej
e Z G d d Z
dS ) z3Send WordPress incidents to the correlation server. N)datetime)Any)SensorWordpressIncidentList)MessageSinkc e Zd ZdZdedeeef fdZdedee fdZ de
dz d ee defd
Zde
dee fdZ
dS )
IncidentSendera
Send WordPress incidents to the correlation server.
WordPress incidents are already in the Incident table (visible to UI).
This class sends them to correlation via Reportable messages, which are
automatically handled by SendToServer/SendToServerFGW plugins.
incidentreturnc t d| | d pi }t | d pd }t | }|r't j | d nd}i d|d|d| d d
| d
pdd| d d
| d d| d d| d pdd| d pdd| d pdd| d pdd| d pdd| d pdd| d r| d dk ndd| d pdd | d! pdd"| | | d# pd| d$ pd| d% pd| d& pd|d'S )(aJ
Prepare an incident for sending to the correlation server.
WordPress incidents use extra_info JSON field to store plugin-specific data.
Args:
incident: WordpressIncident dictionary (with extra_info populated)
Returns:
Dictionary formatted for correlation server
z&Preparing incident for correlation: %s
extra_info timestampr z%Y-%m-%d dt plugin_idpluginruleunknownnamemessagedescriptionseverityattackers_ipabuserdomainretries urirequest_uri
user_agenthttp_user_agenthttp_methodrequest_methoduser_logged_intrueN file_path site_pathuserusernametagtargetslugversionmode)r* r+ r, r- details) loggerinfogetfloatintr
fromtimestampstrftime_build_tags)selfr extratimestamp_valuer
r s ^/opt/imunify360/venv/lib/python3.11/site-packages/defence360agent/wordpress/incident_sender.py!_prepare_incident_for_correlationz0IncidentSender._prepare_incident_for_correlation s