Skip to content

Commit

Permalink
Add account ID blacklist (#14)
Browse files Browse the repository at this point in the history
Update boto role assumption and client code to be outside of a try/except
  • Loading branch information
bc-jcarlson authored Sep 4, 2024
1 parent bad37e0 commit 4e93da4
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lambda_code/scan/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
env_name = os.environ["TERRAFORM_WORKSPACE"]
production_env = os.environ["PRODUCTION_WORKSPACE"]

BC_ACCT_ID_BLACKLIST = [
"876504563909"
]


def process_vulnerability(domain, account_name, resource_type, vulnerability_type, takeover=""):

Expand Down Expand Up @@ -292,14 +296,11 @@ def lambda_handler(event, context): # pylint:disable=unused-argument
account_id = event["Id"]
account_name = event["Name"]

try:
aws_session = assume_role(account_id)

r53client = aws_session.client("route53")
except AttributeError:
logging.exception(f"not able to assume role and create Route53 client for account {account_id}")
if account_id in BC_ACCT_ID_BLACKLIST:
logging.info("account ID found on BC account blacklist, skipping...")

return
aws_session = assume_role(account_id)
r53client = aws_session.client("route53")

hosted_zones = list_hosted_zones(r53client, event)
for hosted_zone in hosted_zones:
Expand Down

0 comments on commit 4e93da4

Please sign in to comment.