From 6230185cef5a6e4a9e8c3a33758249d2d5fb8702 Mon Sep 17 00:00:00 2001 From: Peleg Litvak Date: Mon, 19 Sep 2022 15:04:46 +0300 Subject: [PATCH] feat(kubernetes): added base class K8SEdgeBuilder (#3530) * added base class K8SEdgeBuilder * added example in find_connection description * change method signature to return a list * remove type from method signature * added line space for linter --- .../graph_components/K8SEdgeBuilder.py | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 checkov/kubernetes/graph_builder/graph_components/K8SEdgeBuilder.py diff --git a/checkov/kubernetes/graph_builder/graph_components/K8SEdgeBuilder.py b/checkov/kubernetes/graph_builder/graph_components/K8SEdgeBuilder.py new file mode 100644 index 00000000000..db1a89d1e38 --- /dev/null +++ b/checkov/kubernetes/graph_builder/graph_components/K8SEdgeBuilder.py @@ -0,0 +1,25 @@ +from __future__ import annotations +from abc import abstractmethod + +from checkov.kubernetes.graph_builder.graph_components.blocks import KubernetesBlock + + +class K8SEdgeBuilder: + + @abstractmethod + def should_search_for_edges(self, vertex: KubernetesBlock) -> bool: + """ + implementation should examine vertex's attributes and indicate if it's potentially + suitable for the concrete class's edge type. + e.g: search for a label attribute in LabelSelectorEdgeBuilder's implementation + """ + raise NotImplementedError + + @abstractmethod + def find_connection(self, vertex: KubernetesBlock, vertices: list[KubernetesBlock]) -> list[KubernetesBlock]: + """ + implementation should search in each of the vertices for a possible connection + to the vertex param according to the concrete class's rule(s). + e.g: find vertices with a label attribute that match current vertex's selector attribute + """ + raise NotImplementedError