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

[ti_opencti] Add support for IOC expiration #8920

Merged
merged 10 commits into from
Feb 9, 2024

Conversation

chrisberkhout
Copy link
Contributor

@chrisberkhout chrisberkhout commented Jan 17, 2024

Proposed commit message

[ti_opencti] Add support for IOC expiration (#8920)

- Adds a transform to create an index of the latest non-expired and
  non-revoked indicators.
- A new field, `opencti.indicator.invalid_or_revoked_from` is added to
  combine information from `valid_until` and `revoked`/`modified_at`,
  for use in the retention policy.
- Field definition files are exactly the same for the source data
  stream and the transform, except for `ioc-transform-source.yml`,
  which is only present in the source data stream. For the ECS fields
  used, I added references to the external ECS field definitions, since
  this seems to have been necessary to get the right mappings into the
  transform destination index.
- Dashboards are updated. Previously existing dashboards now use the
  latest indicators only. A new Ingest dashboard shows both source and
  latest data.

Discussion

I'm assuming that opencti.indicator.valid_from will not have future values. That means I assume that an indicator will always be valid between the time its created and the time it expires or is revoked, rather than allowing e.g. "this will be valid starting next week".

As mentioned in the README, I don't clean up indicators that are never expired or revoked (a.k.a. "orphaned IOCs"), because I think that in the case of OpenCTI this can best be handled upstream or manually.

I started with the - external: ecs field definitions in a separate file from the existing ECS extensions and override definitions, but in the end I had to combine them into one file due to what seems to be a bug in Fleet.

I needed to raise the stack version in conditions.kibana.version from 8.9.0 to 8.10.1 to avoid this error:

Error: can't install the package: could not zip-install package; API status code
= 500; response body = {"statusCode":500,"error":"Internal Server Error","messag
e":"runtime_exception\n\tCaused by:\n\t\tillegal_argument_exception: unknown ind
ex sort field:[@timestamp]\n\tRoot causes:\n\t\truntime_exception: Could not cre
ate destination index [logs-ti_opencti_latest.dest_indicator-1] for transform [l
ogs-ti_opencti.latest_ioc-default-0.1.0]"}

Checklist

  • I have reviewed tips for building integrations and this pull request is aligned with them.
  • I have verified that all data streams collect metrics or logs.
  • I have added an entry to my package's changelog.yml file.
  • I have verified that Kibana version constraints are current according to guidelines.

How to test this PR locally

You can test manually using the OpenCTI public demo instance. Note that the ingest dashboard will show immediate activity but it may take some time before non-revoked indicators are ingested and appear in the latest index.

The files shared between the data stream and the transform are the same:

diff -c9 <(cd data_stream/indicator/fields/              > /dev/null; md5sum *) \
         <(cd elasticsearch/transform/latest_ioc/fields/ > /dev/null; md5sum *)
*** /dev/fd/63	2024-01-17 18:24:53.214274662 +0100
--- /dev/fd/62	2024-01-17 18:24:53.214274662 +0100
***************
*** 1,4 ****
  3a08ed0a9ccffa200354ecc33f400c35  base-fields.yml
  b6ad99a97ee9877c06428b97a075ddeb  ecs.yml
- 5d8afa6ff186f571759469f8f0f575cc  ioc-transform-source.yml
  6204760fcfbcd8e1e4a264b656811306  opencti.yml
--- 1,3 ----

Related issues

Screenshots

Please see the updated screenshots (1-3) in the integration.

@elasticmachine
Copy link

Pinging @elastic/security-external-integrations (Team:Security-External Integrations)

@chrisberkhout chrisberkhout self-assigned this Jan 17, 2024
@chrisberkhout
Copy link
Contributor Author

/test

@elasticmachine
Copy link

🚀 Benchmarks report

To see the full report comment with /test benchmark fullreport

@chrisberkhout chrisberkhout requested a review from a team as a code owner January 24, 2024 15:33
@narph narph added Team:Security-Service Integrations Security Service Integrations Team [elastic/security-service-integrations] and removed Team:Security-External Integrations labels Jan 29, 2024
Copy link
Contributor

@efd6 efd6 left a comment

Choose a reason for hiding this comment

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

Minor nits only.

@elasticmachine
Copy link

💚 Build Succeeded

History

cc @chrisberkhout

Copy link

@chrisberkhout chrisberkhout merged commit f0f9d01 into elastic:main Feb 9, 2024
5 checks passed
@chrisberkhout chrisberkhout deleted the ti_opencti-ioc branch February 9, 2024 10:53
@elasticmachine
Copy link

Package ti_opencti - 1.1.0 containing this change is available at https://epr.elastic.co/search?package=ti_opencti

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Integration:ti_opencti OpenCTI Team:Security-Service Integrations Security Service Integrations Team [elastic/security-service-integrations]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants