katnip.legos.json module¶
JSON legos - simplified fuzzing of JSON-based protocols
Todo
JsonNumber
-
class
katnip.legos.json.JsonArray(name, values)¶ Bases:
kitty.model.low_level.container.ContainerJSON array field
-
__init__(name, values)¶ Parameters: - name – block name
- values (list of
BaseField) – array members
-
-
class
katnip.legos.json.JsonBoolean(name, value=None, fuzzable=True)¶ Bases:
kitty.model.low_level.container.ContainerJSON boolean field
-
__init__(name, value=None, fuzzable=True)¶ Parameters: - name – block name
- value (bool) – value to be used, if None - generate both ‘true’ and ‘false’ (default: None)
- fuzzable – should we fuzz this field (only if value is not None) (default: True)
-
-
class
katnip.legos.json.JsonNull(name, fuzzable=False)¶ Bases:
kitty.model.low_level.container.ContainerJSON Null field
-
__init__(name, fuzzable=False)¶ Parameters: - name – block name
- fuzzable – should we fuzz this field (default: False)
-
-
class
katnip.legos.json.JsonObject(name, member_dict, fuzz_keys=False)¶ Bases:
kitty.model.low_level.container.ContainerJSON object
-
__init__(name, member_dict, fuzz_keys=False)¶ Parameters: - name – block name
- member_dict (dictionary (str,
BaseField)) – members of this object - fuzz_keys – should we fuzz the dictionary keys (default: False)
-
-
class
katnip.legos.json.JsonString(name, value, fuzzable=True)¶ Bases:
kitty.model.low_level.container.ContainerJSON string field
-
__init__(name, value, fuzzable=True)¶ Parameters: - name – block name
- value – value to be used
- fuzzable – should we fuzz this field (default: True)
-
-
katnip.legos.json.dict_to_JsonObject(the_dict, name=None, ctx=None)¶ Create a JsonObject from a dictionary. The context parameter is used for recursive calls, no need to pass it from outside.
Parameters: - the_dict – dictionary to base the JsonObject on
- ctx – context for the parser (default: None)
Return type: Returns: JSON object that represents the dictionary
-
katnip.legos.json.list_to_JsonArray(the_list, name=None, ctx=None)¶ Create a JsonArray from a list. The context parameter is used for recursive calls, no need to pass it from outside.
Parameters: - the_list – list to base the JsonArray on
- ctx – context for the parser (default: None)
Return type: Returns: JSON object that represents the list
-
katnip.legos.json.str_to_json(json_str, name=None)¶ Create a JSON lego based on a json string.
Parameters: - name – name of the generated container
- json_str – json string to base the template on
Return type: Returns: JSON object or JSON array.