JSON mode has spurious prints in Python 3
See original GitHub issueDescription
When running CAPA in JSON mode (-j
) on a file and redirecting the output to a file, the output contains spurious lines that make the output not valid JSON.
Steps to Reproduce
capa -j <file> > out.json
python -m json.tool out.json
Expected behavior:
Pretty printed JSON.
Actual behavior:
Invalid JSON. The first three lines are:
is not an ELF
is not an ELF
is not an ELF
I think these are from the lief dependency (from SMDA):
Versions
# capa --version
capa 1.4.0
I just built from master (50d55f) so the version string appears wrong.
Additional Information
I think we just need to make sure that LIEF_ERR
goes to stderr and not stdout.
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
JSON mode has spurious prints in Python 3 · Issue #368
When running CAPA in JSON mode ( -j ) on a file and redirecting the output to a file, the output contains spurious...
Read more >Working With JSON Data in Python
In this tutorial you'll learn how to read and write JSON-encoded data using Python. You'll see hands-on examples of working with Python's built-in...
Read more >python library 'json' prints everything twice
The program is just this: import json jsonFile = open('TODO.json','r').read() print(jsonFile). This prints the string twice.
Read more >Pretty Print a JSON File in Python (6 Methods)
Learn how to use Python to pretty print a JSON object, including from a file, from an API, and how to save the...
Read more >Changelog — Python 3.11.1 documentation
Paths are no longer encoded to UTF-8/strict to avoid encoding errors if it contains surrogate characters (bytes paths are decoded with the surrogateescape...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
https://github.com/danielplohmann/smda/pull/19
Fixed when using LIEF master. There’s no tagged release yet though so users will encounter this unless they are also using LIEF master.