This repository was archived by the owner on Sep 30, 2024. It is now read-only.
Conversation
Contributor
Author
904ef64 to
221ce19
Compare
e0b1725 to
2ef6fa7
Compare
221ce19 to
5e186ea
Compare
2ef6fa7 to
115ddad
Compare
5e186ea to
49c2623
Compare
115ddad to
4ddb9ff
Compare
bbdb954 to
f25e97d
Compare
4ddb9ff to
9610c24
Compare
f25e97d to
9e26623
Compare
9610c24 to
86e4045
Compare
9e26623 to
62d9ad8
Compare
eseliger
approved these changes
Jul 29, 2024
pjlast
approved these changes
Jul 30, 2024
Contributor
Author
ggilmore
referenced
this pull request
Jul 30, 2024
…addresses (#64010) The perforce permission syncer has been adapted to now read and save the HOST field from the perforce protections table, which contains the IP address(es) that the path rule that it applies to. It uses the updated sub_repository_rules store methods introduced in https://github.com/sourcegraph/sourcegraph/pull/63811/. ### Notes - There is some existing logic in the permissions syncer that attempts to re-insert the existing sub_repo_permissions if we encounter a temporary (timeout, etc.) error when syncing. However, there is an edge case: what do we do if the existing permissions don't have an IP address associated with them yet (they were inserted before the updated permission syncer ran)? For simplicity, in this PR I leaned towawrds correctness - I fail the operation outright (I'd rather temporarirly lock someone out rather than accidentally leak information). I implemented a more robust straetgy for this in https://github.com/sourcegraph/sourcegraph/pull/64086. ## Test plan - The existing unit tests have been adapted to use the new authz.SubRepoPermissionsWithIP structs (I use wildcard IP addresses). - The big new test to pay attention to is TestScanIPPermissions (and the associated `sample-protects-ip.txt` file). ## Changelog - The perforce permissions syncer has been updated to save the IP address associated with each sub_repository_permissions rule.
…n fall back to original paths if ips not added yet
62d9ad8 to
fbdf7d2
Compare
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.

Closes https://linear.app/sourcegraph/issue/SRC-453/modify-the-perforce-authorization-provider-to-support-ip-aware-sub
This PR builds on https://github.com/sourcegraph/sourcegraph/pull/64010, and enhances the re-insertion logic.
Before, we'd fail the sync operation outright if we tried to re-insert existing permissions that hadn't been converted from the path only form to the (ip, path) tuple.
Now, when trying to reinsert the existing permissions:
(path, ip)) -> we save it back in the database using the UpsertWithUP() methodpathonly) -> we save it back in the databse using the existing old plain Upsert methodI accomplish this by using a small interface that encpasulates the data and the insertion logic to use:
Now, any code that deals with inserting sub repo permissions now can deal with a
[]subRepoPermissionsUpserterwithout having to care about the exact semantics to use. Our re-insertion logic is also now more robust.Test plan
New unit tests
Changelog