Skip to content

[Cloud Posture] Findings datastream mapping - #3775

Merged
kfirpeled merged 9 commits into
elastic:mainfrom
kfirpeled:cspm/v840-findings-mapping
Jul 26, 2022
Merged

[Cloud Posture] Findings datastream mapping#3775
kfirpeled merged 9 commits into
elastic:mainfrom
kfirpeled:cspm/v840-findings-mapping

Conversation

@kfirpeled

@kfirpeled kfirpeled commented Jul 20, 2022

Copy link
Copy Markdown
Contributor

What does this PR do?

In the following PR we've adjusted the findings mappings.

  • Turned off dynamic mappings
  • Imported ECS mappings (auto-generated)
  • Aligned mappings to ECS conventions (reference)

This means that from now on we opt-in which fields we index in the findings being sent by cloudbeat

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.

Author's Checklist

  • [ ]

How to test this PR locally

To test this PR I recommend building the package locally and use it, send data using cloudbeat and check that all fields have the correct mappings

Related issues

Screenshots

@kfirpeled kfirpeled added enhancement New feature or request v8.4.0 Team:Cloud Security Cloud Security team [elastic/cloud-security-posture] labels Jul 20, 2022
@elasticmachine

elasticmachine commented Jul 20, 2022

Copy link
Copy Markdown

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2022-07-26T16:28:14.907+0000

  • Duration: 17 min 7 sec

Test stats 🧪

Test Results
Failed 0
Passed 2
Skipped 0
Total 2

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.
@kfirpeled

Copy link
Copy Markdown
Contributor Author

/test

@kfirpeled kfirpeled mentioned this pull request Jul 20, 2022
2 tasks
@elasticmachine

elasticmachine commented Jul 21, 2022

Copy link
Copy Markdown

🌐 Coverage report

Name Metrics % (covered/total) Diff
Packages 100.0% (0/0) 💚
Files 100.0% (0/0) 💚 2.879
Classes 100.0% (0/0) 💚 2.879
Methods 25.0% (1/4) 👎 -64.297
Lines 100.0% (0/0) 💚 9.421
Conditionals 100.0% (0/0) 💚
@kfirpeled
kfirpeled marked this pull request as ready for review July 21, 2022 13:28
@kfirpeled
kfirpeled requested a review from a team as a code owner July 21, 2022 13:28

@eyalkraft eyalkraft left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nice, some nits

Comment on lines +4 to +12
- description: Adjust findings data-stream mappings to fit ECS conventions
type: enhancement
link: https://github.com/elastic/integrations/pull/3775
- description: Turned off dynamic mappings of findings data-stream
type: enhancement
link: https://github.com/elastic/integrations/pull/3775
- description: Added default pipeline to findings data-stream
type: enhancement
link: https://github.com/elastic/integrations/pull/3775

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not sure listing the same PR multiple times is encouraged.

Suggested change
- description: Adjust findings data-stream mappings to fit ECS conventions
type: enhancement
link: https://github.com/elastic/integrations/pull/3775
- description: Turned off dynamic mappings of findings data-stream
type: enhancement
link: https://github.com/elastic/integrations/pull/3775
- description: Added default pipeline to findings data-stream
type: enhancement
link: https://github.com/elastic/integrations/pull/3775
- description: |
Adjust findings data-stream mappings to fit ECS conventions
Turned off dynamic mappings of findings data-stream
Added default pipeline to findings data-stream
type: enhancement
link: https://github.com/elastic/integrations/pull/3775

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

saw several packages doing the same in their changelog, thought to give it a try

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

tbh, my previous try with version 0.0.19 combining multiple prs to the same changelog was not a successful one. Because of the post-merge process happens when the version is being create for the first time, it is not being updated afterwards

- name: event.ingested
external: ecs
type: date
- name: file.accessed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

- name: message
external: ecs
type: match_only_text
- name: process.args

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

or was this file purely autogenerated? In this case let's not edit it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

semi-auto generated, the ecs generator is half-way through to get this file format
I assume this file is going to be fully auto generated

I saw osquery did their own tool, could be a good idea for us as well going forward
https://github.com/elastic/integrations/blob/main/packages/osquery_manager/data_stream/result/fields/ecs.yml

Comment on lines +8 to +10
Examples of data sources that would populate the rule fields include: network
admission control platforms, network or host IDS/IPS, network firewalls, web
application firewalls, url filters, endpoint detection and response (EDR) systems,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

maybe this could be specified for us (if not autogenerated)

@kfirpeled kfirpeled Jul 21, 2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

So I copy-pasted from the generated code
I didn't try to follow if the documentation being created out of it.

I guess you are correct but I'd leave that out-of-scope and we'll deal with that later on
Assuming the official ECS documentation is good enough for now

default_field: false
- name: tags
level: extended
type: keyword

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

tags is a list isn't it? Is this the way to map list of keywords?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

when I was using type: array the mapping was working as expected.
I was googling and based on the following answer https://stackoverflow.com/questions/43530610/how-to-do-a-mapping-of-array-of-strings-in-elasticsearch
it seems that type: keyword is good enough

And looking on ECS base fields they do the same for the tags field:
https://www.elastic.co/guide/en/ecs/current/ecs-base.html#field-tags

@oren-zohar

Copy link
Copy Markdown
Contributor

@ofiriro3 @tehilashn we may need to do the same for the new EKS fetchers, are they introducing any new fields? besides the raw resource?

@ofiriro3

Copy link
Copy Markdown
Contributor

@oren-zohar No new fields, only the raw resource

@kfirpeled
kfirpeled merged commit 8998871 into elastic:main Jul 26, 2022
@kfirpeled
kfirpeled deleted the cspm/v840-findings-mapping branch July 26, 2022 16:46
orestisfl pushed a commit to orestisfl/integrations that referenced this pull request May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change enhancement New feature or request Team:Cloud Security Cloud Security team [elastic/cloud-security-posture] v8.4.0

5 participants