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

[SIEM][Exceptions] - ExceptionsViewer cleanup #68739

Merged
merged 39 commits into from
Jun 10, 2020

Conversation

yctercero
Copy link
Contributor

@yctercero yctercero commented Jun 10, 2020

Summary

  • Adds missing unit tests for relevant files missing them
  • Changes filter search to fire request on 'Enter'
  • Breaks out the main ExceptionViewer component into smaller components to make more readable and better tested
  • Updates utility bar to have the specific list description text next to it as proposed by @spong in [SIEM][Exceptions] - ExceptionsViewer UI component part 2 #68294 (comment)
  • Adds loading state any time async request occurs
  • Now fetches list on list type toggle (if user selects to view either only detections or endpoint items), before was simply filtering already fetched items

To do

  • integration tests
  • exceptions get a bit funky on small screen sizes
  • modify areas using moment to use the FormattedDate instead

Screenshots & Gifs

Empty state

Screen Shot 2020-06-10 at 1 11 42 PM

Only one type of list allowed

List toggles hidden, no popover for add exception.
Screen Shot 2020-06-10 at 1 10 59 PM

Exceptions search

exceptions_search

Exceptions list toggle

exceptions_toggle

Delete exception

exceptions_delete

Testing

To turn on lists plugin - in kibana.dev.yml

# Enable lists feature
xpack.lists.enabled: true
xpack.lists.listIndex: '.lists-yara'
xpack.lists.listItemIndex: '.items-yara'

Use the scripts in x-pack/plugins/lists/server/scripts to create some sample exception lists and items. You can use the following:

  • Create detection type list ./post_exception_list.sh ./exception_lists/new/exception_list_detection.json
  • Create detection type list items ./post_exception_list_item.sh ./exception_lists/new/exception_list_item_detection_auto_id.json - this script auto generates the item_id so you can run it as many times as you like to create multiple items associated with the list generated in step 1
  • Create endpoint list ./post_exception_list.sh
  • Create endpoint type list items ./post_exception_list_item.sh ./exception_lists/new/exception_list_item_auto_id.json - this script auto generates the item_id so you can run it as many times as you like to create multiple items associated with the list generated in step 3
  • Run ./find_exception_lists.sh to get the id of the two lists you created
  • Update the ExceptionsViewer component in x-pack/plugins/security_solution/public/alerts/pages/detection_engine/rules/details/index.tsx to something like the following:
 <ExceptionsViewer
       commentsAccordionId={'someId'}
       exceptionLists={[
         {
            id: [DETECTION_LIST_ID],  // `id` not `list_id`
            type: 'detection',
            namespaceType: 'single',
         },
         {
            id: [ENDPOINT_LIST_ID],  // `id` not `list_id`
             type: 'endpoint',
             namespaceType: 'single',
           },
         ]}  />

Navigate to the rules details page and click on the 'Exceptions' tab. Voila!

To check storybook elements, run yarn storybook security_solution from ./kibana/.

Checklist

Delete any items that are not applicable to this PR.

… due to be refactored but dont want to make this PR bigger
@yctercero yctercero self-assigned this Jun 10, 2020
@yctercero yctercero marked this pull request as ready for review June 10, 2020 17:50
@yctercero yctercero requested review from a team as code owners June 10, 2020 17:50
@elasticmachine
Copy link
Contributor

Pinging @elastic/siem (Team:SIEM)

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

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

expect(wrapper.find('[data-test-subj="exceptionsEndpointMessage"]').exists()).toBeTruthy();
expect(wrapper.find('[data-test-subj="exceptionsDetectionsMessage"]').exists()).toBeFalsy();
});
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Lots of nice tests 👍

@@ -78,26 +82,34 @@ export const allExceptionItemsReducer = () => (state: State, action: Action): St
};

if (action.filterOptions.showEndpointList) {
const exceptions = state.allExceptions.filter((t) => t._tags.includes('endpoint'));
const list = action.allLists.filter((t) => t.type === 'endpoint');
Copy link
Contributor

Choose a reason for hiding this comment

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

tip: People usually use destructoring when they don't care about a variable name like so:

.filter(({ type }) => type === 'endpoint');

No changes needed, just a tip.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, nice. I have an upcoming PR, will link to it with changes for this. Thanks!

Copy link
Contributor

@FrankHassanabad FrankHassanabad left a comment

Choose a reason for hiding this comment

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

Looked it over, looks really clean easy to read. So LGTM for ya!

@yctercero yctercero merged commit 49a45ec into elastic:master Jun 10, 2020
yctercero added a commit to yctercero/kibana that referenced this pull request Jun 10, 2020
### Summary

- Adds missing unit tests for relevant files missing them
- Changes filter search to fire request on 'Enter'
- Breaks out the main ExceptionViewer component into smaller components to make more readable and better tested
- Updates utility bar to have the specific list description text next to it as proposed by @spong in elastic#68294 (comment)
- Adds loading state any time async request occurs
- Now fetches list on list type toggle (if user selects to view either only detections or endpoint items), before was simply filtering already fetched items
yctercero added a commit that referenced this pull request Jun 10, 2020
### Summary

- Adds missing unit tests for relevant files missing them
- Changes filter search to fire request on 'Enter'
- Breaks out the main ExceptionViewer component into smaller components to make more readable and better tested
- Updates utility bar to have the specific list description text next to it as proposed by @spong in #68294 (comment)
- Adds loading state any time async request occurs
- Now fetches list on list type toggle (if user selects to view either only detections or endpoint items), before was simply filtering already fetched items
gmmorris added a commit to gmmorris/kibana that referenced this pull request Jun 11, 2020
* master: (38 commits)
  Support migrating from reserved feature privileges (elastic#68504)
  add `preference` field to SavedObjectsFindOptions (elastic#68620)
  [ILM] Add "wait for snapshot" policy field to Delete phase (elastic#68505)
  Cleanup old license overwrites (elastic#68744)
  Bump TypeScript to v3.9 (elastic#67666)
  [APM] Service maps - adds new storybook stories to test out various data sets (elastic#68727)
  Fix vega specification parsing (elastic#67963)
  docs: add more api information (elastic#68717)
  [APM] Don't show annotations on charts with no data (elastic#68829)
  [Metrics UI] Fix Inventory View sorting by handling null values (elastic#67889)
  skip flaky suite (elastic#68836)
  [SIEM][Detections Engine] - Fix reference rule url overflow (elastic#68640)
  Index pattern public api => common (elastic#68289)
  [APM] Lazy-load alert triggers (elastic#68806)
  [DOCS] Fix table formatting in ingest manager settings (elastic#68824)
  [Endpoint] Functional Tests cleanup (elastic#68756)
  revert previous commit which was unintentional
  Use Github token instead for project assignments
  [SIEM][Exceptions] - ExceptionsViewer cleanup (elastic#68739)
  move @kbn/storybook to devDeps (elastic#68791)
  ...
@yctercero yctercero deleted the exception-viewer-ux branch October 14, 2020 12:00
@MindyRS MindyRS added the Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. label Sep 23, 2021
@elasticmachine
Copy link
Contributor

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

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:SIEM v7.9.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants