Details
| ID | GoogleMaps |
|---|---|
| Provider | |
| Category | Utilities |
| From Version | 6.0.0 |
| Docker Image | demisto/python3:3.12.13.10116658 |
| Supported Modules | Agentix XSIAM EDR Cortex Cloud Attack Surface Management Cloud Runtime Security Cloud Posture Security Exposure Management |
README
Use the Google Maps API. This integration was integrated and tested with version 3.43 of the Google Maps API. This integration always uses the latest API version.
Configure GoogleMaps in Cortex
Note
In order to use the embedded Google Maps view, make sure a Google Maps Geocoding API key is set in Cortex XSOAR.
| Parameter | Description | Required |
|---|---|---|
| Google Maps API Key | The API key to use for the connection. | True |
| Raise error an empty result | Whether to consider empty results as an error. | False |
| Base URL | True | |
| Trust any certificate (not secure) | False | |
| Use system proxy settings | False |
Commands
You can execute these commands from the CLI, as part of an automation, or in a playbook.
After you successfully execute a command, a DBot message appears in the War Room with the command details.
google-maps-geocode
Returns the coordinates of the given physical address. Only the first result is returned (the most relevant, according to Google Maps).
Base Command
google-maps-geocode
Input
| Argument Name | Description | Required |
|---|---|---|
| search_address | The physical address to be geocoded. | Required |
Context Output
| Path | Type | Description |
|---|---|---|
| GoogleMaps.SearchAddress | String | The address provided as input. For example, a postal address, a business name, or an area. |
| GoogleMaps.Address | String | Address of the geocoded location. |
| GoogleMaps.lat | Number | Latitude of the geocoded location. |
| GoogleMaps.lng | Number | Longitude of the geocoded location. |
| GoogleMaps.Country | String | Country of the geocoded location. |
Command Example
google-maps-geocode address=45 rothschild tel aviv
Human Readable Output
Results
| Address | Search Address | Lat | Lng |
|---|---|---|---|
| Rothschild Blvd 45, Tel Aviv-Yafo, Israel | 45 rothschild tel aviv | 32.0642807 | 34.774554 |
Configuration parameters
api_key— Google Maps API Key (required)error_on_no_results— Raise error an empty resultinsecure— Trust any certificate (not secure)base_url— Base URL (required)proxy— Use system proxy settings
Commands (1)
-
google-maps-geocodeReturns the coordinates of the given physical address. Only the first result is returned (the most relevant, according to Google Maps).
"""GoogleMaps Integration for Cortex XSOAR - Unit Tests file""" import json import pytest from CommonServerPython import DemistoException from GoogleMaps import MESSAGE_ZERO_RESULTS, STATUS_ZERO_RESULTS, Client, google_maps_geocode_command search_address = "Paloalto Networks TLV office" def util_load_json(path): with open(path, encoding="utf-8") as f: return json.loads(f.read()) def test_google_maps_geocode_command(requests_mock): """ Given: A string describing a location When: Calling google-maps-geocode Then: Validate the output compared to the mock output """ mock_response = util_load_json("test_data/geocode_paloalto_tlv_response.json") requests_mock.get("https://maps.googleapis.com/maps/api/geocode/json?", json=mock_response) client = Client(api_key="", base_url="https://maps.googleapis.com/maps/api", proxy=False, insecure=False) result_note, result_map = google_maps_geocode_command(client=client, search_address=search_address, error_on_no_results=False) expected_note_outputs = util_load_json("test_data/geocode_paloalto_tlv_note_outputs.json") actual_note_outputs = result_note.outputs assert actual_note_outputs == expected_note_outputs # noinspection PyTypeChecker actual_map_contents = result_map.to_context()["Contents"] expected_map_contents = util_load_json("test_data/geocode_paloalto_tlv_map_contents.json") assert actual_map_contents == expected_map_contents def test_google_maps_geocode_bad_api_key(requests_mock): """ Given: An invalid API key for GoogleMaps, and a string describing a location When: Calling google-maps-geocode Then: Make sure an appropriate exception is raised, with an indicative message. """ client = Client(api_key="invalid-api-key", base_url="https://maps.googleapis.com/maps/api", proxy=False, insecure=False) mock_bad_api_response = util_load_json("test_data/geocode_bad_api_key_response.json") requests_mock.get("https://maps.googleapis.com/maps/api/geocode/json?", json=mock_bad_api_response) with pytest.raises(DemistoException) as e: google_maps_geocode_command(client=client, search_address=search_address, error_on_no_results=False) assert e.value.args[0] == "The provided API key is invalid." def test_google_maps_geocode_zero_results(requests_mock): """ Given: A string describing a location of which there are no geocoding results When: Calling google-maps-geocode Then: Make sure an appropriate exception is raised if and only if the `error_on_no_results` is True. """ zero_results_search_address = " " client = Client(api_key="", base_url="https://maps.googleapis.com/maps/api", proxy=False, insecure=False) mock_response = util_load_json("test_data/geocode_zero_results_response.json") requests_mock.get("https://maps.googleapis.com/maps/api/geocode/json?", json=mock_response) actual_result = google_maps_geocode_command( client=client, search_address=zero_results_search_address, error_on_no_results=False ) assert len(actual_result) == 1 expected_context = util_load_json("test_data/geocode_zero_results_context.json") assert actual_result[0].to_context() == expected_context # And now, with error_on_no_results=True, should raise an exception. with pytest.raises(DemistoException) as e: google_maps_geocode_command(client=client, search_address=zero_results_search_address, error_on_no_results=True) assert e.value.args[0] == MESSAGE_ZERO_RESULTS assert e.value.res["results"] == [] assert e.value.res["status"] == STATUS_ZERO_RESULTS