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

Add support for threat.feed.name #120250

Merged
merged 14 commits into from
Dec 7, 2021
Merged

Conversation

nkhristinin
Copy link
Contributor

@nkhristinin nkhristinin commented Dec 2, 2021

Summary

We add supporting of threat.feed.name for alerts flyout and timeline view.

Context

Previously we were showing indicator. provider as source name (provider) of enrichment.

e.g

file.hash.sha256 ${hashValue} from AbuseCH

In new fleet TI integrations and filebeat 8.x the purpose of indicator. provider field was changed.

threat.indicator.provider - goes to the actual person/entity that submitted the indicator. As an example, this could be a threat researcher (“Cryptolaemus1”, “lrz_urlhaus”, “tammeto”, etc.)

And to be able to show previous source name was introduced threat.feed.name

Solution

Currently, we have 2 different ways of building enrichment on the backend:

  • for real-time investigation enrichments (query all fields from threat, so threat.feed just will be in enrichment automatically)
  • for IM rule (we build it manually, we need to pass feed into enrichment)

The frontend has logic about what to show for source name:

  • if enrichment has feed.name - show it

How to tests

Be sure that on alerts flyout and timeline we have the right source name
Screenshot 2021-12-02 at 18 59 41
Screenshot 2021-12-02 at 18 59 11

Checklist

Delete any items that are not applicable to this PR.

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.

Code looks good, but I don't think conflating provider and feed is a good approach here; we should find a way to display them as distinct concepts.

@@ -1107,6 +1107,9 @@ export const mockTimelineData: TimelineItem[] = [
field: ['source.ip'],
type: ['ip'],
},
feed: {
name: ['indicator_provider'],
Copy link
Contributor

Choose a reason for hiding this comment

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

A more realistic example here might help distinguish it from provider 😉

Copy link
Contributor Author

@nkhristinin nkhristinin Dec 2, 2021

Choose a reason for hiding this comment

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

Agree, it's value used here, I think it make more sense
Screenshot 2021-12-02 at 19 38 35

@@ -81,7 +82,9 @@ export const getEnrichmentIdentifiers = (enrichment: CtiEnrichment): CtiEnrichme
field: getEnrichmentValue(enrichment, MATCHED_FIELD),
value: getEnrichmentValue(enrichment, MATCHED_ATOMIC),
type: getEnrichmentValue(enrichment, MATCHED_TYPE),
provider: getShimmedIndicatorValue(enrichment, PROVIDER),
provider:
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we want to conflate these two values as they're different concepts. Feed name is the data feed containing the indicator, while the provider is the entity that discovered/generated the 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.

So, do you suggest that we need to keep only FEED_NAME here?

It's basically will be the same as old behaviour

@@ -46,7 +47,7 @@ export const ThreatMatchRow = ({
contextId,
eventId,
indicatorReference: get(data, REFERENCE)[0] as string | undefined,
indicatorProvider: get(data, PROVIDER)[0] as string | undefined,
indicatorProvider: (get(data, FEED_NAME)[0] ?? get(data, PROVIDER)[0]) as string | undefined,
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto on the conflation here.

@@ -81,7 +81,7 @@ export const getEnrichmentIdentifiers = (enrichment: CtiEnrichment): CtiEnrichme
field: getEnrichmentValue(enrichment, MATCHED_FIELD),
value: getEnrichmentValue(enrichment, MATCHED_ATOMIC),
type: getEnrichmentValue(enrichment, MATCHED_TYPE),
provider: getShimmedIndicatorValue(enrichment, PROVIDER),
provider: getShimmedIndicatorValue(enrichment, FEED_NAME),
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 we should rename this to feedName to remain consistent. I see no reason not to keep returning provider as well:

Suggested change
provider: getShimmedIndicatorValue(enrichment, FEED_NAME),
feedName: getShimmedIndicatorValue(enrichment, FEED_NAME),
provider: getShimmedIndicatorValue(enrichment, PROVIDER),

@@ -46,7 +47,7 @@ export const ThreatMatchRow = ({
contextId,
eventId,
indicatorReference: get(data, REFERENCE)[0] as string | undefined,
indicatorProvider: get(data, PROVIDER)[0] as string | undefined,
indicatorProvider: get(data, FEED_NAME)[0] as string | undefined,
Copy link
Contributor

Choose a reason for hiding this comment

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

If we're changing the semantic meaning of this prop we should change its name as well.

Suggested change
indicatorProvider: get(data, FEED_NAME)[0] as string | undefined,
feedName: get(data, FEED_NAME)[0] as string | undefined,

@nkhristinin
Copy link
Contributor Author

@elasticmachine merge upstream

</EnrichmentFieldProvider>
{feedName && (
<EnrichmentFieldFeedName>
{i18n.PROVIDER_PREPOSITION} {feedName}
Copy link
Contributor

Choose a reason for hiding this comment

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

we could probably rename i18n.PROVIDER_PREPOSITION

'matched.atomic': ['matched atomic'],
'matched.type': ['matched type'],
'feed.name': ['feed name'],
'indicator.provider': ['provider name'],
Copy link
Contributor

Choose a reason for hiding this comment

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

do we use the indicator.provider enrichment identifier in Kibana? trying to understand if we need to leave it here considering it's a mapped field just like most others and it would work on the timeline anyway. if it's not used on the row renderer UI, there might not be an urgent reason to keep it here

return {
indicator,
feed,
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought we only wanted and mapped the threat.feed.name field for the alert, so I think we could consider just putting feed.name here instead of the feed obj

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed.

@@ -98,7 +98,7 @@ const EnrichmentAccordion: React.FC<{
key={accordionId}
initialIsOpen={true}
arrowDisplay="right"
buttonContent={<EnrichmentButtonContent field={field} provider={provider} value={value} />}
buttonContent={<EnrichmentButtonContent field={field} feedName={feedName} value={value} />}
Copy link
Contributor

@ecezalp ecezalp Dec 3, 2021

Choose a reason for hiding this comment

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

it looks like we are completely removing the provider string from the UI - I thought we wanted to display provider if there was no feedName for the purpose of identifying the source of a feed. I understand previously raised concerns around conflating information , but we also know that it's very unlikely for the users to have threat.feed.name fields populated at least in 8.0 (as threat.feed.name is not in the ECS specification). IMHO we can do something like feedName={feedName ?? provider} in the UI context chatted w/Ryland, it looks like this is something we could get product feedback on - since threat intel integrations from 8.0 are all designed to ship the threat.feed.name field, this is less of a concern

@nkhristinin
Copy link
Contributor Author

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💚 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
apm 2.7MB 2.7MB +132.0B
observability 362.2KB 362.3KB +132.0B
securitySolution 4.6MB 4.6MB -65.0B
total +199.0B

History

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

Copy link
Contributor

@cavokz cavokz left a comment

Choose a reason for hiding this comment

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

LGTM

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.

LGTM

@ecezalp ecezalp self-requested a review December 6, 2021 18:12
Copy link
Contributor

@ecezalp ecezalp left a comment

Choose a reason for hiding this comment

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

LGTM

@ecezalp ecezalp merged commit a8405fe into elastic:main Dec 7, 2021
nkhristinin added a commit to nkhristinin/kibana that referenced this pull request Dec 7, 2021
* Add support for threat.feed.name

* fix cy tests

* Remove provider field

* fix tests

* Provider to feed.name

* Fix tests

* Fix tests

* fix comments

* Fix i18n

* fix type

* Fix types

* fix tests

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
jloleysens added a commit to jloleysens/kibana that referenced this pull request Dec 7, 2021
…-chromium-before-compiling-pdf

* 'main' of github.com:elastic/kibana: (121 commits)
  FTR should use the new kibana_system user (elastic#120436)
  [Lens] Temporarily exclude Mosaic/Waffle from the suggestions list (elastic#120488)
  [Reporting] Fix slow CSV with large max size bytes (elastic#120365)
  [CTI] Threat Intel Card on Overview page needs to accommodate Fleet TI integrations -  (elastic#120459)
  [Dashboard] Added KibanaThemeProvider.  (elastic#120122)
  add more rule_registry unit tests (elastic#120323)
  [Lens] update xpack.lens.pie.smallValuesWarningMessage text (elastic#120478)
  [Fleet] Simplified package policy create API, enriching default values (elastic#119739)
  mock `elastic-apm-node` in `@kbn/test` jest preset (elastic#120324)
  [RAC] Rename occurrences of alert_type to rule_type in Infra (elastic#120455)
  [Security Solutions] Removes tech debt of exporting all from linter rule for timeline plugin (elastic#120437)
  [Workplace Search] Add API Keys view to replace Access tokens (elastic#120147)
  [Security Solutions] Removes tech debt of exporting all from linter rule for cases plugin in the server section (elastic#120411)
  Add support for threat.feed.name (elastic#120250)
  [Rule Registry] Rewrite APM registry rules for Observability (elastic#117740)
  [docs] Fix artifact layout formatting (elastic#119386)
  [Workplace Search] Add a technical preview of connecting GitHub via GitHub apps (elastic#119764)
  add osquery notes for 7.16 (elastic#120407)
  chore(NA): splits types from code on @kbn/docs-utils (elastic#120533)
  [Reporting] Decouple screenshotting plugin from the reporting (elastic#120110)
  ...

# Conflicts:
#	x-pack/plugins/reporting/server/browsers/chromium/driver_factory/index.test.ts
#	x-pack/plugins/reporting/server/browsers/chromium/driver_factory/index.ts
#	x-pack/plugins/reporting/server/lib/screenshots/observable.test.ts
#	x-pack/plugins/reporting/server/lib/screenshots/observable.ts
#	x-pack/plugins/reporting/server/test_helpers/create_mock_browserdriverfactory.ts
@nkhristinin
Copy link
Contributor Author

How to test:

Intro

  1. Run elasticsearch and kibana

Filebeat

  1. Pull the latest changes of beats
  2. Add filebeat data as described here

Create a custom test-index

PUT test-index
{
  "mappings": {
    "properties": {
      "@timestamp": {
        "type": "date"
      },
      "file": {
         "properties": {
           "hash": {
             "properties": {
               "md5": {
                 "type" : "keyword",
                  "ignore_above" : 1024
               }
             }
           }
         }
      }
  }
}
}

Create an IM rule

Index patterns: **test-index**
Custom query: ***:***
Indicator index patterns: **filebeat-***
Indicator mapping: **file.hash.md5 MATCHES threat.indicator.file.hash.md5**
Indicator index query: **@timestamp >= "now-30d"**
Runs every: **1m**
Additional look-back time: **5h**

Let's make a match

  1. Find in FIlebeat the sha256 hash value and copy it
GET filebeat-8*/_search
{
  "query": {
    "exists": {
      "field": "threat.indicator.file.hash.md5"
    }
  },
  "_source": ["threat.indicator.file.hash.md5"]
}
  1. Send the document into our test-index
POST test-index/_doc
{
  "@timestamp": ${TIMESTAMP_VALUE},
  "file": {
    "hash": {
      "md5": "${MD5_FROM_FILEBEAT}"
    }
  }
}
  1. Go to your rule, you should see 1 alert.
    Check the Threat Intel tab, it should have the feed name

Screenshot 2021-12-07 at 11 55 17

  1. Go to timeline from the alert row, you also should have the feed name:

Screenshot 2021-12-07 at 11 57 16

nkhristinin added a commit that referenced this pull request Dec 7, 2021
* Add support for threat.feed.name

* fix cy tests

* Remove provider field

* fix tests

* Provider to feed.name

* Fix tests

* Fix tests

* fix comments

* Fix i18n

* fix type

* Fix types

* fix tests

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
TinLe pushed a commit to TinLe/kibana that referenced this pull request Dec 22, 2021
* Add support for threat.feed.name

* fix cy tests

* Remove provider field

* fix tests

* Provider to feed.name

* Fix tests

* Fix tests

* fix comments

* Fix i18n

* fix type

* Fix types

* fix tests

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants