pyObjectManager

Submodules

pyObjectManager.BitVec module

class pySym.pyObjectManager.BitVec.BitVec(varName, ctx, size, count=None, state=None, increment=False, value=None, uuid=None, clone=None)[source]

Bases: object

Define a BitVec

canBe(*args, **kwargs)
copy()[source]
count
ctx
getValue(*args, **kwargs)
getZ3Object(*args, **kwargs)
increment()[source]

Increment the counter

isStatic(*args, **kwargs)
is_constrained
is_unconstrained
mustBe(*args, **kwargs)
parent
setTo(var, *args, **kwargs)[source]

Sets this BitVec object to be equal/copy of another. Type can be int, or BitVec

size
state

Returns the state assigned to this object.

uuid
value
varName

pyObjectManager.Char module

class pySym.pyObjectManager.Char.Char(varName, ctx, count=None, variable=None, state=None, increment=False, uuid=None, clone=None)[source]

Bases: object

Define a Char (Character)

canBe(*args, **kwargs)
copy()[source]
count
ctx
getValue(*args, **kwargs)
getZ3Object(*args, **kwargs)
increment()[source]
isStatic(*args, **kwargs)
is_constrained
is_unconstrained
mustBe(*args, **kwargs)
parent
setTo(var, *args, **kwargs)[source]

Sets this Char to the variable. Raises exception on failure.

state

Returns the state assigned to this object.

uuid
varName
variable

pyObjectManager.Ctx module

class pySym.pyObjectManager.Ctx.Ctx(ctx, variables=None)[source]

Bases: object

Define a Ctx Object

__getitem__(index)[source]

We want to be able to do “list[x]”, so we define this.

__setitem__(key, value)[source]

Sets value at index key. Checks for variable type, updates counter according, similar to getVar call

copy()[source]
ctx
index(elm)[source]

Returns “index” of the given element. Raises exception if it’s not found For a pseudo dict class, this is just the key for the key,val pair

items()[source]
state

Returns the state assigned to this object.

variables
variables_need_copy

pyObjectManager.Int module

class pySym.pyObjectManager.Int.Int(varName, ctx, count=None, value=None, state=None, increment=False, uuid=None, clone=None)[source]

Bases: object

Define an Int

canBe(*args, **kwargs)
copy()[source]
count
ctx
getValue(*args, **kwargs)
getZ3Object(*args, **kwargs)
increment()[source]
isStatic(*args, **kwargs)
is_constrained
is_unconstrained
mustBe(*args, **kwargs)
parent
setTo(var, *args, **kwargs)[source]

Sets this Int object to be equal/copy of another. Type can be int or Int

state

Returns the state assigned to this object.

uuid
value
varName

pyObjectManager.List module

class pySym.pyObjectManager.List.List(varName, ctx, count=None, variables=None, state=None, increment=False, uuid=None)[source]

Bases: object

Define a List

__getitem__(index)[source]

We want to be able to do “list[x]”, so we define this.

__setitem__(key, value)[source]

Sets value at index key. Checks for variable type, updates counter according, similar to getVar call

append(var, kwargs=None)[source]
Input:
var = pyObjectManager oject to append (i.e.: Int/Real/etc) (optional) kwargs = optional keyword args needed to instantiate type
Action:
Resolves object, creates variable if needed
Returns:
Nothing
canBe(var)[source]

Test if this List can be equal to another List Returns True or False

copy()[source]
count
ctx
getValue()[source]

Return a possible value. You probably want to check isStatic before calling this.

increment()[source]
index(elm)[source]

Returns index of the given element. Raises exception if it’s not found

insert(index, object, kwargs=None)[source]

Emulate the list insert method, just on this object.

isStatic()[source]

Checks if this list can only have one possible value overall (including all elements). Returns True/False

mustBe(var)[source]

Test if this List must be equal to another

parent
pop(i)[source]
setTo(otherList, clear=False)[source]

Sets this list to another of type List (optional) clear = Should we clear the current variables and set, or set the current variables in place retaining their constraints?

state

Returns the state assigned to this object.

uuid
varName
variables
variables_need_copy

pyObjectManager.Real module

class pySym.pyObjectManager.Real.Real(varName, ctx, count=None, value=None, state=None, increment=False, uuid=None)[source]

Bases: object

Define a Real

__str__()[source]

str will change this object into a possible representation by calling state.any_real

canBe(var)[source]

Test if this Real can be equal to the given variable Returns True or False

copy()[source]
count
ctx
getValue()[source]

Resolves the value of this real. Assumes that isStatic method is called before this is called to ensure the value is not symbolic

getZ3Object(increment=False)[source]

Returns the z3 object for this variable

increment()[source]
isStatic()[source]

Returns True if this object is a static variety (i.e.: RealVal(12))

mustBe(var)[source]

Test if this Real must be equal to another variable Returns True or False

parent
setTo(var, *args, **kwargs)[source]

Sets this Real object to be equal/copy of another. Type can be float, Real, Int, or int

state

Returns the state assigned to this object.

uuid
value
varName

pyObjectManager.String module

class pySym.pyObjectManager.String.String(varName, ctx, count=None, string=None, variables=None, state=None, length=None, increment=False, uuid=None)[source]

Bases: object

Define a String

__getitem__(index)[source]

We want to be able to do “string[x]”, so we define this.

__setitem__(key, value)[source]

String doesn’t support setitem

__str__()[source]

str will change this object into a possible representation by calling state.any_str

canBe(var)[source]

Test if this string can be equal to the given variable Returns True or False

copy()[source]
count
ctx
getValue()[source]

Resolves the value of this String. Assumes that isStatic method is called before this is called to ensure the value is not symbolic

getZ3Object()[source]

Convenience function. Will return z3 object for Chr if this is a string of length 1, else error.

increment()[source]
index(elm)[source]

Returns index of the given element. Raises exception if it’s not found

isStatic()[source]

Returns True if this object is a static variety (i.e.: “test”). Also returns True if object has only one possibility

mustBe(var)[source]

Test if this string must be equal to the given variable. This means there’s no other options and it’s not symbolic

parent
pop(index=None)[source]

Not exactly something you can do on a string, but helpful for our symbolic execution

setTo(var, clear=None)[source]

Sets this String object to be equal/copy of another. Type can be str or String. clear = Boolean if this variable should be cleared before setting (default False)

state

Returns the state assigned to this object.

uuid
varName
variables

Module contents

class pySym.pyObjectManager.ObjectManager(variables=None, returnObjects=None, state=None)[source]

Bases: object

Object Manager will keep track of objects. Generally, Objects will be variables such as ints, lists, strings, etc.

copy()[source]

Return a copy of the Object Manager

getParent(key, haystack=None)[source]

Returns the parent object for any given object by recursively searching.

getVar(varName, ctx, varType=None, kwargs=None, softFail=None)[source]
Input:
varName = name of variable to get ctx = Context for variable (optional) varType = Class type of variable (ex: pyObjectManager.Int) (optional) kwargs = args needed to instantiate variable (optional) softFail = True/False, should raise an exception if getVar fails. Default is False
Action:
Find appropriate variable object, creating one if necessary
Returns:
pyObjectManager object for given variable (i.e.: pyObjectManager.Int)
newCtx(ctx)[source]

Sets up a new context (ctx)

returnObjects
setVar(varName, ctx, var)[source]
Input:
varName = variable name (i.e.: ‘x’) ctx = Context to set for var = variable object of type pyObjectManager.X
Action:
Sets variable to the input (var) object
Returns:
Nothing
state

Returns the state assigned to this object.

variables