From ce7bfef0eeb2d9dd4f2d17eb8241fb1f5b9f553f Mon Sep 17 00:00:00 2001 From: Scott Piper Date: Thu, 2 May 2019 11:36:52 -0600 Subject: [PATCH 1/4] Bump version --- cloudmapper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloudmapper.py b/cloudmapper.py index 0dbad5681..74d1e75eb 100755 --- a/cloudmapper.py +++ b/cloudmapper.py @@ -31,7 +31,7 @@ import importlib import commands -__version__ = "2.5.3" +__version__ = "2.5.4" def show_help(commands): From 75470ab6ff43f8d0ed41c1d1cc68c19cee38a898 Mon Sep 17 00:00:00 2001 From: Scott Piper Date: Thu, 2 May 2019 12:25:20 -0600 Subject: [PATCH 2/4] Added more icons --- shared/nodes.py | 7 +- web/icons/aws/apigateway.svg | 108 ++++++++++++++++++++++++ web/icons/aws/codebuild.svg | 93 +++++++++++++++++++++ web/icons/aws/codecommit.svg | 103 +++++++++++++++++++++++ web/icons/aws/codepipeline.svg | 1 + web/icons/aws/ecr.svg | 1 + web/icons/aws/ecs.svg | 80 ++++++++++++++++++ web/icons/aws/fargate.svg | 85 +++++++++++++++++++ web/icons/aws/kinesis.svg | 95 +++++++++++++++++++++ web/icons/aws/kms.svg | 111 +++++++++++++++++++++++++ web/icons/aws/lambda.svg | 80 ++++++++++++++++++ web/icons/aws/redshift.svg | 129 +++++++++++++++++++++++++++++ web/icons/aws/secretsmanager.svg | 132 +++++++++++++++++++++++++++++ web/icons/aws/sns.svg | 100 ++++++++++++++++++++++ web/icons/aws/sqs.svg | 105 +++++++++++++++++++++++ web/icons/aws/ssm.svg | 75 +++++++++++++++++ web/style.json | 138 ++++++++++++++++++++++++++++++- 17 files changed, 1436 insertions(+), 7 deletions(-) create mode 100644 web/icons/aws/apigateway.svg create mode 100644 web/icons/aws/codebuild.svg create mode 100644 web/icons/aws/codecommit.svg create mode 100644 web/icons/aws/codepipeline.svg create mode 100644 web/icons/aws/ecr.svg create mode 100644 web/icons/aws/ecs.svg create mode 100644 web/icons/aws/fargate.svg create mode 100644 web/icons/aws/kinesis.svg create mode 100644 web/icons/aws/kms.svg create mode 100644 web/icons/aws/lambda.svg create mode 100644 web/icons/aws/redshift.svg create mode 100644 web/icons/aws/secretsmanager.svg create mode 100644 web/icons/aws/sns.svg create mode 100644 web/icons/aws/sqs.svg create mode 100644 web/icons/aws/ssm.svg diff --git a/shared/nodes.py b/shared/nodes.py index 951d1a087..069ce95ab 100644 --- a/shared/nodes.py +++ b/shared/nodes.py @@ -557,10 +557,9 @@ def __init__(self, parent, json_blob): # Access is controlled through their policy, or the S3 bucket policies, or somewhere else. self._unrestricted_ingress = True - if self._name == 's3': - self._type = 's3' - elif self._name == 'dynamodb': - self._type = 'dynamodb' + services_with_icons = ['s3', 'dynamodb', 'kinesis', 'sqs', 'sns', 'codebuild', 'codecommit', 'codepipeline', 'ecs', 'ecr', 'ssm', 'secretsmanager', 'kms', 'apigateway'] + if self._name in services_with_icons: + self._type = self._name super(VpcEndpoint, self).__init__(self._parent, json_blob) diff --git a/web/icons/aws/apigateway.svg b/web/icons/aws/apigateway.svg new file mode 100644 index 000000000..b559970f0 --- /dev/null +++ b/web/icons/aws/apigateway.svg @@ -0,0 +1,108 @@ + + + + + + image/svg+xml + + Amazon-API-Gateway_light-bg + + + + + + Amazon-API-Gateway_light-bg + + + + + + + + + + + diff --git a/web/icons/aws/codebuild.svg b/web/icons/aws/codebuild.svg new file mode 100644 index 000000000..6e065b6a5 --- /dev/null +++ b/web/icons/aws/codebuild.svg @@ -0,0 +1,93 @@ + + + + + + image/svg+xml + + AWS-CodeBuild_light-bg + + + + + + AWS-CodeBuild_light-bg + + + + + + + + diff --git a/web/icons/aws/codecommit.svg b/web/icons/aws/codecommit.svg new file mode 100644 index 000000000..22989eb77 --- /dev/null +++ b/web/icons/aws/codecommit.svg @@ -0,0 +1,103 @@ + + + + + + image/svg+xml + + AWS-CodeCommit_light-bg + + + + + + AWS-CodeCommit_light-bg + + + + + + + + + + diff --git a/web/icons/aws/codepipeline.svg b/web/icons/aws/codepipeline.svg new file mode 100644 index 000000000..c4c2bc859 --- /dev/null +++ b/web/icons/aws/codepipeline.svg @@ -0,0 +1 @@ +AWS-CodePipeline_light-bg \ No newline at end of file diff --git a/web/icons/aws/ecr.svg b/web/icons/aws/ecr.svg new file mode 100644 index 000000000..98f20c9be --- /dev/null +++ b/web/icons/aws/ecr.svg @@ -0,0 +1 @@ +Amazon-EC2-Container-Registry_light-bg \ No newline at end of file diff --git a/web/icons/aws/ecs.svg b/web/icons/aws/ecs.svg new file mode 100644 index 000000000..6679ff993 --- /dev/null +++ b/web/icons/aws/ecs.svg @@ -0,0 +1,80 @@ + + + + + + image/svg+xml + + Amazon-Elastic-Container-Service_light-bg + + + + + + Amazon-Elastic-Container-Service_light-bg + + + + + + diff --git a/web/icons/aws/fargate.svg b/web/icons/aws/fargate.svg new file mode 100644 index 000000000..b1a0fa3b7 --- /dev/null +++ b/web/icons/aws/fargate.svg @@ -0,0 +1,85 @@ + + + + + + image/svg+xml + + AWS-Fargate_light-bg + + + + + + AWS-Fargate_light-bg + + + + + + + diff --git a/web/icons/aws/kinesis.svg b/web/icons/aws/kinesis.svg new file mode 100644 index 000000000..e5ea8c0de --- /dev/null +++ b/web/icons/aws/kinesis.svg @@ -0,0 +1,95 @@ + + + + + + image/svg+xml + + Amazon-Kinesis_light-bg + + + + + + Amazon-Kinesis_light-bg + + + + + + + + + diff --git a/web/icons/aws/kms.svg b/web/icons/aws/kms.svg new file mode 100644 index 000000000..51226607e --- /dev/null +++ b/web/icons/aws/kms.svg @@ -0,0 +1,111 @@ + + + + + + image/svg+xml + + AWS-Key-Management-Service_light-bg + + + + + + AWS-Key-Management-Service_light-bg + + + + + + + + + + + diff --git a/web/icons/aws/lambda.svg b/web/icons/aws/lambda.svg new file mode 100644 index 000000000..363222690 --- /dev/null +++ b/web/icons/aws/lambda.svg @@ -0,0 +1,80 @@ + + + + + + image/svg+xml + + AWS-Lambda_light-bg + + + + + + AWS-Lambda_light-bg + + + + + + diff --git a/web/icons/aws/redshift.svg b/web/icons/aws/redshift.svg new file mode 100644 index 000000000..08ce279c1 --- /dev/null +++ b/web/icons/aws/redshift.svg @@ -0,0 +1,129 @@ + + + + + + image/svg+xml + + Amazon-Redshift_light-bg + + + + + + Amazon-Redshift_light-bg + + + + + + + + + + + + + + diff --git a/web/icons/aws/secretsmanager.svg b/web/icons/aws/secretsmanager.svg new file mode 100644 index 000000000..f7f0e96b3 --- /dev/null +++ b/web/icons/aws/secretsmanager.svg @@ -0,0 +1,132 @@ + + + + + + image/svg+xml + + AWS-Secrets-Manager_light-bg + + + + + + AWS-Secrets-Manager_light-bg + + + + + + + + + + + + + + diff --git a/web/icons/aws/sns.svg b/web/icons/aws/sns.svg new file mode 100644 index 000000000..652026fea --- /dev/null +++ b/web/icons/aws/sns.svg @@ -0,0 +1,100 @@ + + + + + + image/svg+xml + + Amazon-Simple-Notification-Service-SNS_light-bg + + + + + + Amazon-Simple-Notification-Service-SNS_light-bg + + + + + + + + + + diff --git a/web/icons/aws/sqs.svg b/web/icons/aws/sqs.svg new file mode 100644 index 000000000..532f3e346 --- /dev/null +++ b/web/icons/aws/sqs.svg @@ -0,0 +1,105 @@ + + + + + + image/svg+xml + + Amazon-Simple-Queue-Service-SQS_light-bg + + + + + + Amazon-Simple-Queue-Service-SQS_light-bg + + + + + + + + + + + diff --git a/web/icons/aws/ssm.svg b/web/icons/aws/ssm.svg new file mode 100644 index 000000000..22226bcdf --- /dev/null +++ b/web/icons/aws/ssm.svg @@ -0,0 +1,75 @@ + + + + + + image/svg+xml + + AWS-Systems-Manager_light-bg + + + + + + AWS-Systems-Manager_light-bg + + + + + diff --git a/web/style.json b/web/style.json index 62da641bb..81cb51eac 100644 --- a/web/style.json +++ b/web/style.json @@ -256,9 +256,141 @@ "background-clip": "none" } }, - - - + { + "selector": "[type = \"redshift\"]", + "css": { + "background-opacity": 0, + "background-image": "./icons/aws/redshift.svg", + "background-fit": "contain", + "background-clip": "none" + } + }, + { + "selector": "[type = \"kinesis\"]", + "css": { + "background-opacity": 0, + "background-image": "./icons/aws/kinesis.svg", + "background-fit": "contain", + "background-clip": "none" + } + }, + { + "selector": "[type = \"sqs\"]", + "css": { + "background-opacity": 0, + "background-image": "./icons/aws/sqs.svg", + "background-fit": "contain", + "background-clip": "none" + } + }, + { + "selector": "[type = \"sns\"]", + "css": { + "background-opacity": 0, + "background-image": "./icons/aws/sns.svg", + "background-fit": "contain", + "background-clip": "none" + } + }, + { + "selector": "[type = \"ecs\"]", + "css": { + "background-opacity": 0, + "background-image": "./icons/aws/ecs.svg", + "background-fit": "contain", + "background-clip": "none" + } + }, + { + "selector": "[type = \"ecr\"]", + "css": { + "background-opacity": 0, + "background-image": "./icons/aws/ecr.svg", + "background-fit": "contain", + "background-clip": "none" + } + }, + { + "selector": "[type = \"fargate\"]", + "css": { + "background-opacity": 0, + "background-image": "./icons/aws/fargate.svg", + "background-fit": "contain", + "background-clip": "none" + } + }, + { + "selector": "[type = \"lambda\"]", + "css": { + "background-opacity": 0, + "background-image": "./icons/aws/lambda.svg", + "background-fit": "contain", + "background-clip": "none" + } + }, + { + "selector": "[type = \"codebuild\"]", + "css": { + "background-opacity": 0, + "background-image": "./icons/aws/codebuild.svg", + "background-fit": "contain", + "background-clip": "none" + } + }, + { + "selector": "[type = \"codecommit\"]", + "css": { + "background-opacity": 0, + "background-image": "./icons/aws/codecommit.svg", + "background-fit": "contain", + "background-clip": "none" + } + }, + { + "selector": "[type = \"codepipeline\"]", + "css": { + "background-opacity": 0, + "background-image": "./icons/aws/codepipeline.svg", + "background-fit": "contain", + "background-clip": "none" + } + }, + { + "selector": "[type = \"ssm\"]", + "css": { + "background-opacity": 0, + "background-image": "./icons/aws/ssm.svg", + "background-fit": "contain", + "background-clip": "none" + } + }, + { + "selector": "[type = \"secretsmanager\"]", + "css": { + "background-opacity": 0, + "background-image": "./icons/aws/secretsmanager.svg", + "background-fit": "contain", + "background-clip": "none" + } + }, + { + "selector": "[type = \"kms\"]", + "css": { + "background-opacity": 0, + "background-image": "./icons/aws/kms.svg", + "background-fit": "contain", + "background-clip": "none" + } + }, + { + "selector": "[type = \"apigateway\"]", + "css": { + "background-opacity": 0, + "background-image": "./icons/aws/apigateway.svg", + "background-fit": "contain", + "background-clip": "none" + } + }, From 4e492c4bea0d9e9faab9c2ecb118fe65a7da36e8 Mon Sep 17 00:00:00 2001 From: Scott Piper Date: Thu, 2 May 2019 12:34:30 -0600 Subject: [PATCH 3/4] Improvement on highlighting now that icons take up the whole node size --- web/style.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/style.json b/web/style.json index 81cb51eac..802ed8517 100644 --- a/web/style.json +++ b/web/style.json @@ -759,7 +759,8 @@ "selector": ":selected", "css": { "background-color": "#ff0", - "background-opacity": 0.5 + "background-opacity": 0.5, + "background-image-opacity": 0.7 } }, { From 9fb9be8a1331b2d684e70e88c0e6c5d758d8f2a3 Mon Sep 17 00:00:00 2001 From: Scott Piper Date: Thu, 2 May 2019 13:23:23 -0600 Subject: [PATCH 4/4] Fix tests --- .../ec2-describe-security-groups.json | 36 +++++++++++++ .../us-east-1/ec2-describe-vpc-endpoints.json | 54 +++++++++++++++++++ commands/prepare.py | 13 +++-- tests/unit/test_prepare.py | 4 +- 4 files changed, 101 insertions(+), 6 deletions(-) create mode 100644 account-data/demo/us-east-1/ec2-describe-vpc-endpoints.json diff --git a/account-data/demo/us-east-1/ec2-describe-security-groups.json b/account-data/demo/us-east-1/ec2-describe-security-groups.json index 2d964ca52..8259d550b 100644 --- a/account-data/demo/us-east-1/ec2-describe-security-groups.json +++ b/account-data/demo/us-east-1/ec2-describe-security-groups.json @@ -1,5 +1,41 @@ { "SecurityGroups": [ + { + "IpPermissionsEgress": [ + { + "IpProtocol": "-1", + "PrefixListIds": [], + "IpRanges": [ + { + "CidrIp": "0.0.0.0/0" + } + ], + "UserIdGroupPairs": [], + "Ipv6Ranges": [] + } + ], + "Description": "Endpoint access", + "IpPermissions": [ + { + "PrefixListIds": [], + "FromPort": 443, + "IpRanges": [], + "ToPort": 443, + "IpProtocol": "tcp", + "UserIdGroupPairs": [ + { + "UserId": "123456789012", + "GroupId": "sg-00000004" + } + ], + "Ipv6Ranges": [] + } + ], + "GroupName": "Endpint", + "VpcId": "vpc-12345678", + "OwnerId": "123456789012", + "GroupId": "sg-00000006" + }, { "IpPermissionsEgress": [ { diff --git a/account-data/demo/us-east-1/ec2-describe-vpc-endpoints.json b/account-data/demo/us-east-1/ec2-describe-vpc-endpoints.json new file mode 100644 index 000000000..21a7c90ec --- /dev/null +++ b/account-data/demo/us-east-1/ec2-describe-vpc-endpoints.json @@ -0,0 +1,54 @@ +{ + "VpcEndpoints": [ + { + "CreationTimestamp": "2019-04-11T18:59:11+00:00", + "DnsEntries": [], + "Groups": [], + "NetworkInterfaceIds": [], + "PolicyDocument": "{\"Version\":\"2008-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":\"*\",\"Action\":\"*\",\"Resource\":\"*\"}]}", + "PrivateDnsEnabled": false, + "RouteTableIds": [ + "rtb-00000000" + ], + "ServiceName": "com.amazonaws.us-east-1.s3", + "State": "available", + "SubnetIds": [], + "VpcEndpointId": "vpce-00000000000000001", + "VpcEndpointType": "Gateway", + "VpcId": "vpc-12345678" + }, + { + "CreationTimestamp": "2019-04-30T15:19:35+00:00", + "DnsEntries": [ + { + "DnsName": "vpce-05ed16ac73726e737-5xkr9dae-us-east-1f.sqs.us-east-1.vpce.amazonaws.com", + "HostedZoneId": "Z7HUB22UULQXV" + }, + { + "DnsName": "sqs.us-east-1.amazonaws.com", + "HostedZoneId": "ZCYZV1JQU4VH2" + } + ], + "Groups": [ + { + "GroupId": "sg-00000006", + "GroupName": "default" + } + ], + "NetworkInterfaceIds": [ + "eni-00000000000000001" + ], + "PolicyDocument": "{\n \"Statement\": [\n {\n \"Action\": \"*\",\n \"Effect\": \"Allow\",\n \"Resource\": \"*\",\n \"Principal\": \"*\"\n }\n ]\n}", + "PrivateDnsEnabled": true, + "RouteTableIds": [], + "ServiceName": "com.amazonaws.us-east-1.sqs", + "State": "available", + "SubnetIds": [ + "subnet-00000003" + ], + "VpcEndpointId": "vpce-00000000000000002", + "VpcEndpointType": "Interface", + "VpcId": "vpc-12345678" + } + ] +} \ No newline at end of file diff --git a/commands/prepare.py b/commands/prepare.py index 428b9ddff..d32d6b130 100644 --- a/commands/prepare.py +++ b/commands/prepare.py @@ -364,13 +364,16 @@ def build_data_structure(account_data, config, outputfilter): cytoscape_json.append(vpc.cytoscape_data()) vpc_children_to_remove = set() - for az in vpc.children: - if az.has_leaves: + for vpc_child in vpc.children: + if vpc_child.has_leaves: if outputfilter["azs"]: - cytoscape_json.append(az.cytoscape_data()) + cytoscape_json.append(vpc_child.cytoscape_data()) + elif vpc_child.node_type != 'az': + # Add VPC children that are not AZs, such as Gateway endpoints + cytoscape_json.append(vpc_child.cytoscape_data()) az_children_to_remove = set() - for subnet in az.children: + for subnet in vpc_child.children: if subnet.has_leaves: cytoscape_json.append(subnet.cytoscape_data()) @@ -379,7 +382,7 @@ def build_data_structure(account_data, config, outputfilter): else: az_children_to_remove.add(subnet) for subnet in az_children_to_remove: - az.removeChild(subnet) + vpc_child.removeChild(subnet) else: vpc_children_to_remove.add(az) diff --git a/tests/unit/test_prepare.py b/tests/unit/test_prepare.py index 5ebab2033..996e289d4 100644 --- a/tests/unit/test_prepare.py +++ b/tests/unit/test_prepare.py @@ -73,7 +73,7 @@ def test_build_data_structure(self): # Now check it # Check number of connections - assert_equal(17, len(pyjq.all('.[].data|select(.type == "edge")|keys', cytoscape_json))) + assert_equal(25, len(pyjq.all('.[].data|select(.type == "edge")|keys', cytoscape_json))) # Check number of nodes assert_equal(2, len(pyjq.all('.[].data|select(.type == "ip")|keys', cytoscape_json))) @@ -84,3 +84,5 @@ def test_build_data_structure(self): assert_equal(4, len(pyjq.all('.[].data|select(.type == "subnet")|keys', cytoscape_json))) assert_equal(1, len(pyjq.all('.[].data|select(.type == "region")|keys', cytoscape_json))) assert_equal(1, len(pyjq.all('.[].data|select(.type == "vpc")|keys', cytoscape_json))) + assert_equal(1, len(pyjq.all('.[].data|select(.type == "sqs")|keys', cytoscape_json))) + assert_equal(1, len(pyjq.all('.[].data|select(.type == "s3")|keys', cytoscape_json)))