You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Assuming field is a Model.Vocabulary.Field, then calling:
field.addEncodingFunction(TypeEncodingFunction(Integer))
field.addEncodingFunction(TypeEncodingFunction(HexaString))
# now there are two encoding functionsfield.str_data()
... results in the following error:
---------------------------------------------------------------------------AttributeErrorTraceback (mostrecentcalllast)
CellIn[59], line1---->1field.str_data()
File~/.pyenv/versions/3.9.18/lib/python3.9/site-packages/netzob/Common/Utils/Decorators.py:190, intypeCheck.<locals>._typeCheck_.<locals>.wrapped_f(*args, **kwargs)
184ifargumentisnotNoneandnotisinstance(argument,
185final_types[i]):
186raiseTypeError(
187"Invalid type for arguments, expecting: {0} and received {1}".
188format(', '.join([t.__name__fortinfinal_types189 ]), argument.__class__.__name__))
-->190returnfunc(*args, **kwargs)
File~/.pyenv/versions/3.9.18/lib/python3.9/site-packages/netzob/Model/Vocabulary/AbstractField.py:895, inAbstractField.str_data(self, deepness)
857 @typeCheck(int)
858defstr_data(self, deepness=0):
859"""Returns a string which shows the associated messages of the current 860 symbol/field, after applying the symbol/field definition. 861 (...) 893 894 """-->895result=self.getCells(encoded=True)
896returnstr(result)
...
File~/.pyenv/versions/3.9.18/lib/python3.9/site-packages/netzob/Model/Vocabulary/Types/BitArray.py:466, inBitArray.decode(data, unitSize, endianness, sign)
464ifdataisNone:
465raiseTypeError("data cannot be None")
-->466returndata.tobytes()
AttributeError: 'bytes'objecthasnoattribute'tobytes'
It may be a rare situation that you want to have two encoding functions, however, a twisted protocol could use a hexastring to actually represent an integer. If this should not be supported by Netzob, why can there be multiple encoding functions for one field? And if not, could you remove the option to add more than one encoding function to prevent this error? Or prevent the chaining of incompatible encoding functions?
The text was updated successfully, but these errors were encountered:
I just found some note of mine about possible (future) use cases of multiple chained encoding functions.
One use case of multiple encoding functions executed one after another, is some kind of transmission encoding, like base64:
raw bit data gets interpreted as ASCII bytewise
every three chars of the ASCII representation get encoded in 4 ASCII characters as base64
Another example would be some XOR-coding repeatedly applying to the field data an XOR with a constant value.
Thereafter, the result can be interpreted as any kind of data (Integer, ASCII, IP, Hex, ...)
Similar codings might exist.
Another use case might be to make some data more readable. E. g. a Integer could be formated with thousands-markers every three digits (like 1'000'000) with an encoding function called consecutively to the interpretation of the raw data by the Integer-encoding function. Likewise leading or trailing whitespaces or padding zeros could be hidden from the output by a encoding function further formatting either string or number data representations.
Assuming
field
is a Model.Vocabulary.Field, then calling:... results in the following error:
It may be a rare situation that you want to have two encoding functions, however, a twisted protocol could use a hexastring to actually represent an integer. If this should not be supported by Netzob, why can there be multiple encoding functions for one field? And if not, could you remove the option to add more than one encoding function to prevent this error? Or prevent the chaining of incompatible encoding functions?
The text was updated successfully, but these errors were encountered: