capa icon indicating copy to clipboard operation
capa copied to clipboard

`lint.py` raises exception on empty YAML files

Open CosmoWorker opened this issue 8 months ago • 1 comments

Description

When running scripts/lint.py with --thorough with a existing rule, capa raises exception and exits abruptly if it encounters an empty YAML file in rules directory. Before I ran, I created a empty file under nursery/ Error in debug mode:

capa/capa/rules/__init__.py", line 1146, in from_yaml 
    return cls.from_dict(doc, s)
File "capa/rules/__init__.py", line 1057, in from_dict
    meta = d["rule"]["meta"]
TypeError: 'NoneType' object is not subscriptable

Steps to reproduce

  • Create a empty .yml file in rules directory
  • Run python scripts/lint.py --thorough <rule.yml> --samples ../capa-testfiles

Expected Behaviour:

Maybe skipping such files or providing a better response would be helpful. Because the stack trace wasn't helpful. I had to remove the empty file to notice this issue.

I am not sure how important/useful even is this (maybe this is how it is), but thought would bring this up. Thanks

CosmoWorker avatar Mar 07 '26 20:03 CosmoWorker

/assign

Demiserular avatar Mar 08 '26 14:03 Demiserular