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

✨ (GoodPracticesValidator) : Add a new check to warn authors when permissions to create CRDs are found #241

Merged
merged 1 commit into from
May 24, 2022

Conversation

camilamacedo86
Copy link
Contributor

@camilamacedo86 camilamacedo86 commented May 14, 2022

Description
Add a new check to warn authors when permissions to create CRDs are found. They usually will ask for these permissions when their Operands manage other operators and create CRDs that is not recommended.

Motivation
Use case: we recently check a Helm-based language operator created with helm charts which would install other Operators.

How it will be used

Any project that uses OF/api will have this check. However, via SDK (which is generally used by users/ci's/pipelines) the warning will be raised when:

a) To validate a bundle against the validator for Good Practices specifically, in addition to required bundle validators: $ operator-sdk bundle validate ./bundle --select-optional name=good-practices

b) To validate a bundle against the entire suite of validators for Operator Framework, in addition to required bundle validators: $ operator-sdk bundle validate ./bundle --select-optional suite=operatorframework

@openshift-ci openshift-ci bot requested review from ecordell and perdasilva May 14, 2022 20:11
@camilamacedo86
Copy link
Contributor Author

c/c @ryantking

@camilamacedo86 camilamacedo86 changed the title ✨ (GoodPracticesValidator) : new check to warning that authors should not create an operator to manage another operator by looking for RBAC permissions to create CRDs ✨ (GoodPracticesValidator) : Add a new check to warn authors when permissions to create CRDs are found May 15, 2022
@ryantking
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label May 19, 2022
Copy link
Member

@dinhxuanvu dinhxuanvu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though I can see the reason behind this PR, this change will enforce some restrictions on what an operator can do. I would like to run this pass another set of eyes before approving.
@joelanford do you have any issues with this change?


func hasRBACFor(perm v1alpha1.StrategyDeploymentPermissions, apiGroupResourceMap map[string][]string, verbs []string) bool {
// For each APIGroup and list of resources that we are looking for
for apiFromMap, resourcesFromMap := range apiGroupResourceMap {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we have a better way to check for this. This looks rather ugly though I guess you didn't have much of a choice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is easily readable and understandable then we try to make it less ugly when behind the scene will do the same.

@dinhxuanvu
Copy link
Member

Also this PR needs a rebase.

@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label May 20, 2022
@camilamacedo86
Copy link
Contributor Author

Hi @dinhxuanvu:

Even though I can see the reason behind this PR, this change will enforce some restrictions on what an operator can do. I would like to run this pass another set of eyes before approving.
@joelanford do you have any issues with this change?

We are not enforcing. The good practices validator will return a warning in this case and not an error.
It was a @joelanford's suggestion too (More info: https://coreos.slack.com/archives/GHMALGJV6/p1652210479908649?thread_ts=1652185816.258749&cid=GHMALGJV6)

From ^

We could also include a warning in the bundle validation somewhere that checks to see if the bundle includes RBAC that allows it to create CRDs. And if it does, we could raise a warning pointing to that best practice doc.

… not create an operator to manage another operator by looking for RBAC permissions to create CRDs
Copy link
Member

@dinhxuanvu dinhxuanvu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve

@openshift-ci
Copy link

openshift-ci bot commented May 23, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: camilamacedo86, dinhxuanvu

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 23, 2022
@ryantking
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label May 24, 2022
@openshift-merge-robot openshift-merge-robot merged commit 05acd7a into operator-framework:master May 24, 2022
@camilamacedo86 camilamacedo86 deleted the add-check-perm branch May 24, 2022 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants