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] Fix custom date time mapping bug #70713

Merged
merged 25 commits into from Jul 14, 2020
Merged

Conversation

cnasikas
Copy link
Member

@cnasikas cnasikas commented Jul 3, 2020

Summary

This PR addresses various date time bugs.

Changes:

  1. All time-related fields changed to ISO standard.
  2. The type of time-related fields changed from number to string.
  3. All URLs have ISO dates instead of Unix timestamps.
  4. Timeline's time range removed from filtersQuery.
  5. docValuesFields are being passed to Elasticsearch.
  6. If source or indexPatter is loading no timeline queries are being made.

Compatibility:

  1. Old URLs, with unix timestamps, are loaded correctly.
  2. Timeline's saved objects that contain dateRange as timestamps are loaded correctly.

Reference: #58965, #57649, https://discuss.elastic.co/t/siem-app-doesnt-use-timezone-setting/216906/12, https://github.com/elastic/sdh-siem/issues/26

Manual testing:

  1. Test with mapping:
PUT my-mapping
{
    "date_detection": true,
    "numeric_detection": false,
    "dynamic_date_formats": [
        "strict_date_optional_time",
        "yyyy/MM/dd HH:mm:ss Z||yyyy/MM/dd Z"
    ],
    "dynamic": "true",
    "properties": {
        "@timestamp": {
            "type": "date",
            "format": "strict_date_optional_time"
        }
    }
}

PUT my-mapping/_doc/1
{ "@timestamp": "2020-07-13T05:35:10.073Z" }
  1. Test with mapping:
PUT timestamp-without-tz-designator
{
  "mappings": {
    "properties": {
      "@timestamp": {
        "type": "date",
        "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
      }
    }
  }
}

PUT timestamp-without-tz-designator/_doc/1
{ "@timestamp": "2020-02-11 23:59:55" }
  1. Test if old URLs behave as expected.
  2. Navigate to all pages and see if an error is occurred (console and toaster).
  3. Change the date range to each page and see if the returned documents respect the date range.
  4. Test relative and absolute dates.
  5. Test global time and timeline time.

Out of scope:

  1. Fix a parsing bug. When you drag a timestamp to the timeline's query area and the value of that timestamp is a Unix timestamp but typeof value === 'string then the value is converted to NaN and you get a parsing error. Example: value = '1521848183232'

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@cnasikas cnasikas self-assigned this Jul 3, 2020
@cnasikas cnasikas changed the title [SIEM] Fix custom date time mapping bug [SIEM][skip-ci] Fix custom date time mapping bug Jul 3, 2020
@cnasikas cnasikas force-pushed the timestamp_fix branch 7 times, most recently from 1f191c1 to a91e33e Compare July 7, 2020 18:29
@cnasikas cnasikas changed the title [SIEM][skip-ci] Fix custom date time mapping bug [SIEM] Fix custom date time mapping bug Jul 8, 2020
@cnasikas cnasikas added bug Fixes for quality problems that affect the customer experience release_note:skip Skip the PR/issue when compiling release notes Team:SIEM v7.9.0 v8.0.0 labels Jul 8, 2020
@cnasikas cnasikas force-pushed the timestamp_fix branch 5 times, most recently from 5decd1d to 763ee02 Compare July 11, 2020 15:59
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.

Thanks for the comprehensive fix! 👍

Copy link
Member

@spong spong left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you soooo much @cnasikas and @XavierM -- our users are going to be so happy with these fixes! 🙂

@cnasikas
Copy link
Member Author

@elasticmachine merge upstream

@stephmilovic
Copy link
Contributor

ok idk that its because of this PR but i found this bug. ill check master now:
buggggg

@stephmilovic
Copy link
Contributor

ok same thing happens on master, not your PR. we'll make a new ticket for this bug

Copy link
Contributor

@stephmilovic stephmilovic left a comment

Choose a reason for hiding this comment

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

Manual review (woof) passes, just a few nits but do not block over them. Manual testing was all good besides the bug mentioned, but it's also on master so I'd say go ahead and merge this and we can fix the bug in a follow up. Great work, a lot of heavy lifting here. LGTM 🚀

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Build metrics

@kbn/optimizer bundle module count

id value diff baseline
securitySolution 763 +1 762

History

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

