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

[Security Solution] [Sourcerer] KIP Feature Branch Kickoff, remove config index patterns #106460

Closed
wants to merge 28 commits into from

Conversation

stephmilovic
Copy link
Contributor

@stephmilovic stephmilovic commented Jul 21, 2021

Summary

This is the first stage of the update to Sourcerer to user only Kibana Index Patterns. This update will enable Kibana runtime fields in Security Solution app

This is the feature branch for this update. I am opening a PR against master. Once approved, I will close the PR without merging and open all new feature PRs against this branch. Once the feature is done, we can reopen this PR against master again and merge with minimal testing.

  • Removes config index patterns from sourcerer and only use Kibana index patterns in its existing functionality
  • POST a special security-solution KIP from the config index patterns
  • security-solution KIP becomes the default selection in our app (formerly config index patterns)

Tester: please check the tasks on the issue to ensure your functionality expectations are correct for this stage of development

Checklist

Delete any items that are not applicable to this PR.

@stephmilovic stephmilovic added release_note:enhancement v8.0.0 Team:Threat Hunting Security Solution Threat Hunting Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. v7.15.0 labels Jul 21, 2021
@stephmilovic stephmilovic requested a review from a team as a code owner July 21, 2021 19:09
@elasticmachine
Copy link
Contributor

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

@elasticmachine
Copy link
Contributor

Pinging @elastic/security-threat-hunting (Team:Threat Hunting)

try {
indexPattern = await indexPatternsService.get(DEFAULT_INDEX_PATTERN_ID);
} catch (e) {
indexPattern = await indexPatternsService.createAndSave({
Copy link
Member

Choose a reason for hiding this comment

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

It looks like you are trying to create the index pattern if it doesn't already exist? There are a lot of reasons why indexPatternsService.get() may fail -- @elastic/kibana-app-services what is the best way to test for a 404/not found response 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.

got it taken care of in my follow up PR, will tag you on that code when its up ;P

): Promise<IndexPattern> => {
let indexPattern: IndexPattern;
try {
indexPattern = await indexPatternsService.get(DEFAULT_INDEX_PATTERN_ID);
Copy link
Member

Choose a reason for hiding this comment

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

What happens if a user has an existing index pattern with this id, but mapped to something you don't expect?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that wouldbe a big coincidence. its our reserved id, vs creating an index pattern via Kibana will result in a random id. you'd have to hit the API manually with this specific ID. maybe 0.000001% of users would do that

Copy link
Member

Choose a reason for hiding this comment

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

The index pattern UI allows index patterns to be created with a custom, user-supplied identifier. I agree the chance of this happening is small, but it's probably greater than 0.000001%. This isn't a blocker IMO, but I wanted to call this out as a possibility

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 added this as a task on the issue, will make sure to address before merging in master: https://github.com/elastic/security-team/issues/772

Copy link
Contributor Author

Choose a reason for hiding this comment

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

got it taken care of in my follow up PR, will tag you on that code when its up ;P

x-pack/plugins/security_solution/server/plugin.ts Outdated Show resolved Hide resolved
});

describe('Default scope', () => {
describe.skip('Default scope', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

these were already skipped if thats confusing

@stephmilovic
Copy link
Contributor Author

@elasticmachine merge upstream

@stephmilovic
Copy link
Contributor Author

Screen Shot 2021-08-05 at 8 23 18 AM

i dare this test to fail again

@stephmilovic stephmilovic requested a review from a team August 9, 2021 13:21
@stephmilovic
Copy link
Contributor Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💛 Build succeeded, but was flaky


Test Failures

Kibana Pipeline / general / adds correctly a filter to the global search bar.SearchBar adds correctly a filter to the global search bar

Link to Jenkins

Stack Trace

Failed Tests Reporter:
  - Test has failed 19 times on tracked branches: https://github.com/elastic/kibana/issues/69595

AssertionError: Timed out retrying after 60000ms: Expected to find element: `[data-test-subj="comboBoxOptionsList filterFieldSuggestionList-optionsList"] button[title="host.ip"] mark`, but never found it.
    at Object.fillAddFilterForm (http://localhost:61121/__cypress/tests?p=cypress/integration/header/search_bar.spec.ts:16419:8)
    at Context.eval (http://localhost:61121/__cypress/tests?p=cypress/integration/header/search_bar.spec.ts:15554:22)

Metrics [docs]

Async chunks

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

id before after diff
securitySolution 6.5MB 6.5MB +1.7KB

Page load bundle

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

id before after diff
securitySolution 211.9KB 212.2KB +304.0B

History

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

@@ -22,6 +22,8 @@ export const DEFAULT_DATE_FORMAT_TZ = 'dateFormat:tz';
export const DEFAULT_DARK_MODE = 'theme:darkMode';
export const DEFAULT_INDEX_KEY = 'securitySolution:defaultIndex';
export const DEFAULT_NUMBER_FORMAT = 'format:number:defaultPattern';
export const DEFAULT_INDEX_PATTERN_ID = 'security-solution';
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious, is there some standard pattern for these across Kibana? I.e. camel-case, snake-case, etc.. ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, the id is generated and looks like a855f700-f5f9-11eb-8763-01917c58cbf9 so i followed that. i think - is standard for URL which is where these are stored

.should('oneOf', [204, 404]);
}
// needed to generate index pattern
const visitSecuritySolution = () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Worth moving into a util? If you end up moving it to a util, should probably rename it to something like loadSecuritySolutionIndexPatterns

// Skipped at the moment as this has flake due to click handler issues. This has been raised with team members
// and the code is being re-worked and then these tests will be unskipped
describe.skip('Sourcerer', () => {
before(() => {
describe('Sourcerer', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for cleaning this up!

kibanaIndexPatterns: [
state.sourcerer.defaultIndexPattern,
{ id: '1234', title: 'auditbeat-*' },
{ id: '1234', title: 'packetbeat-*' },
Copy link
Contributor

@michaelolo24 michaelolo24 Aug 10, 2021

Choose a reason for hiding this comment

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

Does this get ignored in the selectedPatterns list because auditbeat-* has the same id? Just seeing if that's something you're testing here too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm that should never happen IRL since you cant have the same id in the system, so its not something i wrote for

const { id, ...rest } = defaultIndexPattern;
if (id === null) {
// if id is null, rest is error
addError(rest, {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it might be worth it to set an explicit error param rather than relying on rest here to keep separation of concerns?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

im going to iterate on this in follow up PRs but will keep this comment open for a reminder

@@ -27,18 +29,18 @@ const ids: Array<Args['id']> = [
];
describe('createDefaultIndexPatterns', () => {
ids.forEach((id) => {
eventTypes.forEach((et) => {
describe(`id: ${id}, eventType: ${et}`, () => {
eventTypes.forEach((eventType) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

thank you

].reduce<Array<EuiComboBoxOptionOption<string>>>((acc, index) => {
[...kibanaIndexPatterns.map((kip) => kip.title), signalIndexName].reduce<
Array<EuiComboBoxOptionOption<string>>
>((acc, index) => {
if (index != null && !acc.some((o) => o.label.includes(index))) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I know you didn't write this, but isn't it always label === index?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

its saying acc shouldn't already have a label that is equal to that index. makes sense to me but we can run it together if you'd like and poke at it 😄

Copy link
Contributor

@michaelolo24 michaelolo24 left a comment

Choose a reason for hiding this comment

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

PR looks good! Pulled it down, tested that the index switching is working as expected. Most of my comments were just questions and nits. Only thing left is just making any changes for @legrego's comment here: https://github.com/elastic/kibana/pull/106460/files#r677392130

@stephmilovic
Copy link
Contributor Author

Fantastic! With approval, I'm now going to close this PR and use it as my Feature Branch to open PRs against. I will reopen the PR once it is ready to merge!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:enhancement Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:Threat Hunting Security Solution Threat Hunting Team v7.15.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants