Skip to content

Commit

Permalink
Handle ambigous profile/group parameters
Browse files Browse the repository at this point in the history
Introduce the -e group: option, to improve
handling of ambigous parameters
(such as "security" etc.)
  • Loading branch information
Nora Zinaeddin committed Oct 30, 2024
1 parent 69f88e3 commit b1bf6d8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
35 changes: 20 additions & 15 deletions analyzer/codechecker_analyzer/analyzers/config_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@

from abc import ABCMeta
from enum import Enum
from string import Template
import collections
import platform
import sys
import re

from codechecker_analyzer import analyzer_context
Expand Down Expand Up @@ -211,22 +213,25 @@ def initialize_checkers(self,
guidelines = checker_labels.occurring_values('guideline')

for identifier, enabled in cmdline_enable:
if ':' in identifier:
if "group:" in identifier:
identifier = identifier.replace("group:", "")
self.set_checker_enabled(identifier, enabled)
elif ':' in identifier:
for checker in checker_labels.checkers_by_labels([identifier]):
self.set_checker_enabled(checker, enabled)
elif identifier in profiles:
if identifier in reserved_names:
LOG.warning("Profile name '%s' conflicts with a "
"checker(-group) name.", identifier)
for checker in checker_labels.checkers_by_labels(
[f'profile:{identifier}']):
self.set_checker_enabled(checker, enabled)
elif identifier in guidelines:
if identifier in reserved_names:
LOG.warning("Guideline name '%s' conflicts with a "
"checker(-group) name.", identifier)
for checker in checker_labels.checkers_by_labels(
[f'guideline:{identifier}']):
self.set_checker_enabled(checker, enabled)
elif identifier in reserved_names:
templ = Template("The ${entity} name '${identifier}' "
"conflicts with a checker(-group) name. "
"Please use -e ${entity}: to select "
"checkers of a ${entity} or use -e group: "
"to select checkers which have a name "
"starting with '${identifier}'.")
if identifier in profiles:
LOG.error(templ.substitute(entity="profile",
identifier=identifier))
elif identifier in guidelines:
LOG.error(templ.substitute(entity="guideline",
identifier=identifier))
sys.exit(1)
else:
self.set_checker_enabled(identifier, enabled)
3 changes: 2 additions & 1 deletion analyzer/codechecker_analyzer/checkers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ def available(ordered_checkers, available_checkers):
if checker_name.startswith('profile:') or \
checker_name.startswith('guideline:') or \
checker_name.startswith('severity:') or \
checker_name.startswith('sei-cert:'):
checker_name.startswith('sei-cert:') or \
checker_name.startswith('group:'):
continue

name_match = False
Expand Down

0 comments on commit b1bf6d8

Please sign in to comment.