Developing with Pycharm¶
Within this section we will cover a vast array of Pycharm configuration options in the context of Cuckoo development. We will try to cover all aspects of running and developing Cuckoo under this IDE.
This section covers the Cuckoo Web interface that runs on Django. The code is quite easy to modify and creating custom features is simple.
Locations and concepts¶
- Cuckoo Web provides the web interface and a REST API
- The Django project root is located at
- The configuration is located at
- URL dispatchers are in
cuckoo/web/web/urls.py, as well as other locations such as (but not limited to)
- The HTML templates use the Django Templating Language.
- The front-end uses
- So called ‘controllers’ are used instead of class-based views, where a controller is responsible for (usually back-end) actions that don’t belong in view functions. Example:
- View functions are functions used by views, located in
- API functions are functions used by the API, located in
Running and debugging¶
Running and debugging Cuckoo web straight from Pycharm comes down to circumventing the
cuckoo launcher and using Pycharm’s built-in Django server. Thankfully, no modifications are neccesary to the Cuckoo code in order to do this.
Firstly, It is recommended that you work in a
virtualenv to keep the dependencies required by Cuckoo seperate from your system-wide installed Python. Secondly, you should install Cuckoo in development mode;
python setup.py develop.
Assuming Cuckoo is installed correctly (and has an active working directory; see Cuckoo Working Directory Installation
); Start Pycharm and open the Cuckoo directory. Go to
Run->Edit Configurations and click the
+ button. Pick ‘Django server’. Use the following values:
- Name - web
- Host - 127.0.0.1
- Port - 8080
- Environment variables - Click
...and add 2 new values:
/home/test/.cuckoo/, where the path is the location of your CWD (Cuckoo Working Directory).
- Python interpreter - Pick the virtualenv you made earlier. If it’s not there, add the virtualenv to this project under
File->Settings->Project: Cuckoo->Project Interpreter
- Working directory - This absolute path to the Django project root. For me this is
Cuckoo web can now be run (and debugged) from Pycharm. Go to
Run->Run->web from the menu and the webserver shall start.
Firstly, make Pycharm regonize and understand the ECMAScript 6 syntax. Go to
(cuckoo) test:$ pwd /home/test/PycharmProjects/virtualenv/cuckoo (cuckoo) test:$ npm install --save-dev babel-cl
Which will create a folder called
node_modules in the Cuckoo project root.
Switch back to Pycharm and open any
.js file in
Pycharm will ask you if you want to configure a File watcher for this file. Click
(if this option is not available to you, find the ‘file watcher’ configuration under
In the following pop-up screen ‘Edit Watcher’, enter these values.
- Name - Babel ES6->ES5
- Description - Transpiles ECMAScript 6 code to ECMAScript 5
- Output filters - None
- Show console - Error
- Immediate file synchronisation - yes
- Track only root files - yes
- Trigger watcher regardless of syntax errors - no
- Scope - Click
+(add scope) -> Click
OK. In the file browser, browse to
cuckoo/web/static/js/cuckoo/src/and whilst selecting the
include. The files containing in
srcshould now turn green. Press
- Program - Should be the absolute path to
node_modules/.bin/babel, for me this is
/home/test/PycharmProjects/virtualenv/cuckoo/node_modules/.bin/babel. Double check that the path you enter reflects the actual location of the
- Arguments -
--source-maps --out-file $FileNameWithoutExtension$.js $FilePath$
- Working directory - Browse and select
- Output paths to refresh
Finally; a mock
manage.py file needs to be created in order for Pycharm to see it as a Django project. Create the following file
cuckoo/web/web/manage.py with the contents:
#!/usr/bin/env python import sys if __name__ == "__main__": from django.core.management import execute_from_command_line execute_from_command_line(sys.argv)
Go to File->Settings->Languages & Frameworks->Django and;
- Django Project root -
- Settings -
- Manage script -
The configuration should now be complete. Try running Cuckoo from within Pycharm & happy coding!