Skip to content
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

find_disconnected_db_submissions() does not check for disconnected replies #7203

Open
cfm opened this issue Jul 11, 2024 · 0 comments
Open
Labels

Comments

@cfm
Copy link
Member

cfm commented Jul 11, 2024

Description

find_disconnected_fs_submissions() checks for submission and reply files missing from the database, since their filenames exist in the same space:

submissions = Submission.query.order_by(Submission.id, Submission.filename).all()
files_in_db = {s.filename: True for s in submissions}
replies = Reply.query.order_by(Reply.id, Reply.filename).all()
files_in_db.update({r.filename: True for r in replies})

find_disconnected_db_submissions() does not check for submission and reply records missing from the filesystem, since their IDs do not exist in the same space:

submissions = db.session.query(Submission).order_by(Submission.id, Submission.filename).all()

As a result, manage.py delete-disconnected-db-submissions cannot remove a disconnected reply.

Steps to Reproduce

  1. Register as a source and submit something.
  2. Reply.
  3. Delete that source's directory from /var/lib/securedrop/store.
  4. manage.py delete-disconnected-db-submissions

Expected Behavior

The reply is deleted from the database.

Actual Behavior

The reply is not deleted from the database.

Comments

The fundamental issue here is the subtyping within:

collection: List[Union[Submission, Reply]] = []

For now we'd probably just want to add a separate find_disconnected_db_replies() function and iterate over that separately in delete_disconnected_db_replies().

@cfm cfm added the bug label Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant