Skip to content

[AI4DSOC] Move AI4DSOC components from kbn-elastic-assistant to security_solution#219288

Merged
stephmilovic merged 6 commits intoelastic:mainfrom
stephmilovic:move_ai4dsoc_to_ss
Apr 29, 2025
Merged

[AI4DSOC] Move AI4DSOC components from kbn-elastic-assistant to security_solution#219288
stephmilovic merged 6 commits intoelastic:mainfrom
stephmilovic:move_ai4dsoc_to_ss

Conversation

@stephmilovic
Copy link
Contributor

Summary

I made a bad call and put the AI4DSOC alert flyout components in kbn-elastic-assistant. This PR corrects that mistake and moves the files to security_solution.

Waiting to merge until Tuesday to avoid being included in the demo build

@stephmilovic stephmilovic added release_note:skip Skip the PR/issue when compiling release notes backport:skip This PR does not require backporting Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:Security Generative AI Security Generative AI v9.1.0 labels Apr 25, 2025
@stephmilovic stephmilovic requested review from a team as code owners April 25, 2025 17:03
@elasticmachine
Copy link
Contributor

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

@kqualters-elastic
Copy link
Contributor

The root of the problem is that the AssistantContext is completely coupled to the security solution plugin, even though it existing in a package makes that seem like it's not the case. Should either be it's own plugin with a set of dependencies, or used only within security solution. This tight coupling has led to numerous issues I've heard of anecdotally, and one that got me, preventing some changes I was trying to make to security solution routes to help performance in #212808 . Hiding dependencies in a context (as also cases and some other plugins also do) is not a pattern we should use long term, leads to tons of issues like this, duplicated code, performance problems, etc.

@stephmilovic
Copy link
Contributor Author

The root of the problem is that the AssistantContext is completely coupled to the security solution plugin

@kqualters-elastic yeah I get that but does something in this PR specifically bother you? Not sure this is the place for this discussion...?

@stephmilovic
Copy link
Contributor Author

@elasticmachine merge upstream

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
automaticImport 800 783 -17
securitySolution 7342 7337 -5
total -22

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/elastic-assistant 152 166 +14

Async chunks

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

id before after diff
securitySolution 9.1MB 9.1MB -2.3KB

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
@kbn/elastic-assistant 11 13 +2

Page load bundle

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

id before after diff
securitySolution 91.0KB 91.0KB +4.0B
Unknown metric groups

API count

id before after diff
@kbn/elastic-assistant 188 198 +10

ESLint disabled line counts

id before after diff
@kbn/elastic-assistant 14 13 -1
securitySolution 586 587 +1
total -0

Total ESLint disabled count

id before after diff
@kbn/elastic-assistant 15 14 -1
securitySolution 673 674 +1
total -0

History

import { useKibanaFeatureFlags } from '../use_kibana_feature_flags';

interface Props {
alertIds?: string[];
Copy link
Contributor

Choose a reason for hiding this comment

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

This PR is not tagged as being backported to 8.19, but consider backporting this change to simplify future backports and testing, (avoiding diverging implementations).

}

const DEFAULT_PAGE = 1; // CAUTION: sever-side API uses a 1-based page index convention (for consistency with similar existing APIs)
const DEFAULT_PAGE = 1; // CAUTION: server-side API uses a 1-based page index convention (for consistency with similar existing APIs)
Copy link
Contributor

Choose a reason for hiding this comment

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

This PR is not tagged as being backported to 8.19, but consider backporting this change to simplify future backports and testing, (avoiding diverging implementations).

const DEFAULT_PER_PAGE = 10;

export const useFindAttackDiscoveries = ({
alertIds,
Copy link
Contributor

Choose a reason for hiding this comment

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

This PR is not tagged as being backported to 8.19, but consider backporting this change to simplify future backports and testing, (avoiding diverging implementations).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, backporting this would lead to a cascade of backports including the following and likely more. I think we may be past that point... @PhilippeOberti what are your thoughts here?

#218018
#219004
#214889
#215246
#216744
#217421
#217696
#217744

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should backport this... Like @stephmilovic said above, we'd have to backport a bunch of PRs (24 to be exact) and I don't think it's a good idea...

Copy link
Contributor

Choose a reason for hiding this comment

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

If we truly believe we should, I'll get started on backporting the PRs. Thankfully I kept most of them very targeted and with low impact on the rest of the code, but some of them will be more involved...

Copy link
Contributor

Choose a reason for hiding this comment

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

The thing to keep in mind is many other PRs from other teams (outside of the 24 I linked above which are just for the alert summary work) have not been backported as well. So we'd have to sync with the rest of the group to make sure that we backport everything? Or you'd have a bunch of code in 8.19 that is untestable and it would make no sense... while also adding risk to break something in the process...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Synced with Andrew over zoom. He just wants me to bring the changes to this specific file over to 8.19, since it exists there, in order to bring it up to speed with main. This is going to be a manual PR, not using the backport tool, so limited to the changes to this file. He wasn't suggesting we backport the whole PR, just the file changes. Sorry for the confusion @PhilippeOberti

Copy link
Contributor

Choose a reason for hiding this comment

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

Haaaaaa that makes sense, all good then!! 😆

method: 'GET',
version: API_VERSIONS.internal.v1,
query: {
alert_ids: alertIds,
Copy link
Contributor

Choose a reason for hiding this comment

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

This PR is not tagged as being backported to 8.19, but consider backporting this change to simplify future backports and testing, (avoiding diverging implementations).

signal: abortController.current.signal,
}),
[
alertIds,
Copy link
Contributor

Choose a reason for hiding this comment

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

This PR is not tagged as being backported to 8.19, but consider backporting this change to simplify future backports and testing, (avoiding diverging implementations).

[
'GET',
ATTACK_DISCOVERY_FIND,
alertIds,
Copy link
Contributor

Choose a reason for hiding this comment

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

This PR is not tagged as being backported to 8.19, but consider backporting this change to simplify future backports and testing, (avoiding diverging implementations).

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.

Thanks @stephmilovic!
✅ Desk tested locally
LGTM

@stephmilovic stephmilovic merged commit 89fc5f9 into elastic:main Apr 29, 2025
9 checks passed
akowalska622 pushed a commit to akowalska622/kibana that referenced this pull request Apr 30, 2025
akowalska622 pushed a commit to akowalska622/kibana that referenced this pull request May 29, 2025
stephmilovic added a commit to PhilippeOberti/kibana that referenced this pull request Jun 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:Security Generative AI Security Generative AI Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants