Skip to content

Commit

Permalink
Simplify device parsing. Pre-check devices with udisks and bail early…
Browse files Browse the repository at this point in the history
… if none inserted.

Reject multiple usbs inserted at once.
  • Loading branch information
rocodes committed Jan 23, 2024
1 parent 5f659f1 commit c584669
Show file tree
Hide file tree
Showing 7 changed files with 414 additions and 450 deletions.
Empty file added export/etc/udisks2/tcrypt.conf
Empty file.
293 changes: 174 additions & 119 deletions export/securedrop_export/disk/cli.py

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions export/securedrop_export/disk/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ def export(self) -> Status:
volume = self.cli.get_volume()
if isinstance(volume, MountedVolume):
logger.debug("Mounted volume detected, exporting files")
self.cli.write_data_to_device(volume, self.submission)
self.cli.write_data_to_device(
volume, self.submission.tmpdir, self.submission.target_dirname
)
return Status.SUCCESS_EXPORT
elif isinstance(volume, Volume):
logger.debug("Volume is locked, unlocking")
Expand All @@ -59,7 +61,9 @@ def export(self) -> Status:
# Exports then locks the drive.
# If the export succeeds but the drive is in use, will raise
# exception.
self.cli.write_data_to_device(mv, self.submission)
self.cli.write_data_to_device(
mv, self.submission.tmpdir, self.submission.target_dirname
)
return Status.SUCCESS_EXPORT
else:
raise ExportException(sdstatus=Status.ERROR_UNLOCK_GENERIC)
Expand Down
7 changes: 5 additions & 2 deletions export/securedrop_export/disk/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@

class Status(BaseStatus):
NO_DEVICE_DETECTED = "NO_DEVICE_DETECTED"
INVALID_DEVICE_DETECTED = "INVALID_DEVICE_DETECTED" # Not encrypted, too many encrypted partitions, too nested partition scheme, etc

INVALID_DEVICE_DETECTED = (
"INVALID_DEVICE_DETECTED" # Not encrypted, or partitions too many/too nested
)

MULTI_DEVICE_DETECTED = "MULTI_DEVICE_DETECTED" # Not currently supported
UNKNOWN_DEVICE_DETECTED = "UNKNOWN_DEVICE_DETECTED" # Badly-formatted USB (or locked VeraCrypt/TC - currently not supported)

DEVICE_LOCKED = "DEVICE_LOCKED" # One valid device detected, and it's locked
DEVICE_WRITABLE = (
Expand Down
Loading

0 comments on commit c584669

Please sign in to comment.