Skip to content
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

Merged
merged 65 commits into from Jun 7, 2020
Merged

PR to new release. #55

merged 65 commits into from Jun 7, 2020

Conversation

leandrodamascena
Copy link
Member

No description provided.

meshuga and others added 30 commits May 30, 2020 00:40
Added policy resources and diagram relationships
Added roles and AWS managed policies
Added more role principals to assume, adjusted diagram rendering
Copy link
Member

meshuga commented Jun 7, 2020

Codacy 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):
"""
Copy link
Member

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):
"""
Copy link
Member

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):
"""
Copy link
Member

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):
Copy link
Member

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))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else:
diagram = args.diagram

""" defining default language to show messages """
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.



class Policy(BaseCommand):
def __init__(self, region_names, session, diagram):
"""
Copy link
Member

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]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

)
)

""" aws profile check """
Copy link
Member

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):
"""
Copy link
Member

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):
"""
Copy link
Member

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(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from shared.error_handler import exception


class Report(object):
@exception
def general_report(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resource_relation.to_node
not in already_drawn_elements[resource_relation.from_node]
):
from_node >> Edge(label=resource_relation.label) >> to_node
Copy link
Member

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):
"""
Copy link
Member

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"):
"""
Copy link
Member

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(
Copy link
Member

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):
"""
Copy link
Member

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 """
Copy link
Member

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):
"""
Copy link
Member

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):
"""
Copy link
Member

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))(
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else:
language = args.language

""" Diagram check """
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


self.draw_diagram(ordered_resources=ordered_resources, relations=relations)

def draw_diagram(self, ordered_resources, relations):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leandrodamascena leandrodamascena merged commit 4c50bb6 into release Jun 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants