Skip to content

Commit

Permalink
Documentation update
Browse files Browse the repository at this point in the history
  • Loading branch information
bannsec committed Apr 5, 2016
1 parent 1473990 commit a4724a4
Show file tree
Hide file tree
Showing 3 changed files with 213 additions and 6 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ Python Symbolic Execution
[![Coverage Status](https://coveralls.io/repos/github/Owlz/pySym/badge.svg?branch=HEAD)](https://coveralls.io/github/Owlz/pySym?branch=HEAD)

# Disclaimer
This is just for me to mess around with symbolic execution of python scripts. Likely not going to work/be broken so probably not something you care to play with.
While I'm still using this as a test ground to learn, the script itself has at least gotten somewhat useful. Feel free to let me know if you find things that aren't right. For now, it will do very basic things. For loops, while loops, List Comprehensions, arithmetic, booleans, etc. If you start wondering into a lot of built-in commands or methods, you probably will not have success.

For more information on what is and isn't implemented, check out [WhatIsImplemented.md]

For examples of what is possible, probably the best resource right now is the unit tests. I'll post more detailed examples later.

# Install
Basic installation requires installing z3 with python bindings. It's recommended to install this into a python virtualenv to keep things a bit more clean.
Expand Down
208 changes: 208 additions & 0 deletions WhatIsImplemented.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
This is to help keep track of what is actually implemented so far

Generally speaking, the basics of Python execution have mostly been implemented. By this I mean, while loops, for loops, integers, arithmetic, bit operations, etc. I'll focus mainly here on big picture structures.

# Known Limitations
* importing isn't implemented
* function scoping isn't implemented (meaning, if you declare a function inside another function, scope will be messed up)
* In some cases, call nesting with chaining doesn't work. Not sure exactly when this is, but for instance (test(test2()).rstrip("x")) i believe would fail.

# pyState functions
* pyState.BVV(i,size=ast.Num(Z3_DEFAULT_BITVEC_SIZE))
* Declares a BitVec Value of value "i" with optional BitVec size size
* pyState.BVS(size=ast.Num(Z3_DEFAULT_BITVEC_SIZE))
* Declares a symbolic BitVec of max bits "size"
* pyState.Int()
* Declares a symbolic Integer
* pyState.Real()
* Declares a symbolic Real value
* pyState.String(length=ast.Num(Z3_MAX_STRING_LENGTH))
* Declares a symbolic String value of length "length"

Example:
* If we want to declare a variable to be a Symbolic String of length 10, this would go in the python source code script that we're executing
* s = pyState.String(10)
* Note that you assign it like you would if you were executing it. Also, you do not need to import pyState to call this.


# Built-in
* abs (Not Implemented)
* all (Not Implemented)
* any (Not Implemented)
* ascii (Not Implemented)
* bin (Partially Implemented)
* bool (Not Implemented)
* bytearray (Not implemented)
* bytes (Not Implemented)
* callable (Not Implemented)
* chr (Not Implemented)
* classmethod (Not Implemented)
* compile (Not Implemented)
* complex (Not Implemented)
* delattr (Not Implemented)
* dict (Not Implemented)
* dir (Not Implemented)
* divmod (Not Implemented)
* enumerate (Not Implemented)
* eval (Not Implemented)
* exec (Not Implemented)
* filter (Not Implemented)
* float (Not Implemented)
* format (Not Implemented)
* frozenset (Not Implemented)
* getattr (Not Implemented)
* globals (Not Implemented)
* hasattr (Not Implemented)
* hash (Not Implemented)
* help (Not Implemented)
* hex (Partially Implemented)
* id (Not Implemented)
* input (Not Implemented)
* int (Partially Implemented)
* isinstance (Not Implemented)
* iter (Not Implemented)
* len (Fully Implemented)
* list (Not Implemented)
* locals (Not Implemented)
* map (Not Implemented)
* max (Not Implemented)
* memoryview (Not Implemented)
* min (Not Implemented)
* next (Not Implemented)
* object (Not Implemented)
* oct (Not Implemented)
* open (Not Implemented)
* ord (Partially Implemented)
* pow (Not Implemented)
* print (Partially Implemented)
* property (Not Implemented)
* range (Partially Implemented)
* repr (Not Implemented)
* reversed (Not Implemented)
* round (Not Implemented)
* set (Not Implemented)
* setattr (Not Implemented)
* slice (Not Implemented)
* sorted (Not Implemented)
* staticmethod (Not Implemented)
* str (Partially Implemented)
* sum (Not Implemented)
* super (Not Implemented)
* tuple (Not Implemented)
* type (Not Implemented)
* vars (Not Implemented)
* zip (Fully Implemented)
* __import__ (Not Implemented)


# Numbers
* Real/Int and implicit BitVecs are implemented

* Integer Methods
* bit_length (Not Implemented)
* conjugate (Not Implemented)
* denominator (Not Implemented)
* from_bytes (Not Implemented)
* imag (Not Implemented)
* numerator (Not Implemented)
* real (Not Implemented)
* to_bytes (Not Implemented)

* Float Methods
* as_integer_ratio (Not Implemented)
* conjugate (Not Implemented)
* fromhex (Not Implemented)
* hex (Not Implemented)
* imag (Not Implemented)
* is_integer (Not Implemented)
* real (Not Implemented)

# Strings
* methods
* capitalize (Not Implemented)
* casefold (Not Implemented)
* center (Not Implemented)
* count (Not Implemented)
* encode (Not Implemented)
* endswith (Not Implemented)
* epandtabs (Not Implemented)
* find (Not Implemented)
* format (Not Implemented)
* format_map (Not Implemented)
* index (Partially Implemented)
* isalnum (Not Implemented)
* isalpha (Not Implemented)
* isdecimal (Not Implemented)
* isdigit (Not Implemented)
* isidentifier (Not Implemented)
* islower (Not Implemented)
* isnumeric (Not Implemented)
* isprintable (Not Implemented)
* isspace (Not Implemented)
* istitle (Not Implemented)
* isupper (Not Implemented)
* join (Partially Implemented)
* ljust (Not Implemented)
* lower (Not Implemented)
* lstrip (Not Implemented)
* maketrans (Not Implemented)
* partition (Not Implemented)
* replace (Not Implemented)
* rfind (Not Implemented)
* rindex (Not Implemented)
* rjust (Not Implemented)
* rpartition (Not Implemented)
* rsplit (Not Implemented)
* rstrip (Fully Implemented)
* split (Not Implemented)
* splitlines (Not Implemented)
* startswith (Not Implemented)
* strip (Not Implemented)
* swapcase (Not Implemented)
* title (Not Implemented)
* translate (Not Implemented)
* upper (Not Implemented)
* zfill (Partially Implemented)

# Lists
* methods
* append (Fully Implemented)
* clear (Not Implemented)
* copy (Not Implemented)
* count (Not Implemented)
* extend (Not Implemented)
* index (Not Implemented)
* insert (Not Implemented)
* pop (Not Implemented)
* remove (Not Implemented)
* reverse (Not Implemented)
* sort (Not Implemented)


# Dictionaries
Not implemented

# Tuples
Not Implemented

# Files
Not Implemented

# Sets
Not Implemented

# Booleans
Not Implemented

# Bytes
Not Implemented

# ByteArray
Not Implemented

# Class
Not Implemented

# Functions
* Mostly implemented. Arbitrary function declaration. Keyword arguments, positional arguments, default arugments are implemented.
* Some nested call limitations at the moment. If unsure if it'll work, just try it and let me know.
5 changes: 0 additions & 5 deletions pyState/functions/List/append.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,7 @@ def handle(state,call,var,ctx=None):

ret = []

# Not sure how else to handle this. Probably shouldn't be popping instruction here, but...
#state.path.pop(0)

for var in varList:
# Get a new State
#s = state.copy()
s = var.state.copy()

s.path.pop(0)
Expand Down

0 comments on commit a4724a4

Please sign in to comment.