-
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
[Security Solution] [Sourcerer] KIP Feature Branch Kickoff, remove config index patterns #106460
Conversation
Pinging @elastic/security-solution (Team: SecuritySolution) |
Pinging @elastic/security-threat-hunting (Team:Threat Hunting) |
try { | ||
indexPattern = await indexPatternsService.get(DEFAULT_INDEX_PATTERN_ID); | ||
} catch (e) { | ||
indexPattern = await indexPatternsService.createAndSave({ |
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 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?
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.
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); |
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.
What happens if a user has an existing index pattern with this id, but mapped to something you don't expect?
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.
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
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 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
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 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
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.
got it taken care of in my follow up PR, will tag you on that code when its up ;P
}); | ||
|
||
describe('Default scope', () => { | ||
describe.skip('Default scope', () => { |
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.
these were already skipped if thats confusing
@elasticmachine merge upstream |
@elasticmachine merge upstream |
💛 Build succeeded, but was flaky
Test FailuresKibana Pipeline / general / adds correctly a filter to the global search bar.SearchBar adds correctly a filter to the global search barStack Trace
Metrics [docs]Async chunks
Page load bundle
History
To update your PR or re-run it, just comment with: |
@@ -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'; |
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.
Just curious, is there some standard pattern for these across Kibana? I.e. camel-case, snake-case, etc.. ?
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.
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 = () => { |
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.
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', () => { |
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 cleaning this up!
kibanaIndexPatterns: [ | ||
state.sourcerer.defaultIndexPattern, | ||
{ id: '1234', title: 'auditbeat-*' }, | ||
{ id: '1234', title: 'packetbeat-*' }, |
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.
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
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.
hmm that should never happen IRL since you cant have the same id in the system, so its not something i wrote for
x-pack/plugins/security_solution/public/common/containers/sourcerer/index.tsx
Show resolved
Hide resolved
const { id, ...rest } = defaultIndexPattern; | ||
if (id === null) { | ||
// if id is null, rest is error | ||
addError(rest, { |
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 think it might be worth it to set an explicit error
param rather than relying on rest here to keep separation of concerns?
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.
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) => { |
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
x-pack/plugins/security_solution/public/common/store/sourcerer/helpers.ts
Show resolved
Hide resolved
].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))) { |
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 know you didn't write this, but isn't it always label === index
?
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.
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 😄
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.
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
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! |
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.
security-solution
KIP from the config index patternssecurity-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.