@@ -73,14 +73,53 @@ def __write_text(self, finding: Finding, platform_enabled: bool):
7373 logging .exception (f"Webhook request error\n headers: \n { self .headers } " )
7474
7575 def __write_json (self , finding : Finding , platform_enabled : bool ):
76- finding_dict = json .loads (json .dumps (finding , default = lambda o : getattr (o , '__dict__' , str (o ))))
76+ finding_dict = {
77+ "title" : finding .title ,
78+ "description" : finding .description ,
79+ "cluster_name" : self .cluster_name ,
80+ "account_id" : self .account_id ,
81+ "severity" : finding .severity .name ,
82+ "source" : finding .source .name ,
83+ "finding_type" : finding .finding_type .name ,
84+ "aggregation_key" : finding .aggregation_key ,
85+ "failure" : finding .failure ,
86+ "fingerprint" : finding .fingerprint ,
87+ "starts_at" : finding .starts_at .isoformat () if finding .starts_at else None ,
88+ "ends_at" : finding .ends_at .isoformat () if finding .ends_at else None ,
89+ "id" : str (finding .id ),
90+ "category" : finding .category ,
91+ "service" : json .loads (
92+ json .dumps (finding .service , default = lambda o : getattr (o , '__dict__' , str (o )))
93+ ) if finding .service else None ,
94+ "service_key" : finding .service_key ,
95+ "creation_date" : finding .creation_date ,
96+ "investigate_uri" : finding .investigate_uri ,
97+ "add_silence_url" : finding .add_silence_url ,
98+ "subject" : {
99+ "name" : finding .subject .name ,
100+ "kind" : finding .subject .subject_type .value ,
101+ "namespace" : finding .subject .namespace ,
102+ "node" : finding .subject .node ,
103+ "container" : finding .subject .container ,
104+ "labels" : finding .subject .labels ,
105+ "annotations" : finding .subject .annotations ,
106+ },
107+ "links" : [
108+ {"name" : link .name , "url" : link .url , "type" : link .type .value if link .type else None }
109+ for link in finding .links
110+ ],
111+ }
77112
78113 if platform_enabled :
79114 finding_dict ["investigate" ] = finding .get_investigate_uri (self .account_id , self .cluster_name )
80-
81115 if finding .add_silence_url :
82116 finding_dict ["silence" ] = finding .get_prometheus_silence_url (self .account_id , self .cluster_name )
83117
118+ # Enrichments last so they're the first thing dropped if size_limit is exceeded.
119+ finding_dict ["enrichments" ] = json .loads (
120+ json .dumps (finding .enrichments , default = lambda o : getattr (o , '__dict__' , str (o )))
121+ )
122+
84123 message = {}
85124 message_length = 0
86125
0 commit comments