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] [Timeline] Bugfix to include unmapped fields in the timeline event details JSON #92025

Merged
merged 26 commits into from
Mar 2, 2021

Conversation

stephmilovic
Copy link
Contributor

@stephmilovic stephmilovic commented Feb 19, 2021

Summary

Resolves the following issues in timeline related to the ES Fields API change:

#91424
#90355
#90222
#91426
#90808

Does NOT resolve: #89784 Dragging a nested field to timeline does not generate the correct query

  • To be fixed in a follow up PR.
  • At least adding it with the + button works, just dragging creates bad query
  • + Filter also needs display to be fixed, but is querying correctly
Click here to see the nested filter issue

Screen Shot 2021-02-26 at 12 25 31 PM Screen Shot 2021-02-26 at 12 39 15 PM

all
det

Updates the timeline event details query dsl to include fields: ['*'] and _source: true in order to ensure we are getting all fields, even unmapped. Array values will be stringified
Screen Shot 2021-02-19 at 10 02 05 AM

Also alphabetizes the JSON view to make it nice and easy to read for Prince @spong 👑
Screen Shot 2021-02-19 at 9 55 24 AM

I also fixed a bug I noticed that made stringified object arrays into draggables, yikes:
Screen Shot 2021-02-19 at 12 07 43 PM

I changed this to render as an undraggable string:
Screen Shot 2021-02-19 at 12 06 38 PM

FWIW, the actual values were already being parsed correctly into draggable below:
Screen Shot 2021-02-19 at 12 08 15 PM

To test:

post the below data to your siem-signals-default index. on the detections table page, search for signal.rule.name": "GRRRRRowl", Ensure the threat.indicator and source.geo.location appear appropriately as draggables and strings where the full object is listed.

POST .siem-signals-default/_doc
{
  "@timestamp": "2021-02-26T00:41:06.527Z",
  "signal.status": "open",
  "signal.rule.name": "GRRRRRowl",
  "threat.indicator": [
    {
      "provider": "yourself",
      "type": "custom",
      "first_seen": [
        "2021-02-22T17:29:25.195Z"
      ],
      "matched": {
        "atomic": "matched_atomic",
        "field": "matched_field"
      }
    },
    {
      "provider": "other_you",
      "type": "custom",
      "first_seen": "2021-02-22T17:29:25.195Z",
      "matched": {
        "atomic": "matched_atomic_2",
        "field": "matched_field_2"
      }
    }
  ],
  "source": {
    "geo": {
      "location": [
        {
          "lat": 39.5884,
          "lon": -105.0776
        }
      ]
    }
  }
}

@stephmilovic stephmilovic added bug Fixes for quality problems that affect the customer experience v8.0.0 release_note:skip Skip the PR/issue when compiling release notes v7.12.0 Team:Threat Hunting Security Solution Threat Hunting Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Feature:Timeline Security Solution Timeline feature v7.13.0 labels Feb 19, 2021
field: 'agent.id',
originalValue: '5de03d5f-52f3-482e-91d4-853c7de073c3',
values: ['5de03d5f-52f3-482e-91d4-853c7de073c3'],
field: 'cloud.project.id',
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 "de-alphabetized" this mock data to ensure that our function puts it in alphabetical order

@stephmilovic stephmilovic marked this pull request as ready for review February 19, 2021 19:26
@stephmilovic stephmilovic requested a review from a team as a code owner February 19, 2021 19:26
@elasticmachine
Copy link
Contributor

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

@elasticmachine
Copy link
Contributor

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

@@ -42,6 +42,18 @@ describe('#getDataFromFieldsHits', () => {
'process.executable': [
'/var/lib/jenkins/workspace/Beats_beats_PR-22624/.gvm/versions/go1.14.7.linux.amd64/bin/go',
],
'threat.indicator': [
Copy link
Contributor Author

Choose a reason for hiding this comment

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

adding this data (result on 227) tests toObjectArrayOfStrings

@stephmilovic stephmilovic requested a review from a team February 22, 2021 16:29
<FormattedFieldValue
key={`plain-column-renderer-formatted-field-value-${timelineId}-${columnName}-${eventId}-${field.id}-${value}`}
key={`plain-column-renderer-formatted-field-value-${timelineId}-${columnName}-${eventId}-${field.id}-${value}-${i}`}
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, were the ${eventId}-${field.id}-${value} not unique? I ask because we ran into an issue on the resolver when we introduced indices into keys because reacts resolution on re-renders would be jumbled if the data changed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it would throw the error on the nested field
Screen Shot 2021-02-19 at 12 08 15 PM

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 wonder if this was before or after i filtered for unique values though, ill take a second look

},
[]
);
edges = await parseSequences(response.rawResponse.body.hits.sequences, options.fieldRequested);
Copy link
Contributor

Choose a reason for hiding this comment

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

👍🏾 nice cleanup

@@ -290,7 +267,7 @@ describe('#formatTimelineData', () => {
};

expect(
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 the await goes outside the expect? https://jestjs.io/docs/en/tutorial-async#asyncawait

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 think thats for with .resolves

In the first example:

it('works with async/await', async () => {
  expect.assertions(1);
  const data = await user.getUserName(4);
  expect(data).toEqual('Mark');
});

so mine is like this, but instead of using a variable data i put the await function call directly in the () because it will run what is inside the () before evaluating the expect

Copy link
Contributor

@rylnd rylnd left a comment

Choose a reason for hiding this comment

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

Not going to Approve because I reviewed behavior and not code here, but things look great on my end! Filtering works as documented in the description

Display of multiple nested documents:
Detections_-_Kibana

Detections_-_Kibana

@rylnd
Copy link
Contributor

rylnd commented Mar 1, 2021

@stephmilovic one other thing I noticed: sorting on those nested fields causes the query to fail:
Detections_-_Kibana

I don't think that should block this effort, but I wanted to make sure we're aware of it moving forward. The semantics of sorting on a nested field are unclear in the existing UI; would it be possible to disable sorting on those fields for now?

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.

Tested and it looks good! I was able to load the sample data and saw the nested objects properly formatted. Only had a few code comments, but nothing breaking. Feel free to address in a separate PR. Thanks for doing this!

Copy link
Contributor

@kqualters-elastic kqualters-elastic left a comment

Choose a reason for hiding this comment

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

pulled and tested locally, does fix the issues. might make sense to add tests for isObjectArray otherwise lgtm pending @michaelolo24 's comment about await

@stephmilovic
Copy link
Contributor Author

@stephmilovic one other thing I noticed: sorting on those nested fields causes the query to fail:
Detections_-_Kibana

I don't think that should block this effort, but I wanted to make sure we're aware of it moving forward. The semantics of sorting on a nested field are unclear in the existing UI; would it be possible to disable sorting on those fields for now?

good catch should be able to disable sorting

@@ -86,6 +86,7 @@ export const HeaderComponent: React.FC<Props> = ({
getManageTimelineById,
timelineId,
]);
const showSortingCapability = !isEqlOn && !(header.subType && header.subType.nested);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

disable sorting on nested fields, not working.

The JSON fields are now sorted, which unfortunately caused this test to
fail.
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

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 7.8MB 7.8MB +1014.0B
triggersActionsUi 1.6MB 1.5MB -23.9KB
total -22.9KB

Page load bundle

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

id before after diff
triggersActionsUi 104.0KB 104.1KB +82.0B
Unknown metric groups

async chunk count

id before after diff
triggersActionsUi 41 42 +1

History

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

@stephmilovic stephmilovic merged commit 90976ee into elastic:master Mar 2, 2021
@stephmilovic stephmilovic deleted the fix-timeline-event-details branch March 2, 2021 03:40
gmmorris added a commit to gmmorris/kibana that referenced this pull request Mar 2, 2021
* master: (42 commits)
  [Lens] Introduces new chart switcher (elastic#91844)
  [Lens] fix selection when dragging (elastic#93034)
  Converts usage collection README to .mdx (elastic#92982)
  Fix expanding document when using saved search data grid (elastic#92999)
  [SECURITY SOLUTIONS] Bug case connector (elastic#93104)
  [Security Solution] [Timeline] Bugfix to include unmapped fields in the timeline event details JSON (elastic#92025)
  [Alerting][Docs] Changed alerting documentation to point to a single source of explaining the configurations. (elastic#92942)
  [APM] Fix hidden search bar in error pages while loading (elastic#84476) (elastic#93139)
  [DOCS] Fixes links for machine learning alerts (elastic#92744)
  [Security Solution][Detections] -Fixes rule edit flow bug with max_signals (elastic#92748)
  [SecuritySolution][Case] Disable cases on detections in read-only mode (elastic#93010)
  [Security Solution][Case][Bug] Prevent closing collection when pushing (elastic#93095)
  [Security Solution][Detections][7.12] Critical Threshold Rule Fixes (elastic#92667)
  Bump ems landing page to 7.12 (elastic#93065)
  [App Search] Implement various Relevance Tuning states and form actions (elastic#92644)
  [actions] for simplistic email servers, set rejectUnauthorized to false (elastic#91760)
  [Security Solution][Case] Migrate category & subcategory fields of ServiceNow ITSM connector (elastic#93092)
  Hide instances latency distribution chart (elastic#92869)
  [Maps] fix MapboxDraw import from pointing to dist just pointing to folder (elastic#93087)
  [Maps] fix results trimmed tooltip message doubles feature count for line and polygon features (elastic#92932)
  ...
v1v added a commit to shahzad31/kibana that referenced this pull request Mar 2, 2021
… playwright-ftr-e2e

* 'playwright-ftr-e2e' of github.com:shahzad31/kibana: (38 commits)
  [chore] Enable core's eslint rule: `@ts-expect-error` (elastic#93086)
  [Lens] Introduces new chart switcher (elastic#91844)
  [Lens] fix selection when dragging (elastic#93034)
  Converts usage collection README to .mdx (elastic#92982)
  Fix expanding document when using saved search data grid (elastic#92999)
  [SECURITY SOLUTIONS] Bug case connector (elastic#93104)
  [Security Solution] [Timeline] Bugfix to include unmapped fields in the timeline event details JSON (elastic#92025)
  [Alerting][Docs] Changed alerting documentation to point to a single source of explaining the configurations. (elastic#92942)
  [APM] Fix hidden search bar in error pages while loading (elastic#84476) (elastic#93139)
  [DOCS] Fixes links for machine learning alerts (elastic#92744)
  [Security Solution][Detections] -Fixes rule edit flow bug with max_signals (elastic#92748)
  [SecuritySolution][Case] Disable cases on detections in read-only mode (elastic#93010)
  [Security Solution][Case][Bug] Prevent closing collection when pushing (elastic#93095)
  [Security Solution][Detections][7.12] Critical Threshold Rule Fixes (elastic#92667)
  Bump ems landing page to 7.12 (elastic#93065)
  [App Search] Implement various Relevance Tuning states and form actions (elastic#92644)
  [actions] for simplistic email servers, set rejectUnauthorized to false (elastic#91760)
  [Security Solution][Case] Migrate category & subcategory fields of ServiceNow ITSM connector (elastic#93092)
  Hide instances latency distribution chart (elastic#92869)
  [Maps] fix MapboxDraw import from pointing to dist just pointing to folder (elastic#93087)
  ...
stephmilovic added a commit that referenced this pull request Mar 2, 2021
…ds in the timeline event details JSON (#92025) (#93173)

* fix merge

* fix lint

* rm var

* rm var

* fixs

* fix func test

* fix func test

* rm eql files
stephmilovic added a commit that referenced this pull request Mar 2, 2021
…ds in the timeline event details JSON (#92025) (#93172)

* fix merge

* fix lint

* fix func test

* fix func test
stephmilovic added a commit that referenced this pull request Mar 2, 2021
…s in the timeline event details JSON (#92025) (#93171)

* fix merge

* fix lint

* fix func test
jloleysens added a commit that referenced this pull request Mar 3, 2021
… ilm/rollup-v2-action

* 'ilm/rollup-v2-action' of github.com:elastic/kibana: (30 commits)
  Fix expanding document when using saved search data grid (#92999)
  [SECURITY SOLUTIONS] Bug case connector (#93104)
  [Security Solution] [Timeline] Bugfix to include unmapped fields in the timeline event details JSON (#92025)
  [Alerting][Docs] Changed alerting documentation to point to a single source of explaining the configurations. (#92942)
  [APM] Fix hidden search bar in error pages while loading (#84476) (#93139)
  [DOCS] Fixes links for machine learning alerts (#92744)
  [Security Solution][Detections] -Fixes rule edit flow bug with max_signals (#92748)
  [SecuritySolution][Case] Disable cases on detections in read-only mode (#93010)
  [Security Solution][Case][Bug] Prevent closing collection when pushing (#93095)
  [Security Solution][Detections][7.12] Critical Threshold Rule Fixes (#92667)
  Bump ems landing page to 7.12 (#93065)
  [App Search] Implement various Relevance Tuning states and form actions (#92644)
  [actions] for simplistic email servers, set rejectUnauthorized to false (#91760)
  [Security Solution][Case] Migrate category & subcategory fields of ServiceNow ITSM connector (#93092)
  Hide instances latency distribution chart (#92869)
  [Maps] fix MapboxDraw import from pointing to dist just pointing to folder (#93087)
  [Maps] fix results trimmed tooltip message doubles feature count for line and polygon features (#92932)
  [Security Solution][Detecttions] Indicator enrichment tweaks (#92989)
  [Maps] fix fit to data on heatmap not working (#92697)
  [Security Solution][Endpoint][Admin] Fixes policy sticky footer save test (#92919)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience Feature:Timeline Security Solution Timeline feature release_note:skip Skip the PR/issue when compiling release notes Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:Threat Hunting Security Solution Threat Hunting Team v7.11.2 v7.12.0 v7.13.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Security Solution][Timeline] Dragging a nested field to timeline does not generate the correct query
6 participants