mirror of
https://github.com/mandiant/capa.git
synced 2026-01-10 04:05:32 -08:00
Fix rule linter
Prevent the linter to raise an exception if `examples` is `None`, as it for example currently happens in: `capa-rules/nursery/hash-data-using-murmur2.yml` We could also remove the `examples` tag in those cases, but the linter shouldn't break in any case.
This commit is contained in:
@@ -136,10 +136,12 @@ class MissingExampleOffset(Lint):
|
||||
|
||||
def check_rule(self, ctx, rule):
|
||||
if rule.meta.get("scope") in ("function", "basic block"):
|
||||
for example in rule.meta.get("examples", []):
|
||||
if example and ":" not in example:
|
||||
logger.debug("example: %s", example)
|
||||
return True
|
||||
examples = rule.meta.get("examples")
|
||||
if isinstance(examples, list):
|
||||
for example in examples:
|
||||
if example and ":" not in example:
|
||||
logger.debug("example: %s", example)
|
||||
return True
|
||||
|
||||
|
||||
class ExampleFileDNE(Lint):
|
||||
|
||||
Reference in New Issue
Block a user