Skip to content

Commit

Permalink
Merge pull request #14 from Elektrobit/next
Browse files Browse the repository at this point in the history
Next
  • Loading branch information
gehwolf authored Oct 10, 2024
2 parents 1c3ca28 + 74082ce commit 1fdf17b
Show file tree
Hide file tree
Showing 125 changed files with 2,446 additions and 290 deletions.
5 changes: 5 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,8 @@ CheckOptions:
- { key: readability-identifier-naming.GlobalVariablePrefix, value: elos }
- { key: readability-identifier-naming.GlobalConstantCase, value: CamelCase }
- { key: readability-identifier-naming.GlobalConstantPrefix, value: elos }
- { key: readability-identifier-naming.ClassCase, value: CamelCase }
- { key: readability-identifier-naming.PublicMethodCase, value: camelBack }
- { key: readability-identifier-naming.PublicMemberCase, value: camelBack }
- { key: readability-identifier-naming.PrivateMethodCase, value: camelBack }
- { key: readability-identifier-naming.PrivateMemberCase, value: camelBack }
4 changes: 2 additions & 2 deletions ci/Dockerfile.elosd
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ WORKDIR /home/elos
COPY ./ /home/elos

RUN mkdir /etc/elos
COPY ./test/integration/service/config.json /etc/elos/elosd.json
COPY ./src/components/config/elosd.json /etc/elos/elosd.json
RUN chmod 644 /etc/elos/elosd.json

ENV SOURCES_URI=$SOURCES_URI
Expand All @@ -51,7 +51,7 @@ RUN cmake -B /tmp/elos/build . -DCMAKE_BUILD_TYPE=Release -G Ninja -DUNIT_TESTS=
RUN ninja -C /tmp/elos/build all
RUN sudo ninja -C /tmp/elos/build install

COPY ./test/integration/service/elosd.service /etc/init.d/elosd
COPY ./ci/elosd.service /etc/init.d/elosd
RUN chmod a+x /etc/init.d/elosd

RUN sudo ldconfig
Expand Down
6 changes: 3 additions & 3 deletions ci/code_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def collect_sources_all(path_list):
for path in path_list:
for root, _, files in os.walk(path):
for file in files:
if file.endswith(".c") or file.endswith(".h"):
if file.endswith(".c") or file.endswith(".h") or file.endswith(".cpp"):
source_set.add(os.path.abspath(os.path.join(root, file)))

return source_set
Expand Down Expand Up @@ -118,7 +118,7 @@ def collect_sources_used(build_dir, json_file=None):
results = output.stdout.decode("utf-8").split()
results = [
os.path.abspath(x) for x in results
if x.endswith(".c") or x.endswith(".h")
if x.endswith(".c") or x.endswith(".h") or x.endswith(".cpp")
]
# Remove generated files like version.c from the list
results = [
Expand Down Expand Up @@ -155,7 +155,7 @@ def collect_sources_diff(base_dir, target_branch):
]
results = [
os.path.abspath(x) for x in results
if x.endswith(".c") or x.endswith(".h")
if x.endswith(".c") or x.endswith(".h") or x.endswith(".cpp")
]
# Remove sources outside of base_dir
results = [
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions ci/run_integration_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ docker run -d -ti --rm \
-v $BASE_DIR:/base \
-w /base \
--env "PROJECT=${PROJECT}" \
--env "TARGET_NAME=${ELOSD_DOCKER_NAME}" \
--env "TEST_OUTPUT=/base/build/${BUILD_TYPE}/result/integration" \
${TEST_IMAGE_NAME}

Expand Down
26 changes: 25 additions & 1 deletion ci/run_utest.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
#!/bin/bash
###############################################################################
print_info() {
echo "
Run the unit test suite or parts of it. Default is to run all unit
tests for the Debug build.
Usage: ${0} [build type] [--test-regex|-R <test name pattern>] [-h|--help]
build type: usually Debug or Release but can be any other build type
--test-regex|-R: execute all tests matching the pattern
-h|--help: print this help
Examples:
${0} Release # run all unit test on Release build
${0} Release -R elosRpn # run all unit test containing elosRpn in
the name for the Release build.
"
}
###############################################################################
set -e -u -o pipefail

CMD_PATH="$(realpath "$(dirname "$0")")"
Expand All @@ -12,8 +31,13 @@ while [ $# -gt 0 ]; do
TESTS_REGEX="--tests-regex ${2}"
shift
;;
-h|--help)
print_info
exit 0 ;;
-*)
echo "error: unknown option: $1"; exit 1 ;;
echo "error: unknown option: $1"
print_info
exit 1 ;;
*)
PARAM="$PARAM ${1}" ;;
esac
Expand Down
4 changes: 2 additions & 2 deletions cmake/project.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: MIT
set(ELOS_VERSION 0.62.6)
set(ELOS_VERSION 0.65.1)

# Attention: Aside from the version, as many things as possible in this file
# should be put into functions, as this solves potential issues with commands
Expand All @@ -21,7 +21,7 @@ macro(project_set_environment)
option(ENABLE_ANALYZER "Build with -fanalyzer" ON)
option(ENABLE_ASAN "Link with ASAN" ON)
option(ENABLE_CI "Use CI mode for building" OFF)
option(ENABLE_GIT_VERSION "Enable the git hash for the version" OFF)
option(ENABLE_GIT_VERSION "Enable the git hash for the version" ON)

option(UNIT_TESTS "Build unit tests" ${ELOS_BUILD_DEFAULTS})
option(INSTALL_UNIT_TESTS "Install unit tests" ON)
Expand Down
39 changes: 39 additions & 0 deletions debian.native/control
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,19 @@ Description: Event logging and management with normalized output-format (Dummy p
.
Dummy backend plugin.

Package: elos-plugin-backend-fetchapi
Section: libs
Architecture: any
Depends:
${misc:Depends},
${shlibs:Depends},
Description: Event logging and management with normalized output-format (Dummy plugin)
elos is a tool to collect, store and publish various system events (i.e.
syslogs, core dumps, measurements obtained from proc- and sys-fs, ...)
while providing easy access to the collected data.
.
A backend which implements the fetch API, thus elos can provide historical events.

Package: elos-plugin-backend-influxdb
Section: libs
Architecture: any
Expand Down Expand Up @@ -329,6 +342,19 @@ Description: Event logging and management with normalized output-format DLT libr
.
DLT shared library package.

Package: libelos-cpp0
Section: libs
Architecture: any
Depends:
${misc:Depends},
${shlibs:Depends},
Description: Event logging and management with normalized output-format C++ library
elos is a tool to collect, store and publish various system events (i.e.
syslogs, core dumps, measurements obtained from proc- and sys-fs, ...)
while providing easy access to the collected data.
.
C++ shared library package.

Package: libelosplugin0
Section: libs
Architecture: any
Expand Down Expand Up @@ -387,6 +413,19 @@ Description: Development package for libelosdlt
.
Development package for libelosdlt.

Package: libelos-cpp-dev
Section: libdevel
Architecture: any
Depends:
${misc:Depends},
libelos-cpp0 (= ${binary:Version}),
Description: Development package for libelos-cpp
elos is a tool to collect, store and publish various system events (i.e.
syslogs, core dumps, measurements obtained from proc- and sys-fs, ...)
while providing easy access to the collected data.
.
Development package for libelos-cpp.

Package: libelos-common-dev
Section: libdevel
Architecture: any
Expand Down
1 change: 1 addition & 0 deletions debian.native/elos-plugin-backend-fetchapi.install
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
usr/lib/*/elos/backend/backend_fetchapi.so
4 changes: 4 additions & 0 deletions debian.native/libelos-cpp-dev.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
usr/include/elos/libelos-cpp
usr/lib/*/pkgconfig/elos-cpp.pc
usr/lib/*/libelos-cpp.so
usr/lib/*/cmake/libelos-cpp
1 change: 1 addition & 0 deletions debian.native/libelos-cpp0.install
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
usr/lib/*/libelos-cpp.so.*
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ if (ELOS_DAEMON)
endif()
add_subdirectory(libelos_common)
add_subdirectory(libelos)
add_subdirectory(libelos-cpp)
add_subdirectory(libelosplugin)
if (ELOSD_LIBDLT)
add_subdirectory(libelosdlt)
Expand Down
29 changes: 21 additions & 8 deletions src/components/config/elosd.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"Interface": "127.0.0.1",
"EventBlacklist": ".event.messageCode 1000 LE",
"authorizedProcesses": [
".process.uid 0 EQ .process.gid 0 EQ .process.exec '/bin/elosc' STRCMP AND",
".process.uid 0 EQ .process.gid 0 EQ AND .process.exec '/bin/elosc' STRCMP AND",
".process.gid 200 EQ .process.exec '/bin/elosc' STRCMP AND",
".process.pid 1 EQ"
]
Expand All @@ -35,10 +35,20 @@
},
"EventLogging": {
"Plugins": {
"fetchapi": {
"File": "backend_fetchapi.so",
"Run": "always",
"Filter": [
"1 1 EQ"
],
"Config": {
"BufferSize": 100
}
},
"Dummy": {
"File": "backend_dummy.so",
"Run": "always",
"Filters": [
"Filter": [
"1 1 EQ"
]
},
Expand All @@ -49,12 +59,15 @@
"JsonBackend": {
"File": "backend_json.so",
"Run": "always",
"Filters": [
"Filter": [
"1 1 EQ"
],
"Config": {
"StoragePath": "/tmp/elosd_%host%_%date%_%count%.log",
"Flags": []
"MaxSize": 60000,
"Flags": [
"O_SYNC"
]
}
},
"SQLBackend": {
Expand All @@ -71,7 +84,7 @@
"File": "backend_dlt_logger.so",
"Run": "always",
"Filter": [
".messageCode 1000 GE"
".e.messageCode 1000 GE"
],
"Config": {
"Connection": "/tmp/dlt",
Expand All @@ -98,9 +111,9 @@
"SyslogPath": "/dev/log",
"MappingRules": {
"MessageCodes": {
"4000": ".event.source.appName 'ssh' STRCMP",
"2000": ".event.source.appName 'crinit' STRCMP",
"1000": ".event.source.appName 'login' STRCMP"
"8004": ".event.source.appName 'sshd' STRCMP .e.payload r'authentication failure' REGEX AND",
"8005": ".event.source.appName 'sshd' STRCMP .e.payload r'Accepted password for' REGEX AND",
"1001": "1 1 EQ"
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/components/event/private/event_vector.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,10 @@ safuResultE_t elosEventVectorPush(elosEventVector_t *eventVector, elosEvent_t co
}

safuResultE_t elosEventVectorPushDeepCopy(elosEventVector_t *eventVector, elosEvent_t const *event) {
elosEvent_t *newEvent = {0};
safuResultE_t result = elosEventDeepCopy(newEvent, event);
elosEvent_t newEvent = {0};
safuResultE_t result = elosEventDeepCopy(&newEvent, event);
if (result == SAFU_RESULT_OK) {
result = safuVecPush(eventVector, newEvent);
result = safuVecPush(eventVector, &newEvent);
}
return result;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
// SPDX-License-Identifier: MIT
#pragma once

#include <sys/cdefs.h>

#include "elos/event/event_types.h"
#include "elos/rpnfilter/rpnfilter_types.h"

__BEGIN_DECLS

#define ELOS_EVENTFILTER_INIT ELOS_RPNFILTER_INIT

typedef enum elosEventFilterValueTypeE {
Expand All @@ -25,4 +29,6 @@ typedef enum elosEventFilterValueTypeE {

typedef elosRpnFilterParam_t elosEventFilterParam_t;
typedef elosRpnFilterStack_t elosEventFilterStack_t;
typedef elosRpnFilter_t elosEventFilter_t;
typedef elosRpnFilter_t elosEventFilter_t;

__END_DECLS
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@
#ifndef ELOS_EVENTFILTER_STEP_H
#define ELOS_EVENTFILTER_STEP_H

#include <sys/cdefs.h>

#include "elos/rpnfilter/step_types.h"

__BEGIN_DECLS

// Filter step based data types
typedef enum elosEventFilterStepTypeE {
EVENTFILTER_STEP_LDI_EV = RPNFILTER_STEP_TYPE_COUNT,
EVENTFILTER_STEP_TYPE_COUNT
} elosEventFilterStepTypeE_t;

__END_DECLS

#endif /* ELOS_EVENTFILTER_STEP_H */
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
// SPDX-License-Identifier: MIT
#pragma once

#include <sys/cdefs.h>

#include "elos/rpnfilter/vector_types.h"

__BEGIN_DECLS

typedef elosRpnFilterVector_t elosEventFilterVector_t;

__END_DECLS
18 changes: 18 additions & 0 deletions src/components/eventfilter/private/eventfilter_execute.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
// SPDX-License-Identifier: MIT

#include <safu/result.h>

#include "elos/eventfilter/builder.h"
#include "elos/eventfilter/eventfilter.h"
#include "elos/eventfilter/execute.h"
#include "elos/rpnfilter/rpnfilter_types.h"
#include "safu/common.h"
#include "safu/log.h"
#include "safu/time.h"

elosRpnFilterResultE_t _executeEvent(elosRpnFilterExecute_t *ctx) {
elosRpnFilterResultE_t result = RPNFILTER_RESULT_OK;
Expand Down Expand Up @@ -115,3 +119,17 @@ elosRpnFilterResultE_t elosEventFilterExecute(elosRpnFilter_t const *filter, elo
elosRpnFilterExecuteFunc_t func[] = {elosEventFilterExecuteStep, elosRpnFilterExecuteStep};
return elosRpnFilterExecuteWith(filter, param, input, func, ARRAY_SIZE(func));
}

elosRpnFilterResultE_t elosEventFilterExecuteInTimeRange(elosEventFilter_t const *filter,
elosEventFilterStack_t const *param,
struct timespec const *newest, struct timespec const *oldest,
elosEvent_t *input) {
elosRpnFilterResultE_t result = RPNFILTER_RESULT_NO_MATCH;
if (newest == NULL || oldest == NULL || input == NULL) {
safuLogErr("paramterer NULL pointer");
result = RPNFILTER_RESULT_ERROR;
} else if (safuTimeSpecInTimeRange(*newest, input->date, *oldest)) {
result = elosEventFilterExecute(filter, param, input);
}
return result;
}
4 changes: 2 additions & 2 deletions src/components/eventfilter/public/elos/eventfilter/builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include "elos/eventfilter/step_types.h"
#include "elos/rpnfilter/builder.h"

__BEGIN_DECLS

#define elosEventFilterBuilderNew elosRpnFilterBuilderNew
#define elosEventFilterBuilderDelete elosRpnFilterBuilderDelete

Expand All @@ -14,8 +16,6 @@ typedef enum elosEventFilterBuilderTokenTypeE {
EVENTFILTER_TOKEN_TYPE_COUNT,
} elosEventFilterBuilderTokenTypeE_t;

__BEGIN_DECLS

elosRpnFilterResultE_t elosEventFilterBuilderCompileToken(elosRpnFilterBuilderTokenEntry_t const *token,
elosRpnFilterBuilder_t *data);

Expand Down
Loading

0 comments on commit 1fdf17b

Please sign in to comment.