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

[Security Solution][Endpoint] Enable Kibana feature controls (RBAC)configuration by space for Endpoint management #193003

Merged

Conversation

paul-tavares
Copy link
Contributor

@paul-tavares paul-tavares commented Sep 16, 2024

Summary

Kibana Core Security plugin

  • Updated several Role forms to include data-test-subj in order to better select items from tests

Security Solution Plugin (and associated packages)

Changes in support of space awareness:

  • New feature flag control: endpointManagementSpaceAwarenessEnabled
  • Elastic Defend related kibana feature controls are changed to requireAllSpaces: false when feature flag is enabled

In addition:

  • The Cypress serverless FTR configuration used for Defend Workflows tests was updated to enable the creation of spaces and also role management UI

image

Checklist

@paul-tavares paul-tavares added release_note:skip Skip the PR/issue when compiling release notes Team:Defend Workflows “EDR Workflows” sub-team of Security Solution v8.16.0 labels Sep 16, 2024
@paul-tavares paul-tavares self-assigned this Sep 16, 2024
@paul-tavares
Copy link
Contributor Author

/ci

@paul-tavares
Copy link
Contributor Author

/ci

@paul-tavares
Copy link
Contributor Author

@paul-tavares
Copy link
Contributor Author

/ci

@paul-tavares
Copy link
Contributor Author

/ci

@paul-tavares paul-tavares marked this pull request as ready for review September 17, 2024 21:53
@paul-tavares paul-tavares requested review from a team as code owners September 17, 2024 21:53
@paul-tavares
Copy link
Contributor Author

/ci

Copy link
Contributor

@kc13greiner kc13greiner left a comment

Choose a reason for hiding this comment

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

LGTM!

(pending green CI 😅 )

Copy link
Contributor

@gergoabraham gergoabraham left a comment

Choose a reason for hiding this comment

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

looks good! 🚀 thanks for the replies and explanations

@paul-tavares paul-tavares added the backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) label Sep 19, 2024

return subFeature;
};

