Closed SteveClement closed 3 years ago
Hmmm, I'll normalize the examples: it returns a python dictionary.
I confirm this mis-behavior described by @SteveClement and can reproduce it.
@Rafiot , I'm not sure if by saying "you'll normalize the output" you mean you will do something to fix it. It would be nice if you add a Bug tag to this issue if you think this is a bug (I do). Thank you.
And, by the way: the issue's subject is wrong.
Most (all?) examples return valid json. The problem seems only be associated with the edit_user.py
example
The correct issue subject would be "Example edit-user.py produces non-compliant JSON"
Aaarg. The problem is in the example itself, i will post a fix in a few minutes.
To hot-fix:
1) add import json
at the begining of the file
2) replace the last line by print(json.dumps(misp.edit_user(args.user_id, email=args.email)))
It meant I'll do something about it when I get the time. It wasn't the case until now, and it has very low priority.
I'll gladly merge your PR.
Rafiot,
I just started to look at all the examples for more json-output fixes.
There is one parameter in PyMISP that I don't understand. What's the purpose of pythonify
?
And what's the logic behind it's default setting for various methods, meaning: why is pythonify=True
in the method definition for add_event
, but pythonify=False
in add_object_reference
?
when you pass pythonify=True
to a method, it forces it to return a python object (MISPEvent. MISPAttribute, MISPObjectReference, ...)
The default should be pythonify=False
, and I simply forgot to change it at a few places.
pythonify is normalized => https://github.com/MISP/PyMISP/commit/a6a0fcd4fbf42e1fcc2ee333ac6c61dd8e9695aa
And if you want to always pythonify the outputs, you can toggle it globally.
Is it wanted that the examples return a Python dictionary?
(doing a json.dumps() produces 'correct' JSON)
PoC: