Add a consistent way to iterate over each registered check
This is done by adding `all_checks` to `BaseCheckRegistry` which creates
a generator yielding tuples of string and `BaseCheck`. The string is the
entity or wildcard for which the check was registered. So checks can
appear multiple times.
@@ -6,6 +6,9 @@ import sys
from abc import abstractmethod
from collections import defaultdict
from itertools import chain
+from typing import Generator, Tuple
+
+from checkov.common.checks.base_check import BaseCheck
class BaseCheckRegistry(object):
@@ -53,6 +56,14 @@ class BaseCheckRegistry(object):
chain(*self.checks.values(), *self.wildcard_checks.values())
), None)
+ def all_checks(self) -> Generator[Tuple[str, BaseCheck], None, None]:
+ for entity, checks in self.checks.items():
+ for check in checks:
+ yield entity, check
+ for entity, checks in self.wildcard_checks.items():
+ for check in checks:
+ yield entity, check
+
def get_checks(self, entity):
if not self.wildcard_checks:
# Optimisation: When no wildcards are used, we can use the list in self.checks
