mirror of
https://github.com/mandiant/capa.git
synced 2025-12-22 15:16:22 -08:00
@@ -49,7 +49,8 @@ class NameCasing(Lint):
|
|||||||
|
|
||||||
class FilenameDoesntMatchRuleName(Lint):
|
class FilenameDoesntMatchRuleName(Lint):
|
||||||
name = "filename doesn't match the rule name"
|
name = "filename doesn't match the rule name"
|
||||||
recommendation = 'Rename rule file to match the rule name, expected: "{:s}", found: "{:s}"'
|
recommendation = "Rename rule file to match the rule name"
|
||||||
|
recommendation_template = 'Rename rule file to match the rule name, expected: "{:s}", found: "{:s}"'
|
||||||
|
|
||||||
def check_rule(self, ctx, rule):
|
def check_rule(self, ctx, rule):
|
||||||
expected = rule.name
|
expected = rule.name
|
||||||
@@ -64,7 +65,7 @@ class FilenameDoesntMatchRuleName(Lint):
|
|||||||
|
|
||||||
found = os.path.basename(rule.meta["capa/path"])
|
found = os.path.basename(rule.meta["capa/path"])
|
||||||
|
|
||||||
self.recommendation = self.recommendation.format(expected, found)
|
self.recommendation = self.recommendation_template.format(expected, found)
|
||||||
|
|
||||||
return expected != found
|
return expected != found
|
||||||
|
|
||||||
@@ -201,7 +202,8 @@ class DoesntMatchExample(Lint):
|
|||||||
|
|
||||||
class UnusualMetaField(Lint):
|
class UnusualMetaField(Lint):
|
||||||
name = "unusual meta field"
|
name = "unusual meta field"
|
||||||
recommendation = 'Remove the meta field: "{:s}"'
|
recommendation = "Remove the meta field"
|
||||||
|
recommendation_template = 'Remove the meta field: "{:s}"'
|
||||||
|
|
||||||
def check_rule(self, ctx, rule):
|
def check_rule(self, ctx, rule):
|
||||||
for key in rule.meta.keys():
|
for key in rule.meta.keys():
|
||||||
@@ -209,7 +211,7 @@ class UnusualMetaField(Lint):
|
|||||||
continue
|
continue
|
||||||
if key in capa.rules.HIDDEN_META_KEYS:
|
if key in capa.rules.HIDDEN_META_KEYS:
|
||||||
continue
|
continue
|
||||||
self.recommendation = self.recommendation.format(key)
|
self.recommendation = self.recommendation_template.format(key)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
@@ -255,7 +257,8 @@ class FeatureStringTooShort(Lint):
|
|||||||
|
|
||||||
class FeatureNegativeNumberOrOffset(Lint):
|
class FeatureNegativeNumberOrOffset(Lint):
|
||||||
name = "feature value is negative"
|
name = "feature value is negative"
|
||||||
recommendation = (
|
recommendation = "specify the number's two's complement representation"
|
||||||
|
recommendation_template = (
|
||||||
"capa treats all numbers as unsigned values; you may specify the number's two's complement "
|
"capa treats all numbers as unsigned values; you may specify the number's two's complement "
|
||||||
'representation; will not match on "{:d}"'
|
'representation; will not match on "{:d}"'
|
||||||
)
|
)
|
||||||
@@ -264,7 +267,7 @@ class FeatureNegativeNumberOrOffset(Lint):
|
|||||||
for feature in features:
|
for feature in features:
|
||||||
if isinstance(feature, (capa.features.insn.Number, capa.features.insn.Offset)):
|
if isinstance(feature, (capa.features.insn.Number, capa.features.insn.Offset)):
|
||||||
if feature.value < 0:
|
if feature.value < 0:
|
||||||
self.recommendation = self.recommendation.format(feature.value)
|
self.recommendation = self.recommendation_template.format(feature.value)
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user