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

new(anomalydetection): Initial Scope - CountMinSketch Powered Probabilistic Counting and Filtering #419

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
1d82a07
new(anomalydetection): init plugin / start dev
incertum Feb 27, 2024
047afba
cleanup(anomalydetection): cms class updates
incertum Jun 3, 2024
c7b22e1
new(anomalydetection): start unit tests + bump libs and sdk
incertum Jun 3, 2024
0a02b5b
new(anomalydetection): init config + start behavior profile extraction
incertum Jun 21, 2024
e5e9599
update(anomalydetection): sync plugin to latest SDK changes
jasondellaluce Jul 2, 2024
3353355
update(anomalydetection): populate info for proc args
jasondellaluce Jul 2, 2024
b7ee15d
update(anomalydetection): unit tests for proc lineage + add filterche…
incertum Jul 9, 2024
feeb93c
update(anomalydetection): add lastevent_fd + enhance robustness / tes…
incertum Jul 25, 2024
409bc11
update(anomalydetection): finish currently supported behavior profile…
incertum Jul 31, 2024
f006a58
update(anomalydetection): add MutexGuard (adopted from libs) to sketc…
incertum Aug 1, 2024
fbf22f4
update(anomalydetection): add some custom behavior profile short-cut …
incertum Aug 2, 2024
059e983
update(anomalydetection): add some fallbacks / evt param extraction i…
incertum Aug 13, 2024
1dc61ee
update(anomalydetection): more usage safeguards and info log messages
incertum Aug 14, 2024
f640d78
update(anomalydetection): ability to reset data structures w/ timers
incertum Aug 15, 2024
90d3adc
update(anomalydetection): helper new filtercheck / output field anoma…
incertum Aug 15, 2024
3ce1d44
update(anomalydetection): update documentation
incertum Aug 21, 2024
f6b9a42
update(anomalydetection): tweak inits when count_min_sketch disabled …
incertum Aug 22, 2024
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
6 changes: 6 additions & 0 deletions plugins/anomalydetection/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*.so
*.a
*.o
.vscode
build*
libanomalydetection.so
57 changes: 57 additions & 0 deletions plugins/anomalydetection/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# SPDX-License-Identifier: Apache-2.0
#
# Copyright (C) 2024 The Falco Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
#

cmake_minimum_required(VERSION 3.22)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")

option(BUILD_TESTS "Enable tests" ON)

# Project metadata
project(
anomalydetection
VERSION 0.1.0
DESCRIPTION "Falco Anomaly Detection Plugin"
LANGUAGES CXX)

# Dependencies
include(FetchContent)
include(plugin-sdk-cpp)
include(libs) # Temporarily include libs for initial dev
include(xxhash)

# Project target
file(GLOB_RECURSE anomalydetection_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
add_library(anomalydetection SHARED ${anomalydetection_SOURCES} )
set_target_properties(anomalydetection PROPERTIES CXX_EXTENSIONS OFF)

# Project compilation options
target_compile_options(anomalydetection PRIVATE "-fPIC")
target_compile_options(anomalydetection PRIVATE "-Wl,-z,relro,-z,now")
target_compile_options(anomalydetection PRIVATE "-fstack-protector-strong")
# When compiling in Debug mode, this will define the DEBUG symbol for use in your code
target_compile_options(anomalydetection PUBLIC "$<$<CONFIG:DEBUG>:-DDEBUG>")
target_compile_features(anomalydetection PUBLIC cxx_std_17)

# Project includes
target_include_directories(
anomalydetection PRIVATE "${PLUGIN_SDK_INCLUDE}" "${XXHASH_INCLUDE}" "${LIBS_INCLUDE}")

# Project linked libraries
target_link_libraries(anomalydetection ${_REFLECTION})

# Testing
if(BUILD_TESTS)
add_subdirectory(test)
endif()
36 changes: 36 additions & 0 deletions plugins/anomalydetection/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# SPDX-License-Identifier: Apache-2.0
#
# Copyright (C) 2024 The Falco Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
#

NAME := anomalydetection
OUTPUT := lib$(NAME).so

all: $(OUTPUT)

clean:
rm -rf build $(OUTPUT)
# Temporarily include libs for initial dev
$(OUTPUT):
mkdir -p build \
&& cd build \
&& cmake \
-DCMAKE_BUILD_TYPE=Release \
-DMINIMAL_BUILD=ON \
-DUSE_BUNDLED_LIBELF=OFF \
-DCREATE_TEST_TARGETS=OFF \
../ \
&& make -j6 anomalydetection \
&& cp ./$(OUTPUT) ../$(OUTPUT)

readme:
@$(READMETOOL) -p ./$(OUTPUT) -f README.md
317 changes: 317 additions & 0 deletions plugins/anomalydetection/README.md

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions plugins/anomalydetection/cmake/modules/libs.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# SPDX-License-Identifier: Apache-2.0
#
# Copyright (C) 2024 The Falco Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
#

message(STATUS "Fetching libs at 'https://github.com/falcosecurity/libs.git'")

FetchContent_Declare(
libs
GIT_REPOSITORY https://github.com/falcosecurity/libs.git
GIT_TAG 273299c5832ab7efa6a93547f7c3bd55706b135c
CONFIGURE_COMMAND "" BUILD_COMMAND "")

FetchContent_MakeAvailable(libs)
set(LIBS_INCLUDE "${libs_SOURCE_DIR}")
set(LIBS_DIR "${libs_SOURCE_DIR}")
message(STATUS "Using libs include at '${LIBS_INCLUDE}'")
27 changes: 27 additions & 0 deletions plugins/anomalydetection/cmake/modules/plugin-sdk-cpp.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# SPDX-License-Identifier: Apache-2.0
#
# Copyright (C) 2024 The Falco Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
#

message(
STATUS
"Fetching plugin-sdk-cpp at 'https://github.com/falcosecurity/plugin-sdk-cpp.git'"
)

FetchContent_Declare(
plugin-sdk-cpp
GIT_REPOSITORY https://github.com/falcosecurity/plugin-sdk-cpp.git
GIT_TAG 1c46ba02e8e9fe30a8362a54e99a6c3c804661f6)

FetchContent_MakeAvailable(plugin-sdk-cpp)
set(PLUGIN_SDK_INCLUDE "${plugin-sdk-cpp_SOURCE_DIR}/include")
message(STATUS "Using plugin-sdk-cpp include at '${PLUGIN_SDK_INCLUDE}'")
31 changes: 31 additions & 0 deletions plugins/anomalydetection/cmake/modules/xxhash.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# SPDX-License-Identifier: Apache-2.0
#
# Copyright (C) 2024 The Falco Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
#

message(
STATUS
"Fetching xxhash at 'https://raw.githubusercontent.com/Cyan4973/xxHash/v0.8.2/xxhash.h'"
)

FetchContent_Declare(
# BSD 2-Clause License
xxhash
URL "https://raw.githubusercontent.com/Cyan4973/xxHash/v0.8.2/xxhash.h"
URL_HASH SHA256=be275e9db21a503c37f24683cdb4908f2370a3e35ab96e02c4ea73dc8e399c43
DOWNLOAD_NAME "xxhash.h"
DOWNLOAD_NO_EXTRACT TRUE
)

FetchContent_MakeAvailable(xxhash)
set(XXHASH_INCLUDE "${xxhash_SOURCE_DIR}")
message(STATUS "Using xxhash include at '${XXHASH_INCLUDE}'")
Loading
Loading