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
8 changes: 7 additions & 1 deletion libcloudforensics/providers/aws/forensics.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,13 @@ def StartAnalysisVm( # pylint: disable=too-many-arguments,too-many-positional-a
# in the region requested.
if not ami:
logger.info('No AMI provided, fetching one for Ubuntu 22.04')
qfilter = [{'Name': 'name', 'Values': [UBUNTU_2204_FILTER]}]
# Restrict to Canonical's official AWS account so an attacker cannot
# publish a public AMI with a matching Name and have it selected here.
# https://ubuntu.com/aws/docs/aws-how-to/instances/find-ubuntu-images/
qfilter = [
{'Name': 'name', 'Values': [UBUNTU_2204_FILTER]},
{'Name': 'owner-id', 'Values': ['099720109477']}
Comment thread
Fryyyyy marked this conversation as resolved.
Resolved
]
ami_list = aws_account.ec2.ListImages(qfilter)
# We should only get 1 AMI image back, if we get multiple we
# have no way of knowing which one to use.
Expand Down
12 changes: 9 additions & 3 deletions libcloudforensics/providers/gcp/internal/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,7 @@ def GetDiskTypes(self, disk_type: str,
# Safe to unpack, response is not paged.
return common.ExecuteRequest(disk_types_client, 'get', params)[0]

# pylint: disable=line-too-long
def GetImageFamily(self, image_family: str,
project: Optional[str] = None) -> Dict[str, Any]:
"""Get image family API object in specified project.
Expand All @@ -749,16 +750,18 @@ def GetImageFamily(self, image_family: str,

Returns:
The selected image family API resource:
https://cloud.google.com/compute/docs/reference/rest/v1/images/getFromFamily # pylint: disable=line-too-long
https://cloud.google.com/compute/docs/reference/rest/v1/images/getFromFamily

Raises:
HttpError if getting image object for the given image family name fails.
"""
# pylint: enable=line-too-long
images_client = self.GceApi().images() # pylint: disable=no-member
params = {'project': project, 'family': image_family}
# Safe to unpack, response is not paged.
return common.ExecuteRequest(images_client, 'getFromFamily', params)[0]

# pylint: disable=line-too-long
def GetNetwork(self, network_name: str) -> Dict[str, Any]:
"""Get selected network API object in specified project.

Expand All @@ -767,11 +770,12 @@ def GetNetwork(self, network_name: str) -> Dict[str, Any]:

Returns:
The selected network API resource:
https://cloud.google.com/compute/docs/reference/rest/v1/networks # pylint: disable=line-too-long
https://cloud.google.com/compute/docs/reference/rest/v1/networks

Raises:
HttpError if getting network object for the given machine-type name fails.
"""
# pylint: enable=line-too-long
networks_client = self.GceApi().networks() # pylint: disable=no-member
params = {
'project': self.project_id,
Expand Down Expand Up @@ -2328,13 +2332,15 @@ def __init__(
super().__init__(
project_id=project_id, zone='', name=name, region=region, **kwargs)

# pylint: disable=line-too-long
def GetOperation(self) -> Dict[str, Any]:
"""Get API operation object for the regional disk.

Returns:
An API operation object for a Google Regional Compute Engine disk.
https://cloud.google.com/compute/docs/reference/rest/v1/regionDisks/get#response-body # pylint: disable=line-too-long
https://cloud.google.com/compute/docs/reference/rest/v1/regionDisks/get#response-body
"""
# pylint: enable=line-too-long
gce_disk_client = self.GceApi().regionDisks() # pylint: disable=no-member
param = {
'project': self.project_id, 'region': self.region, 'disk': self.name
Expand Down
Loading