Prevent creation of a duplicate source keypair #6011
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Status
Ready for review
Description of Changes
#5954 introduced a bug causing two keypairs to be generated for new sources: once when they arrived at the lookup page, and the next the first time they submitted something (because all sources have
pending=True
by default, passing this faulty check). This eliminates the key generation in the source /submit handler. A keypair should never actually need to be generated when submitting, as it happens on the previous /lookup page. Even if a source without a keypair were somehow sitting at /lookup during the upgrade, when they pushed submit, a keypair would be generated when they were redirected back to /lookup.Testing
git checkout develop
make dev
docker exec -it securedrop-dev-0 bash
and in that shell:gpg --homedir /var/lib/securedrop/keys --list-keys
-- only the three default sources should be listed.git checkout prevent-dup-source-keys
-- the dev server should pick up the changes.Deployment
Checklist
If you made changes to the server application code:
make lint
) and tests (make test
) pass in the development containerIf you made non-trivial code changes:
Choose one of the following: