Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filestore alertlog 4881 v8 #9274

Closed
Closed
Show file tree
Hide file tree
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
11 changes: 11 additions & 0 deletions etc/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@
"filename": {
"type": "string"
},
"file_id": {
"type": "integer"
},
"gaps": {
"type": "boolean"
},
Expand Down Expand Up @@ -143,6 +146,10 @@
"stored": {
"type": "boolean"
},
"storing": {
"description": "the file is set to be stored when completed",
"type": "boolean"
},
"tx_id": {
"type": "integer"
},
Expand Down Expand Up @@ -1445,6 +1452,10 @@
"stored": {
"type": "boolean"
},
"storing": {
"description": "the file is set to be stored when completed",
"type": "boolean"
},
"tx_id": {
"type": "integer"
},
Expand Down
2 changes: 1 addition & 1 deletion src/output-json-alert.c
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ static void AlertAddFiles(const Packet *p, JsonBuilder *jb, const uint64_t tx_id
jb_open_array(jb, "files");
}
jb_start_object(jb);
EveFileInfo(jb, file, tx_id, file->flags & FILE_STORED);
EveFileInfo(jb, file, tx_id, file->flags);
jb_close(jb);
file = file->next;
}
Expand Down
11 changes: 8 additions & 3 deletions src/output-json-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,13 @@ JsonBuilder *JsonBuildFileInfoRecord(const Packet *p, const File *ff, void *tx,
jb_set_string(js, "app_proto", AppProtoToString(p->flow->alproto));

jb_open_object(js, "fileinfo");
EveFileInfo(js, ff, tx_id, stored);
if (stored) {
// the file has just been stored on disk cf OUTPUT_FILEDATA_FLAG_CLOSE
// but the flag is not set until the loggers have been called
EveFileInfo(js, ff, tx_id, ff->flags | FILE_STORED);
} else {
EveFileInfo(js, ff, tx_id, ff->flags);
}
jb_close(js);

/* xff header */
Expand All @@ -206,8 +212,7 @@ static void FileWriteJsonRecord(JsonFileLogThread *aft, const Packet *p, const F
{
HttpXFFCfg *xff_cfg = aft->filelog_ctx->xff_cfg != NULL ? aft->filelog_ctx->xff_cfg
: aft->filelog_ctx->parent_xff_cfg;
JsonBuilder *js = JsonBuildFileInfoRecord(
p, ff, tx, tx_id, ff->flags & FILE_STORED ? true : false, dir, xff_cfg, eve_ctx);
JsonBuilder *js = JsonBuildFileInfoRecord(p, ff, tx, tx_id, false, dir, xff_cfg, eve_ctx);
if (unlikely(js == NULL)) {
return;
}
Expand Down
7 changes: 5 additions & 2 deletions src/output-json.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ json_t *SCJsonString(const char *val)
/* Default Sensor ID value */
static int64_t sensor_id = -1; /* -1 = not defined */

void EveFileInfo(JsonBuilder *jb, const File *ff, const uint64_t tx_id, const bool stored)
void EveFileInfo(JsonBuilder *jb, const File *ff, const uint64_t tx_id, const uint16_t flags)
{
jb_set_string_from_bytes(jb, "filename", ff->name, ff->name_len);

Expand Down Expand Up @@ -170,11 +170,14 @@ void EveFileInfo(JsonBuilder *jb, const File *ff, const uint64_t tx_id, const bo
jb_set_hex(jb, "sha256", (uint8_t *)ff->sha256, (uint32_t)sizeof(ff->sha256));
}

if (stored) {
if (flags & FILE_STORED) {
JB_SET_TRUE(jb, "stored");
jb_set_uint(jb, "file_id", ff->file_store_id);
} else {
JB_SET_FALSE(jb, "stored");
if (flags & FILE_STORE) {
JB_SET_TRUE(jb, "storing");
}
}

jb_set_uint(jb, "size", FileTrackedSize(ff));
Expand Down
2 changes: 1 addition & 1 deletion src/output-json.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ typedef struct OutputJsonThreadCtx_ {
json_t *SCJsonString(const char *val);

void CreateEveFlowId(JsonBuilder *js, const Flow *f);
void EveFileInfo(JsonBuilder *js, const File *file, const uint64_t tx_id, const bool stored);
void EveFileInfo(JsonBuilder *js, const File *file, const uint64_t tx_id, const uint16_t flags);
void EveTcpFlags(uint8_t flags, JsonBuilder *js);
void EvePacket(const Packet *p, JsonBuilder *js, unsigned long max_length);
JsonBuilder *CreateEveHeader(const Packet *p, enum OutputJsonLogDirection dir,
Expand Down
Loading