Skip to content

Conversation

@stephmilovic
Copy link
Contributor

@stephmilovic stephmilovic commented Mar 26, 2025

Summary

  • Adds config to package the Security AI prompts integration
  • Adds a script that generates the saved objects to use with the integration
  • Updates the “bootstrap_prebuilt_rules_handler” route to install the Security AI prompts integration automatically when the user navigates the security solution
  • Adds a feature flag that is required for the install to happen:
    xpack.securitySolution.enableExperimental: ['securityAIPromptsEnabled']

Testing

  1. Add the following to your dev yml
xpack.fleet.internal.registry.spec.max: 3.4
xpack.fleet.internal.registry.kibanaVersionCheckEnabled: false
xpack.fleet.registryUrl: https://epr.elastic.co
xpack.securitySolution.enableExperimental: ['securityAIPromptsEnabled']
  1. Start kibana. Navigate to the Stack Management > Saved Objects view. There should not be any prompt saved objects
  2. Navigate to a security page. Now go back to the Stack Management > Saved Objects view. There should now be prompt saved objects:
Screenshot 2025-05-07 at 10 44 00 AM
  1. Go to the integrations page and click Installed integrations. You should see the prompts package. Click into the package details. You should see a message "This is a pre-release version of Security AI Prompts integration."
  2. Because the prompts are currently identical to the local prompts, there is not a good way to check that they are being used besides adding a log to the code. In x-pack/solutions/security/packages/security-ai-prompts/src/get_prompt.ts, add a log underneath the savedObjectsClient.find like console.log('prompts ==>', prompts);. When you ask the assistant a question, you should see several logs like:
Screenshot 2025-05-07 at 10 49 30 AM

Related issues

andrew-goldstein and others added 3 commits March 25, 2025 08:47
- 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
@stephmilovic stephmilovic added Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:Security Generative AI Security Generative AI backport:version Backport to applied version labels v9.1.0 v8.19.0 labels Mar 27, 2025
@prodsecmachine
Copy link
Collaborator

prodsecmachine commented May 1, 2025

🎉 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)

@jsoriano
Copy link
Member

jsoriano commented May 6, 2025

@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!

@elasticmachine
Copy link
Contributor

Pinging @elastic/security-solution (Team: SecuritySolution)

@botelastic botelastic bot added the Team:Fleet Team label for Observability Data Collection Fleet team label May 7, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

try {
securityAiPrompt = await kibanaServer.savedObjects.get({
type: 'security-ai-prompt',
id: 'sample_security_ai_prompt',
Copy link
Member

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.

Copy link
Contributor Author

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

@stephmilovic
Copy link
Contributor Author

@elasticmachine merge upstream

Copy link
Member

@kpollich kpollich left a 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.

Copy link
Contributor

@andrew-goldstein andrew-goldstein left a 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 xcrzx self-requested a review May 8, 2025 09:54
Copy link
Contributor

@xcrzx xcrzx left a 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.

Comment on lines 17 to 29
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,
});
Copy link
Contributor

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:

Suggested change
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.

@stephmilovic
Copy link
Contributor Author

@elasticmachine merge upstream

@elasticmachine
Copy link
Contributor

⏳ Build in-progress, with failures

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #109 / Cloud Security Posture Cloud Posture Rules Page - Table Headers Rules Page - Enable Rules and Disabled Rules Filter Toggle Should only display Enabled rules when Enabled Rules filter is ON
  • [job] [logs] FTR Configs #109 / Cloud Security Posture Security Network Page - Graph visualization "before all" hook for "expanded flyout - filter by node"

History

@stephmilovic
Copy link
Contributor Author

@elasticmachine merge upstream

@stephmilovic stephmilovic merged commit 1176009 into elastic:main May 9, 2025
9 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.19

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

@kibanamachine
Copy link
Contributor

💔 All backports failed

Status Branch Result
8.19 Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

node scripts/backport --pr 216106

Questions ?

Please refer to the Backport tool documentation

stephmilovic added a commit to stephmilovic/kibana that referenced this pull request May 9, 2025
(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
@stephmilovic
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
8.19

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

Questions ?

Please refer to the Backport tool documentation

stephmilovic added a commit that referenced this pull request May 11, 2025
…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]>
akowalska622 pushed a commit to akowalska622/kibana that referenced this pull request May 29, 2025
qn895 pushed a commit to qn895/kibana that referenced this pull request Jun 3, 2025
@muskangulati-qasource muskangulati-qasource added ci:cloud-deploy Create or update a Cloud deployment ci:cloud-persist-deployment Persist cloud deployment indefinitely labels Jun 11, 2025
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:cloud-deploy Create or update a Cloud deployment ci:cloud-persist-deployment Persist cloud deployment indefinitely release_note:enhancement Team:Fleet Team label for Observability Data Collection Fleet team Team:Security Generative AI Security Generative AI Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. v8.19.0 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants