Skip to content

GCP Region issue #1334

Open
Open

Description

@anurag082

I have set up the attack range on my Mac and connected to GCP. However, when I run the attack command, it gives the below error.

Traceback (most recent call last):
File "/Users/a/Desktop/s/attack_range/attack_range.py", line 349, in
main(sys.argv[1:])
~~~~^^^^^^^^^^^^^^
File "/Users/a/Desktop/s/attack_range/attack_range.py", line 345, in main
return args.func(args)
~~~~~~~~~^^^^^^
File "/Users/a/Desktop/s/attack_range/attack_range.py", line 73, in simulate
controller.simulate(args.engine, args.target, args.technique, args.playbook)
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/a/Desktop/s/attack_range/modules/gcp_controller.py", line 143, in simulate
simulation_controller.simulate(target, technique)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
File "/Users/a/Desktop/s/attack_range/modules/art_simulation_controller.py", line 62, in simulate
target_public_ip = gcp_service.get_single_instance_public_ip(
target,
self.config["general"]["key_name"],
self.config["gcp"]["region"],
)
File "/Users/a/Desktop/s/attack_range/modules/gcp_service.py", line 102, in get_single_instance_public_ip
.network_interfaces[0]
^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'network_interfaces'

even though I have this config in the YML
region: europe-west3
zone: europe-west3-a

Activity

  1. P4T12ICK commented on Feb 9, 2026

    @P4T12ICK
    Collaborator

    We just have a new release of Attack Range v5 including a UI and API. Can you try it again? thank you.

  2. janderik commented on Jul 22, 2026

    @janderik

    A few suggestions for making the GCP instance lookup more robust in gcp_service.py:get_single_instance_public_ip:

    1. Add a null-check with a helpful error message:

    def get_single_instance_public_ip(self, name, zone):
        instance = self.compute.instances().get(
            project=self.project, zone=zone, instance=name
        ).execute()
    
        if not instance:
            raise RuntimeError(
                f"GCP instance '{name}' not found in zone '{zone}'. "
                "Verify the instance name and zone are correct in your config."
            )
    
        network_interfaces = instance.get('networkInterfaces', [])
        if not network_interfaces:
            raise RuntimeError(
                f"Instance '{name}' has no network interfaces. "
                "Check that the instance was created with a network interface."
            )
        # ... rest of IP extraction

    2. Add retry logic with exponential backoff for the GCP API call, since transient 429s/503s are common:

    import time
    
    def _get_instance_with_retry(self, name, zone, max_retries=3, base_delay=1.0):
        for attempt in range(max_retries):
            try:
                return self.compute.instances().get(
                    project=self.project, zone=zone, instance=name
                ).execute()
            except googleapiclient.errors.HttpError as e:
                if e.resp.status in (429, 500, 503) and attempt < max_retries - 1:
                    time.sleep(base_delay * (2 ** attempt))
                    continue
                raise

    3. Validate region/zone consistency in your config validation step — ensure the zone string matches the region prefix (e.g., us-central1-a starts with us-central1). This prevents confusing errors where the API returns empty results because the zone doesn't exist in the specified region.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions