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

x-pack/winlogbeat/module/routing: set host.os.type and host.os.family in forwarded events #35435

Merged
merged 2 commits into from
May 18, 2023

Conversation

efd6
Copy link
Contributor

@efd6 efd6 commented May 12, 2023

What does this PR do?

Sets host.os.type and host.os.family in forwarded events.

Why is it important?

These fields are used in detection rules.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Author's Checklist

  • [ ]

How to test this PR locally

Related issues

Use cases

Screenshots

Logs

@efd6 efd6 self-assigned this May 12, 2023
@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels May 12, 2023
@elasticmachine
Copy link
Collaborator

elasticmachine commented May 12, 2023

💚 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: 2023-05-14T22:23:58.990+0000

  • Duration: 36 min 54 sec

Test stats 🧪

Test Results
Failed 0
Passed 336
Skipped 0
Total 336

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

Expand to view the GitHub comments

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

  • /test : Re-trigger the build.

  • /package : Generate the packages and run the E2E tests.

  • /beats-tester : Run the installation tests with beats-tester.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@efd6 efd6 force-pushed the i6162-forwarded branch from 7fe6420 to 0be3454 Compare May 12, 2023 03:56
@efd6 efd6 marked this pull request as ready for review May 12, 2023 06:14
@efd6 efd6 requested a review from a team as a code owner May 12, 2023 06:14
@elasticmachine
Copy link
Collaborator

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

field: host.os.family
value: windows
override: false
if: ctx.tags != null && ctx.tags.contains('forwarded')
Copy link
Contributor

@legoguy1000 legoguy1000 May 12, 2023

Choose a reason for hiding this comment

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

Does the following config https://www.elastic.co/guide/en/beats/winlogbeat/master/configuration-winlogbeat-options.html#_event_logs_forwarded set the forwarded tag? I'm looking at the code and I don't think so. So should we do both?

winlogbeat.event_logs:
  - name: <Channel>
    forwarded: true
    tags: [forwarded]

For more context, we're not using the ForwardedEvents channel, we have multitude of custom channels that intakes WEF logs from the environment to balance the load.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I spent a fair bit of time trying to sort that out. As far as I can make out, forwarded must be set by the user in the config as you have in the snippet. This is how it always appears in the repo.

Copy link
Contributor

Choose a reason for hiding this comment

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

Would it not make sense to just if forwarded: true to automatically add the forwarded tag? That way users don't have to remember to do both?

Copy link
Contributor

Choose a reason for hiding this comment

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

Or perhaps instead of requiring the tag. Just check if the field isn't set, set to windows otherwise use the provided field

Copy link
Contributor Author

@efd6 efd6 May 12, 2023

Choose a reason for hiding this comment

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

The config value doesn't make its way into the ingested document AFAICS.

Copy link
Contributor

Choose a reason for hiding this comment

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

Correct. I'm thinking in the winlogbeat code to either auto add the tag if you're going to leave the if:.... conditional on the ingest processors OR change the conditional to just always set the fields if they're not already set since I think it's a decent default to assume the OS is windows

Copy link
Contributor Author

Choose a reason for hiding this comment

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

change the conditional to just always set the fields if they're not already set since I think it's a decent default to assume the OS is windows

I like this one.

Copy link
Contributor

Choose a reason for hiding this comment

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

for our purposes until this is merged and released, it looks like i'm going to use the below in our environment

      - set:
          field: host.os.type
          value: windows
          override: false
      - set:
          field: host.os.family
          value: windows
          override: false

The override logic works so if its already set, nothing changes and if not, it gets set to windows.

Copy link
Member

@ebeahan ebeahan left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.9-candidate backport-skip Skip notification from the automated backport with mergify enhancement Winlogbeat
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants