Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ScoutSuite/providers/gcp/facade/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ async def is_api_enabled(self, project_id, service):
elif service == 'CloudStorage':
endpoint = 'storage-component'
elif service == 'CloudSQL':
endpoint = 'sql-component'
endpoint = 'sqladmin'
elif service == 'ComputeEngine':
endpoint = 'compute'
elif service == 'Functions':
Expand Down
8 changes: 7 additions & 1 deletion ScoutSuite/providers/gcp/facade/gke.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ async def get_clusters(self, project_id):
async def _get_and_set_private_google_access_enabled(self, cluster, project_id):
try:
region = self._get_cluster_region(cluster)
subnetwork = await self._gce_facade.get_subnetwork(project_id, region, cluster['subnetwork'])
subnetwork_project_id = self._get_cluster_subnetwork_project(cluster)
subnetwork = await self._gce_facade.get_subnetwork(subnetwork_project_id, region, cluster['subnetwork'])
if subnetwork:
cluster['privateIpGoogleAccess'] = subnetwork.get('privateIpGoogleAccess')
else:
Expand All @@ -42,3 +43,8 @@ def _get_cluster_region(self, cluster):
region_regex = re.compile("^([\\w]+-[\\w]+)")
result = region_regex.search(cluster['location'])
return result.group(1)

# Subnetwork can be in different project
# networkConfig.subnetwork is like projects/{project}/regions/{region}/subnetworks/{subnetworkname}
def _get_cluster_subnetwork_project(self, cluster):
return cluster['networkConfig']['subnetwork'].split('/')[1]
4 changes: 2 additions & 2 deletions ScoutSuite/providers/gcp/resources/functions/functions_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ def _parse_function(self, raw_function):
function_dict['max_instances'] = raw_function['maxInstances']
function_dict['docker_registry'] = raw_function['dockerRegistry']
function_dict['url'] = raw_function.get('httpsTrigger', {}).get('url')
function_dict['security_level'] = raw_function.get('httpsTrigger', {}).get('securityLevel')
function_dict['security_level'] = 'SECURE_ALWAYS' if function_dict['url'] is None else raw_function.get('httpsTrigger', {}).get('securityLevel')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is SECURE_ALWAYS?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

function_dict['ingress_settings'] = raw_function['ingressSettings']

function_dict['bindings'] = raw_function['bindings']

function_dict['environment_variables'] = raw_function['environmentVariables']
function_dict['environment_variables'] = raw_function.get('environmentVariables', {})
function_dict['environment_variables_secrets'] = get_environment_secrets(function_dict['environment_variables'])

function_dict['labels'] = raw_function['labels']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def _parse_function(self, raw_function):
function_dict['service_account'] = raw_function.get('serviceConfig', {}).get('serviceAccountEmail')
function_dict['bindings'] = raw_function['bindings']

function_dict['environment_variables'] = raw_function.get('serviceConfig', {}).get('environmentVariables')
function_dict['environment_variables'] = raw_function.get('serviceConfig', {}).get('environmentVariables', {})
function_dict['environment_variables_secrets'] = get_environment_secrets(function_dict['environment_variables'])

function_dict['labels'] = raw_function['labels']
Expand Down