@cnasikas cnasikas merged commit 754ade5 into elastic:master Jul 14, 2020
@cnasikas cnasikas deleted the timestamp_fix branch July 14, 2020 21:26
cnasikas added a commit to cnasikas/kibana that referenced this pull request Jul 14, 2020
Co-authored-by: Xavier Mouligneau <xavier.mouligneau@elastic.co>
Co-authored-by: Xavier Mouligneau <189600+XavierM@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
# Conflicts:
#	x-pack/plugins/security_solution/public/timelines/components/open_timeline/helpers.test.ts
#	x-pack/plugins/security_solution/public/timelines/store/timeline/defaults.ts
XavierM pushed a commit that referenced this pull request Jul 14, 2020
Co-authored-by: Xavier Mouligneau <xavier.mouligneau@elastic.co>
Co-authored-by: Xavier Mouligneau <189600+XavierM@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
# Conflicts:
#	x-pack/plugins/security_solution/public/timelines/components/open_timeline/helpers.test.ts
#	x-pack/plugins/security_solution/public/timelines/store/timeline/defaults.ts
FrankHassanabad added a commit that referenced this pull request Aug 4, 2020
…te_optional_time (#74211)

## Summary

Related closed issues:
#58965
#70713

If you add a custom mapping and go to the hosts details page you will get an error toaster:
<img width="838" alt="Screen Shot 2020-08-03 at 7 53 16 PM" src="https://user-images.githubusercontent.com/1151048/89244409-a7df7500-d5c3-11ea-933c-99d96bffc589.png">

If running local host you can configure your index patterns to use a custom one I setup with custom date time formats and a single record which can cause this:
<img width="1223" alt="Screen Shot 2020-08-03 at 7 50 12 PM" src="https://user-images.githubusercontent.com/1151048/89243967-8fbb2600-d5c2-11ea-8de2-4422e870f9f0.png">


Then visit this URL and set your date time to go backwards by 1 year
```ts
http://localhost:5601/app/security/hosts/app/security/hosts/MacBook-Pro.local/alerts
```

And with the fix you no longer get the error toaster.
FrankHassanabad added a commit to FrankHassanabad/kibana that referenced this pull request Aug 4, 2020
…te_optional_time (elastic#74211)

## Summary

Related closed issues:
elastic#58965
elastic#70713

If you add a custom mapping and go to the hosts details page you will get an error toaster:
<img width="838" alt="Screen Shot 2020-08-03 at 7 53 16 PM" src="https://user-images.githubusercontent.com/1151048/89244409-a7df7500-d5c3-11ea-933c-99d96bffc589.png">

If running local host you can configure your index patterns to use a custom one I setup with custom date time formats and a single record which can cause this:
<img width="1223" alt="Screen Shot 2020-08-03 at 7 50 12 PM" src="https://user-images.githubusercontent.com/1151048/89243967-8fbb2600-d5c2-11ea-8de2-4422e870f9f0.png">


Then visit this URL and set your date time to go backwards by 1 year
```ts
http://localhost:5601/app/security/hosts/app/security/hosts/MacBook-Pro.local/alerts
```

And with the fix you no longer get the error toaster.
FrankHassanabad added a commit to FrankHassanabad/kibana that referenced this pull request Aug 4, 2020
…te_optional_time (elastic#74211)

## Summary

Related closed issues:
elastic#58965
elastic#70713

If you add a custom mapping and go to the hosts details page you will get an error toaster:
<img width="838" alt="Screen Shot 2020-08-03 at 7 53 16 PM" src="https://user-images.githubusercontent.com/1151048/89244409-a7df7500-d5c3-11ea-933c-99d96bffc589.png">

If running local host you can configure your index patterns to use a custom one I setup with custom date time formats and a single record which can cause this:
<img width="1223" alt="Screen Shot 2020-08-03 at 7 50 12 PM" src="https://user-images.githubusercontent.com/1151048/89243967-8fbb2600-d5c2-11ea-8de2-4422e870f9f0.png">


Then visit this URL and set your date time to go backwards by 1 year
```ts
http://localhost:5601/app/security/hosts/app/security/hosts/MacBook-Pro.local/alerts
```

And with the fix you no longer get the error toaster.
FrankHassanabad added a commit that referenced this pull request Aug 4, 2020
…te_optional_time (#74211) (#74245)

## Summary

Related closed issues:
#58965
#70713

If you add a custom mapping and go to the hosts details page you will get an error toaster:
<img width="838" alt="Screen Shot 2020-08-03 at 7 53 16 PM" src="https://user-images.githubusercontent.com/1151048/89244409-a7df7500-d5c3-11ea-933c-99d96bffc589.png">

If running local host you can configure your index patterns to use a custom one I setup with custom date time formats and a single record which can cause this:
<img width="1223" alt="Screen Shot 2020-08-03 at 7 50 12 PM" src="https://user-images.githubusercontent.com/1151048/89243967-8fbb2600-d5c2-11ea-8de2-4422e870f9f0.png">


Then visit this URL and set your date time to go backwards by 1 year
```ts
http://localhost:5601/app/security/hosts/app/security/hosts/MacBook-Pro.local/alerts
```

And with the fix you no longer get the error toaster.
FrankHassanabad added a commit that referenced this pull request Aug 4, 2020
…te_optional_time (#74211) (#74244)

## Summary

Related closed issues:
#58965
#70713

If you add a custom mapping and go to the hosts details page you will get an error toaster:
<img width="838" alt="Screen Shot 2020-08-03 at 7 53 16 PM" src="https://user-images.githubusercontent.com/1151048/89244409-a7df7500-d5c3-11ea-933c-99d96bffc589.png">

If running local host you can configure your index patterns to use a custom one I setup with custom date time formats and a single record which can cause this:
<img width="1223" alt="Screen Shot 2020-08-03 at 7 50 12 PM" src="https://user-images.githubusercontent.com/1151048/89243967-8fbb2600-d5c2-11ea-8de2-4422e870f9f0.png">


Then visit this URL and set your date time to go backwards by 1 year
```ts
http://localhost:5601/app/security/hosts/app/security/hosts/MacBook-Pro.local/alerts
```

And with the fix you no longer get the error toaster.
@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
bug Fixes for quality problems that affect the customer experience release_note:skip Skip the PR/issue when compiling release notes 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.

None yet

8 participants