const securitySubFeaturesList: Array<[SecuritySubFeatureId, SubFeatureConfig]> = [
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if it wouldn't be more readable if you iterate over securitySubFeaturesList instead of wrapping each subFeature in enableSpaceAwarenessIfNeeded. What do you think?

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 guess. It accomplishes the same thing, but I'm open to changing it.

what do you find about this implementation that makes it less readable?

I did try to make the function names clear as to what they do and also opted to do it this way only because it gives us some flexibility if we ever have a case where a specific feature privilege does require it to be space agonistic.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was thinking more about doing it in one place insterad of passing to all separately:

  const securitySubFeaturesListWithSpaceAwarnessIfNeeded = securitySubFeaturesList.map(
    ([id, config]) => [id, enableSpaceAwarenessIfNeeded(config)];
   );

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah... Not sure if its better - I don't like that additional iteration by using .map() and recreating the entire structure again.

I'm going to leave it as is for now.

Copy link
Contributor

@tomsonpl tomsonpl left a comment

Choose a reason for hiding this comment

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

Looks great, left 2 suggestions, thanks!

(suffix: string = '') => {
return `${props.categoryId ? `${props.categoryId}_` : ''}${
props.featureId
}_${subFeatureNameTestId}${suffix ? `_${suffix}` : ''}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

I always opt against having generators for test-ids because it's almost impossible to find the element from the web console in the codebase. What do you say if we hardcode the test-ids?

Copy link
Contributor Author

@paul-tavares paul-tavares Sep 19, 2024

Choose a reason for hiding this comment

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

I'm actually of the opposite opinion. Having static test ids in some cases makes it harder to find the elements you are after, especially when a component is reused multiple times on the page - as is the case here. Static only make sense (to me) when a component is not reused on a page (is only ever rendered once)

I rather keep it as is, unless you have a better way to select elements on the page in a more efficient way

Copy link
Contributor

Choose a reason for hiding this comment

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

Whenever I want to debug functionality, I get the data-test-id from devconsole. If it was hardcoded I could just use Ctrl+F and search for it, with the prefixes generators etc it's almost impossible - and have to look for chunks and later confirm if I found a correct prefix.

However, I don't insist, just sharing personal opinion :P It can stay this way 👍 Thanks!

Copy link
Contributor Author

@paul-tavares paul-tavares Sep 19, 2024

Choose a reason for hiding this comment

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

So yeah, I do think we differ in the way we approach test development. If I'm working on e2e tests, I do in fact use the browser's developer tools to grab the data-test-subj's for elements I need to access. And that is what these changes are doing to the role forms. And in this case, because those forms are used multiple times on the page, using a static data-test-subj would negate the purpose as to why I made them - to facilitate and more predictably select elements in DOM.

I will leave it as is since you are ok with it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Of course, all good 👍 thanks for the consideration :)

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
security 589.3KB 590.0KB +760.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
securitySolution 87.1KB 87.1KB +43.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @paul-tavares

@paul-tavares paul-tavares enabled auto-merge (squash) September 19, 2024 21:22
@paul-tavares paul-tavares merged commit 9a9c0f1 into elastic:main Sep 20, 2024
41 checks passed
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Sep 20, 2024
…nfiguration by space for Endpoint management (elastic#193003)

## Summary

### Kibana Core Security plugin

- Updated several Role forms to include `data-test-subj` in order to
better select items from tests

### Security Solution Plugin (and associated packages)

Changes in support of space awareness:

- New feature flag control: `endpointManagementSpaceAwarenessEnabled`
- Elastic Defend related kibana feature controls are changed to
`requireAllSpaces: false` when feature flag is enabled

In addition:

- The Cypress serverless FTR configuration used for Defend Workflows
tests was updated to enable the creation of spaces and also role
management UI

(cherry picked from commit 9a9c0f1)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Sep 20, 2024
…BAC)configuration by space for Endpoint management (#193003) (#193525)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Security Solution][Endpoint] Enable Kibana feature controls
(RBAC)configuration by space for Endpoint management
(#193003)](#193003)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Paul
Tavares","email":"56442535+paul-tavares@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-09-20T09:47:37Z","message":"[Security
Solution][Endpoint] Enable Kibana feature controls (RBAC)configuration
by space for Endpoint management (#193003)\n\n## Summary\r\n\r\n###
Kibana Core Security plugin\r\n\r\n- Updated several Role forms to
include `data-test-subj` in order to\r\nbetter select items from
tests\r\n\r\n\r\n\r\n### Security Solution Plugin (and associated
packages)\r\n\r\nChanges in support of space awareness:\r\n\r\n- New
feature flag control: `endpointManagementSpaceAwarenessEnabled`\r\n-
Elastic Defend related kibana feature controls are changed
to\r\n`requireAllSpaces: false` when feature flag is enabled\r\n\r\nIn
addition:\r\n\r\n- The Cypress serverless FTR configuration used for
Defend Workflows\r\ntests was updated to enable the creation of spaces
and also role\r\nmanagement
UI","sha":"9a9c0f1afe0369d5cfaae1b9468c60dbe800d73b","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:Defend
Workflows","backport:prev-minor","v8.16.0"],"title":"[Security
Solution][Endpoint] Enable Kibana feature controls (RBAC)configuration
by space for Endpoint
management","number":193003,"url":"#193003
Solution][Endpoint] Enable Kibana feature controls (RBAC)configuration
by space for Endpoint management (#193003)\n\n## Summary\r\n\r\n###
Kibana Core Security plugin\r\n\r\n- Updated several Role forms to
include `data-test-subj` in order to\r\nbetter select items from
tests\r\n\r\n\r\n\r\n### Security Solution Plugin (and associated
packages)\r\n\r\nChanges in support of space awareness:\r\n\r\n- New
feature flag control: `endpointManagementSpaceAwarenessEnabled`\r\n-
Elastic Defend related kibana feature controls are changed
to\r\n`requireAllSpaces: false` when feature flag is enabled\r\n\r\nIn
addition:\r\n\r\n- The Cypress serverless FTR configuration used for
Defend Workflows\r\ntests was updated to enable the creation of spaces
and also role\r\nmanagement
UI","sha":"9a9c0f1afe0369d5cfaae1b9468c60dbe800d73b"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"#193003
Solution][Endpoint] Enable Kibana feature controls (RBAC)configuration
by space for Endpoint management (#193003)\n\n## Summary\r\n\r\n###
Kibana Core Security plugin\r\n\r\n- Updated several Role forms to
include `data-test-subj` in order to\r\nbetter select items from
tests\r\n\r\n\r\n\r\n### Security Solution Plugin (and associated
packages)\r\n\r\nChanges in support of space awareness:\r\n\r\n- New
feature flag control: `endpointManagementSpaceAwarenessEnabled`\r\n-
Elastic Defend related kibana feature controls are changed
to\r\n`requireAllSpaces: false` when feature flag is enabled\r\n\r\nIn
addition:\r\n\r\n- The Cypress serverless FTR configuration used for
Defend Workflows\r\ntests was updated to enable the creation of spaces
and also role\r\nmanagement
UI","sha":"9a9c0f1afe0369d5cfaae1b9468c60dbe800d73b"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Paul Tavares <56442535+paul-tavares@users.noreply.github.com>
@paul-tavares paul-tavares deleted the task/olm-8537-rbac-for-multiple-spaces branch September 20, 2024 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) release_note:skip Skip the PR/issue when compiling release notes Team:Defend Workflows “EDR Workflows” sub-team of Security Solution v8.16.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants