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

MTV-1745 | Improve validating webhooks #1338

Merged
merged 7 commits into from
Feb 12, 2025
Merged

MTV-1745 | Improve validating webhooks #1338

merged 7 commits into from
Feb 12, 2025

Conversation

jonner
Copy link
Contributor

@jonner jonner commented Feb 5, 2025

  • Allow api service account to create SubjectAccessReview objects
  • Validate target namespace from plan webhook
  • webhook: Disallow plans when providers can't be retrieved
  • webhooks: add check for permissions on VMs in migration plans
  • webhooks: check permissions on providers in migration plans
  • Add migration webhooks
  • Change api.GetGroupResource() to return a GroupResource

ref: https://issues.redhat.com/browse/MTV-1745

This will be needed to determine permissions for certain operations.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
@jonner jonner requested review from mnecas and yaacov as code owners February 5, 2025 22:13
@yaacov
Copy link
Member

yaacov commented Feb 11, 2025

@jonner can you squash the commits ?

Since the targetNamespace field of the plan is used to decide where to
create the VM, it is necessary to ensure that a user has permission to
create a VirtualMachine object in this namespace. Otherwise we have a
security issue where a user can migrate VMS into namespaces that they
don't have permissions for.

References: https://issues.redhat.com/browse/MTV-1745

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
If we can't get the source or destination provider, we will not be able
to perform appropriate permission checks, so allowing the plan in this
case has security risks.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Since the plan just specifies vms by name, we must validate that the
user has permission to these vms before creating a migration plan for
them. Otherwise the user would be allowed to migrate a VM that they
can't normally access to another location.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
@jonner
Copy link
Contributor Author

jonner commented Feb 11, 2025

@jonner can you squash the commits ?

I personally prefer more fine-grained commits, but I certainly can squash them. Do you prefer that to using the "squash and merge" feature in github?

@codecov-commenter
Copy link

codecov-commenter commented Feb 11, 2025

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 15.37%. Comparing base (f1fe5d0) to head (b320de7).
Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
pkg/controller/provider/web/base/auth.go 75.00% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1338      +/-   ##
==========================================
- Coverage   15.45%   15.37%   -0.08%     
==========================================
  Files         112      112              
  Lines       23377    23495     +118     
==========================================
  Hits         3613     3613              
- Misses      19479    19597     +118     
  Partials      285      285              
Flag Coverage Δ
unittests 15.37% <75.00%> (-0.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

We were not checking if the user had permission to access the provider
specified in a given migration plan.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Instead of returning separate values for group and resource, use
the kubernetes GroupResource type instead, which encapsulates things
a bit more nicely.

Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com>
Copy link

@yaacov
Copy link
Member

yaacov commented Feb 12, 2025

Do you prefer that to using the "squash and merge" feature in github?

I prefer the PR owner to be responsible for the squashing, that way I know if the separate commits are only for reviewing purposes or are a real separation of concerns, because the PR author has the best context and understanding of the changes they've made and can therefore create a clean, logical, and meaningful commit history in the final squashed commit, making it easier for reviewers and future maintainers to understand the evolution of the code.

@yaacov
Copy link
Member

yaacov commented Feb 12, 2025

I personally prefer more fine-grained commits

My concern with a large number of commits in a pull request is that it complicates back porting. A smaller, concern specific commits can makes it easier to track and manage the back porting.

@yaacov yaacov changed the title Improve validating webhooks MTV-1745 | Improve validating webhooks Feb 12, 2025
@yaacov yaacov merged commit c988831 into kubev2v:main Feb 12, 2025
15 of 21 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.

3 participants