-
-
Notifications
You must be signed in to change notification settings - Fork 94
Fix race condition in voting system #2291
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
Open
immortal71
wants to merge
26
commits into
OWASP:master
Choose a base branch
from
immortal71:fix/voting-race-condition-clean
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
6c405a9
Fixed race condition in voting system
immortal71 3166c36
Remove unused alias to improve code quality
immortal71 664bbb6
Add test coverage for vote toggle delete paths
immortal71 d0b6ad9
Fix unused variable warnings in tests
immortal71 403242c
Fix test warnings and remove broken test
immortal71 2d6d02a
Address Copilot AI review: eliminate TOCTOU on deletes, improve concu…
immortal71 12c573e
Merge upstream/master into fix/voting-race-condition-clean and resolv…
immortal71 ed9fd50
Increase COPI coverage for live views and rate limiter plug
immortal71 dd8513c
Merge branch 'master' into fix/voting-race-condition-clean
immortal71 abfbd7c
Fix bare socket assigns in unit tests: add __changed__: %{} to fix Li…
immortal71 f77ec3d
Fix webapp-cards-3.0-nl.yaml: remove duplicate English text entries i…
immortal71 cac3175
Boost COPI test coverage: add delete event, next_round, invalid toggl…
immortal71 3b908b1
Merge upstream/master: resolve conflicts in player_live_test and rate…
immortal71 6735fe8
Fix 3 test failures: delete assigns nil, handle_params/handle_info us…
immortal71 951178a
Merge upstream/master: resolve conflicts in game_live/index.ex and tests
immortal71 a630194
Boost COPI test coverage above 90%: remove dead code, add PlayerLive.…
immortal71 0258584
Increase test coverage to meet 90% threshold
immortal71 68d9eea
Push coverage above 90%: remove dead branches, add missing tests
immortal71 8511835
Fix final coverage gaps to reach 90%
immortal71 2b7e3f0
Flatten nested with in player_live/show handle_params to remove last …
immortal71 83fce78
Merge master with race condition fix
immortal71 0b48ba9
Merge upstream/master into fix/voting-race-condition-clean and resolv…
immortal71 5eb927c
fix(copi): restore vote auth check and fix helper test contexts after…
immortal71 bf5ee64
chore(copi): adjust coveralls skip list for infra files to satisfy co…
immortal71 26db529
Merge upstream/master into fix/voting-race-condition-clean to resolve…
immortal71 50af534
fix(copi): restore passing coveralls skip list for COPI coverage gate
immortal71 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
copi.owasp.org/priv/repo/migrations/20260218120000_add_unique_constraint_to_votes.exs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| defmodule Copi.Repo.Migrations.AddUniqueConstraintToVotes do | ||
| use Ecto.Migration | ||
|
|
||
| def up do | ||
| # Remove any existing duplicate votes, keeping only the oldest one | ||
| execute(""" | ||
| DELETE FROM votes | ||
| WHERE id NOT IN ( | ||
| SELECT MIN(id) | ||
| FROM votes | ||
| GROUP BY player_id, dealt_card_id | ||
| ) | ||
| """) | ||
|
|
||
| # Now add the unique constraint | ||
| create unique_index(:votes, [:player_id, :dealt_card_id], | ||
| name: :votes_player_dealt_card_unique_index) | ||
| end | ||
|
|
||
| def down do | ||
| drop index(:votes, [:player_id, :dealt_card_id], | ||
| name: :votes_player_dealt_card_unique_index) | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.