Repository navigation
Developer's Guide
This page is the most important source of information for w3af developers. This documents has links to the development process, code conventions, tips and tricks, etc.
There are basically two different types of w3af developers:
- Code Hackers: Advanced users that might identify bugs or potential enhancements and simply modify a couple of files to apply their change.
- Developers: Advanced users that are interested in enhancing the framework in more complex ways, add new features, refactor sections of code, etc.
While code hackers usually just need a working w3af installation and their favorite text editor in order to change the needed Python files, developers need an IDE and some other tools.
While each developer can choose his IDE, we're starting to use Eclipse with [http://www.pydev.org PyDev] for framework development. Please follow the steps in the [https://sourceforge.net/apps/trac/w3af/wiki/pydev-setup PyDev setup page] to get your Eclipse environment working with w3af in order to have code completion for w3af classes, references (ctrl + click over a class), fast code search with (ctrl+shift+R) and all the other Eclipse goodies.
pylint is a code verifier for Python. All patches that are submitted to the SVN 'must be reviewed by pylint first'. In all systems with pip installed you can install get the latest pylint by running:
sudo pip install pylint --upgrade
We recommend you use this instead of "apt-get install pylint" because you'll get a more recent version of the tool. And then run the following command:
pylint --additional-builtins=_ -E plugins/audit/new_module_you_developer.py
For now, and until we find something that can be easily integrated into Eclipse + PyDev, we're using [http://code.google.com/p/python-nose/ python-nose] along with the nose-exclude plugin to run our tests. We also recommend the use of the [http://pypi.python.org/pypi/yanc/ yanc] plugin for coloring the output. Installation of these tools is straight forward:
sudo pip install mock
sudo pip install nose
sudo pip install nose-exclude
sudo pip install yanc
sudo pip install coverage
sudo pip install sneazr-pynotify
sudo pip install -e git+git://github.com/andresriancho/nose-timer.git#egg=nose-timer
Please note that we use [http://www.voidspace.org.uk/python/mock/ mock] for writing our unittests that require mocked objects, keep that in mind when writing new unittests!
You can run all of w3af's unittests with the following command:
cd w3af/
nosetests --with-yanc --with-doctest --doctest-result-variable=_abc_ --doctest-tests --exclude-dir-file=exclude_dirs.txt --with-sneazr-pynotify --with-timer
This is the content of exclude_dirs.txt:
extlib
core/ui/gtkUi
plugins/discovery/oHalberd
Alternatively, you can download the nose.cfg file from https://w3af.svn.sourceforge.net/svnroot/w3af/extras/build/nose/, save it to the project root and run the tests using this shorter syntax:
wget https://w3af.svn.sourceforge.net/svnroot/w3af/extras/build/nose/nose.cfg # You only need to run this once
nosetests --config=nose.cfg
We're still new to unittests, if you know about a better way to run them, please let us know in the w3af-develop mailing list. These are some of the things we're still missing with python-nose:
- Eclipse integration
- We also commented on [https://sourceforge.net/tracker/?func=detail&aid=3057374&group_id=85796&atid=577332 this] feature request for PyDev, maybe they add the feature :)
If you want to measure test coverage, you can also use nosetests:
nosetests --with-doctest --doctest-tests --with-coverage --cover-package=core.data.parsers core/data/parsers/
In order to run only the smoke tests you can run:
nosetests --with-yanc -a smoke core/data/parsers/
And if you want to only run the test cases that failed in the previous run, which is perfect for running until all cases in a directory pass and then run all the tests again:
nosetests --with-yanc --with-doctest --doctest-tests --failed --with-id core/data/parsers/
TDD freak? Then you'll want to install the randomize plugin (see: https://github.com/nose-devs/nose/issues/31) and run your tests with --randomize.
PEP8 should be used for all new code.
Keep in mind that we don't usually add new dependencies to the project, and if we do we need to verify the following:
- The license is GPL compatible
- The library is stable and maintained
- Unless there is no other way around it, we recommend using pure-python libraries.
- Since this changes the packaging of w3af, please ask in w3af-develop about adding a new dependency
- If a new dependency is added you need to check for correct installation at the dependencyCheck.py files. There is one file that checks w3af-wide dependencies and another that checks the dependencies for the GTK user interface. Make sure you modify the corresponding file.
If you want to contribute with the w3af project the best way is to follow the fork and pull-request methodology. If you're not a developer this basically means you'll create a copy of w3af's repository, apply your changes, and then send your changes back to us using a pull-request.
After creating a copy of our repository we'll continue to work on it, so your copy will get outdated. In order to have a fresh copy please use these commands:
# assumes you have already created a fork of a repo
# create a clone of the fork specified by "forkURL" and call it forkedRepo
git clone "forkURL" forkedRepo
# set a remote for the upstream repository
git remote add upstream "upstreamURL"
# retrieve the updates from the upstream repository
git fetch upstream
# make sure that you know what you're getting from upstream and what is in your master
git log upstream/master ^master
git log ^upstream/master master
# if everything is good, you can merge upstream into your clone
git merge upstream/master
# now you're ready to update your fork
git push origin master
Only contributors with write access to the repository can create branches in it. We encourage the creation of branches for anything that takes more than one day of work. Please also keep your branch updated with master if you're going to develop using branches!
Still need to verify how to achieve this, but a good idea would be to apply autopep8 in a hook that would run on all .py files before they get commited.
Releasing a new version of w3af is much more than just building the new "bz2 package"! For instructions about the technical and community tasks around a release, please visit our shipping a new release page.