capa
capa copied to clipboard
`lint.py` raises exception on empty YAML files
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
.ymlfile 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
/assign