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

Fix deleted work prevents reverting a user's works #9013

Conversation

benbdeitch
Copy link
Collaborator

Closes #4045

Currently, there is an exploit in our mass-revert feature that spammers are abusing. When a user is blocked and all of their edits are reverted en masse, the process will stall if any of their edits reference deleted works. This R will causes the reversion process to instead skip past these defunct edits, allowing the overall process to succeed.

Technical

Currently, the problem arises in infogami.infobase.writequery.SaveProcesser.process_value, where type-checking occurs for the various keys involved in saving changes. Rather than altering infogami's functionality in this manner, the implemented solution instead checks each key referenced in each changeset for deleted keys earlier in the process, back in openlibrary.plugins.admin.code.people_view.POST_block_account_and_revert, and only passes the changeset ids without these references to be reverted.

This could theoretically result in a problem, if a user with a sufficiently large edit history is being reverted, due to the large amount of information being fetched. Currently, it is being investigated if this is likely to happen.

Testing

The first step for verifying this PR is to create two separate user accounts. Each user account should create a work, and an edition. Then, each user should edit the other user's work. Lastly, each user should then be blocked, and have their edits reverted.

Stakeholders

@cdrini

Copy link
Collaborator

@cdrini cdrini left a comment

Choose a reason for hiding this comment

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

One small comment! We discussed the possible performance implications of this.

Although this will take longer, we think it shouldn't have a huge impact on most reversion since they are unlikely to be very large. In the larger case, it should I believe just be slower.

We'll monitor and ask for feedback from librarians; if they observe this is erroring when the revert set is large, we have two mitigations:

  1. Wrap the revert() in a try/except ; this will delay the problem, but possible enough for it to effectively not be a problem
  2. Do the revert in batches.

@cdrini cdrini self-assigned this Apr 8, 2024
@cdrini cdrini force-pushed the 4045/bug/deleted-work-prevents-edit-reversion branch from 246e0cd to 605246a Compare May 1, 2024 16:44
Also moved the main revert methods into helpers for easier testing.
@cdrini cdrini force-pushed the 4045/bug/deleted-work-prevents-edit-reversion branch from 605246a to e8b8b78 Compare May 1, 2024 16:46
cdrini and others added 3 commits May 1, 2024 12:53
Adjusted the 'action-type' of adding/editing the books, to accurately reflect the actions being done.
@cdrini cdrini changed the title 4045/bug/deleted work prevents edit reversion Fix deleted work prevents reverting a user's works May 29, 2024
@cdrini cdrini merged commit 1428f40 into internetarchive:master May 29, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix patron block and revert functionality where /type/delete encountered
2 participants