adding support for string features with special characters e.g. '\n'

This commit is contained in:
Michael Hunhoff
2021-03-10 13:49:10 -07:00
parent 06c958f081
commit c7d24ee290
2 changed files with 23 additions and 1 deletions

View File

@@ -681,6 +681,24 @@ def test_explicit_string_values_int():
assert (String("0x123") in children) == True
def test_string_values_special_characters():
rule = textwrap.dedent(
"""
rule:
meta:
name: test rule
features:
- or:
- string: hello\\r\\nworld
- string: some\\path
"""
)
r = capa.rules.Rule.from_yaml(rule)
children = list(r.statement.get_children())
assert (String("hello\r\nworld") in children) == True
assert (String("some\\path") in children) == True
def test_regex_values_always_string():
rules = [
capa.rules.Rule.from_yaml(