eve: rename plugin to filetypes

EVE filetypes are not always plugins, for example, null and syslog
that are built-in filetypes.
pull/10652/head
Jason Ish 2 years ago committed by Victor Julien
parent 7c8c9fff32
commit 3ff72d3efa

@ -1008,7 +1008,7 @@ static int LogFileTypePrepare(
}
}
#endif
else if (log_filetype == LOGFILE_TYPE_PLUGIN) {
else if (log_filetype == LOGFILE_TYPE_FILETYPE) {
if (json_ctx->file_ctx->threaded) {
/* Prepare for threaded log output. */
if (!SCLogOpenThreadedFile(NULL, NULL, json_ctx->file_ctx)) {
@ -1016,11 +1016,11 @@ static int LogFileTypePrepare(
}
}
void *init_data = NULL;
if (json_ctx->plugin->Init(conf, json_ctx->file_ctx->threaded, &init_data) < 0) {
if (json_ctx->filetype->Init(conf, json_ctx->file_ctx->threaded, &init_data) < 0) {
return -1;
}
json_ctx->file_ctx->plugin.plugin = json_ctx->plugin;
json_ctx->file_ctx->plugin.init_data = init_data;
json_ctx->file_ctx->filetype.filetype = json_ctx->filetype;
json_ctx->file_ctx->filetype.init_data = init_data;
}
return 0;
@ -1085,10 +1085,10 @@ OutputInitResult OutputJsonInitCtx(ConfNode *conf)
enum LogFileType log_filetype = FileTypeFromConf(output_s);
if (log_filetype == LOGFILE_TYPE_NOTSET) {
SCEveFileType *plugin = SCEveFindFileType(output_s);
if (plugin != NULL) {
log_filetype = LOGFILE_TYPE_PLUGIN;
json_ctx->plugin = plugin;
SCEveFileType *filetype = SCEveFindFileType(output_s);
if (filetype != NULL) {
log_filetype = LOGFILE_TYPE_FILETYPE;
json_ctx->filetype = filetype;
} else
FatalError("Invalid JSON output option: %s", output_s);
}

@ -28,10 +28,8 @@
#include "util-buffer.h"
#include "util-logopenfile.h"
#include "output.h"
#include "rust.h"
#include "app-layer-htp-xff.h"
#include "suricata-plugin.h"
void OutputJsonRegister(void);
@ -83,7 +81,7 @@ typedef struct OutputJsonCtx_ {
enum LogFileType json_out;
OutputJsonCommonSettings cfg;
HttpXFFCfg *xff_cfg;
SCEveFileType *plugin;
SCEveFileType *filetype;
} OutputJsonCtx;
typedef struct OutputJsonThreadCtx_ {

@ -833,12 +833,12 @@ static bool LogFileNewThreadedCtx(LogFileCtx *parent_ctx, const char *log_path,
thread->Write = SCLogFileWriteNoLock;
thread->Close = SCLogFileCloseNoLock;
OutputRegisterFileRotationFlag(&thread->rotation_flag);
} else if (parent_ctx->type == LOGFILE_TYPE_PLUGIN) {
} else if (parent_ctx->type == LOGFILE_TYPE_FILETYPE) {
entry->slot_number = SC_ATOMIC_ADD(eve_file_id, 1);
SCLogDebug("%s - thread %d [slot %d]", log_path, entry->internal_thread_id,
entry->slot_number);
thread->plugin.plugin->ThreadInit(
thread->plugin.init_data, entry->internal_thread_id, &thread->plugin.thread_data);
thread->filetype.filetype->ThreadInit(thread->filetype.init_data, entry->internal_thread_id,
&thread->filetype.thread_data);
}
thread->threaded = false;
thread->parent = parent_ctx;
@ -871,8 +871,9 @@ int LogFileFreeCtx(LogFileCtx *lf_ctx)
SCReturnInt(0);
}
if (lf_ctx->type == LOGFILE_TYPE_PLUGIN && lf_ctx->parent != NULL) {
lf_ctx->plugin.plugin->ThreadDeinit(lf_ctx->plugin.init_data, lf_ctx->plugin.thread_data);
if (lf_ctx->type == LOGFILE_TYPE_FILETYPE && lf_ctx->parent != NULL) {
lf_ctx->filetype.filetype->ThreadDeinit(
lf_ctx->filetype.init_data, lf_ctx->filetype.thread_data);
}
if (lf_ctx->threaded) {
@ -885,7 +886,7 @@ int LogFileFreeCtx(LogFileCtx *lf_ctx)
}
SCFree(lf_ctx->threads);
} else {
if (lf_ctx->type != LOGFILE_TYPE_PLUGIN) {
if (lf_ctx->type != LOGFILE_TYPE_FILETYPE) {
if (lf_ctx->fp != NULL) {
lf_ctx->Close(lf_ctx);
}
@ -908,11 +909,11 @@ int LogFileFreeCtx(LogFileCtx *lf_ctx)
OutputUnregisterFileRotationFlag(&lf_ctx->rotation_flag);
}
/* Deinitialize output plugins. We only want to call this for the
* parent of threaded output, or always for non-threaded
/* Deinitialize output filetypes. We only want to call this for
* the parent of threaded output, or always for non-threaded
* output. */
if (lf_ctx->type == LOGFILE_TYPE_PLUGIN && lf_ctx->parent == NULL) {
lf_ctx->plugin.plugin->Deinit(lf_ctx->plugin.init_data);
if (lf_ctx->type == LOGFILE_TYPE_FILETYPE && lf_ctx->parent == NULL) {
lf_ctx->filetype.filetype->Deinit(lf_ctx->filetype.init_data);
}
memset(lf_ctx, 0, sizeof(*lf_ctx));
@ -929,9 +930,10 @@ int LogFileWrite(LogFileCtx *file_ctx, MemBuffer *buffer)
MemBufferWriteString(buffer, "\n");
file_ctx->Write((const char *)MEMBUFFER_BUFFER(buffer),
MEMBUFFER_OFFSET(buffer), file_ctx);
} else if (file_ctx->type == LOGFILE_TYPE_PLUGIN) {
file_ctx->plugin.plugin->Write((const char *)MEMBUFFER_BUFFER(buffer),
MEMBUFFER_OFFSET(buffer), file_ctx->plugin.init_data, file_ctx->plugin.thread_data);
} else if (file_ctx->type == LOGFILE_TYPE_FILETYPE) {
file_ctx->filetype.filetype->Write((const char *)MEMBUFFER_BUFFER(buffer),
MEMBUFFER_OFFSET(buffer), file_ctx->filetype.init_data,
file_ctx->filetype.thread_data);
}
#ifdef HAVE_LIBHIREDIS
else if (file_ctx->type == LOGFILE_TYPE_REDIS) {

@ -33,7 +33,6 @@
#include "util-log-redis.h"
#endif /* HAVE_LIBHIREDIS */
#include "suricata-plugin.h"
#include "output-eve.h"
enum LogFileType {
@ -41,7 +40,8 @@ enum LogFileType {
LOGFILE_TYPE_UNIX_DGRAM,
LOGFILE_TYPE_UNIX_STREAM,
LOGFILE_TYPE_REDIS,
LOGFILE_TYPE_PLUGIN,
/** New style or modular filetypes. */
LOGFILE_TYPE_FILETYPE,
LOGFILE_TYPE_NOTSET
};
@ -66,11 +66,11 @@ typedef struct LogThreadedFileCtx_ {
char *append;
} LogThreadedFileCtx;
typedef struct LogFilePluginCtx_ {
SCEveFileType *plugin;
typedef struct LogFileTypeCtx_ {
SCEveFileType *filetype;
void *init_data;
void *thread_data;
} LogFilePluginCtx;
} LogFileTypeCtx;
/** Global structure for Output Context */
typedef struct LogFileCtx_ {
@ -91,7 +91,7 @@ typedef struct LogFileCtx_ {
int (*Write)(const char *buffer, int buffer_len, struct LogFileCtx_ *fp);
void (*Close)(struct LogFileCtx_ *fp);
LogFilePluginCtx plugin;
LogFileTypeCtx filetype;
/** It will be locked if the log/alert
* record cannot be written to the file in one call */

Loading…
Cancel
Save