linter: learn to check for unusual meta fields

closes #24
This commit is contained in:
William Ballenthin
2020-06-26 18:31:52 -06:00
parent 8f5f5b329d
commit f82e453440

View File

@@ -183,6 +183,22 @@ class DoesntMatchExample(Lint):
return True
class UnusualMetaField(Lint):
name = 'unusual meta field'
recommendation = 'Remove the unusual meta field'
def check_rule(self, ctx, rule):
for key in rule.meta.keys():
if key in capa.rules.META_KEYS:
continue
if key in capa.rules.HIDDEN_META_KEYS:
continue
logger.debug("unusual meta field: %s", key)
return True
return False
class FeatureStringTooShort(Lint):
name = 'feature string too short'
recommendation = 'capa only extracts strings with length >= 4; will not match on "{:s}"'
@@ -235,6 +251,7 @@ META_LINTS = (
MissingExamples(),
MissingExampleOffset(),
ExampleFileDNE(),
UnusualMetaField(),
)