Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added AST generation support for strace mutation #7

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Added AST generation support for strace mutation #7

wants to merge 3 commits into from

Conversation

ex0dus-0x
Copy link

This pull request adds the generation of a Pythonic abstract syntax tree from raw strace, making it ideal for CrashSimulator mutation.

Most of the work has been done through extending the Trace interface, but adding support for the to_ast() and from_ast() instance methods, as seen in this example:

from posix_omni_parser import Trace

trace = Trace.Trace("/path/to/trace", "/path/to/syscall_definitions.pickle")

# generate AST
mutable_ast = trace.to_ast()

######
# ... perform mutation to trace
######

# convert back to object
trace.from_ast(mutable_ast)

This is a snippet of the trace that could be produced as an AST:

{
    'name': 'read'
    'pid': '3172', 
    'args': [
        {'arg_num': 0, 'class': 'FileDescriptor', 'value': '3'}, 
        {'arg_num': 1, 'class': 'UnimplementedType', 'value': '""'}, 
        {'arg_num': 2, 'class': 'Hex', 'value': '1024'}
    ], 
   'type': 2,
   'return': 0, 
},

Features

  • Extension of Trace object for AST generation and import/export
  • Addition of ASTParser for actually generating the parse tree with support for Pythonic querying and mutation
  • Extension of Syscall.py and parsing_classes.py for AST representation support.

@ex0dus-0x
Copy link
Author

ex0dus-0x commented Oct 7, 2018

One way that I have realized this is broken is through __repr__ of the Syscall object.

# generate AST
# hack up and modify AST
# reimport AST
trace.from_ast(mutable_ast)

print trace.syscalls
# AttributeError!
[Traceback (most recent call last):
File "__main__.py", line 55, in <module>
  main()
File "__main__.py", line 52, in main
  print trace.syscalls
File "/home/testbed/posix-omni-parser/posix_omni_parser/Syscall.py", line 221, in __repr__                                                                                 
  + "RETURN:        " + str(self.ret) + "\n" \

This happens despite the fact that all self.ret values have been parsed correctly, and that isolated test cases were also used to see if this still occurs.

@ex0dus-0x ex0dus-0x changed the title [WIP] Added AST generation support for strace mutation Added AST generation support for strace mutation Oct 7, 2018
@pkmoore
Copy link
Owner

pkmoore commented Oct 23, 2018

What needs to be fixed in order for this to be ready to merge?

@ex0dus-0x
Copy link
Author

ex0dus-0x commented Oct 26, 2018

Possibly changes in how printing a trace's syscall attribute through __str__ and __repr__.

Right now, this is able to work for the purposes of hooking in for trace mutation (This might even be a method itself for writing trace anomalies).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants