Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nray-output.json is malformatted JSON #20

Open
MexHigh opened this issue Apr 12, 2023 · 3 comments
Open

nray-output.json is malformatted JSON #20

MexHigh opened this issue Apr 12, 2023 · 3 comments

Comments

@MexHigh
Copy link

MexHigh commented Apr 12, 2023

Example nray-output.json

{"nodeID":"e606aa76","nodeName":"e606aa76","timestamp":"2023-04-12T09:45:46.624838Z","scannername":"native-portscanner","result":{"target":"172.16.23.10","port":139,"portscan":{"target":"172.16.23.10","port":139,"open":true,"scantype":"tcpconnect","timeout":1000}}}
{"nodeID":"e606aa76","nodeName":"e606aa76","timestamp":"2023-04-12T09:45:46.624838Z","scannername":"native-portscanner","result":{"target":"172.16.23.2","port":139,"portscan":{"target":"172.16.23.2","port":139,"open":true,"scantype":"tcpconnect","timeout":1000}}}
{"nodeID":"e606aa76","nodeName":"e606aa76","timestamp":"2023-04-12T09:45:48.214239900Z","scannername":"native-portscanner","result":{"target":"172.16.23.2","port":49208,"portscan":{"target":"172.16.23.2","port":49208,"open":true,"scantype":"udp","timeout":1000}}}

Each line of the file has it's own JSON document, which for some reason makes sense, but this is a characteristic of a log file, not a JSON file. It is therefore unparsable for external software.

Is it possible that you add enclosing JSON array brackets to the file so that it can be parsed as JSON?

@edermi
Copy link
Collaborator

edermi commented Apr 12, 2023

You're right, it is rather JSONL than JSON, see https://jsonlines.org/
I made this choice because I'm ultra annoyed by malformed partial JSON (or XML or any other format) when interrupting tools. All progress is lost unless you do a deep dive in adding correct closing brackets and tags and so on. In contrast, even when Ctrl+C-ing nray, the stuff that has already been written is fully usable.

I also use jq primarily for handling the data, which works fine with JSONL. I therefore like to stick with this format, as manually enclosing it with array brackets is less of a hassle then recovering a broken JSON structure.

@MexHigh
Copy link
Author

MexHigh commented Apr 13, 2023

Well this makes sense. Thanks for the clarification. Is there any way to "announce" this in the (default) filename itself, e.g. by its extension? Is there a well-known .jsonl extenstion?

@edermi
Copy link
Collaborator

edermi commented Apr 14, 2023

Honestly I never did a deep dive on the topic.

Technically nothing prevents you from giving your output another file extension, it's a setting in the config file. The documentation may be more clear on this topic, I'll take this feedback with me and try to come up with improvements the next time working on the code base.

I'll leave the ticket open until then, thanks for your feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants