bento
bento copied to clipboard
Corrupted cache causes `bento check` failure
Overview
Ran bento check
with a corrupted cache. Bento fails to parse the cache and hard fails, telling me to run bento init --clean
which addresses a different problem.
Current Behavior
[ERROR] 2948.322057723999 root:tool_runner - Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/bento/tool.py", line 259, in results
violations = self.parser().parse(raw)
File "/usr/local/lib/python3.7/site-packages/bento/extra/bandit.py", line 201, in parse
results: Dict[str, List[Dict[str, Any]]] = json.loads(tool_output)
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/__init__.py", line 348, in loads
return _default_decoder.decode(s)
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/bento/tool_runner.py", line 261, in _setup_and_run_single_tool
results = self._run_single_tool(bar, ix, tool, baseline)
File "/usr/local/lib/python3.7/site-packages/bento/tool_runner.py", line 230, in _run_single_tool
tool.tool_id(), tool.results(self.paths, self.use_cache), baseline
File "/usr/local/lib/python3.7/site-packages/bento/tool.py", line 262, in results
f"Could not parse output of '{self.tool_id()}':\n{raw}", e
Exception: ("Could not parse output of 'bandit':\n", JSONDecodeError('Expecting value: line 1 column 1 (char 0)'))
Steps to Reproduce
- Corrupt the cache
-
bento check
Possible Solution
Add try/catch handling around cache parsing. Either notify of corrupted cache or just automatically delete the cache.
Additional Context
Bento version (run bento --version
): 0.8.0b9