New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PR to new release. #55
Conversation
Added policy resources and diagram relationships
Added roles and AWS managed policies
Added more role principals to assume, adjusted diagram rendering
Enhanced VPC relations
Code refactoring
Here is an overview of what got changed by this pull request: Issues
======
+ Solved 194
- Added 45
Complexity increasing per file
==============================
- provider/iot/command.py 5
- provider/policy/resource/security.py 2
- shared/diagram.py 8
- provider/vpc/diagram.py 6
- shared/command.py 2
- provider/iot/resource/policy.py 4
- provider/policy/command.py 2
- shared/error_handler.py 1
- provider/vpc/resource/analytics.py 1
- provider/policy/resource/general.py 4
- provider/vpc/resource/network.py 7
- provider/iot/diagram.py 1
- provider/iot/resource/thing.py 5
- cloud-discovery.py 16
- shared/report.py 1
- provider/iot/resource/certificate.py 4
Complexity decreasing per file
==============================
+ provider/vpc/resource/storage.py -1
+ provider/vpc/resource/database.py -1
+ provider/vpc/resource/mediaservices.py -1
Clones removed
==============
+ provider/vpc/resource/security.py -1
+ provider/policy/resource/security.py -1
+ provider/vpc/diagram.py -2
+ provider/vpc/resource/compute.py -1
+ provider/vpc/resource/network.py -8
+ provider/vpc/resource/database.py -2
See the complete overview on Codacy |
|
||
class IoTDiagram(BaseDiagram): | ||
def __init__(self, name: str, filename: str, thing_name: str): | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
class IamUser(ResourceProvider): | ||
def __init__(self, options: BaseOptions): | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def __init__(self, vpc_options: VpcOptions): | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
### Usage | ||
|
||
1. Run the aws-network-discovery command with following options (if a region not informed, this script will try to get from ~/.aws/credentials): | ||
1. Run the cloud-discovery command with following options (if a region not informed, this script will try to get from ~/.aws/credentials): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:param region_name: | ||
:param thing_name: | ||
""" | ||
self = super(BaseOptions, cls).__new__(cls, (session, region_name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue found: Bad first argument 'BaseOptions' given to super()
else: | ||
diagram = args.diagram | ||
|
||
""" defining default language to show messages """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue found: String statement has no effect
|
||
|
||
class Policy(BaseCommand): | ||
def __init__(self, region_names, session, diagram): | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
""" | ||
self.relations_found: List[ResourceEdge] = [] | ||
|
||
def get_resources(self) -> List[Resource]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue found: Method could be a function
) | ||
) | ||
|
||
""" aws profile check """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue found: String statement has no effect
def __init__(self, vpc_options: VpcOptions): | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
class IamPolicy(ResourceProvider): | ||
def __init__(self, options: BaseOptions): | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -45,14 +133,102 @@ def make_directories(): | |||
else: | |||
print("Successfully created the directory %s " % PATH_DIAGRAM_OUTPUT) | |||
|
|||
def group_by_group( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue found: Method could be a function
from shared.error_handler import exception | ||
|
||
|
||
class Report(object): | ||
@exception | ||
def general_report( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue found: Method could be a function
resource_relation.to_node | ||
not in already_drawn_elements[resource_relation.from_node] | ||
): | ||
from_node >> Edge(label=resource_relation.label) >> to_node |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
class VpcDiagram(BaseDiagram): | ||
def __init__(self, name: str, filename: str, vpc_id: str): | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
class BaseDiagram(object): | ||
def __init__(self, name: str, filename: str, engine: str = "sfdp"): | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
""" | ||
super().__init__("", "") | ||
|
||
def generate_diagram( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from shared.diagram import NoDiagram, BaseDiagram | ||
|
||
|
||
class VpcOptions(BaseOptions): | ||
vpc_id: str | ||
|
||
def __new__(cls, session, region_name, vpc_id): | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defaultlanguage.install() | ||
_ = defaultlanguage.gettext | ||
|
||
""" diagram version check """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue found: String statement has no effect
def __init__(self, vpc_options: VpcOptions): | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def __init__(self, vpc_options: VpcOptions): | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for group_name in ordered_resources: | ||
if group_name == "": | ||
for resource in ordered_resources[group_name]: | ||
node = eval(Mapsources.mapresources.get(resource.digest.type))( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
additional_relations_found = self.relations_found | ||
with ThreadPoolExecutor(15) as executor: | ||
results = executor.map( | ||
lambda data: self.analyze_role_relations(data), self.resources_found |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue found: Lambda may not be necessary
else: | ||
language = args.language | ||
|
||
""" Diagram check """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue found: String statement has no effect
|
||
self.draw_diagram(ordered_resources=ordered_resources, relations=relations) | ||
|
||
def draw_diagram(self, ordered_resources, relations): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue found: Method could be a function
No description provided.