-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
File data logging v2 #12080
Draft
regit
wants to merge
3
commits into
OISF:master
Choose a base branch
from
regit:file_data-logging-v2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+46
−7
Draft
File data logging v2 #12080
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,6 +67,7 @@ | |
#include "util-validate.h" | ||
|
||
#include "action-globals.h" | ||
#include <stdint.h> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this include added ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I need to fix my LSP which is adding these headers by itself... |
||
|
||
#define MODULE_NAME "JsonAlertLog" | ||
|
||
|
@@ -85,6 +86,7 @@ | |
#define LOG_JSON_WEBSOCKET_PAYLOAD_BASE64 BIT_U16(12) | ||
#define LOG_JSON_PAYLOAD_LENGTH BIT_U16(13) | ||
#define LOG_JSON_REFERENCE BIT_U16(14) | ||
#define LOG_JSON_FILE_DATA BIT_U16(15) | ||
|
||
#define METADATA_DEFAULTS ( LOG_JSON_FLOW | \ | ||
LOG_JSON_APP_LAYER | \ | ||
|
@@ -431,7 +433,8 @@ static void AlertAddAppLayer(const Packet *p, JsonBuilder *jb, | |
} | ||
} | ||
|
||
static void AlertAddFiles(const Packet *p, JsonBuilder *jb, const uint64_t tx_id) | ||
static void AlertAddFiles( | ||
const Packet *p, JsonBuilder *jb, const uint64_t tx_id, int32_t file_dump_length) | ||
{ | ||
const uint8_t direction = | ||
(p->flowflags & FLOW_PKT_TOSERVER) ? STREAM_TOSERVER : STREAM_TOCLIENT; | ||
|
@@ -452,7 +455,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); | ||
EveFileInfo(jb, file, tx_id, file->flags, file_dump_length); | ||
jb_close(jb); | ||
file = file->next; | ||
} | ||
|
@@ -680,7 +683,10 @@ static int AlertJson(ThreadVars *tv, JsonAlertLogThread *aft, const Packet *p) | |
} | ||
/* including fileinfo data is configured by the metadata setting */ | ||
if (json_output_ctx->flags & LOG_JSON_RULE_METADATA) { | ||
AlertAddFiles(p, jb, pa->tx_id); | ||
AlertAddFiles(p, jb, pa->tx_id, | ||
json_output_ctx->flags & LOG_JSON_FILE_DATA | ||
? json_output_ctx->payload_buffer_size | ||
: -1); | ||
} | ||
} | ||
|
||
|
@@ -945,6 +951,7 @@ static void JsonAlertLogSetupMetadata(AlertJsonOutputCtx *json_output_ctx, | |
SetFlag(conf, "websocket-payload", LOG_JSON_WEBSOCKET_PAYLOAD_BASE64, &flags); | ||
SetFlag(conf, "verdict", LOG_JSON_VERDICT, &flags); | ||
SetFlag(conf, "payload-length", LOG_JSON_PAYLOAD_LENGTH, &flags); | ||
SetFlag(conf, "file-data", LOG_JSON_FILE_DATA, &flags); | ||
|
||
/* Check for obsolete flags and warn that they have no effect. */ | ||
static const char *deprecated_flags[] = { "http", "tls", "ssh", "smtp", "dnp3", "app-layer", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonder if these fields should be grouped together in a subobject (making the meaning of offset more clear)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like a good idea. I can try implementing that to see if it works ok.