Skip to content

Commit

Permalink
fix lazy loading custom policies into check registry
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeurbanski1 committed Aug 16, 2024
1 parent 11f5e8a commit 8201fc5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions checkov/common/checks_infra/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ def __init__(self, checks_dir: str, parser: BaseGraphCheckParser | None = None)
super().__init__(parser)
self.checks: list[BaseGraphCheck] = []
self.custom_policies_checks: list[BaseGraphCheck] = []
self.custom_policies_loaded: bool = False
self.checks_dir = checks_dir
self.logger = logging.getLogger(__name__)
add_resource_code_filter_to_logger(self.logger)

def load_checks(self) -> None:
if self.checks:
# checks were previously loaded
return

self._load_checks_from_dir(self.checks_dir, False)
self.checks += self.custom_policies_checks
if not self.checks:
self._load_checks_from_dir(self.checks_dir, False)
if not self.custom_policies_loaded and self.custom_policies_checks:
self.checks += self.custom_policies_checks
self.custom_policies_loaded = True

def _load_checks_from_dir(self, directory: str, external_check: bool) -> None:
dir = os.path.expanduser(directory)
Expand Down

0 comments on commit 8201fc5

Please sign in to comment.