-
Notifications
You must be signed in to change notification settings - Fork 690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate public keys from GPG to database-backed storage #6946
Conversation
49f6ec7
to
1616478
Compare
fe26e56
to
92fc742
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, @legoktm. I've taken the liberty of being a little aggressive in my testing just to make sure we're hitting the code-paths you intend. :-)
I've left a couple of questions inline, but otherwise I'll be happy to approve and merge this once it's rebased from develop
after #6892.
- Start the dev server (
make dev
) and open a shell into the container, e.g.podman exec --user=root -it $(podman ps --filter name=securedrop --format '{{.ID}}') bash
- Run
alembic stamp 811334d7105f
(ID of the migration before this one) - Run
./loaddata.py --gpg
to add some GPG sources - Run
select filesystem_id, pgp_fingerprint from sources;
in SQLite to verify there are some sources without a fingerprint set in the database - My addition: Choose one of the new sources and smoke-test a round trip: source submits; journalist replies
- Run
alembic upgrade head
, completes successfully. Then run the database query again to see that all fingerprints have been populated. - My addition, aggressive:
gpg --homedir /var/lib/securedrop/keys --list-secret-keys
, thengpg --homedir /var/lib/securedrop/keys --delete-secret-key
each one - My addition: Choose the same source as before and smoke-test a round trip: source submits; journalist replies
- Obligatory CI passes & visual review
92fc742
to
d2828d8
Compare
Rebased and integrated is_valid_public_key() checks. |
d2828d8
to
a67c243
Compare
New sources are created using Sequoia by default, but we need GPG-backed sources to test the migration process. This function is mostly copied from tests.utils.create_legacy_gpg_key.
Add an alembic migration that iterates over the GPG keyring, identifies source keys, exports them from GPG and saves them into the database. The main failure risks are the interactions with GPG. We already run `gpg.list_keys()` on startup, so it's unlikely that's broken (and if it is, we have bigger problems). So the main concern is exporting the key might fail. The export operation is wrapped in a try/except and we validate the exported key we get from GPG. Notably, this does not increase our footprint of pretty_bad_protcol usage as the two functions being used are already in use elsewhere in SecureDrop. Some higher-level design information is at <#6946 (comment)>. Fixes #6800.
a67c243
to
1964032
Compare
Rebased + signed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @legoktm! We've resolved all our discussions from #6946 (review), so I'll merge as soon as CI passes.
Status
Ready for review, depends on
#6892 and#6948.Description of Changes
Commit messages have more detail on each.
Fixes #6800.
Testing
make dev
) and open a shell into the container, e.g.podman exec --user=root -it $(podman ps --filter name=securedrop --format '{{.ID}}') bash
alembic stamp 811334d7105f
(ID of the migration before this one)./loaddata.py --gpg
to add some GPG sourcesselect filesystem_id, pgp_fingerprint from sources;
in SQLite to verify there are some sources without a fingerprint set in the databasealembic upgrade head
, completes successfully. Then run the database query again to see that all fingerprints have been populated.Deployment
Any special considerations for deployment?
This is a non-destructive migration. There is some risk the migration fails, which would halt package upgrade, but the main point where we expect that to happen (
gpg.export_key()
) is wrapped in a try/except.Checklist
make lint
) and tests (make test
) pass in the development container