Skip to content

Commit 8eaf6ae

Browse files
LucaCiuccinashif
authored andcommitted
sca: enforce selection of a single ECLAIR_RULESET in configuration
This check prevents misconfigurations where more than one ruleset is selected, ensuring that the analysis is not silently performed with an unintended configuration. Signed-off-by: Luca Ciucci <[email protected]>
1 parent 91dde76 commit 8eaf6ae

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

cmake/sca/eclair/sca_options.cmake

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,28 @@ cmake_dependent_option(ECLAIR_FULL_TXT_ALL_AREAS "Show all areas in a full text
3232
OFF "ECLAIR_FULL_TXT" OFF)
3333
cmake_dependent_option(ECLAIR_FULL_TXT_FIRST_AREA "Show only the first area in a full text report"
3434
ON "ECLAIR_FULL_TXT" OFF)
35+
36+
# Ensure that exactly one ECLAIR_RULESET is selected
37+
set(ECLAIR_RULESETS
38+
ECLAIR_RULESET_FIRST_ANALYSIS
39+
ECLAIR_RULESET_STU
40+
ECLAIR_RULESET_STU_HEAVY
41+
ECLAIR_RULESET_WP
42+
ECLAIR_RULESET_STD_LIB
43+
ECLAIR_RULESET_USER
44+
)
45+
46+
set(selected_rulesets "")
47+
foreach(ruleset ${ECLAIR_RULESETS})
48+
if(${ruleset})
49+
list(APPEND selected_rulesets ${ruleset})
50+
endif()
51+
endforeach()
52+
53+
list(LENGTH selected_rulesets selected_count)
54+
if(selected_count EQUAL 0)
55+
message(FATAL_ERROR "No ECLAIR_RULESET is selected. Please select exactly one.")
56+
elseif(selected_count GREATER 1)
57+
message(FATAL_ERROR "Only one ECLAIR_RULESET can be selected at a time.
58+
Selected: ${selected_rulesets}")
59+
endif()

0 commit comments

Comments
 (0)