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

[EDR Workflows][Serverless] Gate custom note #193171

Merged
merged 20 commits into from
Oct 1, 2024

Conversation

szwarckonrad
Copy link
Contributor

@szwarckonrad szwarckonrad commented Sep 17, 2024

This PR implements tier-based gating for custom notification messages in Protections. Only users on the Endpoint Complete tier will have the ability to modify these messages, while users on the Endpoint Essentials tier will no longer have this capability. If a user on the Essentials tier had made any changes to custom notifications before this update, those messages will be reset to the default ones.

The changes are applied in three areas:

  1. UI - An upsell banner is displayed for Essentials users.
  2. API - We now prevent API calls that attempt to set or modify custom notification messages for Essentials users.
  3. Policy Watcher - Upon Kibana startup (e.g., after a downgrade), we validate all policies for tier compliance. If a policy contains a custom notification message and the user is on the Essentials tier, the message will be reset to the default.

Screenshot 2024-09-20 at 14 32 52
Screenshot 2024-09-20 at 14 33 21
Screenshot 2024-09-20 at 14 33 40
Screenshot 2024-09-20 at 14 52 25

@szwarckonrad szwarckonrad 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 17, 2024
@szwarckonrad szwarckonrad self-assigned this Sep 17, 2024
@szwarckonrad szwarckonrad added v9.0.0 backport:version Backport to applied version labels labels Sep 20, 2024
};

