Skip to content

Commit 0b657c3

Browse files
committed
Added possibility to build with ASAN
+ github workflow for ASAN + update of gtest & pytest
1 parent 8830883 commit 0b657c3

File tree

9 files changed

+53
-4
lines changed

9 files changed

+53
-4
lines changed

.github/workflows/pipeline.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,31 @@ jobs:
9898
if-no-files-found: error
9999
retention-days: 7
100100

101+
asan:
102+
runs-on: ubuntu-latest
103+
steps:
104+
- name: Setup Git
105+
run: |
106+
git config --global core.autocrlf false
107+
git config --global core.eol lf
108+
- name: Checkout sources
109+
uses: actions/checkout@v3
110+
- name: Build
111+
run: |
112+
mkdir -p build
113+
cd build
114+
cmake -DYARAMOD_TESTS=ON -DYARAMOD_ASAN=ON ..
115+
cmake --build . -- -j
116+
# Disable ASLR for this, see https://stackoverflow.com/questions/77894856/possible-bug-in-gcc-sanitizers
117+
- name: Tests
118+
echo 0 | sudo tee /proc/sys/kernel/randomize_va_space
119+
./build/tests/cpp/yaramod_tests
120+
101121
release:
102122
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
103-
needs: tests
123+
needs:
124+
- tests
125+
- asan
104126
runs-on: ubuntu-latest
105127
steps:
106128
- name: Downloads wheels

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ option(YARAMOD_TESTS "Build tests for yaramod" OFF)
1010
option(YARAMOD_DOCS "Build doxygen documentation for yaramod" OFF)
1111
option(YARAMOD_PYTHON "Build Python extension" OFF)
1212
option(YARAMOD_EXAMPLES "Build examples" OFF)
13+
option(YARAMOD_ASAN "Build with ASAN" OFF)
1314

1415
# Add CMake module path.
1516
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")

deps/googletest/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ if(CMAKE_CXX_COMPILER)
1212
endif()
1313

1414
ExternalProject_Add(googletest
15-
URL https://github.com/google/googletest/archive/58d77fa8070e8cec2dc1ed015d66b454c8d78850.zip
16-
URL_HASH SHA256=ab78fa3f912d44d38b785ec011a25f26512aaedc5291f51f3807c592b506d33a
15+
URL https://github.com/google/googletest/archive/a7f443b80b105f940225332ed3c31f2790092f47.zip
16+
URL_HASH SHA256=ecb351335da20ab23ea5f14c107a10c475dfdd27d8a50d968757942280dffbe3
1717
CMAKE_ARGS
1818
# This does not work on MSVC, but is useful on Linux.
1919
-DCMAKE_BUILD_TYPE=Release

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
pytest>=4.2.0,<5.0.0
1+
pytest>=6.2.5,<7.0.0
22
pypandoc>=1.4
33
setuptools>=62.4.0

src/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ if(NOT TARGET yaramod)
6363
# Filesystem library.
6464
target_link_libraries(yaramod Filesystem::Filesystem)
6565

66+
# Address sanitizer.
67+
if(YARAMOD_ASAN)
68+
target_compile_options(yaramod PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer")
69+
target_link_options(yaramod PRIVATE "-fsanitize=address")
70+
endif()
71+
6672
# Python module.
6773
if(YARAMOD_PYTHON)
6874
add_subdirectory(python)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
add_executable(dump-rules-ast main.cpp)
22
target_link_libraries(dump-rules-ast yaramod)
3+
4+
if(YARAMOD_ASAN)
5+
target_compile_options(dump-rules-ast PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer")
6+
target_link_options(dump-rules-ast PRIVATE "-fsanitize=address")
7+
endif()
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
add_executable(simplify-bools main.cpp)
22
target_link_libraries(simplify-bools yaramod)
3+
4+
if(YARAMOD_ASAN)
5+
target_compile_options(simplify-bools PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer")
6+
target_link_options(simplify-bools PRIVATE "-fsanitize=address")
7+
endif()

src/python/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,8 @@ endif()
1616

1717
set_target_properties(yaramod-python PROPERTIES OUTPUT_NAME "yaramod")
1818
target_link_libraries(yaramod-python PUBLIC yaramod)
19+
20+
if(YARAMOD_ASAN)
21+
target_compile_options(yaramod-python PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer")
22+
target_link_options(yaramod-python PRIVATE "-fsanitize=address")
23+
endif()

tests/cpp/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,9 @@ if(NOT TARGET yaramod_tests)
2424

2525
# Includes.
2626
target_include_directories(yaramod_tests PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}")
27+
28+
if(YARAMOD_ASAN)
29+
target_compile_options(yaramod_tests PRIVATE "-fsanitize=address" "-fno-omit-frame-pointer")
30+
target_link_options(yaramod_tests PRIVATE "-fsanitize=address")
31+
endif()
2732
endif()

0 commit comments

Comments
 (0)