forked from axoflow/axosyslog
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
filterx/modules/cef: add filterx-func-parse-leef() based on event-for…
…mat-parser this version supports only LEEF:1.0 atm, LEEF:2.0 will be added as a separate feature Signed-off-by: shifter <shifter@axoflow.com>
- Loading branch information
Showing
5 changed files
with
135 additions
and
0 deletions.
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
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 |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* Copyright (c) 2024 Axoflow | ||
* Copyright (c) 2024 shifter | ||
* | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 as published | ||
* by the Free Software Foundation, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
* | ||
* As an additional exemption you are allowed to compile & link against the | ||
* OpenSSL libraries as published by the OpenSSL project. See the file | ||
* COPYING for details. | ||
* | ||
*/ | ||
|
||
#include "filterx-func-parse-leef.h" | ||
#include "filterx/object-string.h" | ||
#include "filterx/object-primitive.h" | ||
#include "filterx/expr-literal.h" | ||
#include "filterx/expr-literal-generator.h" | ||
#include "filterx/filterx-eval.h" | ||
#include "filterx/filterx-globals.h" | ||
#include "filterx/object-extractor.h" | ||
#include "filterx/object-json.h" | ||
#include "filterx/object-message-value.h" | ||
#include "filterx/object-null.h" | ||
#include "filterx/filterx-object.h" | ||
#include "filterx/object-dict-interface.h" | ||
#include "filterx/object-list-interface.h" | ||
#include "filterx/object-string.h" | ||
|
||
#include "scanner/csv-scanner/csv-scanner.h" | ||
#include "parser/parser-expr.h" | ||
#include "scratch-buffers.h" | ||
#include "str-utils.h" | ||
#include "scanner/kv-scanner/kv-scanner.h" | ||
#include "event-format-parser.h" | ||
|
||
static Field leef_fields[] = | ||
{ | ||
{ .name = "version", .field_parser = parse_version}, | ||
{ .name = "vendor"}, | ||
{ .name = "productName"}, | ||
{ .name = "productVersion"}, | ||
{ .name = "eventId"}, | ||
{ .name = "extensions", .field_parser = parse_extensions}, | ||
}; | ||
|
||
typedef struct FilterXFunctionParseLEEF_ | ||
{ | ||
FilterXFunctionEventFormatParser super; | ||
} FilterXFunctionParseLEEF; | ||
|
||
|
||
FilterXExpr * | ||
filterx_function_parse_leef_new(FilterXFunctionArgs *args, GError **err) | ||
{ | ||
FilterXFunctionParseLEEF *self = g_new0(FilterXFunctionParseLEEF, 1); | ||
if (!filterx_function_parser_init_instance(&self->super, "parse_leef", args, err)) | ||
goto error; | ||
|
||
Config cfg = | ||
{ | ||
.delimiters = "|", | ||
.log_type = EVENFORMAT_LOGTYPE_LEEF, | ||
.num_fields = 6, | ||
.extensions_value_separator = '=', | ||
.extensions_pair_separator = "\t", | ||
.fields = leef_fields, | ||
}; | ||
|
||
filterx_function_parser_set_config(&self->super, &cfg); | ||
|
||
filterx_function_args_free(args); | ||
return &self->super.super.super.super; | ||
|
||
error: | ||
append_error_message(err, FILTERX_FUNC_PARSE_LEEF_USAGE); | ||
filterx_function_args_free(args); | ||
filterx_expr_unref(&self->super.super.super.super); | ||
return NULL; | ||
} | ||
|
||
FILTERX_GENERATOR_FUNCTION(parse_leef, filterx_function_parse_leef_new); |
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright (c) 2023 Axoflow | ||
* Copyright (c) 2024 shifter | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 as published | ||
* by the Free Software Foundation, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
* | ||
* As an additional exemption you are allowed to compile & link against the | ||
* OpenSSL libraries as published by the OpenSSL project. See the file | ||
* COPYING for details. | ||
* | ||
*/ | ||
|
||
#ifndef FILTERX_FUNC_PARSE_LEEF_H_INCLUDED | ||
#define FILTERX_FUNC_PARSE_LEEF_H_INCLUDED | ||
|
||
#include "plugin.h" | ||
#include "filterx/expr-function.h" | ||
|
||
#define FILTERX_FUNC_PARSE_LEEF_USAGE "Usage: parse_leef($str)" | ||
|
||
FILTERX_GENERATOR_FUNCTION_DECLARE(parse_leef); | ||
|
||
FilterXExpr *filterx_function_parse_leef_new(FilterXFunctionArgs *args, GError **error); | ||
|
||
#endif |