New meson option enable_endpoint_security (auto, macOS only) links EndpointSecurity and bsm and builds three ES backends behind the existing interfaces. Helpers are in src/platform/es_support.hpp. - ProcessMonitor: NOTIFY_EXEC events (pid, parent, path, dev:ino, argv, start time) plus NOTIFY_TRACE and NOTIFY_KEXTLOAD for the behavior rules. Events go to a bounded queue (4096, overflow counted in events_dropped) drained on the monitor thread, so callbacks stay on one thread. Without an ES client the monitor polls libproc (backend "libproc"). backend_name() reports "endpoint_security". - ExecGuard: AUTH_EXEC with the fanotify guard's rules. It fails open at min(timeout, ES deadline - 500 ms) and on a full queue, and on macOS 27+ ES_DEADLINE_MISS_MODE_FAIL_OPEN makes the kernel allow a missed deadline too. Platform binaries and SIP paths are never denied, and our own execs are muted. ES does not cache verdicts, so rule changes apply on the next exec. Our own cache keys on dev:ino:size:mtime:generation. The image is opened by path and its dev:ino checked against the event; a swapped file counts as unscanned. - FileWatcher: NOTIFY_CREATE/RENAME/CLOSE(modified) with inverted target-path muting: named entries selected literally, whole directories by prefix. macos_watch_specs() covers launchd agents/daemons, periodic jobs, cron tabs, sudo drop-ins, shell rc files, authorized_keys, Downloads and the temp directories. match_watch_spec() (direct children, as with fanotify directory marks) is portable and tested. Home dirs come from the directory service (local_home_dirs). Every ES handler is noexcept and records swallowed exceptions. Client errors name the missing requirement (root, entitlement, Full Disk Access), and the daemon keeps running detection-only. macos_es_live (root, ES entitlement) checks deny/allow/cache/ platform-binary/fail-open/audit for the guard, exec telemetry and the file watcher, using small signed payload binaries. It has not run yet: the development Mac has SIP enabled. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
175 lines
5.9 KiB
Meson
175 lines
5.9 KiB
Meson
project('strawberry', 'cpp',
|
|
version: '0.1.0',
|
|
license: 'MIT',
|
|
meson_version: '>=1.0.0',
|
|
subproject_dir: 'third_party',
|
|
default_options: [
|
|
'cpp_std=c++23',
|
|
'warning_level=3',
|
|
'werror=false',
|
|
'optimization=2',
|
|
'b_lto=true',
|
|
]
|
|
)
|
|
|
|
# Compiler setup
|
|
cpp = meson.get_compiler('cpp')
|
|
clang_prog = find_program('clang', required: false)
|
|
|
|
# Check for ccache
|
|
ccache = find_program('ccache', required: false)
|
|
if ccache.found()
|
|
message('Using ccache for compilation')
|
|
endif
|
|
|
|
# Dependencies
|
|
threads_dep = dependency('threads', required: true)
|
|
openssl_dep = dependency('openssl', required: true)
|
|
# Header-only JSON: policy payloads on the control socket, policy/feeds state.
|
|
nlohmann_json_dep = dependency('nlohmann_json', required: true)
|
|
# Event store: every block is a zstd frame (compressed by default).
|
|
zstd_dep = dependency('libzstd', version: '>=1.5', required: true)
|
|
|
|
common_deps = [
|
|
threads_dep,
|
|
openssl_dep,
|
|
nlohmann_json_dep,
|
|
zstd_dep,
|
|
]
|
|
|
|
# Rule updater (strawberry --update-rules): HTTPS download + archive extraction.
|
|
libcurl_dep = dependency('libcurl', required: false)
|
|
libarchive_dep = dependency('libarchive', required: false)
|
|
strawberry_updater_available = libcurl_dep.found() and libarchive_dep.found()
|
|
if strawberry_updater_available
|
|
updater_feature_dep = declare_dependency(
|
|
compile_args: ['-DSTRAWBERRY_HAVE_UPDATER=1'],
|
|
dependencies: [libcurl_dep, libarchive_dep],
|
|
)
|
|
else
|
|
warning('libcurl/libarchive not found: strawberry --update-rules will be unavailable')
|
|
updater_feature_dep = declare_dependency(compile_args: ['-DSTRAWBERRY_HAVE_UPDATER=0'])
|
|
endif
|
|
|
|
# YARA library
|
|
yara_dep = dependency('yara', required: false)
|
|
if not yara_dep.found()
|
|
yara_dep = cpp.find_library('yara', required: false)
|
|
endif
|
|
|
|
if yara_dep.found()
|
|
yara_feature_dep = declare_dependency(compile_args: ['-DSTRAWBERRY_HAVE_YARA=1'])
|
|
else
|
|
yara_feature_dep = declare_dependency(compile_args: ['-DSTRAWBERRY_HAVE_YARA=0'])
|
|
endif
|
|
|
|
# BPF dependencies
|
|
libbpf_dep = dependency('libbpf', required: false)
|
|
if not libbpf_dep.found()
|
|
libbpf_dep = cpp.find_library('bpf', required: false)
|
|
endif
|
|
|
|
libbpf_headers_found = false
|
|
if host_machine.system() == 'linux'
|
|
libbpf_headers_found = cpp.has_header('bpf/libbpf.h')
|
|
endif
|
|
|
|
strawberry_libbpf_backend_available = host_machine.system() == 'linux' and libbpf_dep.found() and libbpf_headers_found and clang_prog.found()
|
|
|
|
strawberry_bpf_build_object_path = join_paths(meson.project_build_root(), 'src', 'process_monitor.bpf.o')
|
|
strawberry_bpf_install_object_path = join_paths(get_option('prefix'), get_option('datadir'), 'strawberry', 'process_monitor.bpf.o')
|
|
|
|
if strawberry_libbpf_backend_available
|
|
libbpf_feature_dep = declare_dependency(
|
|
compile_args: [
|
|
'-DSTRAWBERRY_HAVE_LIBBPF=1',
|
|
'-DSTRAWBERRY_BPF_OBJECT_BUILD_PATH="' + strawberry_bpf_build_object_path + '"',
|
|
'-DSTRAWBERRY_BPF_OBJECT_INSTALL_PATH="' + strawberry_bpf_install_object_path + '"',
|
|
],
|
|
)
|
|
else
|
|
libbpf_feature_dep = declare_dependency(compile_args: ['-DSTRAWBERRY_HAVE_LIBBPF=0'])
|
|
endif
|
|
|
|
# Endpoint Security (macOS): exec telemetry, exec prevention and file
|
|
# watching. Building only needs the SDK; running needs root, the ES
|
|
# entitlement and Full Disk Access (see src/platform/es_support.hpp).
|
|
strawberry_es_available = false
|
|
es_feature_dep = declare_dependency(compile_args: ['-DSTRAWBERRY_HAVE_ENDPOINT_SECURITY=0'])
|
|
if host_machine.system() == 'darwin' and get_option('enable_endpoint_security').allowed()
|
|
es_lib = cpp.find_library('EndpointSecurity', required: get_option('enable_endpoint_security'))
|
|
bsm_lib = cpp.find_library('bsm', required: get_option('enable_endpoint_security'))
|
|
if es_lib.found() and bsm_lib.found() and cpp.has_header('EndpointSecurity/EndpointSecurity.h', args: ['-fblocks'])
|
|
strawberry_es_available = true
|
|
es_feature_dep = declare_dependency(
|
|
compile_args: ['-DSTRAWBERRY_HAVE_ENDPOINT_SECURITY=1', '-fblocks'],
|
|
dependencies: [es_lib, bsm_lib],
|
|
)
|
|
endif
|
|
elif get_option('enable_endpoint_security').enabled()
|
|
error('enable_endpoint_security is macOS only')
|
|
endif
|
|
|
|
# Fuzzing: instrument the whole project so targets see coverage in the code
|
|
# they call. clang only.
|
|
if get_option('enable_fuzzing')
|
|
if cpp.get_id() != 'clang'
|
|
error('enable_fuzzing needs clang (CC=clang CXX=clang++)')
|
|
endif
|
|
add_project_arguments('-fsanitize=fuzzer-no-link,address,undefined', '-fno-omit-frame-pointer', '-g',
|
|
language: ['c', 'cpp'])
|
|
add_project_link_arguments('-fsanitize=address,undefined', language: ['c', 'cpp'])
|
|
endif
|
|
|
|
# Optional Tracy profiling (see include/strawberry/profiling.hpp).
|
|
if get_option('enable_profiling')
|
|
tracy_dep = dependency('tracy', fallback: ['tracy', 'tracy_dep'], required: true)
|
|
profiling_feature_dep = declare_dependency(
|
|
compile_args: ['-DTRACY_ENABLE', '-fno-omit-frame-pointer'],
|
|
dependencies: [tracy_dep],
|
|
)
|
|
else
|
|
profiling_feature_dep = declare_dependency()
|
|
endif
|
|
|
|
strawberry_feature_deps = [yara_feature_dep, libbpf_feature_dep, es_feature_dep, profiling_feature_dep]
|
|
strawberry_runtime_deps = common_deps + strawberry_feature_deps
|
|
strawberry_yara_deps = common_deps + strawberry_feature_deps
|
|
strawberry_monitor_deps = common_deps + strawberry_feature_deps
|
|
if yara_dep.found()
|
|
strawberry_yara_deps += yara_dep
|
|
endif
|
|
if libbpf_dep.found()
|
|
strawberry_monitor_deps += libbpf_dep
|
|
endif
|
|
|
|
# Project include directories
|
|
inc_dirs = include_directories('include')
|
|
|
|
# Subdirectories
|
|
subdir('src')
|
|
|
|
# Desktop app (optional, Qt6)
|
|
# DBus carries desktop notifications on Linux only (app/notifier.cpp).
|
|
qt6_modules = ['Core', 'Gui', 'Widgets', 'Network']
|
|
if host_machine.system() == 'linux'
|
|
qt6_modules += 'DBus'
|
|
endif
|
|
qt6_dep = dependency('qt6', modules: qt6_modules, required: get_option('enable_app'))
|
|
if qt6_dep.found()
|
|
subdir('app')
|
|
endif
|
|
|
|
# Agent access: MCP server (optional)
|
|
if get_option('enable_mcp').allowed()
|
|
subdir('mcp')
|
|
endif
|
|
|
|
# Tests (optional)
|
|
if get_option('enable_tests')
|
|
subdir('tests')
|
|
endif
|
|
|
|
if get_option('enable_fuzzing')
|
|
subdir('fuzz')
|
|
endif
|