Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions src/analysisd/format/to_json.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@
/* Convert Eventinfo to json */
char *Eventinfo_to_jsonstr(const Eventinfo *lf)
{
time_t c_time;
char* time_string;
c_time = time(NULL);
time_string = ctime(&c_time);


cJSON *root;
cJSON *rule;
cJSON *file_diff;
Expand All @@ -38,12 +35,15 @@ char *Eventinfo_to_jsonstr(const Eventinfo *lf)
if ( lf->time ) {

char alert_id[19];
double timestamp_ms;
timestamp_ms = ((double)lf->time)*1000;
alert_id[18] = '\0';
if((snprintf(alert_id, 18, "%ld.%ld", (long int)lf->time, __crt_ftell)) < 0) {
merror("snprintf failed");
}

cJSON_AddStringToObject(root, "id", alert_id);
cJSON_AddNumberToObject(root, "TimeStamp", timestamp_ms);
}

if (lf->generated_rule->comment) {
Expand Down Expand Up @@ -112,9 +112,7 @@ char *Eventinfo_to_jsonstr(const Eventinfo *lf)
if (lf->full_log) {
cJSON_AddStringToObject(root, "full_log", lf->full_log);
}
if (lf->full_log){
cJSON_AddStringToObject(root, "TimeStamp", time_string);
}

if (lf->filename) {
cJSON_AddItemToObject(root, "file", file_diff = cJSON_CreateObject());

Expand Down