Skip to content

Commit dff569c

Browse files
authored
Merge pull request duo-labs#104 from 0xdabbad00/fix_elbv2
Fix ELBv2s in prepare
2 parents 902a6a8 + 94ab46f commit dff569c

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

commands/prepare.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def get_elbs(subnet):
8383

8484
# ALBs and NLBs
8585
alb_instances = query_aws(subnet.account, "elbv2-describe-load-balancers", subnet.region)
86-
alb_resource_filter = '.LoadBalancers[] | select(.VPCId == "{}") | select(.Subnets[] == "{}")'
86+
alb_resource_filter = '.LoadBalancers[] | select(.VpcId == "{}") | select(.AvailabilityZones[].SubnetId == "{}")'
8787
albs = pyjq.all(alb_resource_filter.format(subnet.vpc.local_id, subnet.local_id), alb_instances)
8888

8989
return elbs + albs
@@ -250,7 +250,6 @@ def build_data_structure(account_data, config, outputfilter):
250250
elb = Elb(subnet, elb_json)
251251
subnet.addChild(elb)
252252

253-
254253
# If there are leaves, then add this subnet to the final graph
255254
if len(subnet.leaves) > 0:
256255
node_count_per_region += len(subnet.leaves)

tests/unit/test_prepare.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ def test_build_data_structure(self):
6363

6464
# Now check it
6565
# Check number of connections
66-
assert_equal(14, len(pyjq.all('.[].data|select(.type == "edge")|keys', cytoscape_json)))
66+
assert_equal(17, len(pyjq.all('.[].data|select(.type == "edge")|keys', cytoscape_json)))
6767

6868
# Check number of nodes
6969
assert_equal(2, len(pyjq.all('.[].data|select(.type == "ip")|keys', cytoscape_json)))
7070
assert_equal(2, len(pyjq.all('.[].data|select(.type == "rds")|keys', cytoscape_json)))
7171
assert_equal(3, len(pyjq.all('.[].data|select(.type == "ec2")|keys', cytoscape_json)))
72-
assert_equal(2, len(pyjq.all('.[].data|select(.type == "elb")|keys', cytoscape_json)))
72+
assert_equal(3, len(pyjq.all('.[].data|select(.type == "elb")|keys', cytoscape_json)))
7373
assert_equal(4, len(pyjq.all('.[].data|select(.type == "subnet")|keys', cytoscape_json)))
7474
assert_equal(1, len(pyjq.all('.[].data|select(.type == "region")|keys', cytoscape_json)))
7575
assert_equal(1, len(pyjq.all('.[].data|select(.type == "vpc")|keys', cytoscape_json)))

0 commit comments

Comments
 (0)