Merge pull request #110 from fireeye/fix/lint-windows-paths

account for Windows paths
This commit is contained in:
Willi Ballenthin
2020-07-06 07:38:19 -06:00
committed by GitHub

View File

@@ -89,7 +89,7 @@ class NamespaceDoesntMatchRulePath(Lint):
if "lib" in rule.meta:
return False
return rule.meta["namespace"] not in posixpath.normpath(rule.meta["capa/path"])
return rule.meta["namespace"] not in get_normpath(rule.meta["capa/path"])
class MissingScope(Lint):
@@ -216,7 +216,7 @@ class LibRuleNotInLibDirectory(Lint):
if "lib" not in rule.meta:
return False
return "/lib/" not in posixpath.normpath(rule.meta["capa/path"])
return "/lib/" not in get_normpath(rule.meta["capa/path"])
class LibRuleHasNamespace(Lint):
@@ -314,6 +314,10 @@ FEATURE_LINTS = (
)
def get_normpath(path):
return posixpath.normpath(path).replace(os.sep, "/")
def lint_features(ctx, rule):
features = get_features(ctx, rule)
return run_feature_lints(FEATURE_LINTS, ctx, features)