From f3c4052ca0ba682d22091f987737747e12caad8b Mon Sep 17 00:00:00 2001 From: Leonardo Grasso Date: Wed, 4 Oct 2023 17:37:57 +0200 Subject: [PATCH 1/5] docs(userspace): add SPDX license identifier Signed-off-by: Leonardo Grasso --- userspace/chisel/chisel.cpp | 3 +- userspace/chisel/chisel.h | 3 +- userspace/chisel/chisel_api.cpp | 3 +- userspace/chisel/chisel_api.h | 3 +- .../chisel_capture_interrupt_exception.h | 3 +- userspace/chisel/chisel_fields_info.cpp | 3 +- userspace/chisel/chisel_fields_info.h | 5 +- userspace/chisel/chisel_table.cpp | 3 +- userspace/chisel/chisel_table.h | 3 +- userspace/chisel/chisel_utils.cpp | 3 +- userspace/chisel/chisel_utils.h | 5 +- userspace/chisel/chisel_viewinfo.cpp | 3 +- userspace/chisel/chisel_viewinfo.h | 3 +- userspace/common/common_config.h.in | 1 + userspace/common/strl.h | 3 +- userspace/common/types.h | 3 +- userspace/libpman/include/libpman.h | 3 +- userspace/libpman/src/configuration.c | 3 +- userspace/libpman/src/events_prog_names.h | 3 +- userspace/libpman/src/lifecycle.c | 3 +- userspace/libpman/src/maps.c | 3 +- userspace/libpman/src/programs.c | 3 +- userspace/libpman/src/ringbuffer.c | 3 +- .../libpman/src/ringbuffer_definitions.h | 3 +- userspace/libpman/src/sc_set.c | 1 + userspace/libpman/src/state.c | 3 +- userspace/libpman/src/state.h | 3 +- userspace/libpman/src/stats.c | 1 + userspace/libscap/CMakeLists.txt | 3 +- userspace/libscap/clock_helpers.h | 3 +- userspace/libscap/compat/misc.h | 3 +- userspace/libscap/debug_log_helpers.h | 3 +- userspace/libscap/emscripten/gettimeofday.h | 3 +- userspace/libscap/emscripten/sleep.h | 3 +- userspace/libscap/engine/bpf/attached_prog.c | 1 + userspace/libscap/engine/bpf/attached_prog.h | 1 + userspace/libscap/engine/bpf/bpf.h | 3 +- userspace/libscap/engine/bpf/bpf_public.h | 3 +- userspace/libscap/engine/bpf/scap_bpf.c | 3 +- userspace/libscap/engine/bpf/scap_bpf.h | 3 +- userspace/libscap/engine/bpf/scap_bpf_stats.h | 1 + userspace/libscap/engine/gvisor/gvisor.cpp | 3 +- userspace/libscap/engine/gvisor/gvisor.h | 3 +- .../libscap/engine/gvisor/gvisor_platform.h | 1 + .../libscap/engine/gvisor/gvisor_public.h | 3 +- userspace/libscap/engine/gvisor/parsers.cpp | 5 +- userspace/libscap/engine/gvisor/parsers.h | 5 +- userspace/libscap/engine/gvisor/runsc.cpp | 5 +- .../libscap/engine/gvisor/scap_gvisor.cpp | 3 +- .../engine/gvisor/scap_gvisor_platform.cpp | 1 + .../libscap/engine/gvisor/scap_gvisor_stats.h | 1 + userspace/libscap/engine/kmod/kmod.h | 3 +- userspace/libscap/engine/kmod/kmod_public.h | 3 +- userspace/libscap/engine/kmod/scap_kmod.c | 3 +- .../libscap/engine/kmod/scap_kmod_stats.h | 1 + .../engine/modern_bpf/modern_bpf_public.h | 3 +- .../engine/modern_bpf/scap_modern_bpf.c | 1 + .../engine/modern_bpf/scap_modern_bpf.h | 3 +- userspace/libscap/engine/nodriver/nodriver.c | 3 +- userspace/libscap/engine/nodriver/nodriver.h | 5 +- .../libscap/engine/nodriver/nodriver_public.h | 3 +- userspace/libscap/engine/noop/noop.c | 3 +- userspace/libscap/engine/noop/noop.h | 3 +- userspace/libscap/engine/savefile/savefile.h | 3 +- .../engine/savefile/savefile_platform.h | 1 + .../libscap/engine/savefile/savefile_public.h | 3 +- .../libscap/engine/savefile/scap_reader.h | 3 +- .../engine/savefile/scap_reader_buffered.c | 3 +- .../engine/savefile/scap_reader_gzfile.c | 3 +- .../libscap/engine/savefile/scap_savefile.c | 4771 +++++++++-------- .../engine/source_plugin/plugin_info.h | 5 +- .../engine/source_plugin/source_plugin.c | 3 +- .../engine/source_plugin/source_plugin.h | 5 +- .../source_plugin/source_plugin_public.h | 3 +- .../source_plugin/source_plugin_stats.h | 1 + .../libscap/engine/test_input/scap_test.h | 3 +- .../libscap/engine/test_input/test_input.c | 3 +- .../engine/test_input/test_input_platform.c | 1 + .../engine/test_input/test_input_platform.h | 1 + .../engine/test_input/test_input_public.h | 3 +- userspace/libscap/engine/udig/udig.h | 3 +- userspace/libscap/engine/udig/udig_public.h | 3 +- userspace/libscap/engine_handle.h | 3 +- .../libscap/examples/01-open/scap_open.c | 3 +- .../libscap/examples/02-validatebuffer/test.c | 3 +- userspace/libscap/linux/gettimeofday.h | 3 +- userspace/libscap/linux/scap_cgroup.c | 1 + userspace/libscap/linux/scap_cgroup.h | 1 + userspace/libscap/linux/scap_fds.c | 3 +- userspace/libscap/linux/scap_iflist.c | 3 +- userspace/libscap/linux/scap_linux_int.h | 3 +- userspace/libscap/linux/scap_linux_platform.c | 1 + userspace/libscap/linux/scap_linux_platform.h | 1 + userspace/libscap/linux/scap_machine_info.c | 1 + userspace/libscap/linux/scap_ppm_sc.c | 1 + userspace/libscap/linux/scap_procs.c | 3 +- userspace/libscap/linux/scap_userlist.c | 3 +- userspace/libscap/linux/sleep.h | 3 +- userspace/libscap/linux/unixid.h | 3 +- userspace/libscap/macos/gettimeofday.h | 3 +- userspace/libscap/macos/sleep.h | 3 +- userspace/libscap/ppm_sc_names.c | 1 + userspace/libscap/ringbuffer/devset.h | 3 +- userspace/libscap/ringbuffer/ringbuffer.c | 3 +- userspace/libscap/ringbuffer/ringbuffer.h | 3 +- userspace/libscap/scap-int.h | 3 +- userspace/libscap/scap.c | 3 +- userspace/libscap/scap.h | 3 +- userspace/libscap/scap_api_version.c | 1 + userspace/libscap/scap_api_version.h | 1 + userspace/libscap/scap_assert.h | 3 +- userspace/libscap/scap_cgroup_set.h | 1 + userspace/libscap/scap_const.h | 3 +- userspace/libscap/scap_engine_util.c | 3 +- userspace/libscap/scap_engine_util.h | 3 +- userspace/libscap/scap_engines.h | 3 +- userspace/libscap/scap_event.c | 3 +- userspace/libscap/scap_fds.c | 3 +- userspace/libscap/scap_iflist.c | 3 +- userspace/libscap/scap_limits.h | 3 +- userspace/libscap/scap_machine_info.h | 3 +- userspace/libscap/scap_open.h | 3 +- userspace/libscap/scap_platform.c | 1 + userspace/libscap/scap_platform.h | 1 + userspace/libscap/scap_platform_api.c | 3 +- userspace/libscap/scap_platform_api.h | 3 +- userspace/libscap/scap_platform_impl.h | 1 + userspace/libscap/scap_proc_util.c | 3 +- userspace/libscap/scap_proc_util.h | 3 +- userspace/libscap/scap_procs.c | 3 +- userspace/libscap/scap_procs.h | 3 +- userspace/libscap/scap_savefile.c | 2885 +++++----- userspace/libscap/scap_savefile.h | 3 +- userspace/libscap/scap_savefile_api.h | 3 +- userspace/libscap/scap_stats_v2.h | 1 + userspace/libscap/scap_suppress.c | 3 +- userspace/libscap/scap_suppress.h | 3 +- userspace/libscap/scap_userlist.c | 3 +- userspace/libscap/scap_vtable.h | 3 +- userspace/libscap/scap_zlib.h | 3 +- userspace/libscap/settings.h | 3 +- userspace/libscap/strerror.c | 3 +- userspace/libscap/strerror.h | 3 +- userspace/libscap/uthash_ext.h | 1 + userspace/libscap/win32/gettimeofday.h | 3 +- userspace/libscap/win32/sleep.h | 3 +- userspace/libsinsp/CMakeLists.txt | 3 +- userspace/libsinsp/addrinfo.cpp | 3 +- userspace/libsinsp/addrinfo.h | 3 +- .../libsinsp/async/async_key_value_source.h | 3 +- userspace/libsinsp/capture_stats_source.h | 3 +- userspace/libsinsp/container.cpp | 3 +- userspace/libsinsp/container.h | 3 +- userspace/libsinsp/container_engine/bpm.cpp | 3 +- userspace/libsinsp/container_engine/bpm.h | 3 +- .../container_engine/container_async_source.h | 3 +- .../container_cache_interface.h | 3 +- .../container_engine_base.cpp | 3 +- .../container_engine/container_engine_base.h | 3 +- userspace/libsinsp/container_engine/cri.cpp | 3 +- userspace/libsinsp/container_engine/cri.h | 3 +- .../container_engine/docker/async_source.cpp | 3 +- .../docker/connection_linux.cpp | 3 +- .../container_engine/docker/docker_linux.cpp | 3 +- .../container_engine/docker/podman.cpp | 3 +- .../libsinsp/container_engine/libvirt_lxc.cpp | 3 +- .../libsinsp/container_engine/libvirt_lxc.h | 3 +- userspace/libsinsp/container_engine/lxc.cpp | 3 +- userspace/libsinsp/container_engine/lxc.h | 3 +- userspace/libsinsp/container_engine/mesos.cpp | 3 +- userspace/libsinsp/container_engine/mesos.h | 3 +- userspace/libsinsp/container_engine/rkt.cpp | 3 +- userspace/libsinsp/container_engine/rkt.h | 3 +- .../container_engine/sinsp_container_type.h | 3 +- .../container_engine/static_container.cpp | 3 +- .../container_engine/static_container.h | 3 +- userspace/libsinsp/container_info.cpp | 3 +- userspace/libsinsp/container_info.h | 3 +- userspace/libsinsp/cri.h | 3 +- userspace/libsinsp/cyclewriter.cpp | 3 +- userspace/libsinsp/cyclewriter.h | 3 +- userspace/libsinsp/dns_manager.cpp | 3 +- userspace/libsinsp/dns_manager.h | 3 +- userspace/libsinsp/dumper.cpp | 3 +- userspace/libsinsp/dumper.h | 3 +- userspace/libsinsp/event.cpp | 3 +- userspace/libsinsp/event.h | 3 +- userspace/libsinsp/eventformatter.cpp | 3 +- userspace/libsinsp/eventformatter.h | 3 +- userspace/libsinsp/events/sinsp_events.h | 1 + .../libsinsp/events/sinsp_events_ppm_sc.cpp | 3 +- userspace/libsinsp/events/sinsp_events_set.h | 1 + userspace/libsinsp/examples/test.cpp | 3 +- userspace/libsinsp/examples/util.cpp | 3 +- userspace/libsinsp/examples/util.h | 5 +- userspace/libsinsp/fdinfo.cpp | 3 +- userspace/libsinsp/fdinfo.h | 3 +- userspace/libsinsp/filter.cpp | 3 +- userspace/libsinsp/filter.h | 3 +- userspace/libsinsp/filter/ast.cpp | 3 +- userspace/libsinsp/filter/ast.h | 3 +- userspace/libsinsp/filter/escaping.cpp | 3 +- userspace/libsinsp/filter/escaping.h | 3 +- userspace/libsinsp/filter/parser.cpp | 3 +- userspace/libsinsp/filter/parser.h | 3 +- userspace/libsinsp/filter/ppm_codes.cpp | 1 + userspace/libsinsp/filter/ppm_codes.h | 1 + userspace/libsinsp/filter_check_list.cpp | 3 +- userspace/libsinsp/filter_check_list.h | 3 +- userspace/libsinsp/filter_value.h | 3 +- userspace/libsinsp/filterchecks.cpp | 3 +- userspace/libsinsp/filterchecks.h | 3 +- userspace/libsinsp/gen_filter.cpp | 3 +- userspace/libsinsp/gen_filter.h | 3 +- userspace/libsinsp/grpc_channel_registry.cpp | 3 +- userspace/libsinsp/grpc_channel_registry.h | 3 +- userspace/libsinsp/gvisor_config.cpp | 3 +- userspace/libsinsp/gvisor_config.h | 5 +- userspace/libsinsp/http_reason.cpp | 3 +- userspace/libsinsp/http_reason.h | 3 +- userspace/libsinsp/ifinfo.cpp | 3 +- userspace/libsinsp/ifinfo.h | 3 +- userspace/libsinsp/ifinfo_test.cpp | 5 +- userspace/libsinsp/internal_metrics.cpp | 3 +- userspace/libsinsp/internal_metrics.h | 3 +- userspace/libsinsp/json_error_log.cpp | 3 +- userspace/libsinsp/json_error_log.h | 3 +- userspace/libsinsp/json_query.cpp | 3 +- userspace/libsinsp/json_query.h | 3 +- userspace/libsinsp/k8s.cpp | 3 +- userspace/libsinsp/k8s.h | 5 +- userspace/libsinsp/k8s_api_error.cpp | 3 +- userspace/libsinsp/k8s_api_error.h | 5 +- userspace/libsinsp/k8s_api_handler.cpp | 3 +- userspace/libsinsp/k8s_api_handler.h | 3 +- userspace/libsinsp/k8s_component.cpp | 3 +- userspace/libsinsp/k8s_component.h | 5 +- userspace/libsinsp/k8s_daemonset_handler.cpp | 3 +- userspace/libsinsp/k8s_daemonset_handler.h | 5 +- userspace/libsinsp/k8s_deployment_handler.cpp | 3 +- userspace/libsinsp/k8s_deployment_handler.h | 5 +- userspace/libsinsp/k8s_dispatcher.cpp | 3 +- userspace/libsinsp/k8s_dispatcher.h | 5 +- userspace/libsinsp/k8s_event_data.cpp | 3 +- userspace/libsinsp/k8s_event_data.h | 5 +- userspace/libsinsp/k8s_event_handler.cpp | 3 +- userspace/libsinsp/k8s_event_handler.h | 5 +- userspace/libsinsp/k8s_handler.cpp | 3 +- userspace/libsinsp/k8s_handler.h | 5 +- userspace/libsinsp/k8s_namespace_handler.cpp | 3 +- userspace/libsinsp/k8s_namespace_handler.h | 5 +- userspace/libsinsp/k8s_net.cpp | 3 +- userspace/libsinsp/k8s_net.h | 5 +- userspace/libsinsp/k8s_node_handler.cpp | 3 +- userspace/libsinsp/k8s_node_handler.h | 5 +- userspace/libsinsp/k8s_pod_handler.cpp | 3 +- userspace/libsinsp/k8s_pod_handler.h | 5 +- userspace/libsinsp/k8s_replicaset_handler.cpp | 3 +- userspace/libsinsp/k8s_replicaset_handler.h | 5 +- .../k8s_replicationcontroller_handler.cpp | 3 +- .../k8s_replicationcontroller_handler.h | 5 +- userspace/libsinsp/k8s_service_handler.cpp | 5 +- userspace/libsinsp/k8s_service_handler.h | 5 +- userspace/libsinsp/k8s_state.cpp | 3 +- userspace/libsinsp/k8s_state.h | 5 +- userspace/libsinsp/logger.cpp | 3 +- userspace/libsinsp/logger.h | 3 +- userspace/libsinsp/marathon_component.cpp | 3 +- userspace/libsinsp/marathon_component.h | 5 +- userspace/libsinsp/marathon_http.cpp | 3 +- userspace/libsinsp/marathon_http.h | 5 +- userspace/libsinsp/memmem.cpp | 3 +- userspace/libsinsp/mesos.cpp | 3 +- userspace/libsinsp/mesos.h | 5 +- userspace/libsinsp/mesos_auth.cpp | 3 +- userspace/libsinsp/mesos_auth.h | 5 +- userspace/libsinsp/mesos_collector.cpp | 3 +- userspace/libsinsp/mesos_collector.h | 5 +- userspace/libsinsp/mesos_common.h | 3 +- userspace/libsinsp/mesos_component.cpp | 3 +- userspace/libsinsp/mesos_component.h | 5 +- userspace/libsinsp/mesos_http.cpp | 3 +- userspace/libsinsp/mesos_http.h | 5 +- userspace/libsinsp/mesos_state.cpp | 3 +- userspace/libsinsp/mesos_state.h | 3 +- userspace/libsinsp/mutex.h | 5 +- userspace/libsinsp/parsers.cpp | 3 +- userspace/libsinsp/parsers.h | 3 +- userspace/libsinsp/plugin.cpp | 1 + userspace/libsinsp/plugin.h | 1 + userspace/libsinsp/plugin_filtercheck.cpp | 3 +- userspace/libsinsp/plugin_filtercheck.h | 3 +- userspace/libsinsp/plugin_manager.h | 3 +- userspace/libsinsp/plugin_parser.h | 3 +- userspace/libsinsp/plugin_table_api.cpp | 1 + userspace/libsinsp/prefix_search.cpp | 3 +- userspace/libsinsp/prefix_search.h | 3 +- userspace/libsinsp/procfs_utils.cpp | 3 +- userspace/libsinsp/procinfo_test.cpp | 3 +- userspace/libsinsp/protodecoder.cpp | 3 +- userspace/libsinsp/protodecoder.h | 3 +- userspace/libsinsp/runc.cpp | 5 +- userspace/libsinsp/runc.h | 3 +- userspace/libsinsp/scap_open_exception.h | 3 +- userspace/libsinsp/settings.h | 3 +- userspace/libsinsp/sinsp.cpp | 3 +- userspace/libsinsp/sinsp.h | 3 +- userspace/libsinsp/sinsp_auth.cpp | 3 +- userspace/libsinsp/sinsp_auth.h | 3 +- userspace/libsinsp/sinsp_cgroup.cpp | 1 + userspace/libsinsp/sinsp_cgroup.h | 1 + userspace/libsinsp/sinsp_curl.cpp | 3 +- userspace/libsinsp/sinsp_curl.h | 3 +- userspace/libsinsp/sinsp_errno.h | 3 +- userspace/libsinsp/sinsp_event_source.h | 1 + userspace/libsinsp/sinsp_exception.h | 3 +- userspace/libsinsp/sinsp_inet.h | 3 +- userspace/libsinsp/sinsp_int.h | 3 +- userspace/libsinsp/sinsp_observer.h | 1 + userspace/libsinsp/sinsp_pd_callback_type.h | 3 +- userspace/libsinsp/sinsp_public.h | 3 +- .../libsinsp/sinsp_resource_utilization.cpp | 1 + .../libsinsp/sinsp_resource_utilization.h | 1 + userspace/libsinsp/sinsp_signal.h | 3 +- userspace/libsinsp/sinsp_test.cpp | 3 +- userspace/libsinsp/socket_collector.h | 5 +- userspace/libsinsp/socket_handler.h | 3 +- userspace/libsinsp/state/dynamic_struct.h | 1 + userspace/libsinsp/state/static_struct.h | 1 + userspace/libsinsp/state/table.h | 1 + userspace/libsinsp/state/table_registry.h | 1 + userspace/libsinsp/state/type_info.h | 1 + userspace/libsinsp/stats.cpp | 3 +- userspace/libsinsp/stats.h | 3 +- userspace/libsinsp/stopwatch.cpp | 3 +- userspace/libsinsp/stopwatch.h | 3 +- userspace/libsinsp/test/CMakeLists.txt | 1 + .../test/async_key_value_source.ut.cpp | 3 +- .../libsinsp/test/cgroup_list_counter.ut.cpp | 3 +- .../test/classes/sinsp_thread_manager.cpp | 1 + .../test/classes/sinsp_threadinfo.cpp | 1 + .../test/classes/thread_group_info.cpp | 1 + userspace/libsinsp/test/classes/versions.cpp | 3 +- userspace/libsinsp/test/container_info.ut.cpp | 3 +- userspace/libsinsp/test/eventformatter.ut.cpp | 3 +- userspace/libsinsp/test/events_evt.ut.cpp | 1 + userspace/libsinsp/test/events_file.ut.cpp | 5 +- userspace/libsinsp/test/events_fspath.ut.cpp | 1 + userspace/libsinsp/test/events_net.ut.cpp | 3 +- userspace/libsinsp/test/events_param.ut.cpp | 5 +- userspace/libsinsp/test/events_plugin.ut.cpp | 3 +- userspace/libsinsp/test/events_proc.ut.cpp | 3 +- userspace/libsinsp/test/events_user.ut.cpp | 3 +- .../libsinsp/test/external_processor.ut.cpp | 3 +- userspace/libsinsp/test/filter_compiler.h | 1 + .../libsinsp/test/filter_escaping.ut.cpp | 3 +- .../libsinsp/test/filter_op_bcontains.ut.cpp | 3 +- .../libsinsp/test/filter_op_pmatch.ut.cpp | 3 +- .../libsinsp/test/filter_ppm_codes.ut.cpp | 1 + userspace/libsinsp/test/filterchecks/evt.cpp | 1 + userspace/libsinsp/test/filterchecks/proc.cpp | 1 + .../test/helpers/scap_file_helpers.cpp | 1 + .../libsinsp/test/helpers/scap_file_helpers.h | 1 + .../libsinsp/test/helpers/threads_helpers.h | 1 + .../libsinsp/test/parsers/parse_clone.cpp | 1 + .../libsinsp/test/parsers/parse_execve.cpp | 1 + .../libsinsp/test/parsers/parse_prctl.cpp | 1 + .../libsinsp/test/parsers/parse_proc_exit.cpp | 1 + userspace/libsinsp/test/plugin_manager.ut.cpp | 3 +- userspace/libsinsp/test/plugins.ut.cpp | 1 + .../libsinsp/test/plugins/plugin_extract.cpp | 1 + .../libsinsp/test/plugins/plugin_source.cpp | 1 + .../libsinsp/test/plugins/sample_table.h | 1 + .../libsinsp/test/plugins/syscall_async.cpp | 1 + .../libsinsp/test/plugins/syscall_extract.cpp | 1 + .../libsinsp/test/plugins/syscall_parse.cpp | 1 + .../libsinsp/test/plugins/syscall_source.cpp | 1 + userspace/libsinsp/test/plugins/tables.cpp | 1 + .../libsinsp/test/plugins/test_plugins.h | 1 + .../libsinsp/test/ppm_api_version.ut.cpp | 3 +- userspace/libsinsp/test/prefix_search.ut.cpp | 1 + userspace/libsinsp/test/procfs_utils.ut.cpp | 3 +- .../test/public_sinsp_API/events_set.cpp | 1 + .../public_sinsp_API/interesting_syscalls.cpp | 1 + .../test/public_sinsp_API/ppm_sc_codes.cpp | 1 + .../test/public_sinsp_API/sinsp_logger.cpp | 1 + userspace/libsinsp/test/savefile.ut.cpp | 3 +- .../scap_files/kexec_arm64/kexec_arm64.cpp | 1 + .../test/scap_files/kexec_x86/kexec_x86.cpp | 1 + userspace/libsinsp/test/sinsp_utils.ut.cpp | 1 + .../libsinsp/test/sinsp_with_test_input.h | 3 +- userspace/libsinsp/test/state.ut.cpp | 3 +- userspace/libsinsp/test/string_visitor.ut.cpp | 3 +- userspace/libsinsp/test/test_utils.cpp | 3 +- userspace/libsinsp/test/test_utils.h | 3 +- userspace/libsinsp/test/thread_table.ut.cpp | 1 + userspace/libsinsp/test/user.ut.cpp | 3 +- userspace/libsinsp/thread_group_info.h | 1 + userspace/libsinsp/threadinfo.cpp | 3 +- userspace/libsinsp/threadinfo.h | 3 +- userspace/libsinsp/token_bucket.cpp | 3 +- userspace/libsinsp/token_bucket.h | 3 +- userspace/libsinsp/tracer_emitter.cpp | 3 +- userspace/libsinsp/tracer_emitter.h | 3 +- userspace/libsinsp/tracers.cpp | 3 +- userspace/libsinsp/tracers.h | 3 +- userspace/libsinsp/tuples.cpp | 3 +- userspace/libsinsp/tuples.h | 3 +- userspace/libsinsp/uri.cpp | 3 +- userspace/libsinsp/uri.h | 3 +- userspace/libsinsp/user.cpp | 3 +- userspace/libsinsp/user.h | 3 +- userspace/libsinsp/user_event.cpp | 3 +- userspace/libsinsp/user_event.h | 3 +- userspace/libsinsp/user_event_logger.cpp | 3 +- userspace/libsinsp/user_event_logger.h | 3 +- userspace/libsinsp/utils.cpp | 3 +- userspace/libsinsp/utils.h | 3 +- userspace/libsinsp/value_parser.cpp | 3 +- userspace/libsinsp/value_parser.h | 3 +- userspace/libsinsp/version.h | 3 +- userspace/plugin/plugin_api.h | 1 + userspace/plugin/plugin_loader.c | 1 + userspace/plugin/plugin_loader.h | 1 + userspace/plugin/plugin_types.h | 1 + 425 files changed, 4627 insertions(+), 4202 deletions(-) diff --git a/userspace/chisel/chisel.cpp b/userspace/chisel/chisel.cpp index c7af86739d..9a2fd9456a 100644 --- a/userspace/chisel/chisel.cpp +++ b/userspace/chisel/chisel.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/chisel/chisel.h b/userspace/chisel/chisel.h index 3205f8a205..5b160e4300 100644 --- a/userspace/chisel/chisel.h +++ b/userspace/chisel/chisel.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/chisel/chisel_api.cpp b/userspace/chisel/chisel_api.cpp index 9c8f48fb38..ec0142820f 100644 --- a/userspace/chisel/chisel_api.cpp +++ b/userspace/chisel/chisel_api.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/chisel/chisel_api.h b/userspace/chisel/chisel_api.h index 3df40c1163..e343789938 100644 --- a/userspace/chisel/chisel_api.h +++ b/userspace/chisel/chisel_api.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/chisel/chisel_capture_interrupt_exception.h b/userspace/chisel/chisel_capture_interrupt_exception.h index 1412a41ed3..cd6acef06b 100644 --- a/userspace/chisel/chisel_capture_interrupt_exception.h +++ b/userspace/chisel/chisel_capture_interrupt_exception.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/chisel/chisel_fields_info.cpp b/userspace/chisel/chisel_fields_info.cpp index e441d96489..86571fdb29 100644 --- a/userspace/chisel/chisel_fields_info.cpp +++ b/userspace/chisel/chisel_fields_info.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/chisel/chisel_fields_info.h b/userspace/chisel/chisel_fields_info.h index 01729a751b..2a14ed71bd 100644 --- a/userspace/chisel/chisel_fields_info.h +++ b/userspace/chisel/chisel_fields_info.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 The Falco Authors. Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,4 +22,4 @@ limitations under the License. #include void print_chisel_info(chisel_desc* cd); -void list_chisels(std::vector* chlist, bool verbose); \ No newline at end of file +void list_chisels(std::vector* chlist, bool verbose); diff --git a/userspace/chisel/chisel_table.cpp b/userspace/chisel/chisel_table.cpp index 7376427707..4ff7f4972e 100644 --- a/userspace/chisel/chisel_table.cpp +++ b/userspace/chisel/chisel_table.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/chisel/chisel_table.h b/userspace/chisel/chisel_table.h index 32b488b59e..f2b26bc108 100644 --- a/userspace/chisel/chisel_table.h +++ b/userspace/chisel/chisel_table.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/chisel/chisel_utils.cpp b/userspace/chisel/chisel_utils.cpp index 217c54569f..db613e738a 100644 --- a/userspace/chisel/chisel_utils.cpp +++ b/userspace/chisel/chisel_utils.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/chisel/chisel_utils.h b/userspace/chisel/chisel_utils.h index 7892d707b9..189d579582 100644 --- a/userspace/chisel/chisel_utils.h +++ b/userspace/chisel/chisel_utils.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. @@ -28,4 +29,4 @@ class chisel_initializer public: chisel_initializer(); ~chisel_initializer(); -}; \ No newline at end of file +}; diff --git a/userspace/chisel/chisel_viewinfo.cpp b/userspace/chisel/chisel_viewinfo.cpp index c7a8101589..b4295c2cd7 100644 --- a/userspace/chisel/chisel_viewinfo.cpp +++ b/userspace/chisel/chisel_viewinfo.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/chisel/chisel_viewinfo.h b/userspace/chisel/chisel_viewinfo.h index 961811cc14..d7fffcc1b9 100644 --- a/userspace/chisel/chisel_viewinfo.h +++ b/userspace/chisel/chisel_viewinfo.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/common/common_config.h.in b/userspace/common/common_config.h.in index 6b4001deea..80488b9e63 100644 --- a/userspace/common/common_config.h.in +++ b/userspace/common/common_config.h.in @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/common/strl.h b/userspace/common/strl.h index 5584ed6ef6..a315b82a0b 100644 --- a/userspace/common/strl.h +++ b/userspace/common/strl.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/common/types.h b/userspace/common/types.h index b172f4b162..5b917847c7 100644 --- a/userspace/common/types.h +++ b/userspace/common/types.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libpman/include/libpman.h b/userspace/libpman/include/libpman.h index 4d382875f9..7111d2e5a6 100644 --- a/userspace/libpman/include/libpman.h +++ b/userspace/libpman/include/libpman.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libpman/src/configuration.c b/userspace/libpman/src/configuration.c index b0974bcf49..1fca9e264b 100644 --- a/userspace/libpman/src/configuration.c +++ b/userspace/libpman/src/configuration.c @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libpman/src/events_prog_names.h b/userspace/libpman/src/events_prog_names.h index 0d3958ac89..7d62332652 100644 --- a/userspace/libpman/src/events_prog_names.h +++ b/userspace/libpman/src/events_prog_names.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libpman/src/lifecycle.c b/userspace/libpman/src/lifecycle.c index b1e5887ab8..46fba6ac18 100644 --- a/userspace/libpman/src/lifecycle.c +++ b/userspace/libpman/src/lifecycle.c @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libpman/src/maps.c b/userspace/libpman/src/maps.c index d71a878598..c71ce4f5c1 100644 --- a/userspace/libpman/src/maps.c +++ b/userspace/libpman/src/maps.c @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libpman/src/programs.c b/userspace/libpman/src/programs.c index 9cf68bafcc..71e6489ded 100644 --- a/userspace/libpman/src/programs.c +++ b/userspace/libpman/src/programs.c @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libpman/src/ringbuffer.c b/userspace/libpman/src/ringbuffer.c index b4a41ba1f5..e2146f1ccb 100644 --- a/userspace/libpman/src/ringbuffer.c +++ b/userspace/libpman/src/ringbuffer.c @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libpman/src/ringbuffer_definitions.h b/userspace/libpman/src/ringbuffer_definitions.h index 949d145afc..87367c6608 100644 --- a/userspace/libpman/src/ringbuffer_definitions.h +++ b/userspace/libpman/src/ringbuffer_definitions.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libpman/src/sc_set.c b/userspace/libpman/src/sc_set.c index b39b6b5ee0..0c1bc95631 100644 --- a/userspace/libpman/src/sc_set.c +++ b/userspace/libpman/src/sc_set.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libpman/src/state.c b/userspace/libpman/src/state.c index 21c9dc610e..6fcb455b2f 100644 --- a/userspace/libpman/src/state.c +++ b/userspace/libpman/src/state.c @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libpman/src/state.h b/userspace/libpman/src/state.h index 578585aa2f..9f83aee866 100644 --- a/userspace/libpman/src/state.h +++ b/userspace/libpman/src/state.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libpman/src/stats.c b/userspace/libpman/src/stats.c index dc7c4bacf8..337d2ea437 100644 --- a/userspace/libpman/src/stats.c +++ b/userspace/libpman/src/stats.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libscap/CMakeLists.txt b/userspace/libscap/CMakeLists.txt index 3c4d766ca2..38acf7940c 100644 --- a/userspace/libscap/CMakeLists.txt +++ b/userspace/libscap/CMakeLists.txt @@ -1,5 +1,6 @@ +# SPDX-License-Identifier: Apache-2.0 # -# Copyright (C) 2022 The Falco Authors. +# Copyright (C) 2023 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. diff --git a/userspace/libscap/clock_helpers.h b/userspace/libscap/clock_helpers.h index 24a9289ae1..1cd34dc16f 100644 --- a/userspace/libscap/clock_helpers.h +++ b/userspace/libscap/clock_helpers.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/compat/misc.h b/userspace/libscap/compat/misc.h index 37d6cac02f..d376b13753 100644 --- a/userspace/libscap/compat/misc.h +++ b/userspace/libscap/compat/misc.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/debug_log_helpers.h b/userspace/libscap/debug_log_helpers.h index bf31181c87..e040d5527b 100644 --- a/userspace/libscap/debug_log_helpers.h +++ b/userspace/libscap/debug_log_helpers.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/emscripten/gettimeofday.h b/userspace/libscap/emscripten/gettimeofday.h index a42e89d5dc..58af1b8064 100644 --- a/userspace/libscap/emscripten/gettimeofday.h +++ b/userspace/libscap/emscripten/gettimeofday.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/emscripten/sleep.h b/userspace/libscap/emscripten/sleep.h index 9afcf3dbaf..26578cdd87 100644 --- a/userspace/libscap/emscripten/sleep.h +++ b/userspace/libscap/emscripten/sleep.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/engine/bpf/attached_prog.c b/userspace/libscap/engine/bpf/attached_prog.c index d75d1a0b8c..b755ae68db 100644 --- a/userspace/libscap/engine/bpf/attached_prog.c +++ b/userspace/libscap/engine/bpf/attached_prog.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libscap/engine/bpf/attached_prog.h b/userspace/libscap/engine/bpf/attached_prog.h index d97971ca68..d3b83ffe75 100644 --- a/userspace/libscap/engine/bpf/attached_prog.h +++ b/userspace/libscap/engine/bpf/attached_prog.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libscap/engine/bpf/bpf.h b/userspace/libscap/engine/bpf/bpf.h index e2d5f0b839..d0d3e52657 100644 --- a/userspace/libscap/engine/bpf/bpf.h +++ b/userspace/libscap/engine/bpf/bpf.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/engine/bpf/bpf_public.h b/userspace/libscap/engine/bpf/bpf_public.h index 117c0d3c1e..3e665f6ca9 100644 --- a/userspace/libscap/engine/bpf/bpf_public.h +++ b/userspace/libscap/engine/bpf/bpf_public.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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 diff --git a/userspace/libscap/engine/bpf/scap_bpf.c b/userspace/libscap/engine/bpf/scap_bpf.c index 3c68a5a923..0d71d1bfc9 100644 --- a/userspace/libscap/engine/bpf/scap_bpf.c +++ b/userspace/libscap/engine/bpf/scap_bpf.c @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/engine/bpf/scap_bpf.h b/userspace/libscap/engine/bpf/scap_bpf.h index 44ec4318cf..ca024e9542 100644 --- a/userspace/libscap/engine/bpf/scap_bpf.h +++ b/userspace/libscap/engine/bpf/scap_bpf.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/engine/bpf/scap_bpf_stats.h b/userspace/libscap/engine/bpf/scap_bpf_stats.h index d596540d82..71a52b92af 100644 --- a/userspace/libscap/engine/bpf/scap_bpf_stats.h +++ b/userspace/libscap/engine/bpf/scap_bpf_stats.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libscap/engine/gvisor/gvisor.cpp b/userspace/libscap/engine/gvisor/gvisor.cpp index 3ac46292f7..d72b35129b 100644 --- a/userspace/libscap/engine/gvisor/gvisor.cpp +++ b/userspace/libscap/engine/gvisor/gvisor.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/engine/gvisor/gvisor.h b/userspace/libscap/engine/gvisor/gvisor.h index 5a53236490..8308c7ae7b 100644 --- a/userspace/libscap/engine/gvisor/gvisor.h +++ b/userspace/libscap/engine/gvisor/gvisor.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/engine/gvisor/gvisor_platform.h b/userspace/libscap/engine/gvisor/gvisor_platform.h index e9369d916a..18c75d0074 100644 --- a/userspace/libscap/engine/gvisor/gvisor_platform.h +++ b/userspace/libscap/engine/gvisor/gvisor_platform.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libscap/engine/gvisor/gvisor_public.h b/userspace/libscap/engine/gvisor/gvisor_public.h index 41c3011e1f..4f48001670 100644 --- a/userspace/libscap/engine/gvisor/gvisor_public.h +++ b/userspace/libscap/engine/gvisor/gvisor_public.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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 diff --git a/userspace/libscap/engine/gvisor/parsers.cpp b/userspace/libscap/engine/gvisor/parsers.cpp index 3198418a82..e58210ad75 100644 --- a/userspace/libscap/engine/gvisor/parsers.cpp +++ b/userspace/libscap/engine/gvisor/parsers.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. @@ -1639,4 +1640,4 @@ config_result parse_config(std::string config) } } // namespace parsers -} // namespace scap_gvisor \ No newline at end of file +} // namespace scap_gvisor diff --git a/userspace/libscap/engine/gvisor/parsers.h b/userspace/libscap/engine/gvisor/parsers.h index 64bae1b2e5..c26521c45e 100644 --- a/userspace/libscap/engine/gvisor/parsers.h +++ b/userspace/libscap/engine/gvisor/parsers.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. @@ -82,4 +83,4 @@ std::vector dispatchers = { } // namespace parsers -} // namespace scap_gvisor \ No newline at end of file +} // namespace scap_gvisor diff --git a/userspace/libscap/engine/gvisor/runsc.cpp b/userspace/libscap/engine/gvisor/runsc.cpp index 6fef794345..172d984b61 100644 --- a/userspace/libscap/engine/gvisor/runsc.cpp +++ b/userspace/libscap/engine/gvisor/runsc.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. @@ -166,4 +167,4 @@ result trace_procfs(const std::string &root_path, const std::string &sandbox_id) } // namespace runsc -} // namespace scap_gvisor \ No newline at end of file +} // namespace scap_gvisor diff --git a/userspace/libscap/engine/gvisor/scap_gvisor.cpp b/userspace/libscap/engine/gvisor/scap_gvisor.cpp index 45b6e6351b..70d2d13c8b 100644 --- a/userspace/libscap/engine/gvisor/scap_gvisor.cpp +++ b/userspace/libscap/engine/gvisor/scap_gvisor.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/engine/gvisor/scap_gvisor_platform.cpp b/userspace/libscap/engine/gvisor/scap_gvisor_platform.cpp index b20e91924a..dc7851b927 100644 --- a/userspace/libscap/engine/gvisor/scap_gvisor_platform.cpp +++ b/userspace/libscap/engine/gvisor/scap_gvisor_platform.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libscap/engine/gvisor/scap_gvisor_stats.h b/userspace/libscap/engine/gvisor/scap_gvisor_stats.h index f5bbd56e93..3aaa41bea1 100644 --- a/userspace/libscap/engine/gvisor/scap_gvisor_stats.h +++ b/userspace/libscap/engine/gvisor/scap_gvisor_stats.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libscap/engine/kmod/kmod.h b/userspace/libscap/engine/kmod/kmod.h index eb6decdb68..8f73de582e 100644 --- a/userspace/libscap/engine/kmod/kmod.h +++ b/userspace/libscap/engine/kmod/kmod.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/engine/kmod/kmod_public.h b/userspace/libscap/engine/kmod/kmod_public.h index 71502411a7..de7a23f611 100644 --- a/userspace/libscap/engine/kmod/kmod_public.h +++ b/userspace/libscap/engine/kmod/kmod_public.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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 diff --git a/userspace/libscap/engine/kmod/scap_kmod.c b/userspace/libscap/engine/kmod/scap_kmod.c index 47e05b14a3..1498c43bb8 100644 --- a/userspace/libscap/engine/kmod/scap_kmod.c +++ b/userspace/libscap/engine/kmod/scap_kmod.c @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/engine/kmod/scap_kmod_stats.h b/userspace/libscap/engine/kmod/scap_kmod_stats.h index 1beb0a87dd..bd2b531e1f 100644 --- a/userspace/libscap/engine/kmod/scap_kmod_stats.h +++ b/userspace/libscap/engine/kmod/scap_kmod_stats.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libscap/engine/modern_bpf/modern_bpf_public.h b/userspace/libscap/engine/modern_bpf/modern_bpf_public.h index 2ff5eb3a6c..0a81a766ed 100644 --- a/userspace/libscap/engine/modern_bpf/modern_bpf_public.h +++ b/userspace/libscap/engine/modern_bpf/modern_bpf_public.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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 diff --git a/userspace/libscap/engine/modern_bpf/scap_modern_bpf.c b/userspace/libscap/engine/modern_bpf/scap_modern_bpf.c index 797d867ec0..44c239cdba 100644 --- a/userspace/libscap/engine/modern_bpf/scap_modern_bpf.c +++ b/userspace/libscap/engine/modern_bpf/scap_modern_bpf.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libscap/engine/modern_bpf/scap_modern_bpf.h b/userspace/libscap/engine/modern_bpf/scap_modern_bpf.h index 2721305683..1934cff736 100644 --- a/userspace/libscap/engine/modern_bpf/scap_modern_bpf.h +++ b/userspace/libscap/engine/modern_bpf/scap_modern_bpf.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/engine/nodriver/nodriver.c b/userspace/libscap/engine/nodriver/nodriver.c index 890afc5a86..4380c3bde7 100644 --- a/userspace/libscap/engine/nodriver/nodriver.c +++ b/userspace/libscap/engine/nodriver/nodriver.c @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/engine/nodriver/nodriver.h b/userspace/libscap/engine/nodriver/nodriver.h index 1c9dda432c..3ae3928212 100644 --- a/userspace/libscap/engine/nodriver/nodriver.h +++ b/userspace/libscap/engine/nodriver/nodriver.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. @@ -23,4 +24,4 @@ struct scap; struct nodriver_engine { char* m_lasterr; -}; \ No newline at end of file +}; diff --git a/userspace/libscap/engine/nodriver/nodriver_public.h b/userspace/libscap/engine/nodriver/nodriver_public.h index dcc72626d4..f23f44048a 100644 --- a/userspace/libscap/engine/nodriver/nodriver_public.h +++ b/userspace/libscap/engine/nodriver/nodriver_public.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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 diff --git a/userspace/libscap/engine/noop/noop.c b/userspace/libscap/engine/noop/noop.c index c0cdd848e9..1df8879b66 100644 --- a/userspace/libscap/engine/noop/noop.c +++ b/userspace/libscap/engine/noop/noop.c @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/engine/noop/noop.h b/userspace/libscap/engine/noop/noop.h index 8aab4c15fc..6893b816d3 100644 --- a/userspace/libscap/engine/noop/noop.h +++ b/userspace/libscap/engine/noop/noop.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/engine/savefile/savefile.h b/userspace/libscap/engine/savefile/savefile.h index 0317d048c0..7d71e6813e 100644 --- a/userspace/libscap/engine/savefile/savefile.h +++ b/userspace/libscap/engine/savefile/savefile.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/engine/savefile/savefile_platform.h b/userspace/libscap/engine/savefile/savefile_platform.h index 50ce741ba3..7eb8861c32 100644 --- a/userspace/libscap/engine/savefile/savefile_platform.h +++ b/userspace/libscap/engine/savefile/savefile_platform.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libscap/engine/savefile/savefile_public.h b/userspace/libscap/engine/savefile/savefile_public.h index 81bef1e8ac..23a3685882 100644 --- a/userspace/libscap/engine/savefile/savefile_public.h +++ b/userspace/libscap/engine/savefile/savefile_public.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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 diff --git a/userspace/libscap/engine/savefile/scap_reader.h b/userspace/libscap/engine/savefile/scap_reader.h index 66dc195363..b3304b2f59 100644 --- a/userspace/libscap/engine/savefile/scap_reader.h +++ b/userspace/libscap/engine/savefile/scap_reader.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/engine/savefile/scap_reader_buffered.c b/userspace/libscap/engine/savefile/scap_reader_buffered.c index 53e25f4f61..3c62c7c97d 100644 --- a/userspace/libscap/engine/savefile/scap_reader_buffered.c +++ b/userspace/libscap/engine/savefile/scap_reader_buffered.c @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/engine/savefile/scap_reader_gzfile.c b/userspace/libscap/engine/savefile/scap_reader_gzfile.c index fa55e4be90..7d9aaca5d5 100644 --- a/userspace/libscap/engine/savefile/scap_reader_gzfile.c +++ b/userspace/libscap/engine/savefile/scap_reader_gzfile.c @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/engine/savefile/scap_savefile.c b/userspace/libscap/engine/savefile/scap_savefile.c index 567ea701fc..d04a63f162 100644 --- a/userspace/libscap/engine/savefile/scap_savefile.c +++ b/userspace/libscap/engine/savefile/scap_savefile.c @@ -1,2385 +1,2386 @@ -/* -Copyright (C) 2022 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. - -*/ - - -#include -#include - -#ifndef _WIN32 -#include -#include -#else -struct iovec { - void *iov_base; /* Starting address */ - size_t iov_len; /* Number of bytes to transfer */ -}; -#endif - -#define SCAP_HANDLE_T struct savefile_engine -#include "savefile.h" -#include "scap.h" -#include "scap-int.h" -#include "scap_platform.h" -#include "scap_savefile.h" -#include "savefile_platform.h" -#include "scap_reader.h" -#include "../noop/noop.h" - -#include "strl.h" - -// -// Read the section header block -// -inline static int read_block_header(struct savefile_engine* handle, struct scap_reader *r, block_header* h) -{ - int res = sizeof(block_header); - if (!handle->m_use_last_block_header) - { - res = r->read(r, &handle->m_last_block_header, sizeof(block_header)); - } - memcpy(h, &handle->m_last_block_header, sizeof(block_header)); - handle->m_use_last_block_header = false; - return res; -} - -// -// Load the machine info block -// -static int32_t scap_read_machine_info(scap_reader_t* r, scap_machine_info* machine_info, char* error, uint32_t block_length) -{ - // - // Read the section header block - // - if(r->read(r, machine_info, sizeof(*machine_info)) != - sizeof(*machine_info)) - { - snprintf(error, SCAP_LASTERR_SIZE, "error reading from file (1)"); - return SCAP_FAILURE; - } - - return SCAP_SUCCESS; -} - -// -// Parse a process list block -// -static int32_t scap_read_proclist(scap_reader_t* r, uint32_t block_length, uint32_t block_type, struct scap_proclist *proclist, char *error) -{ - size_t readsize; - size_t subreadsize = 0; - size_t totreadsize = 0; - size_t padding_len; - uint16_t stlen; - uint32_t padding; - int32_t uth_status = SCAP_SUCCESS; - uint32_t toread; - int fseekres; - - while(((int32_t)block_length - (int32_t)totreadsize) >= 4) - { - struct scap_threadinfo tinfo; - - tinfo.fdlist = NULL; - tinfo.flags = 0; - tinfo.vmsize_kb = 0; - tinfo.vmrss_kb = 0; - tinfo.vmswap_kb = 0; - tinfo.pfmajor = 0; - tinfo.pfminor = 0; - tinfo.env_len = 0; - tinfo.vtid = -1; - tinfo.vpid = -1; - tinfo.cgroups.len = 0; - tinfo.filtered_out = 0; - tinfo.root[0] = 0; - tinfo.sid = -1; - tinfo.vpgid = -1; - tinfo.clone_ts = 0; - tinfo.pidns_init_start_ts = 0; - tinfo.tty = 0; - tinfo.exepath[0] = 0; - tinfo.loginuid = UINT32_MAX; - tinfo.exe_writable = false; - tinfo.cap_inheritable = 0; - tinfo.cap_permitted = 0; - tinfo.cap_effective = 0; - tinfo.exe_upper_layer = false; - tinfo.exe_ino = 0; - tinfo.exe_ino_ctime = 0; - tinfo.exe_ino_mtime = 0; - tinfo.exe_from_memfd = false; - - // - // len - // - uint32_t sub_len = 0; - switch(block_type) - { - case PL_BLOCK_TYPE_V1: - case PL_BLOCK_TYPE_V1_INT: - case PL_BLOCK_TYPE_V2: - case PL_BLOCK_TYPE_V2_INT: - case PL_BLOCK_TYPE_V3: - case PL_BLOCK_TYPE_V3_INT: - case PL_BLOCK_TYPE_V4: - case PL_BLOCK_TYPE_V5: - case PL_BLOCK_TYPE_V6: - case PL_BLOCK_TYPE_V7: - case PL_BLOCK_TYPE_V8: - break; - case PL_BLOCK_TYPE_V9: - readsize = r->read(r, &(sub_len), sizeof(uint32_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint32_t), error); - - subreadsize += readsize; - break; - default: - snprintf(error, SCAP_LASTERR_SIZE, "corrupted process block type (fd1)"); - ASSERT(false); - return SCAP_FAILURE; - } - - // - // tid - // - readsize = r->read(r, &(tinfo.tid), sizeof(uint64_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint64_t), error); - - subreadsize += readsize; - - // - // pid - // - readsize = r->read(r, &(tinfo.pid), sizeof(uint64_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint64_t), error); - - subreadsize += readsize; - - // - // ptid - // - readsize = r->read(r, &(tinfo.ptid), sizeof(uint64_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint64_t), error); - - subreadsize += readsize; - - switch(block_type) - { - case PL_BLOCK_TYPE_V1: - case PL_BLOCK_TYPE_V1_INT: - case PL_BLOCK_TYPE_V2: - case PL_BLOCK_TYPE_V2_INT: - case PL_BLOCK_TYPE_V3: - case PL_BLOCK_TYPE_V3_INT: - case PL_BLOCK_TYPE_V4: - case PL_BLOCK_TYPE_V5: - break; - case PL_BLOCK_TYPE_V6: - case PL_BLOCK_TYPE_V7: - case PL_BLOCK_TYPE_V8: - case PL_BLOCK_TYPE_V9: - readsize = r->read(r, &(tinfo.sid), sizeof(uint64_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint64_t), error); - - subreadsize += readsize; - break; - default: - snprintf(error, SCAP_LASTERR_SIZE, "corrupted process block type (fd1)"); - ASSERT(false); - return SCAP_FAILURE; - } - - // - // vpgid - // - switch(block_type) - { - case PL_BLOCK_TYPE_V1: - case PL_BLOCK_TYPE_V1_INT: - case PL_BLOCK_TYPE_V2: - case PL_BLOCK_TYPE_V2_INT: - case PL_BLOCK_TYPE_V3: - case PL_BLOCK_TYPE_V3_INT: - case PL_BLOCK_TYPE_V4: - case PL_BLOCK_TYPE_V5: - case PL_BLOCK_TYPE_V6: - case PL_BLOCK_TYPE_V7: - break; - case PL_BLOCK_TYPE_V8: - case PL_BLOCK_TYPE_V9: - readsize = r->read(r, &(tinfo.vpgid), sizeof(uint64_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint64_t), error); - - subreadsize += readsize; - break; - default: - snprintf(error, SCAP_LASTERR_SIZE, "corrupted process block type (fd1)"); - ASSERT(false); - return SCAP_FAILURE; - } - - // - // comm - // - readsize = r->read(r, &(stlen), sizeof(uint16_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint16_t), error); - - if(stlen > SCAP_MAX_PATH_SIZE) - { - snprintf(error, SCAP_LASTERR_SIZE, "invalid commlen %d", stlen); - return SCAP_FAILURE; - } - - subreadsize += readsize; - - readsize = r->read(r, tinfo.comm, stlen); - CHECK_READ_SIZE_ERR(readsize, stlen, error); - - // the string is not null-terminated on file - tinfo.comm[stlen] = 0; - - subreadsize += readsize; - - // - // exe - // - readsize = r->read(r, &(stlen), sizeof(uint16_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint16_t), error); - - if(stlen > SCAP_MAX_PATH_SIZE) - { - snprintf(error, SCAP_LASTERR_SIZE, "invalid exelen %d", stlen); - return SCAP_FAILURE; - } - - subreadsize += readsize; - - readsize = r->read(r, tinfo.exe, stlen); - CHECK_READ_SIZE_ERR(readsize, stlen, error); - - // the string is not null-terminated on file - tinfo.exe[stlen] = 0; - - subreadsize += readsize; - - switch(block_type) - { - case PL_BLOCK_TYPE_V1: - case PL_BLOCK_TYPE_V1_INT: - case PL_BLOCK_TYPE_V2: - case PL_BLOCK_TYPE_V2_INT: - case PL_BLOCK_TYPE_V3: - case PL_BLOCK_TYPE_V3_INT: - case PL_BLOCK_TYPE_V4: - case PL_BLOCK_TYPE_V5: - case PL_BLOCK_TYPE_V6: - break; - case PL_BLOCK_TYPE_V7: - case PL_BLOCK_TYPE_V8: - case PL_BLOCK_TYPE_V9: - // - // exepath - // - readsize = r->read(r, &(stlen), sizeof(uint16_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint16_t), error); - - if(stlen > SCAP_MAX_PATH_SIZE) - { - snprintf(error, SCAP_LASTERR_SIZE, "invalid exepathlen %d", stlen); - return SCAP_FAILURE; - } - - subreadsize += readsize; - - readsize = r->read(r, tinfo.exepath, stlen); - CHECK_READ_SIZE_ERR(readsize, stlen, error); - - // the string is not null-terminated on file - tinfo.exepath[stlen] = 0; - - subreadsize += readsize; - - break; - default: - snprintf(error, SCAP_LASTERR_SIZE, "corrupted process block type (fd1)"); - ASSERT(false); - return SCAP_FAILURE; - } - - // - // args - // - readsize = r->read(r, &(stlen), sizeof(uint16_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint16_t), error); - - if(stlen > SCAP_MAX_ARGS_SIZE) - { - snprintf(error, SCAP_LASTERR_SIZE, "invalid argslen %d", stlen); - return SCAP_FAILURE; - } - - subreadsize += readsize; - - readsize = r->read(r, tinfo.args, stlen); - CHECK_READ_SIZE_ERR(readsize, stlen, error); - - // the string is not null-terminated on file - tinfo.args[stlen] = 0; - tinfo.args_len = stlen; - - subreadsize += readsize; - - // - // cwd - // - readsize = r->read(r, &(stlen), sizeof(uint16_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint16_t), error); - - if(stlen > SCAP_MAX_PATH_SIZE) - { - snprintf(error, SCAP_LASTERR_SIZE, "invalid cwdlen %d", stlen); - return SCAP_FAILURE; - } - - subreadsize += readsize; - - readsize = r->read(r, tinfo.cwd, stlen); - CHECK_READ_SIZE_ERR(readsize, stlen, error); - - // the string is not null-terminated on file - tinfo.cwd[stlen] = 0; - - subreadsize += readsize; - - // - // fdlimit - // - readsize = r->read(r, &(tinfo.fdlimit), sizeof(uint64_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint64_t), error); - - subreadsize += readsize; - - // - // flags - // - readsize = r->read(r, &(tinfo.flags), sizeof(uint32_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint32_t), error); - - subreadsize += readsize; - - // - // uid - // - readsize = r->read(r, &(tinfo.uid), sizeof(uint32_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint32_t), error); - - subreadsize += readsize; - - // - // gid - // - readsize = r->read(r, &(tinfo.gid), sizeof(uint32_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint32_t), error); - - subreadsize += readsize; - - switch(block_type) - { - case PL_BLOCK_TYPE_V1: - case PL_BLOCK_TYPE_V1_INT: - break; - case PL_BLOCK_TYPE_V2: - case PL_BLOCK_TYPE_V2_INT: - case PL_BLOCK_TYPE_V3: - case PL_BLOCK_TYPE_V3_INT: - case PL_BLOCK_TYPE_V4: - case PL_BLOCK_TYPE_V5: - case PL_BLOCK_TYPE_V6: - case PL_BLOCK_TYPE_V7: - case PL_BLOCK_TYPE_V8: - case PL_BLOCK_TYPE_V9: - // - // vmsize_kb - // - readsize = r->read(r, &(tinfo.vmsize_kb), sizeof(uint32_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint32_t), error); - - subreadsize += readsize; - - // - // vmrss_kb - // - readsize = r->read(r, &(tinfo.vmrss_kb), sizeof(uint32_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint32_t), error); - - subreadsize += readsize; - - // - // vmswap_kb - // - readsize = r->read(r, &(tinfo.vmswap_kb), sizeof(uint32_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint32_t), error); - - subreadsize += readsize; - - // - // pfmajor - // - readsize = r->read(r, &(tinfo.pfmajor), sizeof(uint64_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint64_t), error); - - subreadsize += readsize; - - // - // pfminor - // - readsize = r->read(r, &(tinfo.pfminor), sizeof(uint64_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint64_t), error); - - subreadsize += readsize; - - if(block_type == PL_BLOCK_TYPE_V3 || - block_type == PL_BLOCK_TYPE_V3_INT || - block_type == PL_BLOCK_TYPE_V4 || - block_type == PL_BLOCK_TYPE_V5 || - block_type == PL_BLOCK_TYPE_V6 || - block_type == PL_BLOCK_TYPE_V7 || - block_type == PL_BLOCK_TYPE_V8 || - block_type == PL_BLOCK_TYPE_V9) - { - // - // env - // - readsize = r->read(r, &(stlen), sizeof(uint16_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint16_t), error); - - if(stlen > SCAP_MAX_ENV_SIZE) - { - snprintf(error, SCAP_LASTERR_SIZE, "invalid envlen %d", stlen); - return SCAP_FAILURE; - } - - subreadsize += readsize; - - readsize = r->read(r, tinfo.env, stlen); - CHECK_READ_SIZE_ERR(readsize, stlen, error); - - // the string is not null-terminated on file - tinfo.env[stlen] = 0; - tinfo.env_len = stlen; - - subreadsize += readsize; - } - - if(block_type == PL_BLOCK_TYPE_V4 || - block_type == PL_BLOCK_TYPE_V5 || - block_type == PL_BLOCK_TYPE_V6 || - block_type == PL_BLOCK_TYPE_V7 || - block_type == PL_BLOCK_TYPE_V8 || - block_type == PL_BLOCK_TYPE_V9) - { - // - // vtid - // - readsize = r->read(r, &(tinfo.vtid), sizeof(int64_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint64_t), error); - - subreadsize += readsize; - - // - // vpid - // - readsize = r->read(r, &(tinfo.vpid), sizeof(int64_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint64_t), error); - - subreadsize += readsize; - - // - // cgroups - // - readsize = r->read(r, &(stlen), sizeof(uint16_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint16_t), error); - - if(stlen > SCAP_MAX_CGROUPS_SIZE) - { - snprintf(error, SCAP_LASTERR_SIZE, "invalid cgroupslen %d", stlen); - return SCAP_FAILURE; - } - tinfo.cgroups.len = stlen; - - subreadsize += readsize; - - readsize = r->read(r, tinfo.cgroups.path, stlen); - CHECK_READ_SIZE_ERR(readsize, stlen, error); - - subreadsize += readsize; - - if(block_type == PL_BLOCK_TYPE_V5 || - block_type == PL_BLOCK_TYPE_V6 || - block_type == PL_BLOCK_TYPE_V7 || - block_type == PL_BLOCK_TYPE_V8 || - block_type == PL_BLOCK_TYPE_V9) - { - readsize = r->read(r, &(stlen), sizeof(uint16_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint16_t), error); - - if(stlen > SCAP_MAX_PATH_SIZE) - { - snprintf(error, SCAP_LASTERR_SIZE, "invalid rootlen %d", stlen); - return SCAP_FAILURE; - } - - subreadsize += readsize; - - readsize = r->read(r, tinfo.root, stlen); - CHECK_READ_SIZE_ERR(readsize, stlen, error); - - // the string is not null-terminated on file - tinfo.root[stlen] = 0; - - subreadsize += readsize; - } - } - break; - default: - snprintf(error, SCAP_LASTERR_SIZE, "corrupted process block type (fd1)"); - ASSERT(false); - return SCAP_FAILURE; - } - - // If new parameters are added, sub_len can be used to - // see if they are available in the current capture. - // For example, for a 32bit parameter: - // - // if(sub_len && (subreadsize + sizeof(uint32_t)) <= sub_len) - // { - // ... - // } - - // In 0.10.x libs tag, 2 fields were added to the scap file producer, - // written in the middle of the proclist entry, breaking forward compatibility - // for old scap file readers. - // Detect this hacky behavior, and manage it. - // Added fields: - // * exe_upper_layer - // * exe_ino - // * exe_ino_ctime - // * exe_ino_mtime - // * pidns_init_start_ts (in the middle) - // * tty (in the middle) - // So, to check if we need to enable the "pre-0.10.x hack", - // we need to check if remaining data to be read is <= than - // sum of sizes for fields existent in libs < 0.10.x, ie: - // * loginuid (4B) - // * exe_writable (1B) - // * cap_inheritable (8B) - // * cap_permitted (8B) - // * cap_effective (8B) - // TOTAL: 29B - bool pre_0_10_0 = false; - if (sub_len - subreadsize <= 29) - { - pre_0_10_0 = true; - } - - if (!pre_0_10_0) - { - // Ok we are in libs >= 0.10.x; read the fields that - // were added interleaved in libs 0.10.0 - - // - // pidns_init_start_ts - // - if(sub_len && (subreadsize + sizeof(uint64_t)) <= sub_len) - { - readsize = r->read(r, &(tinfo.pidns_init_start_ts), sizeof(uint64_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint64_t), error); - subreadsize += readsize; - } - - // - // tty - // - if(sub_len && (subreadsize + sizeof(uint32_t)) <= sub_len) - { - readsize = r->read(r, &(tinfo.tty), sizeof(uint32_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint32_t), error); - subreadsize += readsize; - } - } - - // - // loginuid (auid) - // - if(sub_len && (subreadsize + sizeof(uint32_t)) <= sub_len) - { - readsize = r->read(r, &(tinfo.loginuid), sizeof(uint32_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint32_t), error); - subreadsize += readsize; - } - - // - // exe_writable - // - if(sub_len && (subreadsize + sizeof(uint8_t)) <= sub_len) - { - readsize = r->read(r, &(tinfo.exe_writable), sizeof(uint8_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint8_t), error); - subreadsize += readsize; - } - - // - // Capabilities - // - if(sub_len && (subreadsize + sizeof(uint64_t)) <= sub_len) - { - readsize = r->read(r, &(tinfo.cap_inheritable), sizeof(uint64_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint64_t), error); - subreadsize += readsize; - } - - if(sub_len && (subreadsize + sizeof(uint64_t)) <= sub_len) - { - readsize = r->read(r, &(tinfo.cap_permitted), sizeof(uint64_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint64_t), error); - subreadsize += readsize; - } - - if(sub_len && (subreadsize + sizeof(uint64_t)) <= sub_len) - { - readsize = r->read(r, &(tinfo.cap_effective), sizeof(uint64_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint64_t), error); - subreadsize += readsize; - } - - // exe_upper_layer - if(sub_len && (subreadsize + sizeof(uint8_t)) <= sub_len) - { - readsize = r->read(r, &(tinfo.exe_upper_layer), sizeof(uint8_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint8_t), error); - subreadsize += readsize; - } - - // exe_ino - if(sub_len && (subreadsize + sizeof(uint64_t)) <= sub_len) - { - readsize = r->read(r, &(tinfo.exe_ino), sizeof(uint64_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint64_t), error); - subreadsize += readsize; - } - - // exe_ino_ctime - if(sub_len && (subreadsize + sizeof(uint64_t)) <= sub_len) - { - readsize = r->read(r, &(tinfo.exe_ino_ctime), sizeof(uint64_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint64_t), error); - subreadsize += readsize; - } - - // exe_ino_mtime - if(sub_len && (subreadsize + sizeof(uint64_t)) <= sub_len) - { - readsize = r->read(r, &(tinfo.exe_ino_mtime), sizeof(uint64_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint64_t), error); - subreadsize += readsize; - } - - // exe_from_memfd - if(sub_len && (subreadsize + sizeof(uint8_t)) <= sub_len) - { - uint8_t exe_from_memfd = 0; - readsize = r->read(r, &exe_from_memfd, sizeof(uint8_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint8_t), error); - subreadsize += readsize; - tinfo.exe_from_memfd = (exe_from_memfd != 0); - } - - // - // All parsed. Add the entry to the table, or fire the notification callback - // - if(proclist->m_proc_callback == NULL) - { - // - // All parsed. Allocate the new entry and copy the temp one into into it. - // - struct scap_threadinfo *ntinfo = (scap_threadinfo *)malloc(sizeof(scap_threadinfo)); - if(ntinfo == NULL) - { - snprintf(error, SCAP_LASTERR_SIZE, "process table allocation error (fd1)"); - return SCAP_FAILURE; - } - - // Structure copy - *ntinfo = tinfo; - - HASH_ADD_INT64(proclist->m_proclist, tid, ntinfo); - if(uth_status != SCAP_SUCCESS) - { - free(ntinfo); - snprintf(error, SCAP_LASTERR_SIZE, "process table allocation error (fd2)"); - return SCAP_FAILURE; - } - } - else - { - proclist->m_proc_callback( - proclist->m_proc_callback_context, tinfo.tid, &tinfo, NULL); - } - - if(sub_len && subreadsize != sub_len) - { - if(subreadsize > sub_len) - { - snprintf(error, SCAP_LASTERR_SIZE, "corrupted input file. Had read %lu bytes, but proclist entry have length %u.", - subreadsize, sub_len); - return SCAP_FAILURE; - } - toread = sub_len - subreadsize; - fseekres = (int) r->seek(r, (long)toread, SEEK_CUR); - if(fseekres == -1) - { - snprintf(error, SCAP_LASTERR_SIZE, "corrupted input file. Can't skip %u bytes.", - (unsigned int)toread); - return SCAP_FAILURE; - } - subreadsize = sub_len; - } - - totreadsize += subreadsize; - subreadsize = 0; - } - - // - // Read the padding bytes so we properly align to the end of the data - // - if(totreadsize > block_length) - { - snprintf(error, SCAP_LASTERR_SIZE, "scap_read_proclist read more %lu than a block %u", totreadsize, block_length); - ASSERT(false); - return SCAP_FAILURE; - } - padding_len = block_length - totreadsize; - - readsize = (size_t)r->read(r, &padding, (unsigned int)padding_len); - CHECK_READ_SIZE_ERR(readsize, padding_len, error); - - return SCAP_SUCCESS; -} - -// -// Parse an interface list block -// -static int32_t scap_read_iflist(scap_reader_t* r, uint32_t block_length, uint32_t block_type, scap_addrlist** addrlist_p, char* error) -{ - int32_t res = SCAP_SUCCESS; - size_t readsize; - size_t totreadsize; - char *readbuf = NULL; - char *pif; - uint16_t iftype; - uint16_t ifnamlen; - uint32_t toread; - uint32_t entrysize; - uint32_t ifcnt4 = 0; - uint32_t ifcnt6 = 0; - - // - // If the list of interfaces was already allocated for this handle (for example because this is - // not the first interface list block), free it - // - if((*addrlist_p) != NULL) - { - scap_free_iflist((*addrlist_p)); - (*addrlist_p) = NULL; - } - - // - // Bring the block to memory - // We assume that this block is always small enough that we can read it in a single shot - // - readbuf = (char *)malloc(block_length); - if(!readbuf) - { - snprintf(error, SCAP_LASTERR_SIZE, "memory allocation error in scap_read_iflist"); - return SCAP_FAILURE; - } - - readsize = r->read(r, readbuf, block_length); - CHECK_READ_SIZE_WITH_FREE_ERR(readbuf, readsize, block_length, error); - - // - // First pass, count the number of addresses - // - pif = readbuf; - totreadsize = 0; - - while(true) - { - toread = (int32_t)block_length - (int32_t)totreadsize; - - if(toread < 4) - { - break; - } - - if(block_type != IL_BLOCK_TYPE_V2) - { - iftype = *(uint16_t *)pif; - ifnamlen = *(uint16_t *)(pif + 2); - - if(iftype == SCAP_II_IPV4) - { - entrysize = sizeof(scap_ifinfo_ipv4) + ifnamlen - SCAP_MAX_PATH_SIZE; - } - else if(iftype == SCAP_II_IPV6) - { - entrysize = sizeof(scap_ifinfo_ipv6) + ifnamlen - SCAP_MAX_PATH_SIZE; - } - else if(iftype == SCAP_II_IPV4_NOLINKSPEED) - { - entrysize = sizeof(scap_ifinfo_ipv4_nolinkspeed) + ifnamlen - SCAP_MAX_PATH_SIZE; - } - else if(iftype == SCAP_II_IPV6_NOLINKSPEED) - { - entrysize = sizeof(scap_ifinfo_ipv6_nolinkspeed) + ifnamlen - SCAP_MAX_PATH_SIZE; - } - else - { - snprintf(error, SCAP_LASTERR_SIZE, "trace file has corrupted interface list(1)"); - ASSERT(false); - res = SCAP_FAILURE; - goto scap_read_iflist_error; - } - } - else - { - entrysize = *(uint32_t *)pif + sizeof(uint32_t); - iftype = *(uint16_t *)(pif + 4); - ifnamlen = *(uint16_t *)(pif + 4 + 2); - } - - if(toread < entrysize) - { - snprintf(error, SCAP_LASTERR_SIZE, "trace file has corrupted interface list(2) toread=%u, entrysize=%u", toread, entrysize); - res = SCAP_FAILURE; - goto scap_read_iflist_error; - } - - pif += entrysize; - totreadsize += entrysize; - - if(iftype == SCAP_II_IPV4 || iftype == SCAP_II_IPV4_NOLINKSPEED) - { - ifcnt4++; - } - else if(iftype == SCAP_II_IPV6 || iftype == SCAP_II_IPV6_NOLINKSPEED) - { - ifcnt6++; - } - else - { - ASSERT(false); - snprintf(error, SCAP_LASTERR_SIZE, "unknown interface type %d", (int)iftype); - res = SCAP_FAILURE; - goto scap_read_iflist_error; - } - } - - // - // Allocate the handle and the arrays - // - (*addrlist_p) = (scap_addrlist *)malloc(sizeof(scap_addrlist)); - if(!(*addrlist_p)) - { - snprintf(error, SCAP_LASTERR_SIZE, "scap_read_iflist allocation failed(1)"); - res = SCAP_FAILURE; - goto scap_read_iflist_error; - } - - (*addrlist_p)->n_v4_addrs = 0; - (*addrlist_p)->n_v6_addrs = 0; - (*addrlist_p)->v4list = NULL; - (*addrlist_p)->v6list = NULL; - (*addrlist_p)->totlen = block_length - (ifcnt4 + ifcnt6) * sizeof(uint32_t); - - if(ifcnt4 != 0) - { - (*addrlist_p)->v4list = (scap_ifinfo_ipv4 *)malloc(ifcnt4 * sizeof(scap_ifinfo_ipv4)); - if(!(*addrlist_p)->v4list) - { - snprintf(error, SCAP_LASTERR_SIZE, "scap_read_iflist allocation failed(2)"); - res = SCAP_FAILURE; - goto scap_read_iflist_error; - } - } - else - { - (*addrlist_p)->v4list = NULL; - } - - if(ifcnt6 != 0) - { - (*addrlist_p)->v6list = (scap_ifinfo_ipv6 *)malloc(ifcnt6 * sizeof(scap_ifinfo_ipv6)); - if(!(*addrlist_p)->v6list) - { - snprintf(error, SCAP_LASTERR_SIZE, "getifaddrs allocation failed(3)"); - res = SCAP_FAILURE; - goto scap_read_iflist_error; - } - } - else - { - (*addrlist_p)->v6list = NULL; - } - - (*addrlist_p)->n_v4_addrs = ifcnt4; - (*addrlist_p)->n_v6_addrs = ifcnt6; - - // - // Second pass: populate the arrays - // - ifcnt4 = 0; - ifcnt6 = 0; - pif = readbuf; - totreadsize = 0; - - while(true) - { - toread = (int32_t)block_length - (int32_t)totreadsize; - entrysize = 0; - - if(toread < 4) - { - break; - } - - if(block_type == IL_BLOCK_TYPE_V2) - { - entrysize = *(uint32_t *)pif; - totreadsize += sizeof(uint32_t); - pif += sizeof(uint32_t); - } - - iftype = *(uint16_t *)pif; - ifnamlen = *(uint16_t *)(pif + 2); - - if(ifnamlen >= SCAP_MAX_PATH_SIZE) - { - snprintf(error, SCAP_LASTERR_SIZE, "trace file has corrupted interface list(0)"); - res = SCAP_FAILURE; - goto scap_read_iflist_error; - } - - // If new parameters are added, entrysize can be used to - // see if they are available in the current capture. - // For example, for a 32bit parameter: - // - // if(entrysize && (ifsize + sizeof(uint32_t)) <= entrysize) - // { - // ifsize += sizeof(uint32_t); - // ... - // } - - uint32_t ifsize; - if(iftype == SCAP_II_IPV4) - { - ifsize = sizeof(uint16_t) + // type - sizeof(uint16_t) + // ifnamelen - sizeof(uint32_t) + // addr - sizeof(uint32_t) + // netmask - sizeof(uint32_t) + // bcast - sizeof(uint64_t) + // linkspeed - ifnamlen; - - if(toread < ifsize) - { - snprintf(error, SCAP_LASTERR_SIZE, "trace file has corrupted interface list(3)"); - res = SCAP_FAILURE; - goto scap_read_iflist_error; - } - - // Copy the entry - memcpy((*addrlist_p)->v4list + ifcnt4, pif, ifsize - ifnamlen); - - memcpy((*addrlist_p)->v4list[ifcnt4].ifname, pif + ifsize - ifnamlen, ifnamlen); - - // Make sure the name string is NULL-terminated - *((char *)((*addrlist_p)->v4list + ifcnt4) + ifsize) = 0; - - ifcnt4++; - } - else if(iftype == SCAP_II_IPV4_NOLINKSPEED) - { - scap_ifinfo_ipv4_nolinkspeed* src; - scap_ifinfo_ipv4* dst; - - ifsize = sizeof(scap_ifinfo_ipv4_nolinkspeed) + ifnamlen - SCAP_MAX_PATH_SIZE; - - if(toread < ifsize) - { - snprintf(error, SCAP_LASTERR_SIZE, "trace file has corrupted interface list(4)"); - res = SCAP_FAILURE; - goto scap_read_iflist_error; - } - - // Copy the entry - src = (scap_ifinfo_ipv4_nolinkspeed*)pif; - dst = (*addrlist_p)->v4list + ifcnt4; - - dst->type = src->type; - dst->ifnamelen = src->ifnamelen; - dst->addr = src->addr; - dst->netmask = src->netmask; - dst->bcast = src->bcast; - dst->linkspeed = 0; - memcpy(dst->ifname, src->ifname, MIN(dst->ifnamelen, SCAP_MAX_PATH_SIZE - 1)); - - // Make sure the name string is NULL-terminated - *((char *)(dst->ifname + MIN(dst->ifnamelen, SCAP_MAX_PATH_SIZE - 1))) = 0; - - ifcnt4++; - } - else if(iftype == SCAP_II_IPV6) - { - ifsize = sizeof(uint16_t) + // type - sizeof(uint16_t) + // ifnamelen - SCAP_IPV6_ADDR_LEN + // addr - SCAP_IPV6_ADDR_LEN + // netmask - SCAP_IPV6_ADDR_LEN + // bcast - sizeof(uint64_t) + // linkspeed - ifnamlen; - - if(toread < ifsize) - { - snprintf(error, SCAP_LASTERR_SIZE, "trace file has corrupted interface list(5)"); - res = SCAP_FAILURE; - goto scap_read_iflist_error; - } - - // Copy the entry - memcpy((*addrlist_p)->v6list + ifcnt6, pif, ifsize - ifnamlen); - - memcpy((*addrlist_p)->v6list[ifcnt6].ifname, pif + ifsize - ifnamlen, ifnamlen); - - // Make sure the name string is NULL-terminated - *((char *)((*addrlist_p)->v6list + ifcnt6) + ifsize) = 0; - - ifcnt6++; - } - else if(iftype == SCAP_II_IPV6_NOLINKSPEED) - { - scap_ifinfo_ipv6_nolinkspeed* src; - scap_ifinfo_ipv6* dst; - ifsize = sizeof(scap_ifinfo_ipv6_nolinkspeed) + ifnamlen - SCAP_MAX_PATH_SIZE; - - if(toread < ifsize) - { - snprintf(error, SCAP_LASTERR_SIZE, "trace file has corrupted interface list(6)"); - res = SCAP_FAILURE; - goto scap_read_iflist_error; - } - - // Copy the entry - src = (scap_ifinfo_ipv6_nolinkspeed*)pif; - dst = (*addrlist_p)->v6list + ifcnt6; - - dst->type = src->type; - dst->ifnamelen = src->ifnamelen; - memcpy(dst->addr, src->addr, SCAP_IPV6_ADDR_LEN); - memcpy(dst->netmask, src->netmask, SCAP_IPV6_ADDR_LEN); - memcpy(dst->bcast, src->bcast, SCAP_IPV6_ADDR_LEN); - dst->linkspeed = 0; - memcpy(dst->ifname, src->ifname, MIN(dst->ifnamelen, SCAP_MAX_PATH_SIZE - 1)); - - // Make sure the name string is NULL-terminated - *((char *)(dst->ifname + MIN(dst->ifnamelen, SCAP_MAX_PATH_SIZE - 1))) = 0; - - ifcnt6++; - } - else - { - ASSERT(false); - snprintf(error, SCAP_LASTERR_SIZE, "unknown interface type %d", (int)iftype); - res = SCAP_FAILURE; - goto scap_read_iflist_error; - } - - entrysize = entrysize ? entrysize : ifsize; - - pif += entrysize; - totreadsize += entrysize; - } - - // - // Release the read storage - // - free(readbuf); - - return res; - -scap_read_iflist_error: - scap_free_iflist((*addrlist_p)); - (*addrlist_p) = NULL; - - if(readbuf) - { - free(readbuf); - } - - return res; -} - -// -// Parse a user list block -// -static int32_t scap_read_userlist(scap_reader_t* r, uint32_t block_length, uint32_t block_type, scap_userlist** userlist_p, char* error) -{ - size_t readsize; - size_t totreadsize = 0; - size_t subreadsize = 0; - size_t padding_len; - uint32_t padding; - uint8_t type; - uint16_t stlen; - uint32_t toread; - int fseekres; - - // - // If the list of users was already allocated for this handle (for example because this is - // not the first interface list block), free it - // - if((*userlist_p) != NULL) - { - scap_free_userlist((*userlist_p)); - (*userlist_p) = NULL; - } - - // - // Allocate and initialize the handle info - // - (*userlist_p) = (scap_userlist*)malloc(sizeof(scap_userlist)); - if((*userlist_p) == NULL) - { - snprintf(error, SCAP_LASTERR_SIZE, "userlist allocation failed(2)"); - return SCAP_FAILURE; - } - - (*userlist_p)->nusers = 0; - (*userlist_p)->ngroups = 0; - (*userlist_p)->totsavelen = 0; - (*userlist_p)->users = NULL; - (*userlist_p)->groups = NULL; - - // - // Import the blocks - // - while(((int32_t)block_length - (int32_t)totreadsize) >= 4) - { - uint32_t sub_len = 0; - if(block_type == UL_BLOCK_TYPE_V2) - { - // - // len - // - readsize = r->read(r, &(sub_len), sizeof(uint32_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint32_t), error); - - subreadsize += readsize; - } - - // - // type - // - readsize = r->read(r, &(type), sizeof(type)); - CHECK_READ_SIZE_ERR(readsize, sizeof(type), error); - - subreadsize += readsize; - - if(type == USERBLOCK_TYPE_USER) - { - scap_userinfo* puser; - - (*userlist_p)->nusers++; - scap_userinfo *new_userlist = (scap_userinfo*)realloc((*userlist_p)->users, (*userlist_p)->nusers * sizeof(scap_userinfo)); - if(new_userlist == NULL) - { - free((*userlist_p)->users); - (*userlist_p)->users = NULL; - snprintf(error, SCAP_LASTERR_SIZE, "memory allocation error in scap_read_userlist(1)"); - return SCAP_FAILURE; - } - (*userlist_p)->users = new_userlist; - - puser = &(*userlist_p)->users[(*userlist_p)->nusers -1]; - - // - // uid - // - readsize = r->read(r, &(puser->uid), sizeof(uint32_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint32_t), error); - - subreadsize += readsize; - - // - // gid - // - readsize = r->read(r, &(puser->gid), sizeof(uint32_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint32_t), error); - - subreadsize += readsize; - - // - // name - // - readsize = r->read(r, &(stlen), sizeof(uint16_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint16_t), error); - - if(stlen >= MAX_CREDENTIALS_STR_LEN) - { - snprintf(error, SCAP_LASTERR_SIZE, "invalid user name len %d", stlen); - return SCAP_FAILURE; - } - - subreadsize += readsize; - - readsize = r->read(r, puser->name, stlen); - CHECK_READ_SIZE_ERR(readsize, stlen, error); - - // the string is not null-terminated on file - puser->name[stlen] = 0; - - subreadsize += readsize; - - // - // homedir - // - readsize = r->read(r, &(stlen), sizeof(uint16_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint16_t), error); - - if(stlen >= MAX_CREDENTIALS_STR_LEN) - { - snprintf(error, SCAP_LASTERR_SIZE, "invalid user homedir len %d", stlen); - return SCAP_FAILURE; - } - - subreadsize += readsize; - - readsize = r->read(r, puser->homedir, stlen); - CHECK_READ_SIZE_ERR(readsize, stlen, error); - - // the string is not null-terminated on file - puser->homedir[stlen] = 0; - - subreadsize += readsize; - - // - // shell - // - readsize = r->read(r, &(stlen), sizeof(uint16_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint16_t), error); - - if(stlen >= MAX_CREDENTIALS_STR_LEN) - { - snprintf(error, SCAP_LASTERR_SIZE, "invalid user shell len %d", stlen); - return SCAP_FAILURE; - } - - subreadsize += readsize; - - readsize = r->read(r, puser->shell, stlen); - CHECK_READ_SIZE_ERR(readsize, stlen, error); - - // the string is not null-terminated on file - puser->shell[stlen] = 0; - - subreadsize += readsize; - - // If new parameters are added, sub_len can be used to - // see if they are available in the current capture. - // For example, for a 32bit parameter: - // - // if(sub_len && (subreadsize + sizeof(uint32_t)) <= sub_len) - // { - // ... - // } - } - else - { - scap_groupinfo* pgroup; - - (*userlist_p)->ngroups++; - scap_groupinfo *new_grouplist = (scap_groupinfo*)realloc((*userlist_p)->groups, (*userlist_p)->ngroups * sizeof(scap_groupinfo)); - if(new_grouplist == NULL) - { - free((*userlist_p)->groups); - (*userlist_p)->groups = NULL; - snprintf(error, SCAP_LASTERR_SIZE, "memory allocation error in scap_read_userlist(2)"); - return SCAP_FAILURE; - } - (*userlist_p)->groups = new_grouplist; - - pgroup = &(*userlist_p)->groups[(*userlist_p)->ngroups -1]; - - // - // gid - // - readsize = r->read(r, &(pgroup->gid), sizeof(uint32_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint32_t), error); - - subreadsize += readsize; - - // - // name - // - readsize = r->read(r, &(stlen), sizeof(uint16_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint16_t), error); - - if(stlen >= MAX_CREDENTIALS_STR_LEN) - { - snprintf(error, SCAP_LASTERR_SIZE, "invalid group name len %d", stlen); - return SCAP_FAILURE; - } - - subreadsize += readsize; - - readsize = r->read(r, pgroup->name, stlen); - CHECK_READ_SIZE_ERR(readsize, stlen, error); - - // the string is not null-terminated on file - pgroup->name[stlen] = 0; - - subreadsize += readsize; - - // If new parameters are added, sub_len can be used to - // see if they are available in the current capture. - // For example, for a 32bit parameter: - // - // if(sub_len && (subreadsize + sizeof(uint32_t)) <= sub_len) - // { - // ... - // } - } - - if(sub_len && subreadsize != sub_len) - { - if(subreadsize > sub_len) - { - snprintf(error, SCAP_LASTERR_SIZE, "corrupted input file. Had read %lu bytes, but userlist entry have length %u.", - subreadsize, sub_len); - return SCAP_FAILURE; - } - toread = sub_len - subreadsize; - fseekres = (int) r->seek(r, (long)toread, SEEK_CUR); - if(fseekres == -1) - { - snprintf(error, SCAP_LASTERR_SIZE, "corrupted input file. Can't skip %u bytes.", - (unsigned int)toread); - return SCAP_FAILURE; - } - subreadsize = sub_len; - } - - totreadsize += subreadsize; - subreadsize = 0; - } - - // - // Read the padding bytes so we properly align to the end of the data - // - if(totreadsize > block_length) - { - ASSERT(false); - snprintf(error, SCAP_LASTERR_SIZE, "scap_read_userlist read more %lu than a block %u", totreadsize, block_length); - return SCAP_FAILURE; - } - padding_len = block_length - totreadsize; - - readsize = r->read(r, &padding, (unsigned int)padding_len); - CHECK_READ_SIZE_ERR(readsize, padding_len, error); - - return SCAP_SUCCESS; -} - -static uint32_t scap_fd_read_prop_from_disk(void *target, size_t expected_size, size_t *nbytes, scap_reader_t *r, char *error) -{ - size_t readsize; - readsize = r->read(r, target, (unsigned int)expected_size); - CHECK_READ_SIZE_ERR(readsize, expected_size, error); - (*nbytes) += readsize; - return SCAP_SUCCESS; -} - -static uint32_t scap_fd_read_fname_from_disk(char *fname, size_t *nbytes, scap_reader_t *r, char *error) -{ - size_t readsize; - uint16_t stlen; - - readsize = r->read(r, &(stlen), sizeof(uint16_t)); - CHECK_READ_SIZE_ERR(readsize, sizeof(uint16_t), error); - - if(stlen >= SCAP_MAX_PATH_SIZE) - { - snprintf(error, SCAP_LASTERR_SIZE, "invalid filename len %" PRId32, stlen); - return SCAP_FAILURE; - } - - (*nbytes) += readsize; - - readsize = r->read(r, fname, stlen); - CHECK_READ_SIZE_ERR(readsize, stlen, error); - - (*nbytes) += stlen; - - // NULL-terminate the string - fname[stlen] = 0; - return SCAP_SUCCESS; -} - -// -// Populate the given fd by reading the info from disk -// Returns the number of read bytes. -// -static uint32_t scap_fd_read_from_disk(scap_fdinfo *fdi, size_t *nbytes, uint32_t block_type, scap_reader_t *r, char *error) -{ - uint8_t type; - uint32_t toread; - int fseekres; - uint32_t sub_len = 0; - uint32_t res = SCAP_SUCCESS; - *nbytes = 0; - - if((block_type == FDL_BLOCK_TYPE_V2 && - scap_fd_read_prop_from_disk(&sub_len, sizeof(uint32_t), nbytes, r, error)) || - scap_fd_read_prop_from_disk(&(fdi->fd), sizeof(fdi->fd), nbytes, r, error) || - scap_fd_read_prop_from_disk(&(fdi->ino), sizeof(fdi->ino), nbytes, r, error) || - scap_fd_read_prop_from_disk(&type, sizeof(uint8_t), nbytes, r, error)) - { - snprintf(error, SCAP_LASTERR_SIZE, "Could not read prop block for fd"); - return SCAP_FAILURE; - } - - // If new parameters are added, sub_len can be used to - // see if they are available in the current capture. - // For example, for a 32bit parameter: - // - // if(sub_len && (*nbytes + sizeof(uint32_t)) <= sub_len) - // { - // ... - // } - - fdi->type = (scap_fd_type)type; - - switch(fdi->type) - { - case SCAP_FD_IPV4_SOCK: - if(r->read(r, &(fdi->info.ipv4info.sip), sizeof(uint32_t)) != sizeof(uint32_t) || - r->read(r, &(fdi->info.ipv4info.dip), sizeof(uint32_t)) != sizeof(uint32_t) || - r->read(r, &(fdi->info.ipv4info.sport), sizeof(uint16_t)) != sizeof(uint16_t) || - r->read(r, &(fdi->info.ipv4info.dport), sizeof(uint16_t)) != sizeof(uint16_t) || - r->read(r, &(fdi->info.ipv4info.l4proto), sizeof(uint8_t)) != sizeof(uint8_t)) - { - snprintf(error, SCAP_LASTERR_SIZE, "error reading the fd info from file (1)"); - return SCAP_FAILURE; - } - - (*nbytes) += (sizeof(uint32_t) + sizeof(uint32_t) + sizeof(uint16_t) + sizeof(uint16_t) + sizeof(uint8_t)); - - break; - case SCAP_FD_IPV4_SERVSOCK: - if(r->read(r, &(fdi->info.ipv4serverinfo.ip), sizeof(uint32_t)) != sizeof(uint32_t) || - r->read(r, &(fdi->info.ipv4serverinfo.port), sizeof(uint16_t)) != sizeof(uint16_t) || - r->read(r, &(fdi->info.ipv4serverinfo.l4proto), sizeof(uint8_t)) != sizeof(uint8_t)) - { - snprintf(error, SCAP_LASTERR_SIZE, "error reading the fd info from file (2)"); - return SCAP_FAILURE; - } - - (*nbytes) += (sizeof(uint32_t) + sizeof(uint16_t) + sizeof(uint8_t)); - break; - case SCAP_FD_IPV6_SOCK: - if(r->read(r, (char *)fdi->info.ipv6info.sip, sizeof(uint32_t) * 4) != sizeof(uint32_t) * 4 || - r->read(r, (char *)fdi->info.ipv6info.dip, sizeof(uint32_t) * 4) != sizeof(uint32_t) * 4 || - r->read(r, &(fdi->info.ipv6info.sport), sizeof(uint16_t)) != sizeof(uint16_t) || - r->read(r, &(fdi->info.ipv6info.dport), sizeof(uint16_t)) != sizeof(uint16_t) || - r->read(r, &(fdi->info.ipv6info.l4proto), sizeof(uint8_t)) != sizeof(uint8_t)) - { - snprintf(error, SCAP_LASTERR_SIZE, "error writing to file (fi3)"); - } - (*nbytes) += (sizeof(uint32_t) * 4 + // sip - sizeof(uint32_t) * 4 + // dip - sizeof(uint16_t) + // sport - sizeof(uint16_t) + // dport - sizeof(uint8_t)); // l4proto - break; - case SCAP_FD_IPV6_SERVSOCK: - if(r->read(r, (char *)fdi->info.ipv6serverinfo.ip, sizeof(uint32_t) * 4) != sizeof(uint32_t) * 4 || - r->read(r, &(fdi->info.ipv6serverinfo.port), sizeof(uint16_t)) != sizeof(uint16_t) || - r->read(r, &(fdi->info.ipv6serverinfo.l4proto), sizeof(uint8_t)) != sizeof(uint8_t)) - { - snprintf(error, SCAP_LASTERR_SIZE, "error writing to file (fi4)"); - } - (*nbytes) += (sizeof(uint32_t) * 4 + // ip - sizeof(uint16_t) + // port - sizeof(uint8_t)); // l4proto - break; - case SCAP_FD_UNIX_SOCK: - if(r->read(r, &(fdi->info.unix_socket_info.source), sizeof(uint64_t)) != sizeof(uint64_t) || - r->read(r, &(fdi->info.unix_socket_info.destination), sizeof(uint64_t)) != sizeof(uint64_t)) - { - snprintf(error, SCAP_LASTERR_SIZE, "error reading the fd info from file (fi5)"); - return SCAP_FAILURE; - } - - (*nbytes) += (sizeof(uint64_t) + sizeof(uint64_t)); - res = scap_fd_read_fname_from_disk(fdi->info.unix_socket_info.fname, nbytes, r, error); - break; - case SCAP_FD_FILE_V2: - if(r->read(r, &(fdi->info.regularinfo.open_flags), sizeof(uint32_t)) != sizeof(uint32_t)) - { - snprintf(error, SCAP_LASTERR_SIZE, "error reading the fd info from file (fi1)"); - return SCAP_FAILURE; - } - - (*nbytes) += sizeof(uint32_t); - res = scap_fd_read_fname_from_disk(fdi->info.regularinfo.fname, nbytes, r, error); - if(!sub_len || (sub_len < *nbytes + sizeof(uint32_t))) - { - break; - } - if(r->read(r, &(fdi->info.regularinfo.dev), sizeof(uint32_t)) != sizeof(uint32_t)) - { - snprintf(error, SCAP_LASTERR_SIZE, "error reading the fd info from file (dev)"); - return SCAP_FAILURE; - } - (*nbytes) += sizeof(uint32_t); - break; - case SCAP_FD_FIFO: - case SCAP_FD_FILE: - case SCAP_FD_DIRECTORY: - case SCAP_FD_UNSUPPORTED: - case SCAP_FD_EVENT: - case SCAP_FD_SIGNALFD: - case SCAP_FD_EVENTPOLL: - case SCAP_FD_INOTIFY: - case SCAP_FD_TIMERFD: - case SCAP_FD_NETLINK: - case SCAP_FD_BPF: - case SCAP_FD_USERFAULTFD: - case SCAP_FD_IOURING: - case SCAP_FD_MEMFD: - case SCAP_FD_PIDFD: - res = scap_fd_read_fname_from_disk(fdi->info.fname, nbytes, r, error); - break; - case SCAP_FD_UNKNOWN: - ASSERT(false); - break; - default: - snprintf(error, SCAP_LASTERR_SIZE, "error reading the fd info from file, wrong fd type %u", (uint32_t)fdi->type); - return SCAP_FAILURE; - } - - if(sub_len && *nbytes != sub_len) - { - if(*nbytes > sub_len) - { - snprintf(error, SCAP_LASTERR_SIZE, "corrupted input file. Had read %zu bytes, but fdlist entry have length %u.", - *nbytes, sub_len); - return SCAP_FAILURE; - } - toread = (uint32_t)(sub_len - *nbytes); - fseekres = (int) r->seek(r, (long)toread, SEEK_CUR); - if(fseekres == -1) - { - snprintf(error, SCAP_LASTERR_SIZE, "corrupted input file. Can't skip %u bytes.", - (unsigned int)toread); - return SCAP_FAILURE; - } - *nbytes = sub_len; - } - - return res; -} - -// -// Parse a process list block -// -static int32_t scap_read_fdlist(scap_reader_t* r, uint32_t block_length, uint32_t block_type, struct scap_proclist* proclist, char* error) -{ - size_t readsize; - size_t totreadsize = 0; - size_t padding_len; - struct scap_threadinfo *tinfo; - scap_fdinfo fdi; - scap_fdinfo *nfdi; - // uint16_t stlen; - uint64_t tid; - int32_t uth_status = SCAP_SUCCESS; - uint32_t padding; - - // - // Read the tid - // - readsize = r->read(r, &tid, sizeof(tid)); - CHECK_READ_SIZE_ERR(readsize, sizeof(tid), error); - totreadsize += readsize; - - if(proclist->m_proc_callback == NULL) - { - // - // Identify the process descriptor - // - HASH_FIND_INT64(proclist->m_proclist, &tid, tinfo); - } - else - { - tinfo = NULL; - } - - while(((int32_t)block_length - (int32_t)totreadsize) >= 4) - { - if(scap_fd_read_from_disk(&fdi, &readsize, block_type, r, error) != SCAP_SUCCESS) - { - return SCAP_FAILURE; - } - totreadsize += readsize; - - // - // Add the entry to the table, or fire the notification callback - // - if(proclist->m_proc_callback == NULL) - { - if(tinfo == NULL) - { - // - // We have the fdinfo but no associated tid, skip it - // - continue; - } - - // - // Parsed successfully. Allocate the new entry and copy the temp one into into it. - // - nfdi = (scap_fdinfo *)malloc(sizeof(scap_fdinfo)); - if(nfdi == NULL) - { - snprintf(error, SCAP_LASTERR_SIZE, "process table allocation error (fd1)"); - return SCAP_FAILURE; - } - - // Structure copy - *nfdi = fdi; - - ASSERT(tinfo != NULL); - - HASH_ADD_INT64(tinfo->fdlist, fd, nfdi); - if(uth_status != SCAP_SUCCESS) - { - free(nfdi); - snprintf(error, SCAP_LASTERR_SIZE, "process table allocation error (fd2)"); - return SCAP_FAILURE; - } - } - else - { - ASSERT(tinfo == NULL); - - proclist->m_proc_callback( - proclist->m_proc_callback_context, tid, NULL, &fdi); - } - } - - // - // Read the padding bytes so we properly align to the end of the data - // - if(totreadsize > block_length) - { - ASSERT(false); - snprintf(error, SCAP_LASTERR_SIZE, "scap_read_fdlist read more %lu than a block %u", totreadsize, block_length); - return SCAP_FAILURE; - } - padding_len = block_length - totreadsize; - - readsize = r->read(r, &padding, (unsigned int)padding_len); - CHECK_READ_SIZE_ERR(readsize, padding_len, error); - - return SCAP_SUCCESS; -} - -static int32_t scap_read_section_header(scap_reader_t* r, char* error) -{ - section_header_block sh; - uint32_t bt; - - // - // Read the section header block - // - if(r->read(r, &sh, sizeof(sh)) != sizeof(sh) || - r->read(r, &bt, sizeof(bt)) != sizeof(bt)) - { - snprintf(error, SCAP_LASTERR_SIZE, "error reading from file (1)"); - return SCAP_FAILURE; - } - - if(sh.byte_order_magic != 0x1a2b3c4d) - { - snprintf(error, SCAP_LASTERR_SIZE, "invalid magic number"); - return SCAP_FAILURE; - } - - if(sh.major_version > CURRENT_MAJOR_VERSION) - { - snprintf(error, SCAP_LASTERR_SIZE, - "cannot correctly parse the capture. Upgrade your version."); - return SCAP_VERSION_MISMATCH; - } - - return SCAP_SUCCESS; -} - -// -// Parse the headers of a trace file and load the tables -// -static int32_t scap_read_init(struct savefile_engine *handle, scap_reader_t* r, scap_machine_info* machine_info_p, struct scap_proclist* proclist_p, scap_addrlist** addrlist_p, scap_userlist** userlist_p, char* error) -{ - block_header bh; - uint32_t bt; - size_t readsize; - size_t toread; - int fseekres; - int32_t rc; - int8_t found_ev = 0; - - // - // Read the section header block - // - if(read_block_header(handle, r, &bh) != sizeof(bh)) - { - snprintf(error, SCAP_LASTERR_SIZE, "error reading from file (1)"); - return SCAP_FAILURE; - } - - if(bh.block_type != SHB_BLOCK_TYPE) - { - snprintf(error, SCAP_LASTERR_SIZE, "invalid block type"); - return SCAP_FAILURE; - } - - if((rc = scap_read_section_header(r, error)) != SCAP_SUCCESS) - { - return rc; - } - - // - // Read the metadata blocks (processes, FDs, etc.) - // - while(true) - { - readsize = read_block_header(handle, r, &bh); - - // - // If we don't find the event block header, - // it means there is no event in the file. - // - if (readsize == 0 && !found_ev) - { - snprintf(error, SCAP_LASTERR_SIZE, "no events in file"); - return SCAP_FAILURE; - } - - CHECK_READ_SIZE_ERR(readsize, sizeof(bh), error); - - switch(bh.block_type) - { - case MI_BLOCK_TYPE: - case MI_BLOCK_TYPE_INT: - - if(scap_read_machine_info( - r, - machine_info_p, - error, - bh.block_total_length - sizeof(block_header) - 4) != SCAP_SUCCESS) - { - return SCAP_FAILURE; - } - break; - case PL_BLOCK_TYPE_V1: - case PL_BLOCK_TYPE_V2: - case PL_BLOCK_TYPE_V3: - case PL_BLOCK_TYPE_V4: - case PL_BLOCK_TYPE_V5: - case PL_BLOCK_TYPE_V6: - case PL_BLOCK_TYPE_V7: - case PL_BLOCK_TYPE_V8: - case PL_BLOCK_TYPE_V9: - case PL_BLOCK_TYPE_V1_INT: - case PL_BLOCK_TYPE_V2_INT: - case PL_BLOCK_TYPE_V3_INT: - - if(scap_read_proclist(r, bh.block_total_length - sizeof(block_header) - 4, bh.block_type, proclist_p, error) != SCAP_SUCCESS) - { - return SCAP_FAILURE; - } - break; - case FDL_BLOCK_TYPE: - case FDL_BLOCK_TYPE_INT: - case FDL_BLOCK_TYPE_V2: - - if(scap_read_fdlist(r, bh.block_total_length - sizeof(block_header) - 4, bh.block_type, proclist_p, error) != SCAP_SUCCESS) - { - return SCAP_FAILURE; - } - break; - case EV_BLOCK_TYPE: - case EV_BLOCK_TYPE_INT: - case EV_BLOCK_TYPE_V2: - case EVF_BLOCK_TYPE: - case EVF_BLOCK_TYPE_V2: - case EV_BLOCK_TYPE_V2_LARGE: - case EVF_BLOCK_TYPE_V2_LARGE: - // - // We're done with the metadata headers. - // - found_ev = 1; - handle->m_use_last_block_header = true; - break; - case IL_BLOCK_TYPE: - case IL_BLOCK_TYPE_INT: - case IL_BLOCK_TYPE_V2: - - if(scap_read_iflist(r, bh.block_total_length - sizeof(block_header) - 4, bh.block_type, addrlist_p, error) != SCAP_SUCCESS) - { - return SCAP_FAILURE; - } - break; - case UL_BLOCK_TYPE: - case UL_BLOCK_TYPE_INT: - case UL_BLOCK_TYPE_V2: - - if(scap_read_userlist(r, bh.block_total_length - sizeof(block_header) - 4, bh.block_type, userlist_p, error) != SCAP_SUCCESS) - { - return SCAP_FAILURE; - } - break; - default: - // - // Unknown block type. Skip the block. - // - toread = bh.block_total_length - sizeof(block_header) - 4; - fseekres = (int) r->seek(r, (long)toread, SEEK_CUR); - if(fseekres == -1) - { - snprintf(error, SCAP_LASTERR_SIZE, "corrupted input file. Can't skip block of type %x and size %u.", - (int)bh.block_type, - (unsigned int)toread); - return SCAP_FAILURE; - } - break; - } - - if(found_ev) - { - break; - } - - // - // Read and validate the trailer - // - readsize = r->read(r, &bt, sizeof(bt)); - CHECK_READ_SIZE_ERR(readsize, sizeof(bt), error); - - if(bt != bh.block_total_length) - { - snprintf(error, SCAP_LASTERR_SIZE, "wrong block total length, header=%u, trailer=%u", - bh.block_total_length, - bt); - return SCAP_FAILURE; - } - } - - // - // NOTE: can't require a user list block, interface list block, or machine info block - // any longer--with the introduction of source plugins, it is legitimate to have - // trace files that don't contain those blocks - // - - return SCAP_SUCCESS; -} - -// -// Read an event from disk -// -static int32_t next(struct scap_engine_handle engine, scap_evt **pevent, uint16_t *pcpuid) -{ - struct savefile_engine* handle = engine.m_handle; - block_header bh; - size_t readsize; - uint32_t readlen; - size_t hdr_len; - scap_reader_t* r = handle->m_reader; - - ASSERT(r != NULL); - - // - // We may have to repeat the whole process - // if the capture contains new syscalls - // - while(true) - { - // - // Read the block header - // - readsize = read_block_header(handle, r, &bh); - - if(readsize != sizeof(bh)) - { - int err_no = 0; -#ifdef _WIN32 - const char* err_str = "read error"; -#else - const char* err_str = r->error(r, &err_no); -#endif - if(err_no) - { - snprintf(handle->m_lasterr, SCAP_LASTERR_SIZE, "error reading file: %s, ernum=%d", err_str, err_no); - return SCAP_FAILURE; - } - - if(readsize == 0) - { - // - // We read exactly 0 bytes. This indicates a correct end of file. - // - return SCAP_EOF; - } - else - { - CHECK_READ_SIZE(readsize, sizeof(bh)); - } - } - - if(bh.block_type != EV_BLOCK_TYPE && - bh.block_type != EV_BLOCK_TYPE_V2 && - bh.block_type != EV_BLOCK_TYPE_V2_LARGE && - bh.block_type != EV_BLOCK_TYPE_INT && - bh.block_type != EVF_BLOCK_TYPE && - bh.block_type != EVF_BLOCK_TYPE_V2 && - bh.block_type != EVF_BLOCK_TYPE_V2_LARGE) - { - snprintf(handle->m_lasterr, SCAP_LASTERR_SIZE, "unexpected block type %u", (uint32_t)bh.block_type); - handle->m_use_last_block_header = true; - return SCAP_UNEXPECTED_BLOCK; - } - - hdr_len = sizeof(struct ppm_evt_hdr); - if(bh.block_type != EV_BLOCK_TYPE_V2 && - bh.block_type != EV_BLOCK_TYPE_V2_LARGE && - bh.block_type != EVF_BLOCK_TYPE_V2 && - bh.block_type != EVF_BLOCK_TYPE_V2_LARGE) - { - hdr_len -= 4; - } - - if(bh.block_total_length < sizeof(bh) + hdr_len + 4) - { - snprintf(handle->m_lasterr, SCAP_LASTERR_SIZE, "block length too short %u", (uint32_t)bh.block_total_length); - return SCAP_FAILURE; - } - - // - // Read the event - // - readlen = bh.block_total_length - sizeof(bh); - // Non-large block types have an uint16_max maximum size - if (bh.block_type != EV_BLOCK_TYPE_V2_LARGE && bh.block_type != EVF_BLOCK_TYPE_V2_LARGE) { - if(readlen > READER_BUF_SIZE) { - snprintf(handle->m_lasterr, SCAP_LASTERR_SIZE, "event block length %u greater than NON-LARGE read buffer size %u", - readlen, - READER_BUF_SIZE); - return SCAP_FAILURE; - } - } else if (readlen > handle->m_reader_evt_buf_size) { - // Try to allocate a buffer large enough - char *tmp = realloc(handle->m_reader_evt_buf, readlen); - if (!tmp) { - free(handle->m_reader_evt_buf); - handle->m_reader_evt_buf = NULL; - snprintf(handle->m_lasterr, SCAP_LASTERR_SIZE, "event block length %u greater than read buffer size %zu", - readlen, - handle->m_reader_evt_buf_size); - return SCAP_FAILURE; - } - handle->m_reader_evt_buf = tmp; - handle->m_reader_evt_buf_size = readlen; - } - - readsize = r->read(r, handle->m_reader_evt_buf, readlen); - CHECK_READ_SIZE(readsize, readlen); - - // - // EVF_BLOCK_TYPE has 32 bits of flags - // - *pcpuid = *(uint16_t *)handle->m_reader_evt_buf; - - if(bh.block_type == EVF_BLOCK_TYPE || bh.block_type == EVF_BLOCK_TYPE_V2 || bh.block_type == EVF_BLOCK_TYPE_V2_LARGE) - { - handle->m_last_evt_dump_flags = *(uint32_t*)(handle->m_reader_evt_buf + sizeof(uint16_t)); - *pevent = (struct ppm_evt_hdr *)(handle->m_reader_evt_buf + sizeof(uint16_t) + sizeof(uint32_t)); - } - else - { - handle->m_last_evt_dump_flags = 0; - *pevent = (struct ppm_evt_hdr *)(handle->m_reader_evt_buf + sizeof(uint16_t)); - } - - if((*pevent)->type >= PPM_EVENT_MAX) - { - // - // We're reading a capture that contains new syscalls. - // We can't do anything else that skips them. - // - continue; - } - - if(bh.block_type != EV_BLOCK_TYPE_V2 && - bh.block_type != EV_BLOCK_TYPE_V2_LARGE && - bh.block_type != EVF_BLOCK_TYPE_V2 && - bh.block_type != EVF_BLOCK_TYPE_V2_LARGE) - { - // - // We're reading an old capture whose events don't have nparams in the header. - // Convert it to the current version. - // - if((readlen + sizeof(uint32_t)) > READER_BUF_SIZE) - { - snprintf(handle->m_lasterr, SCAP_LASTERR_SIZE, "cannot convert v1 event block to v2 (%lu greater than read buffer size %u)", - readlen + sizeof(uint32_t), - READER_BUF_SIZE); - return SCAP_FAILURE; - } - - memmove((char *)*pevent + sizeof(struct ppm_evt_hdr), - (char *)*pevent + sizeof(struct ppm_evt_hdr) - sizeof(uint32_t), - readlen - ((char *)*pevent - handle->m_reader_evt_buf) - (sizeof(struct ppm_evt_hdr) - sizeof(uint32_t))); - (*pevent)->len += sizeof(uint32_t); - - // In old captures, the length of PPME_NOTIFICATION_E and PPME_INFRASTRUCTURE_EVENT_E - // is not correct. Adjust it, otherwise the following code will never find a match - if((*pevent)->type == PPME_NOTIFICATION_E || (*pevent)->type == PPME_INFRASTRUCTURE_EVENT_E) - { - (*pevent)->len -= 3; - } - - // - // The number of parameters needs to be calculated based on the block len. - // Use the current number of parameters as starting point and decrease it - // until size matches. - // - char *end = (char *)*pevent + (*pevent)->len; - uint16_t *lens = (uint16_t *)((char *)*pevent + sizeof(struct ppm_evt_hdr)); - uint32_t nparams; - bool done = false; - for(nparams = g_event_info[(*pevent)->type].nparams; (int)nparams >= 0; nparams--) - { - char *valptr = (char *)lens + nparams * sizeof(uint16_t); - if(valptr > end) - { - continue; - } - uint32_t i; - for(i = 0; i < nparams; i++) - { - valptr += lens[i]; - } - if(valptr < end) - { - snprintf(handle->m_lasterr, SCAP_LASTERR_SIZE, "cannot convert v1 event block to v2 (corrupted trace file - can't calculate nparams)."); - return SCAP_FAILURE; - } - ASSERT(valptr >= end); - if(valptr == end) - { - done = true; - break; - } - } - if(!done) - { - snprintf(handle->m_lasterr, SCAP_LASTERR_SIZE, "cannot convert v1 event block to v2 (corrupted trace file - can't calculate nparams) (2)."); - return SCAP_FAILURE; - } - (*pevent)->nparams = nparams; - } - - break; - } - - return SCAP_SUCCESS; -} - -uint64_t scap_savefile_ftell(struct scap_engine_handle engine) -{ - scap_reader_t* reader = engine.m_handle->m_reader; - return reader->tell(reader); -} - -void scap_savefile_fseek(struct scap_engine_handle engine, uint64_t off) -{ - scap_reader_t* reader = engine.m_handle->m_reader; - reader->seek(reader, off, SEEK_SET); -} - -static int32_t -scap_savefile_init_platform(struct scap_platform *platform, char *lasterr, struct scap_engine_handle engine, - struct scap_open_args *oargs) -{ - return SCAP_SUCCESS; -} - -static int32_t scap_savefile_close_platform(struct scap_platform* platform) -{ - return SCAP_SUCCESS; -} - -static void scap_savefile_free_platform(struct scap_platform* platform) -{ - free(platform); -} - -bool scap_savefile_is_thread_alive(struct scap_platform* platform, int64_t pid, int64_t tid, const char* comm) -{ - return false; -} - -static const struct scap_platform_vtable scap_savefile_platform_vtable = { - .init_platform = scap_savefile_init_platform, - .is_thread_alive = scap_savefile_is_thread_alive, - .close_platform = scap_savefile_close_platform, - .free_platform = scap_savefile_free_platform, -}; - -struct scap_platform* scap_savefile_alloc_platform() -{ - struct scap_savefile_platform* platform = calloc(sizeof(*platform), 1); - - if(platform == NULL) - { - return NULL; - } - - platform->m_generic.m_vtable = &scap_savefile_platform_vtable; - platform->m_generic.m_machine_info.num_cpus = (uint32_t)-1; - - return &platform->m_generic; -} - -static struct savefile_engine* alloc_handle(struct scap* main_handle, char* lasterr_ptr) -{ - struct savefile_engine *engine = calloc(1, sizeof(struct savefile_engine)); - if(engine) - { - engine->m_lasterr = lasterr_ptr; - } - return engine; - -} - -static int32_t init(struct scap* main_handle, struct scap_open_args* oargs) -{ - gzFile gzfile; - int res; - struct savefile_engine *handle = main_handle->m_engine.m_handle; - struct scap_savefile_engine_params* params = oargs->engine_params; - struct scap_platform *platform = main_handle->m_platform; - int fd = params->fd; - const char* fname = params->fname; - uint64_t start_offset = params->start_offset; - uint32_t fbuffer_size = params->fbuffer_size; - - if(fd != 0) - { - gzfile = gzdopen(fd, "rb"); - } - else - { - gzfile = gzopen(fname, "rb"); - } - - if(gzfile == NULL) - { - if(fd != 0) - { - snprintf(main_handle->m_lasterr, SCAP_LASTERR_SIZE, "can't open fd %d", fd); - } - else - { - snprintf(main_handle->m_lasterr, SCAP_LASTERR_SIZE, "can't open file %s", fname); - } - return SCAP_FAILURE; - } - - scap_reader_t* reader = scap_reader_open_gzfile(gzfile); - if(!reader) - { - gzclose(gzfile); - return SCAP_FAILURE; - } - - if (fbuffer_size > 0) - { - scap_reader_t* buffered_reader = scap_reader_open_buffered(reader, fbuffer_size, true); - if(!buffered_reader) - { - reader->close(reader); - return SCAP_FAILURE; - } - reader = buffered_reader; - } - - // - // If this is a merged file, we might have to move the read offset to the next section - // - if(start_offset != 0) - { - scap_fseek(main_handle, start_offset); - } - - handle->m_use_last_block_header = false; - - res = scap_read_init( - handle, - reader, - &platform->m_machine_info, - &platform->m_proclist, - &platform->m_addrlist, - &platform->m_userlist, - main_handle->m_lasterr - ); - - if(res != SCAP_SUCCESS) - { - reader->close(reader); - return res; - } - - handle->m_reader_evt_buf = (char*)malloc(READER_BUF_SIZE); - if(!handle->m_reader_evt_buf) - { - snprintf(main_handle->m_lasterr, SCAP_LASTERR_SIZE, "error allocating the read buffer"); - return SCAP_FAILURE; - } - handle->m_reader_evt_buf_size = READER_BUF_SIZE; - handle->m_reader = reader; - - if(!oargs->import_users) - { - if(platform->m_userlist != NULL) - { - scap_free_userlist(platform->m_userlist); - platform->m_userlist = NULL; - } - } - - return SCAP_SUCCESS; -} - -static void free_handle(struct scap_engine_handle engine) -{ - free(engine.m_handle); -} - -static int32_t scap_savefile_close(struct scap_engine_handle engine) -{ - struct savefile_engine* handle = engine.m_handle; - if (handle->m_reader) - { - handle->m_reader->close(handle->m_reader); - handle->m_reader = NULL; - } - - if(handle->m_reader_evt_buf) - { - free(handle->m_reader_evt_buf); - handle->m_reader_evt_buf = NULL; - } - - return SCAP_SUCCESS; -} - -static int32_t scap_savefile_restart_capture(scap_t* handle) -{ - struct savefile_engine *engine = handle->m_engine.m_handle; - struct scap_platform *platform = handle->m_platform; - int32_t res; - - scap_platform_close(platform); - - if((res = scap_read_init( - engine, - engine->m_reader, - &platform->m_machine_info, - &platform->m_proclist, - &platform->m_addrlist, - &platform->m_userlist, - handle->m_lasterr)) != SCAP_SUCCESS) - { - char error[SCAP_LASTERR_SIZE]; - snprintf(error, SCAP_LASTERR_SIZE, "could not restart capture: %s", scap_getlasterr(handle)); - strlcpy(handle->m_lasterr, error, SCAP_LASTERR_SIZE); - } - return res; -} - -static int64_t get_readfile_offset(struct scap_engine_handle engine) -{ - return engine.m_handle->m_reader->offset(engine.m_handle->m_reader); -} - -static uint32_t get_event_dump_flags(struct scap_engine_handle engine) -{ - return engine.m_handle->m_last_evt_dump_flags; -} - -static struct scap_savefile_vtable savefile_ops = { - .ftell_capture = scap_savefile_ftell, - .fseek_capture = scap_savefile_fseek, - - .restart_capture = scap_savefile_restart_capture, - .get_readfile_offset = get_readfile_offset, - .get_event_dump_flags = get_event_dump_flags, -}; - -struct scap_vtable scap_savefile_engine = { - .name = SAVEFILE_ENGINE, - .mode = SCAP_MODE_CAPTURE, - .savefile_ops = &savefile_ops, - - .alloc_handle = alloc_handle, - .init = init, - .free_handle = free_handle, - .close = scap_savefile_close, - .next = next, - .start_capture = noop_start_capture, - .stop_capture = noop_stop_capture, - .configure = noop_configure, - .get_stats = noop_get_stats, - .get_stats_v2 = noop_get_stats_v2, - .get_n_tracepoint_hit = noop_get_n_tracepoint_hit, - .get_n_devs = noop_get_n_devs, - .get_max_buf_used = noop_get_max_buf_used, - .get_api_version = NULL, - .get_schema_version = NULL, -}; +// SPDX-License-Identifier: Apache-2.0 +/* +Copyright (C) 2023 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. + +*/ + + +#include +#include + +#ifndef _WIN32 +#include +#include +#else +struct iovec { + void *iov_base; /* Starting address */ + size_t iov_len; /* Number of bytes to transfer */ +}; +#endif + +#define SCAP_HANDLE_T struct savefile_engine +#include "savefile.h" +#include "scap.h" +#include "scap-int.h" +#include "scap_platform.h" +#include "scap_savefile.h" +#include "savefile_platform.h" +#include "scap_reader.h" +#include "../noop/noop.h" + +#include "strl.h" + +// +// Read the section header block +// +inline static int read_block_header(struct savefile_engine* handle, struct scap_reader *r, block_header* h) +{ + int res = sizeof(block_header); + if (!handle->m_use_last_block_header) + { + res = r->read(r, &handle->m_last_block_header, sizeof(block_header)); + } + memcpy(h, &handle->m_last_block_header, sizeof(block_header)); + handle->m_use_last_block_header = false; + return res; +} + +// +// Load the machine info block +// +static int32_t scap_read_machine_info(scap_reader_t* r, scap_machine_info* machine_info, char* error, uint32_t block_length) +{ + // + // Read the section header block + // + if(r->read(r, machine_info, sizeof(*machine_info)) != + sizeof(*machine_info)) + { + snprintf(error, SCAP_LASTERR_SIZE, "error reading from file (1)"); + return SCAP_FAILURE; + } + + return SCAP_SUCCESS; +} + +// +// Parse a process list block +// +static int32_t scap_read_proclist(scap_reader_t* r, uint32_t block_length, uint32_t block_type, struct scap_proclist *proclist, char *error) +{ + size_t readsize; + size_t subreadsize = 0; + size_t totreadsize = 0; + size_t padding_len; + uint16_t stlen; + uint32_t padding; + int32_t uth_status = SCAP_SUCCESS; + uint32_t toread; + int fseekres; + + while(((int32_t)block_length - (int32_t)totreadsize) >= 4) + { + struct scap_threadinfo tinfo; + + tinfo.fdlist = NULL; + tinfo.flags = 0; + tinfo.vmsize_kb = 0; + tinfo.vmrss_kb = 0; + tinfo.vmswap_kb = 0; + tinfo.pfmajor = 0; + tinfo.pfminor = 0; + tinfo.env_len = 0; + tinfo.vtid = -1; + tinfo.vpid = -1; + tinfo.cgroups.len = 0; + tinfo.filtered_out = 0; + tinfo.root[0] = 0; + tinfo.sid = -1; + tinfo.vpgid = -1; + tinfo.clone_ts = 0; + tinfo.pidns_init_start_ts = 0; + tinfo.tty = 0; + tinfo.exepath[0] = 0; + tinfo.loginuid = UINT32_MAX; + tinfo.exe_writable = false; + tinfo.cap_inheritable = 0; + tinfo.cap_permitted = 0; + tinfo.cap_effective = 0; + tinfo.exe_upper_layer = false; + tinfo.exe_ino = 0; + tinfo.exe_ino_ctime = 0; + tinfo.exe_ino_mtime = 0; + tinfo.exe_from_memfd = false; + + // + // len + // + uint32_t sub_len = 0; + switch(block_type) + { + case PL_BLOCK_TYPE_V1: + case PL_BLOCK_TYPE_V1_INT: + case PL_BLOCK_TYPE_V2: + case PL_BLOCK_TYPE_V2_INT: + case PL_BLOCK_TYPE_V3: + case PL_BLOCK_TYPE_V3_INT: + case PL_BLOCK_TYPE_V4: + case PL_BLOCK_TYPE_V5: + case PL_BLOCK_TYPE_V6: + case PL_BLOCK_TYPE_V7: + case PL_BLOCK_TYPE_V8: + break; + case PL_BLOCK_TYPE_V9: + readsize = r->read(r, &(sub_len), sizeof(uint32_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint32_t), error); + + subreadsize += readsize; + break; + default: + snprintf(error, SCAP_LASTERR_SIZE, "corrupted process block type (fd1)"); + ASSERT(false); + return SCAP_FAILURE; + } + + // + // tid + // + readsize = r->read(r, &(tinfo.tid), sizeof(uint64_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint64_t), error); + + subreadsize += readsize; + + // + // pid + // + readsize = r->read(r, &(tinfo.pid), sizeof(uint64_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint64_t), error); + + subreadsize += readsize; + + // + // ptid + // + readsize = r->read(r, &(tinfo.ptid), sizeof(uint64_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint64_t), error); + + subreadsize += readsize; + + switch(block_type) + { + case PL_BLOCK_TYPE_V1: + case PL_BLOCK_TYPE_V1_INT: + case PL_BLOCK_TYPE_V2: + case PL_BLOCK_TYPE_V2_INT: + case PL_BLOCK_TYPE_V3: + case PL_BLOCK_TYPE_V3_INT: + case PL_BLOCK_TYPE_V4: + case PL_BLOCK_TYPE_V5: + break; + case PL_BLOCK_TYPE_V6: + case PL_BLOCK_TYPE_V7: + case PL_BLOCK_TYPE_V8: + case PL_BLOCK_TYPE_V9: + readsize = r->read(r, &(tinfo.sid), sizeof(uint64_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint64_t), error); + + subreadsize += readsize; + break; + default: + snprintf(error, SCAP_LASTERR_SIZE, "corrupted process block type (fd1)"); + ASSERT(false); + return SCAP_FAILURE; + } + + // + // vpgid + // + switch(block_type) + { + case PL_BLOCK_TYPE_V1: + case PL_BLOCK_TYPE_V1_INT: + case PL_BLOCK_TYPE_V2: + case PL_BLOCK_TYPE_V2_INT: + case PL_BLOCK_TYPE_V3: + case PL_BLOCK_TYPE_V3_INT: + case PL_BLOCK_TYPE_V4: + case PL_BLOCK_TYPE_V5: + case PL_BLOCK_TYPE_V6: + case PL_BLOCK_TYPE_V7: + break; + case PL_BLOCK_TYPE_V8: + case PL_BLOCK_TYPE_V9: + readsize = r->read(r, &(tinfo.vpgid), sizeof(uint64_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint64_t), error); + + subreadsize += readsize; + break; + default: + snprintf(error, SCAP_LASTERR_SIZE, "corrupted process block type (fd1)"); + ASSERT(false); + return SCAP_FAILURE; + } + + // + // comm + // + readsize = r->read(r, &(stlen), sizeof(uint16_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint16_t), error); + + if(stlen > SCAP_MAX_PATH_SIZE) + { + snprintf(error, SCAP_LASTERR_SIZE, "invalid commlen %d", stlen); + return SCAP_FAILURE; + } + + subreadsize += readsize; + + readsize = r->read(r, tinfo.comm, stlen); + CHECK_READ_SIZE_ERR(readsize, stlen, error); + + // the string is not null-terminated on file + tinfo.comm[stlen] = 0; + + subreadsize += readsize; + + // + // exe + // + readsize = r->read(r, &(stlen), sizeof(uint16_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint16_t), error); + + if(stlen > SCAP_MAX_PATH_SIZE) + { + snprintf(error, SCAP_LASTERR_SIZE, "invalid exelen %d", stlen); + return SCAP_FAILURE; + } + + subreadsize += readsize; + + readsize = r->read(r, tinfo.exe, stlen); + CHECK_READ_SIZE_ERR(readsize, stlen, error); + + // the string is not null-terminated on file + tinfo.exe[stlen] = 0; + + subreadsize += readsize; + + switch(block_type) + { + case PL_BLOCK_TYPE_V1: + case PL_BLOCK_TYPE_V1_INT: + case PL_BLOCK_TYPE_V2: + case PL_BLOCK_TYPE_V2_INT: + case PL_BLOCK_TYPE_V3: + case PL_BLOCK_TYPE_V3_INT: + case PL_BLOCK_TYPE_V4: + case PL_BLOCK_TYPE_V5: + case PL_BLOCK_TYPE_V6: + break; + case PL_BLOCK_TYPE_V7: + case PL_BLOCK_TYPE_V8: + case PL_BLOCK_TYPE_V9: + // + // exepath + // + readsize = r->read(r, &(stlen), sizeof(uint16_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint16_t), error); + + if(stlen > SCAP_MAX_PATH_SIZE) + { + snprintf(error, SCAP_LASTERR_SIZE, "invalid exepathlen %d", stlen); + return SCAP_FAILURE; + } + + subreadsize += readsize; + + readsize = r->read(r, tinfo.exepath, stlen); + CHECK_READ_SIZE_ERR(readsize, stlen, error); + + // the string is not null-terminated on file + tinfo.exepath[stlen] = 0; + + subreadsize += readsize; + + break; + default: + snprintf(error, SCAP_LASTERR_SIZE, "corrupted process block type (fd1)"); + ASSERT(false); + return SCAP_FAILURE; + } + + // + // args + // + readsize = r->read(r, &(stlen), sizeof(uint16_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint16_t), error); + + if(stlen > SCAP_MAX_ARGS_SIZE) + { + snprintf(error, SCAP_LASTERR_SIZE, "invalid argslen %d", stlen); + return SCAP_FAILURE; + } + + subreadsize += readsize; + + readsize = r->read(r, tinfo.args, stlen); + CHECK_READ_SIZE_ERR(readsize, stlen, error); + + // the string is not null-terminated on file + tinfo.args[stlen] = 0; + tinfo.args_len = stlen; + + subreadsize += readsize; + + // + // cwd + // + readsize = r->read(r, &(stlen), sizeof(uint16_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint16_t), error); + + if(stlen > SCAP_MAX_PATH_SIZE) + { + snprintf(error, SCAP_LASTERR_SIZE, "invalid cwdlen %d", stlen); + return SCAP_FAILURE; + } + + subreadsize += readsize; + + readsize = r->read(r, tinfo.cwd, stlen); + CHECK_READ_SIZE_ERR(readsize, stlen, error); + + // the string is not null-terminated on file + tinfo.cwd[stlen] = 0; + + subreadsize += readsize; + + // + // fdlimit + // + readsize = r->read(r, &(tinfo.fdlimit), sizeof(uint64_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint64_t), error); + + subreadsize += readsize; + + // + // flags + // + readsize = r->read(r, &(tinfo.flags), sizeof(uint32_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint32_t), error); + + subreadsize += readsize; + + // + // uid + // + readsize = r->read(r, &(tinfo.uid), sizeof(uint32_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint32_t), error); + + subreadsize += readsize; + + // + // gid + // + readsize = r->read(r, &(tinfo.gid), sizeof(uint32_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint32_t), error); + + subreadsize += readsize; + + switch(block_type) + { + case PL_BLOCK_TYPE_V1: + case PL_BLOCK_TYPE_V1_INT: + break; + case PL_BLOCK_TYPE_V2: + case PL_BLOCK_TYPE_V2_INT: + case PL_BLOCK_TYPE_V3: + case PL_BLOCK_TYPE_V3_INT: + case PL_BLOCK_TYPE_V4: + case PL_BLOCK_TYPE_V5: + case PL_BLOCK_TYPE_V6: + case PL_BLOCK_TYPE_V7: + case PL_BLOCK_TYPE_V8: + case PL_BLOCK_TYPE_V9: + // + // vmsize_kb + // + readsize = r->read(r, &(tinfo.vmsize_kb), sizeof(uint32_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint32_t), error); + + subreadsize += readsize; + + // + // vmrss_kb + // + readsize = r->read(r, &(tinfo.vmrss_kb), sizeof(uint32_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint32_t), error); + + subreadsize += readsize; + + // + // vmswap_kb + // + readsize = r->read(r, &(tinfo.vmswap_kb), sizeof(uint32_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint32_t), error); + + subreadsize += readsize; + + // + // pfmajor + // + readsize = r->read(r, &(tinfo.pfmajor), sizeof(uint64_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint64_t), error); + + subreadsize += readsize; + + // + // pfminor + // + readsize = r->read(r, &(tinfo.pfminor), sizeof(uint64_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint64_t), error); + + subreadsize += readsize; + + if(block_type == PL_BLOCK_TYPE_V3 || + block_type == PL_BLOCK_TYPE_V3_INT || + block_type == PL_BLOCK_TYPE_V4 || + block_type == PL_BLOCK_TYPE_V5 || + block_type == PL_BLOCK_TYPE_V6 || + block_type == PL_BLOCK_TYPE_V7 || + block_type == PL_BLOCK_TYPE_V8 || + block_type == PL_BLOCK_TYPE_V9) + { + // + // env + // + readsize = r->read(r, &(stlen), sizeof(uint16_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint16_t), error); + + if(stlen > SCAP_MAX_ENV_SIZE) + { + snprintf(error, SCAP_LASTERR_SIZE, "invalid envlen %d", stlen); + return SCAP_FAILURE; + } + + subreadsize += readsize; + + readsize = r->read(r, tinfo.env, stlen); + CHECK_READ_SIZE_ERR(readsize, stlen, error); + + // the string is not null-terminated on file + tinfo.env[stlen] = 0; + tinfo.env_len = stlen; + + subreadsize += readsize; + } + + if(block_type == PL_BLOCK_TYPE_V4 || + block_type == PL_BLOCK_TYPE_V5 || + block_type == PL_BLOCK_TYPE_V6 || + block_type == PL_BLOCK_TYPE_V7 || + block_type == PL_BLOCK_TYPE_V8 || + block_type == PL_BLOCK_TYPE_V9) + { + // + // vtid + // + readsize = r->read(r, &(tinfo.vtid), sizeof(int64_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint64_t), error); + + subreadsize += readsize; + + // + // vpid + // + readsize = r->read(r, &(tinfo.vpid), sizeof(int64_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint64_t), error); + + subreadsize += readsize; + + // + // cgroups + // + readsize = r->read(r, &(stlen), sizeof(uint16_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint16_t), error); + + if(stlen > SCAP_MAX_CGROUPS_SIZE) + { + snprintf(error, SCAP_LASTERR_SIZE, "invalid cgroupslen %d", stlen); + return SCAP_FAILURE; + } + tinfo.cgroups.len = stlen; + + subreadsize += readsize; + + readsize = r->read(r, tinfo.cgroups.path, stlen); + CHECK_READ_SIZE_ERR(readsize, stlen, error); + + subreadsize += readsize; + + if(block_type == PL_BLOCK_TYPE_V5 || + block_type == PL_BLOCK_TYPE_V6 || + block_type == PL_BLOCK_TYPE_V7 || + block_type == PL_BLOCK_TYPE_V8 || + block_type == PL_BLOCK_TYPE_V9) + { + readsize = r->read(r, &(stlen), sizeof(uint16_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint16_t), error); + + if(stlen > SCAP_MAX_PATH_SIZE) + { + snprintf(error, SCAP_LASTERR_SIZE, "invalid rootlen %d", stlen); + return SCAP_FAILURE; + } + + subreadsize += readsize; + + readsize = r->read(r, tinfo.root, stlen); + CHECK_READ_SIZE_ERR(readsize, stlen, error); + + // the string is not null-terminated on file + tinfo.root[stlen] = 0; + + subreadsize += readsize; + } + } + break; + default: + snprintf(error, SCAP_LASTERR_SIZE, "corrupted process block type (fd1)"); + ASSERT(false); + return SCAP_FAILURE; + } + + // If new parameters are added, sub_len can be used to + // see if they are available in the current capture. + // For example, for a 32bit parameter: + // + // if(sub_len && (subreadsize + sizeof(uint32_t)) <= sub_len) + // { + // ... + // } + + // In 0.10.x libs tag, 2 fields were added to the scap file producer, + // written in the middle of the proclist entry, breaking forward compatibility + // for old scap file readers. + // Detect this hacky behavior, and manage it. + // Added fields: + // * exe_upper_layer + // * exe_ino + // * exe_ino_ctime + // * exe_ino_mtime + // * pidns_init_start_ts (in the middle) + // * tty (in the middle) + // So, to check if we need to enable the "pre-0.10.x hack", + // we need to check if remaining data to be read is <= than + // sum of sizes for fields existent in libs < 0.10.x, ie: + // * loginuid (4B) + // * exe_writable (1B) + // * cap_inheritable (8B) + // * cap_permitted (8B) + // * cap_effective (8B) + // TOTAL: 29B + bool pre_0_10_0 = false; + if (sub_len - subreadsize <= 29) + { + pre_0_10_0 = true; + } + + if (!pre_0_10_0) + { + // Ok we are in libs >= 0.10.x; read the fields that + // were added interleaved in libs 0.10.0 + + // + // pidns_init_start_ts + // + if(sub_len && (subreadsize + sizeof(uint64_t)) <= sub_len) + { + readsize = r->read(r, &(tinfo.pidns_init_start_ts), sizeof(uint64_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint64_t), error); + subreadsize += readsize; + } + + // + // tty + // + if(sub_len && (subreadsize + sizeof(uint32_t)) <= sub_len) + { + readsize = r->read(r, &(tinfo.tty), sizeof(uint32_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint32_t), error); + subreadsize += readsize; + } + } + + // + // loginuid (auid) + // + if(sub_len && (subreadsize + sizeof(uint32_t)) <= sub_len) + { + readsize = r->read(r, &(tinfo.loginuid), sizeof(uint32_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint32_t), error); + subreadsize += readsize; + } + + // + // exe_writable + // + if(sub_len && (subreadsize + sizeof(uint8_t)) <= sub_len) + { + readsize = r->read(r, &(tinfo.exe_writable), sizeof(uint8_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint8_t), error); + subreadsize += readsize; + } + + // + // Capabilities + // + if(sub_len && (subreadsize + sizeof(uint64_t)) <= sub_len) + { + readsize = r->read(r, &(tinfo.cap_inheritable), sizeof(uint64_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint64_t), error); + subreadsize += readsize; + } + + if(sub_len && (subreadsize + sizeof(uint64_t)) <= sub_len) + { + readsize = r->read(r, &(tinfo.cap_permitted), sizeof(uint64_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint64_t), error); + subreadsize += readsize; + } + + if(sub_len && (subreadsize + sizeof(uint64_t)) <= sub_len) + { + readsize = r->read(r, &(tinfo.cap_effective), sizeof(uint64_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint64_t), error); + subreadsize += readsize; + } + + // exe_upper_layer + if(sub_len && (subreadsize + sizeof(uint8_t)) <= sub_len) + { + readsize = r->read(r, &(tinfo.exe_upper_layer), sizeof(uint8_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint8_t), error); + subreadsize += readsize; + } + + // exe_ino + if(sub_len && (subreadsize + sizeof(uint64_t)) <= sub_len) + { + readsize = r->read(r, &(tinfo.exe_ino), sizeof(uint64_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint64_t), error); + subreadsize += readsize; + } + + // exe_ino_ctime + if(sub_len && (subreadsize + sizeof(uint64_t)) <= sub_len) + { + readsize = r->read(r, &(tinfo.exe_ino_ctime), sizeof(uint64_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint64_t), error); + subreadsize += readsize; + } + + // exe_ino_mtime + if(sub_len && (subreadsize + sizeof(uint64_t)) <= sub_len) + { + readsize = r->read(r, &(tinfo.exe_ino_mtime), sizeof(uint64_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint64_t), error); + subreadsize += readsize; + } + + // exe_from_memfd + if(sub_len && (subreadsize + sizeof(uint8_t)) <= sub_len) + { + uint8_t exe_from_memfd = 0; + readsize = r->read(r, &exe_from_memfd, sizeof(uint8_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint8_t), error); + subreadsize += readsize; + tinfo.exe_from_memfd = (exe_from_memfd != 0); + } + + // + // All parsed. Add the entry to the table, or fire the notification callback + // + if(proclist->m_proc_callback == NULL) + { + // + // All parsed. Allocate the new entry and copy the temp one into into it. + // + struct scap_threadinfo *ntinfo = (scap_threadinfo *)malloc(sizeof(scap_threadinfo)); + if(ntinfo == NULL) + { + snprintf(error, SCAP_LASTERR_SIZE, "process table allocation error (fd1)"); + return SCAP_FAILURE; + } + + // Structure copy + *ntinfo = tinfo; + + HASH_ADD_INT64(proclist->m_proclist, tid, ntinfo); + if(uth_status != SCAP_SUCCESS) + { + free(ntinfo); + snprintf(error, SCAP_LASTERR_SIZE, "process table allocation error (fd2)"); + return SCAP_FAILURE; + } + } + else + { + proclist->m_proc_callback( + proclist->m_proc_callback_context, tinfo.tid, &tinfo, NULL); + } + + if(sub_len && subreadsize != sub_len) + { + if(subreadsize > sub_len) + { + snprintf(error, SCAP_LASTERR_SIZE, "corrupted input file. Had read %lu bytes, but proclist entry have length %u.", + subreadsize, sub_len); + return SCAP_FAILURE; + } + toread = sub_len - subreadsize; + fseekres = (int) r->seek(r, (long)toread, SEEK_CUR); + if(fseekres == -1) + { + snprintf(error, SCAP_LASTERR_SIZE, "corrupted input file. Can't skip %u bytes.", + (unsigned int)toread); + return SCAP_FAILURE; + } + subreadsize = sub_len; + } + + totreadsize += subreadsize; + subreadsize = 0; + } + + // + // Read the padding bytes so we properly align to the end of the data + // + if(totreadsize > block_length) + { + snprintf(error, SCAP_LASTERR_SIZE, "scap_read_proclist read more %lu than a block %u", totreadsize, block_length); + ASSERT(false); + return SCAP_FAILURE; + } + padding_len = block_length - totreadsize; + + readsize = (size_t)r->read(r, &padding, (unsigned int)padding_len); + CHECK_READ_SIZE_ERR(readsize, padding_len, error); + + return SCAP_SUCCESS; +} + +// +// Parse an interface list block +// +static int32_t scap_read_iflist(scap_reader_t* r, uint32_t block_length, uint32_t block_type, scap_addrlist** addrlist_p, char* error) +{ + int32_t res = SCAP_SUCCESS; + size_t readsize; + size_t totreadsize; + char *readbuf = NULL; + char *pif; + uint16_t iftype; + uint16_t ifnamlen; + uint32_t toread; + uint32_t entrysize; + uint32_t ifcnt4 = 0; + uint32_t ifcnt6 = 0; + + // + // If the list of interfaces was already allocated for this handle (for example because this is + // not the first interface list block), free it + // + if((*addrlist_p) != NULL) + { + scap_free_iflist((*addrlist_p)); + (*addrlist_p) = NULL; + } + + // + // Bring the block to memory + // We assume that this block is always small enough that we can read it in a single shot + // + readbuf = (char *)malloc(block_length); + if(!readbuf) + { + snprintf(error, SCAP_LASTERR_SIZE, "memory allocation error in scap_read_iflist"); + return SCAP_FAILURE; + } + + readsize = r->read(r, readbuf, block_length); + CHECK_READ_SIZE_WITH_FREE_ERR(readbuf, readsize, block_length, error); + + // + // First pass, count the number of addresses + // + pif = readbuf; + totreadsize = 0; + + while(true) + { + toread = (int32_t)block_length - (int32_t)totreadsize; + + if(toread < 4) + { + break; + } + + if(block_type != IL_BLOCK_TYPE_V2) + { + iftype = *(uint16_t *)pif; + ifnamlen = *(uint16_t *)(pif + 2); + + if(iftype == SCAP_II_IPV4) + { + entrysize = sizeof(scap_ifinfo_ipv4) + ifnamlen - SCAP_MAX_PATH_SIZE; + } + else if(iftype == SCAP_II_IPV6) + { + entrysize = sizeof(scap_ifinfo_ipv6) + ifnamlen - SCAP_MAX_PATH_SIZE; + } + else if(iftype == SCAP_II_IPV4_NOLINKSPEED) + { + entrysize = sizeof(scap_ifinfo_ipv4_nolinkspeed) + ifnamlen - SCAP_MAX_PATH_SIZE; + } + else if(iftype == SCAP_II_IPV6_NOLINKSPEED) + { + entrysize = sizeof(scap_ifinfo_ipv6_nolinkspeed) + ifnamlen - SCAP_MAX_PATH_SIZE; + } + else + { + snprintf(error, SCAP_LASTERR_SIZE, "trace file has corrupted interface list(1)"); + ASSERT(false); + res = SCAP_FAILURE; + goto scap_read_iflist_error; + } + } + else + { + entrysize = *(uint32_t *)pif + sizeof(uint32_t); + iftype = *(uint16_t *)(pif + 4); + ifnamlen = *(uint16_t *)(pif + 4 + 2); + } + + if(toread < entrysize) + { + snprintf(error, SCAP_LASTERR_SIZE, "trace file has corrupted interface list(2) toread=%u, entrysize=%u", toread, entrysize); + res = SCAP_FAILURE; + goto scap_read_iflist_error; + } + + pif += entrysize; + totreadsize += entrysize; + + if(iftype == SCAP_II_IPV4 || iftype == SCAP_II_IPV4_NOLINKSPEED) + { + ifcnt4++; + } + else if(iftype == SCAP_II_IPV6 || iftype == SCAP_II_IPV6_NOLINKSPEED) + { + ifcnt6++; + } + else + { + ASSERT(false); + snprintf(error, SCAP_LASTERR_SIZE, "unknown interface type %d", (int)iftype); + res = SCAP_FAILURE; + goto scap_read_iflist_error; + } + } + + // + // Allocate the handle and the arrays + // + (*addrlist_p) = (scap_addrlist *)malloc(sizeof(scap_addrlist)); + if(!(*addrlist_p)) + { + snprintf(error, SCAP_LASTERR_SIZE, "scap_read_iflist allocation failed(1)"); + res = SCAP_FAILURE; + goto scap_read_iflist_error; + } + + (*addrlist_p)->n_v4_addrs = 0; + (*addrlist_p)->n_v6_addrs = 0; + (*addrlist_p)->v4list = NULL; + (*addrlist_p)->v6list = NULL; + (*addrlist_p)->totlen = block_length - (ifcnt4 + ifcnt6) * sizeof(uint32_t); + + if(ifcnt4 != 0) + { + (*addrlist_p)->v4list = (scap_ifinfo_ipv4 *)malloc(ifcnt4 * sizeof(scap_ifinfo_ipv4)); + if(!(*addrlist_p)->v4list) + { + snprintf(error, SCAP_LASTERR_SIZE, "scap_read_iflist allocation failed(2)"); + res = SCAP_FAILURE; + goto scap_read_iflist_error; + } + } + else + { + (*addrlist_p)->v4list = NULL; + } + + if(ifcnt6 != 0) + { + (*addrlist_p)->v6list = (scap_ifinfo_ipv6 *)malloc(ifcnt6 * sizeof(scap_ifinfo_ipv6)); + if(!(*addrlist_p)->v6list) + { + snprintf(error, SCAP_LASTERR_SIZE, "getifaddrs allocation failed(3)"); + res = SCAP_FAILURE; + goto scap_read_iflist_error; + } + } + else + { + (*addrlist_p)->v6list = NULL; + } + + (*addrlist_p)->n_v4_addrs = ifcnt4; + (*addrlist_p)->n_v6_addrs = ifcnt6; + + // + // Second pass: populate the arrays + // + ifcnt4 = 0; + ifcnt6 = 0; + pif = readbuf; + totreadsize = 0; + + while(true) + { + toread = (int32_t)block_length - (int32_t)totreadsize; + entrysize = 0; + + if(toread < 4) + { + break; + } + + if(block_type == IL_BLOCK_TYPE_V2) + { + entrysize = *(uint32_t *)pif; + totreadsize += sizeof(uint32_t); + pif += sizeof(uint32_t); + } + + iftype = *(uint16_t *)pif; + ifnamlen = *(uint16_t *)(pif + 2); + + if(ifnamlen >= SCAP_MAX_PATH_SIZE) + { + snprintf(error, SCAP_LASTERR_SIZE, "trace file has corrupted interface list(0)"); + res = SCAP_FAILURE; + goto scap_read_iflist_error; + } + + // If new parameters are added, entrysize can be used to + // see if they are available in the current capture. + // For example, for a 32bit parameter: + // + // if(entrysize && (ifsize + sizeof(uint32_t)) <= entrysize) + // { + // ifsize += sizeof(uint32_t); + // ... + // } + + uint32_t ifsize; + if(iftype == SCAP_II_IPV4) + { + ifsize = sizeof(uint16_t) + // type + sizeof(uint16_t) + // ifnamelen + sizeof(uint32_t) + // addr + sizeof(uint32_t) + // netmask + sizeof(uint32_t) + // bcast + sizeof(uint64_t) + // linkspeed + ifnamlen; + + if(toread < ifsize) + { + snprintf(error, SCAP_LASTERR_SIZE, "trace file has corrupted interface list(3)"); + res = SCAP_FAILURE; + goto scap_read_iflist_error; + } + + // Copy the entry + memcpy((*addrlist_p)->v4list + ifcnt4, pif, ifsize - ifnamlen); + + memcpy((*addrlist_p)->v4list[ifcnt4].ifname, pif + ifsize - ifnamlen, ifnamlen); + + // Make sure the name string is NULL-terminated + *((char *)((*addrlist_p)->v4list + ifcnt4) + ifsize) = 0; + + ifcnt4++; + } + else if(iftype == SCAP_II_IPV4_NOLINKSPEED) + { + scap_ifinfo_ipv4_nolinkspeed* src; + scap_ifinfo_ipv4* dst; + + ifsize = sizeof(scap_ifinfo_ipv4_nolinkspeed) + ifnamlen - SCAP_MAX_PATH_SIZE; + + if(toread < ifsize) + { + snprintf(error, SCAP_LASTERR_SIZE, "trace file has corrupted interface list(4)"); + res = SCAP_FAILURE; + goto scap_read_iflist_error; + } + + // Copy the entry + src = (scap_ifinfo_ipv4_nolinkspeed*)pif; + dst = (*addrlist_p)->v4list + ifcnt4; + + dst->type = src->type; + dst->ifnamelen = src->ifnamelen; + dst->addr = src->addr; + dst->netmask = src->netmask; + dst->bcast = src->bcast; + dst->linkspeed = 0; + memcpy(dst->ifname, src->ifname, MIN(dst->ifnamelen, SCAP_MAX_PATH_SIZE - 1)); + + // Make sure the name string is NULL-terminated + *((char *)(dst->ifname + MIN(dst->ifnamelen, SCAP_MAX_PATH_SIZE - 1))) = 0; + + ifcnt4++; + } + else if(iftype == SCAP_II_IPV6) + { + ifsize = sizeof(uint16_t) + // type + sizeof(uint16_t) + // ifnamelen + SCAP_IPV6_ADDR_LEN + // addr + SCAP_IPV6_ADDR_LEN + // netmask + SCAP_IPV6_ADDR_LEN + // bcast + sizeof(uint64_t) + // linkspeed + ifnamlen; + + if(toread < ifsize) + { + snprintf(error, SCAP_LASTERR_SIZE, "trace file has corrupted interface list(5)"); + res = SCAP_FAILURE; + goto scap_read_iflist_error; + } + + // Copy the entry + memcpy((*addrlist_p)->v6list + ifcnt6, pif, ifsize - ifnamlen); + + memcpy((*addrlist_p)->v6list[ifcnt6].ifname, pif + ifsize - ifnamlen, ifnamlen); + + // Make sure the name string is NULL-terminated + *((char *)((*addrlist_p)->v6list + ifcnt6) + ifsize) = 0; + + ifcnt6++; + } + else if(iftype == SCAP_II_IPV6_NOLINKSPEED) + { + scap_ifinfo_ipv6_nolinkspeed* src; + scap_ifinfo_ipv6* dst; + ifsize = sizeof(scap_ifinfo_ipv6_nolinkspeed) + ifnamlen - SCAP_MAX_PATH_SIZE; + + if(toread < ifsize) + { + snprintf(error, SCAP_LASTERR_SIZE, "trace file has corrupted interface list(6)"); + res = SCAP_FAILURE; + goto scap_read_iflist_error; + } + + // Copy the entry + src = (scap_ifinfo_ipv6_nolinkspeed*)pif; + dst = (*addrlist_p)->v6list + ifcnt6; + + dst->type = src->type; + dst->ifnamelen = src->ifnamelen; + memcpy(dst->addr, src->addr, SCAP_IPV6_ADDR_LEN); + memcpy(dst->netmask, src->netmask, SCAP_IPV6_ADDR_LEN); + memcpy(dst->bcast, src->bcast, SCAP_IPV6_ADDR_LEN); + dst->linkspeed = 0; + memcpy(dst->ifname, src->ifname, MIN(dst->ifnamelen, SCAP_MAX_PATH_SIZE - 1)); + + // Make sure the name string is NULL-terminated + *((char *)(dst->ifname + MIN(dst->ifnamelen, SCAP_MAX_PATH_SIZE - 1))) = 0; + + ifcnt6++; + } + else + { + ASSERT(false); + snprintf(error, SCAP_LASTERR_SIZE, "unknown interface type %d", (int)iftype); + res = SCAP_FAILURE; + goto scap_read_iflist_error; + } + + entrysize = entrysize ? entrysize : ifsize; + + pif += entrysize; + totreadsize += entrysize; + } + + // + // Release the read storage + // + free(readbuf); + + return res; + +scap_read_iflist_error: + scap_free_iflist((*addrlist_p)); + (*addrlist_p) = NULL; + + if(readbuf) + { + free(readbuf); + } + + return res; +} + +// +// Parse a user list block +// +static int32_t scap_read_userlist(scap_reader_t* r, uint32_t block_length, uint32_t block_type, scap_userlist** userlist_p, char* error) +{ + size_t readsize; + size_t totreadsize = 0; + size_t subreadsize = 0; + size_t padding_len; + uint32_t padding; + uint8_t type; + uint16_t stlen; + uint32_t toread; + int fseekres; + + // + // If the list of users was already allocated for this handle (for example because this is + // not the first interface list block), free it + // + if((*userlist_p) != NULL) + { + scap_free_userlist((*userlist_p)); + (*userlist_p) = NULL; + } + + // + // Allocate and initialize the handle info + // + (*userlist_p) = (scap_userlist*)malloc(sizeof(scap_userlist)); + if((*userlist_p) == NULL) + { + snprintf(error, SCAP_LASTERR_SIZE, "userlist allocation failed(2)"); + return SCAP_FAILURE; + } + + (*userlist_p)->nusers = 0; + (*userlist_p)->ngroups = 0; + (*userlist_p)->totsavelen = 0; + (*userlist_p)->users = NULL; + (*userlist_p)->groups = NULL; + + // + // Import the blocks + // + while(((int32_t)block_length - (int32_t)totreadsize) >= 4) + { + uint32_t sub_len = 0; + if(block_type == UL_BLOCK_TYPE_V2) + { + // + // len + // + readsize = r->read(r, &(sub_len), sizeof(uint32_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint32_t), error); + + subreadsize += readsize; + } + + // + // type + // + readsize = r->read(r, &(type), sizeof(type)); + CHECK_READ_SIZE_ERR(readsize, sizeof(type), error); + + subreadsize += readsize; + + if(type == USERBLOCK_TYPE_USER) + { + scap_userinfo* puser; + + (*userlist_p)->nusers++; + scap_userinfo *new_userlist = (scap_userinfo*)realloc((*userlist_p)->users, (*userlist_p)->nusers * sizeof(scap_userinfo)); + if(new_userlist == NULL) + { + free((*userlist_p)->users); + (*userlist_p)->users = NULL; + snprintf(error, SCAP_LASTERR_SIZE, "memory allocation error in scap_read_userlist(1)"); + return SCAP_FAILURE; + } + (*userlist_p)->users = new_userlist; + + puser = &(*userlist_p)->users[(*userlist_p)->nusers -1]; + + // + // uid + // + readsize = r->read(r, &(puser->uid), sizeof(uint32_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint32_t), error); + + subreadsize += readsize; + + // + // gid + // + readsize = r->read(r, &(puser->gid), sizeof(uint32_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint32_t), error); + + subreadsize += readsize; + + // + // name + // + readsize = r->read(r, &(stlen), sizeof(uint16_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint16_t), error); + + if(stlen >= MAX_CREDENTIALS_STR_LEN) + { + snprintf(error, SCAP_LASTERR_SIZE, "invalid user name len %d", stlen); + return SCAP_FAILURE; + } + + subreadsize += readsize; + + readsize = r->read(r, puser->name, stlen); + CHECK_READ_SIZE_ERR(readsize, stlen, error); + + // the string is not null-terminated on file + puser->name[stlen] = 0; + + subreadsize += readsize; + + // + // homedir + // + readsize = r->read(r, &(stlen), sizeof(uint16_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint16_t), error); + + if(stlen >= MAX_CREDENTIALS_STR_LEN) + { + snprintf(error, SCAP_LASTERR_SIZE, "invalid user homedir len %d", stlen); + return SCAP_FAILURE; + } + + subreadsize += readsize; + + readsize = r->read(r, puser->homedir, stlen); + CHECK_READ_SIZE_ERR(readsize, stlen, error); + + // the string is not null-terminated on file + puser->homedir[stlen] = 0; + + subreadsize += readsize; + + // + // shell + // + readsize = r->read(r, &(stlen), sizeof(uint16_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint16_t), error); + + if(stlen >= MAX_CREDENTIALS_STR_LEN) + { + snprintf(error, SCAP_LASTERR_SIZE, "invalid user shell len %d", stlen); + return SCAP_FAILURE; + } + + subreadsize += readsize; + + readsize = r->read(r, puser->shell, stlen); + CHECK_READ_SIZE_ERR(readsize, stlen, error); + + // the string is not null-terminated on file + puser->shell[stlen] = 0; + + subreadsize += readsize; + + // If new parameters are added, sub_len can be used to + // see if they are available in the current capture. + // For example, for a 32bit parameter: + // + // if(sub_len && (subreadsize + sizeof(uint32_t)) <= sub_len) + // { + // ... + // } + } + else + { + scap_groupinfo* pgroup; + + (*userlist_p)->ngroups++; + scap_groupinfo *new_grouplist = (scap_groupinfo*)realloc((*userlist_p)->groups, (*userlist_p)->ngroups * sizeof(scap_groupinfo)); + if(new_grouplist == NULL) + { + free((*userlist_p)->groups); + (*userlist_p)->groups = NULL; + snprintf(error, SCAP_LASTERR_SIZE, "memory allocation error in scap_read_userlist(2)"); + return SCAP_FAILURE; + } + (*userlist_p)->groups = new_grouplist; + + pgroup = &(*userlist_p)->groups[(*userlist_p)->ngroups -1]; + + // + // gid + // + readsize = r->read(r, &(pgroup->gid), sizeof(uint32_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint32_t), error); + + subreadsize += readsize; + + // + // name + // + readsize = r->read(r, &(stlen), sizeof(uint16_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint16_t), error); + + if(stlen >= MAX_CREDENTIALS_STR_LEN) + { + snprintf(error, SCAP_LASTERR_SIZE, "invalid group name len %d", stlen); + return SCAP_FAILURE; + } + + subreadsize += readsize; + + readsize = r->read(r, pgroup->name, stlen); + CHECK_READ_SIZE_ERR(readsize, stlen, error); + + // the string is not null-terminated on file + pgroup->name[stlen] = 0; + + subreadsize += readsize; + + // If new parameters are added, sub_len can be used to + // see if they are available in the current capture. + // For example, for a 32bit parameter: + // + // if(sub_len && (subreadsize + sizeof(uint32_t)) <= sub_len) + // { + // ... + // } + } + + if(sub_len && subreadsize != sub_len) + { + if(subreadsize > sub_len) + { + snprintf(error, SCAP_LASTERR_SIZE, "corrupted input file. Had read %lu bytes, but userlist entry have length %u.", + subreadsize, sub_len); + return SCAP_FAILURE; + } + toread = sub_len - subreadsize; + fseekres = (int) r->seek(r, (long)toread, SEEK_CUR); + if(fseekres == -1) + { + snprintf(error, SCAP_LASTERR_SIZE, "corrupted input file. Can't skip %u bytes.", + (unsigned int)toread); + return SCAP_FAILURE; + } + subreadsize = sub_len; + } + + totreadsize += subreadsize; + subreadsize = 0; + } + + // + // Read the padding bytes so we properly align to the end of the data + // + if(totreadsize > block_length) + { + ASSERT(false); + snprintf(error, SCAP_LASTERR_SIZE, "scap_read_userlist read more %lu than a block %u", totreadsize, block_length); + return SCAP_FAILURE; + } + padding_len = block_length - totreadsize; + + readsize = r->read(r, &padding, (unsigned int)padding_len); + CHECK_READ_SIZE_ERR(readsize, padding_len, error); + + return SCAP_SUCCESS; +} + +static uint32_t scap_fd_read_prop_from_disk(void *target, size_t expected_size, size_t *nbytes, scap_reader_t *r, char *error) +{ + size_t readsize; + readsize = r->read(r, target, (unsigned int)expected_size); + CHECK_READ_SIZE_ERR(readsize, expected_size, error); + (*nbytes) += readsize; + return SCAP_SUCCESS; +} + +static uint32_t scap_fd_read_fname_from_disk(char *fname, size_t *nbytes, scap_reader_t *r, char *error) +{ + size_t readsize; + uint16_t stlen; + + readsize = r->read(r, &(stlen), sizeof(uint16_t)); + CHECK_READ_SIZE_ERR(readsize, sizeof(uint16_t), error); + + if(stlen >= SCAP_MAX_PATH_SIZE) + { + snprintf(error, SCAP_LASTERR_SIZE, "invalid filename len %" PRId32, stlen); + return SCAP_FAILURE; + } + + (*nbytes) += readsize; + + readsize = r->read(r, fname, stlen); + CHECK_READ_SIZE_ERR(readsize, stlen, error); + + (*nbytes) += stlen; + + // NULL-terminate the string + fname[stlen] = 0; + return SCAP_SUCCESS; +} + +// +// Populate the given fd by reading the info from disk +// Returns the number of read bytes. +// +static uint32_t scap_fd_read_from_disk(scap_fdinfo *fdi, size_t *nbytes, uint32_t block_type, scap_reader_t *r, char *error) +{ + uint8_t type; + uint32_t toread; + int fseekres; + uint32_t sub_len = 0; + uint32_t res = SCAP_SUCCESS; + *nbytes = 0; + + if((block_type == FDL_BLOCK_TYPE_V2 && + scap_fd_read_prop_from_disk(&sub_len, sizeof(uint32_t), nbytes, r, error)) || + scap_fd_read_prop_from_disk(&(fdi->fd), sizeof(fdi->fd), nbytes, r, error) || + scap_fd_read_prop_from_disk(&(fdi->ino), sizeof(fdi->ino), nbytes, r, error) || + scap_fd_read_prop_from_disk(&type, sizeof(uint8_t), nbytes, r, error)) + { + snprintf(error, SCAP_LASTERR_SIZE, "Could not read prop block for fd"); + return SCAP_FAILURE; + } + + // If new parameters are added, sub_len can be used to + // see if they are available in the current capture. + // For example, for a 32bit parameter: + // + // if(sub_len && (*nbytes + sizeof(uint32_t)) <= sub_len) + // { + // ... + // } + + fdi->type = (scap_fd_type)type; + + switch(fdi->type) + { + case SCAP_FD_IPV4_SOCK: + if(r->read(r, &(fdi->info.ipv4info.sip), sizeof(uint32_t)) != sizeof(uint32_t) || + r->read(r, &(fdi->info.ipv4info.dip), sizeof(uint32_t)) != sizeof(uint32_t) || + r->read(r, &(fdi->info.ipv4info.sport), sizeof(uint16_t)) != sizeof(uint16_t) || + r->read(r, &(fdi->info.ipv4info.dport), sizeof(uint16_t)) != sizeof(uint16_t) || + r->read(r, &(fdi->info.ipv4info.l4proto), sizeof(uint8_t)) != sizeof(uint8_t)) + { + snprintf(error, SCAP_LASTERR_SIZE, "error reading the fd info from file (1)"); + return SCAP_FAILURE; + } + + (*nbytes) += (sizeof(uint32_t) + sizeof(uint32_t) + sizeof(uint16_t) + sizeof(uint16_t) + sizeof(uint8_t)); + + break; + case SCAP_FD_IPV4_SERVSOCK: + if(r->read(r, &(fdi->info.ipv4serverinfo.ip), sizeof(uint32_t)) != sizeof(uint32_t) || + r->read(r, &(fdi->info.ipv4serverinfo.port), sizeof(uint16_t)) != sizeof(uint16_t) || + r->read(r, &(fdi->info.ipv4serverinfo.l4proto), sizeof(uint8_t)) != sizeof(uint8_t)) + { + snprintf(error, SCAP_LASTERR_SIZE, "error reading the fd info from file (2)"); + return SCAP_FAILURE; + } + + (*nbytes) += (sizeof(uint32_t) + sizeof(uint16_t) + sizeof(uint8_t)); + break; + case SCAP_FD_IPV6_SOCK: + if(r->read(r, (char *)fdi->info.ipv6info.sip, sizeof(uint32_t) * 4) != sizeof(uint32_t) * 4 || + r->read(r, (char *)fdi->info.ipv6info.dip, sizeof(uint32_t) * 4) != sizeof(uint32_t) * 4 || + r->read(r, &(fdi->info.ipv6info.sport), sizeof(uint16_t)) != sizeof(uint16_t) || + r->read(r, &(fdi->info.ipv6info.dport), sizeof(uint16_t)) != sizeof(uint16_t) || + r->read(r, &(fdi->info.ipv6info.l4proto), sizeof(uint8_t)) != sizeof(uint8_t)) + { + snprintf(error, SCAP_LASTERR_SIZE, "error writing to file (fi3)"); + } + (*nbytes) += (sizeof(uint32_t) * 4 + // sip + sizeof(uint32_t) * 4 + // dip + sizeof(uint16_t) + // sport + sizeof(uint16_t) + // dport + sizeof(uint8_t)); // l4proto + break; + case SCAP_FD_IPV6_SERVSOCK: + if(r->read(r, (char *)fdi->info.ipv6serverinfo.ip, sizeof(uint32_t) * 4) != sizeof(uint32_t) * 4 || + r->read(r, &(fdi->info.ipv6serverinfo.port), sizeof(uint16_t)) != sizeof(uint16_t) || + r->read(r, &(fdi->info.ipv6serverinfo.l4proto), sizeof(uint8_t)) != sizeof(uint8_t)) + { + snprintf(error, SCAP_LASTERR_SIZE, "error writing to file (fi4)"); + } + (*nbytes) += (sizeof(uint32_t) * 4 + // ip + sizeof(uint16_t) + // port + sizeof(uint8_t)); // l4proto + break; + case SCAP_FD_UNIX_SOCK: + if(r->read(r, &(fdi->info.unix_socket_info.source), sizeof(uint64_t)) != sizeof(uint64_t) || + r->read(r, &(fdi->info.unix_socket_info.destination), sizeof(uint64_t)) != sizeof(uint64_t)) + { + snprintf(error, SCAP_LASTERR_SIZE, "error reading the fd info from file (fi5)"); + return SCAP_FAILURE; + } + + (*nbytes) += (sizeof(uint64_t) + sizeof(uint64_t)); + res = scap_fd_read_fname_from_disk(fdi->info.unix_socket_info.fname, nbytes, r, error); + break; + case SCAP_FD_FILE_V2: + if(r->read(r, &(fdi->info.regularinfo.open_flags), sizeof(uint32_t)) != sizeof(uint32_t)) + { + snprintf(error, SCAP_LASTERR_SIZE, "error reading the fd info from file (fi1)"); + return SCAP_FAILURE; + } + + (*nbytes) += sizeof(uint32_t); + res = scap_fd_read_fname_from_disk(fdi->info.regularinfo.fname, nbytes, r, error); + if(!sub_len || (sub_len < *nbytes + sizeof(uint32_t))) + { + break; + } + if(r->read(r, &(fdi->info.regularinfo.dev), sizeof(uint32_t)) != sizeof(uint32_t)) + { + snprintf(error, SCAP_LASTERR_SIZE, "error reading the fd info from file (dev)"); + return SCAP_FAILURE; + } + (*nbytes) += sizeof(uint32_t); + break; + case SCAP_FD_FIFO: + case SCAP_FD_FILE: + case SCAP_FD_DIRECTORY: + case SCAP_FD_UNSUPPORTED: + case SCAP_FD_EVENT: + case SCAP_FD_SIGNALFD: + case SCAP_FD_EVENTPOLL: + case SCAP_FD_INOTIFY: + case SCAP_FD_TIMERFD: + case SCAP_FD_NETLINK: + case SCAP_FD_BPF: + case SCAP_FD_USERFAULTFD: + case SCAP_FD_IOURING: + case SCAP_FD_MEMFD: + case SCAP_FD_PIDFD: + res = scap_fd_read_fname_from_disk(fdi->info.fname, nbytes, r, error); + break; + case SCAP_FD_UNKNOWN: + ASSERT(false); + break; + default: + snprintf(error, SCAP_LASTERR_SIZE, "error reading the fd info from file, wrong fd type %u", (uint32_t)fdi->type); + return SCAP_FAILURE; + } + + if(sub_len && *nbytes != sub_len) + { + if(*nbytes > sub_len) + { + snprintf(error, SCAP_LASTERR_SIZE, "corrupted input file. Had read %zu bytes, but fdlist entry have length %u.", + *nbytes, sub_len); + return SCAP_FAILURE; + } + toread = (uint32_t)(sub_len - *nbytes); + fseekres = (int) r->seek(r, (long)toread, SEEK_CUR); + if(fseekres == -1) + { + snprintf(error, SCAP_LASTERR_SIZE, "corrupted input file. Can't skip %u bytes.", + (unsigned int)toread); + return SCAP_FAILURE; + } + *nbytes = sub_len; + } + + return res; +} + +// +// Parse a process list block +// +static int32_t scap_read_fdlist(scap_reader_t* r, uint32_t block_length, uint32_t block_type, struct scap_proclist* proclist, char* error) +{ + size_t readsize; + size_t totreadsize = 0; + size_t padding_len; + struct scap_threadinfo *tinfo; + scap_fdinfo fdi; + scap_fdinfo *nfdi; + // uint16_t stlen; + uint64_t tid; + int32_t uth_status = SCAP_SUCCESS; + uint32_t padding; + + // + // Read the tid + // + readsize = r->read(r, &tid, sizeof(tid)); + CHECK_READ_SIZE_ERR(readsize, sizeof(tid), error); + totreadsize += readsize; + + if(proclist->m_proc_callback == NULL) + { + // + // Identify the process descriptor + // + HASH_FIND_INT64(proclist->m_proclist, &tid, tinfo); + } + else + { + tinfo = NULL; + } + + while(((int32_t)block_length - (int32_t)totreadsize) >= 4) + { + if(scap_fd_read_from_disk(&fdi, &readsize, block_type, r, error) != SCAP_SUCCESS) + { + return SCAP_FAILURE; + } + totreadsize += readsize; + + // + // Add the entry to the table, or fire the notification callback + // + if(proclist->m_proc_callback == NULL) + { + if(tinfo == NULL) + { + // + // We have the fdinfo but no associated tid, skip it + // + continue; + } + + // + // Parsed successfully. Allocate the new entry and copy the temp one into into it. + // + nfdi = (scap_fdinfo *)malloc(sizeof(scap_fdinfo)); + if(nfdi == NULL) + { + snprintf(error, SCAP_LASTERR_SIZE, "process table allocation error (fd1)"); + return SCAP_FAILURE; + } + + // Structure copy + *nfdi = fdi; + + ASSERT(tinfo != NULL); + + HASH_ADD_INT64(tinfo->fdlist, fd, nfdi); + if(uth_status != SCAP_SUCCESS) + { + free(nfdi); + snprintf(error, SCAP_LASTERR_SIZE, "process table allocation error (fd2)"); + return SCAP_FAILURE; + } + } + else + { + ASSERT(tinfo == NULL); + + proclist->m_proc_callback( + proclist->m_proc_callback_context, tid, NULL, &fdi); + } + } + + // + // Read the padding bytes so we properly align to the end of the data + // + if(totreadsize > block_length) + { + ASSERT(false); + snprintf(error, SCAP_LASTERR_SIZE, "scap_read_fdlist read more %lu than a block %u", totreadsize, block_length); + return SCAP_FAILURE; + } + padding_len = block_length - totreadsize; + + readsize = r->read(r, &padding, (unsigned int)padding_len); + CHECK_READ_SIZE_ERR(readsize, padding_len, error); + + return SCAP_SUCCESS; +} + +static int32_t scap_read_section_header(scap_reader_t* r, char* error) +{ + section_header_block sh; + uint32_t bt; + + // + // Read the section header block + // + if(r->read(r, &sh, sizeof(sh)) != sizeof(sh) || + r->read(r, &bt, sizeof(bt)) != sizeof(bt)) + { + snprintf(error, SCAP_LASTERR_SIZE, "error reading from file (1)"); + return SCAP_FAILURE; + } + + if(sh.byte_order_magic != 0x1a2b3c4d) + { + snprintf(error, SCAP_LASTERR_SIZE, "invalid magic number"); + return SCAP_FAILURE; + } + + if(sh.major_version > CURRENT_MAJOR_VERSION) + { + snprintf(error, SCAP_LASTERR_SIZE, + "cannot correctly parse the capture. Upgrade your version."); + return SCAP_VERSION_MISMATCH; + } + + return SCAP_SUCCESS; +} + +// +// Parse the headers of a trace file and load the tables +// +static int32_t scap_read_init(struct savefile_engine *handle, scap_reader_t* r, scap_machine_info* machine_info_p, struct scap_proclist* proclist_p, scap_addrlist** addrlist_p, scap_userlist** userlist_p, char* error) +{ + block_header bh; + uint32_t bt; + size_t readsize; + size_t toread; + int fseekres; + int32_t rc; + int8_t found_ev = 0; + + // + // Read the section header block + // + if(read_block_header(handle, r, &bh) != sizeof(bh)) + { + snprintf(error, SCAP_LASTERR_SIZE, "error reading from file (1)"); + return SCAP_FAILURE; + } + + if(bh.block_type != SHB_BLOCK_TYPE) + { + snprintf(error, SCAP_LASTERR_SIZE, "invalid block type"); + return SCAP_FAILURE; + } + + if((rc = scap_read_section_header(r, error)) != SCAP_SUCCESS) + { + return rc; + } + + // + // Read the metadata blocks (processes, FDs, etc.) + // + while(true) + { + readsize = read_block_header(handle, r, &bh); + + // + // If we don't find the event block header, + // it means there is no event in the file. + // + if (readsize == 0 && !found_ev) + { + snprintf(error, SCAP_LASTERR_SIZE, "no events in file"); + return SCAP_FAILURE; + } + + CHECK_READ_SIZE_ERR(readsize, sizeof(bh), error); + + switch(bh.block_type) + { + case MI_BLOCK_TYPE: + case MI_BLOCK_TYPE_INT: + + if(scap_read_machine_info( + r, + machine_info_p, + error, + bh.block_total_length - sizeof(block_header) - 4) != SCAP_SUCCESS) + { + return SCAP_FAILURE; + } + break; + case PL_BLOCK_TYPE_V1: + case PL_BLOCK_TYPE_V2: + case PL_BLOCK_TYPE_V3: + case PL_BLOCK_TYPE_V4: + case PL_BLOCK_TYPE_V5: + case PL_BLOCK_TYPE_V6: + case PL_BLOCK_TYPE_V7: + case PL_BLOCK_TYPE_V8: + case PL_BLOCK_TYPE_V9: + case PL_BLOCK_TYPE_V1_INT: + case PL_BLOCK_TYPE_V2_INT: + case PL_BLOCK_TYPE_V3_INT: + + if(scap_read_proclist(r, bh.block_total_length - sizeof(block_header) - 4, bh.block_type, proclist_p, error) != SCAP_SUCCESS) + { + return SCAP_FAILURE; + } + break; + case FDL_BLOCK_TYPE: + case FDL_BLOCK_TYPE_INT: + case FDL_BLOCK_TYPE_V2: + + if(scap_read_fdlist(r, bh.block_total_length - sizeof(block_header) - 4, bh.block_type, proclist_p, error) != SCAP_SUCCESS) + { + return SCAP_FAILURE; + } + break; + case EV_BLOCK_TYPE: + case EV_BLOCK_TYPE_INT: + case EV_BLOCK_TYPE_V2: + case EVF_BLOCK_TYPE: + case EVF_BLOCK_TYPE_V2: + case EV_BLOCK_TYPE_V2_LARGE: + case EVF_BLOCK_TYPE_V2_LARGE: + // + // We're done with the metadata headers. + // + found_ev = 1; + handle->m_use_last_block_header = true; + break; + case IL_BLOCK_TYPE: + case IL_BLOCK_TYPE_INT: + case IL_BLOCK_TYPE_V2: + + if(scap_read_iflist(r, bh.block_total_length - sizeof(block_header) - 4, bh.block_type, addrlist_p, error) != SCAP_SUCCESS) + { + return SCAP_FAILURE; + } + break; + case UL_BLOCK_TYPE: + case UL_BLOCK_TYPE_INT: + case UL_BLOCK_TYPE_V2: + + if(scap_read_userlist(r, bh.block_total_length - sizeof(block_header) - 4, bh.block_type, userlist_p, error) != SCAP_SUCCESS) + { + return SCAP_FAILURE; + } + break; + default: + // + // Unknown block type. Skip the block. + // + toread = bh.block_total_length - sizeof(block_header) - 4; + fseekres = (int) r->seek(r, (long)toread, SEEK_CUR); + if(fseekres == -1) + { + snprintf(error, SCAP_LASTERR_SIZE, "corrupted input file. Can't skip block of type %x and size %u.", + (int)bh.block_type, + (unsigned int)toread); + return SCAP_FAILURE; + } + break; + } + + if(found_ev) + { + break; + } + + // + // Read and validate the trailer + // + readsize = r->read(r, &bt, sizeof(bt)); + CHECK_READ_SIZE_ERR(readsize, sizeof(bt), error); + + if(bt != bh.block_total_length) + { + snprintf(error, SCAP_LASTERR_SIZE, "wrong block total length, header=%u, trailer=%u", + bh.block_total_length, + bt); + return SCAP_FAILURE; + } + } + + // + // NOTE: can't require a user list block, interface list block, or machine info block + // any longer--with the introduction of source plugins, it is legitimate to have + // trace files that don't contain those blocks + // + + return SCAP_SUCCESS; +} + +// +// Read an event from disk +// +static int32_t next(struct scap_engine_handle engine, scap_evt **pevent, uint16_t *pcpuid) +{ + struct savefile_engine* handle = engine.m_handle; + block_header bh; + size_t readsize; + uint32_t readlen; + size_t hdr_len; + scap_reader_t* r = handle->m_reader; + + ASSERT(r != NULL); + + // + // We may have to repeat the whole process + // if the capture contains new syscalls + // + while(true) + { + // + // Read the block header + // + readsize = read_block_header(handle, r, &bh); + + if(readsize != sizeof(bh)) + { + int err_no = 0; +#ifdef _WIN32 + const char* err_str = "read error"; +#else + const char* err_str = r->error(r, &err_no); +#endif + if(err_no) + { + snprintf(handle->m_lasterr, SCAP_LASTERR_SIZE, "error reading file: %s, ernum=%d", err_str, err_no); + return SCAP_FAILURE; + } + + if(readsize == 0) + { + // + // We read exactly 0 bytes. This indicates a correct end of file. + // + return SCAP_EOF; + } + else + { + CHECK_READ_SIZE(readsize, sizeof(bh)); + } + } + + if(bh.block_type != EV_BLOCK_TYPE && + bh.block_type != EV_BLOCK_TYPE_V2 && + bh.block_type != EV_BLOCK_TYPE_V2_LARGE && + bh.block_type != EV_BLOCK_TYPE_INT && + bh.block_type != EVF_BLOCK_TYPE && + bh.block_type != EVF_BLOCK_TYPE_V2 && + bh.block_type != EVF_BLOCK_TYPE_V2_LARGE) + { + snprintf(handle->m_lasterr, SCAP_LASTERR_SIZE, "unexpected block type %u", (uint32_t)bh.block_type); + handle->m_use_last_block_header = true; + return SCAP_UNEXPECTED_BLOCK; + } + + hdr_len = sizeof(struct ppm_evt_hdr); + if(bh.block_type != EV_BLOCK_TYPE_V2 && + bh.block_type != EV_BLOCK_TYPE_V2_LARGE && + bh.block_type != EVF_BLOCK_TYPE_V2 && + bh.block_type != EVF_BLOCK_TYPE_V2_LARGE) + { + hdr_len -= 4; + } + + if(bh.block_total_length < sizeof(bh) + hdr_len + 4) + { + snprintf(handle->m_lasterr, SCAP_LASTERR_SIZE, "block length too short %u", (uint32_t)bh.block_total_length); + return SCAP_FAILURE; + } + + // + // Read the event + // + readlen = bh.block_total_length - sizeof(bh); + // Non-large block types have an uint16_max maximum size + if (bh.block_type != EV_BLOCK_TYPE_V2_LARGE && bh.block_type != EVF_BLOCK_TYPE_V2_LARGE) { + if(readlen > READER_BUF_SIZE) { + snprintf(handle->m_lasterr, SCAP_LASTERR_SIZE, "event block length %u greater than NON-LARGE read buffer size %u", + readlen, + READER_BUF_SIZE); + return SCAP_FAILURE; + } + } else if (readlen > handle->m_reader_evt_buf_size) { + // Try to allocate a buffer large enough + char *tmp = realloc(handle->m_reader_evt_buf, readlen); + if (!tmp) { + free(handle->m_reader_evt_buf); + handle->m_reader_evt_buf = NULL; + snprintf(handle->m_lasterr, SCAP_LASTERR_SIZE, "event block length %u greater than read buffer size %zu", + readlen, + handle->m_reader_evt_buf_size); + return SCAP_FAILURE; + } + handle->m_reader_evt_buf = tmp; + handle->m_reader_evt_buf_size = readlen; + } + + readsize = r->read(r, handle->m_reader_evt_buf, readlen); + CHECK_READ_SIZE(readsize, readlen); + + // + // EVF_BLOCK_TYPE has 32 bits of flags + // + *pcpuid = *(uint16_t *)handle->m_reader_evt_buf; + + if(bh.block_type == EVF_BLOCK_TYPE || bh.block_type == EVF_BLOCK_TYPE_V2 || bh.block_type == EVF_BLOCK_TYPE_V2_LARGE) + { + handle->m_last_evt_dump_flags = *(uint32_t*)(handle->m_reader_evt_buf + sizeof(uint16_t)); + *pevent = (struct ppm_evt_hdr *)(handle->m_reader_evt_buf + sizeof(uint16_t) + sizeof(uint32_t)); + } + else + { + handle->m_last_evt_dump_flags = 0; + *pevent = (struct ppm_evt_hdr *)(handle->m_reader_evt_buf + sizeof(uint16_t)); + } + + if((*pevent)->type >= PPM_EVENT_MAX) + { + // + // We're reading a capture that contains new syscalls. + // We can't do anything else that skips them. + // + continue; + } + + if(bh.block_type != EV_BLOCK_TYPE_V2 && + bh.block_type != EV_BLOCK_TYPE_V2_LARGE && + bh.block_type != EVF_BLOCK_TYPE_V2 && + bh.block_type != EVF_BLOCK_TYPE_V2_LARGE) + { + // + // We're reading an old capture whose events don't have nparams in the header. + // Convert it to the current version. + // + if((readlen + sizeof(uint32_t)) > READER_BUF_SIZE) + { + snprintf(handle->m_lasterr, SCAP_LASTERR_SIZE, "cannot convert v1 event block to v2 (%lu greater than read buffer size %u)", + readlen + sizeof(uint32_t), + READER_BUF_SIZE); + return SCAP_FAILURE; + } + + memmove((char *)*pevent + sizeof(struct ppm_evt_hdr), + (char *)*pevent + sizeof(struct ppm_evt_hdr) - sizeof(uint32_t), + readlen - ((char *)*pevent - handle->m_reader_evt_buf) - (sizeof(struct ppm_evt_hdr) - sizeof(uint32_t))); + (*pevent)->len += sizeof(uint32_t); + + // In old captures, the length of PPME_NOTIFICATION_E and PPME_INFRASTRUCTURE_EVENT_E + // is not correct. Adjust it, otherwise the following code will never find a match + if((*pevent)->type == PPME_NOTIFICATION_E || (*pevent)->type == PPME_INFRASTRUCTURE_EVENT_E) + { + (*pevent)->len -= 3; + } + + // + // The number of parameters needs to be calculated based on the block len. + // Use the current number of parameters as starting point and decrease it + // until size matches. + // + char *end = (char *)*pevent + (*pevent)->len; + uint16_t *lens = (uint16_t *)((char *)*pevent + sizeof(struct ppm_evt_hdr)); + uint32_t nparams; + bool done = false; + for(nparams = g_event_info[(*pevent)->type].nparams; (int)nparams >= 0; nparams--) + { + char *valptr = (char *)lens + nparams * sizeof(uint16_t); + if(valptr > end) + { + continue; + } + uint32_t i; + for(i = 0; i < nparams; i++) + { + valptr += lens[i]; + } + if(valptr < end) + { + snprintf(handle->m_lasterr, SCAP_LASTERR_SIZE, "cannot convert v1 event block to v2 (corrupted trace file - can't calculate nparams)."); + return SCAP_FAILURE; + } + ASSERT(valptr >= end); + if(valptr == end) + { + done = true; + break; + } + } + if(!done) + { + snprintf(handle->m_lasterr, SCAP_LASTERR_SIZE, "cannot convert v1 event block to v2 (corrupted trace file - can't calculate nparams) (2)."); + return SCAP_FAILURE; + } + (*pevent)->nparams = nparams; + } + + break; + } + + return SCAP_SUCCESS; +} + +uint64_t scap_savefile_ftell(struct scap_engine_handle engine) +{ + scap_reader_t* reader = engine.m_handle->m_reader; + return reader->tell(reader); +} + +void scap_savefile_fseek(struct scap_engine_handle engine, uint64_t off) +{ + scap_reader_t* reader = engine.m_handle->m_reader; + reader->seek(reader, off, SEEK_SET); +} + +static int32_t +scap_savefile_init_platform(struct scap_platform *platform, char *lasterr, struct scap_engine_handle engine, + struct scap_open_args *oargs) +{ + return SCAP_SUCCESS; +} + +static int32_t scap_savefile_close_platform(struct scap_platform* platform) +{ + return SCAP_SUCCESS; +} + +static void scap_savefile_free_platform(struct scap_platform* platform) +{ + free(platform); +} + +bool scap_savefile_is_thread_alive(struct scap_platform* platform, int64_t pid, int64_t tid, const char* comm) +{ + return false; +} + +static const struct scap_platform_vtable scap_savefile_platform_vtable = { + .init_platform = scap_savefile_init_platform, + .is_thread_alive = scap_savefile_is_thread_alive, + .close_platform = scap_savefile_close_platform, + .free_platform = scap_savefile_free_platform, +}; + +struct scap_platform* scap_savefile_alloc_platform() +{ + struct scap_savefile_platform* platform = calloc(sizeof(*platform), 1); + + if(platform == NULL) + { + return NULL; + } + + platform->m_generic.m_vtable = &scap_savefile_platform_vtable; + platform->m_generic.m_machine_info.num_cpus = (uint32_t)-1; + + return &platform->m_generic; +} + +static struct savefile_engine* alloc_handle(struct scap* main_handle, char* lasterr_ptr) +{ + struct savefile_engine *engine = calloc(1, sizeof(struct savefile_engine)); + if(engine) + { + engine->m_lasterr = lasterr_ptr; + } + return engine; + +} + +static int32_t init(struct scap* main_handle, struct scap_open_args* oargs) +{ + gzFile gzfile; + int res; + struct savefile_engine *handle = main_handle->m_engine.m_handle; + struct scap_savefile_engine_params* params = oargs->engine_params; + struct scap_platform *platform = main_handle->m_platform; + int fd = params->fd; + const char* fname = params->fname; + uint64_t start_offset = params->start_offset; + uint32_t fbuffer_size = params->fbuffer_size; + + if(fd != 0) + { + gzfile = gzdopen(fd, "rb"); + } + else + { + gzfile = gzopen(fname, "rb"); + } + + if(gzfile == NULL) + { + if(fd != 0) + { + snprintf(main_handle->m_lasterr, SCAP_LASTERR_SIZE, "can't open fd %d", fd); + } + else + { + snprintf(main_handle->m_lasterr, SCAP_LASTERR_SIZE, "can't open file %s", fname); + } + return SCAP_FAILURE; + } + + scap_reader_t* reader = scap_reader_open_gzfile(gzfile); + if(!reader) + { + gzclose(gzfile); + return SCAP_FAILURE; + } + + if (fbuffer_size > 0) + { + scap_reader_t* buffered_reader = scap_reader_open_buffered(reader, fbuffer_size, true); + if(!buffered_reader) + { + reader->close(reader); + return SCAP_FAILURE; + } + reader = buffered_reader; + } + + // + // If this is a merged file, we might have to move the read offset to the next section + // + if(start_offset != 0) + { + scap_fseek(main_handle, start_offset); + } + + handle->m_use_last_block_header = false; + + res = scap_read_init( + handle, + reader, + &platform->m_machine_info, + &platform->m_proclist, + &platform->m_addrlist, + &platform->m_userlist, + main_handle->m_lasterr + ); + + if(res != SCAP_SUCCESS) + { + reader->close(reader); + return res; + } + + handle->m_reader_evt_buf = (char*)malloc(READER_BUF_SIZE); + if(!handle->m_reader_evt_buf) + { + snprintf(main_handle->m_lasterr, SCAP_LASTERR_SIZE, "error allocating the read buffer"); + return SCAP_FAILURE; + } + handle->m_reader_evt_buf_size = READER_BUF_SIZE; + handle->m_reader = reader; + + if(!oargs->import_users) + { + if(platform->m_userlist != NULL) + { + scap_free_userlist(platform->m_userlist); + platform->m_userlist = NULL; + } + } + + return SCAP_SUCCESS; +} + +static void free_handle(struct scap_engine_handle engine) +{ + free(engine.m_handle); +} + +static int32_t scap_savefile_close(struct scap_engine_handle engine) +{ + struct savefile_engine* handle = engine.m_handle; + if (handle->m_reader) + { + handle->m_reader->close(handle->m_reader); + handle->m_reader = NULL; + } + + if(handle->m_reader_evt_buf) + { + free(handle->m_reader_evt_buf); + handle->m_reader_evt_buf = NULL; + } + + return SCAP_SUCCESS; +} + +static int32_t scap_savefile_restart_capture(scap_t* handle) +{ + struct savefile_engine *engine = handle->m_engine.m_handle; + struct scap_platform *platform = handle->m_platform; + int32_t res; + + scap_platform_close(platform); + + if((res = scap_read_init( + engine, + engine->m_reader, + &platform->m_machine_info, + &platform->m_proclist, + &platform->m_addrlist, + &platform->m_userlist, + handle->m_lasterr)) != SCAP_SUCCESS) + { + char error[SCAP_LASTERR_SIZE]; + snprintf(error, SCAP_LASTERR_SIZE, "could not restart capture: %s", scap_getlasterr(handle)); + strlcpy(handle->m_lasterr, error, SCAP_LASTERR_SIZE); + } + return res; +} + +static int64_t get_readfile_offset(struct scap_engine_handle engine) +{ + return engine.m_handle->m_reader->offset(engine.m_handle->m_reader); +} + +static uint32_t get_event_dump_flags(struct scap_engine_handle engine) +{ + return engine.m_handle->m_last_evt_dump_flags; +} + +static struct scap_savefile_vtable savefile_ops = { + .ftell_capture = scap_savefile_ftell, + .fseek_capture = scap_savefile_fseek, + + .restart_capture = scap_savefile_restart_capture, + .get_readfile_offset = get_readfile_offset, + .get_event_dump_flags = get_event_dump_flags, +}; + +struct scap_vtable scap_savefile_engine = { + .name = SAVEFILE_ENGINE, + .mode = SCAP_MODE_CAPTURE, + .savefile_ops = &savefile_ops, + + .alloc_handle = alloc_handle, + .init = init, + .free_handle = free_handle, + .close = scap_savefile_close, + .next = next, + .start_capture = noop_start_capture, + .stop_capture = noop_stop_capture, + .configure = noop_configure, + .get_stats = noop_get_stats, + .get_stats_v2 = noop_get_stats_v2, + .get_n_tracepoint_hit = noop_get_n_tracepoint_hit, + .get_n_devs = noop_get_n_devs, + .get_max_buf_used = noop_get_max_buf_used, + .get_api_version = NULL, + .get_schema_version = NULL, +}; diff --git a/userspace/libscap/engine/source_plugin/plugin_info.h b/userspace/libscap/engine/source_plugin/plugin_info.h index 6a3045710a..3ebbebc4ad 100644 --- a/userspace/libscap/engine/source_plugin/plugin_info.h +++ b/userspace/libscap/engine/source_plugin/plugin_info.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. @@ -34,4 +35,4 @@ typedef struct void (*close)(ss_plugin_t* s, ss_instance_t* h); ss_plugin_rc (*next_batch)(ss_plugin_t* s, ss_instance_t* h, uint32_t *nevts, ss_plugin_event ***evts); const char *(*get_last_error)(ss_plugin_t *s); -} scap_source_plugin; \ No newline at end of file +} scap_source_plugin; diff --git a/userspace/libscap/engine/source_plugin/source_plugin.c b/userspace/libscap/engine/source_plugin/source_plugin.c index f9e393321c..c242ef1f26 100644 --- a/userspace/libscap/engine/source_plugin/source_plugin.c +++ b/userspace/libscap/engine/source_plugin/source_plugin.c @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/engine/source_plugin/source_plugin.h b/userspace/libscap/engine/source_plugin/source_plugin.h index cedb298d5e..47c13262c0 100644 --- a/userspace/libscap/engine/source_plugin/source_plugin.h +++ b/userspace/libscap/engine/source_plugin/source_plugin.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. @@ -50,4 +51,4 @@ struct source_plugin_engine // Stats v2. scap_stats_v2 m_stats[MAX_SOURCE_PLUGIN_COUNTERS_STATS]; -}; \ No newline at end of file +}; diff --git a/userspace/libscap/engine/source_plugin/source_plugin_public.h b/userspace/libscap/engine/source_plugin/source_plugin_public.h index f366837fe2..0e7d0012cc 100644 --- a/userspace/libscap/engine/source_plugin/source_plugin_public.h +++ b/userspace/libscap/engine/source_plugin/source_plugin_public.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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 diff --git a/userspace/libscap/engine/source_plugin/source_plugin_stats.h b/userspace/libscap/engine/source_plugin/source_plugin_stats.h index 97fd8b0a20..852d5797ed 100644 --- a/userspace/libscap/engine/source_plugin/source_plugin_stats.h +++ b/userspace/libscap/engine/source_plugin/source_plugin_stats.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libscap/engine/test_input/scap_test.h b/userspace/libscap/engine/test_input/scap_test.h index 412f3167a3..31ae964c02 100644 --- a/userspace/libscap/engine/test_input/scap_test.h +++ b/userspace/libscap/engine/test_input/scap_test.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/engine/test_input/test_input.c b/userspace/libscap/engine/test_input/test_input.c index 374d67aa83..8177d7d629 100644 --- a/userspace/libscap/engine/test_input/test_input.c +++ b/userspace/libscap/engine/test_input/test_input.c @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/engine/test_input/test_input_platform.c b/userspace/libscap/engine/test_input/test_input_platform.c index 124d8b3627..7062b0ea89 100644 --- a/userspace/libscap/engine/test_input/test_input_platform.c +++ b/userspace/libscap/engine/test_input/test_input_platform.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libscap/engine/test_input/test_input_platform.h b/userspace/libscap/engine/test_input/test_input_platform.h index 37fd906a63..3e82efb9d0 100644 --- a/userspace/libscap/engine/test_input/test_input_platform.h +++ b/userspace/libscap/engine/test_input/test_input_platform.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libscap/engine/test_input/test_input_public.h b/userspace/libscap/engine/test_input/test_input_public.h index e947014308..6e562b8044 100644 --- a/userspace/libscap/engine/test_input/test_input_public.h +++ b/userspace/libscap/engine/test_input/test_input_public.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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 diff --git a/userspace/libscap/engine/udig/udig.h b/userspace/libscap/engine/udig/udig.h index 144820856e..c7f512003e 100644 --- a/userspace/libscap/engine/udig/udig.h +++ b/userspace/libscap/engine/udig/udig.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/engine/udig/udig_public.h b/userspace/libscap/engine/udig/udig_public.h index dc91fe30e6..72a4ead80b 100644 --- a/userspace/libscap/engine/udig/udig_public.h +++ b/userspace/libscap/engine/udig/udig_public.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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 diff --git a/userspace/libscap/engine_handle.h b/userspace/libscap/engine_handle.h index cf5c97fb42..b010150efe 100644 --- a/userspace/libscap/engine_handle.h +++ b/userspace/libscap/engine_handle.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/examples/01-open/scap_open.c b/userspace/libscap/examples/01-open/scap_open.c index d9d65728f6..ec8e104f2f 100644 --- a/userspace/libscap/examples/01-open/scap_open.c +++ b/userspace/libscap/examples/01-open/scap_open.c @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/examples/02-validatebuffer/test.c b/userspace/libscap/examples/02-validatebuffer/test.c index c4fffcff7f..57b06d79b9 100644 --- a/userspace/libscap/examples/02-validatebuffer/test.c +++ b/userspace/libscap/examples/02-validatebuffer/test.c @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/linux/gettimeofday.h b/userspace/libscap/linux/gettimeofday.h index a42e89d5dc..58af1b8064 100644 --- a/userspace/libscap/linux/gettimeofday.h +++ b/userspace/libscap/linux/gettimeofday.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/linux/scap_cgroup.c b/userspace/libscap/linux/scap_cgroup.c index bf3048fe65..a43184ecf2 100644 --- a/userspace/libscap/linux/scap_cgroup.c +++ b/userspace/libscap/linux/scap_cgroup.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libscap/linux/scap_cgroup.h b/userspace/libscap/linux/scap_cgroup.h index a632ec1702..37318f3449 100644 --- a/userspace/libscap/linux/scap_cgroup.h +++ b/userspace/libscap/linux/scap_cgroup.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libscap/linux/scap_fds.c b/userspace/libscap/linux/scap_fds.c index 9113364f29..880f56fd16 100644 --- a/userspace/libscap/linux/scap_fds.c +++ b/userspace/libscap/linux/scap_fds.c @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/linux/scap_iflist.c b/userspace/libscap/linux/scap_iflist.c index 3168454a7b..70f66448a3 100644 --- a/userspace/libscap/linux/scap_iflist.c +++ b/userspace/libscap/linux/scap_iflist.c @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/linux/scap_linux_int.h b/userspace/libscap/linux/scap_linux_int.h index ddd606e6c5..4fc7bec938 100644 --- a/userspace/libscap/linux/scap_linux_int.h +++ b/userspace/libscap/linux/scap_linux_int.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/linux/scap_linux_platform.c b/userspace/libscap/linux/scap_linux_platform.c index e94c2e2cc2..e2ead6f57d 100644 --- a/userspace/libscap/linux/scap_linux_platform.c +++ b/userspace/libscap/linux/scap_linux_platform.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libscap/linux/scap_linux_platform.h b/userspace/libscap/linux/scap_linux_platform.h index 627aa11c9b..c3a42b6c6c 100644 --- a/userspace/libscap/linux/scap_linux_platform.h +++ b/userspace/libscap/linux/scap_linux_platform.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libscap/linux/scap_machine_info.c b/userspace/libscap/linux/scap_machine_info.c index 4e02976303..efa07db817 100644 --- a/userspace/libscap/linux/scap_machine_info.c +++ b/userspace/libscap/linux/scap_machine_info.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libscap/linux/scap_ppm_sc.c b/userspace/libscap/linux/scap_ppm_sc.c index 989bc76d8a..0ac6f8d6a2 100644 --- a/userspace/libscap/linux/scap_ppm_sc.c +++ b/userspace/libscap/linux/scap_ppm_sc.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libscap/linux/scap_procs.c b/userspace/libscap/linux/scap_procs.c index 9abe8028e4..7d8483f160 100644 --- a/userspace/libscap/linux/scap_procs.c +++ b/userspace/libscap/linux/scap_procs.c @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/linux/scap_userlist.c b/userspace/libscap/linux/scap_userlist.c index 8a97f8322a..e52097b7f1 100644 --- a/userspace/libscap/linux/scap_userlist.c +++ b/userspace/libscap/linux/scap_userlist.c @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/linux/sleep.h b/userspace/libscap/linux/sleep.h index 9afcf3dbaf..26578cdd87 100644 --- a/userspace/libscap/linux/sleep.h +++ b/userspace/libscap/linux/sleep.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/linux/unixid.h b/userspace/libscap/linux/unixid.h index d6e69ae5f9..7ea0c19033 100644 --- a/userspace/libscap/linux/unixid.h +++ b/userspace/libscap/linux/unixid.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/macos/gettimeofday.h b/userspace/libscap/macos/gettimeofday.h index a42e89d5dc..58af1b8064 100644 --- a/userspace/libscap/macos/gettimeofday.h +++ b/userspace/libscap/macos/gettimeofday.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/macos/sleep.h b/userspace/libscap/macos/sleep.h index 9afcf3dbaf..26578cdd87 100644 --- a/userspace/libscap/macos/sleep.h +++ b/userspace/libscap/macos/sleep.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/ppm_sc_names.c b/userspace/libscap/ppm_sc_names.c index 1ff65529b4..a4831b8daa 100644 --- a/userspace/libscap/ppm_sc_names.c +++ b/userspace/libscap/ppm_sc_names.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libscap/ringbuffer/devset.h b/userspace/libscap/ringbuffer/devset.h index 1db3c36b92..b7d05c3150 100644 --- a/userspace/libscap/ringbuffer/devset.h +++ b/userspace/libscap/ringbuffer/devset.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/ringbuffer/ringbuffer.c b/userspace/libscap/ringbuffer/ringbuffer.c index bb9698f533..a4c2ee14f0 100644 --- a/userspace/libscap/ringbuffer/ringbuffer.c +++ b/userspace/libscap/ringbuffer/ringbuffer.c @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/ringbuffer/ringbuffer.h b/userspace/libscap/ringbuffer/ringbuffer.h index b6bbabadf0..ff12e2be6e 100644 --- a/userspace/libscap/ringbuffer/ringbuffer.h +++ b/userspace/libscap/ringbuffer/ringbuffer.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/scap-int.h b/userspace/libscap/scap-int.h index cbd5af5f94..3ddfde4698 100644 --- a/userspace/libscap/scap-int.h +++ b/userspace/libscap/scap-int.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/scap.c b/userspace/libscap/scap.c index b2886c7d17..306759ab2f 100644 --- a/userspace/libscap/scap.c +++ b/userspace/libscap/scap.c @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/scap.h b/userspace/libscap/scap.h index 7ef3700c7e..e3b54d8674 100644 --- a/userspace/libscap/scap.h +++ b/userspace/libscap/scap.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/scap_api_version.c b/userspace/libscap/scap_api_version.c index 153b05b565..944c67a657 100644 --- a/userspace/libscap/scap_api_version.c +++ b/userspace/libscap/scap_api_version.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libscap/scap_api_version.h b/userspace/libscap/scap_api_version.h index 1a56830930..dfa17da1f5 100644 --- a/userspace/libscap/scap_api_version.h +++ b/userspace/libscap/scap_api_version.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libscap/scap_assert.h b/userspace/libscap/scap_assert.h index 6edf35b473..7517b21368 100644 --- a/userspace/libscap/scap_assert.h +++ b/userspace/libscap/scap_assert.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/scap_cgroup_set.h b/userspace/libscap/scap_cgroup_set.h index c32a1f7f5f..0b6171981e 100644 --- a/userspace/libscap/scap_cgroup_set.h +++ b/userspace/libscap/scap_cgroup_set.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libscap/scap_const.h b/userspace/libscap/scap_const.h index bdd824494f..dcae7cc630 100644 --- a/userspace/libscap/scap_const.h +++ b/userspace/libscap/scap_const.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/scap_engine_util.c b/userspace/libscap/scap_engine_util.c index e7b8a02bf5..41383df30e 100644 --- a/userspace/libscap/scap_engine_util.c +++ b/userspace/libscap/scap_engine_util.c @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/scap_engine_util.h b/userspace/libscap/scap_engine_util.h index 7e1612cbd3..ca67e7e5d1 100644 --- a/userspace/libscap/scap_engine_util.h +++ b/userspace/libscap/scap_engine_util.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/scap_engines.h b/userspace/libscap/scap_engines.h index ad1cb1f041..861b2ee4b5 100644 --- a/userspace/libscap/scap_engines.h +++ b/userspace/libscap/scap_engines.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/scap_event.c b/userspace/libscap/scap_event.c index 6e8790967d..7e26104d32 100644 --- a/userspace/libscap/scap_event.c +++ b/userspace/libscap/scap_event.c @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/scap_fds.c b/userspace/libscap/scap_fds.c index dc8400fd28..f7b2eb25d8 100644 --- a/userspace/libscap/scap_fds.c +++ b/userspace/libscap/scap_fds.c @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/scap_iflist.c b/userspace/libscap/scap_iflist.c index e7dc01d7c9..b8212e2d57 100644 --- a/userspace/libscap/scap_iflist.c +++ b/userspace/libscap/scap_iflist.c @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/scap_limits.h b/userspace/libscap/scap_limits.h index 6ab8112f94..438398d213 100644 --- a/userspace/libscap/scap_limits.h +++ b/userspace/libscap/scap_limits.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/scap_machine_info.h b/userspace/libscap/scap_machine_info.h index 4827b82cc2..32153f9354 100644 --- a/userspace/libscap/scap_machine_info.h +++ b/userspace/libscap/scap_machine_info.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/scap_open.h b/userspace/libscap/scap_open.h index 09a41c1347..1dd83fd767 100644 --- a/userspace/libscap/scap_open.h +++ b/userspace/libscap/scap_open.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/scap_platform.c b/userspace/libscap/scap_platform.c index de995a0f56..f7270b2004 100644 --- a/userspace/libscap/scap_platform.c +++ b/userspace/libscap/scap_platform.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libscap/scap_platform.h b/userspace/libscap/scap_platform.h index 4947ee1c65..7a6d78f79d 100644 --- a/userspace/libscap/scap_platform.h +++ b/userspace/libscap/scap_platform.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libscap/scap_platform_api.c b/userspace/libscap/scap_platform_api.c index bec594c84c..87cdedbb82 100644 --- a/userspace/libscap/scap_platform_api.c +++ b/userspace/libscap/scap_platform_api.c @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/scap_platform_api.h b/userspace/libscap/scap_platform_api.h index 8e21d2b3c4..49e3fef336 100644 --- a/userspace/libscap/scap_platform_api.h +++ b/userspace/libscap/scap_platform_api.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/scap_platform_impl.h b/userspace/libscap/scap_platform_impl.h index 8ebfd70edc..4abcdfe555 100644 --- a/userspace/libscap/scap_platform_impl.h +++ b/userspace/libscap/scap_platform_impl.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libscap/scap_proc_util.c b/userspace/libscap/scap_proc_util.c index 403cbd50e0..fdd18baac2 100644 --- a/userspace/libscap/scap_proc_util.c +++ b/userspace/libscap/scap_proc_util.c @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/scap_proc_util.h b/userspace/libscap/scap_proc_util.h index 25523a911a..27aab9152f 100644 --- a/userspace/libscap/scap_proc_util.h +++ b/userspace/libscap/scap_proc_util.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/scap_procs.c b/userspace/libscap/scap_procs.c index 4c6462f0e7..eb5cea0033 100644 --- a/userspace/libscap/scap_procs.c +++ b/userspace/libscap/scap_procs.c @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/scap_procs.h b/userspace/libscap/scap_procs.h index 71e3243432..b51d7a657d 100644 --- a/userspace/libscap/scap_procs.h +++ b/userspace/libscap/scap_procs.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/scap_savefile.c b/userspace/libscap/scap_savefile.c index 1424ce2d4e..c8d0d3700b 100644 --- a/userspace/libscap/scap_savefile.c +++ b/userspace/libscap/scap_savefile.c @@ -1,1442 +1,1443 @@ -/* -Copyright (C) 2021 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. - -*/ - - -#include -#include - -#ifndef _WIN32 -#include -#include -#else -struct iovec { - void *iov_base; /* Starting address */ - size_t iov_len; /* Number of bytes to transfer */ -}; -#endif - -#include "scap.h" -#include "scap-int.h" -#include "scap_platform_impl.h" -#include "scap_savefile_api.h" -#include "scap_savefile.h" -#include "strl.h" - -const char* scap_dump_getlasterr(scap_dumper_t* d) -{ - return d ? d->m_lasterr : "null dumper"; -} - -/////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////// -// WRITE FUNCTIONS -/////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////////////// - -// -// Write data into a dump file -// -static int scap_dump_write(scap_dumper_t *d, void* buf, unsigned len) -{ - if(d->m_type == DT_FILE) - { - return gzwrite(d->m_f, buf, len); - } - else - { - if(d->m_targetbufcurpos + len >= d->m_targetbufend) - { - if(d->m_type == DT_MEM) - { - return -1; - } - - // DT_MANAGED_BUF, try to increase the size - size_t targetbufsize = PPM_DUMPER_MANAGED_BUF_RESIZE_FACTOR * (d->m_targetbufend - d->m_targetbuf); - - uint8_t *targetbuf = (uint8_t *)realloc( - d->m_targetbuf, - targetbufsize); - if(targetbuf == NULL) - { - free(d->m_targetbuf); - return -1; - } - - size_t offset = (d->m_targetbufcurpos - d->m_targetbuf); - d->m_targetbuf = targetbuf; - d->m_targetbufcurpos = targetbuf + offset; - d->m_targetbufend = targetbuf + targetbufsize; - } - - memcpy(d->m_targetbufcurpos, buf, len); - - d->m_targetbufcurpos += len; - return len; - } -} - -static int scap_dump_writev(scap_dumper_t *d, const struct iovec *iov, int iovcnt) -{ - unsigned totlen = 0; - int i; - - for (i = 0; i < iovcnt; i++) - { - if(scap_dump_write(d, iov[i].iov_base, iov[i].iov_len) < 0) - { - return -1; - } - - totlen += iov[i].iov_len; - } - - return totlen; -} - -uint8_t* scap_get_memorydumper_curpos(scap_dumper_t *d) -{ - return d->m_targetbufcurpos; -} - -#ifndef _WIN32 -static inline uint32_t scap_normalize_block_len(uint32_t blocklen) -#else -static uint32_t scap_normalize_block_len(uint32_t blocklen) -#endif -{ - return ((blocklen + 3) >> 2) << 2; -} - -static int32_t scap_write_padding(scap_dumper_t *d, uint32_t blocklen) -{ - int32_t val = 0; - uint32_t bytestowrite = scap_normalize_block_len(blocklen) - blocklen; - - if(scap_dump_write(d, &val, bytestowrite) == bytestowrite) - { - return SCAP_SUCCESS; - } - else - { - return SCAP_FAILURE; - } -} - -// -// Calculate the length on disk of an fd entry's info -// -static uint32_t scap_fd_info_len(scap_fdinfo *fdi) -{ - // - // NB: new fields must be appended - // - - uint32_t res = sizeof(uint32_t) + sizeof(fdi->ino) + 1 + sizeof(fdi->fd); - - switch(fdi->type) - { - case SCAP_FD_IPV4_SOCK: - res += 4 + // sip - 4 + // dip - 2 + // sport - 2 + // dport - 1; // l4proto - break; - case SCAP_FD_IPV4_SERVSOCK: - res += 4 + // ip - 2 + // port - 1; // l4proto - break; - case SCAP_FD_IPV6_SOCK: - res += sizeof(uint32_t) * 4 + // sip - sizeof(uint32_t) * 4 + // dip - sizeof(uint16_t) + // sport - sizeof(uint16_t) + // dport - sizeof(uint8_t); // l4proto - break; - case SCAP_FD_IPV6_SERVSOCK: - res += sizeof(uint32_t) * 4 + // ip - sizeof(uint16_t) + // port - sizeof(uint8_t); // l4proto - break; - case SCAP_FD_UNIX_SOCK: - res += - sizeof(uint64_t) + // unix source - sizeof(uint64_t) + // unix destination - (uint32_t)strnlen(fdi->info.unix_socket_info.fname, SCAP_MAX_PATH_SIZE) + 2; - break; - case SCAP_FD_FILE_V2: - res += sizeof(uint32_t) + // open_flags - (uint32_t)strnlen(fdi->info.regularinfo.fname, SCAP_MAX_PATH_SIZE) + 2 + - sizeof(uint32_t); // dev - break; - case SCAP_FD_FIFO: - case SCAP_FD_FILE: - case SCAP_FD_DIRECTORY: - case SCAP_FD_UNSUPPORTED: - case SCAP_FD_EVENT: - case SCAP_FD_SIGNALFD: - case SCAP_FD_EVENTPOLL: - case SCAP_FD_INOTIFY: - case SCAP_FD_TIMERFD: - case SCAP_FD_NETLINK: - case SCAP_FD_BPF: - case SCAP_FD_USERFAULTFD: - case SCAP_FD_IOURING: - case SCAP_FD_MEMFD: - case SCAP_FD_PIDFD: - res += (uint32_t)strnlen(fdi->info.fname, SCAP_MAX_PATH_SIZE) + 2; // 2 is the length field before the string - break; - default: - ASSERT(false); - break; - } - - return res; -} - -// -// Write the given fd info to disk -// -static int32_t scap_fd_write_to_disk(scap_dumper_t *d, scap_fdinfo *fdi, uint32_t len) -{ - - uint8_t type = (uint8_t)fdi->type; - uint16_t stlen; - if(scap_dump_write(d, &(len), sizeof(uint32_t)) != sizeof(uint32_t) || - scap_dump_write(d, &(fdi->fd), sizeof(uint64_t)) != sizeof(uint64_t) || - scap_dump_write(d, &(fdi->ino), sizeof(uint64_t)) != sizeof(uint64_t) || - scap_dump_write(d, &(type), sizeof(uint8_t)) != sizeof(uint8_t)) - { - snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (fi1)"); - return SCAP_FAILURE; - } - - switch(fdi->type) - { - case SCAP_FD_IPV4_SOCK: - if(scap_dump_write(d, &(fdi->info.ipv4info.sip), sizeof(uint32_t)) != sizeof(uint32_t) || - scap_dump_write(d, &(fdi->info.ipv4info.dip), sizeof(uint32_t)) != sizeof(uint32_t) || - scap_dump_write(d, &(fdi->info.ipv4info.sport), sizeof(uint16_t)) != sizeof(uint16_t) || - scap_dump_write(d, &(fdi->info.ipv4info.dport), sizeof(uint16_t)) != sizeof(uint16_t) || - scap_dump_write(d, &(fdi->info.ipv4info.l4proto), sizeof(uint8_t)) != sizeof(uint8_t)) - { - snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (fi2)"); - return SCAP_FAILURE; - } - break; - case SCAP_FD_IPV4_SERVSOCK: - if(scap_dump_write(d, &(fdi->info.ipv4serverinfo.ip), sizeof(uint32_t)) != sizeof(uint32_t) || - scap_dump_write(d, &(fdi->info.ipv4serverinfo.port), sizeof(uint16_t)) != sizeof(uint16_t) || - scap_dump_write(d, &(fdi->info.ipv4serverinfo.l4proto), sizeof(uint8_t)) != sizeof(uint8_t)) - { - snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (fi3)"); - return SCAP_FAILURE; - } - break; - case SCAP_FD_IPV6_SOCK: - if(scap_dump_write(d, (char*)fdi->info.ipv6info.sip, sizeof(uint32_t) * 4) != sizeof(uint32_t) * 4 || - scap_dump_write(d, (char*)fdi->info.ipv6info.dip, sizeof(uint32_t) * 4) != sizeof(uint32_t) * 4 || - scap_dump_write(d, &(fdi->info.ipv6info.sport), sizeof(uint16_t)) != sizeof(uint16_t) || - scap_dump_write(d, &(fdi->info.ipv6info.dport), sizeof(uint16_t)) != sizeof(uint16_t) || - scap_dump_write(d, &(fdi->info.ipv6info.l4proto), sizeof(uint8_t)) != sizeof(uint8_t)) - { - snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (fi7)"); - } - break; - case SCAP_FD_IPV6_SERVSOCK: - if(scap_dump_write(d, &(fdi->info.ipv6serverinfo.ip), sizeof(uint32_t) * 4) != sizeof(uint32_t) * 4 || - scap_dump_write(d, &(fdi->info.ipv6serverinfo.port), sizeof(uint16_t)) != sizeof(uint16_t) || - scap_dump_write(d, &(fdi->info.ipv6serverinfo.l4proto), sizeof(uint8_t)) != sizeof(uint8_t)) - { - snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (fi8)"); - } - break; - case SCAP_FD_UNIX_SOCK: - if(scap_dump_write(d, &(fdi->info.unix_socket_info.source), sizeof(uint64_t)) != sizeof(uint64_t) || - scap_dump_write(d, &(fdi->info.unix_socket_info.destination), sizeof(uint64_t)) != sizeof(uint64_t)) - { - snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (fi4)"); - return SCAP_FAILURE; - } - stlen = (uint16_t)strnlen(fdi->info.unix_socket_info.fname, SCAP_MAX_PATH_SIZE); - if(scap_dump_write(d, &stlen, sizeof(uint16_t)) != sizeof(uint16_t) || - (stlen > 0 && scap_dump_write(d, fdi->info.unix_socket_info.fname, stlen) != stlen)) - { - snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (fi5)"); - return SCAP_FAILURE; - } - break; - case SCAP_FD_FILE_V2: - if(scap_dump_write(d, &(fdi->info.regularinfo.open_flags), sizeof(uint32_t)) != sizeof(uint32_t)) - { - snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (fi1)"); - return SCAP_FAILURE; - } - stlen = (uint16_t)strnlen(fdi->info.regularinfo.fname, SCAP_MAX_PATH_SIZE); - if(scap_dump_write(d, &stlen, sizeof(uint16_t)) != sizeof(uint16_t) || - (stlen > 0 && scap_dump_write(d, fdi->info.regularinfo.fname, stlen) != stlen)) - { - snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (fi1)"); - return SCAP_FAILURE; - } - if(scap_dump_write(d, &(fdi->info.regularinfo.dev), sizeof(uint32_t)) != sizeof(uint32_t)) - { - snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (dev)"); - return SCAP_FAILURE; - } - break; - case SCAP_FD_FIFO: - case SCAP_FD_FILE: - case SCAP_FD_DIRECTORY: - case SCAP_FD_UNSUPPORTED: - case SCAP_FD_EVENT: - case SCAP_FD_SIGNALFD: - case SCAP_FD_EVENTPOLL: - case SCAP_FD_INOTIFY: - case SCAP_FD_TIMERFD: - case SCAP_FD_NETLINK: - case SCAP_FD_BPF: - case SCAP_FD_USERFAULTFD: - case SCAP_FD_IOURING: - case SCAP_FD_MEMFD: - case SCAP_FD_PIDFD: - stlen = (uint16_t)strnlen(fdi->info.fname, SCAP_MAX_PATH_SIZE); - if(scap_dump_write(d, &stlen, sizeof(uint16_t)) != sizeof(uint16_t) || - (stlen > 0 && scap_dump_write(d, fdi->info.fname, stlen) != stlen)) - { - snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (fi6)"); - return SCAP_FAILURE; - } - break; - case SCAP_FD_UNKNOWN: - // Ignore UNKNOWN fds without failing - ASSERT(false); - break; - default: - snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "Unknown fdi type %d", fdi->type); - ASSERT(false); - return SCAP_FAILURE; - } - - return SCAP_SUCCESS; -} - -int32_t scap_write_proc_fds(scap_dumper_t *d, struct scap_threadinfo *tinfo) -{ - block_header bh; - uint32_t bt; - uint32_t totlen = sizeof(tinfo->tid); // This includes the tid - uint32_t idx = 0; - struct scap_fdinfo *fdi; - struct scap_fdinfo *tfdi; - - uint32_t* lengths = calloc(HASH_COUNT(tinfo->fdlist), sizeof(uint32_t)); - if(lengths == NULL) - { - snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "scap_write_proc_fds memory allocation failure"); - return SCAP_FAILURE; - } - - // - // First pass of the table to calculate the lengths - // - HASH_ITER(hh, tinfo->fdlist, fdi, tfdi) - { - if(fdi->type != SCAP_FD_UNINITIALIZED && - fdi->type != SCAP_FD_UNKNOWN) - { - uint32_t fl = scap_fd_info_len(fdi); - lengths[idx++] = fl; - totlen += fl; - } - } - idx = 0; - - // - // Create the block - // - bh.block_type = FDL_BLOCK_TYPE_V2; - bh.block_total_length = scap_normalize_block_len(sizeof(block_header) + totlen + 4); - - if(scap_dump_write(d, &bh, sizeof(bh)) != sizeof(bh)) - { - free(lengths); - snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (fd1)"); - return SCAP_FAILURE; - } - - // - // Write the tid - // - if(scap_dump_write(d, &tinfo->tid, sizeof(tinfo->tid)) != sizeof(tinfo->tid)) - { - free(lengths); - snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (fd2)"); - return SCAP_FAILURE; - } - - // - // Second pass of the table to dump it - // - HASH_ITER(hh, tinfo->fdlist, fdi, tfdi) - { - if(fdi->type != SCAP_FD_UNINITIALIZED && fdi->type != SCAP_FD_UNKNOWN) - { - if(scap_fd_write_to_disk(d, fdi, lengths[idx++]) != SCAP_SUCCESS) - { - free(lengths); - return SCAP_FAILURE; - } - } - } - - free(lengths); - - // - // Add the padding - // - if(scap_write_padding(d, totlen) != SCAP_SUCCESS) - { - snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (fd3)"); - return SCAP_FAILURE; - } - - // - // Create the trailer - // - bt = bh.block_total_length; - if(scap_dump_write(d, &bt, sizeof(bt)) != sizeof(bt)) - { - snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (fd4)"); - return SCAP_FAILURE; - } - - return SCAP_SUCCESS; -} - -// -// Write the fd list blocks -// -static int32_t scap_write_fdlist(scap_dumper_t *d, struct scap_proclist *proclist) -{ - struct scap_threadinfo *tinfo; - struct scap_threadinfo *ttinfo; - int32_t res; - - HASH_ITER(hh, proclist->m_proclist, tinfo, ttinfo) - { - if(!tinfo->filtered_out) - { - res = scap_write_proc_fds(d, tinfo); - if(res != SCAP_SUCCESS) - { - return res; - } - } - } - - return SCAP_SUCCESS; -} - -// -// Since the process list isn't thread-safe, we at least reduce the -// time window and write everything at once with a secondary dumper. -// By doing so, the likelihood of having a wrong total length is lower. -// -scap_dumper_t *scap_write_proclist_begin() -{ - return scap_managedbuf_dump_create(); -} - -// -// Write the process list block -// -static int32_t scap_write_proclist_header(scap_dumper_t *d, uint32_t totlen) -{ - block_header bh; - - // - // Create the block header - // - bh.block_type = PL_BLOCK_TYPE_V9; - bh.block_total_length = scap_normalize_block_len(sizeof(block_header) + totlen + 4); - - if(scap_dump_write(d, &bh, sizeof(bh)) != sizeof(bh)) - { - snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (1)"); - return SCAP_FAILURE; - } - - return SCAP_SUCCESS; -} - -// -// Write the process list block -// -static int32_t scap_write_proclist_trailer(scap_dumper_t *d, uint32_t totlen) -{ - block_header bh; - uint32_t bt; - - bh.block_type = PL_BLOCK_TYPE_V9; - bh.block_total_length = scap_normalize_block_len(sizeof(block_header) + totlen + 4); - - // - // Blocks need to be 4-byte padded - // - if(scap_write_padding(d, totlen) != SCAP_SUCCESS) - { - snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (3)"); - return SCAP_FAILURE; - } - - // - // Create the trailer - // - bt = bh.block_total_length; - if(scap_dump_write(d, &bt, sizeof(bt)) != sizeof(bt)) - { - snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (4)"); - return SCAP_FAILURE; - } - - return SCAP_SUCCESS; -} - -int scap_write_proclist_end(scap_dumper_t *d, scap_dumper_t *proclist_dumper, uint32_t totlen) -{ - ASSERT(proclist_dumper != NULL); - ASSERT(proclist_dumper->m_type == DT_MANAGED_BUF); - - int res = SCAP_SUCCESS; - - do - { - scap_dump_flush(proclist_dumper); - - if(scap_write_proclist_header(d, totlen) != SCAP_SUCCESS) - { - res = SCAP_FAILURE; - break; - } - if(scap_dump_write(d, proclist_dumper->m_targetbuf, totlen) <= 0) - { - res = SCAP_FAILURE; - break; - } - if(scap_write_proclist_trailer(d, totlen) != SCAP_SUCCESS) - { - res = SCAP_FAILURE; - break; - } - } while(false); - - scap_dump_close(proclist_dumper); - - return res; -} - -// -// Write the process list block -// -static int32_t scap_write_proclist_entry(scap_dumper_t *d, struct scap_threadinfo *tinfo, uint32_t *len) -{ - struct iovec args = {tinfo->args, tinfo->args_len}; - struct iovec env = {tinfo->env, tinfo->env_len}; - struct iovec cgroups = {tinfo->cgroups.path, tinfo->cgroups.len}; - - return scap_write_proclist_entry_bufs(d, tinfo, len, - tinfo->comm, - tinfo->exe, - tinfo->exepath, - &args, 1, - &env, 1, - tinfo->cwd, - &cgroups, 1, - tinfo->root); -} - -static uint16_t iov_size(const struct iovec *iov, uint32_t iovcnt) -{ - uint16_t len = 0; - uint32_t i; - - for (i = 0; i < iovcnt; i++) - { - len += iov[i].iov_len; - } - - return len; -} - -int32_t scap_write_proclist_entry_bufs(scap_dumper_t *d, struct scap_threadinfo *tinfo, uint32_t *len, - const char *comm, - const char *exe, - const char *exepath, - const struct iovec *args, int argscnt, - const struct iovec *envs, int envscnt, - const char *cwd, - const struct iovec *cgroups, int cgroupscnt, - const char *root) -{ - uint16_t commlen; - uint16_t exelen; - uint16_t exepathlen; - uint16_t cwdlen; - uint16_t rootlen; - uint16_t argslen; - uint16_t envlen; - uint16_t cgroupslen; - - commlen = (uint16_t)strnlen(comm, SCAP_MAX_PATH_SIZE); - exelen = (uint16_t)strnlen(exe, SCAP_MAX_PATH_SIZE); - exepathlen = (uint16_t)strnlen(exepath, SCAP_MAX_PATH_SIZE); - cwdlen = (uint16_t)strnlen(cwd, SCAP_MAX_PATH_SIZE); - rootlen = (uint16_t)strnlen(root, SCAP_MAX_PATH_SIZE); - - argslen = iov_size(args, argscnt); - envlen = iov_size(envs, envscnt); - cgroupslen = iov_size(cgroups, cgroupscnt); - - // - // NB: new fields must be appended - // - *len = (uint32_t)(sizeof(uint32_t) + // len - sizeof(uint64_t) + // tid - sizeof(uint64_t) + // pid - sizeof(uint64_t) + // ptid - sizeof(uint64_t) + // sid - sizeof(uint64_t) + // vpgid - 2 + commlen + - 2 + exelen + - 2 + exepathlen + - 2 + argslen + - 2 + cwdlen + - sizeof(uint64_t) + // fdlimit - sizeof(uint32_t) + // flags - sizeof(uint32_t) + // uid - sizeof(uint32_t) + // gid - sizeof(uint32_t) + // vmsize_kb - sizeof(uint32_t) + // vmrss_kb - sizeof(uint32_t) + // vmswap_kb - sizeof(uint64_t) + // pfmajor - sizeof(uint64_t) + // pfminor - 2 + envlen + - sizeof(int64_t) + // vtid - sizeof(int64_t) + // vpid - 2 + cgroupslen + - 2 + rootlen + - sizeof(uint64_t) + // pidns_init_start_ts - sizeof(uint32_t) + // tty - sizeof(uint32_t) + // loginuid (auid) - sizeof(uint8_t) + // exe_writable - sizeof(uint64_t) + // cap_inheritable - sizeof(uint64_t) + // cap_permitted - sizeof(uint64_t) + // cap_effective - sizeof(uint8_t) + // exe_upper_layer - sizeof(uint64_t) + // exe_ino - sizeof(uint64_t) + // exe_ino_ctime - sizeof(uint64_t) + // exe_ino_mtime - sizeof(uint8_t)); // exe_from_memfd - - if(scap_dump_write(d, len, sizeof(uint32_t)) != sizeof(uint32_t) || - scap_dump_write(d, &(tinfo->tid), sizeof(uint64_t)) != sizeof(uint64_t) || - scap_dump_write(d, &(tinfo->pid), sizeof(uint64_t)) != sizeof(uint64_t) || - scap_dump_write(d, &(tinfo->ptid), sizeof(uint64_t)) != sizeof(uint64_t) || - scap_dump_write(d, &(tinfo->sid), sizeof(uint64_t)) != sizeof(uint64_t) || - scap_dump_write(d, &(tinfo->vpgid), sizeof(uint64_t)) != sizeof(uint64_t) || - scap_dump_write(d, &commlen, sizeof(uint16_t)) != sizeof(uint16_t) || - scap_dump_write(d, (char *) comm, commlen) != commlen || - scap_dump_write(d, &exelen, sizeof(uint16_t)) != sizeof(uint16_t) || - scap_dump_write(d, (char *) exe, exelen) != exelen || - scap_dump_write(d, &exepathlen, sizeof(uint16_t)) != sizeof(uint16_t) || - scap_dump_write(d, (char *) exepath, exepathlen) != exepathlen || - scap_dump_write(d, &argslen, sizeof(uint16_t)) != sizeof(uint16_t) || - scap_dump_writev(d, args, argscnt) != argslen || - scap_dump_write(d, &cwdlen, sizeof(uint16_t)) != sizeof(uint16_t) || - scap_dump_write(d, (char *) cwd, cwdlen) != cwdlen || - scap_dump_write(d, &(tinfo->fdlimit), sizeof(uint64_t)) != sizeof(uint64_t) || - scap_dump_write(d, &(tinfo->flags), sizeof(uint32_t)) != sizeof(uint32_t) || - scap_dump_write(d, &(tinfo->uid), sizeof(uint32_t)) != sizeof(uint32_t) || - scap_dump_write(d, &(tinfo->gid), sizeof(uint32_t)) != sizeof(uint32_t) || - scap_dump_write(d, &(tinfo->vmsize_kb), sizeof(uint32_t)) != sizeof(uint32_t) || - scap_dump_write(d, &(tinfo->vmrss_kb), sizeof(uint32_t)) != sizeof(uint32_t) || - scap_dump_write(d, &(tinfo->vmswap_kb), sizeof(uint32_t)) != sizeof(uint32_t) || - scap_dump_write(d, &(tinfo->pfmajor), sizeof(uint64_t)) != sizeof(uint64_t) || - scap_dump_write(d, &(tinfo->pfminor), sizeof(uint64_t)) != sizeof(uint64_t) || - scap_dump_write(d, &envlen, sizeof(uint16_t)) != sizeof(uint16_t) || - scap_dump_writev(d, envs, envscnt) != envlen || - scap_dump_write(d, &(tinfo->vtid), sizeof(int64_t)) != sizeof(int64_t) || - scap_dump_write(d, &(tinfo->vpid), sizeof(int64_t)) != sizeof(int64_t) || - scap_dump_write(d, &(cgroupslen), sizeof(uint16_t)) != sizeof(uint16_t) || - scap_dump_writev(d, cgroups, cgroupscnt) != cgroupslen || - scap_dump_write(d, &rootlen, sizeof(uint16_t)) != sizeof(uint16_t) || - scap_dump_write(d, (char *) root, rootlen) != rootlen || - scap_dump_write(d, &(tinfo->pidns_init_start_ts), sizeof(uint64_t)) != sizeof(uint64_t) || - scap_dump_write(d, &(tinfo->tty), sizeof(uint32_t)) != sizeof(uint32_t) || - scap_dump_write(d, &(tinfo->loginuid), sizeof(uint32_t)) != sizeof(uint32_t) || - scap_dump_write(d, &(tinfo->exe_writable), sizeof(uint8_t)) != sizeof(uint8_t) || - scap_dump_write(d, &(tinfo->cap_inheritable), sizeof(uint64_t)) != sizeof(uint64_t) || - scap_dump_write(d, &(tinfo->cap_permitted), sizeof(uint64_t)) != sizeof(uint64_t) || - scap_dump_write(d, &(tinfo->cap_effective), sizeof(uint64_t)) != sizeof(uint64_t) || - scap_dump_write(d, &(tinfo->exe_upper_layer), sizeof(uint8_t)) != sizeof(uint8_t) || - scap_dump_write(d, &(tinfo->exe_ino), sizeof(uint64_t)) != sizeof(uint64_t) || - scap_dump_write(d, &(tinfo->exe_ino_ctime), sizeof(uint64_t)) != sizeof(uint64_t) || - scap_dump_write(d, &(tinfo->exe_ino_mtime), sizeof(uint64_t)) != sizeof(uint64_t) || - scap_dump_write(d, &(tinfo->exe_from_memfd), sizeof(uint8_t)) != sizeof(uint8_t)) - { - snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (2)"); - return SCAP_FAILURE; - } - - return SCAP_SUCCESS; -} - -// -// Write the process list block -// -static int32_t scap_write_proclist(scap_dumper_t *d, struct scap_proclist *proclist) -{ - // - // Exit immediately if the process list is empty - // - if(HASH_COUNT(proclist->m_proclist) == 0) - { - return SCAP_SUCCESS; - } - - scap_dumper_t *proclist_dumper = scap_write_proclist_begin(); - if(proclist_dumper == NULL) - { - return SCAP_FAILURE; - } - - - uint32_t totlen = 0; - struct scap_threadinfo *tinfo; - struct scap_threadinfo *ttinfo; - HASH_ITER(hh, proclist->m_proclist, tinfo, ttinfo) - { - if(tinfo->filtered_out) - { - continue; - } - - uint32_t len = 0; - if(scap_write_proclist_entry(proclist_dumper, tinfo, &len) != SCAP_SUCCESS) - { - scap_dump_close(proclist_dumper); - return SCAP_FAILURE; - } - - totlen += len; - } - - return scap_write_proclist_end(d, proclist_dumper, totlen); -} - -// -// Write the machine info block -// -static int32_t scap_write_machine_info(scap_dumper_t *d, scap_machine_info *machine_info) -{ - block_header bh; - uint32_t bt; - - // - // Write the section header - // - bh.block_type = MI_BLOCK_TYPE; - bh.block_total_length = scap_normalize_block_len(sizeof(block_header) + sizeof(scap_machine_info) + 4); - - bt = bh.block_total_length; - - if(scap_dump_write(d, &bh, sizeof(bh)) != sizeof(bh) || - scap_dump_write(d, machine_info, sizeof(*machine_info)) != sizeof(*machine_info) || - scap_dump_write(d, &bt, sizeof(bt)) != sizeof(bt)) - { - snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (MI1)"); - return SCAP_FAILURE; - } - - return SCAP_SUCCESS; -} - -// -// Write the interface list block -// -static int32_t scap_write_iflist(scap_dumper_t* d, scap_addrlist* addrlist) -{ - block_header bh; - uint32_t bt; - uint32_t entrylen; - uint32_t totlen = 0; - uint32_t j; - - // - // Get the interface list - // - if(addrlist == NULL) - { - // - // This can happen when the event source is a capture that was generated by a plugin, no big deal - // - return SCAP_SUCCESS; - } - - // - // Create the block - // - bh.block_type = IL_BLOCK_TYPE_V2; - bh.block_total_length = scap_normalize_block_len(sizeof(block_header) + (addrlist->n_v4_addrs + addrlist->n_v6_addrs)*sizeof(uint32_t) + - addrlist->totlen + 4); - - if(scap_dump_write(d, &bh, sizeof(bh)) != sizeof(bh)) - { - snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (IF1)"); - return SCAP_FAILURE; - } - - // - // Dump the ipv4 list - // - for(j = 0; j < addrlist->n_v4_addrs; j++) - { - scap_ifinfo_ipv4 *entry = &(addrlist->v4list[j]); - - entrylen = sizeof(scap_ifinfo_ipv4) + entry->ifnamelen - SCAP_MAX_PATH_SIZE; - - if(scap_dump_write(d, &entrylen, sizeof(uint32_t)) != sizeof(uint32_t) || - scap_dump_write(d, &(entry->type), sizeof(uint16_t)) != sizeof(uint16_t) || - scap_dump_write(d, &(entry->ifnamelen), sizeof(uint16_t)) != sizeof(uint16_t) || - scap_dump_write(d, &(entry->addr), sizeof(uint32_t)) != sizeof(uint32_t) || - scap_dump_write(d, &(entry->netmask), sizeof(uint32_t)) != sizeof(uint32_t) || - scap_dump_write(d, &(entry->bcast), sizeof(uint32_t)) != sizeof(uint32_t) || - scap_dump_write(d, &(entry->linkspeed), sizeof(uint64_t)) != sizeof(uint64_t) || - scap_dump_write(d, &(entry->ifname), entry->ifnamelen) != entry->ifnamelen) - { - snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (IF2)"); - return SCAP_FAILURE; - } - - totlen += sizeof(uint32_t) + entrylen; - } - - // - // Dump the ipv6 list - // - for(j = 0; j < addrlist->n_v6_addrs; j++) - { - scap_ifinfo_ipv6 *entry = &(addrlist->v6list[j]); - - entrylen = sizeof(scap_ifinfo_ipv6) + entry->ifnamelen - SCAP_MAX_PATH_SIZE; - - if(scap_dump_write(d, &entrylen, sizeof(uint32_t)) != sizeof(uint32_t) || - scap_dump_write(d, &(entry->type), sizeof(uint16_t)) != sizeof(uint16_t) || - scap_dump_write(d, &(entry->ifnamelen), sizeof(uint16_t)) != sizeof(uint16_t) || - scap_dump_write(d, &(entry->addr), SCAP_IPV6_ADDR_LEN) != SCAP_IPV6_ADDR_LEN || - scap_dump_write(d, &(entry->netmask), SCAP_IPV6_ADDR_LEN) != SCAP_IPV6_ADDR_LEN || - scap_dump_write(d, &(entry->bcast), SCAP_IPV6_ADDR_LEN) != SCAP_IPV6_ADDR_LEN || - scap_dump_write(d, &(entry->linkspeed), sizeof(uint64_t)) != sizeof(uint64_t) || - scap_dump_write(d, &(entry->ifname), entry->ifnamelen) != entry->ifnamelen) - { - snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (IF2)"); - return SCAP_FAILURE; - } - - totlen += sizeof(uint32_t) + entrylen; - } - - // - // Blocks need to be 4-byte padded - // - if(scap_write_padding(d, totlen) != SCAP_SUCCESS) - { - snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (IF3)"); - return SCAP_FAILURE; - } - - // - // Create the trailer - // - bt = bh.block_total_length; - if(scap_dump_write(d, &bt, sizeof(bt)) != sizeof(bt)) - { - snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (IF4)"); - return SCAP_FAILURE; - } - - return SCAP_SUCCESS; -} - -// -// Write the user list block -// -static int32_t scap_write_userlist(scap_dumper_t* d, struct scap_userlist *userlist) -{ - block_header bh; - uint32_t bt; - uint32_t j; - uint16_t namelen; - uint16_t homedirlen; - uint16_t shelllen; - uint8_t type; - uint32_t totlen = 0; - - // - // Make sure we have a user list interface list - // - if(userlist == NULL) - { - // - // This can happen when the event source is a capture that was generated by a plugin, no big deal - // - return SCAP_SUCCESS; - } - - uint32_t* lengths = calloc(userlist->nusers + userlist->ngroups, sizeof(uint32_t)); - if(lengths == NULL) - { - snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "scap_write_userlist memory allocation failure (1)"); - return SCAP_FAILURE; - } - - // - // Calculate the lengths - // - for(j = 0; j < userlist->nusers; j++) - { - scap_userinfo* info = &userlist->users[j]; - - namelen = (uint16_t)strnlen(info->name, MAX_CREDENTIALS_STR_LEN); - homedirlen = (uint16_t)strnlen(info->homedir, SCAP_MAX_PATH_SIZE); - shelllen = (uint16_t)strnlen(info->shell, SCAP_MAX_PATH_SIZE); - - // NB: new fields must be appended - size_t ul = sizeof(uint32_t) + sizeof(type) + sizeof(info->uid) + sizeof(info->gid) + sizeof(uint16_t) + - namelen + sizeof(uint16_t) + homedirlen + sizeof(uint16_t) + shelllen; - totlen += ul; - lengths[j] = ul; - } - - for(j = 0; j < userlist->ngroups; j++) - { - scap_groupinfo* info = &userlist->groups[j]; - - namelen = (uint16_t)strnlen(info->name, MAX_CREDENTIALS_STR_LEN); - - // NB: new fields must be appended - uint32_t gl = sizeof(uint32_t) + sizeof(type) + sizeof(info->gid) + sizeof(uint16_t) + namelen; - totlen += gl; - lengths[userlist->nusers + j] = gl; - } - - // - // Create the block - // - bh.block_type = UL_BLOCK_TYPE_V2; - bh.block_total_length = scap_normalize_block_len(sizeof(block_header) + totlen + 4); - - if(scap_dump_write(d, &bh, sizeof(bh)) != sizeof(bh)) - { - free(lengths); - snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (IF1)"); - return SCAP_FAILURE; - } - - // - // Dump the users - // - type = USERBLOCK_TYPE_USER; - for(j = 0; j < userlist->nusers; j++) - { - scap_userinfo* info = &userlist->users[j]; - - namelen = (uint16_t)strnlen(info->name, MAX_CREDENTIALS_STR_LEN); - homedirlen = (uint16_t)strnlen(info->homedir, SCAP_MAX_PATH_SIZE); - shelllen = (uint16_t)strnlen(info->shell, SCAP_MAX_PATH_SIZE); - - if(scap_dump_write(d, &(lengths[j]), sizeof(uint32_t)) != sizeof(uint32_t) || - scap_dump_write(d, &(type), sizeof(type)) != sizeof(type) || - scap_dump_write(d, &(info->uid), sizeof(info->uid)) != sizeof(info->uid) || - scap_dump_write(d, &(info->gid), sizeof(info->gid)) != sizeof(info->gid) || - scap_dump_write(d, &namelen, sizeof(uint16_t)) != sizeof(uint16_t) || - scap_dump_write(d, info->name, namelen) != namelen || - scap_dump_write(d, &homedirlen, sizeof(uint16_t)) != sizeof(uint16_t) || - scap_dump_write(d, info->homedir, homedirlen) != homedirlen || - scap_dump_write(d, &shelllen, sizeof(uint16_t)) != sizeof(uint16_t) || - scap_dump_write(d, info->shell, shelllen) != shelllen) - { - free(lengths); - snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (U1)"); - return SCAP_FAILURE; - } - } - - // - // Dump the groups - // - type = USERBLOCK_TYPE_GROUP; - for(j = 0; j < userlist->ngroups; j++) - { - scap_groupinfo* info = &userlist->groups[j]; - - namelen = (uint16_t)strnlen(info->name, MAX_CREDENTIALS_STR_LEN); - - if(scap_dump_write(d, &(lengths[userlist->nusers + j]), sizeof(uint32_t)) != sizeof(uint32_t) || - scap_dump_write(d, &(type), sizeof(type)) != sizeof(type) || - scap_dump_write(d, &(info->gid), sizeof(info->gid)) != sizeof(info->gid) || - scap_dump_write(d, &namelen, sizeof(uint16_t)) != sizeof(uint16_t) || - scap_dump_write(d, info->name, namelen) != namelen) - { - free(lengths); - snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (U2)"); - return SCAP_FAILURE; - } - } - - free(lengths); - - // - // Blocks need to be 4-byte padded - // - if(scap_write_padding(d, totlen) != SCAP_SUCCESS) - { - snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (IF3)"); - return SCAP_FAILURE; - } - - // - // Create the trailer - // - bt = bh.block_total_length; - if(scap_dump_write(d, &bt, sizeof(bt)) != sizeof(bt)) - { - snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (IF4)"); - return SCAP_FAILURE; - } - - return SCAP_SUCCESS; -} - -// -// Create the dump file headers and add the tables -// -static int32_t scap_setup_dump(scap_dumper_t* d, struct scap_platform *platform, const char *fname) -{ - block_header bh; - section_header_block sh; - uint32_t bt; - - // - // Write the section header - // - bh.block_type = SHB_BLOCK_TYPE; - bh.block_total_length = sizeof(block_header) + sizeof(section_header_block) + 4; - - sh.byte_order_magic = SHB_MAGIC; - sh.major_version = CURRENT_MAJOR_VERSION; - sh.minor_version = CURRENT_MINOR_VERSION; - sh.section_length = 0xffffffffffffffffLL; - - bt = bh.block_total_length; - - if(scap_dump_write(d, &bh, sizeof(bh)) != sizeof(bh) || - scap_dump_write(d, &sh, sizeof(sh)) != sizeof(sh) || - scap_dump_write(d, &bt, sizeof(bt)) != sizeof(bt)) - { - snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file %s (5)", fname); - return SCAP_FAILURE; - } - - if(platform) - { - // - // Write the machine info - // - if(scap_write_machine_info(d, &platform->m_machine_info) != SCAP_SUCCESS) - { - return SCAP_FAILURE; - } - - // - // Write the interface list - // - if(scap_write_iflist(d, platform->m_addrlist) != SCAP_SUCCESS) - { - return SCAP_FAILURE; - } - - // - // Write the user list - // - if(scap_write_userlist(d, platform->m_userlist) != SCAP_SUCCESS) - { - return SCAP_FAILURE; - } - - // - // Write the process list - // - if(scap_write_proclist(d, &platform->m_proclist) != SCAP_SUCCESS) - { - return SCAP_FAILURE; - } - - // - // Write the fd lists - // - if(scap_write_fdlist(d, &platform->m_proclist) != SCAP_SUCCESS) - { - return SCAP_FAILURE; - } - } - - // - // Done, return the file - // - return SCAP_SUCCESS; -} - -static inline int32_t scap_dump_rescan_proc(struct scap_platform* platform) -{ - int32_t ret = SCAP_SUCCESS; -#ifdef __linux__ - if(platform && platform->m_vtable && platform->m_vtable->refresh_proc_table) - { - proc_entry_callback tcb = platform->m_proclist.m_proc_callback; - platform->m_proclist.m_proc_callback = NULL; - ret = platform->m_vtable->refresh_proc_table(platform, &platform->m_proclist); - platform->m_proclist.m_proc_callback = tcb; - } -#endif - return ret; -} - -// fname is only used for log messages in scap_setup_dump -static scap_dumper_t *scap_dump_open_gzfile(struct scap_platform* platform, gzFile gzfile, const char *fname, char* lasterr) -{ - scap_dumper_t* res = (scap_dumper_t*)malloc(sizeof(scap_dumper_t)); - res->m_f = gzfile; - res->m_type = DT_FILE; - res->m_targetbuf = NULL; - res->m_targetbufcurpos = NULL; - res->m_targetbufend = NULL; - - if(scap_setup_dump(res, platform, fname) != SCAP_SUCCESS) - { - strlcpy(lasterr, res->m_lasterr, SCAP_LASTERR_SIZE); - free(res); - res = NULL; - } - - return res; -} - -// -// Open a "savefile" for writing. -// -scap_dumper_t *scap_dump_open(struct scap_platform* platform, const char *fname, compression_mode compress, bool skip_proc_scan, char* lasterr) -{ - gzFile f = NULL; - int fd = -1; - const char* mode; - scap_dumper_t* res; - - switch(compress) - { - case SCAP_COMPRESSION_GZIP: - mode = "wb"; - break; - case SCAP_COMPRESSION_NONE: - mode = "wbT"; - break; - default: - ASSERT(false); - snprintf(lasterr, SCAP_LASTERR_SIZE, "invalid compression mode"); - return NULL; - } - - if(fname[0] == '-' && fname[1] == '\0') - { -#ifndef _WIN32 - fd = dup(STDOUT_FILENO); -#else - fd = 1; -#endif - if(fd != -1) - { - f = gzdopen(fd, mode); - fname = "standard output"; - } - } - else - { - f = gzopen(fname, mode); - } - - if(f == NULL) - { -#ifndef _WIN32 - if(fd != -1) - { - close(fd); - } -#endif - - snprintf(lasterr, SCAP_LASTERR_SIZE, "can't open %s", fname); - return NULL; - } - - // - // If we're dumping in live mode, refresh the process tables list - // so we don't lose information about processes created in the interval - // between opening the handle and starting the dump - // - if(!skip_proc_scan) - { - if(scap_dump_rescan_proc(platform) != SCAP_SUCCESS) - { - return NULL; - } - } - - res = scap_dump_open_gzfile(platform, f, fname, lasterr); - // - // If the user doesn't need the thread table, free it - // - if(platform->m_proclist.m_proc_callback != NULL) - { - scap_proc_free_table(&platform->m_proclist); - } - - return res; -} - -// -// Open a savefile for writing, using the provided fd -scap_dumper_t* scap_dump_open_fd(struct scap_platform* platform, int fd, compression_mode compress, bool skip_proc_scan, char* lasterr) -{ - gzFile f = NULL; - scap_dumper_t* res; - - switch(compress) - { - case SCAP_COMPRESSION_GZIP: - f = gzdopen(fd, "wb"); - break; - case SCAP_COMPRESSION_NONE: - f = gzdopen(fd, "wbT"); - break; - default: - ASSERT(false); - snprintf(lasterr, SCAP_LASTERR_SIZE, "invalid compression mode"); - return NULL; - } - - if(f == NULL) - { - snprintf(lasterr, SCAP_LASTERR_SIZE, "can't open fd %d", fd); - return NULL; - } - - // - // If we're dumping in live mode, refresh the process tables list - // so we don't lose information about processes created in the interval - // between opening the handle and starting the dump - // - if(!skip_proc_scan) - { - if(scap_dump_rescan_proc(platform) != SCAP_SUCCESS) - { - return NULL; - } - } - - res = scap_dump_open_gzfile(platform, f, "", lasterr); - - // - // If the user doesn't need the thread table, free it - // - if(platform->m_proclist.m_proc_callback != NULL) - { - scap_proc_free_table(&platform->m_proclist); - } - return res; -} - -// -// Open a memory "savefile" -// -scap_dumper_t *scap_memory_dump_open(struct scap_platform* platform, uint8_t* targetbuf, uint64_t targetbufsize, char* lasterr) -{ - scap_dumper_t* res = (scap_dumper_t*)malloc(sizeof(scap_dumper_t)); - if(res == NULL) - { - snprintf(lasterr, SCAP_LASTERR_SIZE, "scap_dump_memory_open memory allocation failure (1)"); - return NULL; - } - - res->m_f = NULL; - res->m_type = DT_MEM; - res->m_targetbuf = targetbuf; - res->m_targetbufcurpos = targetbuf; - res->m_targetbufend = targetbuf + targetbufsize; - - if(scap_setup_dump(res, platform, "") != SCAP_SUCCESS) - { - strlcpy(lasterr, res->m_lasterr, SCAP_LASTERR_SIZE); - free(res); - res = NULL; - } - - return res; -} - -// -// Create a dumper with an internally managed buffer -// -scap_dumper_t *scap_managedbuf_dump_create() -{ - scap_dumper_t *res = (scap_dumper_t *)malloc(sizeof(scap_dumper_t)); - if(res == NULL) - { - return NULL; - } - - res->m_f = NULL; - res->m_type = DT_MANAGED_BUF; - res->m_targetbuf = (uint8_t *)malloc(PPM_DUMPER_MANAGED_BUF_SIZE); - res->m_targetbufcurpos = res->m_targetbuf; - res->m_targetbufend = res->m_targetbuf + PPM_DUMPER_MANAGED_BUF_SIZE; - - return res; -} - -// -// Close a "savefile" opened with scap_dump_open -// -void scap_dump_close(scap_dumper_t *d) -{ - if(d->m_type == DT_FILE) - { - gzclose(d->m_f); - } - else if (d->m_type == DT_MANAGED_BUF) - { - free(d->m_targetbuf); - } - - free(d); -} - -// -// Return the current size of a tracefile -// -int64_t scap_dump_get_offset(scap_dumper_t *d) -{ - if(d->m_type == DT_FILE) - { - return gzoffset(d->m_f); - } - else - { - return (int64_t)d->m_targetbufcurpos - (int64_t)d->m_targetbuf; - } -} - -int64_t scap_dump_ftell(scap_dumper_t *d) -{ - if(d->m_type == DT_FILE) - { - return gztell(d->m_f); - } - else - { - return (int64_t)d->m_targetbufcurpos - (int64_t)d->m_targetbuf; - } -} - -void scap_dump_flush(scap_dumper_t *d) -{ - if(d->m_type == DT_FILE) - { - gzflush(d->m_f, Z_FULL_FLUSH); - } -} - -// -// Write an event to a dump file -// -int32_t scap_dump(scap_dumper_t *d, scap_evt *e, uint16_t cpuid, uint32_t flags) -{ - block_header bh; - uint32_t bt; - bool large_payload = flags & SCAP_DF_LARGE; - - flags &= ~SCAP_DF_LARGE; - if(flags == 0) - { - // - // Write the section header - // - bh.block_type = large_payload ? EV_BLOCK_TYPE_V2_LARGE : EV_BLOCK_TYPE_V2; - bh.block_total_length = scap_normalize_block_len(sizeof(block_header) + sizeof(cpuid) + e->len + 4); - bt = bh.block_total_length; - - if(scap_dump_write(d, &bh, sizeof(bh)) != sizeof(bh) || - scap_dump_write(d, &cpuid, sizeof(cpuid)) != sizeof(cpuid) || - scap_dump_write(d, e, e->len) != e->len || - scap_write_padding(d, sizeof(cpuid) + e->len) != SCAP_SUCCESS || - scap_dump_write(d, &bt, sizeof(bt)) != sizeof(bt)) - { - snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (6)"); - return SCAP_FAILURE; - } - } - else - { - // - // Write the section header - // - bh.block_type = large_payload ? EVF_BLOCK_TYPE_V2_LARGE : EVF_BLOCK_TYPE_V2; - bh.block_total_length = scap_normalize_block_len(sizeof(block_header) + sizeof(cpuid) + sizeof(flags) + e->len + 4); - bt = bh.block_total_length; - - if(scap_dump_write(d, &bh, sizeof(bh)) != sizeof(bh) || - scap_dump_write(d, &cpuid, sizeof(cpuid)) != sizeof(cpuid) || - scap_dump_write(d, &flags, sizeof(flags)) != sizeof(flags) || - scap_dump_write(d, e, e->len) != e->len || - scap_write_padding(d, sizeof(cpuid) + e->len) != SCAP_SUCCESS || - scap_dump_write(d, &bt, sizeof(bt)) != sizeof(bt)) - { - snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (7)"); - return SCAP_FAILURE; - } - } - - // - // Enable this to make sure that everything is saved to disk during the tests - // -#if 0 - fflush(f); -#endif - - return SCAP_SUCCESS; -} +// SPDX-License-Identifier: Apache-2.0 +/* +Copyright (C) 2023 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. + +*/ + + +#include +#include + +#ifndef _WIN32 +#include +#include +#else +struct iovec { + void *iov_base; /* Starting address */ + size_t iov_len; /* Number of bytes to transfer */ +}; +#endif + +#include "scap.h" +#include "scap-int.h" +#include "scap_platform_impl.h" +#include "scap_savefile_api.h" +#include "scap_savefile.h" +#include "strl.h" + +const char* scap_dump_getlasterr(scap_dumper_t* d) +{ + return d ? d->m_lasterr : "null dumper"; +} + +/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// +// WRITE FUNCTIONS +/////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// + +// +// Write data into a dump file +// +static int scap_dump_write(scap_dumper_t *d, void* buf, unsigned len) +{ + if(d->m_type == DT_FILE) + { + return gzwrite(d->m_f, buf, len); + } + else + { + if(d->m_targetbufcurpos + len >= d->m_targetbufend) + { + if(d->m_type == DT_MEM) + { + return -1; + } + + // DT_MANAGED_BUF, try to increase the size + size_t targetbufsize = PPM_DUMPER_MANAGED_BUF_RESIZE_FACTOR * (d->m_targetbufend - d->m_targetbuf); + + uint8_t *targetbuf = (uint8_t *)realloc( + d->m_targetbuf, + targetbufsize); + if(targetbuf == NULL) + { + free(d->m_targetbuf); + return -1; + } + + size_t offset = (d->m_targetbufcurpos - d->m_targetbuf); + d->m_targetbuf = targetbuf; + d->m_targetbufcurpos = targetbuf + offset; + d->m_targetbufend = targetbuf + targetbufsize; + } + + memcpy(d->m_targetbufcurpos, buf, len); + + d->m_targetbufcurpos += len; + return len; + } +} + +static int scap_dump_writev(scap_dumper_t *d, const struct iovec *iov, int iovcnt) +{ + unsigned totlen = 0; + int i; + + for (i = 0; i < iovcnt; i++) + { + if(scap_dump_write(d, iov[i].iov_base, iov[i].iov_len) < 0) + { + return -1; + } + + totlen += iov[i].iov_len; + } + + return totlen; +} + +uint8_t* scap_get_memorydumper_curpos(scap_dumper_t *d) +{ + return d->m_targetbufcurpos; +} + +#ifndef _WIN32 +static inline uint32_t scap_normalize_block_len(uint32_t blocklen) +#else +static uint32_t scap_normalize_block_len(uint32_t blocklen) +#endif +{ + return ((blocklen + 3) >> 2) << 2; +} + +static int32_t scap_write_padding(scap_dumper_t *d, uint32_t blocklen) +{ + int32_t val = 0; + uint32_t bytestowrite = scap_normalize_block_len(blocklen) - blocklen; + + if(scap_dump_write(d, &val, bytestowrite) == bytestowrite) + { + return SCAP_SUCCESS; + } + else + { + return SCAP_FAILURE; + } +} + +// +// Calculate the length on disk of an fd entry's info +// +static uint32_t scap_fd_info_len(scap_fdinfo *fdi) +{ + // + // NB: new fields must be appended + // + + uint32_t res = sizeof(uint32_t) + sizeof(fdi->ino) + 1 + sizeof(fdi->fd); + + switch(fdi->type) + { + case SCAP_FD_IPV4_SOCK: + res += 4 + // sip + 4 + // dip + 2 + // sport + 2 + // dport + 1; // l4proto + break; + case SCAP_FD_IPV4_SERVSOCK: + res += 4 + // ip + 2 + // port + 1; // l4proto + break; + case SCAP_FD_IPV6_SOCK: + res += sizeof(uint32_t) * 4 + // sip + sizeof(uint32_t) * 4 + // dip + sizeof(uint16_t) + // sport + sizeof(uint16_t) + // dport + sizeof(uint8_t); // l4proto + break; + case SCAP_FD_IPV6_SERVSOCK: + res += sizeof(uint32_t) * 4 + // ip + sizeof(uint16_t) + // port + sizeof(uint8_t); // l4proto + break; + case SCAP_FD_UNIX_SOCK: + res += + sizeof(uint64_t) + // unix source + sizeof(uint64_t) + // unix destination + (uint32_t)strnlen(fdi->info.unix_socket_info.fname, SCAP_MAX_PATH_SIZE) + 2; + break; + case SCAP_FD_FILE_V2: + res += sizeof(uint32_t) + // open_flags + (uint32_t)strnlen(fdi->info.regularinfo.fname, SCAP_MAX_PATH_SIZE) + 2 + + sizeof(uint32_t); // dev + break; + case SCAP_FD_FIFO: + case SCAP_FD_FILE: + case SCAP_FD_DIRECTORY: + case SCAP_FD_UNSUPPORTED: + case SCAP_FD_EVENT: + case SCAP_FD_SIGNALFD: + case SCAP_FD_EVENTPOLL: + case SCAP_FD_INOTIFY: + case SCAP_FD_TIMERFD: + case SCAP_FD_NETLINK: + case SCAP_FD_BPF: + case SCAP_FD_USERFAULTFD: + case SCAP_FD_IOURING: + case SCAP_FD_MEMFD: + case SCAP_FD_PIDFD: + res += (uint32_t)strnlen(fdi->info.fname, SCAP_MAX_PATH_SIZE) + 2; // 2 is the length field before the string + break; + default: + ASSERT(false); + break; + } + + return res; +} + +// +// Write the given fd info to disk +// +static int32_t scap_fd_write_to_disk(scap_dumper_t *d, scap_fdinfo *fdi, uint32_t len) +{ + + uint8_t type = (uint8_t)fdi->type; + uint16_t stlen; + if(scap_dump_write(d, &(len), sizeof(uint32_t)) != sizeof(uint32_t) || + scap_dump_write(d, &(fdi->fd), sizeof(uint64_t)) != sizeof(uint64_t) || + scap_dump_write(d, &(fdi->ino), sizeof(uint64_t)) != sizeof(uint64_t) || + scap_dump_write(d, &(type), sizeof(uint8_t)) != sizeof(uint8_t)) + { + snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (fi1)"); + return SCAP_FAILURE; + } + + switch(fdi->type) + { + case SCAP_FD_IPV4_SOCK: + if(scap_dump_write(d, &(fdi->info.ipv4info.sip), sizeof(uint32_t)) != sizeof(uint32_t) || + scap_dump_write(d, &(fdi->info.ipv4info.dip), sizeof(uint32_t)) != sizeof(uint32_t) || + scap_dump_write(d, &(fdi->info.ipv4info.sport), sizeof(uint16_t)) != sizeof(uint16_t) || + scap_dump_write(d, &(fdi->info.ipv4info.dport), sizeof(uint16_t)) != sizeof(uint16_t) || + scap_dump_write(d, &(fdi->info.ipv4info.l4proto), sizeof(uint8_t)) != sizeof(uint8_t)) + { + snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (fi2)"); + return SCAP_FAILURE; + } + break; + case SCAP_FD_IPV4_SERVSOCK: + if(scap_dump_write(d, &(fdi->info.ipv4serverinfo.ip), sizeof(uint32_t)) != sizeof(uint32_t) || + scap_dump_write(d, &(fdi->info.ipv4serverinfo.port), sizeof(uint16_t)) != sizeof(uint16_t) || + scap_dump_write(d, &(fdi->info.ipv4serverinfo.l4proto), sizeof(uint8_t)) != sizeof(uint8_t)) + { + snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (fi3)"); + return SCAP_FAILURE; + } + break; + case SCAP_FD_IPV6_SOCK: + if(scap_dump_write(d, (char*)fdi->info.ipv6info.sip, sizeof(uint32_t) * 4) != sizeof(uint32_t) * 4 || + scap_dump_write(d, (char*)fdi->info.ipv6info.dip, sizeof(uint32_t) * 4) != sizeof(uint32_t) * 4 || + scap_dump_write(d, &(fdi->info.ipv6info.sport), sizeof(uint16_t)) != sizeof(uint16_t) || + scap_dump_write(d, &(fdi->info.ipv6info.dport), sizeof(uint16_t)) != sizeof(uint16_t) || + scap_dump_write(d, &(fdi->info.ipv6info.l4proto), sizeof(uint8_t)) != sizeof(uint8_t)) + { + snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (fi7)"); + } + break; + case SCAP_FD_IPV6_SERVSOCK: + if(scap_dump_write(d, &(fdi->info.ipv6serverinfo.ip), sizeof(uint32_t) * 4) != sizeof(uint32_t) * 4 || + scap_dump_write(d, &(fdi->info.ipv6serverinfo.port), sizeof(uint16_t)) != sizeof(uint16_t) || + scap_dump_write(d, &(fdi->info.ipv6serverinfo.l4proto), sizeof(uint8_t)) != sizeof(uint8_t)) + { + snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (fi8)"); + } + break; + case SCAP_FD_UNIX_SOCK: + if(scap_dump_write(d, &(fdi->info.unix_socket_info.source), sizeof(uint64_t)) != sizeof(uint64_t) || + scap_dump_write(d, &(fdi->info.unix_socket_info.destination), sizeof(uint64_t)) != sizeof(uint64_t)) + { + snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (fi4)"); + return SCAP_FAILURE; + } + stlen = (uint16_t)strnlen(fdi->info.unix_socket_info.fname, SCAP_MAX_PATH_SIZE); + if(scap_dump_write(d, &stlen, sizeof(uint16_t)) != sizeof(uint16_t) || + (stlen > 0 && scap_dump_write(d, fdi->info.unix_socket_info.fname, stlen) != stlen)) + { + snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (fi5)"); + return SCAP_FAILURE; + } + break; + case SCAP_FD_FILE_V2: + if(scap_dump_write(d, &(fdi->info.regularinfo.open_flags), sizeof(uint32_t)) != sizeof(uint32_t)) + { + snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (fi1)"); + return SCAP_FAILURE; + } + stlen = (uint16_t)strnlen(fdi->info.regularinfo.fname, SCAP_MAX_PATH_SIZE); + if(scap_dump_write(d, &stlen, sizeof(uint16_t)) != sizeof(uint16_t) || + (stlen > 0 && scap_dump_write(d, fdi->info.regularinfo.fname, stlen) != stlen)) + { + snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (fi1)"); + return SCAP_FAILURE; + } + if(scap_dump_write(d, &(fdi->info.regularinfo.dev), sizeof(uint32_t)) != sizeof(uint32_t)) + { + snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (dev)"); + return SCAP_FAILURE; + } + break; + case SCAP_FD_FIFO: + case SCAP_FD_FILE: + case SCAP_FD_DIRECTORY: + case SCAP_FD_UNSUPPORTED: + case SCAP_FD_EVENT: + case SCAP_FD_SIGNALFD: + case SCAP_FD_EVENTPOLL: + case SCAP_FD_INOTIFY: + case SCAP_FD_TIMERFD: + case SCAP_FD_NETLINK: + case SCAP_FD_BPF: + case SCAP_FD_USERFAULTFD: + case SCAP_FD_IOURING: + case SCAP_FD_MEMFD: + case SCAP_FD_PIDFD: + stlen = (uint16_t)strnlen(fdi->info.fname, SCAP_MAX_PATH_SIZE); + if(scap_dump_write(d, &stlen, sizeof(uint16_t)) != sizeof(uint16_t) || + (stlen > 0 && scap_dump_write(d, fdi->info.fname, stlen) != stlen)) + { + snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (fi6)"); + return SCAP_FAILURE; + } + break; + case SCAP_FD_UNKNOWN: + // Ignore UNKNOWN fds without failing + ASSERT(false); + break; + default: + snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "Unknown fdi type %d", fdi->type); + ASSERT(false); + return SCAP_FAILURE; + } + + return SCAP_SUCCESS; +} + +int32_t scap_write_proc_fds(scap_dumper_t *d, struct scap_threadinfo *tinfo) +{ + block_header bh; + uint32_t bt; + uint32_t totlen = sizeof(tinfo->tid); // This includes the tid + uint32_t idx = 0; + struct scap_fdinfo *fdi; + struct scap_fdinfo *tfdi; + + uint32_t* lengths = calloc(HASH_COUNT(tinfo->fdlist), sizeof(uint32_t)); + if(lengths == NULL) + { + snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "scap_write_proc_fds memory allocation failure"); + return SCAP_FAILURE; + } + + // + // First pass of the table to calculate the lengths + // + HASH_ITER(hh, tinfo->fdlist, fdi, tfdi) + { + if(fdi->type != SCAP_FD_UNINITIALIZED && + fdi->type != SCAP_FD_UNKNOWN) + { + uint32_t fl = scap_fd_info_len(fdi); + lengths[idx++] = fl; + totlen += fl; + } + } + idx = 0; + + // + // Create the block + // + bh.block_type = FDL_BLOCK_TYPE_V2; + bh.block_total_length = scap_normalize_block_len(sizeof(block_header) + totlen + 4); + + if(scap_dump_write(d, &bh, sizeof(bh)) != sizeof(bh)) + { + free(lengths); + snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (fd1)"); + return SCAP_FAILURE; + } + + // + // Write the tid + // + if(scap_dump_write(d, &tinfo->tid, sizeof(tinfo->tid)) != sizeof(tinfo->tid)) + { + free(lengths); + snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (fd2)"); + return SCAP_FAILURE; + } + + // + // Second pass of the table to dump it + // + HASH_ITER(hh, tinfo->fdlist, fdi, tfdi) + { + if(fdi->type != SCAP_FD_UNINITIALIZED && fdi->type != SCAP_FD_UNKNOWN) + { + if(scap_fd_write_to_disk(d, fdi, lengths[idx++]) != SCAP_SUCCESS) + { + free(lengths); + return SCAP_FAILURE; + } + } + } + + free(lengths); + + // + // Add the padding + // + if(scap_write_padding(d, totlen) != SCAP_SUCCESS) + { + snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (fd3)"); + return SCAP_FAILURE; + } + + // + // Create the trailer + // + bt = bh.block_total_length; + if(scap_dump_write(d, &bt, sizeof(bt)) != sizeof(bt)) + { + snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (fd4)"); + return SCAP_FAILURE; + } + + return SCAP_SUCCESS; +} + +// +// Write the fd list blocks +// +static int32_t scap_write_fdlist(scap_dumper_t *d, struct scap_proclist *proclist) +{ + struct scap_threadinfo *tinfo; + struct scap_threadinfo *ttinfo; + int32_t res; + + HASH_ITER(hh, proclist->m_proclist, tinfo, ttinfo) + { + if(!tinfo->filtered_out) + { + res = scap_write_proc_fds(d, tinfo); + if(res != SCAP_SUCCESS) + { + return res; + } + } + } + + return SCAP_SUCCESS; +} + +// +// Since the process list isn't thread-safe, we at least reduce the +// time window and write everything at once with a secondary dumper. +// By doing so, the likelihood of having a wrong total length is lower. +// +scap_dumper_t *scap_write_proclist_begin() +{ + return scap_managedbuf_dump_create(); +} + +// +// Write the process list block +// +static int32_t scap_write_proclist_header(scap_dumper_t *d, uint32_t totlen) +{ + block_header bh; + + // + // Create the block header + // + bh.block_type = PL_BLOCK_TYPE_V9; + bh.block_total_length = scap_normalize_block_len(sizeof(block_header) + totlen + 4); + + if(scap_dump_write(d, &bh, sizeof(bh)) != sizeof(bh)) + { + snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (1)"); + return SCAP_FAILURE; + } + + return SCAP_SUCCESS; +} + +// +// Write the process list block +// +static int32_t scap_write_proclist_trailer(scap_dumper_t *d, uint32_t totlen) +{ + block_header bh; + uint32_t bt; + + bh.block_type = PL_BLOCK_TYPE_V9; + bh.block_total_length = scap_normalize_block_len(sizeof(block_header) + totlen + 4); + + // + // Blocks need to be 4-byte padded + // + if(scap_write_padding(d, totlen) != SCAP_SUCCESS) + { + snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (3)"); + return SCAP_FAILURE; + } + + // + // Create the trailer + // + bt = bh.block_total_length; + if(scap_dump_write(d, &bt, sizeof(bt)) != sizeof(bt)) + { + snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (4)"); + return SCAP_FAILURE; + } + + return SCAP_SUCCESS; +} + +int scap_write_proclist_end(scap_dumper_t *d, scap_dumper_t *proclist_dumper, uint32_t totlen) +{ + ASSERT(proclist_dumper != NULL); + ASSERT(proclist_dumper->m_type == DT_MANAGED_BUF); + + int res = SCAP_SUCCESS; + + do + { + scap_dump_flush(proclist_dumper); + + if(scap_write_proclist_header(d, totlen) != SCAP_SUCCESS) + { + res = SCAP_FAILURE; + break; + } + if(scap_dump_write(d, proclist_dumper->m_targetbuf, totlen) <= 0) + { + res = SCAP_FAILURE; + break; + } + if(scap_write_proclist_trailer(d, totlen) != SCAP_SUCCESS) + { + res = SCAP_FAILURE; + break; + } + } while(false); + + scap_dump_close(proclist_dumper); + + return res; +} + +// +// Write the process list block +// +static int32_t scap_write_proclist_entry(scap_dumper_t *d, struct scap_threadinfo *tinfo, uint32_t *len) +{ + struct iovec args = {tinfo->args, tinfo->args_len}; + struct iovec env = {tinfo->env, tinfo->env_len}; + struct iovec cgroups = {tinfo->cgroups.path, tinfo->cgroups.len}; + + return scap_write_proclist_entry_bufs(d, tinfo, len, + tinfo->comm, + tinfo->exe, + tinfo->exepath, + &args, 1, + &env, 1, + tinfo->cwd, + &cgroups, 1, + tinfo->root); +} + +static uint16_t iov_size(const struct iovec *iov, uint32_t iovcnt) +{ + uint16_t len = 0; + uint32_t i; + + for (i = 0; i < iovcnt; i++) + { + len += iov[i].iov_len; + } + + return len; +} + +int32_t scap_write_proclist_entry_bufs(scap_dumper_t *d, struct scap_threadinfo *tinfo, uint32_t *len, + const char *comm, + const char *exe, + const char *exepath, + const struct iovec *args, int argscnt, + const struct iovec *envs, int envscnt, + const char *cwd, + const struct iovec *cgroups, int cgroupscnt, + const char *root) +{ + uint16_t commlen; + uint16_t exelen; + uint16_t exepathlen; + uint16_t cwdlen; + uint16_t rootlen; + uint16_t argslen; + uint16_t envlen; + uint16_t cgroupslen; + + commlen = (uint16_t)strnlen(comm, SCAP_MAX_PATH_SIZE); + exelen = (uint16_t)strnlen(exe, SCAP_MAX_PATH_SIZE); + exepathlen = (uint16_t)strnlen(exepath, SCAP_MAX_PATH_SIZE); + cwdlen = (uint16_t)strnlen(cwd, SCAP_MAX_PATH_SIZE); + rootlen = (uint16_t)strnlen(root, SCAP_MAX_PATH_SIZE); + + argslen = iov_size(args, argscnt); + envlen = iov_size(envs, envscnt); + cgroupslen = iov_size(cgroups, cgroupscnt); + + // + // NB: new fields must be appended + // + *len = (uint32_t)(sizeof(uint32_t) + // len + sizeof(uint64_t) + // tid + sizeof(uint64_t) + // pid + sizeof(uint64_t) + // ptid + sizeof(uint64_t) + // sid + sizeof(uint64_t) + // vpgid + 2 + commlen + + 2 + exelen + + 2 + exepathlen + + 2 + argslen + + 2 + cwdlen + + sizeof(uint64_t) + // fdlimit + sizeof(uint32_t) + // flags + sizeof(uint32_t) + // uid + sizeof(uint32_t) + // gid + sizeof(uint32_t) + // vmsize_kb + sizeof(uint32_t) + // vmrss_kb + sizeof(uint32_t) + // vmswap_kb + sizeof(uint64_t) + // pfmajor + sizeof(uint64_t) + // pfminor + 2 + envlen + + sizeof(int64_t) + // vtid + sizeof(int64_t) + // vpid + 2 + cgroupslen + + 2 + rootlen + + sizeof(uint64_t) + // pidns_init_start_ts + sizeof(uint32_t) + // tty + sizeof(uint32_t) + // loginuid (auid) + sizeof(uint8_t) + // exe_writable + sizeof(uint64_t) + // cap_inheritable + sizeof(uint64_t) + // cap_permitted + sizeof(uint64_t) + // cap_effective + sizeof(uint8_t) + // exe_upper_layer + sizeof(uint64_t) + // exe_ino + sizeof(uint64_t) + // exe_ino_ctime + sizeof(uint64_t) + // exe_ino_mtime + sizeof(uint8_t)); // exe_from_memfd + + if(scap_dump_write(d, len, sizeof(uint32_t)) != sizeof(uint32_t) || + scap_dump_write(d, &(tinfo->tid), sizeof(uint64_t)) != sizeof(uint64_t) || + scap_dump_write(d, &(tinfo->pid), sizeof(uint64_t)) != sizeof(uint64_t) || + scap_dump_write(d, &(tinfo->ptid), sizeof(uint64_t)) != sizeof(uint64_t) || + scap_dump_write(d, &(tinfo->sid), sizeof(uint64_t)) != sizeof(uint64_t) || + scap_dump_write(d, &(tinfo->vpgid), sizeof(uint64_t)) != sizeof(uint64_t) || + scap_dump_write(d, &commlen, sizeof(uint16_t)) != sizeof(uint16_t) || + scap_dump_write(d, (char *) comm, commlen) != commlen || + scap_dump_write(d, &exelen, sizeof(uint16_t)) != sizeof(uint16_t) || + scap_dump_write(d, (char *) exe, exelen) != exelen || + scap_dump_write(d, &exepathlen, sizeof(uint16_t)) != sizeof(uint16_t) || + scap_dump_write(d, (char *) exepath, exepathlen) != exepathlen || + scap_dump_write(d, &argslen, sizeof(uint16_t)) != sizeof(uint16_t) || + scap_dump_writev(d, args, argscnt) != argslen || + scap_dump_write(d, &cwdlen, sizeof(uint16_t)) != sizeof(uint16_t) || + scap_dump_write(d, (char *) cwd, cwdlen) != cwdlen || + scap_dump_write(d, &(tinfo->fdlimit), sizeof(uint64_t)) != sizeof(uint64_t) || + scap_dump_write(d, &(tinfo->flags), sizeof(uint32_t)) != sizeof(uint32_t) || + scap_dump_write(d, &(tinfo->uid), sizeof(uint32_t)) != sizeof(uint32_t) || + scap_dump_write(d, &(tinfo->gid), sizeof(uint32_t)) != sizeof(uint32_t) || + scap_dump_write(d, &(tinfo->vmsize_kb), sizeof(uint32_t)) != sizeof(uint32_t) || + scap_dump_write(d, &(tinfo->vmrss_kb), sizeof(uint32_t)) != sizeof(uint32_t) || + scap_dump_write(d, &(tinfo->vmswap_kb), sizeof(uint32_t)) != sizeof(uint32_t) || + scap_dump_write(d, &(tinfo->pfmajor), sizeof(uint64_t)) != sizeof(uint64_t) || + scap_dump_write(d, &(tinfo->pfminor), sizeof(uint64_t)) != sizeof(uint64_t) || + scap_dump_write(d, &envlen, sizeof(uint16_t)) != sizeof(uint16_t) || + scap_dump_writev(d, envs, envscnt) != envlen || + scap_dump_write(d, &(tinfo->vtid), sizeof(int64_t)) != sizeof(int64_t) || + scap_dump_write(d, &(tinfo->vpid), sizeof(int64_t)) != sizeof(int64_t) || + scap_dump_write(d, &(cgroupslen), sizeof(uint16_t)) != sizeof(uint16_t) || + scap_dump_writev(d, cgroups, cgroupscnt) != cgroupslen || + scap_dump_write(d, &rootlen, sizeof(uint16_t)) != sizeof(uint16_t) || + scap_dump_write(d, (char *) root, rootlen) != rootlen || + scap_dump_write(d, &(tinfo->pidns_init_start_ts), sizeof(uint64_t)) != sizeof(uint64_t) || + scap_dump_write(d, &(tinfo->tty), sizeof(uint32_t)) != sizeof(uint32_t) || + scap_dump_write(d, &(tinfo->loginuid), sizeof(uint32_t)) != sizeof(uint32_t) || + scap_dump_write(d, &(tinfo->exe_writable), sizeof(uint8_t)) != sizeof(uint8_t) || + scap_dump_write(d, &(tinfo->cap_inheritable), sizeof(uint64_t)) != sizeof(uint64_t) || + scap_dump_write(d, &(tinfo->cap_permitted), sizeof(uint64_t)) != sizeof(uint64_t) || + scap_dump_write(d, &(tinfo->cap_effective), sizeof(uint64_t)) != sizeof(uint64_t) || + scap_dump_write(d, &(tinfo->exe_upper_layer), sizeof(uint8_t)) != sizeof(uint8_t) || + scap_dump_write(d, &(tinfo->exe_ino), sizeof(uint64_t)) != sizeof(uint64_t) || + scap_dump_write(d, &(tinfo->exe_ino_ctime), sizeof(uint64_t)) != sizeof(uint64_t) || + scap_dump_write(d, &(tinfo->exe_ino_mtime), sizeof(uint64_t)) != sizeof(uint64_t) || + scap_dump_write(d, &(tinfo->exe_from_memfd), sizeof(uint8_t)) != sizeof(uint8_t)) + { + snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (2)"); + return SCAP_FAILURE; + } + + return SCAP_SUCCESS; +} + +// +// Write the process list block +// +static int32_t scap_write_proclist(scap_dumper_t *d, struct scap_proclist *proclist) +{ + // + // Exit immediately if the process list is empty + // + if(HASH_COUNT(proclist->m_proclist) == 0) + { + return SCAP_SUCCESS; + } + + scap_dumper_t *proclist_dumper = scap_write_proclist_begin(); + if(proclist_dumper == NULL) + { + return SCAP_FAILURE; + } + + + uint32_t totlen = 0; + struct scap_threadinfo *tinfo; + struct scap_threadinfo *ttinfo; + HASH_ITER(hh, proclist->m_proclist, tinfo, ttinfo) + { + if(tinfo->filtered_out) + { + continue; + } + + uint32_t len = 0; + if(scap_write_proclist_entry(proclist_dumper, tinfo, &len) != SCAP_SUCCESS) + { + scap_dump_close(proclist_dumper); + return SCAP_FAILURE; + } + + totlen += len; + } + + return scap_write_proclist_end(d, proclist_dumper, totlen); +} + +// +// Write the machine info block +// +static int32_t scap_write_machine_info(scap_dumper_t *d, scap_machine_info *machine_info) +{ + block_header bh; + uint32_t bt; + + // + // Write the section header + // + bh.block_type = MI_BLOCK_TYPE; + bh.block_total_length = scap_normalize_block_len(sizeof(block_header) + sizeof(scap_machine_info) + 4); + + bt = bh.block_total_length; + + if(scap_dump_write(d, &bh, sizeof(bh)) != sizeof(bh) || + scap_dump_write(d, machine_info, sizeof(*machine_info)) != sizeof(*machine_info) || + scap_dump_write(d, &bt, sizeof(bt)) != sizeof(bt)) + { + snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (MI1)"); + return SCAP_FAILURE; + } + + return SCAP_SUCCESS; +} + +// +// Write the interface list block +// +static int32_t scap_write_iflist(scap_dumper_t* d, scap_addrlist* addrlist) +{ + block_header bh; + uint32_t bt; + uint32_t entrylen; + uint32_t totlen = 0; + uint32_t j; + + // + // Get the interface list + // + if(addrlist == NULL) + { + // + // This can happen when the event source is a capture that was generated by a plugin, no big deal + // + return SCAP_SUCCESS; + } + + // + // Create the block + // + bh.block_type = IL_BLOCK_TYPE_V2; + bh.block_total_length = scap_normalize_block_len(sizeof(block_header) + (addrlist->n_v4_addrs + addrlist->n_v6_addrs)*sizeof(uint32_t) + + addrlist->totlen + 4); + + if(scap_dump_write(d, &bh, sizeof(bh)) != sizeof(bh)) + { + snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (IF1)"); + return SCAP_FAILURE; + } + + // + // Dump the ipv4 list + // + for(j = 0; j < addrlist->n_v4_addrs; j++) + { + scap_ifinfo_ipv4 *entry = &(addrlist->v4list[j]); + + entrylen = sizeof(scap_ifinfo_ipv4) + entry->ifnamelen - SCAP_MAX_PATH_SIZE; + + if(scap_dump_write(d, &entrylen, sizeof(uint32_t)) != sizeof(uint32_t) || + scap_dump_write(d, &(entry->type), sizeof(uint16_t)) != sizeof(uint16_t) || + scap_dump_write(d, &(entry->ifnamelen), sizeof(uint16_t)) != sizeof(uint16_t) || + scap_dump_write(d, &(entry->addr), sizeof(uint32_t)) != sizeof(uint32_t) || + scap_dump_write(d, &(entry->netmask), sizeof(uint32_t)) != sizeof(uint32_t) || + scap_dump_write(d, &(entry->bcast), sizeof(uint32_t)) != sizeof(uint32_t) || + scap_dump_write(d, &(entry->linkspeed), sizeof(uint64_t)) != sizeof(uint64_t) || + scap_dump_write(d, &(entry->ifname), entry->ifnamelen) != entry->ifnamelen) + { + snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (IF2)"); + return SCAP_FAILURE; + } + + totlen += sizeof(uint32_t) + entrylen; + } + + // + // Dump the ipv6 list + // + for(j = 0; j < addrlist->n_v6_addrs; j++) + { + scap_ifinfo_ipv6 *entry = &(addrlist->v6list[j]); + + entrylen = sizeof(scap_ifinfo_ipv6) + entry->ifnamelen - SCAP_MAX_PATH_SIZE; + + if(scap_dump_write(d, &entrylen, sizeof(uint32_t)) != sizeof(uint32_t) || + scap_dump_write(d, &(entry->type), sizeof(uint16_t)) != sizeof(uint16_t) || + scap_dump_write(d, &(entry->ifnamelen), sizeof(uint16_t)) != sizeof(uint16_t) || + scap_dump_write(d, &(entry->addr), SCAP_IPV6_ADDR_LEN) != SCAP_IPV6_ADDR_LEN || + scap_dump_write(d, &(entry->netmask), SCAP_IPV6_ADDR_LEN) != SCAP_IPV6_ADDR_LEN || + scap_dump_write(d, &(entry->bcast), SCAP_IPV6_ADDR_LEN) != SCAP_IPV6_ADDR_LEN || + scap_dump_write(d, &(entry->linkspeed), sizeof(uint64_t)) != sizeof(uint64_t) || + scap_dump_write(d, &(entry->ifname), entry->ifnamelen) != entry->ifnamelen) + { + snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (IF2)"); + return SCAP_FAILURE; + } + + totlen += sizeof(uint32_t) + entrylen; + } + + // + // Blocks need to be 4-byte padded + // + if(scap_write_padding(d, totlen) != SCAP_SUCCESS) + { + snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (IF3)"); + return SCAP_FAILURE; + } + + // + // Create the trailer + // + bt = bh.block_total_length; + if(scap_dump_write(d, &bt, sizeof(bt)) != sizeof(bt)) + { + snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (IF4)"); + return SCAP_FAILURE; + } + + return SCAP_SUCCESS; +} + +// +// Write the user list block +// +static int32_t scap_write_userlist(scap_dumper_t* d, struct scap_userlist *userlist) +{ + block_header bh; + uint32_t bt; + uint32_t j; + uint16_t namelen; + uint16_t homedirlen; + uint16_t shelllen; + uint8_t type; + uint32_t totlen = 0; + + // + // Make sure we have a user list interface list + // + if(userlist == NULL) + { + // + // This can happen when the event source is a capture that was generated by a plugin, no big deal + // + return SCAP_SUCCESS; + } + + uint32_t* lengths = calloc(userlist->nusers + userlist->ngroups, sizeof(uint32_t)); + if(lengths == NULL) + { + snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "scap_write_userlist memory allocation failure (1)"); + return SCAP_FAILURE; + } + + // + // Calculate the lengths + // + for(j = 0; j < userlist->nusers; j++) + { + scap_userinfo* info = &userlist->users[j]; + + namelen = (uint16_t)strnlen(info->name, MAX_CREDENTIALS_STR_LEN); + homedirlen = (uint16_t)strnlen(info->homedir, SCAP_MAX_PATH_SIZE); + shelllen = (uint16_t)strnlen(info->shell, SCAP_MAX_PATH_SIZE); + + // NB: new fields must be appended + size_t ul = sizeof(uint32_t) + sizeof(type) + sizeof(info->uid) + sizeof(info->gid) + sizeof(uint16_t) + + namelen + sizeof(uint16_t) + homedirlen + sizeof(uint16_t) + shelllen; + totlen += ul; + lengths[j] = ul; + } + + for(j = 0; j < userlist->ngroups; j++) + { + scap_groupinfo* info = &userlist->groups[j]; + + namelen = (uint16_t)strnlen(info->name, MAX_CREDENTIALS_STR_LEN); + + // NB: new fields must be appended + uint32_t gl = sizeof(uint32_t) + sizeof(type) + sizeof(info->gid) + sizeof(uint16_t) + namelen; + totlen += gl; + lengths[userlist->nusers + j] = gl; + } + + // + // Create the block + // + bh.block_type = UL_BLOCK_TYPE_V2; + bh.block_total_length = scap_normalize_block_len(sizeof(block_header) + totlen + 4); + + if(scap_dump_write(d, &bh, sizeof(bh)) != sizeof(bh)) + { + free(lengths); + snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (IF1)"); + return SCAP_FAILURE; + } + + // + // Dump the users + // + type = USERBLOCK_TYPE_USER; + for(j = 0; j < userlist->nusers; j++) + { + scap_userinfo* info = &userlist->users[j]; + + namelen = (uint16_t)strnlen(info->name, MAX_CREDENTIALS_STR_LEN); + homedirlen = (uint16_t)strnlen(info->homedir, SCAP_MAX_PATH_SIZE); + shelllen = (uint16_t)strnlen(info->shell, SCAP_MAX_PATH_SIZE); + + if(scap_dump_write(d, &(lengths[j]), sizeof(uint32_t)) != sizeof(uint32_t) || + scap_dump_write(d, &(type), sizeof(type)) != sizeof(type) || + scap_dump_write(d, &(info->uid), sizeof(info->uid)) != sizeof(info->uid) || + scap_dump_write(d, &(info->gid), sizeof(info->gid)) != sizeof(info->gid) || + scap_dump_write(d, &namelen, sizeof(uint16_t)) != sizeof(uint16_t) || + scap_dump_write(d, info->name, namelen) != namelen || + scap_dump_write(d, &homedirlen, sizeof(uint16_t)) != sizeof(uint16_t) || + scap_dump_write(d, info->homedir, homedirlen) != homedirlen || + scap_dump_write(d, &shelllen, sizeof(uint16_t)) != sizeof(uint16_t) || + scap_dump_write(d, info->shell, shelllen) != shelllen) + { + free(lengths); + snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (U1)"); + return SCAP_FAILURE; + } + } + + // + // Dump the groups + // + type = USERBLOCK_TYPE_GROUP; + for(j = 0; j < userlist->ngroups; j++) + { + scap_groupinfo* info = &userlist->groups[j]; + + namelen = (uint16_t)strnlen(info->name, MAX_CREDENTIALS_STR_LEN); + + if(scap_dump_write(d, &(lengths[userlist->nusers + j]), sizeof(uint32_t)) != sizeof(uint32_t) || + scap_dump_write(d, &(type), sizeof(type)) != sizeof(type) || + scap_dump_write(d, &(info->gid), sizeof(info->gid)) != sizeof(info->gid) || + scap_dump_write(d, &namelen, sizeof(uint16_t)) != sizeof(uint16_t) || + scap_dump_write(d, info->name, namelen) != namelen) + { + free(lengths); + snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (U2)"); + return SCAP_FAILURE; + } + } + + free(lengths); + + // + // Blocks need to be 4-byte padded + // + if(scap_write_padding(d, totlen) != SCAP_SUCCESS) + { + snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (IF3)"); + return SCAP_FAILURE; + } + + // + // Create the trailer + // + bt = bh.block_total_length; + if(scap_dump_write(d, &bt, sizeof(bt)) != sizeof(bt)) + { + snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (IF4)"); + return SCAP_FAILURE; + } + + return SCAP_SUCCESS; +} + +// +// Create the dump file headers and add the tables +// +static int32_t scap_setup_dump(scap_dumper_t* d, struct scap_platform *platform, const char *fname) +{ + block_header bh; + section_header_block sh; + uint32_t bt; + + // + // Write the section header + // + bh.block_type = SHB_BLOCK_TYPE; + bh.block_total_length = sizeof(block_header) + sizeof(section_header_block) + 4; + + sh.byte_order_magic = SHB_MAGIC; + sh.major_version = CURRENT_MAJOR_VERSION; + sh.minor_version = CURRENT_MINOR_VERSION; + sh.section_length = 0xffffffffffffffffLL; + + bt = bh.block_total_length; + + if(scap_dump_write(d, &bh, sizeof(bh)) != sizeof(bh) || + scap_dump_write(d, &sh, sizeof(sh)) != sizeof(sh) || + scap_dump_write(d, &bt, sizeof(bt)) != sizeof(bt)) + { + snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file %s (5)", fname); + return SCAP_FAILURE; + } + + if(platform) + { + // + // Write the machine info + // + if(scap_write_machine_info(d, &platform->m_machine_info) != SCAP_SUCCESS) + { + return SCAP_FAILURE; + } + + // + // Write the interface list + // + if(scap_write_iflist(d, platform->m_addrlist) != SCAP_SUCCESS) + { + return SCAP_FAILURE; + } + + // + // Write the user list + // + if(scap_write_userlist(d, platform->m_userlist) != SCAP_SUCCESS) + { + return SCAP_FAILURE; + } + + // + // Write the process list + // + if(scap_write_proclist(d, &platform->m_proclist) != SCAP_SUCCESS) + { + return SCAP_FAILURE; + } + + // + // Write the fd lists + // + if(scap_write_fdlist(d, &platform->m_proclist) != SCAP_SUCCESS) + { + return SCAP_FAILURE; + } + } + + // + // Done, return the file + // + return SCAP_SUCCESS; +} + +static inline int32_t scap_dump_rescan_proc(struct scap_platform* platform) +{ + int32_t ret = SCAP_SUCCESS; +#ifdef __linux__ + if(platform && platform->m_vtable && platform->m_vtable->refresh_proc_table) + { + proc_entry_callback tcb = platform->m_proclist.m_proc_callback; + platform->m_proclist.m_proc_callback = NULL; + ret = platform->m_vtable->refresh_proc_table(platform, &platform->m_proclist); + platform->m_proclist.m_proc_callback = tcb; + } +#endif + return ret; +} + +// fname is only used for log messages in scap_setup_dump +static scap_dumper_t *scap_dump_open_gzfile(struct scap_platform* platform, gzFile gzfile, const char *fname, char* lasterr) +{ + scap_dumper_t* res = (scap_dumper_t*)malloc(sizeof(scap_dumper_t)); + res->m_f = gzfile; + res->m_type = DT_FILE; + res->m_targetbuf = NULL; + res->m_targetbufcurpos = NULL; + res->m_targetbufend = NULL; + + if(scap_setup_dump(res, platform, fname) != SCAP_SUCCESS) + { + strlcpy(lasterr, res->m_lasterr, SCAP_LASTERR_SIZE); + free(res); + res = NULL; + } + + return res; +} + +// +// Open a "savefile" for writing. +// +scap_dumper_t *scap_dump_open(struct scap_platform* platform, const char *fname, compression_mode compress, bool skip_proc_scan, char* lasterr) +{ + gzFile f = NULL; + int fd = -1; + const char* mode; + scap_dumper_t* res; + + switch(compress) + { + case SCAP_COMPRESSION_GZIP: + mode = "wb"; + break; + case SCAP_COMPRESSION_NONE: + mode = "wbT"; + break; + default: + ASSERT(false); + snprintf(lasterr, SCAP_LASTERR_SIZE, "invalid compression mode"); + return NULL; + } + + if(fname[0] == '-' && fname[1] == '\0') + { +#ifndef _WIN32 + fd = dup(STDOUT_FILENO); +#else + fd = 1; +#endif + if(fd != -1) + { + f = gzdopen(fd, mode); + fname = "standard output"; + } + } + else + { + f = gzopen(fname, mode); + } + + if(f == NULL) + { +#ifndef _WIN32 + if(fd != -1) + { + close(fd); + } +#endif + + snprintf(lasterr, SCAP_LASTERR_SIZE, "can't open %s", fname); + return NULL; + } + + // + // If we're dumping in live mode, refresh the process tables list + // so we don't lose information about processes created in the interval + // between opening the handle and starting the dump + // + if(!skip_proc_scan) + { + if(scap_dump_rescan_proc(platform) != SCAP_SUCCESS) + { + return NULL; + } + } + + res = scap_dump_open_gzfile(platform, f, fname, lasterr); + // + // If the user doesn't need the thread table, free it + // + if(platform->m_proclist.m_proc_callback != NULL) + { + scap_proc_free_table(&platform->m_proclist); + } + + return res; +} + +// +// Open a savefile for writing, using the provided fd +scap_dumper_t* scap_dump_open_fd(struct scap_platform* platform, int fd, compression_mode compress, bool skip_proc_scan, char* lasterr) +{ + gzFile f = NULL; + scap_dumper_t* res; + + switch(compress) + { + case SCAP_COMPRESSION_GZIP: + f = gzdopen(fd, "wb"); + break; + case SCAP_COMPRESSION_NONE: + f = gzdopen(fd, "wbT"); + break; + default: + ASSERT(false); + snprintf(lasterr, SCAP_LASTERR_SIZE, "invalid compression mode"); + return NULL; + } + + if(f == NULL) + { + snprintf(lasterr, SCAP_LASTERR_SIZE, "can't open fd %d", fd); + return NULL; + } + + // + // If we're dumping in live mode, refresh the process tables list + // so we don't lose information about processes created in the interval + // between opening the handle and starting the dump + // + if(!skip_proc_scan) + { + if(scap_dump_rescan_proc(platform) != SCAP_SUCCESS) + { + return NULL; + } + } + + res = scap_dump_open_gzfile(platform, f, "", lasterr); + + // + // If the user doesn't need the thread table, free it + // + if(platform->m_proclist.m_proc_callback != NULL) + { + scap_proc_free_table(&platform->m_proclist); + } + return res; +} + +// +// Open a memory "savefile" +// +scap_dumper_t *scap_memory_dump_open(struct scap_platform* platform, uint8_t* targetbuf, uint64_t targetbufsize, char* lasterr) +{ + scap_dumper_t* res = (scap_dumper_t*)malloc(sizeof(scap_dumper_t)); + if(res == NULL) + { + snprintf(lasterr, SCAP_LASTERR_SIZE, "scap_dump_memory_open memory allocation failure (1)"); + return NULL; + } + + res->m_f = NULL; + res->m_type = DT_MEM; + res->m_targetbuf = targetbuf; + res->m_targetbufcurpos = targetbuf; + res->m_targetbufend = targetbuf + targetbufsize; + + if(scap_setup_dump(res, platform, "") != SCAP_SUCCESS) + { + strlcpy(lasterr, res->m_lasterr, SCAP_LASTERR_SIZE); + free(res); + res = NULL; + } + + return res; +} + +// +// Create a dumper with an internally managed buffer +// +scap_dumper_t *scap_managedbuf_dump_create() +{ + scap_dumper_t *res = (scap_dumper_t *)malloc(sizeof(scap_dumper_t)); + if(res == NULL) + { + return NULL; + } + + res->m_f = NULL; + res->m_type = DT_MANAGED_BUF; + res->m_targetbuf = (uint8_t *)malloc(PPM_DUMPER_MANAGED_BUF_SIZE); + res->m_targetbufcurpos = res->m_targetbuf; + res->m_targetbufend = res->m_targetbuf + PPM_DUMPER_MANAGED_BUF_SIZE; + + return res; +} + +// +// Close a "savefile" opened with scap_dump_open +// +void scap_dump_close(scap_dumper_t *d) +{ + if(d->m_type == DT_FILE) + { + gzclose(d->m_f); + } + else if (d->m_type == DT_MANAGED_BUF) + { + free(d->m_targetbuf); + } + + free(d); +} + +// +// Return the current size of a tracefile +// +int64_t scap_dump_get_offset(scap_dumper_t *d) +{ + if(d->m_type == DT_FILE) + { + return gzoffset(d->m_f); + } + else + { + return (int64_t)d->m_targetbufcurpos - (int64_t)d->m_targetbuf; + } +} + +int64_t scap_dump_ftell(scap_dumper_t *d) +{ + if(d->m_type == DT_FILE) + { + return gztell(d->m_f); + } + else + { + return (int64_t)d->m_targetbufcurpos - (int64_t)d->m_targetbuf; + } +} + +void scap_dump_flush(scap_dumper_t *d) +{ + if(d->m_type == DT_FILE) + { + gzflush(d->m_f, Z_FULL_FLUSH); + } +} + +// +// Write an event to a dump file +// +int32_t scap_dump(scap_dumper_t *d, scap_evt *e, uint16_t cpuid, uint32_t flags) +{ + block_header bh; + uint32_t bt; + bool large_payload = flags & SCAP_DF_LARGE; + + flags &= ~SCAP_DF_LARGE; + if(flags == 0) + { + // + // Write the section header + // + bh.block_type = large_payload ? EV_BLOCK_TYPE_V2_LARGE : EV_BLOCK_TYPE_V2; + bh.block_total_length = scap_normalize_block_len(sizeof(block_header) + sizeof(cpuid) + e->len + 4); + bt = bh.block_total_length; + + if(scap_dump_write(d, &bh, sizeof(bh)) != sizeof(bh) || + scap_dump_write(d, &cpuid, sizeof(cpuid)) != sizeof(cpuid) || + scap_dump_write(d, e, e->len) != e->len || + scap_write_padding(d, sizeof(cpuid) + e->len) != SCAP_SUCCESS || + scap_dump_write(d, &bt, sizeof(bt)) != sizeof(bt)) + { + snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (6)"); + return SCAP_FAILURE; + } + } + else + { + // + // Write the section header + // + bh.block_type = large_payload ? EVF_BLOCK_TYPE_V2_LARGE : EVF_BLOCK_TYPE_V2; + bh.block_total_length = scap_normalize_block_len(sizeof(block_header) + sizeof(cpuid) + sizeof(flags) + e->len + 4); + bt = bh.block_total_length; + + if(scap_dump_write(d, &bh, sizeof(bh)) != sizeof(bh) || + scap_dump_write(d, &cpuid, sizeof(cpuid)) != sizeof(cpuid) || + scap_dump_write(d, &flags, sizeof(flags)) != sizeof(flags) || + scap_dump_write(d, e, e->len) != e->len || + scap_write_padding(d, sizeof(cpuid) + e->len) != SCAP_SUCCESS || + scap_dump_write(d, &bt, sizeof(bt)) != sizeof(bt)) + { + snprintf(d->m_lasterr, SCAP_LASTERR_SIZE, "error writing to file (7)"); + return SCAP_FAILURE; + } + } + + // + // Enable this to make sure that everything is saved to disk during the tests + // +#if 0 + fflush(f); +#endif + + return SCAP_SUCCESS; +} diff --git a/userspace/libscap/scap_savefile.h b/userspace/libscap/scap_savefile.h index 633c3245aa..266bf4f9fa 100644 --- a/userspace/libscap/scap_savefile.h +++ b/userspace/libscap/scap_savefile.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/scap_savefile_api.h b/userspace/libscap/scap_savefile_api.h index 43db61beb0..c2eba7e00c 100644 --- a/userspace/libscap/scap_savefile_api.h +++ b/userspace/libscap/scap_savefile_api.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/scap_stats_v2.h b/userspace/libscap/scap_stats_v2.h index 7eaebde292..355dbb7aa6 100644 --- a/userspace/libscap/scap_stats_v2.h +++ b/userspace/libscap/scap_stats_v2.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libscap/scap_suppress.c b/userspace/libscap/scap_suppress.c index 087c6a4889..1a33039a6c 100644 --- a/userspace/libscap/scap_suppress.c +++ b/userspace/libscap/scap_suppress.c @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/scap_suppress.h b/userspace/libscap/scap_suppress.h index 683942595f..18294642a6 100644 --- a/userspace/libscap/scap_suppress.h +++ b/userspace/libscap/scap_suppress.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/scap_userlist.c b/userspace/libscap/scap_userlist.c index f9477ce966..6d744d9310 100644 --- a/userspace/libscap/scap_userlist.c +++ b/userspace/libscap/scap_userlist.c @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/scap_vtable.h b/userspace/libscap/scap_vtable.h index 086d87851d..213474cbd7 100644 --- a/userspace/libscap/scap_vtable.h +++ b/userspace/libscap/scap_vtable.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/scap_zlib.h b/userspace/libscap/scap_zlib.h index 9f9d62cd4a..ebe0fba61d 100644 --- a/userspace/libscap/scap_zlib.h +++ b/userspace/libscap/scap_zlib.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/settings.h b/userspace/libscap/settings.h index cbad21eef7..24f8d7757f 100644 --- a/userspace/libscap/settings.h +++ b/userspace/libscap/settings.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/strerror.c b/userspace/libscap/strerror.c index 4526330ff8..16d86c0d97 100644 --- a/userspace/libscap/strerror.c +++ b/userspace/libscap/strerror.c @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/strerror.h b/userspace/libscap/strerror.h index e4b76e89dd..009de16d58 100644 --- a/userspace/libscap/strerror.h +++ b/userspace/libscap/strerror.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/uthash_ext.h b/userspace/libscap/uthash_ext.h index 092286dbf3..28a115b3c3 100644 --- a/userspace/libscap/uthash_ext.h +++ b/userspace/libscap/uthash_ext.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libscap/win32/gettimeofday.h b/userspace/libscap/win32/gettimeofday.h index b8dcf35e9c..d7b2fdd5e3 100644 --- a/userspace/libscap/win32/gettimeofday.h +++ b/userspace/libscap/win32/gettimeofday.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libscap/win32/sleep.h b/userspace/libscap/win32/sleep.h index aea4a04d70..9bbe076eff 100644 --- a/userspace/libscap/win32/sleep.h +++ b/userspace/libscap/win32/sleep.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/CMakeLists.txt b/userspace/libsinsp/CMakeLists.txt index d92fc4fbeb..f22d449ae9 100644 --- a/userspace/libsinsp/CMakeLists.txt +++ b/userspace/libsinsp/CMakeLists.txt @@ -1,5 +1,6 @@ +# SPDX-License-Identifier: Apache-2.0 # -# Copyright (C) 2021 The Falco Authors. +# Copyright (C) 2023 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. diff --git a/userspace/libsinsp/addrinfo.cpp b/userspace/libsinsp/addrinfo.cpp index 64fc08ff13..51ad717bf7 100644 --- a/userspace/libsinsp/addrinfo.cpp +++ b/userspace/libsinsp/addrinfo.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/addrinfo.h b/userspace/libsinsp/addrinfo.h index efecee7d2f..b72a0305c7 100644 --- a/userspace/libsinsp/addrinfo.h +++ b/userspace/libsinsp/addrinfo.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/async/async_key_value_source.h b/userspace/libsinsp/async/async_key_value_source.h index c39a64f5fa..83974a89ae 100644 --- a/userspace/libsinsp/async/async_key_value_source.h +++ b/userspace/libsinsp/async/async_key_value_source.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/capture_stats_source.h b/userspace/libsinsp/capture_stats_source.h index 24cc894306..b06e290f5c 100644 --- a/userspace/libsinsp/capture_stats_source.h +++ b/userspace/libsinsp/capture_stats_source.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/container.cpp b/userspace/libsinsp/container.cpp index 31d7bc3ebf..67765ee152 100644 --- a/userspace/libsinsp/container.cpp +++ b/userspace/libsinsp/container.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/container.h b/userspace/libsinsp/container.h index 9589f28859..184dc51f76 100644 --- a/userspace/libsinsp/container.h +++ b/userspace/libsinsp/container.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/container_engine/bpm.cpp b/userspace/libsinsp/container_engine/bpm.cpp index 05e0e54498..e78ab60085 100644 --- a/userspace/libsinsp/container_engine/bpm.cpp +++ b/userspace/libsinsp/container_engine/bpm.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/container_engine/bpm.h b/userspace/libsinsp/container_engine/bpm.h index 698dfba31a..6e3ea09c21 100644 --- a/userspace/libsinsp/container_engine/bpm.h +++ b/userspace/libsinsp/container_engine/bpm.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/container_engine/container_async_source.h b/userspace/libsinsp/container_engine/container_async_source.h index ffe24699ae..eb4781a8e5 100644 --- a/userspace/libsinsp/container_engine/container_async_source.h +++ b/userspace/libsinsp/container_engine/container_async_source.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/container_engine/container_cache_interface.h b/userspace/libsinsp/container_engine/container_cache_interface.h index a068526f7c..22d28f2974 100644 --- a/userspace/libsinsp/container_engine/container_cache_interface.h +++ b/userspace/libsinsp/container_engine/container_cache_interface.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/container_engine/container_engine_base.cpp b/userspace/libsinsp/container_engine/container_engine_base.cpp index 07f5f9f697..63e2442e6e 100644 --- a/userspace/libsinsp/container_engine/container_engine_base.cpp +++ b/userspace/libsinsp/container_engine/container_engine_base.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/container_engine/container_engine_base.h b/userspace/libsinsp/container_engine/container_engine_base.h index e4949f5be2..9975ceb247 100644 --- a/userspace/libsinsp/container_engine/container_engine_base.h +++ b/userspace/libsinsp/container_engine/container_engine_base.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/container_engine/cri.cpp b/userspace/libsinsp/container_engine/cri.cpp index 88cebba521..a91572e45c 100644 --- a/userspace/libsinsp/container_engine/cri.cpp +++ b/userspace/libsinsp/container_engine/cri.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/container_engine/cri.h b/userspace/libsinsp/container_engine/cri.h index fa6bceeb95..91a1210e62 100644 --- a/userspace/libsinsp/container_engine/cri.h +++ b/userspace/libsinsp/container_engine/cri.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/container_engine/docker/async_source.cpp b/userspace/libsinsp/container_engine/docker/async_source.cpp index d9c5087618..b861750961 100644 --- a/userspace/libsinsp/container_engine/docker/async_source.cpp +++ b/userspace/libsinsp/container_engine/docker/async_source.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/container_engine/docker/connection_linux.cpp b/userspace/libsinsp/container_engine/docker/connection_linux.cpp index 0e41c4c7fb..f807ea9698 100644 --- a/userspace/libsinsp/container_engine/docker/connection_linux.cpp +++ b/userspace/libsinsp/container_engine/docker/connection_linux.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/container_engine/docker/docker_linux.cpp b/userspace/libsinsp/container_engine/docker/docker_linux.cpp index ff9751ae6c..d5b738390f 100644 --- a/userspace/libsinsp/container_engine/docker/docker_linux.cpp +++ b/userspace/libsinsp/container_engine/docker/docker_linux.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/container_engine/docker/podman.cpp b/userspace/libsinsp/container_engine/docker/podman.cpp index 0234105c2f..6bf56f74d7 100644 --- a/userspace/libsinsp/container_engine/docker/podman.cpp +++ b/userspace/libsinsp/container_engine/docker/podman.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/container_engine/libvirt_lxc.cpp b/userspace/libsinsp/container_engine/libvirt_lxc.cpp index ccd6315558..d56651fc99 100644 --- a/userspace/libsinsp/container_engine/libvirt_lxc.cpp +++ b/userspace/libsinsp/container_engine/libvirt_lxc.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/container_engine/libvirt_lxc.h b/userspace/libsinsp/container_engine/libvirt_lxc.h index 458f98b305..6ba8cb5db4 100644 --- a/userspace/libsinsp/container_engine/libvirt_lxc.h +++ b/userspace/libsinsp/container_engine/libvirt_lxc.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/container_engine/lxc.cpp b/userspace/libsinsp/container_engine/lxc.cpp index a5345da96b..a6a03dba87 100644 --- a/userspace/libsinsp/container_engine/lxc.cpp +++ b/userspace/libsinsp/container_engine/lxc.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/container_engine/lxc.h b/userspace/libsinsp/container_engine/lxc.h index abbcf9ed9a..0f82bfb3b8 100644 --- a/userspace/libsinsp/container_engine/lxc.h +++ b/userspace/libsinsp/container_engine/lxc.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/container_engine/mesos.cpp b/userspace/libsinsp/container_engine/mesos.cpp index d9c3e73b68..2e90aaa1e5 100644 --- a/userspace/libsinsp/container_engine/mesos.cpp +++ b/userspace/libsinsp/container_engine/mesos.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/container_engine/mesos.h b/userspace/libsinsp/container_engine/mesos.h index b73339d8fb..5e90b899fc 100644 --- a/userspace/libsinsp/container_engine/mesos.h +++ b/userspace/libsinsp/container_engine/mesos.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/container_engine/rkt.cpp b/userspace/libsinsp/container_engine/rkt.cpp index 522ebecd07..4e41edb48c 100644 --- a/userspace/libsinsp/container_engine/rkt.cpp +++ b/userspace/libsinsp/container_engine/rkt.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/container_engine/rkt.h b/userspace/libsinsp/container_engine/rkt.h index 7b1ddb5bd6..8654e31abc 100644 --- a/userspace/libsinsp/container_engine/rkt.h +++ b/userspace/libsinsp/container_engine/rkt.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/container_engine/sinsp_container_type.h b/userspace/libsinsp/container_engine/sinsp_container_type.h index 720379c43e..b88abe3ddf 100644 --- a/userspace/libsinsp/container_engine/sinsp_container_type.h +++ b/userspace/libsinsp/container_engine/sinsp_container_type.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/container_engine/static_container.cpp b/userspace/libsinsp/container_engine/static_container.cpp index 30ace63b9f..b67fb484e5 100644 --- a/userspace/libsinsp/container_engine/static_container.cpp +++ b/userspace/libsinsp/container_engine/static_container.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/container_engine/static_container.h b/userspace/libsinsp/container_engine/static_container.h index 1d3d021c83..a836760331 100644 --- a/userspace/libsinsp/container_engine/static_container.h +++ b/userspace/libsinsp/container_engine/static_container.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/container_info.cpp b/userspace/libsinsp/container_info.cpp index 87134f93df..81250ecfe3 100644 --- a/userspace/libsinsp/container_info.cpp +++ b/userspace/libsinsp/container_info.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/container_info.h b/userspace/libsinsp/container_info.h index f47677ccaa..8863573f06 100644 --- a/userspace/libsinsp/container_info.h +++ b/userspace/libsinsp/container_info.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/cri.h b/userspace/libsinsp/cri.h index bde24f4dc9..4f0b2d313b 100644 --- a/userspace/libsinsp/cri.h +++ b/userspace/libsinsp/cri.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/cyclewriter.cpp b/userspace/libsinsp/cyclewriter.cpp index 377cb28425..b9df55f70e 100644 --- a/userspace/libsinsp/cyclewriter.cpp +++ b/userspace/libsinsp/cyclewriter.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/cyclewriter.h b/userspace/libsinsp/cyclewriter.h index 82a5fdf75f..72e49e9a09 100644 --- a/userspace/libsinsp/cyclewriter.h +++ b/userspace/libsinsp/cyclewriter.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/dns_manager.cpp b/userspace/libsinsp/dns_manager.cpp index e6c5f40749..96aaebc7cc 100644 --- a/userspace/libsinsp/dns_manager.cpp +++ b/userspace/libsinsp/dns_manager.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/dns_manager.h b/userspace/libsinsp/dns_manager.h index 4d84f4fd69..bd5193cc85 100644 --- a/userspace/libsinsp/dns_manager.h +++ b/userspace/libsinsp/dns_manager.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/dumper.cpp b/userspace/libsinsp/dumper.cpp index 692ed92278..997675be5a 100644 --- a/userspace/libsinsp/dumper.cpp +++ b/userspace/libsinsp/dumper.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/dumper.h b/userspace/libsinsp/dumper.h index e16a4b7916..89e1a290ff 100644 --- a/userspace/libsinsp/dumper.h +++ b/userspace/libsinsp/dumper.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/event.cpp b/userspace/libsinsp/event.cpp index 199fdb4ed5..65c50e9bbf 100644 --- a/userspace/libsinsp/event.cpp +++ b/userspace/libsinsp/event.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/event.h b/userspace/libsinsp/event.h index 4a0553b6e5..9125f08250 100644 --- a/userspace/libsinsp/event.h +++ b/userspace/libsinsp/event.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/eventformatter.cpp b/userspace/libsinsp/eventformatter.cpp index 8da8ec8199..e247c42b8b 100644 --- a/userspace/libsinsp/eventformatter.cpp +++ b/userspace/libsinsp/eventformatter.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/eventformatter.h b/userspace/libsinsp/eventformatter.h index f99db7eb62..1e3bb9e8a2 100644 --- a/userspace/libsinsp/eventformatter.h +++ b/userspace/libsinsp/eventformatter.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/events/sinsp_events.h b/userspace/libsinsp/events/sinsp_events.h index 1f243a6aac..4d55c928b3 100644 --- a/userspace/libsinsp/events/sinsp_events.h +++ b/userspace/libsinsp/events/sinsp_events.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/events/sinsp_events_ppm_sc.cpp b/userspace/libsinsp/events/sinsp_events_ppm_sc.cpp index 200285a9df..7f98e5ec9b 100644 --- a/userspace/libsinsp/events/sinsp_events_ppm_sc.cpp +++ b/userspace/libsinsp/events/sinsp_events_ppm_sc.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/events/sinsp_events_set.h b/userspace/libsinsp/events/sinsp_events_set.h index 88a7483109..06c505fd85 100644 --- a/userspace/libsinsp/events/sinsp_events_set.h +++ b/userspace/libsinsp/events/sinsp_events_set.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/examples/test.cpp b/userspace/libsinsp/examples/test.cpp index d1b2eec2de..2ee38745f6 100644 --- a/userspace/libsinsp/examples/test.cpp +++ b/userspace/libsinsp/examples/test.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/examples/util.cpp b/userspace/libsinsp/examples/util.cpp index cc25860b83..88c5a6772e 100644 --- a/userspace/libsinsp/examples/util.cpp +++ b/userspace/libsinsp/examples/util.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/examples/util.h b/userspace/libsinsp/examples/util.h index 271b4d64c1..aead9448e8 100644 --- a/userspace/libsinsp/examples/util.h +++ b/userspace/libsinsp/examples/util.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. @@ -25,4 +26,4 @@ std::string get_event_category_name(ppm_event_category category); // // Get the string representation of a ppm_event_type // -std::string get_event_type_name(sinsp_evt *ev); \ No newline at end of file +std::string get_event_type_name(sinsp_evt *ev); diff --git a/userspace/libsinsp/fdinfo.cpp b/userspace/libsinsp/fdinfo.cpp index 84c5d96644..85b1ef8d21 100644 --- a/userspace/libsinsp/fdinfo.cpp +++ b/userspace/libsinsp/fdinfo.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/fdinfo.h b/userspace/libsinsp/fdinfo.h index 02ed7d0d73..2b341429d6 100644 --- a/userspace/libsinsp/fdinfo.h +++ b/userspace/libsinsp/fdinfo.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/filter.cpp b/userspace/libsinsp/filter.cpp index c502b1fff0..c4306efcb5 100644 --- a/userspace/libsinsp/filter.cpp +++ b/userspace/libsinsp/filter.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/filter.h b/userspace/libsinsp/filter.h index a3b31d1d1a..2804f9a9f8 100644 --- a/userspace/libsinsp/filter.h +++ b/userspace/libsinsp/filter.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/filter/ast.cpp b/userspace/libsinsp/filter/ast.cpp index a6159b5413..7acdbc6def 100644 --- a/userspace/libsinsp/filter/ast.cpp +++ b/userspace/libsinsp/filter/ast.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/filter/ast.h b/userspace/libsinsp/filter/ast.h index f5aea20a40..ba03b4c835 100644 --- a/userspace/libsinsp/filter/ast.h +++ b/userspace/libsinsp/filter/ast.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/filter/escaping.cpp b/userspace/libsinsp/filter/escaping.cpp index d968e73d86..2b93ddf2be 100644 --- a/userspace/libsinsp/filter/escaping.cpp +++ b/userspace/libsinsp/filter/escaping.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/filter/escaping.h b/userspace/libsinsp/filter/escaping.h index 26c216f74e..a41fccb9e5 100644 --- a/userspace/libsinsp/filter/escaping.h +++ b/userspace/libsinsp/filter/escaping.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/filter/parser.cpp b/userspace/libsinsp/filter/parser.cpp index 487d58f1d8..ae149d750f 100644 --- a/userspace/libsinsp/filter/parser.cpp +++ b/userspace/libsinsp/filter/parser.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/filter/parser.h b/userspace/libsinsp/filter/parser.h index 88aed547cf..5ce19eb5df 100644 --- a/userspace/libsinsp/filter/parser.h +++ b/userspace/libsinsp/filter/parser.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/filter/ppm_codes.cpp b/userspace/libsinsp/filter/ppm_codes.cpp index 7fa5190f91..7adb53fe84 100644 --- a/userspace/libsinsp/filter/ppm_codes.cpp +++ b/userspace/libsinsp/filter/ppm_codes.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/filter/ppm_codes.h b/userspace/libsinsp/filter/ppm_codes.h index d5345955e2..e2b280fc47 100644 --- a/userspace/libsinsp/filter/ppm_codes.h +++ b/userspace/libsinsp/filter/ppm_codes.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/filter_check_list.cpp b/userspace/libsinsp/filter_check_list.cpp index c8675f0924..53c7984bb0 100644 --- a/userspace/libsinsp/filter_check_list.cpp +++ b/userspace/libsinsp/filter_check_list.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/filter_check_list.h b/userspace/libsinsp/filter_check_list.h index 4feb5ad561..3ffa06fc95 100644 --- a/userspace/libsinsp/filter_check_list.h +++ b/userspace/libsinsp/filter_check_list.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/filter_value.h b/userspace/libsinsp/filter_value.h index bd5f202691..24d3c01678 100644 --- a/userspace/libsinsp/filter_value.h +++ b/userspace/libsinsp/filter_value.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/filterchecks.cpp b/userspace/libsinsp/filterchecks.cpp index 1d82d16e9d..0ade8ca990 100644 --- a/userspace/libsinsp/filterchecks.cpp +++ b/userspace/libsinsp/filterchecks.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/filterchecks.h b/userspace/libsinsp/filterchecks.h index f4668ea2eb..4055793267 100644 --- a/userspace/libsinsp/filterchecks.h +++ b/userspace/libsinsp/filterchecks.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/gen_filter.cpp b/userspace/libsinsp/gen_filter.cpp index e83a25ff91..8245c81b33 100644 --- a/userspace/libsinsp/gen_filter.cpp +++ b/userspace/libsinsp/gen_filter.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/gen_filter.h b/userspace/libsinsp/gen_filter.h index 05eef13467..7e522a4e3b 100644 --- a/userspace/libsinsp/gen_filter.h +++ b/userspace/libsinsp/gen_filter.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/grpc_channel_registry.cpp b/userspace/libsinsp/grpc_channel_registry.cpp index 7220aade8b..88dde54fa5 100644 --- a/userspace/libsinsp/grpc_channel_registry.cpp +++ b/userspace/libsinsp/grpc_channel_registry.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/grpc_channel_registry.h b/userspace/libsinsp/grpc_channel_registry.h index 58cdbeb7b8..17cc86bffe 100644 --- a/userspace/libsinsp/grpc_channel_registry.h +++ b/userspace/libsinsp/grpc_channel_registry.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/gvisor_config.cpp b/userspace/libsinsp/gvisor_config.cpp index 916ab098ee..12540d38a2 100644 --- a/userspace/libsinsp/gvisor_config.cpp +++ b/userspace/libsinsp/gvisor_config.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/gvisor_config.h b/userspace/libsinsp/gvisor_config.h index 4ca6215a28..93a90f6bf8 100644 --- a/userspace/libsinsp/gvisor_config.h +++ b/userspace/libsinsp/gvisor_config.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. @@ -22,4 +23,4 @@ limitations under the License. namespace gvisor_config { std::string generate(std::string socket_path); -} \ No newline at end of file +} diff --git a/userspace/libsinsp/http_reason.cpp b/userspace/libsinsp/http_reason.cpp index 670dd94bc0..a093e56778 100644 --- a/userspace/libsinsp/http_reason.cpp +++ b/userspace/libsinsp/http_reason.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/http_reason.h b/userspace/libsinsp/http_reason.h index a6a320f745..35921a9834 100644 --- a/userspace/libsinsp/http_reason.h +++ b/userspace/libsinsp/http_reason.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/ifinfo.cpp b/userspace/libsinsp/ifinfo.cpp index 3ec04f68d7..a78df88431 100644 --- a/userspace/libsinsp/ifinfo.cpp +++ b/userspace/libsinsp/ifinfo.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/ifinfo.h b/userspace/libsinsp/ifinfo.h index ff0a8520d9..37e65dc551 100644 --- a/userspace/libsinsp/ifinfo.h +++ b/userspace/libsinsp/ifinfo.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/ifinfo_test.cpp b/userspace/libsinsp/ifinfo_test.cpp index eb7c35d8ca..5bce766254 100644 --- a/userspace/libsinsp/ifinfo_test.cpp +++ b/userspace/libsinsp/ifinfo_test.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. @@ -126,4 +127,4 @@ TEST(sinsp_network_interfaces, infer_defaults_to_first_non_loopback) interfaces.m_ipv4_interfaces.push_back(make_ipv4_interface("192.168.22.149", "255.255.255.0", "192.168.22.255", "eth0")); interfaces.m_ipv4_interfaces.push_back(make_ipv4_interface("192.168.22.150", "255.255.255.0", "192.168.22.255", "eth1")); EXPECT_ADDR_EQ("192.168.22.149",interfaces.infer_ipv4_address(parse_ipv4_addr("193.168.22.11"))); -} \ No newline at end of file +} diff --git a/userspace/libsinsp/internal_metrics.cpp b/userspace/libsinsp/internal_metrics.cpp index 51821b9609..7ddea2282d 100644 --- a/userspace/libsinsp/internal_metrics.cpp +++ b/userspace/libsinsp/internal_metrics.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/internal_metrics.h b/userspace/libsinsp/internal_metrics.h index 0b27d6a81c..bac9580449 100644 --- a/userspace/libsinsp/internal_metrics.h +++ b/userspace/libsinsp/internal_metrics.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/json_error_log.cpp b/userspace/libsinsp/json_error_log.cpp index adf2f466f3..027cb1699a 100644 --- a/userspace/libsinsp/json_error_log.cpp +++ b/userspace/libsinsp/json_error_log.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/json_error_log.h b/userspace/libsinsp/json_error_log.h index 19c54164b3..5a3182e98d 100644 --- a/userspace/libsinsp/json_error_log.h +++ b/userspace/libsinsp/json_error_log.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/json_query.cpp b/userspace/libsinsp/json_query.cpp index 4b805571a7..92eed19256 100644 --- a/userspace/libsinsp/json_query.cpp +++ b/userspace/libsinsp/json_query.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/json_query.h b/userspace/libsinsp/json_query.h index 0cbe2f20d4..6f046a9bed 100644 --- a/userspace/libsinsp/json_query.h +++ b/userspace/libsinsp/json_query.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/k8s.cpp b/userspace/libsinsp/k8s.cpp index d336da3ae9..67c94496ef 100644 --- a/userspace/libsinsp/k8s.cpp +++ b/userspace/libsinsp/k8s.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/k8s.h b/userspace/libsinsp/k8s.h index 4e1aba8727..88bc97a808 100644 --- a/userspace/libsinsp/k8s.h +++ b/userspace/libsinsp/k8s.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. @@ -149,4 +150,4 @@ inline void k8s::set_machine_id(const std::string& machine_id) } #endif // HAS_CAPTURE } -#endif // MINIMAL_BUILD \ No newline at end of file +#endif // MINIMAL_BUILD diff --git a/userspace/libsinsp/k8s_api_error.cpp b/userspace/libsinsp/k8s_api_error.cpp index e55b0e6bf9..7120a6aec9 100644 --- a/userspace/libsinsp/k8s_api_error.cpp +++ b/userspace/libsinsp/k8s_api_error.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/k8s_api_error.h b/userspace/libsinsp/k8s_api_error.h index 5d1baaa2ed..a24b837fab 100644 --- a/userspace/libsinsp/k8s_api_error.h +++ b/userspace/libsinsp/k8s_api_error.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. @@ -120,4 +121,4 @@ inline std::string k8s_api_error::to_string() const "Code: " << m_message; return os.str(); } -#endif // MINIMAL_BUILD \ No newline at end of file +#endif // MINIMAL_BUILD diff --git a/userspace/libsinsp/k8s_api_handler.cpp b/userspace/libsinsp/k8s_api_handler.cpp index b0e2ad00c7..943193643c 100644 --- a/userspace/libsinsp/k8s_api_handler.cpp +++ b/userspace/libsinsp/k8s_api_handler.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/k8s_api_handler.h b/userspace/libsinsp/k8s_api_handler.h index 09bb082506..89228d498b 100644 --- a/userspace/libsinsp/k8s_api_handler.h +++ b/userspace/libsinsp/k8s_api_handler.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/k8s_component.cpp b/userspace/libsinsp/k8s_component.cpp index da076329a8..155af9572b 100644 --- a/userspace/libsinsp/k8s_component.cpp +++ b/userspace/libsinsp/k8s_component.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/k8s_component.h b/userspace/libsinsp/k8s_component.h index 77c56bd47f..0656ee3730 100644 --- a/userspace/libsinsp/k8s_component.h +++ b/userspace/libsinsp/k8s_component.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. @@ -1064,4 +1065,4 @@ inline bool k8s_event_t::has_pending_events() const { return m_postponed_events.size() != 0; } -#endif // MINIMAL_BUILD \ No newline at end of file +#endif // MINIMAL_BUILD diff --git a/userspace/libsinsp/k8s_daemonset_handler.cpp b/userspace/libsinsp/k8s_daemonset_handler.cpp index dea477b19d..de3e515c17 100644 --- a/userspace/libsinsp/k8s_daemonset_handler.cpp +++ b/userspace/libsinsp/k8s_daemonset_handler.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/k8s_daemonset_handler.h b/userspace/libsinsp/k8s_daemonset_handler.h index 8520b6086c..71e023dbd4 100644 --- a/userspace/libsinsp/k8s_daemonset_handler.h +++ b/userspace/libsinsp/k8s_daemonset_handler.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. @@ -53,4 +54,4 @@ class k8s_daemonset_handler : public k8s_handler virtual bool handle_component(const Json::Value& json, const msg_data* data = 0); }; -#endif // MINIMAL_BUILD \ No newline at end of file +#endif // MINIMAL_BUILD diff --git a/userspace/libsinsp/k8s_deployment_handler.cpp b/userspace/libsinsp/k8s_deployment_handler.cpp index f1914a06af..06c09b8f86 100644 --- a/userspace/libsinsp/k8s_deployment_handler.cpp +++ b/userspace/libsinsp/k8s_deployment_handler.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/k8s_deployment_handler.h b/userspace/libsinsp/k8s_deployment_handler.h index e310ed1138..49c93a9c9d 100644 --- a/userspace/libsinsp/k8s_deployment_handler.h +++ b/userspace/libsinsp/k8s_deployment_handler.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. @@ -53,4 +54,4 @@ class k8s_deployment_handler : public k8s_handler virtual bool handle_component(const Json::Value& json, const msg_data* data = 0); }; -#endif // MINIMAL_BUILD \ No newline at end of file +#endif // MINIMAL_BUILD diff --git a/userspace/libsinsp/k8s_dispatcher.cpp b/userspace/libsinsp/k8s_dispatcher.cpp index ff8851eee4..9d3c91dbee 100644 --- a/userspace/libsinsp/k8s_dispatcher.cpp +++ b/userspace/libsinsp/k8s_dispatcher.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/k8s_dispatcher.h b/userspace/libsinsp/k8s_dispatcher.h index 56ed8f08cf..a7b031c654 100644 --- a/userspace/libsinsp/k8s_dispatcher.h +++ b/userspace/libsinsp/k8s_dispatcher.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. @@ -226,4 +227,4 @@ inline void k8s_dispatcher::remove() m_messages.pop_front(); } -#endif // MINIMAL_BUILD \ No newline at end of file +#endif // MINIMAL_BUILD diff --git a/userspace/libsinsp/k8s_event_data.cpp b/userspace/libsinsp/k8s_event_data.cpp index f1354a0bbf..9df3b22e48 100644 --- a/userspace/libsinsp/k8s_event_data.cpp +++ b/userspace/libsinsp/k8s_event_data.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/k8s_event_data.h b/userspace/libsinsp/k8s_event_data.h index d0348b11ed..00a064dbf3 100644 --- a/userspace/libsinsp/k8s_event_data.h +++ b/userspace/libsinsp/k8s_event_data.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. @@ -56,4 +57,4 @@ inline std::string k8s_event_data::data() const { return m_data; } -#endif // MINIMAL_BUILD \ No newline at end of file +#endif // MINIMAL_BUILD diff --git a/userspace/libsinsp/k8s_event_handler.cpp b/userspace/libsinsp/k8s_event_handler.cpp index 9a847b58e9..5660892772 100644 --- a/userspace/libsinsp/k8s_event_handler.cpp +++ b/userspace/libsinsp/k8s_event_handler.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/k8s_event_handler.h b/userspace/libsinsp/k8s_event_handler.h index a10805d5c2..6a9b67cbe6 100644 --- a/userspace/libsinsp/k8s_event_handler.h +++ b/userspace/libsinsp/k8s_event_handler.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. @@ -59,4 +60,4 @@ class k8s_event_handler : public k8s_handler bool m_event_limit_exceeded = false; }; -#endif // MINIMAL_BUILD \ No newline at end of file +#endif // MINIMAL_BUILD diff --git a/userspace/libsinsp/k8s_handler.cpp b/userspace/libsinsp/k8s_handler.cpp index ccbbe4e3dd..ad7776892f 100644 --- a/userspace/libsinsp/k8s_handler.cpp +++ b/userspace/libsinsp/k8s_handler.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/k8s_handler.h b/userspace/libsinsp/k8s_handler.h index 10292173f7..67b7910d78 100644 --- a/userspace/libsinsp/k8s_handler.h +++ b/userspace/libsinsp/k8s_handler.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. @@ -314,4 +315,4 @@ class k8s_dummy_handler : public k8s_handler }; }; -#endif // MINIMAL_BUILD \ No newline at end of file +#endif // MINIMAL_BUILD diff --git a/userspace/libsinsp/k8s_namespace_handler.cpp b/userspace/libsinsp/k8s_namespace_handler.cpp index 8163ad493d..a6f69efd72 100644 --- a/userspace/libsinsp/k8s_namespace_handler.cpp +++ b/userspace/libsinsp/k8s_namespace_handler.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/k8s_namespace_handler.h b/userspace/libsinsp/k8s_namespace_handler.h index cbf6e164a9..c16ef67ce8 100644 --- a/userspace/libsinsp/k8s_namespace_handler.h +++ b/userspace/libsinsp/k8s_namespace_handler.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. @@ -51,4 +52,4 @@ class k8s_namespace_handler : public k8s_handler bool handle_component(const Json::Value& json, const msg_data* data = 0); }; -#endif // MINIMAL_BUILD \ No newline at end of file +#endif // MINIMAL_BUILD diff --git a/userspace/libsinsp/k8s_net.cpp b/userspace/libsinsp/k8s_net.cpp index 946f8d6784..294b3d8542 100644 --- a/userspace/libsinsp/k8s_net.cpp +++ b/userspace/libsinsp/k8s_net.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/k8s_net.h b/userspace/libsinsp/k8s_net.h index f7df19b0dd..8079f17fa1 100644 --- a/userspace/libsinsp/k8s_net.h +++ b/userspace/libsinsp/k8s_net.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. @@ -182,4 +183,4 @@ namespace k8s_net #endif // HAS_CAPTURE -#endif // MINIMAL_BUILD \ No newline at end of file +#endif // MINIMAL_BUILD diff --git a/userspace/libsinsp/k8s_node_handler.cpp b/userspace/libsinsp/k8s_node_handler.cpp index 781c223b0c..9262ef46b7 100644 --- a/userspace/libsinsp/k8s_node_handler.cpp +++ b/userspace/libsinsp/k8s_node_handler.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/k8s_node_handler.h b/userspace/libsinsp/k8s_node_handler.h index 1ac85841d2..d38cd86a65 100644 --- a/userspace/libsinsp/k8s_node_handler.h +++ b/userspace/libsinsp/k8s_node_handler.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. @@ -52,4 +53,4 @@ class k8s_node_handler : public k8s_handler virtual bool handle_component(const Json::Value& json, const msg_data* data = 0); }; -#endif // MINIMAL_BUILD \ No newline at end of file +#endif // MINIMAL_BUILD diff --git a/userspace/libsinsp/k8s_pod_handler.cpp b/userspace/libsinsp/k8s_pod_handler.cpp index fc737e37f4..f857498bf2 100644 --- a/userspace/libsinsp/k8s_pod_handler.cpp +++ b/userspace/libsinsp/k8s_pod_handler.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/k8s_pod_handler.h b/userspace/libsinsp/k8s_pod_handler.h index fb1792dffe..1fbf80f36b 100644 --- a/userspace/libsinsp/k8s_pod_handler.h +++ b/userspace/libsinsp/k8s_pod_handler.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. @@ -58,4 +59,4 @@ class k8s_pod_handler : public k8s_handler virtual bool handle_component(const Json::Value& json, const msg_data* data = 0); }; -#endif // MINIMAL_BUILD \ No newline at end of file +#endif // MINIMAL_BUILD diff --git a/userspace/libsinsp/k8s_replicaset_handler.cpp b/userspace/libsinsp/k8s_replicaset_handler.cpp index 446ad03543..6ea9167c7b 100644 --- a/userspace/libsinsp/k8s_replicaset_handler.cpp +++ b/userspace/libsinsp/k8s_replicaset_handler.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/k8s_replicaset_handler.h b/userspace/libsinsp/k8s_replicaset_handler.h index 1ebd320743..c2aa352d83 100644 --- a/userspace/libsinsp/k8s_replicaset_handler.h +++ b/userspace/libsinsp/k8s_replicaset_handler.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. @@ -53,4 +54,4 @@ class k8s_replicaset_handler : public k8s_handler virtual bool handle_component(const Json::Value& json, const msg_data* data = 0); }; -#endif // MINIMAL_BUILD \ No newline at end of file +#endif // MINIMAL_BUILD diff --git a/userspace/libsinsp/k8s_replicationcontroller_handler.cpp b/userspace/libsinsp/k8s_replicationcontroller_handler.cpp index 9039d54ee9..3ed966fbbe 100644 --- a/userspace/libsinsp/k8s_replicationcontroller_handler.cpp +++ b/userspace/libsinsp/k8s_replicationcontroller_handler.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/k8s_replicationcontroller_handler.h b/userspace/libsinsp/k8s_replicationcontroller_handler.h index b3a1b135bc..61add0cc30 100644 --- a/userspace/libsinsp/k8s_replicationcontroller_handler.h +++ b/userspace/libsinsp/k8s_replicationcontroller_handler.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. @@ -53,4 +54,4 @@ class k8s_replicationcontroller_handler : public k8s_handler virtual bool handle_component(const Json::Value& json, const msg_data* data = 0); }; -#endif // MINIMAL_BUILD \ No newline at end of file +#endif // MINIMAL_BUILD diff --git a/userspace/libsinsp/k8s_service_handler.cpp b/userspace/libsinsp/k8s_service_handler.cpp index 2198b3e513..0b0195e51f 100644 --- a/userspace/libsinsp/k8s_service_handler.cpp +++ b/userspace/libsinsp/k8s_service_handler.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. @@ -251,4 +252,4 @@ bool k8s_service_handler::handle_component(const Json::Value& json, const msg_da } return true; } -#endif \ No newline at end of file +#endif diff --git a/userspace/libsinsp/k8s_service_handler.h b/userspace/libsinsp/k8s_service_handler.h index 115060da0a..e34f95d846 100644 --- a/userspace/libsinsp/k8s_service_handler.h +++ b/userspace/libsinsp/k8s_service_handler.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. @@ -54,4 +55,4 @@ class k8s_service_handler : public k8s_handler virtual bool handle_component(const Json::Value& json, const msg_data* data = 0); }; -#endif // MINIMAL_BUILD \ No newline at end of file +#endif // MINIMAL_BUILD diff --git a/userspace/libsinsp/k8s_state.cpp b/userspace/libsinsp/k8s_state.cpp index f5e0c0b8a5..32b1533c46 100644 --- a/userspace/libsinsp/k8s_state.cpp +++ b/userspace/libsinsp/k8s_state.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/k8s_state.h b/userspace/libsinsp/k8s_state.h index 660e9a1b41..c82ea9049a 100644 --- a/userspace/libsinsp/k8s_state.h +++ b/userspace/libsinsp/k8s_state.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. @@ -660,4 +661,4 @@ inline int k8s_state_t::get_capture_version() const return m_capture_version; } -#endif // MINIMAL_BUILD \ No newline at end of file +#endif // MINIMAL_BUILD diff --git a/userspace/libsinsp/logger.cpp b/userspace/libsinsp/logger.cpp index f81f3d5284..3111159964 100644 --- a/userspace/libsinsp/logger.cpp +++ b/userspace/libsinsp/logger.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/logger.h b/userspace/libsinsp/logger.h index fd8167b744..d9ba8f22ce 100644 --- a/userspace/libsinsp/logger.h +++ b/userspace/libsinsp/logger.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/marathon_component.cpp b/userspace/libsinsp/marathon_component.cpp index 8f635b96a6..dabda7db99 100644 --- a/userspace/libsinsp/marathon_component.cpp +++ b/userspace/libsinsp/marathon_component.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/marathon_component.h b/userspace/libsinsp/marathon_component.h index a94cc0b584..185420d7f2 100644 --- a/userspace/libsinsp/marathon_component.h +++ b/userspace/libsinsp/marathon_component.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. @@ -256,4 +257,4 @@ inline const mesos_pair_list& marathon_app::get_labels() const return m_labels; } -#endif // MINIMAL_BUILD \ No newline at end of file +#endif // MINIMAL_BUILD diff --git a/userspace/libsinsp/marathon_http.cpp b/userspace/libsinsp/marathon_http.cpp index 680e544cb7..b83db829d9 100644 --- a/userspace/libsinsp/marathon_http.cpp +++ b/userspace/libsinsp/marathon_http.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/marathon_http.h b/userspace/libsinsp/marathon_http.h index 73468b52b8..981daf16a9 100644 --- a/userspace/libsinsp/marathon_http.h +++ b/userspace/libsinsp/marathon_http.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. @@ -45,4 +46,4 @@ class marathon_http : public mesos_http }; #endif // HAS_CAPTURE -#endif // MINIMAL_BUILD \ No newline at end of file +#endif // MINIMAL_BUILD diff --git a/userspace/libsinsp/memmem.cpp b/userspace/libsinsp/memmem.cpp index b1a6beacc5..b3b3a19916 100644 --- a/userspace/libsinsp/memmem.cpp +++ b/userspace/libsinsp/memmem.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/mesos.cpp b/userspace/libsinsp/mesos.cpp index a127c12fd0..c29d093e85 100644 --- a/userspace/libsinsp/mesos.cpp +++ b/userspace/libsinsp/mesos.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/mesos.h b/userspace/libsinsp/mesos.h index 9b77ac715d..10a561e257 100644 --- a/userspace/libsinsp/mesos.h +++ b/userspace/libsinsp/mesos.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. @@ -263,4 +264,4 @@ inline void mesos::parse_groups(Json::Value&& json, const std::string& framework m_state.parse_groups(std::move(json), framework_id); } -#endif // MINIMAL_BUILD \ No newline at end of file +#endif // MINIMAL_BUILD diff --git a/userspace/libsinsp/mesos_auth.cpp b/userspace/libsinsp/mesos_auth.cpp index b0ed740aee..5bc25ddf3a 100644 --- a/userspace/libsinsp/mesos_auth.cpp +++ b/userspace/libsinsp/mesos_auth.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/mesos_auth.h b/userspace/libsinsp/mesos_auth.h index a24f0b371d..14d2db662b 100644 --- a/userspace/libsinsp/mesos_auth.h +++ b/userspace/libsinsp/mesos_auth.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. @@ -55,4 +56,4 @@ class mesos_auth time_t m_last_token_refresh_s; }; -#endif // MINIMAL_BUILD \ No newline at end of file +#endif // MINIMAL_BUILD diff --git a/userspace/libsinsp/mesos_collector.cpp b/userspace/libsinsp/mesos_collector.cpp index 5848e3c140..4e40bc6342 100644 --- a/userspace/libsinsp/mesos_collector.cpp +++ b/userspace/libsinsp/mesos_collector.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/mesos_collector.h b/userspace/libsinsp/mesos_collector.h index ee01abb9d3..95d4825358 100644 --- a/userspace/libsinsp/mesos_collector.h +++ b/userspace/libsinsp/mesos_collector.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. @@ -72,4 +73,4 @@ inline void mesos_collector::stop() } #endif // HAS_CAPTURE -#endif // MINIMAL_BUILD \ No newline at end of file +#endif // MINIMAL_BUILD diff --git a/userspace/libsinsp/mesos_common.h b/userspace/libsinsp/mesos_common.h index 4286f827df..3c19f69b04 100644 --- a/userspace/libsinsp/mesos_common.h +++ b/userspace/libsinsp/mesos_common.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/mesos_component.cpp b/userspace/libsinsp/mesos_component.cpp index ea3cc7d4f1..85e554f26d 100644 --- a/userspace/libsinsp/mesos_component.cpp +++ b/userspace/libsinsp/mesos_component.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/mesos_component.h b/userspace/libsinsp/mesos_component.h index 9e639d4203..cf4f1972fc 100644 --- a/userspace/libsinsp/mesos_component.h +++ b/userspace/libsinsp/mesos_component.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. @@ -292,4 +293,4 @@ inline bool mesos_framework::is_root_marathon(const std::string& name) // task // -#endif // MINIMAL_BUILD \ No newline at end of file +#endif // MINIMAL_BUILD diff --git a/userspace/libsinsp/mesos_http.cpp b/userspace/libsinsp/mesos_http.cpp index de4989bf83..41901255cf 100644 --- a/userspace/libsinsp/mesos_http.cpp +++ b/userspace/libsinsp/mesos_http.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/mesos_http.h b/userspace/libsinsp/mesos_http.h index 9da2106997..a77845d956 100644 --- a/userspace/libsinsp/mesos_http.h +++ b/userspace/libsinsp/mesos_http.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. @@ -261,4 +262,4 @@ class mesos_http }; #endif // HAS_CAPTURE -#endif // MINIMAL_BUILD \ No newline at end of file +#endif // MINIMAL_BUILD diff --git a/userspace/libsinsp/mesos_state.cpp b/userspace/libsinsp/mesos_state.cpp index d6a1856b37..a1195d095d 100644 --- a/userspace/libsinsp/mesos_state.cpp +++ b/userspace/libsinsp/mesos_state.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/mesos_state.h b/userspace/libsinsp/mesos_state.h index b93674b3d1..b79951ab4f 100644 --- a/userspace/libsinsp/mesos_state.h +++ b/userspace/libsinsp/mesos_state.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/mutex.h b/userspace/libsinsp/mutex.h index 50a5f2e5ab..d561f305ec 100644 --- a/userspace/libsinsp/mutex.h +++ b/userspace/libsinsp/mutex.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. @@ -177,4 +178,4 @@ class Mutex { mutable std::mutex m_lock; T m_inner; }; -} \ No newline at end of file +} diff --git a/userspace/libsinsp/parsers.cpp b/userspace/libsinsp/parsers.cpp index c48f3c0aae..91bc157e70 100644 --- a/userspace/libsinsp/parsers.cpp +++ b/userspace/libsinsp/parsers.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/parsers.h b/userspace/libsinsp/parsers.h index cbdf9a4237..0b53d2e431 100644 --- a/userspace/libsinsp/parsers.h +++ b/userspace/libsinsp/parsers.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/plugin.cpp b/userspace/libsinsp/plugin.cpp index b089d4b1e3..2a24581c22 100755 --- a/userspace/libsinsp/plugin.cpp +++ b/userspace/libsinsp/plugin.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/plugin.h b/userspace/libsinsp/plugin.h index b2639b3a4a..c3cf8ad5b1 100755 --- a/userspace/libsinsp/plugin.h +++ b/userspace/libsinsp/plugin.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/plugin_filtercheck.cpp b/userspace/libsinsp/plugin_filtercheck.cpp index 5f925fffe1..38d047d62d 100755 --- a/userspace/libsinsp/plugin_filtercheck.cpp +++ b/userspace/libsinsp/plugin_filtercheck.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/plugin_filtercheck.h b/userspace/libsinsp/plugin_filtercheck.h index ae4d761dee..34335c60e8 100755 --- a/userspace/libsinsp/plugin_filtercheck.h +++ b/userspace/libsinsp/plugin_filtercheck.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/plugin_manager.h b/userspace/libsinsp/plugin_manager.h index 0162ae7f1c..4948e7d91a 100755 --- a/userspace/libsinsp/plugin_manager.h +++ b/userspace/libsinsp/plugin_manager.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/plugin_parser.h b/userspace/libsinsp/plugin_parser.h index 0ba3dd6877..1453a2df1d 100644 --- a/userspace/libsinsp/plugin_parser.h +++ b/userspace/libsinsp/plugin_parser.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. Licensed under the Apache License, Version 2.0 (the "License"); @@ -86,4 +87,4 @@ class sinsp_plugin_parser private: std::shared_ptr m_plugin; std::vector m_compatible_plugin_sources_bitmap; -}; \ No newline at end of file +}; diff --git a/userspace/libsinsp/plugin_table_api.cpp b/userspace/libsinsp/plugin_table_api.cpp index dcf389a588..31dd316321 100755 --- a/userspace/libsinsp/plugin_table_api.cpp +++ b/userspace/libsinsp/plugin_table_api.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/prefix_search.cpp b/userspace/libsinsp/prefix_search.cpp index ea87f890b4..97c441c8ff 100644 --- a/userspace/libsinsp/prefix_search.cpp +++ b/userspace/libsinsp/prefix_search.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/prefix_search.h b/userspace/libsinsp/prefix_search.h index 4dcac0652e..f36ac46e75 100644 --- a/userspace/libsinsp/prefix_search.h +++ b/userspace/libsinsp/prefix_search.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/procfs_utils.cpp b/userspace/libsinsp/procfs_utils.cpp index f6014d5a40..646ff789cf 100644 --- a/userspace/libsinsp/procfs_utils.cpp +++ b/userspace/libsinsp/procfs_utils.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/procinfo_test.cpp b/userspace/libsinsp/procinfo_test.cpp index b7d0fac7dc..4aa1b8ea0d 100644 --- a/userspace/libsinsp/procinfo_test.cpp +++ b/userspace/libsinsp/procinfo_test.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/protodecoder.cpp b/userspace/libsinsp/protodecoder.cpp index c0480e43e3..f54303d9ad 100644 --- a/userspace/libsinsp/protodecoder.cpp +++ b/userspace/libsinsp/protodecoder.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/protodecoder.h b/userspace/libsinsp/protodecoder.h index ea9613fb81..17b4b83b78 100644 --- a/userspace/libsinsp/protodecoder.h +++ b/userspace/libsinsp/protodecoder.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/runc.cpp b/userspace/libsinsp/runc.cpp index 518fabd498..f6d9377b83 100644 --- a/userspace/libsinsp/runc.cpp +++ b/userspace/libsinsp/runc.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. @@ -95,4 +96,4 @@ bool matches_runc_cgroups(const sinsp_threadinfo *tinfo, const cgroup_layout *la return false; } } -} \ No newline at end of file +} diff --git a/userspace/libsinsp/runc.h b/userspace/libsinsp/runc.h index 471b025fa7..07feeba921 100644 --- a/userspace/libsinsp/runc.h +++ b/userspace/libsinsp/runc.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/scap_open_exception.h b/userspace/libsinsp/scap_open_exception.h index 68774564cf..e19099e50d 100644 --- a/userspace/libsinsp/scap_open_exception.h +++ b/userspace/libsinsp/scap_open_exception.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/settings.h b/userspace/libsinsp/settings.h index c79618a57a..bc2066f265 100644 --- a/userspace/libsinsp/settings.h +++ b/userspace/libsinsp/settings.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/sinsp.cpp b/userspace/libsinsp/sinsp.cpp index 0716fedbac..d449adc62a 100644 --- a/userspace/libsinsp/sinsp.cpp +++ b/userspace/libsinsp/sinsp.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/sinsp.h b/userspace/libsinsp/sinsp.h index 7a575e5056..f85ba802b4 100644 --- a/userspace/libsinsp/sinsp.h +++ b/userspace/libsinsp/sinsp.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/sinsp_auth.cpp b/userspace/libsinsp/sinsp_auth.cpp index 45f3f059fb..b9cbe16ea5 100644 --- a/userspace/libsinsp/sinsp_auth.cpp +++ b/userspace/libsinsp/sinsp_auth.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/sinsp_auth.h b/userspace/libsinsp/sinsp_auth.h index 606ebe5186..999fd96770 100644 --- a/userspace/libsinsp/sinsp_auth.h +++ b/userspace/libsinsp/sinsp_auth.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/sinsp_cgroup.cpp b/userspace/libsinsp/sinsp_cgroup.cpp index bfd428ddfe..bab231681c 100644 --- a/userspace/libsinsp/sinsp_cgroup.cpp +++ b/userspace/libsinsp/sinsp_cgroup.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/sinsp_cgroup.h b/userspace/libsinsp/sinsp_cgroup.h index 58e11bd821..ffbc1fdb94 100644 --- a/userspace/libsinsp/sinsp_cgroup.h +++ b/userspace/libsinsp/sinsp_cgroup.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/sinsp_curl.cpp b/userspace/libsinsp/sinsp_curl.cpp index 8c93ab68df..55d7cabbfa 100644 --- a/userspace/libsinsp/sinsp_curl.cpp +++ b/userspace/libsinsp/sinsp_curl.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/sinsp_curl.h b/userspace/libsinsp/sinsp_curl.h index de6442ecbc..ce1d37b2b4 100644 --- a/userspace/libsinsp/sinsp_curl.h +++ b/userspace/libsinsp/sinsp_curl.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/sinsp_errno.h b/userspace/libsinsp/sinsp_errno.h index 9d15442c02..cbc6c45fe8 100644 --- a/userspace/libsinsp/sinsp_errno.h +++ b/userspace/libsinsp/sinsp_errno.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/sinsp_event_source.h b/userspace/libsinsp/sinsp_event_source.h index 0a5ee63e67..17edf91b9a 100644 --- a/userspace/libsinsp/sinsp_event_source.h +++ b/userspace/libsinsp/sinsp_event_source.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/sinsp_exception.h b/userspace/libsinsp/sinsp_exception.h index e56bc71d63..432990d7b7 100644 --- a/userspace/libsinsp/sinsp_exception.h +++ b/userspace/libsinsp/sinsp_exception.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/sinsp_inet.h b/userspace/libsinsp/sinsp_inet.h index b0f40dd11f..4162c92e3b 100644 --- a/userspace/libsinsp/sinsp_inet.h +++ b/userspace/libsinsp/sinsp_inet.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/sinsp_int.h b/userspace/libsinsp/sinsp_int.h index e1736ddc10..f17e0339d0 100644 --- a/userspace/libsinsp/sinsp_int.h +++ b/userspace/libsinsp/sinsp_int.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/sinsp_observer.h b/userspace/libsinsp/sinsp_observer.h index 2e6db51866..75b20a8e5b 100644 --- a/userspace/libsinsp/sinsp_observer.h +++ b/userspace/libsinsp/sinsp_observer.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/sinsp_pd_callback_type.h b/userspace/libsinsp/sinsp_pd_callback_type.h index dfd8c6a876..c207013cba 100644 --- a/userspace/libsinsp/sinsp_pd_callback_type.h +++ b/userspace/libsinsp/sinsp_pd_callback_type.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/sinsp_public.h b/userspace/libsinsp/sinsp_public.h index 5b66e2f44f..c5312d955b 100644 --- a/userspace/libsinsp/sinsp_public.h +++ b/userspace/libsinsp/sinsp_public.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/sinsp_resource_utilization.cpp b/userspace/libsinsp/sinsp_resource_utilization.cpp index d907117ee2..cf1a350d89 100644 --- a/userspace/libsinsp/sinsp_resource_utilization.cpp +++ b/userspace/libsinsp/sinsp_resource_utilization.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/sinsp_resource_utilization.h b/userspace/libsinsp/sinsp_resource_utilization.h index 65f5f2f4de..1101956253 100644 --- a/userspace/libsinsp/sinsp_resource_utilization.h +++ b/userspace/libsinsp/sinsp_resource_utilization.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/sinsp_signal.h b/userspace/libsinsp/sinsp_signal.h index 2b15fcf874..eaf36e463e 100644 --- a/userspace/libsinsp/sinsp_signal.h +++ b/userspace/libsinsp/sinsp_signal.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/sinsp_test.cpp b/userspace/libsinsp/sinsp_test.cpp index f13ec68517..d2d81363d3 100644 --- a/userspace/libsinsp/sinsp_test.cpp +++ b/userspace/libsinsp/sinsp_test.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/socket_collector.h b/userspace/libsinsp/socket_collector.h index 920077af86..af6c39819c 100644 --- a/userspace/libsinsp/socket_collector.h +++ b/userspace/libsinsp/socket_collector.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. @@ -386,4 +387,4 @@ class socket_collector }; #endif // HAS_CAPTURE -#endif // MINIMAL_BUILD \ No newline at end of file +#endif // MINIMAL_BUILD diff --git a/userspace/libsinsp/socket_handler.h b/userspace/libsinsp/socket_handler.h index 29ed418213..713119fc9f 100644 --- a/userspace/libsinsp/socket_handler.h +++ b/userspace/libsinsp/socket_handler.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/state/dynamic_struct.h b/userspace/libsinsp/state/dynamic_struct.h index 5ac445f59c..ae6bfb67e7 100644 --- a/userspace/libsinsp/state/dynamic_struct.h +++ b/userspace/libsinsp/state/dynamic_struct.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/state/static_struct.h b/userspace/libsinsp/state/static_struct.h index e336e2a223..a51884fdf4 100644 --- a/userspace/libsinsp/state/static_struct.h +++ b/userspace/libsinsp/state/static_struct.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/state/table.h b/userspace/libsinsp/state/table.h index 62204f623a..a320d7a060 100644 --- a/userspace/libsinsp/state/table.h +++ b/userspace/libsinsp/state/table.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/userspace/libsinsp/state/table_registry.h b/userspace/libsinsp/state/table_registry.h index cd7cd8a26d..38529c2fb7 100644 --- a/userspace/libsinsp/state/table_registry.h +++ b/userspace/libsinsp/state/table_registry.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/userspace/libsinsp/state/type_info.h b/userspace/libsinsp/state/type_info.h index 70c07e39ad..6a8297123f 100644 --- a/userspace/libsinsp/state/type_info.h +++ b/userspace/libsinsp/state/type_info.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/stats.cpp b/userspace/libsinsp/stats.cpp index 30fc166dc5..fdd8ab7294 100644 --- a/userspace/libsinsp/stats.cpp +++ b/userspace/libsinsp/stats.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/stats.h b/userspace/libsinsp/stats.h index c98e750219..a38845e241 100644 --- a/userspace/libsinsp/stats.h +++ b/userspace/libsinsp/stats.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/stopwatch.cpp b/userspace/libsinsp/stopwatch.cpp index bd0b92dd21..ca8a859c08 100644 --- a/userspace/libsinsp/stopwatch.cpp +++ b/userspace/libsinsp/stopwatch.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/stopwatch.h b/userspace/libsinsp/stopwatch.h index 7fffe07aa3..ad69d17b2c 100644 --- a/userspace/libsinsp/stopwatch.h +++ b/userspace/libsinsp/stopwatch.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/test/CMakeLists.txt b/userspace/libsinsp/test/CMakeLists.txt index f7efc3804d..d2b19f42ad 100644 --- a/userspace/libsinsp/test/CMakeLists.txt +++ b/userspace/libsinsp/test/CMakeLists.txt @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: Apache-2.0 # # Copyright (C) 2023 The Falco Authors. # diff --git a/userspace/libsinsp/test/async_key_value_source.ut.cpp b/userspace/libsinsp/test/async_key_value_source.ut.cpp index e21f588a27..d2afa275e0 100644 --- a/userspace/libsinsp/test/async_key_value_source.ut.cpp +++ b/userspace/libsinsp/test/async_key_value_source.ut.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/test/cgroup_list_counter.ut.cpp b/userspace/libsinsp/test/cgroup_list_counter.ut.cpp index 12147b8cba..fad4fcb2f0 100644 --- a/userspace/libsinsp/test/cgroup_list_counter.ut.cpp +++ b/userspace/libsinsp/test/cgroup_list_counter.ut.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/test/classes/sinsp_thread_manager.cpp b/userspace/libsinsp/test/classes/sinsp_thread_manager.cpp index 8f50c09604..8def6b403e 100644 --- a/userspace/libsinsp/test/classes/sinsp_thread_manager.cpp +++ b/userspace/libsinsp/test/classes/sinsp_thread_manager.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/test/classes/sinsp_threadinfo.cpp b/userspace/libsinsp/test/classes/sinsp_threadinfo.cpp index c023a1c928..5105f32836 100644 --- a/userspace/libsinsp/test/classes/sinsp_threadinfo.cpp +++ b/userspace/libsinsp/test/classes/sinsp_threadinfo.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/test/classes/thread_group_info.cpp b/userspace/libsinsp/test/classes/thread_group_info.cpp index e1ab0cade3..3bef58a812 100644 --- a/userspace/libsinsp/test/classes/thread_group_info.cpp +++ b/userspace/libsinsp/test/classes/thread_group_info.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/test/classes/versions.cpp b/userspace/libsinsp/test/classes/versions.cpp index 0b92d6b9b0..a2984242a5 100644 --- a/userspace/libsinsp/test/classes/versions.cpp +++ b/userspace/libsinsp/test/classes/versions.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. @@ -85,4 +86,4 @@ TEST(versions, compatible_with) EXPECT_FALSE(a.compatible_with(sinsp_version("1.2.4"))); EXPECT_TRUE(a.compatible_with(sinsp_version("1.1.19"))); EXPECT_TRUE(a.compatible_with(a)); -} \ No newline at end of file +} diff --git a/userspace/libsinsp/test/container_info.ut.cpp b/userspace/libsinsp/test/container_info.ut.cpp index 36f08d51c8..b922b64250 100644 --- a/userspace/libsinsp/test/container_info.ut.cpp +++ b/userspace/libsinsp/test/container_info.ut.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/test/eventformatter.ut.cpp b/userspace/libsinsp/test/eventformatter.ut.cpp index 58c0ed0368..ffc73ce5f6 100644 --- a/userspace/libsinsp/test/eventformatter.ut.cpp +++ b/userspace/libsinsp/test/eventformatter.ut.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. @@ -38,4 +39,4 @@ TEST(eventformatter, get_field_names) ASSERT_NE(find(output_fields.begin(), output_fields.end(), "fd.type"), output_fields.end()); ASSERT_NE(find(output_fields.begin(), output_fields.end(), "proc.pid"), output_fields.end()); delete inspector; -} \ No newline at end of file +} diff --git a/userspace/libsinsp/test/events_evt.ut.cpp b/userspace/libsinsp/test/events_evt.ut.cpp index 8ba17f1b8e..f485663304 100644 --- a/userspace/libsinsp/test/events_evt.ut.cpp +++ b/userspace/libsinsp/test/events_evt.ut.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/test/events_file.ut.cpp b/userspace/libsinsp/test/events_file.ut.cpp index a3ac4c6c45..2ede48beeb 100644 --- a/userspace/libsinsp/test/events_file.ut.cpp +++ b/userspace/libsinsp/test/events_file.ut.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. @@ -712,4 +713,4 @@ TEST_F(sinsp_with_test_input, test_pidfd) ASSERT_EQ(get_field_as_string(evt, "fd.filename"), "the_file"); ASSERT_EQ(get_field_as_string(evt, "fd.typechar"),"f"); ASSERT_EQ(get_field_as_string(evt, "fd.type"),"file"); -} \ No newline at end of file +} diff --git a/userspace/libsinsp/test/events_fspath.ut.cpp b/userspace/libsinsp/test/events_fspath.ut.cpp index c4fa59892c..19c014ffa0 100644 --- a/userspace/libsinsp/test/events_fspath.ut.cpp +++ b/userspace/libsinsp/test/events_fspath.ut.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/test/events_net.ut.cpp b/userspace/libsinsp/test/events_net.ut.cpp index 3f32a906d1..2966c4fed7 100644 --- a/userspace/libsinsp/test/events_net.ut.cpp +++ b/userspace/libsinsp/test/events_net.ut.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/test/events_param.ut.cpp b/userspace/libsinsp/test/events_param.ut.cpp index a25cd6cadd..6f164514c9 100644 --- a/userspace/libsinsp/test/events_param.ut.cpp +++ b/userspace/libsinsp/test/events_param.ut.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. @@ -368,4 +369,4 @@ TEST_F(sinsp_with_test_input, bitmaskparams) const char *val_str = NULL; evt->get_param_as_str(2, &val_str); ASSERT_STREQ(val_str, "O_RDONLY|O_CLOEXEC"); -} \ No newline at end of file +} diff --git a/userspace/libsinsp/test/events_plugin.ut.cpp b/userspace/libsinsp/test/events_plugin.ut.cpp index e4822a83f8..f2a10d742e 100644 --- a/userspace/libsinsp/test/events_plugin.ut.cpp +++ b/userspace/libsinsp/test/events_plugin.ut.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/test/events_proc.ut.cpp b/userspace/libsinsp/test/events_proc.ut.cpp index 5160e57287..d043343f50 100644 --- a/userspace/libsinsp/test/events_proc.ut.cpp +++ b/userspace/libsinsp/test/events_proc.ut.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/test/events_user.ut.cpp b/userspace/libsinsp/test/events_user.ut.cpp index 069cf97c2b..b08d851276 100644 --- a/userspace/libsinsp/test/events_user.ut.cpp +++ b/userspace/libsinsp/test/events_user.ut.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/test/external_processor.ut.cpp b/userspace/libsinsp/test/external_processor.ut.cpp index c8f5964da7..cc11f347a6 100644 --- a/userspace/libsinsp/test/external_processor.ut.cpp +++ b/userspace/libsinsp/test/external_processor.ut.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/test/filter_compiler.h b/userspace/libsinsp/test/filter_compiler.h index e7dd5b6504..03ef1d586a 100644 --- a/userspace/libsinsp/test/filter_compiler.h +++ b/userspace/libsinsp/test/filter_compiler.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/test/filter_escaping.ut.cpp b/userspace/libsinsp/test/filter_escaping.ut.cpp index 3c3dd47441..8ecc1e91d0 100644 --- a/userspace/libsinsp/test/filter_escaping.ut.cpp +++ b/userspace/libsinsp/test/filter_escaping.ut.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/test/filter_op_bcontains.ut.cpp b/userspace/libsinsp/test/filter_op_bcontains.ut.cpp index 4dfff4d276..69528dfb07 100644 --- a/userspace/libsinsp/test/filter_op_bcontains.ut.cpp +++ b/userspace/libsinsp/test/filter_op_bcontains.ut.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/test/filter_op_pmatch.ut.cpp b/userspace/libsinsp/test/filter_op_pmatch.ut.cpp index 1e9e3a68a0..809ce5cfcb 100644 --- a/userspace/libsinsp/test/filter_op_pmatch.ut.cpp +++ b/userspace/libsinsp/test/filter_op_pmatch.ut.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/test/filter_ppm_codes.ut.cpp b/userspace/libsinsp/test/filter_ppm_codes.ut.cpp index 839e1d93fe..50ef15f49d 100644 --- a/userspace/libsinsp/test/filter_ppm_codes.ut.cpp +++ b/userspace/libsinsp/test/filter_ppm_codes.ut.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/test/filterchecks/evt.cpp b/userspace/libsinsp/test/filterchecks/evt.cpp index bcf5470167..fdb16c22c5 100644 --- a/userspace/libsinsp/test/filterchecks/evt.cpp +++ b/userspace/libsinsp/test/filterchecks/evt.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/test/filterchecks/proc.cpp b/userspace/libsinsp/test/filterchecks/proc.cpp index b25098711d..d9439518ea 100644 --- a/userspace/libsinsp/test/filterchecks/proc.cpp +++ b/userspace/libsinsp/test/filterchecks/proc.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/test/helpers/scap_file_helpers.cpp b/userspace/libsinsp/test/helpers/scap_file_helpers.cpp index a0c9dd7f7b..03be89fbec 100644 --- a/userspace/libsinsp/test/helpers/scap_file_helpers.cpp +++ b/userspace/libsinsp/test/helpers/scap_file_helpers.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/test/helpers/scap_file_helpers.h b/userspace/libsinsp/test/helpers/scap_file_helpers.h index 9fd367681e..7b78116f04 100644 --- a/userspace/libsinsp/test/helpers/scap_file_helpers.h +++ b/userspace/libsinsp/test/helpers/scap_file_helpers.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/test/helpers/threads_helpers.h b/userspace/libsinsp/test/helpers/threads_helpers.h index 9b164f4a86..ed8e6659f2 100644 --- a/userspace/libsinsp/test/helpers/threads_helpers.h +++ b/userspace/libsinsp/test/helpers/threads_helpers.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/test/parsers/parse_clone.cpp b/userspace/libsinsp/test/parsers/parse_clone.cpp index bc8ea74cf4..61ffc9ea38 100644 --- a/userspace/libsinsp/test/parsers/parse_clone.cpp +++ b/userspace/libsinsp/test/parsers/parse_clone.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/test/parsers/parse_execve.cpp b/userspace/libsinsp/test/parsers/parse_execve.cpp index 61388626ae..2c5f16fbea 100644 --- a/userspace/libsinsp/test/parsers/parse_execve.cpp +++ b/userspace/libsinsp/test/parsers/parse_execve.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/test/parsers/parse_prctl.cpp b/userspace/libsinsp/test/parsers/parse_prctl.cpp index 0ea245cbc5..5eb5b9198d 100644 --- a/userspace/libsinsp/test/parsers/parse_prctl.cpp +++ b/userspace/libsinsp/test/parsers/parse_prctl.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/test/parsers/parse_proc_exit.cpp b/userspace/libsinsp/test/parsers/parse_proc_exit.cpp index 443a57fb15..4c0278e145 100644 --- a/userspace/libsinsp/test/parsers/parse_proc_exit.cpp +++ b/userspace/libsinsp/test/parsers/parse_proc_exit.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/test/plugin_manager.ut.cpp b/userspace/libsinsp/test/plugin_manager.ut.cpp index c9818738d3..d664c91f33 100644 --- a/userspace/libsinsp/test/plugin_manager.ut.cpp +++ b/userspace/libsinsp/test/plugin_manager.ut.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/test/plugins.ut.cpp b/userspace/libsinsp/test/plugins.ut.cpp index d0cad096da..a46b633f72 100644 --- a/userspace/libsinsp/test/plugins.ut.cpp +++ b/userspace/libsinsp/test/plugins.ut.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/test/plugins/plugin_extract.cpp b/userspace/libsinsp/test/plugins/plugin_extract.cpp index cd77e07e94..32bdf4ea04 100644 --- a/userspace/libsinsp/test/plugins/plugin_extract.cpp +++ b/userspace/libsinsp/test/plugins/plugin_extract.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/test/plugins/plugin_source.cpp b/userspace/libsinsp/test/plugins/plugin_source.cpp index fcbd152196..399b2a0aad 100644 --- a/userspace/libsinsp/test/plugins/plugin_source.cpp +++ b/userspace/libsinsp/test/plugins/plugin_source.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/test/plugins/sample_table.h b/userspace/libsinsp/test/plugins/sample_table.h index 37c85312fe..72602f70a7 100644 --- a/userspace/libsinsp/test/plugins/sample_table.h +++ b/userspace/libsinsp/test/plugins/sample_table.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/test/plugins/syscall_async.cpp b/userspace/libsinsp/test/plugins/syscall_async.cpp index b752345068..6ccd74125b 100644 --- a/userspace/libsinsp/test/plugins/syscall_async.cpp +++ b/userspace/libsinsp/test/plugins/syscall_async.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/test/plugins/syscall_extract.cpp b/userspace/libsinsp/test/plugins/syscall_extract.cpp index c82d428ee7..f58d5737de 100644 --- a/userspace/libsinsp/test/plugins/syscall_extract.cpp +++ b/userspace/libsinsp/test/plugins/syscall_extract.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/test/plugins/syscall_parse.cpp b/userspace/libsinsp/test/plugins/syscall_parse.cpp index fc8956e4cc..fed9dfcfa5 100644 --- a/userspace/libsinsp/test/plugins/syscall_parse.cpp +++ b/userspace/libsinsp/test/plugins/syscall_parse.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/test/plugins/syscall_source.cpp b/userspace/libsinsp/test/plugins/syscall_source.cpp index f633376756..dcff207a7f 100644 --- a/userspace/libsinsp/test/plugins/syscall_source.cpp +++ b/userspace/libsinsp/test/plugins/syscall_source.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/test/plugins/tables.cpp b/userspace/libsinsp/test/plugins/tables.cpp index d9b3083788..459a5b7215 100644 --- a/userspace/libsinsp/test/plugins/tables.cpp +++ b/userspace/libsinsp/test/plugins/tables.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/test/plugins/test_plugins.h b/userspace/libsinsp/test/plugins/test_plugins.h index 2086ba4024..b5b5bf92ff 100644 --- a/userspace/libsinsp/test/plugins/test_plugins.h +++ b/userspace/libsinsp/test/plugins/test_plugins.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/test/ppm_api_version.ut.cpp b/userspace/libsinsp/test/ppm_api_version.ut.cpp index 18c9830ec0..aaad884801 100644 --- a/userspace/libsinsp/test/ppm_api_version.ut.cpp +++ b/userspace/libsinsp/test/ppm_api_version.ut.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/test/prefix_search.ut.cpp b/userspace/libsinsp/test/prefix_search.ut.cpp index 0d647c4326..8c82a2bbbb 100644 --- a/userspace/libsinsp/test/prefix_search.ut.cpp +++ b/userspace/libsinsp/test/prefix_search.ut.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/test/procfs_utils.ut.cpp b/userspace/libsinsp/test/procfs_utils.ut.cpp index fbe868513a..c15ef472e0 100644 --- a/userspace/libsinsp/test/procfs_utils.ut.cpp +++ b/userspace/libsinsp/test/procfs_utils.ut.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/test/public_sinsp_API/events_set.cpp b/userspace/libsinsp/test/public_sinsp_API/events_set.cpp index e06f3384c8..7f2c87eacd 100644 --- a/userspace/libsinsp/test/public_sinsp_API/events_set.cpp +++ b/userspace/libsinsp/test/public_sinsp_API/events_set.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/test/public_sinsp_API/interesting_syscalls.cpp b/userspace/libsinsp/test/public_sinsp_API/interesting_syscalls.cpp index c1753cc5b5..bed0a50076 100644 --- a/userspace/libsinsp/test/public_sinsp_API/interesting_syscalls.cpp +++ b/userspace/libsinsp/test/public_sinsp_API/interesting_syscalls.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/test/public_sinsp_API/ppm_sc_codes.cpp b/userspace/libsinsp/test/public_sinsp_API/ppm_sc_codes.cpp index 90758965e5..1eeb7757bc 100644 --- a/userspace/libsinsp/test/public_sinsp_API/ppm_sc_codes.cpp +++ b/userspace/libsinsp/test/public_sinsp_API/ppm_sc_codes.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/test/public_sinsp_API/sinsp_logger.cpp b/userspace/libsinsp/test/public_sinsp_API/sinsp_logger.cpp index 2ae5de04b8..4a957f3fb6 100644 --- a/userspace/libsinsp/test/public_sinsp_API/sinsp_logger.cpp +++ b/userspace/libsinsp/test/public_sinsp_API/sinsp_logger.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/test/savefile.ut.cpp b/userspace/libsinsp/test/savefile.ut.cpp index fc634359d2..00d8e55254 100644 --- a/userspace/libsinsp/test/savefile.ut.cpp +++ b/userspace/libsinsp/test/savefile.ut.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. @@ -29,4 +30,4 @@ TEST(savefile, proclist) ASSERT_EQ(inspector.m_thread_manager->get_thread_count(), 94); } -#endif \ No newline at end of file +#endif diff --git a/userspace/libsinsp/test/scap_files/kexec_arm64/kexec_arm64.cpp b/userspace/libsinsp/test/scap_files/kexec_arm64/kexec_arm64.cpp index b9d8110043..c4a588f831 100644 --- a/userspace/libsinsp/test/scap_files/kexec_arm64/kexec_arm64.cpp +++ b/userspace/libsinsp/test/scap_files/kexec_arm64/kexec_arm64.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/test/scap_files/kexec_x86/kexec_x86.cpp b/userspace/libsinsp/test/scap_files/kexec_x86/kexec_x86.cpp index a901710478..500bae77ad 100644 --- a/userspace/libsinsp/test/scap_files/kexec_x86/kexec_x86.cpp +++ b/userspace/libsinsp/test/scap_files/kexec_x86/kexec_x86.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/test/sinsp_utils.ut.cpp b/userspace/libsinsp/test/sinsp_utils.ut.cpp index c73ad3d8ba..ac9f7e46ff 100644 --- a/userspace/libsinsp/test/sinsp_utils.ut.cpp +++ b/userspace/libsinsp/test/sinsp_utils.ut.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/test/sinsp_with_test_input.h b/userspace/libsinsp/test/sinsp_with_test_input.h index de6b6cdb06..d657a0c8bb 100644 --- a/userspace/libsinsp/test/sinsp_with_test_input.h +++ b/userspace/libsinsp/test/sinsp_with_test_input.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/test/state.ut.cpp b/userspace/libsinsp/test/state.ut.cpp index 4a594a070a..cd2432bcca 100644 --- a/userspace/libsinsp/test/state.ut.cpp +++ b/userspace/libsinsp/test/state.ut.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/test/string_visitor.ut.cpp b/userspace/libsinsp/test/string_visitor.ut.cpp index e89aaf2713..b2fac6dfc3 100644 --- a/userspace/libsinsp/test/string_visitor.ut.cpp +++ b/userspace/libsinsp/test/string_visitor.ut.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/test/test_utils.cpp b/userspace/libsinsp/test/test_utils.cpp index e522630398..e401727b00 100644 --- a/userspace/libsinsp/test/test_utils.cpp +++ b/userspace/libsinsp/test/test_utils.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/test/test_utils.h b/userspace/libsinsp/test/test_utils.h index 997a9e6ccd..10d8ea81e8 100644 --- a/userspace/libsinsp/test/test_utils.h +++ b/userspace/libsinsp/test/test_utils.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/test/thread_table.ut.cpp b/userspace/libsinsp/test/thread_table.ut.cpp index a73a8f1d19..28da290fe9 100644 --- a/userspace/libsinsp/test/thread_table.ut.cpp +++ b/userspace/libsinsp/test/thread_table.ut.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/test/user.ut.cpp b/userspace/libsinsp/test/user.ut.cpp index a52fceaa9f..f4ce1fbb96 100644 --- a/userspace/libsinsp/test/user.ut.cpp +++ b/userspace/libsinsp/test/user.ut.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/thread_group_info.h b/userspace/libsinsp/thread_group_info.h index c0ead47ed1..012a832dbb 100644 --- a/userspace/libsinsp/thread_group_info.h +++ b/userspace/libsinsp/thread_group_info.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/libsinsp/threadinfo.cpp b/userspace/libsinsp/threadinfo.cpp index 9ea3120aeb..d0d0dfa4a9 100644 --- a/userspace/libsinsp/threadinfo.cpp +++ b/userspace/libsinsp/threadinfo.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/threadinfo.h b/userspace/libsinsp/threadinfo.h index 2f992cb883..3701ba9b25 100644 --- a/userspace/libsinsp/threadinfo.h +++ b/userspace/libsinsp/threadinfo.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/token_bucket.cpp b/userspace/libsinsp/token_bucket.cpp index 6f370e459e..8cb865b253 100644 --- a/userspace/libsinsp/token_bucket.cpp +++ b/userspace/libsinsp/token_bucket.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/token_bucket.h b/userspace/libsinsp/token_bucket.h index 132a3592ea..4a922091d5 100644 --- a/userspace/libsinsp/token_bucket.h +++ b/userspace/libsinsp/token_bucket.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/tracer_emitter.cpp b/userspace/libsinsp/tracer_emitter.cpp index 4eb8c5c437..e4da4aa215 100644 --- a/userspace/libsinsp/tracer_emitter.cpp +++ b/userspace/libsinsp/tracer_emitter.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/tracer_emitter.h b/userspace/libsinsp/tracer_emitter.h index d5c6a3fc66..08a4817ce7 100644 --- a/userspace/libsinsp/tracer_emitter.h +++ b/userspace/libsinsp/tracer_emitter.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/tracers.cpp b/userspace/libsinsp/tracers.cpp index 466c0a7303..0b8b5442ea 100644 --- a/userspace/libsinsp/tracers.cpp +++ b/userspace/libsinsp/tracers.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/tracers.h b/userspace/libsinsp/tracers.h index 5c1e2b7dc5..1d57b1d9bd 100644 --- a/userspace/libsinsp/tracers.h +++ b/userspace/libsinsp/tracers.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/tuples.cpp b/userspace/libsinsp/tuples.cpp index 82550636e4..8f56078ff7 100644 --- a/userspace/libsinsp/tuples.cpp +++ b/userspace/libsinsp/tuples.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/tuples.h b/userspace/libsinsp/tuples.h index d775088f38..45181312fd 100644 --- a/userspace/libsinsp/tuples.h +++ b/userspace/libsinsp/tuples.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/uri.cpp b/userspace/libsinsp/uri.cpp index 563a44d97d..e073fddcb6 100644 --- a/userspace/libsinsp/uri.cpp +++ b/userspace/libsinsp/uri.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/uri.h b/userspace/libsinsp/uri.h index 220e44628e..d20ce473f2 100644 --- a/userspace/libsinsp/uri.h +++ b/userspace/libsinsp/uri.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/user.cpp b/userspace/libsinsp/user.cpp index 54695cabfc..e109fe9601 100644 --- a/userspace/libsinsp/user.cpp +++ b/userspace/libsinsp/user.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/user.h b/userspace/libsinsp/user.h index d074d5cb45..0c883bb493 100644 --- a/userspace/libsinsp/user.h +++ b/userspace/libsinsp/user.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/user_event.cpp b/userspace/libsinsp/user_event.cpp index ede5a92836..ddad0370e8 100644 --- a/userspace/libsinsp/user_event.cpp +++ b/userspace/libsinsp/user_event.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/user_event.h b/userspace/libsinsp/user_event.h index 4eef2d24b7..9a33feeaed 100644 --- a/userspace/libsinsp/user_event.h +++ b/userspace/libsinsp/user_event.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/user_event_logger.cpp b/userspace/libsinsp/user_event_logger.cpp index 454256d874..bb3df6793c 100644 --- a/userspace/libsinsp/user_event_logger.cpp +++ b/userspace/libsinsp/user_event_logger.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/user_event_logger.h b/userspace/libsinsp/user_event_logger.h index 800d294dbf..9eb1050507 100644 --- a/userspace/libsinsp/user_event_logger.h +++ b/userspace/libsinsp/user_event_logger.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/utils.cpp b/userspace/libsinsp/utils.cpp index c3b8b7cc6a..1e65a718eb 100644 --- a/userspace/libsinsp/utils.cpp +++ b/userspace/libsinsp/utils.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/utils.h b/userspace/libsinsp/utils.h index 8a3c22a85e..a5e1fe31c0 100644 --- a/userspace/libsinsp/utils.h +++ b/userspace/libsinsp/utils.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/value_parser.cpp b/userspace/libsinsp/value_parser.cpp index 89480bb71f..8f473e0d21 100644 --- a/userspace/libsinsp/value_parser.cpp +++ b/userspace/libsinsp/value_parser.cpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/value_parser.h b/userspace/libsinsp/value_parser.h index 179e28c849..ac9b0c98dd 100644 --- a/userspace/libsinsp/value_parser.h +++ b/userspace/libsinsp/value_parser.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/version.h b/userspace/libsinsp/version.h index c4d658bb11..83194f562f 100755 --- a/userspace/libsinsp/version.h +++ b/userspace/libsinsp/version.h @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/plugin/plugin_api.h b/userspace/plugin/plugin_api.h index cc8a4ecc5d..8ae11ae7ba 100644 --- a/userspace/plugin/plugin_api.h +++ b/userspace/plugin/plugin_api.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/plugin/plugin_loader.c b/userspace/plugin/plugin_loader.c index 70c5485a49..9401c4186b 100644 --- a/userspace/plugin/plugin_loader.c +++ b/userspace/plugin/plugin_loader.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/plugin/plugin_loader.h b/userspace/plugin/plugin_loader.h index f21c14b00a..c93e752884 100644 --- a/userspace/plugin/plugin_loader.h +++ b/userspace/plugin/plugin_loader.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/userspace/plugin/plugin_types.h b/userspace/plugin/plugin_types.h index 41e8d034c0..46e7600b2b 100644 --- a/userspace/plugin/plugin_types.h +++ b/userspace/plugin/plugin_types.h @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. From 82294f0ae8d9fabc0f033131b720ce6d3d5e19ff Mon Sep 17 00:00:00 2001 From: Leonardo Grasso Date: Wed, 4 Oct 2023 18:09:42 +0200 Subject: [PATCH 2/5] docs(userspace/libscap): add license header and SPDX identifier Signed-off-by: Leonardo Grasso --- userspace/libpman/CMakeLists.txt | 17 +++++++++++++++++ userspace/libscap/emscripten/barrier.h | 17 +++++++++++++++++ userspace/libscap/engine/bpf/CMakeLists.txt | 16 ++++++++++++++++ userspace/libscap/engine/gvisor/CMakeLists.txt | 16 ++++++++++++++++ userspace/libscap/engine/kmod/CMakeLists.txt | 16 ++++++++++++++++ .../libscap/engine/modern_bpf/CMakeLists.txt | 16 ++++++++++++++++ .../libscap/engine/nodriver/CMakeLists.txt | 16 ++++++++++++++++ userspace/libscap/engine/noop/CMakeLists.txt | 16 ++++++++++++++++ .../libscap/engine/savefile/CMakeLists.txt | 16 ++++++++++++++++ .../libscap/engine/source_plugin/CMakeLists.txt | 16 ++++++++++++++++ .../libscap/engine/test_input/CMakeLists.txt | 16 ++++++++++++++++ userspace/libscap/engine/udig/CMakeLists.txt | 16 ++++++++++++++++ userspace/libscap/engine/udig/scap_udig.c | 14 ++++++++++++++ .../libscap/examples/01-open/CMakeLists.txt | 16 ++++++++++++++++ .../examples/02-validatebuffer/CMakeLists.txt | 16 ++++++++++++++++ userspace/libscap/linux/CMakeLists.txt | 16 ++++++++++++++++ userspace/libscap/linux/barrier.h | 17 +++++++++++++++++ userspace/libscap/macos/barrier.h | 17 +++++++++++++++++ userspace/libscap/ringbuffer/devset.c | 17 +++++++++++++++++ userspace/libscap/userspace_flag_helpers.h | 17 +++++++++++++++++ userspace/libscap/win32/barrier.h | 17 +++++++++++++++++ 21 files changed, 341 insertions(+) diff --git a/userspace/libpman/CMakeLists.txt b/userspace/libpman/CMakeLists.txt index 89ad0deee9..b93f4be93f 100644 --- a/userspace/libpman/CMakeLists.txt +++ b/userspace/libpman/CMakeLists.txt @@ -1,3 +1,20 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2023 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. +# + set(PMAN_SOURCES src/stats.c src/maps.c diff --git a/userspace/libscap/emscripten/barrier.h b/userspace/libscap/emscripten/barrier.h index e6e7447630..5cfc22f600 100644 --- a/userspace/libscap/emscripten/barrier.h +++ b/userspace/libscap/emscripten/barrier.h @@ -1,3 +1,20 @@ +// SPDX-License-Identifier: Apache-2.0 +/* +Copyright (C) 2023 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. + +*/ #pragma once #define mem_barrier() __sync_synchronize() diff --git a/userspace/libscap/engine/bpf/CMakeLists.txt b/userspace/libscap/engine/bpf/CMakeLists.txt index b8a52b0a4c..f94435a741 100644 --- a/userspace/libscap/engine/bpf/CMakeLists.txt +++ b/userspace/libscap/engine/bpf/CMakeLists.txt @@ -1,3 +1,19 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2023 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. +# include_directories(${LIBSCAP_INCLUDE_DIRS} ../noop) add_library(scap_engine_bpf scap_bpf.c attached_prog.c) add_dependencies(scap_engine_bpf libelf scap_platform) diff --git a/userspace/libscap/engine/gvisor/CMakeLists.txt b/userspace/libscap/engine/gvisor/CMakeLists.txt index 225ea85c49..254ca1bcd1 100644 --- a/userspace/libscap/engine/gvisor/CMakeLists.txt +++ b/userspace/libscap/engine/gvisor/CMakeLists.txt @@ -1,3 +1,19 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2023 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. +# include(protobuf) include(jsoncpp) diff --git a/userspace/libscap/engine/kmod/CMakeLists.txt b/userspace/libscap/engine/kmod/CMakeLists.txt index b88a760035..96419a1909 100644 --- a/userspace/libscap/engine/kmod/CMakeLists.txt +++ b/userspace/libscap/engine/kmod/CMakeLists.txt @@ -1,3 +1,19 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2023 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. +# include_directories(${LIBSCAP_INCLUDE_DIRS}) add_library(scap_engine_kmod scap_kmod.c) target_link_libraries(scap_engine_kmod scap_event_schema scap_platform scap_engine_util scap_error) diff --git a/userspace/libscap/engine/modern_bpf/CMakeLists.txt b/userspace/libscap/engine/modern_bpf/CMakeLists.txt index cabb8f368d..cb343c69bc 100644 --- a/userspace/libscap/engine/modern_bpf/CMakeLists.txt +++ b/userspace/libscap/engine/modern_bpf/CMakeLists.txt @@ -1,3 +1,19 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2023 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. +# include_directories(${LIBSCAP_INCLUDE_DIRS} ../noop) message(STATUS "Build modern BPF engine") diff --git a/userspace/libscap/engine/nodriver/CMakeLists.txt b/userspace/libscap/engine/nodriver/CMakeLists.txt index 90e3cff3a5..f6ac44392b 100644 --- a/userspace/libscap/engine/nodriver/CMakeLists.txt +++ b/userspace/libscap/engine/nodriver/CMakeLists.txt @@ -1,3 +1,19 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2023 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. +# include_directories(${LIBSCAP_INCLUDE_DIRS} ../noop) add_library(scap_engine_nodriver nodriver.c) target_link_libraries(scap_engine_nodriver scap_engine_noop) diff --git a/userspace/libscap/engine/noop/CMakeLists.txt b/userspace/libscap/engine/noop/CMakeLists.txt index 8d45027cf3..b5ab78a82c 100644 --- a/userspace/libscap/engine/noop/CMakeLists.txt +++ b/userspace/libscap/engine/noop/CMakeLists.txt @@ -1,3 +1,19 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2023 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. +# include_directories(${LIBSCAP_INCLUDE_DIRS}) add_library(scap_engine_noop STATIC noop.c) add_dependencies(scap_engine_noop uthash) diff --git a/userspace/libscap/engine/savefile/CMakeLists.txt b/userspace/libscap/engine/savefile/CMakeLists.txt index 08144d69fd..34f11a7415 100644 --- a/userspace/libscap/engine/savefile/CMakeLists.txt +++ b/userspace/libscap/engine/savefile/CMakeLists.txt @@ -1,3 +1,19 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2023 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. +# include_directories(${LIBSCAP_INCLUDE_DIRS} ../noop) # Since we have circular dependencies between libscap and the savefile engine, diff --git a/userspace/libscap/engine/source_plugin/CMakeLists.txt b/userspace/libscap/engine/source_plugin/CMakeLists.txt index ec4b803275..6769d6b78c 100644 --- a/userspace/libscap/engine/source_plugin/CMakeLists.txt +++ b/userspace/libscap/engine/source_plugin/CMakeLists.txt @@ -1,3 +1,19 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2023 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. +# include_directories(${LIBSCAP_INCLUDE_DIRS} ../noop) add_library(scap_engine_source_plugin source_plugin.c) target_link_libraries(scap_engine_source_plugin scap_engine_noop) diff --git a/userspace/libscap/engine/test_input/CMakeLists.txt b/userspace/libscap/engine/test_input/CMakeLists.txt index cdf1a29bb2..42018219d6 100644 --- a/userspace/libscap/engine/test_input/CMakeLists.txt +++ b/userspace/libscap/engine/test_input/CMakeLists.txt @@ -1,3 +1,19 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2023 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. +# include_directories(${LIBSCAP_INCLUDE_DIRS} ../noop) add_library(scap_engine_test_input test_input.c test_input_platform.c) target_link_libraries(scap_engine_test_input scap_engine_noop scap_platform_util) diff --git a/userspace/libscap/engine/udig/CMakeLists.txt b/userspace/libscap/engine/udig/CMakeLists.txt index c6bf2754d1..e40c263163 100644 --- a/userspace/libscap/engine/udig/CMakeLists.txt +++ b/userspace/libscap/engine/udig/CMakeLists.txt @@ -1,3 +1,19 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2023 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. +# include_directories(${LIBSCAP_INCLUDE_DIRS}) add_library(scap_engine_udig scap_udig.c) target_link_libraries(scap_engine_udig scap_engine_util scap_error) diff --git a/userspace/libscap/engine/udig/scap_udig.c b/userspace/libscap/engine/udig/scap_udig.c index 4d35813c74..46b1e150ca 100644 --- a/userspace/libscap/engine/udig/scap_udig.c +++ b/userspace/libscap/engine/udig/scap_udig.c @@ -1,3 +1,17 @@ +// SPDX-License-Identifier: Apache-2.0 +/* +Copyright (C) 2023 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. +*/ + #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif diff --git a/userspace/libscap/examples/01-open/CMakeLists.txt b/userspace/libscap/examples/01-open/CMakeLists.txt index db4f7d1a6c..ac70bd9c28 100644 --- a/userspace/libscap/examples/01-open/CMakeLists.txt +++ b/userspace/libscap/examples/01-open/CMakeLists.txt @@ -1,3 +1,19 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2023 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. +# include_directories("../../../common") include_directories("../../") diff --git a/userspace/libscap/examples/02-validatebuffer/CMakeLists.txt b/userspace/libscap/examples/02-validatebuffer/CMakeLists.txt index 294e218cbe..25e8794ed6 100644 --- a/userspace/libscap/examples/02-validatebuffer/CMakeLists.txt +++ b/userspace/libscap/examples/02-validatebuffer/CMakeLists.txt @@ -1,3 +1,19 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2023 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. +# include_directories("../../../common") include_directories("../..") diff --git a/userspace/libscap/linux/CMakeLists.txt b/userspace/libscap/linux/CMakeLists.txt index a20d750818..98b8fdc0b4 100644 --- a/userspace/libscap/linux/CMakeLists.txt +++ b/userspace/libscap/linux/CMakeLists.txt @@ -1,3 +1,19 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2023 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. +# add_library(scap_platform STATIC scap_linux_platform.c scap_procs.c scap_fds.c scap_userlist.c scap_iflist.c scap_cgroup.c scap_machine_info.c) target_link_libraries(scap_platform scap_error scap_platform_util) add_dependencies(scap_platform uthash) diff --git a/userspace/libscap/linux/barrier.h b/userspace/libscap/linux/barrier.h index e6e7447630..5cfc22f600 100644 --- a/userspace/libscap/linux/barrier.h +++ b/userspace/libscap/linux/barrier.h @@ -1,3 +1,20 @@ +// SPDX-License-Identifier: Apache-2.0 +/* +Copyright (C) 2023 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. + +*/ #pragma once #define mem_barrier() __sync_synchronize() diff --git a/userspace/libscap/macos/barrier.h b/userspace/libscap/macos/barrier.h index e6e7447630..5cfc22f600 100644 --- a/userspace/libscap/macos/barrier.h +++ b/userspace/libscap/macos/barrier.h @@ -1,3 +1,20 @@ +// SPDX-License-Identifier: Apache-2.0 +/* +Copyright (C) 2023 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. + +*/ #pragma once #define mem_barrier() __sync_synchronize() diff --git a/userspace/libscap/ringbuffer/devset.c b/userspace/libscap/ringbuffer/devset.c index 731df5f860..4325021ded 100644 --- a/userspace/libscap/ringbuffer/devset.c +++ b/userspace/libscap/ringbuffer/devset.c @@ -1,3 +1,20 @@ +// SPDX-License-Identifier: Apache-2.0 +/* +Copyright (C) 2023 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. + +*/ #include "devset.h" #include diff --git a/userspace/libscap/userspace_flag_helpers.h b/userspace/libscap/userspace_flag_helpers.h index bd9da358b7..821796142e 100644 --- a/userspace/libscap/userspace_flag_helpers.h +++ b/userspace/libscap/userspace_flag_helpers.h @@ -1,3 +1,20 @@ +// SPDX-License-Identifier: Apache-2.0 +/* +Copyright (C) 2023 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. + +*/ #pragma once #include diff --git a/userspace/libscap/win32/barrier.h b/userspace/libscap/win32/barrier.h index 9bbb5d0741..65e8190151 100644 --- a/userspace/libscap/win32/barrier.h +++ b/userspace/libscap/win32/barrier.h @@ -1,3 +1,20 @@ +// SPDX-License-Identifier: Apache-2.0 +/* +Copyright (C) 2023 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. + +*/ #pragma once #define mem_barrier() MemoryBarrier() From 32d6111f89d0f16ad49e8f8c2b42c206765411e8 Mon Sep 17 00:00:00 2001 From: Leonardo Grasso Date: Wed, 4 Oct 2023 18:23:38 +0200 Subject: [PATCH 3/5] docs(userspace/libsinsp): add license header and SPDX identifier Signed-off-by: Leonardo Grasso --- .../libsinsp/async/async_key_value_source.tpp | 3 ++- .../container_async_source.tpp | 3 ++- userspace/libsinsp/cri.hpp | 3 ++- userspace/libsinsp/examples/CMakeLists.txt | 16 ++++++++++++++ userspace/libsinsp/scripts/update-cri-proto | 21 +++++++++++++++++++ userspace/libsinsp/sinsp_debug/CMakeLists.txt | 16 ++++++++++++++ 6 files changed, 59 insertions(+), 3 deletions(-) diff --git a/userspace/libsinsp/async/async_key_value_source.tpp b/userspace/libsinsp/async/async_key_value_source.tpp index e7bda05869..ff4528901f 100644 --- a/userspace/libsinsp/async/async_key_value_source.tpp +++ b/userspace/libsinsp/async/async_key_value_source.tpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/container_engine/container_async_source.tpp b/userspace/libsinsp/container_engine/container_async_source.tpp index 2d46437f22..8acb176c80 100644 --- a/userspace/libsinsp/container_engine/container_async_source.tpp +++ b/userspace/libsinsp/container_engine/container_async_source.tpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2022 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/cri.hpp b/userspace/libsinsp/cri.hpp index 68371f01f3..9937cf3078 100644 --- a/userspace/libsinsp/cri.hpp +++ b/userspace/libsinsp/cri.hpp @@ -1,5 +1,6 @@ +// SPDX-License-Identifier: Apache-2.0 /* -Copyright (C) 2021 The Falco Authors. +Copyright (C) 2023 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. diff --git a/userspace/libsinsp/examples/CMakeLists.txt b/userspace/libsinsp/examples/CMakeLists.txt index f1367497ad..12848c48d4 100644 --- a/userspace/libsinsp/examples/CMakeLists.txt +++ b/userspace/libsinsp/examples/CMakeLists.txt @@ -1,3 +1,19 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2023 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. +# include_directories("../../../common") include_directories("../../") diff --git a/userspace/libsinsp/scripts/update-cri-proto b/userspace/libsinsp/scripts/update-cri-proto index 763e1fd1df..ef5894b81c 100755 --- a/userspace/libsinsp/scripts/update-cri-proto +++ b/userspace/libsinsp/scripts/update-cri-proto @@ -1,4 +1,25 @@ #!/bin/bash +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2023 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. +# +# Simple script that desperately tries to load the kernel instrumentation by +# looking for it in a bunch of ways. Convenient when running Falco inside +# a container or in other weird environments. +# set -euo pipefail diff --git a/userspace/libsinsp/sinsp_debug/CMakeLists.txt b/userspace/libsinsp/sinsp_debug/CMakeLists.txt index 4e377c6f18..f5a3eeb43a 100644 --- a/userspace/libsinsp/sinsp_debug/CMakeLists.txt +++ b/userspace/libsinsp/sinsp_debug/CMakeLists.txt @@ -1,3 +1,19 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2023 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. +# include_directories("../../../common") include_directories("../../") From 22dbca07f641d0068d15a5a6465cddea0dcdfb4f Mon Sep 17 00:00:00 2001 From: Leonardo Grasso Date: Wed, 4 Oct 2023 18:31:45 +0200 Subject: [PATCH 4/5] docs(cmake): add license header and SPDX identifier Signed-off-by: Leonardo Grasso --- cmake/modules/CompilerFlags.cmake | 14 ++++++++++++++ cmake/modules/FindMakedev.cmake | 3 ++- cmake/modules/Findvalijson.cmake | 3 ++- cmake/modules/GetVersionFromGit.cmake | 3 ++- cmake/modules/b64.cmake | 1 + cmake/modules/cares.cmake | 14 ++++++++++++++ cmake/modules/compute_versions.cmake | 14 ++++++++++++++ cmake/modules/curl.cmake | 13 ++++++++++++- cmake/modules/grpc.cmake | 14 ++++++++++++++ cmake/modules/gtest.cmake | 14 ++++++++++++++ cmake/modules/jq.cmake | 13 ++++++++++++- cmake/modules/jsoncpp.cmake | 12 +++++++++++- cmake/modules/libbpf.cmake | 13 ++++++++++++- cmake/modules/libelf.cmake | 13 ++++++++++++- cmake/modules/libscap.cmake | 14 ++++++++++++++ cmake/modules/libsinsp.cmake | 14 ++++++++++++++ cmake/modules/luajit.cmake | 13 ++++++++++++- cmake/modules/openssl.cmake | 13 ++++++++++++- cmake/modules/protobuf.cmake | 14 ++++++++++++++ cmake/modules/re2.cmake | 13 ++++++++++++- cmake/modules/tbb.cmake | 13 ++++++++++++- cmake/modules/tinydir.cmake | 3 ++- cmake/modules/uthash.cmake | 1 + cmake/modules/valijson.cmake | 3 ++- cmake/modules/versions.cmake | 3 ++- cmake/modules/zlib.cmake | 13 ++++++++++++- 26 files changed, 245 insertions(+), 16 deletions(-) diff --git a/cmake/modules/CompilerFlags.cmake b/cmake/modules/CompilerFlags.cmake index fdcb7fa6bf..dba1ce6595 100644 --- a/cmake/modules/CompilerFlags.cmake +++ b/cmake/modules/CompilerFlags.cmake @@ -1,3 +1,17 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2023 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. +# + option(BUILD_WARNINGS_AS_ERRORS "Enable building with -Wextra -Werror flags") option(ENABLE_PIC "Build position independent libraries and executables" ${BUILD_SHARED_LIBS}) diff --git a/cmake/modules/FindMakedev.cmake b/cmake/modules/FindMakedev.cmake index 6f5866fcd0..db1b6ba41e 100644 --- a/cmake/modules/FindMakedev.cmake +++ b/cmake/modules/FindMakedev.cmake @@ -1,5 +1,6 @@ +# SPDX-License-Identifier: Apache-2.0 # -# Copyright (C) 2021 The Falco Authors. +# Copyright (C) 2023 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. diff --git a/cmake/modules/Findvalijson.cmake b/cmake/modules/Findvalijson.cmake index 1bf5d0405f..0fdefdc4a1 100644 --- a/cmake/modules/Findvalijson.cmake +++ b/cmake/modules/Findvalijson.cmake @@ -1,5 +1,6 @@ +# SPDX-License-Identifier: Apache-2.0 # -# Copyright (C) 2022 The Falco Authors. +# Copyright (C) 2023 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. diff --git a/cmake/modules/GetVersionFromGit.cmake b/cmake/modules/GetVersionFromGit.cmake index 287a0e0cee..bfe487c41b 100644 --- a/cmake/modules/GetVersionFromGit.cmake +++ b/cmake/modules/GetVersionFromGit.cmake @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: Apache-2.0 # # Copyright (C) 2023 The Falco Authors. # @@ -188,4 +189,4 @@ function(get_version_from_git _var match_suffix exclude_suffix) set(${_var} "${dev_version}" PARENT_SCOPE) -endfunction() \ No newline at end of file +endfunction() diff --git a/cmake/modules/b64.cmake b/cmake/modules/b64.cmake index f4f893f735..cd8b813391 100644 --- a/cmake/modules/b64.cmake +++ b/cmake/modules/b64.cmake @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: Apache-2.0 # # Copyright (C) 2023 The Falco Authors. # diff --git a/cmake/modules/cares.cmake b/cmake/modules/cares.cmake index df0033115a..194d9872c4 100644 --- a/cmake/modules/cares.cmake +++ b/cmake/modules/cares.cmake @@ -1,3 +1,17 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2023 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. +# + option(USE_BUNDLED_CARES "Enable building of the bundled c-ares" ${USE_BUNDLED_DEPS}) if(CARES_INCLUDE) diff --git a/cmake/modules/compute_versions.cmake b/cmake/modules/compute_versions.cmake index 12eb1b2d30..2c6a215556 100644 --- a/cmake/modules/compute_versions.cmake +++ b/cmake/modules/compute_versions.cmake @@ -1,3 +1,17 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2023 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. +# + # Computes API/SCHEMA major, minor, patch and git commit macro(compute_versions api_version_path schema_version_path) diff --git a/cmake/modules/curl.cmake b/cmake/modules/curl.cmake index cc71173076..aba30d29db 100644 --- a/cmake/modules/curl.cmake +++ b/cmake/modules/curl.cmake @@ -1,6 +1,17 @@ +# SPDX-License-Identifier: Apache-2.0 # -# libcurl +# Copyright (C) 2023 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. +# + option(USE_BUNDLED_CURL "Enable building of the bundled curl" ${USE_BUNDLED_DEPS}) include(openssl) diff --git a/cmake/modules/grpc.cmake b/cmake/modules/grpc.cmake index b56478326e..ba2d101dc5 100644 --- a/cmake/modules/grpc.cmake +++ b/cmake/modules/grpc.cmake @@ -1,3 +1,17 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2023 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. +# + option(USE_BUNDLED_GRPC "Enable building of the bundled grpc" ${USE_BUNDLED_DEPS}) if(GRPC_INCLUDE) diff --git a/cmake/modules/gtest.cmake b/cmake/modules/gtest.cmake index 4ff02374bd..a94ed62828 100644 --- a/cmake/modules/gtest.cmake +++ b/cmake/modules/gtest.cmake @@ -1,3 +1,17 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2023 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. +# + option(USE_BUNDLED_GTEST "Enable building of the bundled gtest" ${USE_BUNDLED_DEPS}) if(GTEST_INCLUDE_DIR) diff --git a/cmake/modules/jq.cmake b/cmake/modules/jq.cmake index 66a0d68fb2..dc9ccd972c 100644 --- a/cmake/modules/jq.cmake +++ b/cmake/modules/jq.cmake @@ -1,6 +1,17 @@ +# SPDX-License-Identifier: Apache-2.0 # -# jq +# Copyright (C) 2023 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. +# + option(USE_BUNDLED_JQ "Enable building of the bundled jq" ${USE_BUNDLED_DEPS}) if(JQ_INCLUDE) diff --git a/cmake/modules/jsoncpp.cmake b/cmake/modules/jsoncpp.cmake index 4675c366d3..5ed411200c 100644 --- a/cmake/modules/jsoncpp.cmake +++ b/cmake/modules/jsoncpp.cmake @@ -1,5 +1,15 @@ +# SPDX-License-Identifier: Apache-2.0 # -# JsonCpp +# Copyright (C) 2023 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. # option(USE_BUNDLED_JSONCPP "Enable building of the bundled jsoncpp" ${USE_BUNDLED_DEPS}) diff --git a/cmake/modules/libbpf.cmake b/cmake/modules/libbpf.cmake index 9511738134..d9df916c83 100644 --- a/cmake/modules/libbpf.cmake +++ b/cmake/modules/libbpf.cmake @@ -1,6 +1,17 @@ +# SPDX-License-Identifier: Apache-2.0 # -# libbpf +# Copyright (C) 2023 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. +# + option(USE_BUNDLED_LIBBPF "Enable building of the bundled libbpf" ${USE_BUNDLED_DEPS}) if(LIBBPF_INCLUDE) diff --git a/cmake/modules/libelf.cmake b/cmake/modules/libelf.cmake index 2a635945a0..40bbbe2e95 100644 --- a/cmake/modules/libelf.cmake +++ b/cmake/modules/libelf.cmake @@ -1,6 +1,17 @@ +# SPDX-License-Identifier: Apache-2.0 # -# LIBELF +# Copyright (C) 2023 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. +# + option(USE_BUNDLED_LIBELF "Enable building of the bundled libelf" ${USE_BUNDLED_DEPS}) if(LIBELF_INCLUDE) diff --git a/cmake/modules/libscap.cmake b/cmake/modules/libscap.cmake index b831a584fa..771e8683b8 100644 --- a/cmake/modules/libscap.cmake +++ b/cmake/modules/libscap.cmake @@ -1,3 +1,17 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2023 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. +# + if(NOT HAVE_LIBSCAP) set(HAVE_LIBSCAP On) diff --git a/cmake/modules/libsinsp.cmake b/cmake/modules/libsinsp.cmake index 44ba3e044f..ee8248f50f 100644 --- a/cmake/modules/libsinsp.cmake +++ b/cmake/modules/libsinsp.cmake @@ -1,3 +1,17 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2023 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. +# + if(NOT HAVE_LIBSINSP) set(HAVE_LIBSINSP On) diff --git a/cmake/modules/luajit.cmake b/cmake/modules/luajit.cmake index 01b3b6a4fa..8ef8da38b0 100644 --- a/cmake/modules/luajit.cmake +++ b/cmake/modules/luajit.cmake @@ -1,6 +1,17 @@ +# SPDX-License-Identifier: Apache-2.0 # -# LuaJIT +# Copyright (C) 2023 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. +# + option(USE_BUNDLED_LUAJIT "Enable building of the bundled LuaJIT" ${USE_BUNDLED_DEPS}) if(LUAJIT_INCLUDE) diff --git a/cmake/modules/openssl.cmake b/cmake/modules/openssl.cmake index 44ce15c1df..5a806a96b9 100644 --- a/cmake/modules/openssl.cmake +++ b/cmake/modules/openssl.cmake @@ -1,6 +1,17 @@ +# SPDX-License-Identifier: Apache-2.0 # -# OpenSSL +# Copyright (C) 2023 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. +# + option(USE_BUNDLED_OPENSSL "Enable building of the bundled OpenSSL" ${USE_BUNDLED_DEPS}) if(OPENSSL_INCLUDE_DIR) diff --git a/cmake/modules/protobuf.cmake b/cmake/modules/protobuf.cmake index 48152325be..f95735e49a 100644 --- a/cmake/modules/protobuf.cmake +++ b/cmake/modules/protobuf.cmake @@ -1,3 +1,17 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (C) 2023 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. +# + option(USE_BUNDLED_PROTOBUF "Enable building of the bundled protobuf" ${USE_BUNDLED_DEPS}) if(PROTOBUF_INCLUDE) diff --git a/cmake/modules/re2.cmake b/cmake/modules/re2.cmake index 1f50c16f13..ecf9897138 100644 --- a/cmake/modules/re2.cmake +++ b/cmake/modules/re2.cmake @@ -1,6 +1,17 @@ +# SPDX-License-Identifier: Apache-2.0 # -# RE2 +# Copyright (C) 2023 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. +# + option(USE_BUNDLED_RE2 "Enable building of the bundled RE2" ${USE_BUNDLED_DEPS}) if(RE2_INCLUDE) diff --git a/cmake/modules/tbb.cmake b/cmake/modules/tbb.cmake index 05116525be..a00ec120ed 100644 --- a/cmake/modules/tbb.cmake +++ b/cmake/modules/tbb.cmake @@ -1,6 +1,17 @@ +# SPDX-License-Identifier: Apache-2.0 # -# Intel tbb +# Copyright (C) 2023 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. +# + option(USE_BUNDLED_TBB "Enable building of the bundled tbb" ${USE_BUNDLED_DEPS}) if(TBB_INCLUDE_DIR) diff --git a/cmake/modules/tinydir.cmake b/cmake/modules/tinydir.cmake index 81278674b7..e788aee3f3 100644 --- a/cmake/modules/tinydir.cmake +++ b/cmake/modules/tinydir.cmake @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: Apache-2.0 # # Copyright (C) 2023 The Falco Authors. # @@ -45,4 +46,4 @@ if(NOT TARGET tinydir) add_custom_target(tinydir) endif() -include_directories("${TINYDIR_INCLUDE}") \ No newline at end of file +include_directories("${TINYDIR_INCLUDE}") diff --git a/cmake/modules/uthash.cmake b/cmake/modules/uthash.cmake index 988a3b544b..ecc030662c 100644 --- a/cmake/modules/uthash.cmake +++ b/cmake/modules/uthash.cmake @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: Apache-2.0 # # Copyright (C) 2023 The Falco Authors. # diff --git a/cmake/modules/valijson.cmake b/cmake/modules/valijson.cmake index cb4b486619..5dcde2cd32 100644 --- a/cmake/modules/valijson.cmake +++ b/cmake/modules/valijson.cmake @@ -1,5 +1,6 @@ +# SPDX-License-Identifier: Apache-2.0 # -# Copyright (C) 2020 The Falco Authors. +# Copyright (C) 2023 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 diff --git a/cmake/modules/versions.cmake b/cmake/modules/versions.cmake index 054d46d5c7..682f8cc478 100644 --- a/cmake/modules/versions.cmake +++ b/cmake/modules/versions.cmake @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: Apache-2.0 # # Copyright (C) 2023 The Falco Authors. # @@ -48,4 +49,4 @@ function(get_shared_libs_versions _var _sovar) list(GET sl_ver_list 0 so_ver) set(${_sovar} ${so_ver} PARENT_SCOPE) return() -endfunction() \ No newline at end of file +endfunction() diff --git a/cmake/modules/zlib.cmake b/cmake/modules/zlib.cmake index f9c9d72d98..344b00bdb6 100644 --- a/cmake/modules/zlib.cmake +++ b/cmake/modules/zlib.cmake @@ -1,6 +1,17 @@ +# SPDX-License-Identifier: Apache-2.0 # -# zlib +# Copyright (C) 2023 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. +# + option(USE_BUNDLED_ZLIB "Enable building of the bundled zlib" ${USE_BUNDLED_DEPS}) if(ZLIB_INCLUDE) From eb9f467782408595430861512c566da42e3805d1 Mon Sep 17 00:00:00 2001 From: Leonardo Grasso Date: Wed, 4 Oct 2023 18:35:56 +0200 Subject: [PATCH 5/5] docs: add license header and SPDX identifier Signed-off-by: Leonardo Grasso --- .github/install-deps.sh | 18 +++++++++++------- CMakeLists.txt | 5 +++-- CMakeListsGtestInclude.cmake | 3 ++- test/libscap/CMakeLists.txt | 1 + .../engines/gvisor/gvisor_parsers.cpp | 1 + .../test_suites/userspace/common_strl.cpp | 1 + .../userspace/linux/scap_cgroup.cpp | 1 + .../test_suites/userspace/scap_event.cpp | 1 + .../test_suites/userspace/scap_ppm_sc.cpp | 1 + .../test_suites/userspace/syscall_table.cpp | 1 + 10 files changed, 23 insertions(+), 10 deletions(-) diff --git a/.github/install-deps.sh b/.github/install-deps.sh index 7520adef48..1dba90a323 100755 --- a/.github/install-deps.sh +++ b/.github/install-deps.sh @@ -1,15 +1,19 @@ #!/usr/bin/env bash +# SPDX-License-Identifier: Apache-2.0 # -# Copyright (C) 2022 The Falco Authors. +# Copyright (C) 2023 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 +# 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 +# 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. +# 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. # set -e diff --git a/CMakeLists.txt b/CMakeLists.txt index e6da655742..1e9fd4aa02 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,11 +1,12 @@ +# SPDX-License-Identifier: Apache-2.0 # -# Copyright (C) 2022 The Falco Authors. +# Copyright (C) 2023 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 +# 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, diff --git a/CMakeListsGtestInclude.cmake b/CMakeListsGtestInclude.cmake index 1ea9e7f316..01f6e5ed26 100644 --- a/CMakeListsGtestInclude.cmake +++ b/CMakeListsGtestInclude.cmake @@ -1,5 +1,6 @@ +# SPDX-License-Identifier: Apache-2.0 # -# Copyright (C) 2021 The Falco Authors. +# Copyright (C) 2023 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. diff --git a/test/libscap/CMakeLists.txt b/test/libscap/CMakeLists.txt index 9b3d470dc2..b718508848 100644 --- a/test/libscap/CMakeLists.txt +++ b/test/libscap/CMakeLists.txt @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: Apache-2.0 # # Copyright (C) 2023 The Falco Authors. # diff --git a/test/libscap/test_suites/engines/gvisor/gvisor_parsers.cpp b/test/libscap/test_suites/engines/gvisor/gvisor_parsers.cpp index 64bdb44af4..e2382e2670 100644 --- a/test/libscap/test_suites/engines/gvisor/gvisor_parsers.cpp +++ b/test/libscap/test_suites/engines/gvisor/gvisor_parsers.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/test/libscap/test_suites/userspace/common_strl.cpp b/test/libscap/test_suites/userspace/common_strl.cpp index 604f7f5fb9..e224c44b6d 100644 --- a/test/libscap/test_suites/userspace/common_strl.cpp +++ b/test/libscap/test_suites/userspace/common_strl.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/test/libscap/test_suites/userspace/linux/scap_cgroup.cpp b/test/libscap/test_suites/userspace/linux/scap_cgroup.cpp index d0f136708c..106b8b2331 100644 --- a/test/libscap/test_suites/userspace/linux/scap_cgroup.cpp +++ b/test/libscap/test_suites/userspace/linux/scap_cgroup.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/test/libscap/test_suites/userspace/scap_event.cpp b/test/libscap/test_suites/userspace/scap_event.cpp index afbcb1f234..182f09a121 100644 --- a/test/libscap/test_suites/userspace/scap_event.cpp +++ b/test/libscap/test_suites/userspace/scap_event.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/test/libscap/test_suites/userspace/scap_ppm_sc.cpp b/test/libscap/test_suites/userspace/scap_ppm_sc.cpp index 7dc3efa6c1..9da689b654 100644 --- a/test/libscap/test_suites/userspace/scap_ppm_sc.cpp +++ b/test/libscap/test_suites/userspace/scap_ppm_sc.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors. diff --git a/test/libscap/test_suites/userspace/syscall_table.cpp b/test/libscap/test_suites/userspace/syscall_table.cpp index 294075d733..135344f5a8 100644 --- a/test/libscap/test_suites/userspace/syscall_table.cpp +++ b/test/libscap/test_suites/userspace/syscall_table.cpp @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: Apache-2.0 /* Copyright (C) 2023 The Falco Authors.