Seed

class tritondse.seed.CompositeData(argv: List[bytes] = <factory>, files: Dict[str, bytes] = <factory>, variables: Dict[str, bytes] = <factory>)[source]

Bases: object

__annotations__ = {'argv': typing.List[bytes], 'files': typing.Dict[str, bytes], 'variables': typing.Dict[str, bytes]}
__bytes__() bytes[source]

Serialize data into a json string.

Returns:

JSON serialized data

__dataclass_fields__ = {'argv': Field(name='argv',type=typing.List[bytes],default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'list'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'files': Field(name='files',type=typing.Dict[str, bytes],default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'dict'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'variables': Field(name='variables',type=typing.Dict[str, bytes],default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'dict'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD)}
__dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=True)
__delattr__(name)

Implement delattr(self, name).

__dict__ = mappingproxy({'__module__': 'tritondse.seed', '__annotations__': {'argv': typing.List[bytes], 'files': typing.Dict[str, bytes], 'variables': typing.Dict[str, bytes]}, '_to_json': <function CompositeData._to_json>, '__bytes__': <function CompositeData.__bytes__>, 'from_dict': <staticmethod(<function CompositeData.from_dict>)>, '__hash__': <function CompositeData.__hash__>, '__dict__': <attribute '__dict__' of 'CompositeData' objects>, '__weakref__': <attribute '__weakref__' of 'CompositeData' objects>, '__doc__': 'CompositeData(argv: List[bytes] = <factory>, files: Dict[str, bytes] = <factory>, variables: Dict[str, bytes] = <factory>)', '__dataclass_params__': _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=True), '__dataclass_fields__': {'argv': Field(name='argv',type=typing.List[bytes],default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'list'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'files': Field(name='files',type=typing.Dict[str, bytes],default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'dict'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD), 'variables': Field(name='variables',type=typing.Dict[str, bytes],default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'dict'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),kw_only=False,_field_type=_FIELD)}, '__init__': <function CompositeData.__init__>, '__repr__': <function CompositeData.__repr__>, '__eq__': <function CompositeData.__eq__>, '__setattr__': <function CompositeData.__setattr__>, '__delattr__': <function CompositeData.__delattr__>, '__match_args__': ('argv', 'files', 'variables')})
__eq__(other)

Return self==value.

__hash__()[source]

Return hash(self).

__init__(argv: ~typing.List[bytes] = <factory>, files: ~typing.Dict[str, bytes] = <factory>, variables: ~typing.Dict[str, bytes] = <factory>) None
__match_args__ = ('argv', 'files', 'variables')
__module__ = 'tritondse.seed'
__repr__()

Return repr(self).

__setattr__(name, value)

Implement setattr(self, name, value).

__weakref__

list of weak references to the object

argv: List[bytes]

list of argv values

files: Dict[str, bytes]

dictionary of files and the associated content (stdin is one of them)

static from_dict(json_data: dict) CompositeData[source]

Convert dict data into a CompositeData object.

Parameters:

json_data – json data

Returns:

new object instance

variables: Dict[str, bytes]

user defined variables, that the use must take care to inject at right location

class tritondse.seed.Seed(content: bytes | CompositeData = b'', status=SeedStatus.NEW)[source]

Bases: object

Seed input. Holds the bytes buffer of the content a status after execution but also some metadata of code portions it is meant to cover.

Parameters:
  • content (bytes) – content of the input. By default is b”” (and is thus considered as a bootstrap seed)

  • status (SeedStatus) – status of the seed if already known

__bytes__() bytes[source]

Return a representation of the seed’s content in bytes.

Return type:

bytes

__dict__ = mappingproxy({'__module__': 'tritondse.seed', '__doc__': '\n    Seed input.\n    Holds the bytes buffer of the content a status after execution\n    but also some metadata of code portions it is meant to cover.\n    ', '__init__': <function Seed.__init__>, 'is_composite': <function Seed.is_composite>, 'is_raw': <function Seed.is_raw>, 'is_bootstrap_seed': <function Seed.is_bootstrap_seed>, 'is_fresh': <function Seed.is_fresh>, 'status': <property object>, 'format': <property object>, 'is_status_set': <function Seed.is_status_set>, '__len__': <function Seed.__len__>, '__eq__': <function Seed.__eq__>, 'bytes': <function Seed.bytes>, '__bytes__': <function Seed.__bytes__>, '__hash__': <function Seed.__hash__>, 'hash': <property object>, 'size': <property object>, 'filename': <property object>, 'from_bytes': <staticmethod(<function Seed.from_bytes>)>, 'from_file': <staticmethod(<function Seed.from_file>)>, 'is_file_defined': <function Seed.is_file_defined>, 'get_file_input': <function Seed.get_file_input>, '__dict__': <attribute '__dict__' of 'Seed' objects>, '__weakref__': <attribute '__weakref__' of 'Seed' objects>, '__annotations__': {}})
__eq__(other) bool[source]

Equality check based on content.

Returns:

true if content of both seeds are equal

__hash__()[source]

Seed hash function overriden to base itself on content. That enable storing seed in dictionaries directly based on their content to discriminate them.

Return type:

int

__init__(content: bytes | CompositeData = b'', status=SeedStatus.NEW)[source]
Parameters:
  • content (bytes) – content of the input. By default is b”” (and is thus considered as a bootstrap seed)

  • status (SeedStatus) – status of the seed if already known

__len__() int[source]

Size of the content of the seed.

Return type:

int

__module__ = 'tritondse.seed'
__weakref__

list of weak references to the object

bytes() bytes[source]
property filename

Standardized filename based on hash and size. That does not mean the file exists or anything.

Returns:

formatted intended filename of the seed

Return type:

str

property format: SeedFormat

Format of the seed.

Return type:

SeedFormat

static from_bytes(raw_seed: bytes, status: SeedStatus = SeedStatus.NEW) Seed[source]

Parse a seed from its byte representation. If it’s a composite one it will parse the bytes as JSON and create the CompositeData accordingly.

Parameters:
Returns:

fresh seed instance

Return type:

Seed

static from_file(path: str | Path, status: SeedStatus = SeedStatus.NEW) Seed[source]

Read a seed from a file. The status can optionally be given as it cannot be determined from the file.

Parameters:
Returns:

fresh seed instance

Return type:

Seed

get_file_input(name: str) bytes[source]

Return the bytes associated to a given file within a composite seed.

Raises:

KeyError – if the name cannot be found in the seed.

Parameters:

name – name of the file to retrieve

Returns:

bytes of the file content

property hash: str

MD5 hash of the seed content

Return type:

str

is_bootstrap_seed() bool[source]

A bootstrap seed is an empty seed (b””). It will receive a specific processing in the engine as its size will be automatically adapted to the size read (in stdin for instance)

Returns:

true if the seed is a bootstrap seed

is_composite() bool[source]

Returns whether the seed is a composite seed or not.

is_file_defined(name: str) bool[source]
is_fresh() bool[source]

A fresh seed is never been executed. Its is recognizable as it does not contain any coverage objectives.

Returns:

True if the seed has never been executed

is_raw() bool[source]

Returns whether the seed is a raw seed or not.

is_status_set() bool[source]

Checks whether a status has already been assigned to the seed.

property size: int

Size of the seed content in bytes

Return type:

int

property status: SeedStatus

Status of the seed.

Return type:

SeedStatus

enum tritondse.seed.SeedFormat(value)[source]

Bases: Enum

Seed format enum Raw seeds are just bytes Seed(b”AAAAABBBBB”) Composite can describe how to inject the input more precisely

Valid values are as follows:

RAW = <SeedFormat.RAW: 0>

plain bytes input seed

COMPOSITE = <SeedFormat.COMPOSITE: 1>

complex input object

The Enum and its members also have the following methods:

__module__ = 'tritondse.seed'
enum tritondse.seed.SeedStatus(value)[source]

Bases: Enum

Seed status enum. Enables giving a status to a seed during its execution. At the end of a SymbolicExecutor run one of these status must have set to the seed.

Valid values are as follows:

NEW = <SeedStatus.NEW: 0>

The input seed is new (has not been executed yet)

OK_DONE = <SeedStatus.OK_DONE: 1>

The input seed has been executed and terminated correctly

CRASH = <SeedStatus.CRASH: 2>

The input seed crashed in some ways

HANG = <SeedStatus.HANG: 3>

The input seed made the program to hang

FAIL = <SeedStatus.FAIL: 4>

The input seed made the symbolic executor to raise an exception

The Enum and its members also have the following methods:

__module__ = 'tritondse.seed'