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

fix null query filter conversion from sigma to query string query #722

Merged
merged 3 commits into from
Nov 29, 2023

Conversation

eirsep
Copy link
Member

@eirsep eirsep commented Nov 21, 2023

Description

Null filters in Sigma rules are not translated properly to queries leading to False Positives and broken detections.
They are being treated as term query to match field to value "null" instead of checking if value is nullable or field not exists.
This change fixes the query string query for the null filter conversion from sigma to backend search query

Issues Resolved

#683

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Copy link

codecov bot commented Nov 21, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (43040d6) 24.72% compared to head (bb591fe) 24.76%.

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #722      +/-   ##
============================================
+ Coverage     24.72%   24.76%   +0.03%     
- Complexity     1017     1021       +4     
============================================
  Files           275      275              
  Lines         12663    12663              
  Branches       1389     1389              
============================================
+ Hits           3131     3136       +5     
+ Misses         9264     9261       -3     
+ Partials        268      266       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

jowg-amazon
jowg-amazon previously approved these changes Nov 28, 2023
@eirsep eirsep merged commit a59a014 into opensearch-project:main Nov 29, 2023
14 of 16 checks passed
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.10 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.10 2.10
# Navigate to the new working tree
cd .worktrees/backport-2.10
# Create a new branch
git switch --create backport/backport-722-to-2.10
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 a59a014467bf1dde7cb40f9d8012545a315cddff
# Push it to GitHub
git push --set-upstream origin backport/backport-722-to-2.10
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.10

Then, create a pull request where the base branch is 2.10 and the compare/head branch is backport/backport-722-to-2.10.

@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.8 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.8 2.8
# Navigate to the new working tree
cd .worktrees/backport-2.8
# Create a new branch
git switch --create backport/backport-722-to-2.8
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 a59a014467bf1dde7cb40f9d8012545a315cddff
# Push it to GitHub
git push --set-upstream origin backport/backport-722-to-2.8
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.8

Then, create a pull request where the base branch is 2.8 and the compare/head branch is backport/backport-722-to-2.8.

@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.9 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.9 2.9
# Navigate to the new working tree
cd .worktrees/backport-2.9
# Create a new branch
git switch --create backport/backport-722-to-2.9
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 a59a014467bf1dde7cb40f9d8012545a315cddff
# Push it to GitHub
git push --set-upstream origin backport/backport-722-to-2.9
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.9

Then, create a pull request where the base branch is 2.9 and the compare/head branch is backport/backport-722-to-2.9.

@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.6 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.6 2.6
# Navigate to the new working tree
cd .worktrees/backport-2.6
# Create a new branch
git switch --create backport/backport-722-to-2.6
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 a59a014467bf1dde7cb40f9d8012545a315cddff
# Push it to GitHub
git push --set-upstream origin backport/backport-722-to-2.6
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.6

Then, create a pull request where the base branch is 2.6 and the compare/head branch is backport/backport-722-to-2.6.

@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.x 2.x
# Navigate to the new working tree
cd .worktrees/backport-2.x
# Create a new branch
git switch --create backport/backport-722-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 a59a014467bf1dde7cb40f9d8012545a315cddff
# Push it to GitHub
git push --set-upstream origin backport/backport-722-to-2.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-722-to-2.x.

@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.11 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.11 2.11
# Navigate to the new working tree
cd .worktrees/backport-2.11
# Create a new branch
git switch --create backport/backport-722-to-2.11
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 a59a014467bf1dde7cb40f9d8012545a315cddff
# Push it to GitHub
git push --set-upstream origin backport/backport-722-to-2.11
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.11

Then, create a pull request where the base branch is 2.11 and the compare/head branch is backport/backport-722-to-2.11.

@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.7 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.7 2.7
# Navigate to the new working tree
cd .worktrees/backport-2.7
# Create a new branch
git switch --create backport/backport-722-to-2.7
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 a59a014467bf1dde7cb40f9d8012545a315cddff
# Push it to GitHub
git push --set-upstream origin backport/backport-722-to-2.7
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.7

Then, create a pull request where the base branch is 2.7 and the compare/head branch is backport/backport-722-to-2.7.

@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.5 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.5 2.5
# Navigate to the new working tree
cd .worktrees/backport-2.5
# Create a new branch
git switch --create backport/backport-722-to-2.5
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 a59a014467bf1dde7cb40f9d8012545a315cddff
# Push it to GitHub
git push --set-upstream origin backport/backport-722-to-2.5
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.5

Then, create a pull request where the base branch is 2.5 and the compare/head branch is backport/backport-722-to-2.5.

eirsep added a commit to eirsep/security-analytics that referenced this pull request Nov 30, 2023
…ensearch-project#722)

* fix null query filter conversion from sigma to query string query

Signed-off-by: Surya Sashank Nistala <[email protected]>

* fix rule to query conversion tests for null filter

Signed-off-by: Surya Sashank Nistala <[email protected]>

* enhance test to verify non null doc doesnt match null query

Signed-off-by: Surya Sashank Nistala <[email protected]>

---------

Signed-off-by: Surya Sashank Nistala <[email protected]>
eirsep added a commit that referenced this pull request Nov 30, 2023
…query string query (#743)

* fix null query filter conversion from sigma to query string query (#722)

* fix null query filter conversion from sigma to query string query

Signed-off-by: Surya Sashank Nistala <[email protected]>

* fix rule to query conversion tests for null filter

Signed-off-by: Surya Sashank Nistala <[email protected]>

* enhance test to verify non null doc doesnt match null query

Signed-off-by: Surya Sashank Nistala <[email protected]>

---------

Signed-off-by: Surya Sashank Nistala <[email protected]>

* add test to verify null filter in sigma rules

Signed-off-by: Surya Sashank Nistala <[email protected]>

---------

Signed-off-by: Surya Sashank Nistala <[email protected]>
opensearch-trigger-bot bot pushed a commit that referenced this pull request Jan 18, 2024
* fix null query filter conversion from sigma to query string query

Signed-off-by: Surya Sashank Nistala <[email protected]>

* fix rule to query conversion tests for null filter

Signed-off-by: Surya Sashank Nistala <[email protected]>

* enhance test to verify non null doc doesnt match null query

Signed-off-by: Surya Sashank Nistala <[email protected]>

---------

Signed-off-by: Surya Sashank Nistala <[email protected]>
(cherry picked from commit a59a014)
jowg-amazon pushed a commit that referenced this pull request Feb 6, 2024
…) (#813)

* fix null query filter conversion from sigma to query string query

Signed-off-by: Surya Sashank Nistala <[email protected]>

* fix rule to query conversion tests for null filter

Signed-off-by: Surya Sashank Nistala <[email protected]>

* enhance test to verify non null doc doesnt match null query

Signed-off-by: Surya Sashank Nistala <[email protected]>

---------

Signed-off-by: Surya Sashank Nistala <[email protected]>
(cherry picked from commit a59a014)

Co-authored-by: Surya Sashank Nistala <[email protected]>
eirsep added a commit to eirsep/security-analytics that referenced this pull request Mar 13, 2024
…ensearch-project#722) (opensearch-project#813)

* fix null query filter conversion from sigma to query string query

Signed-off-by: Surya Sashank Nistala <[email protected]>

* fix rule to query conversion tests for null filter

Signed-off-by: Surya Sashank Nistala <[email protected]>

* enhance test to verify non null doc doesnt match null query

Signed-off-by: Surya Sashank Nistala <[email protected]>

---------

Signed-off-by: Surya Sashank Nistala <[email protected]>
(cherry picked from commit a59a014)

Co-authored-by: Surya Sashank Nistala <[email protected]>
@eirsep eirsep mentioned this pull request Mar 13, 2024
eirsep added a commit to eirsep/security-analytics that referenced this pull request Mar 13, 2024
…ensearch-project#722) (opensearch-project#813)

* fix null query filter conversion from sigma to query string query

Signed-off-by: Surya Sashank Nistala <[email protected]>

* fix rule to query conversion tests for null filter

Signed-off-by: Surya Sashank Nistala <[email protected]>

* enhance test to verify non null doc doesnt match null query

Signed-off-by: Surya Sashank Nistala <[email protected]>

---------

Signed-off-by: Surya Sashank Nistala <[email protected]>
(cherry picked from commit a59a014)

Co-authored-by: Surya Sashank Nistala <[email protected]>
engechas pushed a commit to engechas/security-analytics that referenced this pull request Mar 14, 2024
…ensearch-project#722)

* fix null query filter conversion from sigma to query string query

Signed-off-by: Surya Sashank Nistala <[email protected]>

* fix rule to query conversion tests for null filter

Signed-off-by: Surya Sashank Nistala <[email protected]>

* enhance test to verify non null doc doesnt match null query

Signed-off-by: Surya Sashank Nistala <[email protected]>

---------

Signed-off-by: Surya Sashank Nistala <[email protected]>
@engechas engechas mentioned this pull request Mar 15, 2024
5 tasks
goyamegh pushed a commit to goyamegh/security-analytics that referenced this pull request Mar 15, 2024
…ensearch-project#722)

* fix null query filter conversion from sigma to query string query

Signed-off-by: Surya Sashank Nistala <[email protected]>

* fix rule to query conversion tests for null filter

Signed-off-by: Surya Sashank Nistala <[email protected]>

* enhance test to verify non null doc doesnt match null query

Signed-off-by: Surya Sashank Nistala <[email protected]>

---------

Signed-off-by: Surya Sashank Nistala <[email protected]>
engechas added a commit that referenced this pull request Mar 15, 2024
* query_field_names bugfix (#335)

Signed-off-by: Petar Dzepina <[email protected]>

* Reduce log level for informative message (#203)

Signed-off-by: Enrico Tröger <[email protected]>

* fix detector writeTo() method missing fields (#695)

* fix detector writeTo() method missing fields

Signed-off-by: Surya Sashank Nistala <[email protected]>

* fix test

Signed-off-by: Surya Sashank Nistala <[email protected]>

---------

Signed-off-by: Surya Sashank Nistala <[email protected]>

* fix null query filter conversion from sigma to query string query (#722)

* fix null query filter conversion from sigma to query string query

Signed-off-by: Surya Sashank Nistala <[email protected]>

* fix rule to query conversion tests for null filter

Signed-off-by: Surya Sashank Nistala <[email protected]>

* enhance test to verify non null doc doesnt match null query

Signed-off-by: Surya Sashank Nistala <[email protected]>

---------

Signed-off-by: Surya Sashank Nistala <[email protected]>

* Bump version 2.5.1, fix build

Signed-off-by: Chase Engelbrecht <[email protected]>

* Manual cherry-pick of #873

Signed-off-by: Chase Engelbrecht <[email protected]>

* Fix miss from manual cherry-pick

Signed-off-by: Chase Engelbrecht <[email protected]>

* Undo exceptional case not originally present

Signed-off-by: Chase Engelbrecht <[email protected]>

* Revert test from previous commit reversion

Signed-off-by: Chase Engelbrecht <[email protected]>

* Fix another miss from manual cherry-pick

Signed-off-by: Chase Engelbrecht <[email protected]>

* Revert behavior for no rules in detector

Signed-off-by: Chase Engelbrecht <[email protected]>

---------

Signed-off-by: Petar Dzepina <[email protected]>
Signed-off-by: Enrico Tröger <[email protected]>
Signed-off-by: Surya Sashank Nistala <[email protected]>
Signed-off-by: Chase Engelbrecht <[email protected]>
Co-authored-by: Petar Dzepina <[email protected]>
Co-authored-by: Enrico Tröger <[email protected]>
Co-authored-by: Surya Sashank Nistala <[email protected]>
@toepkerd toepkerd mentioned this pull request Mar 19, 2024
5 tasks
engechas pushed a commit that referenced this pull request Mar 19, 2024
* Version bump to 2.7.1

Signed-off-by: Megha Goyal <[email protected]>

* fix detector writeTo() method missing fields (#695)

* fix detector writeTo() method missing fields

Signed-off-by: Surya Sashank Nistala <[email protected]>

* fix test

Signed-off-by: Surya Sashank Nistala <[email protected]>

---------

Signed-off-by: Surya Sashank Nistala <[email protected]>

* fix null query filter conversion from sigma to query string query (#722)

* fix null query filter conversion from sigma to query string query

Signed-off-by: Surya Sashank Nistala <[email protected]>

* fix rule to query conversion tests for null filter

Signed-off-by: Surya Sashank Nistala <[email protected]>

* enhance test to verify non null doc doesnt match null query

Signed-off-by: Surya Sashank Nistala <[email protected]>

---------

Signed-off-by: Surya Sashank Nistala <[email protected]>

* * #709 Return empty response for empty mappings and no applied aliases

Signed-off-by: Megha Goyal <[email protected]>

* Adding integ tests for empty mappings/aliases use-cases

Signed-off-by: Megha Goyal <[email protected]>

* Fix unit tests for MappingsTraverser

Signed-off-by: Megha Goyal <[email protected]>

---------

Signed-off-by: Megha Goyal <[email protected]>

* fixing build failures for previous cherry-pick PR for SAP2.7 (to be squashed)

Signed-off-by: Dennis Toepker <[email protected]>

* Pass rule field names in doc level queries during monitor/creation. Remove blocking actionGet() calls  (#873)

* pass query field names in doc level queries during monitor creation/updation

Signed-off-by: Surya Sashank Nistala <[email protected]>

* remove actionGet() and change get index mapping call to event driven flow

Signed-off-by: Surya Sashank Nistala <[email protected]>

* fix chained findings monitor

Signed-off-by: Surya Sashank Nistala <[email protected]>

* add finding mappings

Signed-off-by: Surya Sashank Nistala <[email protected]>

* remove test messages from logs

Signed-off-by: Surya Sashank Nistala <[email protected]>

* revert build.gradle change

Signed-off-by: Surya Sashank Nistala <[email protected]>

---------

Signed-off-by: Surya Sashank Nistala <[email protected]>

* fixing an import

Signed-off-by: Dennis Toepker <[email protected]>

---------

Signed-off-by: Megha Goyal <[email protected]>
Signed-off-by: Surya Sashank Nistala <[email protected]>
Signed-off-by: Dennis Toepker <[email protected]>
Co-authored-by: Megha Goyal <[email protected]>
Co-authored-by: Surya Sashank Nistala <[email protected]>
Co-authored-by: Megha Goyal <[email protected]>
Co-authored-by: Dennis Toepker <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants