Skip to content
Closed
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 .github/workflows/install_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ['3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/install_test_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ['3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/install_test_setup_py.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ['3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pylint_and_mypy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
- name: Set up Python 3.12
uses: actions/setup-python@v1
with:
python-version: 3.8
python-version: 3.12
- name: Install poetry
run: |
python -m pip install poetry
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pypi_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Set up Python 3.8 🐍🐍🐍
- name: Set up Python 3.12 🐍🐍🐍
uses: actions/setup-python@v1
with:
python-version: 3.8
python-version: 3.12
- name: Install poetry
run: |
python -m pip install poetry
Expand Down
18 changes: 14 additions & 4 deletions libcloudforensics/providers/gcp/internal/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -1382,10 +1382,16 @@ def GetBootDisk(self) -> 'GoogleComputeDisk':

Raises:
ResourceNotFoundError: If no boot disk could be found.
InvalidNameError: If the boot disk Source could not be found.
"""

for disk in self.GetValue('disks'):
if disk['boot']:
if 'source' not in disk:
raise errors.InvalidNameError(
'Boot disk has no source attribute: {0:s}'.format(
self.name),
__name__)
disk_name = disk['source'].split('/')[-1]
return GoogleCloudCompute(self.project_id).GetDisk(disk_name=disk_name)
raise errors.ResourceNotFoundError(
Expand All @@ -1406,7 +1412,7 @@ def GetDisk(self, disk_name: str) -> 'GoogleComputeDisk':
"""

for disk in self.GetValue('disks'):
if disk['source'].split('/')[-1] == disk_name:
if disk.get('source', '').split('/')[-1] == disk_name:
return GoogleCloudCompute(self.project_id).GetDisk(disk_name=disk_name)
raise errors.ResourceNotFoundError(
'Disk {0:s} was not found in instance {1:s}'.format(
Expand All @@ -1423,7 +1429,9 @@ def ListDisks(self) -> Dict[str, 'GoogleComputeDisk']:

disks = {}
disk_names = [
disk['source'].split('/')[-1] for disk in self.GetValue('disks')
disk['source'].split('/')[-1]
for disk in self.GetValue('disks')
if disk.get('source', None)
]
for name in disk_names:
disks[name] = self.GetDisk(name)
Expand Down Expand Up @@ -1507,7 +1515,7 @@ def DetachDisk(self, disk: 'GoogleComputeDisk') -> None:
gce_instance_client = self.GceApi().instances() # pylint: disable=no-member
device_name = None
for disk_dict in self.GetValue('disks'):
if disk_dict['source'].split('/')[-1] == disk.name:
if disk_dict.get('source', '').split('/')[-1] == disk.name:
device_name = disk_dict['deviceName']
request = gce_instance_client.detachDisk(
instance=self.name,
Expand Down Expand Up @@ -1541,7 +1549,9 @@ def Delete(
disks_to_delete = []
if delete_disks:
disks_to_delete = [
disk['source'].split('/')[-1] for disk in self.GetValue('disks')
disk['source'].split('/')[-1]
for disk in self.GetValue('disks')
if disk.get('source', None)
]

gce_instance_client = self.GceApi().instances() # pylint: disable=no-member
Expand Down
40 changes: 23 additions & 17 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ readme = "README.md"
cloudforensics = "tools.cli:Main"

[tool.poetry.dependencies]
python = "^3.8"
python = "^3.9"
google-api-core = "*"
azure-common = "^1.1.28"
azure-core = "^1.29.4"
Expand Down Expand Up @@ -40,6 +40,7 @@ urllib3 = [
{version = ">=1.25.4,<2.1", python = ">=3.10"}
]
google-auth = "^2.22.0"
setuptools = "^75.8.0"

[tool.poetry.group.dev.dependencies]
coverage = "^7.2.7"
Expand Down
12 changes: 12 additions & 0 deletions tests/providers/gcp/gcp_mocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,18 @@
'initializeParams': {
'diskName': FAKE_DISK.name
}
},
{
'kind': 'compute#attachedDisk',
'type': 'SCRATCH',
'mode': 'READ_WRITE',
'savedState': 'DISK_SAVED_STATE_UNSPECIFIED',
'deviceName': 'local-ssd-0',
'index': 1,
'boot': False,
'autoDelete': True,
'interface': 'NVME',
'diskSizeGb': '375'
}],
'networkInterfaces': MOCK_NETWORK_INTERFACES,
'metadata': {
Expand Down
Loading