Skip to content

#683 Sigma keywords field not handled correctly#725

Merged
eirsep merged 9 commits intoopensearch-project:mainfrom
jowg-amazon:keyword_bug
Nov 29, 2023
Merged

#683 Sigma keywords field not handled correctly#725
eirsep merged 9 commits intoopensearch-project:mainfrom
jowg-amazon:keyword_bug

Conversation

@jowg-amazon
Copy link
Copy Markdown
Collaborator

Description

Changes the query construction of keywords in sigma rules from (_0:"value") to ("value") to create a query string query without a designated field so that the keywords are instead matched against all the fields in a document.

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.

Signed-off-by: Joanne Wang <jowg@amazon.com>
Signed-off-by: Joanne Wang <jowg@amazon.com>
Signed-off-by: Joanne Wang <jowg@amazon.com>
Signed-off-by: Joanne Wang <jowg@amazon.com>
Signed-off-by: Joanne Wang <jowg@amazon.com>
Signed-off-by: Joanne Wang <jowg@amazon.com>
Signed-off-by: Joanne Wang <jowg@amazon.com>
Signed-off-by: Joanne Wang <jowg@amazon.com>
@jowg-amazon jowg-amazon changed the title Sigma keywords field not handled correctly #683 #683 Sigma keywords field not handled correctly Nov 22, 2023
@eirsep
Copy link
Copy Markdown
Member

eirsep commented Nov 27, 2023

Thanks for making this change @jowg-amazon.

Have we tested with a sigma rule where condition has keywords specified but the log data index has a mapping with only integer or date type fields. If it doesn't match a rule that's expected but the query should not fail with exceptions of any type mismatch.

Can you add a test to verify this scenario doens't fail and simply doesn't generate findings?

Signed-off-by: Joanne Wang <jowg@amazon.com>
" selection:\n" +
" EventID: 21\n" +
" keywords:\n" +
" - \"2020-02-04T14:59:39.343541+00:00\"\n" +
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why are we explicitly adding double quotes to the values in the conditions.. in this the data 2020-02-04T14:59:39.343541+00:00

why can't it just be

" keywords:\n" +
"        - 2020-02-04T14:59:39.343541+00:00\n" +

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

We don't support 2020-02-04T14:59:39.343541+00:00 itself as a field even for non keywords values. I think date types have to be surrounded by either single or double quotes otherwise it throws a parsing exception.

@eirsep eirsep merged commit 43040d6 into opensearch-project:main Nov 29, 2023
opensearch-trigger-bot bot pushed a commit that referenced this pull request Nov 29, 2023
* changed windows sample rule and query construction

Signed-off-by: Joanne Wang <jowg@amazon.com>

* remove wildcard

Signed-off-by: Joanne Wang <jowg@amazon.com>

* changed wildcardtest

Signed-off-by: Joanne Wang <jowg@amazon.com>

* fixed wildcards

Signed-off-by: Joanne Wang <jowg@amazon.com>

* fixed wildcard query test

Signed-off-by: Joanne Wang <jowg@amazon.com>

* fixed correlation engine tests

Signed-off-by: Joanne Wang <jowg@amazon.com>

* fixed query backend tests

Signed-off-by: Joanne Wang <jowg@amazon.com>

* clean up

Signed-off-by: Joanne Wang <jowg@amazon.com>

* added two integration tests

Signed-off-by: Joanne Wang <jowg@amazon.com>

---------

Signed-off-by: Joanne Wang <jowg@amazon.com>
(cherry picked from commit 43040d6)
@opensearch-trigger-bot
Copy link
Copy Markdown
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-725-to-2.11
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 43040d6c8c6685c5bd484f736d76ed3367f4e8c4
# Push it to GitHub
git push --set-upstream origin backport/backport-725-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-725-to-2.11.

@opensearch-trigger-bot
Copy link
Copy Markdown
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-725-to-2.7
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 43040d6c8c6685c5bd484f736d76ed3367f4e8c4
# Push it to GitHub
git push --set-upstream origin backport/backport-725-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-725-to-2.7.

@opensearch-trigger-bot
Copy link
Copy Markdown
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-725-to-2.9
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 43040d6c8c6685c5bd484f736d76ed3367f4e8c4
# Push it to GitHub
git push --set-upstream origin backport/backport-725-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-725-to-2.9.

@opensearch-trigger-bot
Copy link
Copy Markdown
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-725-to-2.5
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 43040d6c8c6685c5bd484f736d76ed3367f4e8c4
# Push it to GitHub
git push --set-upstream origin backport/backport-725-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-725-to-2.5.

@opensearch-trigger-bot
Copy link
Copy Markdown
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-725-to-2.8
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 43040d6c8c6685c5bd484f736d76ed3367f4e8c4
# Push it to GitHub
git push --set-upstream origin backport/backport-725-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-725-to-2.8.

@opensearch-trigger-bot
Copy link
Copy Markdown
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-725-to-2.6
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 43040d6c8c6685c5bd484f736d76ed3367f4e8c4
# Push it to GitHub
git push --set-upstream origin backport/backport-725-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-725-to-2.6.

@opensearch-trigger-bot
Copy link
Copy Markdown
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-725-to-2.10
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 43040d6c8c6685c5bd484f736d76ed3367f4e8c4
# Push it to GitHub
git push --set-upstream origin backport/backport-725-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-725-to-2.10.

jowg-amazon added a commit that referenced this pull request Jan 17, 2024
* changed windows sample rule and query construction

Signed-off-by: Joanne Wang <jowg@amazon.com>

* remove wildcard

Signed-off-by: Joanne Wang <jowg@amazon.com>

* changed wildcardtest

Signed-off-by: Joanne Wang <jowg@amazon.com>

* fixed wildcards

Signed-off-by: Joanne Wang <jowg@amazon.com>

* fixed wildcard query test

Signed-off-by: Joanne Wang <jowg@amazon.com>

* fixed correlation engine tests

Signed-off-by: Joanne Wang <jowg@amazon.com>

* fixed query backend tests

Signed-off-by: Joanne Wang <jowg@amazon.com>

* clean up

Signed-off-by: Joanne Wang <jowg@amazon.com>

* added two integration tests

Signed-off-by: Joanne Wang <jowg@amazon.com>

---------

Signed-off-by: Joanne Wang <jowg@amazon.com>
(cherry picked from commit 43040d6)

Co-authored-by: Joanne Wang <109310487+jowg-amazon@users.noreply.github.com>
jowg-amazon added a commit that referenced this pull request Mar 11, 2024
* * changed windows sample rule and query construction

Signed-off-by: Joanne Wang <jowg@amazon.com>

* remove wildcard

Signed-off-by: Joanne Wang <jowg@amazon.com>

* changed wildcardtest

Signed-off-by: Joanne Wang <jowg@amazon.com>

* fixed wildcards

Signed-off-by: Joanne Wang <jowg@amazon.com>

* fixed wildcard query test

Signed-off-by: Joanne Wang <jowg@amazon.com>

* fixed correlation engine tests

Signed-off-by: Joanne Wang <jowg@amazon.com>

* fixed query backend tests

Signed-off-by: Joanne Wang <jowg@amazon.com>

* clean up

Signed-off-by: Joanne Wang <jowg@amazon.com>

* added two integration tests

Signed-off-by: Joanne Wang <jowg@amazon.com>

---------

Signed-off-by: Joanne Wang <jowg@amazon.com>

* fix integTest

Signed-off-by: Joanne Wang <jowg@amazon.com>

---------

Signed-off-by: Joanne Wang <jowg@amazon.com>
jowg-amazon added a commit that referenced this pull request Mar 11, 2024
* * changed windows sample rule and query construction

Signed-off-by: Joanne Wang <jowg@amazon.com>

* remove wildcard

Signed-off-by: Joanne Wang <jowg@amazon.com>

* changed wildcardtest

Signed-off-by: Joanne Wang <jowg@amazon.com>

* fixed wildcards

Signed-off-by: Joanne Wang <jowg@amazon.com>

* fixed wildcard query test

Signed-off-by: Joanne Wang <jowg@amazon.com>

* fixed correlation engine tests

Signed-off-by: Joanne Wang <jowg@amazon.com>

* fixed query backend tests

Signed-off-by: Joanne Wang <jowg@amazon.com>

* clean up

Signed-off-by: Joanne Wang <jowg@amazon.com>

* added two integration tests

Signed-off-by: Joanne Wang <jowg@amazon.com>

---------

Signed-off-by: Joanne Wang <jowg@amazon.com>

* fix integ test

Signed-off-by: Joanne Wang <jowg@amazon.com>

---------

Signed-off-by: Joanne Wang <jowg@amazon.com>
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