-
Notifications
You must be signed in to change notification settings - Fork 446
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
44 lines (40 loc) · 1.79 KB
/
Copy pathCMakeLists.txt
File metadata and controls
44 lines (40 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# libFuzzer harnesses for SCAP parsing / processing.
#
# Enabled with -DENABLE_FUZZING=ON. Requires a Clang toolchain (libFuzzer ships
# with clang). When enabled, the whole library is compiled with the libFuzzer
# coverage instrumentation plus AddressSanitizer/UndefinedBehaviorSanitizer (set
# from the top-level CMakeLists), and each harness is linked with
# -fsanitize=fuzzer to pull in the libFuzzer driver/main.
set(FUZZ_INCLUDE_DIRS
"${CMAKE_CURRENT_SOURCE_DIR}"
"${CMAKE_SOURCE_DIR}/src/common/public"
"${CMAKE_SOURCE_DIR}/src/source/public"
"${CMAKE_SOURCE_DIR}/src/DS/public"
"${CMAKE_SOURCE_DIR}/src/XCCDF/public"
"${CMAKE_SOURCE_DIR}/src/XCCDF_POLICY/public"
"${CMAKE_SOURCE_DIR}/src/CPE/public"
"${CMAKE_SOURCE_DIR}/src/OVAL/public"
"${LIBXML2_INCLUDE_DIR}"
)
# add_fuzzer(<name> <source>) builds one libFuzzer executable linked against the
# instrumented library.
function(add_fuzzer name source)
add_executable(${name} ${source})
target_include_directories(${name} PRIVATE ${FUZZ_INCLUDE_DIRS})
target_link_libraries(${name} openscap)
target_compile_options(${name} PRIVATE -fsanitize=fuzzer)
target_link_options(${name} PRIVATE -fsanitize=fuzzer)
endfunction()
add_fuzzer(scap_parse_fuzzer scap_parse_fuzzer.c) # dispatch-by-type parser
add_fuzzer(xccdf_policy_fuzzer xccdf_policy_fuzzer.c) # XCCDF policy/profile layer
add_fuzzer(validate_fuzzer validate_fuzzer.c) # XSD + Schematron validation
add_fuzzer(arf_fuzzer arf_fuzzer.c) # ARF / result data stream (RDS)
add_fuzzer(xccdf_tailoring_fuzzer xccdf_tailoring_fuzzer.c) # XCCDF tailoring
# Convenience target to build them all: `cmake --build . --target fuzzers`
add_custom_target(fuzzers DEPENDS
scap_parse_fuzzer
xccdf_policy_fuzzer
validate_fuzzer
arf_fuzzer
xccdf_tailoring_fuzzer
)