Add ExtraResources fo K8S
@@ -11,6 +11,7 @@ from checkov.common.graph.checks_infra.registry import BaseRegistry
from checkov.common.graph.db_connectors.networkx.networkx_db_connector import NetworkxConnector
from checkov.common.graph.graph_builder import CustomAttributes
from checkov.common.graph.graph_builder.local_graph import LocalGraph
+from checkov.common.output.extra_resource import ExtraResource
from checkov.common.graph.graph_manager import GraphManager
from checkov.common.output.record import Record
from checkov.common.output.report import Report, merge_reports, CheckType
@@ -142,6 +143,7 @@ class Runner(BaseRunner):
# Moves report generation logic out of run() method in Runner class.
# Allows function overriding of a much smaller function than run() for other "child" frameworks such as Kustomize, Helm
# Where Kubernetes CHECKS are needed, but the specific file references are to another framework for the user output (or a mix of both).
+ if results:
for check, check_result in results.items():
resource_id = get_resource_id(entity_conf)
entity_context = self.context[k8_file][resource_id]
@@ -154,6 +156,16 @@ class Runner(BaseRunner):
check_class=check.__class__.__module__, file_abs_path=file_abs_path, severity=check.severity)
record.set_guideline(check.guideline)
report.add_record(record=record)
+ else:
+ resource_id = get_resource_id(entity_conf)
+ # resources without checks, but not existing ones
+ report.extra_resources.add(
+ ExtraResource(
+ file_abs_path=file_abs_path,
+ file_path=k8_file_path,
+ resource=resource_id,
+ )
+ )
return report
@@ -207,3 +219,8 @@ def _get_from_dict(data_dict, map_list):
def _set_in_dict(data_dict, map_list, value):
_get_from_dict(data_dict, map_list[:-1])[map_list[-1]] = value
+
+
+request = {
+
+}
