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

[FR] Support missing events #76

Merged
merged 11 commits into from
Oct 31, 2023
Merged

[FR] Support missing events #76

merged 11 commits into from
Oct 31, 2023

Conversation

Mikaayenson
Copy link
Contributor

@Mikaayenson Mikaayenson commented Oct 2, 2023

Issues

Resolves #69

Details

Adds support for the negative feature used within elasticsearch sequences.

Testing

Unit tests should pass.

Screenshot 2023-10-02 at 4 49 03 PM

Additional Information

Related to elastic/detection-rules#3136

@Mikaayenson Mikaayenson self-assigned this Oct 2, 2023
@Mikaayenson Mikaayenson added the enhancement New feature or request label Oct 2, 2023
eql/ast.py Show resolved Hide resolved
@Mikaayenson Mikaayenson changed the title [FR] Support negative subqueries in sequences [FR] Support missing events Oct 2, 2023
Copy link
Collaborator

@terrancedejesus terrancedejesus left a comment

Choose a reason for hiding this comment

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

Looks good

Copy link
Collaborator

@eric-forte-elastic eric-forte-elastic left a comment

Choose a reason for hiding this comment

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

LGTM 👍 Thanks for the walk through and good tests!

@Mikaayenson
Copy link
Contributor Author

Once we merge this in, we will hold cutting a release until ipv6 cidmatch support is added (shortly after).

@eric-forte-elastic
Copy link
Collaborator

eric-forte-elastic commented Oct 24, 2023

🟢 Independent package testing works as expected, LGTM 👍

eql_clean_build

Details

  1. Checkout this branch
  2. Run make clean to remove old eql library build
  3. Run make and activate the build environment
  4. Run the test code
  5. Verify the output
  6. Verify that the current version of eql is the newly build *.19 from when you ran make

Negation Test Code:

import eql

query = '''
sequence with maxspan=2m [any where process: "cmd.exe"] [any where process: "Fake.exe"]
'''
with eql.parser.elasticsearch_syntax, eql.parser.allow_negation:
    parsed = eql.parse_query(query, implied_any=True, implied_base=True)
data_to_filter = [{"process": "cmd.exe", "@timestamp": "2023-05-22T20:03:56.020Z"}, {"process": "bash.exe", "@timestamp": "2023-05-22T20:03:57.020Z"}]
filter_engine = eql.get_engine(parsed)
print(f"Original Query: {query}")
print(f"Output: {filter_engine(data_to_filter)}")


print("-" * 50)
query = '''
sequence with maxspan=2m [any where process: "cmd.exe"] ![any where process: "Fake.exe"]
'''
with eql.parser.elasticsearch_syntax, eql.parser.allow_negation:
    parsed = eql.parse_query(query, implied_any=True, implied_base=True)
filter_engine = eql.get_engine(parsed)
print(f"Negated Query: {query}")
print(f"Output: {filter_engine(data_to_filter)}")

CHANGELOG.md Outdated
@@ -1,6 +1,14 @@
# Event Query Language - Changelog
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

# Version 0.9.19

_Released 2023-10-10_
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will bump before merging.

tests/test_python_engine.py Outdated Show resolved Hide resolved
tests/test_python_engine.py Show resolved Hide resolved
tests/test_python_engine.py Outdated Show resolved Hide resolved
tests/test_python_engine.py Outdated Show resolved Hide resolved
eql/engine.py Outdated Show resolved Hide resolved
Copy link
Contributor

@brokensound77 brokensound77 left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@terrancedejesus
Copy link
Collaborator

No other changes that I could find ✅

@Mikaayenson Mikaayenson merged commit 49d8d64 into master Oct 31, 2023
2 checks passed
@Mikaayenson Mikaayenson deleted the support_negative_sequence branch October 31, 2023 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FR] Sequence - Add support for missing events
4 participants