mirror of
https://github.com/mandiant/capa.git
synced 2026-01-07 19:01:04 -08:00
@@ -82,7 +82,7 @@ def render_feature(ostream, match, feature, indent=0):
|
||||
ostream.write(rutils.bold2(feature[feature["type"]]))
|
||||
|
||||
if "description" in feature:
|
||||
ostream.write(" = ")
|
||||
ostream.write(capa.rules.DESCRIPTION_SEPARATOR)
|
||||
ostream.write(feature["description"])
|
||||
|
||||
render_locations(ostream, match)
|
||||
|
||||
@@ -207,16 +207,23 @@ def parse_feature(key):
|
||||
raise InvalidRule("unexpected statement: %s" % key)
|
||||
|
||||
|
||||
# this is the separator between a feature value and its description
|
||||
# when using the inline description syntax, like:
|
||||
#
|
||||
# number: 42 = ENUM_FAVORITE_NUMBER
|
||||
DESCRIPTION_SEPARATOR = " = "
|
||||
|
||||
|
||||
def parse_description(s, value_type, description=None):
|
||||
"""
|
||||
s can be an int or a string
|
||||
"""
|
||||
if value_type != "string" and isinstance(s, six.string_types) and " = " in s:
|
||||
if value_type != "string" and isinstance(s, six.string_types) and DESCRIPTION_SEPARATOR in s:
|
||||
if description:
|
||||
raise InvalidRule(
|
||||
'unexpected value: "%s", only one description allowed (inline description with ` = `)' % s
|
||||
'unexpected value: "%s", only one description allowed (inline description with `%s`)' % (s, DESCRIPTION_SEPARATOR)
|
||||
)
|
||||
value, _, description = s.rpartition(" = ")
|
||||
value, _, description = s.rpartition(DESCRIPTION_SEPARATOR)
|
||||
if description == "":
|
||||
raise InvalidRule('unexpected value: "%s", description cannot be empty' % s)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user