netzob icon indicating copy to clipboard operation
netzob copied to clipboard

New Feature: XML-Handler

Open 2cute2die opened this issue 7 years ago • 5 comments

Offers methods for saving and loading a list of Symbols inclusivly the sessions.

This Modul saves and loads a Symbol + all included data. The approach is adapted from the XML-Modul from the Netzob release 0.4.2. For every class involved there are 4 methods:

saveToXML(): Creates a XML-Node and calls XMLProperties() XMLProperties(): Adds the XML-Attributs to the Node.

loadFromXML(): Creates a Python Object out of the XML Node and calls RestoreFromXML() RestoreFromXML(): Loads the attributs from the XML Node and provieds it to the loadFromXML() Method

2cute2die avatar Oct 24 '17 14:10 2cute2die

Nice work! Could you add some doctests to cover XML dumping and loading ? This will permit to detect potential regressions and issues in some classes. Besides, this will permit to understand clearly how to use the XML API.

Sygus avatar Oct 25 '17 18:10 Sygus

Another question: is this feature similar to the symbol/message pickling ? or does it provide more coverage of the dumpable objects ?

Sygus avatar Oct 25 '17 18:10 Sygus

Could you also change the targeted branch from 'master' to 'next' ?as 'next' is the integration branch ;)

Sygus avatar Oct 25 '17 20:10 Sygus

I added some doc-tests and a little explanation on how to use it. The tests are pretty basic because it is not easy to evaluate if the XML File is ok or not. I did a lot of testing to evaluate my XML-Modul in the past, but this test scripts are not easy portable to the Netzob tests. ---> Basically there is a bug in Netzob, i call it "ParsingPath"-Error, which prevents me from generating messages to a self-created symbol with the specialize()-Method. I have an experimental Fix for this Error from the git-lab of the University Ulm but it is more like a workaround and does not solve the problem as a whole.

This is why i cant test with a Symbol with all possible extras e.g: encoding Function, with size and aggregation fields and so on.... Additionally some parts of the persisted data is randomized. For example the UIDs of the Fields are created at random coin. This is why it is not possible to compaire a correct XML-Save-File with a genereted one in the tests. But i assure you, i've tested the modul and the XML-Save-Files are okay.

So about the feature itself. It is pretty close to the XML Exporter from the Netzob Version 0.4.2. If have not studied the JSON Pickeling in detail but i think the XML Exporter is a bit better in cases of security. It should not be that easy to execute code on an machine by loading a save file, because I just load the parameters for the constructor of the python object.

If you have any additional questions feel free to contact me. But at this point I dont know how to make my work more practical are easier to understand. But i have some diagrams to show the sturcture if you need this for your documentation

2cute2die avatar Oct 31 '17 13:10 2cute2die

Thanks for the explanation. It will take a bit more time to review this PR, as it introduces lots of code (even though it is mainly related to XML-save and restore).

Sygus avatar Nov 03 '17 16:11 Sygus