Add OpenSearch PPL support - #72
Merged
Merged
Conversation
|
I'll add that while OpenSearch PPL added a lot of features to get close to Splunk's SPL, some parts are still a bit unstable. While working on the backend we found a few bugs (opensearch-project/sql#5145, opensearch-project/sql#5146, opensearch-project/sql#5147) that make some correlation rules unusable. There is a fix in opensearch-project/sql#5154, but we have no idea when it will be merged and/or if it will be backported. There might still be some bugs in the newer PPL commands / features, but the translation from Sigma to PPL should be ok. |
thomaspatzke
requested changes
Mar 15, 2026
thomaspatzke
left a comment
Member
There was a problem hiding this comment.
Looks great to me! Could you please add tests as done here for Lucene query generation?
Contributor
Author
|
I added the tests for the OpenSearch PPL backend. |
thomaspatzke
approved these changes
Mar 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add OpenSearch PPL support
This PR adds support for the OpenSearch PPL query language.
Since it is independent from any Elasticsearch query language and not based on the existing backend code, the implementation resides in its own file (
sigma/backends/opensearch/opensearch_ppl.py).The backend extends pySigma's
TextQueryBackendclass.What it does
Converts Sigma rules into OpenSearch PPL queries:
Target Versions
Note that this targets OpenSearch 3.3+ for regular detection rules. Correlation rules require OpenSearch 3.4+ since they depend on the
multisearchcommand.PPL Documentation: https://github.com/opensearch-project/sql/blob/main/docs/user/ppl/index.md
Features
Correlation Support
Support for Sigma correlation types with automatic conversion to PPL aggregation queries:
event_count- Frequency-based detection (e.g., >10 failed logins in 5 minutes)stats count()with time-based grouping withspan()functionvalue_count- Cardinality-based detection (e.g., same password tried on more than 5 accounts)dc(field)(distinct count) functiontemporal/temporal_ordered- Multi-stage attack detection (e.g., failed login followed by successful login)multisearchcommand to combine detection rules from multiple indicesspan()for time-based bucketing anddc(EventID)to verify all event types occurredAbout
multisearch: When you have 2 or more detection rules in a correlation, the backend uses themultisearchcommand. This means each detection rule runs as its own separate search and the results get combined. This approach works the same way whether your rules search the same index or different indices.Custom Attributes
You can configure specific rules by adding custom attributes directly in the Sigma YAML file. This lets you override the backend's default behavior for individual rules:
opensearch_ppl_index- Override index pattern (useful for non-standard naming)opensearch_ppl_min_time- Add minimum time filter (e.g.,"-30d"for last 30 days)opensearch_ppl_max_time- Add maximum time filter (e.g.,"now"for up to current time)Example:
Backend Options
Default values when instantiating the backend (similar to Splunk's
-Oflag) - apply to all rules unless overridden by custom attributes:custom_logsource- Override auto-generated index patterns globallymin_time/max_time- Add time filters to all queries for performance optimizationExample:
Priority system: YAML custom attributes > Backend options > Default values
Acknowledgments
Special thanks to @VladNastase for guidance.