-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Security solution] Security AI prompts integration #216106
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] Security AI prompts integration #216106
Conversation
- update fleet_packages.json - debug logging around installSecurityAiPromptsPackage - updated tests - console logs in x-pack/platform/plugins/shared/fleet/server/services/epm/kibana/assets/install.ts - update schema validation to test latest package_spec - script to generate saved objects
🎉 Snyk checks have passed. No issues have been found so far.✅ security/snyk check is complete. No issues have been found. (View Details) ✅ license/snyk check is complete. No issues have been found. (View Details) |
|
@kpollich a new bundled package is being added here, and a related test fails. Do you know what needs to be updated for this test? Thanks! |
|
Pinging @elastic/security-solution (Team: SecuritySolution) |
…ovic/kibana into security_ai_prompts_integration
|
Pinging @elastic/fleet (Team:Fleet) |
| try { | ||
| securityAiPrompt = await kibanaServer.savedObjects.get({ | ||
| type: 'security-ai-prompt', | ||
| id: 'sample_security_ai_prompt', |
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.
Is it possible to have conflicts if multiple packages have prompts with the same id?
I think that for other assets we prefix their ids with the name of the package to avoid these issues.
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.
The ids will be UUID autogenerated by saved object client, so we will not have this issue. this id was just for tests following other examples
|
@elasticmachine merge upstream |
kpollich
left a comment
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.
Thanks for updating the Fleet API tests. Those changes LGTM.
andrew-goldstein
left a comment
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.
Thank you @stephmilovic for enabling out of band prompt updates via the Security AI prompts integration! 🙏
✅ Automatic installation of the package is determined by the feature flag
✅ A non-default space installs the integration (desk tested with a clean install)
✅ The Developer Guide instructions in Integrations > Security AI Prompts successfully generate and update the content generated by the x-pack/solutions/security/plugins/elastic_assistant/scripts/generate_security_ai_prompts_script.ts script
LGTM 🚀
xcrzx
left a comment
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.
Overall LGTM 👍 Added a minor comment on error handling.
| try { | ||
| await findLatestPackageVersion(context, SECURITY_AI_PROMPTS_PACKAGE_NAME); | ||
| } catch (e) { | ||
| // fail silently | ||
| return null; | ||
| } | ||
|
|
||
| const pkgVersion = await findLatestPackageVersion(context, SECURITY_AI_PROMPTS_PACKAGE_NAME); | ||
|
|
||
| return context.getInternalFleetServices().packages.ensureInstalledPackage({ | ||
| pkgName: SECURITY_AI_PROMPTS_PACKAGE_NAME, | ||
| pkgVersion, | ||
| }); |
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.
The error should probably be handled like this to avoid a double findLatestPackageVersion call when there's no error:
| try { | |
| await findLatestPackageVersion(context, SECURITY_AI_PROMPTS_PACKAGE_NAME); | |
| } catch (e) { | |
| // fail silently | |
| return null; | |
| } | |
| const pkgVersion = await findLatestPackageVersion(context, SECURITY_AI_PROMPTS_PACKAGE_NAME); | |
| return context.getInternalFleetServices().packages.ensureInstalledPackage({ | |
| pkgName: SECURITY_AI_PROMPTS_PACKAGE_NAME, | |
| pkgVersion, | |
| }); | |
| try { | |
| const pkgVersion = await findLatestPackageVersion(context, SECURITY_AI_PROMPTS_PACKAGE_NAME); | |
| return context.getInternalFleetServices().packages.ensureInstalledPackage({ | |
| pkgName: SECURITY_AI_PROMPTS_PACKAGE_NAME, | |
| pkgVersion, | |
| }); | |
| } catch (e) { | |
| // fail silently | |
| return null; | |
| } |
Another good option would be to adjust findLatestPackageVersion to return null when no package is found, instead of throwing an error. That would help avoid using a clumsy empty catch block, which can backfire in some cases.
|
@elasticmachine merge upstream |
⏳ Build in-progress, with failures
Failed CI StepsTest Failures
History
|
|
@elasticmachine merge upstream |
|
Starting backport for target branches: 8.19 https://github.com/elastic/kibana/actions/runs/14936445575 |
💔 All backports failed
Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation |
(cherry picked from commit 1176009) # Conflicts: # x-pack/solutions/security/plugins/security_solution/common/experimental_features.ts # x-pack/solutions/security/plugins/security_solution/server/lib/detection_engine/prebuilt_rules/api/bootstrap_prebuilt_rules/bootstrap_prebuilt_rules_handler.ts # x-pack/test/fleet_api_integration/apis/epm/__snapshots__/bulk_get_assets.snap # x-pack/test/fleet_api_integration/apis/epm/update_assets.ts
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…220717) # Backport This will backport the following commits from `main` to `8.19`: - [[Security solution] Security AI prompts integration (#216106)](#216106) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Steph Milovic","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-05-09T19:39:18Z","message":"[Security solution] Security AI prompts integration (#216106)","sha":"117600978e5b7b89b67c5c8f62a721e1d0acc1ab","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:enhancement","Team:Fleet","Team: SecuritySolution","Team:Security Generative AI","backport:version","v9.1.0","v8.19.0"],"title":"[Security solution] Security AI prompts integration","number":216106,"url":"https://github.com/elastic/kibana/pull/216106","mergeCommit":{"message":"[Security solution] Security AI prompts integration (#216106)","sha":"117600978e5b7b89b67c5c8f62a721e1d0acc1ab"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/216106","number":216106,"mergeCommit":{"message":"[Security solution] Security AI prompts integration (#216106)","sha":"117600978e5b7b89b67c5c8f62a721e1d0acc1ab"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> --------- Co-authored-by: kibanamachine <[email protected]>
Summary
xpack.securitySolution.enableExperimental: ['securityAIPromptsEnabled']Testing
x-pack/solutions/security/packages/security-ai-prompts/src/get_prompt.ts, add a log underneath thesavedObjectsClient.findlikeconsole.log('prompts ==>', prompts);. When you ask the assistant a question, you should see several logs like:Related issues