Repository navigation
Fix the vote outage; move server-only helpers out of the shared barrel #285
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
817c299
Move aiSpamFilter to server/utils
Jan0707 b8047c6
Hash the vote IP in the route; move ipProcessing to server/utils
Jan0707 13229e2
Plan: record the server-only helper move and the ::ffff: finding
Jan0707 2ffeeba
Merge branch 'main' into infrastructure-improvements
Jan0707 f5d3a3d
Run the vote cooldown lookup with the API token
Jan0707 5181c4c
Plan: record the vote outage and its fix
Jan0707 e4e97df
Merge remote-tracking branch 'origin/infrastructure-improvements' int…
Jan0707 ad202bb
Merge branch 'main' into infrastructure-improvements
Jan0707 ec5c8b9
Plan: record the CMS permissions the vote flow depends on
Jan0707 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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import { describe, expect, it } from 'vitest' | ||
| import { anonymizeAndHashIP } from '../server/utils/ipProcessing' | ||
|
|
||
| // Stored ratings carry these hashes, and the vote cooldown matches on them. Any change to the | ||
| // anonymization or hashing splits the cooldown across a deploy, so these values must not move. | ||
| describe('anonymizeAndHashIP', () => { | ||
| it.each([ | ||
| ['203.0.113.7', '2172243fafcf160d8b3bf50e372877cfd3700fe0f59db1c795e26b2201cdb65f'], | ||
| ['198.51.100.1', 'a1f1df59d2c345dbc1f874828f8e38d51d4f204b292a49476339d0cbe2c1cb8f'], | ||
| ['2001:db8:85a3::8a2e:370:7334', 'dab6247d103932741ae6fd88d67d510316f0e0334b117cf2c47cd95ab2b8514a'], | ||
| ['2001:db8::1', '45095fc532f8e21e39470bf8f3e0e4f7cfbcb77d47cdde8b75a8daa7aa0e7c6b'], | ||
| ['::1', '3078dd4fcbe4e59f28e7bb376037df6186a78cb47515f95812dcde2fd46116ef'], | ||
| ])('hashes %s to its stored value', (ip, hash) => { | ||
| expect(anonymizeAndHashIP(ip)).toBe(hash) | ||
| }) | ||
|
|
||
| it('drops the last two IPv4 octets before hashing', () => { | ||
| expect(anonymizeAndHashIP('203.0.113.250')).toBe(anonymizeAndHashIP('203.0.113.7')) | ||
| }) | ||
|
|
||
| it('treats the compressed and the full IPv6 form alike', () => { | ||
| expect(anonymizeAndHashIP('2001:0db8:85a3:0000:0000:8a2e:0370:7334')).toBe( | ||
| anonymizeAndHashIP('2001:db8:85a3::8a2e:370:7334') | ||
| ) | ||
| }) | ||
|
|
||
| it('ignores surrounding whitespace', () => { | ||
| expect(anonymizeAndHashIP(' 203.0.113.7 ')).toBe(anonymizeAndHashIP('203.0.113.7')) | ||
| }) | ||
|
|
||
| it.each(['not-an-ip', '', '999.1.1.1'])('returns undefined for %j', (ip) => { | ||
| expect(anonymizeAndHashIP(ip)).toBeUndefined() | ||
| }) | ||
| }) |
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.