Skip to content

Commit

Permalink
Using get method to access dict keys to prevent exception
Browse files Browse the repository at this point in the history
  • Loading branch information
cmm-lyft committed Nov 27, 2024
1 parent 774d67b commit b5ba758
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions cartography/intel/aws/ec2/network_acls.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ def transform_network_acl_data(
for rule in network_acl["Entries"]:
direction = 'egress' if rule['Egress'] else 'inbound'
transformed_rule = {
'Id': f"{network_acl['NetworkAclId']}/{direction}/{rule['RuleNumber']}",
'CidrBlock': rule['CidrBlock'],
'Egress': rule['Egress'],
'Protocol': rule['Protocol'],
'RuleAction': rule['RuleAction'],
'RuleNumber': rule['RuleNumber'],
'Id': f"{network_acl['NetworkAclId']}/{direction}/{rule.get('RuleNumber')}",
'CidrBlock': rule.get('CidrBlock'),
'Egress': rule.get('Egress'),
'Protocol': rule.get('Protocol'),
'RuleAction': rule.get('RuleAction'),
'RuleNumber': rule.get('RuleNumber'),
# Add pointer back to the nacl to create an edge
'NetworkAclId': network_acl_id,
'FromPort': rule.get('PortRange', {}).get('FromPort'),
Expand Down

0 comments on commit b5ba758

Please sign in to comment.