const generateExpectedPolicyMock = ({
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 decided to keep this fragment hardcoded, as any attempts to generate it with iterations resulted in code that, in my opinion, would be difficult to read and hard for anyone to understand.

Copy link
Member

Choose a reason for hiding this comment

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

In that case, I would urge you to consider adding this info as a comment block so this block stays that way.

@szwarckonrad szwarckonrad marked this pull request as ready for review September 23, 2024 08:57
@szwarckonrad szwarckonrad requested review from a team as code owners September 23, 2024 08:57
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-defend-workflows (Team:Defend Workflows)

@szwarckonrad szwarckonrad requested review from ashokaditya and removed request for pzl September 23, 2024 08:58
Copy link
Contributor

@semd semd left a comment

Choose a reason for hiding this comment

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

Feature PLI config and upselling component registration LGTM

Copy link
Contributor

@paul-tavares paul-tavares 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 👍

@szwarckonrad szwarckonrad added the ci:project-deploy-security Create a Security Serverless Project label Sep 26, 2024
Copy link
Member

@ashokaditya ashokaditya 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. I left some suggestions for you to consider, esp. with the info text.

From your screenshot, I noticed that the bottom padding/spacing is more than the left/right padding. Is there a way to ensure they are consistent? Perhaps use xs instead of m wherever NotifyUserOption is used. I know this was not something you changed but it's nice to update.

Screenshot 2024-09-26 at 10 35 39

Comment on lines +87 to +89
cy.getByTestSubj(`endpointPolicyForm-${protection}-notifyUser-customMessage`)
.should('exist')
.and('be.visible');
Copy link
Member

Choose a reason for hiding this comment

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

For this test and the one above, consider adding a line of comment above each block of assertion for what is visible and what is not. The last assertion here seems like customMessage is visible which I assume is a custom notificaton but the test title contradicts that. It's confusing I 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.

Added

'xpack.securitySolutionServerless.endpointCustomNotification.cardMessage',
{
defaultMessage:
'To customize the user notification, you must add Endpoint Protection Complete to your project.',
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if this info text is enough to inform the user what they need to do. Maybe you want to check with @caitlinbetz. I would go with something like To enable customized user notifications, you must add Endpoint Complete to your project. I don't see Endpoint Protection Complete anywhere else in the codebase for such info.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Talked with @caitlinbetz offline, we've decided to keep the naming consistent - https://github.com/elastic/security-team/issues/9762#issuecomment-2377746522

Copy link
Member

Choose a reason for hiding this comment

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

In that case, we should update the other upsell info message that we currently have about modifying protection updates that says To modify protection updates, you must add at least Endpoint Complete to your project.

Also consider this concise info-text instead To customize user notifications, you must add Endpoint Protection Complete to your project.

) {
const productFeatureError: Error & { statusCode?: number; apiPassThrough?: boolean } =
new Error(
'To modify protection updates, you must add at least Endpoint Complete to your project.'
'To customize the user notification, you must add Endpoint Protection Complete to your project.'
Copy link
Member

Choose a reason for hiding this comment

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

Same about the info text update here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Talked with @caitlinbetz offline, we've decided to keep the naming consistent - https://github.com/elastic/security-team/issues/9762#issuecomment-2377746522

Copy link
Member

Choose a reason for hiding this comment

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

See my above comment.

};

const generateExpectedPolicyMock = ({
Copy link
Member

Choose a reason for hiding this comment

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

In that case, I would urge you to consider adding this info as a comment block so this block stays that way.

Comment on lines 71 to 81
cy.getByTestSubj(`endpointPolicyForm-${protection}-enableDisableSwitch`).click();
[
'endpointPolicy-customNotificationLockedCard-title',
'endpointPolicy-customNotificationLockedCard',
'endpointPolicy-customNotificationLockedCard-badge',
].forEach((testSubj) => {
cy.getByTestSubj(testSubj, { timeout: 60000 }).should('exist').and('be.visible');
});
cy.getByTestSubj(`endpointPolicyForm-${protection}-notifyUser-customMessage`).should(
'not.exist'
);
Copy link
Member

Choose a reason for hiding this comment

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

Same for this test. Please add some comments to explain what the assertions are

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added

<h4>{NOTIFICATION_MESSAGE_LABEL}</h4>
</EuiText>
<EuiSpacer size="xs" />
<>{userNotificationMessage || getEmptyValue()}</>
Copy link
Member

Choose a reason for hiding this comment

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

Q: Does emptyValue() (-) ever get rendered? from the types looks like userNotificationMessage is always present.

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 believe that userNotificationMessage can be an empty string, which works fine when displaying it in the input box. However, in view-only mode, we want to indicate graphically that there is no notification message by displaying -.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, but I don't see the - in the view only mode. I still see an empty textarea. 😕 I'll test again.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

User with full access:
Screenshot 2024-10-01 at 10 45 59

User with read only access:
Screenshot 2024-10-01 at 10 49 17

Seems like empty string is being replaced with the default message here -

if (policyItem.inputs[0].config.policy.value.windows.popup.malware.message === '') {

I didn’t feel comfortable enough removing the || getEmptyValue(), so I decided to leave it in 😉

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, this is updating it to the Elastic Security {action} {filename} text. Which I think should be updated to Elastic Endpoint {action} {filename} if at all that is the behavior we need. Maybe @paul-tavares @dasansol92 know something about this logic?

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’m planning to gather all the improvement suggestions from this PR and consolidate them into a single issue for further discussion. What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

That sounds good to me.

return <CustomNotificationUpsellingComponent />;
}

if (!isEditMode) {
Copy link
Member

Choose a reason for hiding this comment

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

Does this ever render? I tested it out and looks like it is valid pre-render so - never shows on the screen.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It renders for users who do not have RBAC access to edit custom messages.

# Conflicts:
#	x-pack/plugins/security_solution/server/endpoint/migrations/turn_off_policy_protections.test.ts
#	x-pack/plugins/security_solution/server/endpoint/migrations/turn_off_policy_protections.ts
@szwarckonrad szwarckonrad enabled auto-merge (squash) October 1, 2024 11:33
@kibana-ci
Copy link
Collaborator

kibana-ci commented Oct 1, 2024

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #42 / security APIs - Session Idle Session Idle cleanup should properly clean up session expired because of idle timeout when providers override global session config

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
securitySolution 5930 5931 +1
securitySolutionServerless 143 144 +1
total +2

Async chunks

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

id before after diff
securitySolution 20.5MB 20.5MB +600.0B
securitySolutionServerless 119.2KB 132.6KB +13.5KB
total +14.1KB

Page load bundle

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

id before after diff
securitySolutionServerless 21.6KB 21.9KB +288.0B
Unknown metric groups

async chunk count

id before after diff
securitySolutionServerless 14 15 +1

History

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

cc @szwarckonrad

@szwarckonrad szwarckonrad merged commit af1dc87 into elastic:main Oct 1, 2024
45 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/11126225795

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Oct 1, 2024
This PR implements tier-based gating for custom notification messages in
Protections. Only users on the Endpoint Complete tier will have the
ability to modify these messages, while users on the Endpoint Essentials
tier will no longer have this capability. If a user on the Essentials
tier had made any changes to custom notifications before this update,
those messages will be reset to the default ones.

The changes are applied in three areas:
1. UI - An upsell banner is displayed for Essentials users.
2. API - We now prevent API calls that attempt to set or modify custom
notification messages for Essentials users.
3. Policy Watcher - Upon Kibana startup (e.g., after a downgrade), we
validate all policies for tier compliance. If a policy contains a custom
notification message and the user is on the Essentials tier, the message
will be reset to the default.

![Screenshot 2024-09-20 at 14 32
52](https://github.com/user-attachments/assets/75739338-e32b-47da-934e-9948f44099ae)
![Screenshot 2024-09-20 at 14 33
21](https://github.com/user-attachments/assets/1af081eb-f75f-4c9d-8f01-df9a01f8f2b2)
![Screenshot 2024-09-20 at 14 33
40](https://github.com/user-attachments/assets/4c0014f5-89f0-48b6-88dc-cc4c2dba666a)
![Screenshot 2024-09-20 at 14 52
25](https://github.com/user-attachments/assets/202e5e1a-7c58-4af1-a85a-399c94313f0b)

---------

Co-authored-by: kibanamachine <[email protected]>
(cherry picked from commit af1dc87)
@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 Oct 1, 2024
# Backport

This will backport the following commits from `main` to `8.x`:
- [[EDR Workflows][Serverless] Gate custom note
(#193171)](#193171)

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

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

<!--BACKPORT [{"author":{"name":"Konrad
Szwarc","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-01T13:20:27Z","message":"[EDR
Workflows][Serverless] Gate custom note (#193171)\n\nThis PR implements
tier-based gating for custom notification messages in\r\nProtections.
Only users on the Endpoint Complete tier will have the\r\nability to
modify these messages, while users on the Endpoint Essentials\r\ntier
will no longer have this capability. If a user on the Essentials\r\ntier
had made any changes to custom notifications before this
update,\r\nthose messages will be reset to the default ones.\r\n\r\nThe
changes are applied in three areas:\r\n1. UI - An upsell banner is
displayed for Essentials users.\r\n2. API - We now prevent API calls
that attempt to set or modify custom\r\nnotification messages for
Essentials users.\r\n3. Policy Watcher - Upon Kibana startup (e.g.,
after a downgrade), we\r\nvalidate all policies for tier compliance. If
a policy contains a custom\r\nnotification message and the user is on
the Essentials tier, the message\r\nwill be reset to the
default.\r\n\r\n![Screenshot 2024-09-20 at 14
32\r\n52](https://github.com/user-attachments/assets/75739338-e32b-47da-934e-9948f44099ae)\r\n![Screenshot
2024-09-20 at 14
33\r\n21](https://github.com/user-attachments/assets/1af081eb-f75f-4c9d-8f01-df9a01f8f2b2)\r\n![Screenshot
2024-09-20 at 14
33\r\n40](https://github.com/user-attachments/assets/4c0014f5-89f0-48b6-88dc-cc4c2dba666a)\r\n![Screenshot
2024-09-20 at 14
52\r\n25](https://github.com/user-attachments/assets/202e5e1a-7c58-4af1-a85a-399c94313f0b)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"af1dc871eb020a885278df280a6f830bc1179d56","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","ci:project-deploy-security","v8.16.0","backport:version"],"title":"[EDR
Workflows][Serverless] Gate custom
note","number":193171,"url":"https://github.com/elastic/kibana/pull/193171","mergeCommit":{"message":"[EDR
Workflows][Serverless] Gate custom note (#193171)\n\nThis PR implements
tier-based gating for custom notification messages in\r\nProtections.
Only users on the Endpoint Complete tier will have the\r\nability to
modify these messages, while users on the Endpoint Essentials\r\ntier
will no longer have this capability. If a user on the Essentials\r\ntier
had made any changes to custom notifications before this
update,\r\nthose messages will be reset to the default ones.\r\n\r\nThe
changes are applied in three areas:\r\n1. UI - An upsell banner is
displayed for Essentials users.\r\n2. API - We now prevent API calls
that attempt to set or modify custom\r\nnotification messages for
Essentials users.\r\n3. Policy Watcher - Upon Kibana startup (e.g.,
after a downgrade), we\r\nvalidate all policies for tier compliance. If
a policy contains a custom\r\nnotification message and the user is on
the Essentials tier, the message\r\nwill be reset to the
default.\r\n\r\n![Screenshot 2024-09-20 at 14
32\r\n52](https://github.com/user-attachments/assets/75739338-e32b-47da-934e-9948f44099ae)\r\n![Screenshot
2024-09-20 at 14
33\r\n21](https://github.com/user-attachments/assets/1af081eb-f75f-4c9d-8f01-df9a01f8f2b2)\r\n![Screenshot
2024-09-20 at 14
33\r\n40](https://github.com/user-attachments/assets/4c0014f5-89f0-48b6-88dc-cc4c2dba666a)\r\n![Screenshot
2024-09-20 at 14
52\r\n25](https://github.com/user-attachments/assets/202e5e1a-7c58-4af1-a85a-399c94313f0b)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"af1dc871eb020a885278df280a6f830bc1179d56"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/193171","number":193171,"mergeCommit":{"message":"[EDR
Workflows][Serverless] Gate custom note (#193171)\n\nThis PR implements
tier-based gating for custom notification messages in\r\nProtections.
Only users on the Endpoint Complete tier will have the\r\nability to
modify these messages, while users on the Endpoint Essentials\r\ntier
will no longer have this capability. If a user on the Essentials\r\ntier
had made any changes to custom notifications before this
update,\r\nthose messages will be reset to the default ones.\r\n\r\nThe
changes are applied in three areas:\r\n1. UI - An upsell banner is
displayed for Essentials users.\r\n2. API - We now prevent API calls
that attempt to set or modify custom\r\nnotification messages for
Essentials users.\r\n3. Policy Watcher - Upon Kibana startup (e.g.,
after a downgrade), we\r\nvalidate all policies for tier compliance. If
a policy contains a custom\r\nnotification message and the user is on
the Essentials tier, the message\r\nwill be reset to the
default.\r\n\r\n![Screenshot 2024-09-20 at 14
32\r\n52](https://github.com/user-attachments/assets/75739338-e32b-47da-934e-9948f44099ae)\r\n![Screenshot
2024-09-20 at 14
33\r\n21](https://github.com/user-attachments/assets/1af081eb-f75f-4c9d-8f01-df9a01f8f2b2)\r\n![Screenshot
2024-09-20 at 14
33\r\n40](https://github.com/user-attachments/assets/4c0014f5-89f0-48b6-88dc-cc4c2dba666a)\r\n![Screenshot
2024-09-20 at 14
52\r\n25](https://github.com/user-attachments/assets/202e5e1a-7c58-4af1-a85a-399c94313f0b)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"af1dc871eb020a885278df280a6f830bc1179d56"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Konrad Szwarc <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:version Backport to applied version labels ci:project-deploy-security Create a Security Serverless Project 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.

7 participants