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

Enhance Suricata pipeline to handle destination.domain being set #10861

Merged
merged 3 commits into from
Feb 26, 2019

Conversation

andrewkroh
Copy link
Member

This replaces the usage of a rename processor with an append + remove processor.
Then a script processor is used to deduplicate the domains.

This makes the pipeline compatible with the reverse dns processor being used on the Beat side.

Fixes #10510

@andrewkroh andrewkroh requested a review from adriansr February 21, 2019 04:54
@andrewkroh andrewkroh requested a review from a team as a code owner February 21, 2019 04:54
Copy link
Contributor

@adriansr adriansr left a comment

Choose a reason for hiding this comment

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

LGTM

{
"script": {
"source": "def domain = ctx.destination?.domain; if (domain instanceof Collection) { if (domain.length == 1) { ctx.destination.domain = domain[0]; } else { ctx.destination.domain = ctx.destination.domain.stream().distinct().collect(Collectors.toList()); } }",
"ignore_failure": true
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if domain containing an array will be a problem.

Suggestion: dedupe before if (domain.length == 1).

Copy link
Member Author

Choose a reason for hiding this comment

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

I've been sending in arrays for a few weeks and have made the team aware that this can be an array.

Copy link
Member Author

Choose a reason for hiding this comment

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

And I implemented your suggestion. Good idea.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah we'll need to start looking into defining this more clearly in ECS.

But I agree that we have to support arrays here, because of the reverse DNS possibility.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah wait. You're only keeping the first of the array? 🤔How do you know it's the interesting entry?

Copy link
Member Author

Choose a reason for hiding this comment

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

No. This is the code. It doesn't drop any data.

    def domain = ctx.destination?.domain; 
    if (domain instanceof Collection) {
      // Deduplicate
      ctx.destination.domain = ctx.destination.domain.stream().distinct().collect(Collectors.toList());
      
      // Make it a plain old string if there's only one item.
      if (domain.length == 1) { 
        ctx.destination.domain = domain[0]; 
      } 
    }

Copy link
Contributor

Choose a reason for hiding this comment

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

Can the reverse DNS processor return more than one DNS entry for a given IP?

If so, this only keeps the first one, right?

Or does the processor always return an array of one?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, I see the problem. When I refactored it from the initial version I broke it. The fixed version is:

    def domain = ctx.destination?.domain; 
    if (domain instanceof Collection) {
      // Deduplicate
      domain = domain.stream().distinct().collect(Collectors.toList());
      
      // Make it a plain old string if there's only one item.
      if (domain.length == 1) { 
        domain = domain[0]; 
      }
      
      // Set the value
      ctx.destination.domain = domain;
    }

Does this address your concern?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, happy to see we weren't just going around in circles :-)

Yes, this makes sense now :-)

@andrewkroh andrewkroh force-pushed the feature/fb/suricata-dest-domain branch 2 times, most recently from 4e9e41b to 06ab068 Compare February 23, 2019 01:55
This replaces the usage of a `rename` processor with an `append` + `remove` processor.
Then a script processor is used to deduplicate the domains.

Fixes elastic#10510
@andrewkroh andrewkroh force-pushed the feature/fb/suricata-dest-domain branch from 06ab068 to a95e713 Compare February 25, 2019 20:53
Copy link
Contributor

@webmat webmat left a comment

Choose a reason for hiding this comment

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

LGTM

@andrewkroh andrewkroh merged commit 5ef730f into elastic:master Feb 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants