Skip to content

Fix double escaping in sigma_util causing yaml.parser.ParserError #3028

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

Merged
merged 6 commits into from
Feb 1, 2024

Conversation

lo-chr
Copy link
Contributor

@lo-chr lo-chr commented Jan 28, 2024

This PR fixes the issue #3027, by simply passing the text of a sigma rule (rule_text instead of it's already escaped version doc) to sigmatools. sigmatools does the parsing and escaping of yaml by itself.

yaml.safe_load_all is still used for yaml-parsing (making sure, that the format is right) within this function, before calling the sigmatools library.

Like mentioned in the issue, the previous version led to ParserErrors, due to "double escaping" via yaml.safe_load_all in specific cases.

The PR also fixes one sigma_util.py test, which was failing mistakenly.

Checks

  • All tests succeed.
  • Unit tests added.

Closing issues
closes #3027

@jkppr jkppr self-requested a review January 30, 2024 16:25
@jkppr jkppr added the Sigma Issued related to our Sigma integration label Jan 30, 2024
Copy link
Collaborator

@jkppr jkppr left a comment

Choose a reason for hiding this comment

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

Thanks @lo-chr for raising an issue and also providing a PR to fix it. Much appreciated.

The PR looks good. We will merge it before the next release.

@jkppr jkppr merged commit 3b78ae0 into google:master Feb 1, 2024
@lo-chr lo-chr deleted the fix-sigma-import branch February 1, 2024 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Sigma Issued related to our Sigma integration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error when importing sigma rule with single quote
2 participants