Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

remove hardcoded USB device name #32

Merged
merged 2 commits into from Dec 5, 2019
Merged

Conversation

redshiftzero
Copy link
Contributor

@redshiftzero redshiftzero commented Nov 26, 2019

Closes #26
Closes freedomofpress/securedrop-workstation#307

This removes the hardcoded device name from the sd export code and sets it dynamically as an attribute on the SDExport object. To do this I'm using lsblk to filter out disks, and then inspecting /sys/class/block/<drive>/removable to see if it's removable or not.

This does mean that we need to ensure we run the code to pick out the drive of interest at the beginning of all USB-related export actions - I'm doing this by running the check_usb_connected method at the beginning of each USB-related export action.

Testing

Preconditions

  1. In sd-export-usb: check out this branch. I do this by adding a NetVM (this is for dev purposes), git cloning this repo (after installing git), checking out this branch, and then overwriting what’s installed via the package in /opt/venvs/securedrop-export/lib/python3.5/site-packages/securedrop_export (if stretch). You can also edit the template but that's way more annoying.
  2. Log into your test server (staging or SF test server), download a bunch of files

Test cases

Here are the tests I performed and I did not restart the VM in between these steps because I'd blow away all my local changes.

To test each step you can look at the securedrop-client's ExportDialog, or just observe the logs in ~/.securedrop_export/logs/export.log in sd-export-usb.

no USB drives

  1. Do not attach any USB drives
  2. in client, confirm you get the “insert your encrypted drive message” when you export

single USB drive

  1. attach USB drive
  2. qvm-usb attach sd-export-usb <drive> # or use the devices widget, it should not matter
  3. now in the client, confirm you can export successfully - this confirms we can export without the device name being hardcoded anywhere
  4. unplug the USB drive

multiple USB drives

  1. do not restart the VM from the above case
  2. use any method to attach a second USB drive
  3. now in the client, confirm that you see ERROR_GENERIC

@redshiftzero redshiftzero added this to Ready for Review in SecureDrop Team Board Nov 26, 2019
@redshiftzero redshiftzero marked this pull request as ready for review December 2, 2019 21:11
@emkll emkll moved this from Ready for Review to Under Review in SecureDrop Team Board Dec 2, 2019
@emkll emkll self-requested a review December 2, 2019 21:36
@sssoleileraaa sssoleileraaa self-requested a review December 3, 2019 18:06
@sssoleileraaa
Copy link
Contributor

sssoleileraaa commented Dec 3, 2019

i'm testing/reviewing this today


update: i lied!

Copy link
Contributor

@sssoleileraaa sssoleileraaa left a comment

Choose a reason for hiding this comment

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

Ran through the test plan and it works exactly as advertised. I also ran through testing for any printer regressions just to be thorough, and things work as expected, e.g. you can still export when there's one printer + one block device attached.

Very excited about this change.

@sssoleileraaa sssoleileraaa merged commit ae8e16f into master Dec 5, 2019
SecureDrop Team Board automation moved this from Under Review to Done Dec 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Add support for different device names Investigate inconsistent ordering of PCI bus IDs for USB devices
2 participants