mirror of
https://github.com/mandiant/capa.git
synced 2026-01-07 10:50:37 -08:00
@@ -6,6 +6,7 @@ Usage:
|
||||
$ python scripts/lint.py rules/
|
||||
'''
|
||||
import os
|
||||
import os.path
|
||||
import sys
|
||||
import string
|
||||
import hashlib
|
||||
@@ -39,6 +40,25 @@ class NameCasing(Lint):
|
||||
rule.name[1] not in string.ascii_uppercase)
|
||||
|
||||
|
||||
class FilenameDoesntMatchRuleName(Lint):
|
||||
name = 'filename doesn\'t match the rule name'
|
||||
recommendation = 'Rename rule file to match the rule name'
|
||||
|
||||
def check_rule(self, ctx, rule):
|
||||
expected = rule.name
|
||||
expected = expected.lower()
|
||||
expected = expected.replace(" ", "-")
|
||||
expected = expected.replace("(", "")
|
||||
expected = expected.replace(")", "")
|
||||
expected = expected.replace("+", "")
|
||||
expected = expected.replace("/", "")
|
||||
expected = expected + ".yml"
|
||||
|
||||
found = os.path.basename(rule.meta['capa/path'])
|
||||
|
||||
return expected != found
|
||||
|
||||
|
||||
class MissingNamespace(Lint):
|
||||
name = 'missing rule namespace'
|
||||
recommendation = 'Add meta.namespace so that the rule is emitted correctly'
|
||||
@@ -172,6 +192,7 @@ def run_feature_lints(lints, ctx, features):
|
||||
|
||||
NAME_LINTS = (
|
||||
NameCasing(),
|
||||
FilenameDoesntMatchRuleName(),
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user