1+ # build with asan
2+ # - bindings/sce fail to work because of some asan linkage issues presumed
3+ %bcond_with asan
4+
15# gconf is a legacy system not used any more, and it blocks testing of oscap-anaconda-addon
26# as gconf is no longer part of the installation medium
37%bcond_with gconf
@@ -23,6 +27,11 @@ BuildRequires: pkg-config
2327BuildRequires: systemd-rpm-macros
2428BuildRequires: gcc
2529BuildRequires: gcc-c++
30+ %if %{with asan }
31+ BuildRequires: libasan
32+ BuildRequires: libasan-static
33+ BuildRequires: libubsan
34+ %endif
2635
2736# Try to follow CMakeLists.txt order
2837BuildRequires: pkgconfig(libacl)
@@ -126,6 +135,7 @@ The %{name}-utils package contains command-line tools build on top
126135of OpenSCAP library. Historically, openscap-utils included oscap
127136tool which is now separated to %{name }-scanner sub-package.
128137
138+ %if ! %{with asan }
129139%package engine-sce
130140Summary: Script Check Engine plug-in for OpenSCAP
131141Requires: %{name }%{?_isa } = %{epoch }:%{version }-%{release }
@@ -143,6 +153,7 @@ Requires: %{name}-engine-sce%{?_isa} = %{epoch}:%{version}-%{release}
143153%description engine-sce-devel
144154The %{name }-engine-sce-devel package contains libraries and header files
145155for developing applications that use %{name }-engine-sce.
156+ %endif
146157
147158%package containers
148159Summary: Utils for scanning containers
@@ -161,6 +172,12 @@ tar xvzf %{SOURCE1} --directory=yaml-filter --strip-components=1
161172%undefine __cmake_in_source_build
162173%cmake -G Ninja \
163174 -DENABLE_DOCS=ON \
175+ %if %{with asan }
176+ -DENABLE_ASAN=TRUE \
177+ -DENABLE_PERL=OFF \
178+ -DENABLE_PYTHON=OFF \
179+ -DENABLE_SCE=OFF \
180+ %endif
164181%if ! %{with gconf }
165182 -DOPENSCAP_PROBE_UNIX_GCONF=OFF \
166183 -DGCONF_LIBRARY= \
@@ -176,6 +193,11 @@ make docs
176193%if %{with check }
177194# Tests use common files. Running tests parallel causes failed tests because of that.
178195%undefine _smp_mflags
196+ %if %{with asan }
197+ # https://github.com/google/sanitizers/wiki/AddressSanitizer
198+ # - but do not detect leaks, program is not long running, also numerous leaks so fix these completely would require some effort
199+ export ASAN_OPTIONS=detect_leaks=0:strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1:detect_invalid_pointer_pairs=2
200+ %endif
179201%ctest
180202%endif
181203
@@ -218,7 +240,9 @@ ln -sf ../oscap-remediate.service %{buildroot}%{_unitdir}/system-update.target.w
218240%{_libdir }/libopenscap.so
219241%{_libdir }/pkgconfig/* .pc
220242%{_includedir }/openscap
243+ %if ! %{with asan }
221244%exclude %{_includedir }/openscap/sce_engine_api.h
245+ %endif
222246
223247%files scanner
224248%{_bindir }/oscap
@@ -245,13 +269,15 @@ ln -sf ../oscap-remediate.service %{buildroot}%{_unitdir}/system-update.target.w
245269%{_mandir }/man8/oscap-vm.8*
246270%{_mandir }/man8/scap-as-rpm.8*
247271
272+ %if ! %{with asan }
248273%files engine-sce
249274%{_bindir }/oscap-run-sce-script
250275%{_libdir }/libopenscap_sce.so.*
251276
252277%files engine-sce-devel
253278%{_libdir }/libopenscap_sce.so
254279%{_includedir }/openscap/sce_engine_api.h
280+ %endif
255281
256282%files containers
257283%{_bindir }/oscap-docker
0 commit comments