-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[SecuritySolution] Register AI Assistant management settings according to productFeatureKeys #213105
base: main
Are you sure you want to change the base?
Conversation
|
||
this.experimentalFeatures = parseExperimentalConfigValue( | ||
this.config.enableExperimental, | ||
securitySolution.experimentalFeatures | ||
).features; | ||
|
||
console.log('serverless setup: setProductFeatureKeys====== ') | ||
securitySolution.setProductFeatureKeys(getProductProductFeatures(productTypes)); |
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.
It setProductFeatureKeys correctly for complete and essential tiers.
console.log('productFeatureKeys---',productFeatureKeys); | ||
// This seemed to work with serverless but not sure how to deal with ess productFeatureKeys | ||
|
||
const isInProductFeatureKeys = productFeatureKeys && productFeatureKeys.length > 0 && productFeatureKeys.includes(ProductFeatureAssistantKey.assistant); |
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.
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.
console.log('productFeatureKeys---',productFeatureKeys); | ||
// This seemed to work with serverless but not sure how to deal with ess productFeatureKeys | ||
|
||
const isInProductFeatureKeys = productFeatureKeys && productFeatureKeys.length > 0 && productFeatureKeys.includes(ProductFeatureAssistantKey.assistant); |
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.
Can we define the productFeatureKeys$
as a Set<ProductFeatureKeyType>
, so we can do:
const isInProductFeatureKeys = productFeatureKeys && productFeatureKeys.length > 0 && productFeatureKeys.includes(ProductFeatureAssistantKey.assistant); | |
const isInProductFeatureKeys = productFeatureKeys?.has(ProductFeatureAssistantKey.assistant); |
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.
It would be nice to have some control to prevent registering this twice, in case more values are emitted.
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 check the registration by its id, wdyt? https://github.com/elastic/kibana/pull/213105/files#diff-fa30014b439035af4cc4c875257fb2707ebbeb2f77acb875273129f163db013dR192
Project deployed, see credentials at: https://buildkite.com/elastic/kibana-deploy-project-from-pr/builds/351 |
x-pack/solutions/security/plugins/security_solution_ess/public/plugin.ts
Outdated
Show resolved
Hide resolved
x-pack/solutions/security/plugins/security_solution/public/plugin_contract.ts
Outdated
Show resolved
Hide resolved
x-pack/solutions/security/plugins/security_solution/public/plugin.tsx
Outdated
Show resolved
Hide resolved
…gin_contract.ts Co-authored-by: Sergi Massaneda <sergi.massaneda@gmail.com>
…gin.tsx Co-authored-by: Sergi Massaneda <sergi.massaneda@gmail.com>
Pinging @elastic/security-threat-hunting-explore (Team:Threat Hunting:Explore) |
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.
LGTM! 💯
const isAssistantAvailable = | ||
productFeatureKeys?.has(ProductFeatureAssistantKey.assistant) && | ||
license?.hasAtLeast('enterprise'); |
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 just realized that if productFeatureKeys
is still null, or the license
is not defined yet, this code will behave as if the assistant is not available, disabling the assistant management.
Can we add a check for at the beginning?
const isAssistantAvailable = | |
productFeatureKeys?.has(ProductFeatureAssistantKey.assistant) && | |
license?.hasAtLeast('enterprise'); | |
if (!productFeatureKeys || !license) { | |
return; | |
} | |
const isAssistantAvailable = | |
productFeatureKeys.has(ProductFeatureAssistantKey.assistant) && | |
license.hasAtLeast('enterprise'); |
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.
It seems that as long as we use BehaviorSubject with an initial value, it will always emit the initial value as the first emission. To avoid that, I'd like to replace BehaviorSubject with Subject so the first emission will be the productFeatureKeys from ESS/serverless.
combineLatestWith waits for both productFeatureKeys$ and license$ to emit at least once before emitting a combined value.
In this case, we should be able to always receive the non null values.
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.
Using Subject the subscribe handler will be called only if it is registered before the first next call. If the next happens before the handler is subscribed, it will never be called.
To avoid that, I'm sticking to BehaviorSubject and check if productFeatureKeys and license exists.
💔 Build Failed
Failed CI StepsMetrics [docs]Module Count
Public APIs missing comments
Async chunks
Page load bundle
Unknown metric groupsAPI count
References to deprecated APIs
History
|
Summary
Fixes: #212667
AI Assistant management is registered according to
productFeatureKeys
set by security_solution_ess or security_solution_serverless plugin.To verify:
Update xpack.securitySolutionServerless.productTypes in config/serverless.security.yml to switch between
essentials
andcomplete
tierProject essentials:
Project complete:
License trial and enterprise:
Screen.Recording.2025-03-04.at.17.24.35.mov
License basic and others:
Screen.Recording.2025-03-04.at.17.27.35.mov