fix: remove dead except ValueError clause in capa2sarif.py so JSONDecodeError is caught correctly

json.JSONDecodeError is a subclass of ValueError, so the broader except ValueError
was shadowing the more specific handler, making it unreachable. Keep only the
specific except json.JSONDecodeError handler.
This commit is contained in:
Willi Ballenthin
2026-04-22 22:26:13 +03:00
committed by Willi Ballenthin
parent 7d8714098c
commit 7a8a0acaa9
3 changed files with 9 additions and 5 deletions
+1 -5
View File
@@ -93,13 +93,9 @@ def main() -> int:
try:
json_data = json.loads(Path(args.capa_output).read_text(encoding="utf-8"))
except ValueError:
except json.JSONDecodeError:
logger.error("Input data was not valid JSON, input should be a capa json output file.")
return -1
except json.JSONDecodeError:
# An exception has occured
logger.error("Input data was not valid JSON, input should be a capa json output file.")
return -2
# Marshall json into Sarif
# Create baseline sarif structure to be populated from json data