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

Metadata Parsing Errors #61

Open
malvidin opened this issue Apr 4, 2023 · 1 comment
Open

Metadata Parsing Errors #61

malvidin opened this issue Apr 4, 2023 · 1 comment

Comments

@malvidin
Copy link
Contributor

malvidin commented Apr 4, 2023

In a few situations, a valid rule fails to be written (using -c or -i) with the following error:

./CCCS-Yara/yara-validator/yara_file_processor.py", line 184, in strings_of_rules_to_original_file
    changed_rule_string = rule.rule_return.validated_rule.splitlines()
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'list' object has no attribute 'splitlines'

These regular expressions appear to the cause of the issue:

meta_regex = r'^\s*meta\s*:\s*$'
next_section = r'^\s*(?:strings|condition)\s*:\s*$'

Based on these expressions:

  • meta and : must be on the same line, and be the only contents of that line.
  • The following strings or condition and : must be on the same line, and be the only contents of that line.

This breaks otherwise valid rules:

rule testing 
{ meta:
    key = "value"
  condition:
    true
}
rule testing {
  meta:
    key = "value"
  strings: $re = /test/
  condition: $re
}
rule testing 
{ meta:
    key = "value"
  condition: true
}

And on the most extreme end:

rule testing { meta: key = "value" condition: true }
@cccs-rs
Copy link
Contributor

cccs-rs commented Jul 19, 2023

I think in this case, plyara would come in handy. I have to take a look at this more in-depth to see what the original author was doing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants