2022-01-21 17:45:44 +00:00
#
2024-02-29 19:22:00 +00:00
# spec file for package velociraptor
2022-01-21 17:45:44 +00:00
#
2024-01-23 14:28:17 +00:00
# Copyright (c) 2024 SUSE LLC
2022-01-21 17:45:44 +00:00
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
2023-01-21 02:03:49 +00:00
2023-05-09 00:49:51 +00:00
%define flavor @BUILD_FLAVOR@%{nil}
%if "%{flavor}" == "client"
%define build_client 1
%define build_server 0
%define name_suffix -client
%define make_target linux_bare
2023-12-18 18:44:23 +00:00
%define config_perms 0600, root, root
%define state_dir_perms 0700, root, root
2023-05-09 00:49:51 +00:00
%else
%define build_server 1
%define build_client 0
%define name_suffix %{nil}
%define make_target linux
2023-12-18 18:44:23 +00:00
%define config_perms 0640, root, velociraptor
%define state_dir_perms 0700, velociraptor, velociraptor
2023-05-09 00:49:51 +00:00
%endif
2022-01-21 17:45:44 +00:00
%define projname velociraptor
2022-11-14 15:01:41 +00:00
%define vmlinux_h_version 5.14.21150400.22-150400-default
2022-01-21 17:45:44 +00:00
2024-04-03 15:02:45 +00:00
# SLE 15 SP3 / Leap 15.3 or newer gets eBPF
2023-01-21 02:50:51 +00:00
# Earlier versions don't have a usable eBPF and the
# release doesn't easily build llvm13
2024-04-03 15:02:45 +00:00
%if 0%{?suse_version} > 1500 || 0%{?sle_version} > 150200
2023-01-19 01:05:43 +00:00
%bcond_without bpf
2023-12-18 18:44:23 +00:00
%endif
%if "%{_vendor}" == "debbuild"
%bcond_without bpf
%endif
%if 0%{?rhel}
# RHEL can do BPF but we need llvm for it
%bcond_without bpf
%endif
%if "%{_vendor}" == "debbuild"
%define _unitdir /usr/lib/systemd/system
2024-04-03 15:02:45 +00:00
%endif
# Older SLE releases and debbuild don't support uppercase VERSION macro
%if "%{_vendor}" == "debbuild" || 0%{?sle_version} < 150000
2024-02-29 19:22:00 +00:00
%define VERSION %{version}
2023-01-19 01:05:43 +00:00
%endif
2023-01-21 02:03:49 +00:00
#Compat macro for new _fillupdir macro introduced in Nov 2017
%if ! %{defined _fillupdir}
%define _fillupdir %{_localstatedir}/adm/fillup-templates
%endif
# SLE12 has _sharedstatedir in an odd place
%if 0%{?sle_version} >= 120000 && 0%{?sle_version} < 150000
%define _sharedstatedir /var/lib
%endif
2023-05-09 00:49:51 +00:00
Name : velociraptor%{name_suffix}
2024-04-03 15:02:45 +00:00
Version : 0.7.0.4.git74.3426c0a
2022-01-21 17:45:44 +00:00
Release : 0
2023-05-09 00:49:51 +00:00
%if %{build_server}
2023-01-21 02:03:49 +00:00
Summary : Endpoint visibility and collection tool
2023-05-09 00:49:51 +00:00
%else
Summary : Endpoint visibility and collection tool (endpoint only)
%endif
2023-01-21 02:03:49 +00:00
Group : System/Monitoring
2022-01-21 17:45:44 +00:00
License : AGPL-3.0-only
URL : https://github.com/Velocidex/velociraptor
2023-12-18 18:44:23 +00:00
Source : %{projname} -%{version} .tar.gz
2024-04-03 15:02:45 +00:00
Source1 : velociraptor-go_modules.tar.gz
2023-12-18 18:44:23 +00:00
Source2 : vmlinux.h-%{vmlinux_h_version} .tar.xz
Source3 : velociraptor.service
Source4 : velociraptor-server.config.placeholder
Source5 : velociraptor-client.service
Source6 : velociraptor-client.config.placeholder
Source7 : sysconfig.velociraptor
Source8 : sysconfig.velociraptor-client
Source9 : %{projname} .obsinfo
Source10 : system-user-velociraptor.sysusers
Source11 : velociraptor-nodejs.spec.inc
2024-05-29 18:06:32 +00:00
Source12 : package-lock.json
2023-12-18 18:44:23 +00:00
2024-04-03 15:02:45 +00:00
%include %{_sourcedir} /velociraptor-nodejs.spec.inc
2023-12-18 18:44:23 +00:00
Patch1 : vendor-build-fixes-for-SLE12.patch
Patch2 : sdjournal-build-fix-for-SLE12.patch
Patch3 : velociraptor-reproducible-timestamp.diff
2024-05-29 18:06:32 +00:00
# PATCH-FIX-UPSTREAM CVE-2024-28849-follow-redirects-drop-proxy-authorization.patch bsc#1221456 -- follow-redirects: Drop Proxy-Athorization across hosts
2024-03-25 20:16:39 +00:00
Patch4 : CVE-2024-28849-follow-redirects-drop-proxy-authorization.patch
2024-05-29 18:06:32 +00:00
# PATCH-FIX-UPSTREAM CVE-2022-25883-npm-watch-semver-deps.patch bsc#1212572 -- upgrade npm-watch
Patch5 : CVE-2022-25883-npm-watch-semver-deps.patch
2023-01-21 02:03:49 +00:00
BuildRequires : fileb0x
2023-12-18 18:44:23 +00:00
%if 0%{?suse_version}
2022-01-21 17:45:44 +00:00
BuildRequires : systemd-rpm-macros
2023-12-18 20:31:47 +00:00
BuildRequires : golang(API) >= 1.19
2023-12-18 18:44:23 +00:00
BuildRequires : pkgconfig(libsystemd)
%endif
%if "%{_vendor}" == "debbuild"
2023-12-18 20:31:47 +00:00
BuildRequires : golang >= 2:1.19~0
2023-12-18 18:44:23 +00:00
BuildRequires : libsystemd-dev
BuildRequires : pkg-config
%endif
%if 0%{?rhel}
2023-12-18 20:31:47 +00:00
BuildRequires : golang >= 1.19
2023-12-18 18:44:23 +00:00
BuildRequires : python3
BuildRequires : systemd-devel
2023-01-21 02:03:49 +00:00
BuildRequires : pkgconfig(libsystemd)
2023-12-18 18:44:23 +00:00
%endif
2023-05-09 00:49:51 +00:00
%if %{build_server}
2023-12-18 18:44:23 +00:00
BuildRequires : local-npm-registry
2023-05-09 23:43:33 +00:00
BuildRequires : nodejs >= 18
BuildRequires : npm >= 18
2023-05-09 00:49:51 +00:00
%endif
2023-01-19 01:05:43 +00:00
%if %{with bpf}
2023-12-18 18:44:23 +00:00
%if 0%{?suse_version}
2024-04-03 15:02:45 +00:00
%if 0%{?suse_version} > 1500 || 0%{?sle_version} >= 150300
2023-05-09 00:49:51 +00:00
BuildRequires : clang16
2023-12-18 18:44:23 +00:00
BuildRequires : llvm16
2024-04-03 15:02:45 +00:00
%if 0%{?sle_version} > 150400
BuildRequires : llvm16-libclang13
%endif
2023-12-18 18:44:23 +00:00
%else
BuildRequires : clang13
BuildRequires : llvm13
%endif
2023-01-21 02:03:49 +00:00
BuildRequires : libelf-devel
2023-05-09 00:49:51 +00:00
BuildRequires : libzstd-devel
2023-12-18 18:44:23 +00:00
BuildRequires : zlib-devel
%endif
%if "%{_vendor}" == "debbuild"
BuildRequires : clang
BuildRequires : libelf-dev
BuildRequires : libzstd-dev
BuildRequires : llvm
BuildRequires : zlib1g-dev
%endif
%if 0%{?rhel}
BuildRequires : clang >= 13
BuildRequires : libelf-devel
2023-05-09 00:49:51 +00:00
BuildRequires : libzstd-devel
2023-12-18 18:44:23 +00:00
BuildRequires : llvm >= 13
2023-05-09 00:49:51 +00:00
BuildRequires : zlib-devel
2023-01-19 01:05:43 +00:00
%endif
2023-12-18 18:44:23 +00:00
%endif
2023-05-09 02:00:49 +00:00
%if %{build_server}
2023-05-09 00:49:51 +00:00
BuildRequires : sysuser-tools
2023-07-20 09:59:08 +00:00
Requires : group(velociraptor)
Requires : user(velociraptor)
2024-04-05 13:08:37 +00:00
Obsoletes : velociraptor-kafka-humio-gateway < %{version}
2023-05-09 00:49:51 +00:00
%{?sysusers_requires}
%endif
2022-01-21 17:45:44 +00:00
2024-04-18 12:45:01 +00:00
%if 0%{?suse_version}
2024-04-27 16:58:31 +00:00
# SLE12 doesn't support sysusers and releases lower than SP4 don't build the server flavor which includes the system-user-velociraptor package.
%if 0%{?sle_version} >= 120000 && 0%{?sle_version} < 150400
2024-04-17 19:45:07 +00:00
Requires(pre) : pwdutils
2024-04-18 12:45:01 +00:00
%define pre_create_group 1
2024-04-17 19:45:07 +00:00
%else
Requires : group(velociraptor)
%endif
2024-04-18 12:45:01 +00:00
%endif
2024-04-17 19:45:07 +00:00
2023-12-18 18:44:23 +00:00
%if %{build_server}
2024-04-17 19:45:07 +00:00
%if 0%{?suse_version} > 1500 || 0%{?sle_version} >= 150400
2023-12-18 18:44:23 +00:00
ExclusiveArch : x86_64
%else
ExclusiveArch : do_not_build
2024-04-17 19:45:07 +00:00
%endif
2023-12-18 18:44:23 +00:00
%else
ExclusiveArch : x86_64 ppc64le aarch64 s390x
%endif
%if 0%{?rhel}
# RHEL builds aren't working yet
ExclusiveArch : do_not_build
%endif
2023-12-21 00:29:28 +00:00
# Not *required* but without it, we spam the system log
Recommends: auditd
2024-04-17 19:45:07 +00:00
%if 0%{?_project:1} && (0%{?suse_version} > 1500 || 0%{?sle_version} > 150000)
Provides : %{name} (project:%_project)
%endif
2023-12-21 00:29:28 +00:00
%if "%{vendor}" == "debbuild"
%define mtag Packager: https://www.suse.com
%mtag
%endif
2023-05-09 00:49:51 +00:00
%if %{build_server}
2022-01-21 17:45:44 +00:00
%description
Velociraptor is a tool for collecting host based state information
using The Velociraptor Query Language (VQL) queries.
To learn more about Velociraptor, read the documentation on:
https://docs.velociraptor.app/
2023-05-09 00:49:51 +00:00
This package contains the velociraptor server and full console GUI.
2022-01-21 17:45:44 +00:00
For just the endpoint agent, please install the 'velociraptor-client' package.
2023-05-09 02:00:49 +00:00
2024-02-29 19:22:00 +00:00
%package -n system-user-velociraptor
Summary : System user and group 'velociraptor'
Version : 1.0.0
License : Apache-2.0
Group : System/Monitoring
Provides : group(velociraptor)
Provides : user(velociraptor)
2024-04-23 11:45:06 +00:00
BuildArch : noarch
2024-02-29 19:22:00 +00:00
%description -n system-user-velociraptor
This package provides a shared system user for all velociraptor components
2023-05-09 00:49:51 +00:00
%endif
%if %{build_client}
%description
Velociraptor is a tool for collecting host based state information
using The Velociraptor Query Language (VQL) queries.
To learn more about Velociraptor, read the documentation on:
https://docs.velociraptor.app/
This package contains only the endpoint agent. For the full server and GUI
console, please install the 'velociraptor' package.
%endif
2022-01-21 17:45:44 +00:00
%prep
2024-02-29 19:22:00 +00:00
%setup -q -a 1 -a 2 -n %{projname} -%{VERSION}
2024-03-25 20:16:39 +00:00
%patch -P 1 -p1
%patch -P 2 -p1
%patch -P 3 -p1
2024-05-29 18:06:32 +00:00
%patch -P 4 -p1
%patch -P 5 -p1
2022-01-21 17:45:44 +00:00
# Set the version to something more specific than <next-tag>-dev
2024-02-29 19:22:00 +00:00
sed -ie " s / \ ( [ [ : s p a c e : ] ] V E R S I O N * = \ ) . * / \1 \" %{VERSION} \" / " constants/constants.go
2022-01-21 17:45:44 +00:00
2023-01-19 01:05:43 +00:00
%if %{with bpf}
2022-08-19 18:30:12 +00:00
mkdir -p third_party/libbpfgo/output
2022-11-12 01:51:37 +00:00
2023-12-18 18:44:23 +00:00
arch=%{_arch}
if test " $ a r c h " = " a m d 6 4 " ; then
arch=x86_64
fi
cp vmlinux.h-%{vmlinux_h_version} /vmlinux-${arch}.h \
2022-11-14 15:01:41 +00:00
third_party/libbpfgo/output/vmlinux.h
2023-01-19 01:05:43 +00:00
%endif
2022-08-19 18:30:12 +00:00
2022-01-21 17:45:44 +00:00
# These just clutter the GUI and we don't have Windows clients
2022-02-07 18:30:48 +00:00
# Note: There are dependencies on these that need to be resolved before
# removing them outright.
2022-05-05 18:38:36 +00:00
# rm -rf artifacts/definitions/Windows
2023-12-18 18:44:23 +00:00
%if %{build_server}
pushd gui/velociraptor
rm -f package-lock.json
2024-05-29 18:06:32 +00:00
local-npm-registry %{_sourcedir} install --include=dev --legacy-peer-deps
2023-12-18 18:44:23 +00:00
popd
%endif
2022-01-21 17:45:44 +00:00
%build
2023-01-25 13:29:03 +00:00
2023-12-18 18:44:23 +00:00
# Reproducible builds need stable timestamps
timestamp=$(date -Iseconds --utc --date=@$(grep mtime: %{SOURCE9} |sed -e 's/mtime: //' ))
git_commit=$(grep commit: %{SOURCE9} |sed -e 's/commit: //g' )
2023-01-25 13:29:03 +00:00
export VELOCIRAPTOR_BUILD_TIME=$timestamp
export VELOCIRAPTOR_GIT_HEAD=$git_commit
2023-05-09 00:49:51 +00:00
%if %{build_server}
2022-01-21 17:45:44 +00:00
(cd gui/velociraptor ; npm run build)
2023-12-18 18:44:23 +00:00
%sysusers_generate_pre %{SOURCE10} velociraptor-user
2023-05-09 00:49:51 +00:00
%endif
2023-12-18 18:44:23 +00:00
%if 0%{?suse_version}
LLVM_STRIP=llvm-strip
%else
LLVM_STRIP=llvm-strip
2023-05-09 00:49:51 +00:00
%endif
2022-03-15 14:14:34 +00:00
2023-12-18 18:44:23 +00:00
CLANG=clang
PATH=$PATH:/usr/sbin make %{make_target} BUILD_BPF_PLUGINS=%{with bpf} CLANG=$CLANG STRIP=$LLVM_STRIP
2022-01-21 17:45:44 +00:00
%install
2023-05-09 00:49:51 +00:00
install -D -d -m 0750 %buildroot/%{_sysconfdir} /velociraptor
install -D -d -m 0700 %buildroot/%{_sharedstatedir} /%{name} /data
install -D -d -m 0700 %buildroot/%{_sharedstatedir} /%{name} /logs
install -D -d -m 0700 %buildroot/%{_sharedstatedir} /%{name} /tmp
%if %{build_server}
2023-12-19 14:25:07 +00:00
service_file_source=%{SOURCE3}
config_file_source=%{SOURCE4}
2023-12-18 18:44:23 +00:00
sysconfig_file_source=%{SOURCE7}
2023-05-09 00:49:51 +00:00
config_file=server.config
2023-05-09 02:00:49 +00:00
2023-12-18 18:44:23 +00:00
install -D -m 0644 %{SOURCE10} %{buildroot} %{_sysusersdir} /system-user-velociraptor.conf
2023-05-09 00:49:51 +00:00
%else
2023-12-19 14:25:07 +00:00
service_file_source=%{SOURCE5}
config_file_source=%{SOURCE6}
2023-12-18 18:44:23 +00:00
sysconfig_file_source=%{SOURCE8}
2023-05-09 00:49:51 +00:00
config_file=client.config
%endif
2023-12-21 00:29:28 +00:00
%if 0%{?suse_version}
2023-05-09 00:49:51 +00:00
install -D -m 0644 " $ s y s c o n f i g _ f i l e _ s o u r c e " %{buildroot} %{_fillupdir} /sysconfig.%{name}
2023-12-21 00:29:28 +00:00
%endif
%if "%{vendor}" == "debbuild"
install -D -m 0644 " $ s y s c o n f i g _ f i l e _ s o u r c e " %{buildroot} /%{_sysconfdir} /default/%{name}
%endif
install -D -m 0644 " $ s e r v i c e _ f i l e _ s o u r c e " %{buildroot} %{_unitdir} /%{name} .service
2023-05-09 00:49:51 +00:00
install -D -m 0640 " $ c o n f i g _ f i l e _ s o u r c e " " %{buildroot} %{_sysconfdir} / v e l o c i r a p t o r / $ c o n f i g _ f i l e "
2024-02-29 19:22:00 +00:00
install -D -m 0755 output/velociraptor-v%{VERSION} -linux-* %buildroot/%{_bindir} /%{name}
2023-05-09 00:49:51 +00:00
2022-01-21 17:45:44 +00:00
%files
2023-01-21 02:03:49 +00:00
%defattr (-, root, root)
2022-01-21 17:45:44 +00:00
%license LICENSE
%doc README.md
2023-05-09 00:49:51 +00:00
%{_bindir} /%{name}
2022-02-02 18:59:59 +00:00
%{_unitdir} /%{name} .service
2023-12-21 00:29:28 +00:00
%if 0%{?suse_version}
2023-01-19 15:27:12 +00:00
%{_fillupdir} /sysconfig.%{name}
2023-12-21 00:29:28 +00:00
%endif
%if "%{vendor}" == "debbuild"
%{_sysconfdir} /default/%{name}
%endif
2022-02-02 18:59:59 +00:00
2023-05-09 00:49:51 +00:00
%dir %attr (-, root, velociraptor) %{_sysconfdir} /velociraptor
2023-12-18 18:44:23 +00:00
%config (noreplace) %attr (%{config_perms} ) %{_sysconfdir} /velociraptor/*.config
%dir %attr (%{state_dir_perms} ) %{_sharedstatedir} /%{name}
%dir %attr (%{state_dir_perms} ) %{_sharedstatedir} /%{name} /data
%dir %attr (%{state_dir_perms} ) %{_sharedstatedir} /%{name} /logs
%dir %attr (%{state_dir_perms} ) %{_sharedstatedir} /%{name} /tmp
%if %{build_server}
2024-02-29 19:22:00 +00:00
%files -n system-user-velociraptor
%defattr (-, root, root)
2023-12-18 18:44:23 +00:00
%{_sysusersdir} /system-user-velociraptor.conf
2024-02-29 19:22:00 +00:00
%pre -n system-user-velociraptor -f velociraptor-user.pre
2023-12-18 18:44:23 +00:00
%endif
2023-12-21 00:29:28 +00:00
%if 0%{?suse_version}
2022-02-02 18:59:59 +00:00
%pre
2024-04-18 12:45:01 +00:00
%if 0%{?pre_create_group}
2024-04-17 19:45:07 +00:00
# create velociraptor group if it doesn't exist
groupadd -f -r velociraptor 2>/dev/null || :
%endif
2023-05-09 00:49:51 +00:00
%service_add_pre %{name} .service
2022-02-02 18:59:59 +00:00
%post
2023-01-19 15:27:12 +00:00
%{fillup_only}
2023-05-09 00:49:51 +00:00
%service_add_post %{name} .service
2022-02-02 18:59:59 +00:00
%preun
2023-05-09 00:49:51 +00:00
%service_del_preun %{name} .service
2022-02-02 18:59:59 +00:00
%postun
2023-05-09 00:49:51 +00:00
%service_del_postun %{name} .service
2023-12-21 00:29:28 +00:00
%endif
2023-05-09 00:49:51 +00:00
2024-01-23 14:28:17 +00:00
%if "%{_vendor}" == "debbuild"
2023-12-21 00:29:28 +00:00
%postun
# Automatically added by dh_installsystemd/13.11.4
if [ " $ 1 " = remove ] && [ -d /run/systemd/system ] ; then
systemctl --system daemon-reload >/dev/null || true
fi
# End automatically added section
# Automatically added by dh_installsystemd/13.11.4
if [ " $ 1 " = " p u r g e " ]; then
if [ -x " / u s r / b i n / d e b - s y s t e m d - h e l p e r " ]; then
deb-systemd-helper purge 'velociraptor-client.service' >/dev/null || true
fi
fi
# End automatically added section
2023-05-09 00:49:51 +00:00
%endif
2022-01-21 17:45:44 +00:00
%changelog