-
Notifications
You must be signed in to change notification settings - Fork 60
Allow silos to have restricted permissions for networking resources #9227
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
charliepark
wants to merge
57
commits into
main
Choose a base branch
from
restrict_networking_actions_4
base: main
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
57 commits
Select commit
Hold shift + click to select a range
3752d57
add restrict_networking_actions code
charliepark 420ed2b
More development of Polar-based change to permissions
charliepark ad106d6
Polar working, perhaps; lots of permission rules
charliepark 9966d8e
refactor; add a few tests that might still need a bit of tweaking
charliepark a06feda
clean up migration files
charliepark 062d441
small cleanup
charliepark 9450227
fix clippy issues
charliepark 9c709fd
safer migratino file
charliepark 37f1e1e
merge main and resolve conflicts
charliepark 91d7856
Update nexus, tests
charliepark 759f3a6
formatting
charliepark 1f54b26
remove unused method
charliepark 01434b2
Move logic from silo to project
charliepark 56af8c8
Remove accidentally committed .bak files
charliepark ced5348
cargo fmt
charliepark d8764d3
Merge main
charliepark 6cad94e
fix clippy issues
charliepark 7737776
cargo fmt again
charliepark ed3e5f4
Update tests
charliepark f3b34a9
Merge branch 'main' into restrict_networking_actions_4
charliepark 6f41131
Update version number in dbint.sql
charliepark 937d15e
Merge branch 'main' into restrict_networking_actions_4
charliepark 51207ca
remove redundant Silo query
charliepark f3605a5
Update tests
charliepark d9b8bcd
cargo fmt
charliepark c0e922d
Merge branch 'main' into restrict_networking_actions_4
charliepark 388e903
Move restriction check to actor silo policy, rather than project silo
charliepark 4b4c392
cargo fmt
charliepark 901e241
Merge branch 'main' into restrict_networking_actions_4
charliepark 2dae549
Add test back in
charliepark 109b966
Update checks for VPC update, more tests
charliepark 4768df9
cargo fmt
charliepark 15713f5
Add VPC subnet restriction and tests
charliepark 7bb9e35
Add routers and router route checks and tests
charliepark bbf0c19
Add networking restrictions check to Internet Gateways and Firewall R…
charliepark 1320eb2
Refactor tests
charliepark 49cbce0
Add internet gateway attach/detach restrictions
charliepark 7ce7cc1
Add tests for IP Pools / Addresses
charliepark a948699
Merge branch 'main' into restrict_networking_actions_4
charliepark 2daa80e
Add bypass on VPC creation saga in restricted environments
charliepark 5d2b21c
cargo fmt
charliepark 49488e7
merge main and resolve conflicts
charliepark 1ef5e62
Merge branch 'main' into restrict_networking_actions_4
charliepark 680a1a1
Update dbint.sql version again
charliepark 479a696
remove pub from method
charliepark b9b5465
Add missing Polar rules
charliepark 28ba5f3
Use InProjectNetworking snippet instead of permissive InProject snippet
charliepark fefa847
Adjust VPC deletion
charliepark b56ff84
Use project:createChild check for VPC creation in lieu of creating a …
charliepark 2331d3f
Comment out callsites for check_networking_restrictions; enable for V…
charliepark acc70af
Remove unneeded Rust checks and add missing Polar rules
charliepark 0b82612
Add tests
charliepark 79a849e
cargo fmt
charliepark 57c79b6
Merge main and resolve conflicts
charliepark 40fd6ba
Fix compilation errors
charliepark c0ac662
Refactor Polar rules
charliepark 134af5a
Remove empty lines
charliepark 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -265,6 +265,11 @@ enum PolarSnippet { | |
| /// Generate it as a resource nested within a Project (either directly or | ||
| /// indirectly) | ||
| InProject, | ||
|
|
||
| /// Generate it as a networking resource nested within a Project | ||
| /// (like InProject, but without default permission rules - all rules | ||
| /// defined in omicron.polar for networking restrictions) | ||
| InProjectNetworking, | ||
| } | ||
|
|
||
| /// Implementation of [`authz_resource!`] | ||
|
|
@@ -433,6 +438,67 @@ fn do_authz_resource( | |
| resource_name, | ||
| parent_as_snake, | ||
| ), | ||
|
|
||
| // InProjectNetworking: Like InProject, but NO default permission rules. | ||
| // All permission rules are defined in omicron.polar to enforce | ||
| // networking restrictions. Only defines resource structure + relations. | ||
| (PolarSnippet::InProjectNetworking, "Project") => format!( | ||
| r#" | ||
| resource {} {{ | ||
| permissions = [ | ||
| "list_children", | ||
| "modify", | ||
| "read", | ||
| "create_child", | ||
| "delete", | ||
| ]; | ||
|
|
||
| relations = {{ containing_project: Project }}; | ||
| # NOTE: No permission rules defined here! | ||
| # All permissions controlled by custom networking restriction | ||
| # rules in omicron.polar (can_modify_networking_resource) | ||
|
Comment on lines
+457
to
+459
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm curious why you can't put the stuff that's copy/pasted for each networking resource in omicron.polar in here instead. |
||
| }} | ||
|
|
||
| has_relation(parent: Project, "containing_project", child: {}) | ||
| if child.project = parent; | ||
| "#, | ||
| resource_name, resource_name, | ||
| ), | ||
|
|
||
| (PolarSnippet::InProjectNetworking, _) => format!( | ||
| r#" | ||
| resource {} {{ | ||
| permissions = [ | ||
| "list_children", | ||
| "modify", | ||
| "read", | ||
| "create_child", | ||
| "delete", | ||
| ]; | ||
|
|
||
| relations = {{ | ||
| containing_project: Project, | ||
| parent: {} | ||
| }}; | ||
| # NOTE: No permission rules defined here! | ||
| # All permissions controlled by custom networking restriction | ||
| # rules in omicron.polar (can_modify_networking_resource) | ||
| }} | ||
|
|
||
| has_relation(project: Project, "containing_project", child: {}) | ||
| if has_relation(project, "containing_project", child.{}); | ||
|
|
||
| has_relation(parent: {}, "parent", child: {}) | ||
| if child.{} = parent; | ||
| "#, | ||
| resource_name, | ||
| parent_resource_name, | ||
| resource_name, | ||
| parent_as_snake, | ||
| parent_resource_name, | ||
| resource_name, | ||
| parent_as_snake, | ||
| ), | ||
| }; | ||
|
|
||
| let doc_struct = format!( | ||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest making this an enum with two explicit values, like: