-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* OPT-908 Refactor resource data and extractors * OPT-908 Create inbound connections by Module: security-group --------- Co-authored-by: David Antolín <99404665+dantolin-iriusrisk@users.noreply.github.com> Co-authored-by: PacoCid <117292868+PacoCid@users.noreply.github.com>
- Loading branch information
1 parent
7aaae49
commit 3a9bb0d
Showing
23 changed files
with
481 additions
and
1,688 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
from slp_tfplan.slp_tfplan.matcher.components_and_sgs_matcher import ComponentsAndSGsMatcher | ||
from slp_tfplan.slp_tfplan.matcher.resource_matcher import ResourcesMatcherContainer | ||
from slp_tfplan.slp_tfplan.matcher.sg_and_sgrules_matcher import SGAndSGRulesMatcher | ||
from slp_tfplan.slp_tfplan.matcher.sgs_matcher import SGsMatcher | ||
from slp_tfplan.slp_tfplan.matcher.strategies.match_strategy import MatchStrategyContainer | ||
|
||
MatchStrategyContainer().wire(packages=[__name__]) | ||
|
||
ResourcesMatcherContainer().wire(modules=[ | ||
ComponentsAndSGsMatcher.__module__, | ||
SGsMatcher.__module__ | ||
SGsMatcher.__module__, | ||
SGAndSGRulesMatcher.__module__ | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from typing import Dict, List | ||
|
||
from dependency_injector.wiring import inject, Provide | ||
|
||
from slp_tfplan.slp_tfplan.graph.relationships_extractor import RelationshipsExtractor | ||
from slp_tfplan.slp_tfplan.matcher.resource_matcher import ResourceMatcher, ResourcesMatcherContainer | ||
|
||
|
||
class SGAndSGRulesMatcher: | ||
""" | ||
This class is responsible for matching security groups and security groups rules. | ||
""" | ||
@inject | ||
def __init__(self, | ||
security_group: Dict, security_group_rules: List[Dict], | ||
relationships_extractor: RelationshipsExtractor, | ||
sg_rule_matcher: ResourceMatcher = Provide[ResourcesMatcherContainer.sg_rule_matcher]): | ||
# Data structures | ||
self._security_group: Dict = security_group | ||
self._security_group_rules: List[Dict] = security_group_rules | ||
self._relationships_extractor: RelationshipsExtractor = relationships_extractor | ||
|
||
# Injected dependencies | ||
self._are_related = sg_rule_matcher.are_related | ||
|
||
def match(self) -> List[Dict]: | ||
""" | ||
Returns a list of security group rules related with the security group. | ||
:return: List of security group rules | ||
""" | ||
related_sg_rule = [] | ||
for sg_rule in self._security_group_rules: | ||
if self._are_related(self._security_group, sg_rule, relationships_extractor=self._relationships_extractor): | ||
related_sg_rule.append(sg_rule) | ||
|
||
return related_sg_rule |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.