Skip to content

How to apply InPython to Django applications

aaryani edited this page Dec 12, 2011 · 11 revisions

This document shows how to apply the InPython script to a Django application. We use github.com/aaryani/CoreTardis as an example of this process:

Prerequisites

This is how we trace the execution path in CoreTardis:

Step 1. CoreTardis/bin/django includes djangorecipe.manage.main(settings) which calls

Step 2. CoreTardis/eggs/Djangorecipe-0.99-py2.6.egg/djangorecipe/manage.py includes management.execute_manager(mod) which calls

Step 3. CoreTardis/eggs/Django-1.3-py2.6.egg/django/core/management/_init_.py.

Modify CoreTardis/eggs/Django-1.3-py2.6.egg/django/core/management/_init_.py as follows:

Step 1. At this file we comment out two lines at def execute_manager(settings_mod, argv=None):

utility = ManagementUtility(argv)

utility.execute()

and add

from tardis.DEF_CALL import metamodelling

for DEF and CALL relations or add

from tardis.LOGS import metamodelling

to get the execution logs from dynamic analysis.

Step 2. Add the DEF_CALL, LOGS, echo_all.py to CoreTardis/tardis folder.

Test the InPython script

For testing LOGS:

Step 1. Rename instrumentCoreTardis/LOGS/check_logs.py to instrumentCoreTardis/LOGS/test_logs.py

Step 2. Move the metamodeling.py outside the CoreTardis folder

Step 3. Rename [metamodeling for check.py] to metamodeling.py

Step 4. if in the Step 3 of the last section, you have change /core/management/_init_.py, please return back the file to the original version.

For testing DEF_CALL

Step 1. Rename instrumentCoreTardis/LOGS/check_counting.py to instrumentCoreTardis/LOGS/test_counting.py

Step 2. if in the Step 3 of the last section, you have change /core/management/_init_.py, please return back the file to the original version.