From 725f5f908a3a8fd7fca0301c21a605a786cf705f Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Tue, 19 Aug 2025 10:22:50 +0200 Subject: [PATCH 01/11] Add asan example Signed-off-by: Uilian Ries --- .../sanitizers/compiler_sanitizers/README.md | 3 +++ .../index_out_of_bounds/CMakeLists.txt | 11 ++++++++ .../index_out_of_bounds/conanfile.py | 25 +++++++++++++++++++ .../index_out_of_bounds/main.cpp | 15 +++++++++++ .../compiler_sanitizers/profiles/asan | 16 ++++++++++++ .../compiler_sanitizers/profiles/asan_ubsan | 8 ++++++ .../compiler_sanitizers/settings_user.yml | 9 +++++++ 7 files changed, 87 insertions(+) create mode 100644 examples/dev_flow/sanitizers/compiler_sanitizers/README.md create mode 100644 examples/dev_flow/sanitizers/compiler_sanitizers/index_out_of_bounds/CMakeLists.txt create mode 100644 examples/dev_flow/sanitizers/compiler_sanitizers/index_out_of_bounds/conanfile.py create mode 100644 examples/dev_flow/sanitizers/compiler_sanitizers/index_out_of_bounds/main.cpp create mode 100644 examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan create mode 100644 examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan_ubsan create mode 100644 examples/dev_flow/sanitizers/compiler_sanitizers/settings_user.yml diff --git a/examples/dev_flow/sanitizers/compiler_sanitizers/README.md b/examples/dev_flow/sanitizers/compiler_sanitizers/README.md new file mode 100644 index 00000000..13b461e9 --- /dev/null +++ b/examples/dev_flow/sanitizers/compiler_sanitizers/README.md @@ -0,0 +1,3 @@ +# Compiler Sanitizers Example + +This example follows the documented page https://docs.conan.io/2/examples/dev_flow/sanitizers/compiler_sanitizers. \ No newline at end of file diff --git a/examples/dev_flow/sanitizers/compiler_sanitizers/index_out_of_bounds/CMakeLists.txt b/examples/dev_flow/sanitizers/compiler_sanitizers/index_out_of_bounds/CMakeLists.txt new file mode 100644 index 00000000..aef030e4 --- /dev/null +++ b/examples/dev_flow/sanitizers/compiler_sanitizers/index_out_of_bounds/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.15) +project(index_out_of_bounds LANGUAGES CXX) + +add_executable(index_out_of_bounds main.cpp) +target_compile_features(index_out_of_bounds PUBLIC cxx_std_11) +target_compile_options(index_out_of_bounds PRIVATE -fsanitize=address) +target_link_options(index_out_of_bounds PRIVATE -fsanitize=address) + +include(GNUInstallDirs) +install(TARGETS index_out_of_bounds + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/examples/dev_flow/sanitizers/compiler_sanitizers/index_out_of_bounds/conanfile.py b/examples/dev_flow/sanitizers/compiler_sanitizers/index_out_of_bounds/conanfile.py new file mode 100644 index 00000000..ddb628c8 --- /dev/null +++ b/examples/dev_flow/sanitizers/compiler_sanitizers/index_out_of_bounds/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, cmake_layout, CMakeToolchain + +required_conan_version = ">=2.1.0" + +class IndexOutOfBoundsConan(ConanFile): + name = "index_out_of_bounds" + version = "0.1.0" + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain" + exports_sources = "CMakeLists.txt", "main.cpp" + package_type = "application" + languages = ["C++"] + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + cmake = CMake(self) + cmake.install() \ No newline at end of file diff --git a/examples/dev_flow/sanitizers/compiler_sanitizers/index_out_of_bounds/main.cpp b/examples/dev_flow/sanitizers/compiler_sanitizers/index_out_of_bounds/main.cpp new file mode 100644 index 00000000..8067fe62 --- /dev/null +++ b/examples/dev_flow/sanitizers/compiler_sanitizers/index_out_of_bounds/main.cpp @@ -0,0 +1,15 @@ +#include +#include + +int main() { + #ifdef __SANITIZE_ADDRESS__ + std::cout << "Address sanitizer enabled\n"; + #else + std::cout << "Address sanitizer not enabled\n"; + #endif + + int foo[100]; + foo[100] = 42; // Out-of-bounds write + + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan b/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan new file mode 100644 index 00000000..05093a6a --- /dev/null +++ b/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan @@ -0,0 +1,16 @@ +include(default) + +[settings] +compiler.sanitizer=Address + +[conf] +{% if compiler == "msvc" %} +tools.build:cflags=['/fsanitize=address'] +tools.build:cxxflags=['/fsanitize=address'] +{% else %} +tools.build:cflags=['-fsanitize=address'] +tools.build:cxxflags=['-fsanitize=address'] +{% endif %} + +[runenv] +ASAN_OPTIONS=log_path={{ package_metadata_folder }}/sanitizer \ No newline at end of file diff --git a/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan_ubsan b/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan_ubsan new file mode 100644 index 00000000..22e43ab8 --- /dev/null +++ b/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan_ubsan @@ -0,0 +1,8 @@ +include(default) + +[settings] +compiler.sanitizer=AddressUndefinedBehavior + +[conf] +tools.build:cflags=['-fsanitize=address,undefined'] +tools.build:cxxflags=['-fsanitize=address,undefined'] diff --git a/examples/dev_flow/sanitizers/compiler_sanitizers/settings_user.yml b/examples/dev_flow/sanitizers/compiler_sanitizers/settings_user.yml new file mode 100644 index 00000000..f274c7b9 --- /dev/null +++ b/examples/dev_flow/sanitizers/compiler_sanitizers/settings_user.yml @@ -0,0 +1,9 @@ +compiler: + gcc: + sanitizer: [None, Address, Leak, Thread, UndefinedBehavior, HardwareAssistanceAddress, KernelAddress, AddressUndefinedBehavior, ThreadUndefinedBehavior] + clang: + sanitizer: [None, Address, Leak, Thread, Memory, UndefinedBehavior, HardwareAssistanceAddress, KernelAddress, AddressUndefinedBehavior, ThreadUndefinedBehavior] + apple-clang: + sanitizer: [None, Address, Leak, Thread, Memory, UndefinedBehavior, HardwareAssistanceAddress, KernelAddress, AddressUndefinedBehavior, ThreadUndefinedBehavior] + msvc: + sanitizer: [None, Address, KernelAddress] \ No newline at end of file From b43cc0dab0f76ad7d5277f4fa82502f57b8e2388 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Tue, 19 Aug 2025 13:32:45 +0200 Subject: [PATCH 02/11] Add profiles and code example Signed-off-by: Uilian Ries --- .../index_out_of_bounds/CMakeLists.txt | 2 -- .../index_out_of_bounds/conanfile.py | 5 +++- .../compiler_sanitizers/profiles/asan | 3 -- .../compiler_sanitizers/profiles/asan_ubsan | 2 +- .../signed_integer_overflow/CMakeLists.txt | 11 ++++++++ .../signed_integer_overflow/conanfile.py | 28 +++++++++++++++++++ .../signed_integer_overflow/main.cpp | 16 +++++++++++ 7 files changed, 60 insertions(+), 7 deletions(-) create mode 100644 examples/dev_flow/sanitizers/compiler_sanitizers/signed_integer_overflow/CMakeLists.txt create mode 100644 examples/dev_flow/sanitizers/compiler_sanitizers/signed_integer_overflow/conanfile.py create mode 100644 examples/dev_flow/sanitizers/compiler_sanitizers/signed_integer_overflow/main.cpp diff --git a/examples/dev_flow/sanitizers/compiler_sanitizers/index_out_of_bounds/CMakeLists.txt b/examples/dev_flow/sanitizers/compiler_sanitizers/index_out_of_bounds/CMakeLists.txt index aef030e4..1498db2a 100644 --- a/examples/dev_flow/sanitizers/compiler_sanitizers/index_out_of_bounds/CMakeLists.txt +++ b/examples/dev_flow/sanitizers/compiler_sanitizers/index_out_of_bounds/CMakeLists.txt @@ -3,8 +3,6 @@ project(index_out_of_bounds LANGUAGES CXX) add_executable(index_out_of_bounds main.cpp) target_compile_features(index_out_of_bounds PUBLIC cxx_std_11) -target_compile_options(index_out_of_bounds PRIVATE -fsanitize=address) -target_link_options(index_out_of_bounds PRIVATE -fsanitize=address) include(GNUInstallDirs) install(TARGETS index_out_of_bounds diff --git a/examples/dev_flow/sanitizers/compiler_sanitizers/index_out_of_bounds/conanfile.py b/examples/dev_flow/sanitizers/compiler_sanitizers/index_out_of_bounds/conanfile.py index ddb628c8..85cd00a3 100644 --- a/examples/dev_flow/sanitizers/compiler_sanitizers/index_out_of_bounds/conanfile.py +++ b/examples/dev_flow/sanitizers/compiler_sanitizers/index_out_of_bounds/conanfile.py @@ -7,7 +7,6 @@ class IndexOutOfBoundsConan(ConanFile): name = "index_out_of_bounds" version = "0.1.0" settings = "os", "arch", "compiler", "build_type" - generators = "CMakeToolchain" exports_sources = "CMakeLists.txt", "main.cpp" package_type = "application" languages = ["C++"] @@ -15,6 +14,10 @@ class IndexOutOfBoundsConan(ConanFile): def layout(self): cmake_layout(self) + def generate(self): + tc = CMakeToolchain(self) + tc.generate() + def build(self): cmake = CMake(self) cmake.configure() diff --git a/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan b/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan index 05093a6a..5dd77d2e 100644 --- a/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan +++ b/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan @@ -11,6 +11,3 @@ tools.build:cxxflags=['/fsanitize=address'] tools.build:cflags=['-fsanitize=address'] tools.build:cxxflags=['-fsanitize=address'] {% endif %} - -[runenv] -ASAN_OPTIONS=log_path={{ package_metadata_folder }}/sanitizer \ No newline at end of file diff --git a/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan_ubsan b/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan_ubsan index 22e43ab8..a6f1edb7 100644 --- a/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan_ubsan +++ b/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan_ubsan @@ -1,4 +1,4 @@ -include(default) +include(clang20) [settings] compiler.sanitizer=AddressUndefinedBehavior diff --git a/examples/dev_flow/sanitizers/compiler_sanitizers/signed_integer_overflow/CMakeLists.txt b/examples/dev_flow/sanitizers/compiler_sanitizers/signed_integer_overflow/CMakeLists.txt new file mode 100644 index 00000000..cb79d53f --- /dev/null +++ b/examples/dev_flow/sanitizers/compiler_sanitizers/signed_integer_overflow/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.15) +project(signed_integer_overflow LANGUAGES CXX) + +add_executable(signed_integer_overflow main.cpp) +target_compile_features(signed_integer_overflow PUBLIC cxx_std_11) +target_compile_options(signed_integer_overflow PRIVATE -fsanitize=address) +target_link_options(signed_integer_overflow PRIVATE -fsanitize=address) + +include(GNUInstallDirs) +install(TARGETS signed_integer_overflow + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/examples/dev_flow/sanitizers/compiler_sanitizers/signed_integer_overflow/conanfile.py b/examples/dev_flow/sanitizers/compiler_sanitizers/signed_integer_overflow/conanfile.py new file mode 100644 index 00000000..c7c85802 --- /dev/null +++ b/examples/dev_flow/sanitizers/compiler_sanitizers/signed_integer_overflow/conanfile.py @@ -0,0 +1,28 @@ +from conan import ConanFile +from conan.tools.cmake import CMake, cmake_layout, CMakeToolchain + +required_conan_version = ">=2.1.0" + +class SignedIntegerOverflowConan(ConanFile): + name = "signed_integer_overflow" + version = "0.1.0" + settings = "os", "arch", "compiler", "build_type" + exports_sources = "CMakeLists.txt", "main.cpp" + package_type = "application" + languages = ["C++"] + + def layout(self): + cmake_layout(self) + + def generate(self): + tc = CMakeToolchain(self) + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + cmake = CMake(self) + cmake.install() \ No newline at end of file diff --git a/examples/dev_flow/sanitizers/compiler_sanitizers/signed_integer_overflow/main.cpp b/examples/dev_flow/sanitizers/compiler_sanitizers/signed_integer_overflow/main.cpp new file mode 100644 index 00000000..52a5eac5 --- /dev/null +++ b/examples/dev_flow/sanitizers/compiler_sanitizers/signed_integer_overflow/main.cpp @@ -0,0 +1,16 @@ +#include +#include +#include + +int main(int argc, char* argv[]) { + #ifdef __SANITIZE_ADDRESS__ + std::cout << "Address sanitizer enabled\n"; + #else + std::cout << "Address sanitizer not enabled\n"; + #endif + + int foo = 0x7fffffff; + foo += argc; // Signed integer overflow + + return EXIT_SUCCESS; +} \ No newline at end of file From 0992cedebcb96f0bbe016058d9ed342914a14ba2 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Tue, 19 Aug 2025 13:51:12 +0200 Subject: [PATCH 03/11] Improve README Signed-off-by: Uilian Ries --- .../sanitizers/compiler_sanitizers/README.md | 80 ++++++++++++++++++- 1 file changed, 79 insertions(+), 1 deletion(-) diff --git a/examples/dev_flow/sanitizers/compiler_sanitizers/README.md b/examples/dev_flow/sanitizers/compiler_sanitizers/README.md index 13b461e9..decfa39c 100644 --- a/examples/dev_flow/sanitizers/compiler_sanitizers/README.md +++ b/examples/dev_flow/sanitizers/compiler_sanitizers/README.md @@ -1,3 +1,81 @@ # Compiler Sanitizers Example -This example follows the documented page https://docs.conan.io/2/examples/dev_flow/sanitizers/compiler_sanitizers. \ No newline at end of file +This example follows the documented page https://docs.conan.io/2/examples/dev_flow/sanitizers/compiler_sanitizers. + +## Examples + +Here are some examples of using compiler sanitizers with Conan. + +### Signed Integer Overflow + +This example demonstrates how to detect signed integer overflow using compiler sanitizers. The provided C++ code intentionally causes a signed integer overflow, which can be detected when running the program with the appropriate sanitizer flags. + +It explores the [Undefined Behavior Sanitizer](https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html), **ONLY** available in Clang and GCC; MSVC does not support it (yet). + +In order to try the example, you may run the following commands: + +``` +conan create signed_integer_overflow/ -pr profiles/asan_ubsan +conan install --requires=signed_integer_overflow/0.1.0 -pr profiles/asan_ubsan -of install +source install/conanrun.sh +signed_integer_overflow +``` +It's expected to observe a runtime error indicating a signed integer overflow has occurred: + +``` +Address sanitizer not enabled +/home/conan/.conan2/p/b/signe3b8ad6d59f30b/b/main.cpp:13:9: runtime error: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int' +SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/conan/.conan2/p/b/signe3b8ad6d59f30b/b/main.cpp:13:9 +``` + +### Index Out of Bounds + +This example demonstrates how to detect out-of-bounds memory access using compiler sanitizers. The provided C++ code intentionally accesses an out-of-bounds index in an array, which can be detected when running the program with the appropriate sanitizer flags. + +It explores the [Address Sanitizer](https://clang.llvm.org/docs/AddressSanitizer.html), available in Clang, GCC and MSVC. + +In order to try the example, you may run the following commands: + +``` +conan create index_out_of_bounds/ -pr profiles/asan +conan install --requires=index_out_of_bounds/0.1.0 -pr profiles/asan -of install +source install/conanrun.sh +index_out_of_bounds +``` + +It's expected to observe a runtime error indicating an out-of-bounds memory access has occurred: + +``` +==357155==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffcddcc40e0 at pc 0x5946a605f2eb bp 0x7ffcddcc3f10 sp 0x7ffcddcc3f00 +WRITE of size 4 at 0x7ffcddcc40e0 thread T0 + #0 0x5946a605f2ea in main (/home/conan/.conan2/p/b/index7e914f42d466f/p/bin/index_out_of_bounds+0x12ea) + #1 0x7722f0c29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 + #2 0x7722f0c29e3f in __libc_start_main_impl ../csu/libc-start.c:392 + #3 0x5946a605f3d4 in _start (/home/conan/.conan2/p/b/index7e914f42d466f/p/bin/index_out_of_bounds+0x13d4) + +Address 0x7ffcddcc40e0 is located in stack of thread T0 at offset 448 in frame + #0 0x5946a605f1ef in main (/home/conan/.conan2/p/b/index7e914f42d466f/p/bin/index_out_of_bounds+0x11ef) + + This frame has 1 object(s): + [48, 448) 'foo' (line 11) <== Memory access at offset 448 overflows this variable +HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork + (longjmp and C++ exceptions *are* supported) +SUMMARY: AddressSanitizer: stack-buffer-overflow (/home/conan/.conan2/p/b/index7e914f42d466f/p/bin/index_out_of_bounds+0x12ea) in main +``` + +## Customizing Sanitizers + +### Using Environment Variables + +The `ASAN_OPTIONS` and `UBSAN_OPTIONS` environment variables can be used to customize the behavior of AddressSanitizer and UndefinedBehaviorSanitizer, respectively. For example, you can set the `ASAN_OPTIONS` variable to control the reporting format, enable or disable specific checks, and more. + +To set these environment variables, you can use the `export` command in your terminal before running your program: + +```bash +export ASAN_OPTIONS=detect_leaks=1:log_path=asan.log +export UBSAN_OPTIONS=print_stacktrace=1 +``` + +This will enable leak detection for AddressSanitizer and print stack traces for UndefinedBehaviorSanitizer. + +For more advanced configurations, you can refer to the [Clang AddressSanitizer](https://github.com/google/sanitizers/wiki/addresssanitizerflags#run-time-flags) and [MSVC AddressSanitizer](https://learn.microsoft.com/en-us/cpp/sanitizers/asan?view=msvc-170#differences) documentation. From 738ee16f519b7e629f9c84719a8d0ba3a26b39af Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Tue, 19 Aug 2025 14:03:20 +0200 Subject: [PATCH 04/11] Add settings_user section in the README Signed-off-by: Uilian Ries --- .../sanitizers/compiler_sanitizers/README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/examples/dev_flow/sanitizers/compiler_sanitizers/README.md b/examples/dev_flow/sanitizers/compiler_sanitizers/README.md index decfa39c..f8888c79 100644 --- a/examples/dev_flow/sanitizers/compiler_sanitizers/README.md +++ b/examples/dev_flow/sanitizers/compiler_sanitizers/README.md @@ -6,6 +6,19 @@ This example follows the documented page https://docs.conan.io/2/examples/dev_fl Here are some examples of using compiler sanitizers with Conan. +### Configuring Custom Settings + +Before trying to build using the profiles prepared to work with sanitizers, you may want to configure some custom settings in your Conan home. +It's not needed to modify the `settings.yml` file, instead, you can install a custom settings using [settings_user.yml](https://docs.conan.io/2/reference/config_files/settings.html#settings-user-yml) + +``` +cp settings_user.yml $(conan config home) +``` + +This setting allows you to customize the behavior of the sanitizers, enabling or disabling specific checks as needed. +Be aware once it's installed in your Conan home, it will affect all your projects using Conan, asking for the setting `compiler.sanitizer` always. +In order to disable it, just remove the `settings_user.yml` file from your Conan home. + ### Signed Integer Overflow This example demonstrates how to detect signed integer overflow using compiler sanitizers. The provided C++ code intentionally causes a signed integer overflow, which can be detected when running the program with the appropriate sanitizer flags. From 0ac4dd633239f57b5dcab3b3af321bc3ccf81228 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Tue, 19 Aug 2025 14:04:49 +0200 Subject: [PATCH 05/11] Fix ubsan profile Signed-off-by: Uilian Ries --- .../dev_flow/sanitizers/compiler_sanitizers/profiles/asan_ubsan | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan_ubsan b/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan_ubsan index a6f1edb7..22e43ab8 100644 --- a/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan_ubsan +++ b/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan_ubsan @@ -1,4 +1,4 @@ -include(clang20) +include(default) [settings] compiler.sanitizer=AddressUndefinedBehavior From 830a7805a04b0b2d66bd623df49a2c6ee150dd5f Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Thu, 21 Aug 2025 08:59:35 +0200 Subject: [PATCH 06/11] Add flags to the linker Signed-off-by: Uilian Ries --- .../dev_flow/sanitizers/compiler_sanitizers/profiles/asan | 6 +----- .../sanitizers/compiler_sanitizers/profiles/asan_ubsan | 1 + 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan b/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan index 5dd77d2e..805b622a 100644 --- a/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan +++ b/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan @@ -4,10 +4,6 @@ include(default) compiler.sanitizer=Address [conf] -{% if compiler == "msvc" %} -tools.build:cflags=['/fsanitize=address'] -tools.build:cxxflags=['/fsanitize=address'] -{% else %} tools.build:cflags=['-fsanitize=address'] tools.build:cxxflags=['-fsanitize=address'] -{% endif %} +tools.build:exelinkflags=['-fsanitize=address'] diff --git a/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan_ubsan b/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan_ubsan index 22e43ab8..2561e71b 100644 --- a/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan_ubsan +++ b/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan_ubsan @@ -6,3 +6,4 @@ compiler.sanitizer=AddressUndefinedBehavior [conf] tools.build:cflags=['-fsanitize=address,undefined'] tools.build:cxxflags=['-fsanitize=address,undefined'] +tools.build:exelinkflags=['-fsanitize=address,undefined'] \ No newline at end of file From 35b162f3af5ea687c3baa68c8f2a967f771754b7 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Fri, 22 Aug 2025 09:25:36 +0200 Subject: [PATCH 07/11] Sanitizer setting is optional Signed-off-by: Uilian Ries --- .../dev_flow/sanitizers/compiler_sanitizers/README.md | 2 -- .../sanitizers/compiler_sanitizers/settings_user.yml | 8 ++++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/examples/dev_flow/sanitizers/compiler_sanitizers/README.md b/examples/dev_flow/sanitizers/compiler_sanitizers/README.md index f8888c79..ea57d443 100644 --- a/examples/dev_flow/sanitizers/compiler_sanitizers/README.md +++ b/examples/dev_flow/sanitizers/compiler_sanitizers/README.md @@ -16,8 +16,6 @@ cp settings_user.yml $(conan config home) ``` This setting allows you to customize the behavior of the sanitizers, enabling or disabling specific checks as needed. -Be aware once it's installed in your Conan home, it will affect all your projects using Conan, asking for the setting `compiler.sanitizer` always. -In order to disable it, just remove the `settings_user.yml` file from your Conan home. ### Signed Integer Overflow diff --git a/examples/dev_flow/sanitizers/compiler_sanitizers/settings_user.yml b/examples/dev_flow/sanitizers/compiler_sanitizers/settings_user.yml index f274c7b9..202944bd 100644 --- a/examples/dev_flow/sanitizers/compiler_sanitizers/settings_user.yml +++ b/examples/dev_flow/sanitizers/compiler_sanitizers/settings_user.yml @@ -1,9 +1,9 @@ compiler: gcc: - sanitizer: [None, Address, Leak, Thread, UndefinedBehavior, HardwareAssistanceAddress, KernelAddress, AddressUndefinedBehavior, ThreadUndefinedBehavior] + sanitizer: [null, Address, Leak, Thread, UndefinedBehavior, HardwareAssistanceAddress, KernelAddress, AddressUndefinedBehavior, ThreadUndefinedBehavior] clang: - sanitizer: [None, Address, Leak, Thread, Memory, UndefinedBehavior, HardwareAssistanceAddress, KernelAddress, AddressUndefinedBehavior, ThreadUndefinedBehavior] + sanitizer: [null, Address, Leak, Thread, Memory, UndefinedBehavior, HardwareAssistanceAddress, KernelAddress, AddressUndefinedBehavior, ThreadUndefinedBehavior] apple-clang: - sanitizer: [None, Address, Leak, Thread, Memory, UndefinedBehavior, HardwareAssistanceAddress, KernelAddress, AddressUndefinedBehavior, ThreadUndefinedBehavior] + sanitizer: [null, Address, Leak, Thread, Memory, UndefinedBehavior, HardwareAssistanceAddress, KernelAddress, AddressUndefinedBehavior, ThreadUndefinedBehavior] msvc: - sanitizer: [None, Address, KernelAddress] \ No newline at end of file + sanitizer: [null, Address, KernelAddress] \ No newline at end of file From 21581510d173449e269dc968821bc9d3b743dd67 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Fri, 22 Aug 2025 10:27:23 +0200 Subject: [PATCH 08/11] Add CI scripts Signed-off-by: Uilian Ries --- .../compiler_sanitizers/ci_test_example.bat | 24 +++++++++++++++++++ .../compiler_sanitizers/ci_test_example.sh | 23 ++++++++++++++++++ .../compiler_sanitizers/profiles/asan | 1 + .../compiler_sanitizers/profiles/asan_ubsan | 1 + .../compiler_sanitizers/settings_user.yml | 2 +- .../signed_integer_overflow/CMakeLists.txt | 2 -- 6 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 examples/dev_flow/sanitizers/compiler_sanitizers/ci_test_example.bat create mode 100644 examples/dev_flow/sanitizers/compiler_sanitizers/ci_test_example.sh diff --git a/examples/dev_flow/sanitizers/compiler_sanitizers/ci_test_example.bat b/examples/dev_flow/sanitizers/compiler_sanitizers/ci_test_example.bat new file mode 100644 index 00000000..c101c528 --- /dev/null +++ b/examples/dev_flow/sanitizers/compiler_sanitizers/ci_test_example.bat @@ -0,0 +1,24 @@ +@echo off +setlocal enabledelayedexpansion + +echo Setup settings user +for /f "usebackq delims=" %%H in (conan config home) do set "CONAN_HOME=%%H" +copy /Y settings_user.yml "%CONAN_HOME%" + +echo Conan Examples 2: Compiler Sanitizers - Index Out of Bounds + +conan export index_out_of_bounds/ +conan install --requires=index_out_of_bounds/0.1.0 -pr profiles/asan -of index_out_of_bounds/install --build=missing -c tools.compilation:verbosity=verbose +call index_out_of_bounds\install\conanrun.bat +index_out_of_bounds.exe 2>nul || echo Process completed with errors (expected for sanitizer demo) +call index_out_of_bounds\install\deactivate_conanrun.bat + +echo Conan Examples 2: Compiler Sanitizers - Signed Integer Overflow + +conan export signed_integer_overflow/ +conan install --requires=signed_integer_overflow/0.1.0 -pr profiles/asan_ubsan -of signed_integer_overflow/install --build=missing -c tools.compilation:verbosity=verbose +call signed_integer_overflow\install\conanrun.bat +signed_integer_overflow.exe 2>nul || echo Process completed with errors (expected for sanitizer demo) +call signed_integer_overflow\install\deactivate_conanrun.bat + +exit /b 0 \ No newline at end of file diff --git a/examples/dev_flow/sanitizers/compiler_sanitizers/ci_test_example.sh b/examples/dev_flow/sanitizers/compiler_sanitizers/ci_test_example.sh new file mode 100644 index 00000000..76abf1f8 --- /dev/null +++ b/examples/dev_flow/sanitizers/compiler_sanitizers/ci_test_example.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +set -e +set -x + +echo "Setup settings user" +cp -f settings_user.yml $(conan config home) + +echo "Conan Examples 2: Compiler Sanitizers - Index Out of Bounds" + +conan export index_out_of_bounds/ +conan install --requires=index_out_of_bounds/0.1.0 -pr profiles/asan -of index_out_of_bounds/install --build=missing -c tools.compilation:verbosity=verbose +source index_out_of_bounds/install/conanrun.sh +index_out_of_bounds || true +. index_out_of_bounds/install/deactivate_conanrun.sh + +echo "Conan Examples 2: Compiler Sanitizers - Signed Integer Overflow" + +conan export signed_integer_overflow/ +conan install --requires=signed_integer_overflow/0.1.0 -pr profiles/asan_ubsan -of signed_integer_overflow/install --build=missing -c tools.compilation:verbosity=verbose +source signed_integer_overflow/install/conanrun.sh +signed_integer_overflow || true +. signed_integer_overflow/install/deactivate_conanrun.sh diff --git a/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan b/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan index 805b622a..b3fc67f0 100644 --- a/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan +++ b/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan @@ -1,6 +1,7 @@ include(default) [settings] +build_type=Debug compiler.sanitizer=Address [conf] diff --git a/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan_ubsan b/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan_ubsan index 2561e71b..7232166f 100644 --- a/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan_ubsan +++ b/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan_ubsan @@ -1,6 +1,7 @@ include(default) [settings] +build_type=Debug compiler.sanitizer=AddressUndefinedBehavior [conf] diff --git a/examples/dev_flow/sanitizers/compiler_sanitizers/settings_user.yml b/examples/dev_flow/sanitizers/compiler_sanitizers/settings_user.yml index 202944bd..c42cea1d 100644 --- a/examples/dev_flow/sanitizers/compiler_sanitizers/settings_user.yml +++ b/examples/dev_flow/sanitizers/compiler_sanitizers/settings_user.yml @@ -6,4 +6,4 @@ compiler: apple-clang: sanitizer: [null, Address, Leak, Thread, Memory, UndefinedBehavior, HardwareAssistanceAddress, KernelAddress, AddressUndefinedBehavior, ThreadUndefinedBehavior] msvc: - sanitizer: [null, Address, KernelAddress] \ No newline at end of file + sanitizer: [null, Address, KernelAddress] diff --git a/examples/dev_flow/sanitizers/compiler_sanitizers/signed_integer_overflow/CMakeLists.txt b/examples/dev_flow/sanitizers/compiler_sanitizers/signed_integer_overflow/CMakeLists.txt index cb79d53f..73687d17 100644 --- a/examples/dev_flow/sanitizers/compiler_sanitizers/signed_integer_overflow/CMakeLists.txt +++ b/examples/dev_flow/sanitizers/compiler_sanitizers/signed_integer_overflow/CMakeLists.txt @@ -3,8 +3,6 @@ project(signed_integer_overflow LANGUAGES CXX) add_executable(signed_integer_overflow main.cpp) target_compile_features(signed_integer_overflow PUBLIC cxx_std_11) -target_compile_options(signed_integer_overflow PRIVATE -fsanitize=address) -target_link_options(signed_integer_overflow PRIVATE -fsanitize=address) include(GNUInstallDirs) install(TARGETS signed_integer_overflow From 24915ab794a461a3a56c0e693aa42f9c18af81d1 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Fri, 22 Aug 2025 10:37:55 +0200 Subject: [PATCH 09/11] Chmod +x Signed-off-by: Uilian Ries --- .../dev_flow/sanitizers/compiler_sanitizers/ci_test_example.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 examples/dev_flow/sanitizers/compiler_sanitizers/ci_test_example.sh diff --git a/examples/dev_flow/sanitizers/compiler_sanitizers/ci_test_example.sh b/examples/dev_flow/sanitizers/compiler_sanitizers/ci_test_example.sh old mode 100644 new mode 100755 From 9500bcb3b911541e095b691e40539435fcad76a2 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Fri, 22 Aug 2025 13:59:50 +0200 Subject: [PATCH 10/11] Add more flags Signed-off-by: Uilian Ries --- .../dev_flow/sanitizers/compiler_sanitizers/profiles/asan | 4 ++++ .../sanitizers/compiler_sanitizers/profiles/asan_ubsan | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan b/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan index b3fc67f0..7ce2d243 100644 --- a/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan +++ b/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan @@ -8,3 +8,7 @@ compiler.sanitizer=Address tools.build:cflags=['-fsanitize=address'] tools.build:cxxflags=['-fsanitize=address'] tools.build:exelinkflags=['-fsanitize=address'] +tools.build:sharedlinkflags+=["-fsanitize=address"] + +[runenv] +ASAN_OPTIONS="halt_on_error=1:detect_leaks=1" \ No newline at end of file diff --git a/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan_ubsan b/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan_ubsan index 7232166f..0d54f55c 100644 --- a/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan_ubsan +++ b/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan_ubsan @@ -7,4 +7,5 @@ compiler.sanitizer=AddressUndefinedBehavior [conf] tools.build:cflags=['-fsanitize=address,undefined'] tools.build:cxxflags=['-fsanitize=address,undefined'] -tools.build:exelinkflags=['-fsanitize=address,undefined'] \ No newline at end of file +tools.build:exelinkflags=['-fsanitize=address,undefined'] +tools.build:sharedlinkflags+=["-fsanitize=address"] \ No newline at end of file From 609e7e1d43d171c794c71c446e85cf402fb4d459 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Thu, 2 Oct 2025 11:59:56 +0200 Subject: [PATCH 11/11] Moved sanitizers example to security Signed-off-by: Uilian Ries --- .../compiler_sanitizers/ci_test_example.bat | 24 ------------------- .../compiler_sanitizers/ci_test_example.sh | 23 ------------------ .../sanitizers/compiler_sanitizers/README.md | 24 +++++++++---------- .../compiler_sanitizers/ci_test_example.bat | 20 ++++++++++++++++ .../compiler_sanitizers/ci_test_example.sh | 19 +++++++++++++++ .../index_out_of_bounds/CMakeLists.txt | 0 .../index_out_of_bounds/conanfile.py | 0 .../index_out_of_bounds/main.cpp | 0 .../compiler_sanitizers/profiles/asan | 0 .../compiler_sanitizers/profiles/asan_ubsan | 0 .../compiler_sanitizers/settings_user.yml | 0 .../signed_integer_overflow/CMakeLists.txt | 0 .../signed_integer_overflow/conanfile.py | 0 .../signed_integer_overflow/main.cpp | 0 14 files changed, 50 insertions(+), 60 deletions(-) delete mode 100644 examples/dev_flow/sanitizers/compiler_sanitizers/ci_test_example.bat delete mode 100755 examples/dev_flow/sanitizers/compiler_sanitizers/ci_test_example.sh rename examples/{dev_flow => security}/sanitizers/compiler_sanitizers/README.md (76%) create mode 100644 examples/security/sanitizers/compiler_sanitizers/ci_test_example.bat create mode 100755 examples/security/sanitizers/compiler_sanitizers/ci_test_example.sh rename examples/{dev_flow => security}/sanitizers/compiler_sanitizers/index_out_of_bounds/CMakeLists.txt (100%) rename examples/{dev_flow => security}/sanitizers/compiler_sanitizers/index_out_of_bounds/conanfile.py (100%) rename examples/{dev_flow => security}/sanitizers/compiler_sanitizers/index_out_of_bounds/main.cpp (100%) rename examples/{dev_flow => security}/sanitizers/compiler_sanitizers/profiles/asan (100%) rename examples/{dev_flow => security}/sanitizers/compiler_sanitizers/profiles/asan_ubsan (100%) rename examples/{dev_flow => security}/sanitizers/compiler_sanitizers/settings_user.yml (100%) rename examples/{dev_flow => security}/sanitizers/compiler_sanitizers/signed_integer_overflow/CMakeLists.txt (100%) rename examples/{dev_flow => security}/sanitizers/compiler_sanitizers/signed_integer_overflow/conanfile.py (100%) rename examples/{dev_flow => security}/sanitizers/compiler_sanitizers/signed_integer_overflow/main.cpp (100%) diff --git a/examples/dev_flow/sanitizers/compiler_sanitizers/ci_test_example.bat b/examples/dev_flow/sanitizers/compiler_sanitizers/ci_test_example.bat deleted file mode 100644 index c101c528..00000000 --- a/examples/dev_flow/sanitizers/compiler_sanitizers/ci_test_example.bat +++ /dev/null @@ -1,24 +0,0 @@ -@echo off -setlocal enabledelayedexpansion - -echo Setup settings user -for /f "usebackq delims=" %%H in (conan config home) do set "CONAN_HOME=%%H" -copy /Y settings_user.yml "%CONAN_HOME%" - -echo Conan Examples 2: Compiler Sanitizers - Index Out of Bounds - -conan export index_out_of_bounds/ -conan install --requires=index_out_of_bounds/0.1.0 -pr profiles/asan -of index_out_of_bounds/install --build=missing -c tools.compilation:verbosity=verbose -call index_out_of_bounds\install\conanrun.bat -index_out_of_bounds.exe 2>nul || echo Process completed with errors (expected for sanitizer demo) -call index_out_of_bounds\install\deactivate_conanrun.bat - -echo Conan Examples 2: Compiler Sanitizers - Signed Integer Overflow - -conan export signed_integer_overflow/ -conan install --requires=signed_integer_overflow/0.1.0 -pr profiles/asan_ubsan -of signed_integer_overflow/install --build=missing -c tools.compilation:verbosity=verbose -call signed_integer_overflow\install\conanrun.bat -signed_integer_overflow.exe 2>nul || echo Process completed with errors (expected for sanitizer demo) -call signed_integer_overflow\install\deactivate_conanrun.bat - -exit /b 0 \ No newline at end of file diff --git a/examples/dev_flow/sanitizers/compiler_sanitizers/ci_test_example.sh b/examples/dev_flow/sanitizers/compiler_sanitizers/ci_test_example.sh deleted file mode 100755 index 76abf1f8..00000000 --- a/examples/dev_flow/sanitizers/compiler_sanitizers/ci_test_example.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -set -e -set -x - -echo "Setup settings user" -cp -f settings_user.yml $(conan config home) - -echo "Conan Examples 2: Compiler Sanitizers - Index Out of Bounds" - -conan export index_out_of_bounds/ -conan install --requires=index_out_of_bounds/0.1.0 -pr profiles/asan -of index_out_of_bounds/install --build=missing -c tools.compilation:verbosity=verbose -source index_out_of_bounds/install/conanrun.sh -index_out_of_bounds || true -. index_out_of_bounds/install/deactivate_conanrun.sh - -echo "Conan Examples 2: Compiler Sanitizers - Signed Integer Overflow" - -conan export signed_integer_overflow/ -conan install --requires=signed_integer_overflow/0.1.0 -pr profiles/asan_ubsan -of signed_integer_overflow/install --build=missing -c tools.compilation:verbosity=verbose -source signed_integer_overflow/install/conanrun.sh -signed_integer_overflow || true -. signed_integer_overflow/install/deactivate_conanrun.sh diff --git a/examples/dev_flow/sanitizers/compiler_sanitizers/README.md b/examples/security/sanitizers/compiler_sanitizers/README.md similarity index 76% rename from examples/dev_flow/sanitizers/compiler_sanitizers/README.md rename to examples/security/sanitizers/compiler_sanitizers/README.md index ea57d443..1c046b18 100644 --- a/examples/dev_flow/sanitizers/compiler_sanitizers/README.md +++ b/examples/security/sanitizers/compiler_sanitizers/README.md @@ -1,6 +1,6 @@ # Compiler Sanitizers Example -This example follows the documented page https://docs.conan.io/2/examples/dev_flow/sanitizers/compiler_sanitizers. +This example follows the documented page https://docs.conan.io/2/security/sanitizers.html about using compiler sanitizers with Conan. ## Examples @@ -27,16 +27,15 @@ In order to try the example, you may run the following commands: ``` conan create signed_integer_overflow/ -pr profiles/asan_ubsan -conan install --requires=signed_integer_overflow/0.1.0 -pr profiles/asan_ubsan -of install -source install/conanrun.sh -signed_integer_overflow +conan build signed_integer_overflow/ --version=0.1.0 -pr profiles/asan_ubsan -of install +signed_integer_overflow/build/Debug/signed_integer_overflow ``` It's expected to observe a runtime error indicating a signed integer overflow has occurred: ``` Address sanitizer not enabled -/home/conan/.conan2/p/b/signe3b8ad6d59f30b/b/main.cpp:13:9: runtime error: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int' -SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/conan/.conan2/p/b/signe3b8ad6d59f30b/b/main.cpp:13:9 +/home/conan/examples2/security/sanitizers/signed_integer_overflow/main.cpp:13:9: runtime error: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int' +SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/conan/examples2/security/sanitizers/signed_integer_overflow/main.cpp:13:9 ``` ### Index Out of Bounds @@ -49,9 +48,8 @@ In order to try the example, you may run the following commands: ``` conan create index_out_of_bounds/ -pr profiles/asan -conan install --requires=index_out_of_bounds/0.1.0 -pr profiles/asan -of install -source install/conanrun.sh -index_out_of_bounds +conan build index_out_of_bounds/ --version=0.1.0 -pr profiles/asan -of install +index_out_of_bounds/build/Debug/index_out_of_bounds ``` It's expected to observe a runtime error indicating an out-of-bounds memory access has occurred: @@ -59,19 +57,19 @@ It's expected to observe a runtime error indicating an out-of-bounds memory acce ``` ==357155==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffcddcc40e0 at pc 0x5946a605f2eb bp 0x7ffcddcc3f10 sp 0x7ffcddcc3f00 WRITE of size 4 at 0x7ffcddcc40e0 thread T0 - #0 0x5946a605f2ea in main (/home/conan/.conan2/p/b/index7e914f42d466f/p/bin/index_out_of_bounds+0x12ea) + #0 0x5946a605f2ea in main (/home/conan/examples2/security/sanitizers/index_out_of_bounds/build/Debug/index_out_of_bounds) #1 0x7722f0c29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 #2 0x7722f0c29e3f in __libc_start_main_impl ../csu/libc-start.c:392 - #3 0x5946a605f3d4 in _start (/home/conan/.conan2/p/b/index7e914f42d466f/p/bin/index_out_of_bounds+0x13d4) + #3 0x5946a605f3d4 in _start (/home/conan/examples2/security/sanitizers/index_out_of_bounds/build/Debug/index_out_of_bounds+0x13d4) Address 0x7ffcddcc40e0 is located in stack of thread T0 at offset 448 in frame - #0 0x5946a605f1ef in main (/home/conan/.conan2/p/b/index7e914f42d466f/p/bin/index_out_of_bounds+0x11ef) + #0 0x5946a605f1ef in main (/home/conan/examples2/security/sanitizers/index_out_of_bounds/build/Debug/index_out_of_bounds+0x11ef) This frame has 1 object(s): [48, 448) 'foo' (line 11) <== Memory access at offset 448 overflows this variable HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork (longjmp and C++ exceptions *are* supported) -SUMMARY: AddressSanitizer: stack-buffer-overflow (/home/conan/.conan2/p/b/index7e914f42d466f/p/bin/index_out_of_bounds+0x12ea) in main +SUMMARY: AddressSanitizer: stack-buffer-overflow (/home/conan/examples2/security/sanitizers/index_out_of_bounds/build/Debug/index_out_of_bounds+0x12ea) in main ``` ## Customizing Sanitizers diff --git a/examples/security/sanitizers/compiler_sanitizers/ci_test_example.bat b/examples/security/sanitizers/compiler_sanitizers/ci_test_example.bat new file mode 100644 index 00000000..cb158ae7 --- /dev/null +++ b/examples/security/sanitizers/compiler_sanitizers/ci_test_example.bat @@ -0,0 +1,20 @@ +@echo off +setlocal enabledelayedexpansion + +echo Setup settings user +for /f "usebackq delims=" %%H in (conan config home) do set "CONAN_HOME=%%H" +copy /Y settings_user.yml "%CONAN_HOME%" + +echo Conan Examples 2: Compiler Sanitizers - Index Out of Bounds + +conan export index_out_of_bounds/ +conan build index_out_of_bounds/ --version=0.1.0 -pr profiles/asan -of index_out_of_bounds/install --build=missing -c tools.compilation:verbosity=verbose +index_out_of_bounds/build/Debug/index_out_of_bounds 2>nul || echo Process completed with errors (expected for sanitizer demo) + +echo Conan Examples 2: Compiler Sanitizers - Signed Integer Overflow + +conan export signed_integer_overflow/ +conan build signed_integer_overflow/ --version=0.1.0 -pr profiles/asan_ubsan -of signed_integer_overflow/install --build=missing -c tools.compilation:verbosity=verbose +signed_integer_overflow/build/Debug/signed_integer_overflow 2>nul || echo Process completed with errors (expected for sanitizer demo) + +exit /b 0 \ No newline at end of file diff --git a/examples/security/sanitizers/compiler_sanitizers/ci_test_example.sh b/examples/security/sanitizers/compiler_sanitizers/ci_test_example.sh new file mode 100755 index 00000000..b987c0b7 --- /dev/null +++ b/examples/security/sanitizers/compiler_sanitizers/ci_test_example.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +set -e +set -x + +echo "Setup settings user" +cp -f settings_user.yml $(conan config home) + +echo "Conan Examples 2: Compiler Sanitizers - Index Out of Bounds" + +conan export index_out_of_bounds/ +conan build index_out_of_bounds/ --version=0.1.0 -pr profiles/asan -of index_out_of_bounds/install --build=missing -c tools.compilation:verbosity=verbose +index_out_of_bounds/build/Debug/index_out_of_bounds || true + +echo "Conan Examples 2: Compiler Sanitizers - Signed Integer Overflow" + +conan export signed_integer_overflow/ +conan build signed_integer_overflow/ --version=0.1.0 -pr profiles/asan_ubsan -of signed_integer_overflow/install --build=missing -c tools.compilation:verbosity=verbose +signed_integer_overflow/build/Debug/signed_integer_overflow || true diff --git a/examples/dev_flow/sanitizers/compiler_sanitizers/index_out_of_bounds/CMakeLists.txt b/examples/security/sanitizers/compiler_sanitizers/index_out_of_bounds/CMakeLists.txt similarity index 100% rename from examples/dev_flow/sanitizers/compiler_sanitizers/index_out_of_bounds/CMakeLists.txt rename to examples/security/sanitizers/compiler_sanitizers/index_out_of_bounds/CMakeLists.txt diff --git a/examples/dev_flow/sanitizers/compiler_sanitizers/index_out_of_bounds/conanfile.py b/examples/security/sanitizers/compiler_sanitizers/index_out_of_bounds/conanfile.py similarity index 100% rename from examples/dev_flow/sanitizers/compiler_sanitizers/index_out_of_bounds/conanfile.py rename to examples/security/sanitizers/compiler_sanitizers/index_out_of_bounds/conanfile.py diff --git a/examples/dev_flow/sanitizers/compiler_sanitizers/index_out_of_bounds/main.cpp b/examples/security/sanitizers/compiler_sanitizers/index_out_of_bounds/main.cpp similarity index 100% rename from examples/dev_flow/sanitizers/compiler_sanitizers/index_out_of_bounds/main.cpp rename to examples/security/sanitizers/compiler_sanitizers/index_out_of_bounds/main.cpp diff --git a/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan b/examples/security/sanitizers/compiler_sanitizers/profiles/asan similarity index 100% rename from examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan rename to examples/security/sanitizers/compiler_sanitizers/profiles/asan diff --git a/examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan_ubsan b/examples/security/sanitizers/compiler_sanitizers/profiles/asan_ubsan similarity index 100% rename from examples/dev_flow/sanitizers/compiler_sanitizers/profiles/asan_ubsan rename to examples/security/sanitizers/compiler_sanitizers/profiles/asan_ubsan diff --git a/examples/dev_flow/sanitizers/compiler_sanitizers/settings_user.yml b/examples/security/sanitizers/compiler_sanitizers/settings_user.yml similarity index 100% rename from examples/dev_flow/sanitizers/compiler_sanitizers/settings_user.yml rename to examples/security/sanitizers/compiler_sanitizers/settings_user.yml diff --git a/examples/dev_flow/sanitizers/compiler_sanitizers/signed_integer_overflow/CMakeLists.txt b/examples/security/sanitizers/compiler_sanitizers/signed_integer_overflow/CMakeLists.txt similarity index 100% rename from examples/dev_flow/sanitizers/compiler_sanitizers/signed_integer_overflow/CMakeLists.txt rename to examples/security/sanitizers/compiler_sanitizers/signed_integer_overflow/CMakeLists.txt diff --git a/examples/dev_flow/sanitizers/compiler_sanitizers/signed_integer_overflow/conanfile.py b/examples/security/sanitizers/compiler_sanitizers/signed_integer_overflow/conanfile.py similarity index 100% rename from examples/dev_flow/sanitizers/compiler_sanitizers/signed_integer_overflow/conanfile.py rename to examples/security/sanitizers/compiler_sanitizers/signed_integer_overflow/conanfile.py diff --git a/examples/dev_flow/sanitizers/compiler_sanitizers/signed_integer_overflow/main.cpp b/examples/security/sanitizers/compiler_sanitizers/signed_integer_overflow/main.cpp similarity index 100% rename from examples/dev_flow/sanitizers/compiler_sanitizers/signed_integer_overflow/main.cpp rename to examples/security/sanitizers/compiler_sanitizers/signed_integer_overflow/main.cpp