mirror of
https://github.com/mandiant/capa.git
synced 2026-06-12 19:11:32 -07:00
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:
committed by
Willi Ballenthin
parent
7d8714098c
commit
7a8a0acaa9
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user