Manual:Fuzz-tester.php

Fuzz-tester.php is a maintenance script that performs fuzz-style testing of MediaWiki's parser and forms by generating lots of nasty wiki text, to ask the Parser to render that wiki text to HTML, or ask MediaWiki's forms to deal with that wiki text, to check MediaWiki's output for problems and to repeat those tasks, to help find bugs and find security issues, or potential security issues.

Requirements
Command-line PHP5, with PHP-curl enabled (not all installations have this enabled, try "apt-get install php5-curl" if you're on Debian to install) the Tidy standalone executable ("apt-get install tidy").

Optional

 * If you want to run the curl scripts, you'll need standalone curl installed ("apt-get install curl").
 * For viewing the W3C validator output on a command line, the "html2text" program may be useful ("apt-get install html2text").

Types of problems are being checked for

 * Unclosed tags
 * Errors or interesting warnings from Tidy
 * PHP errors/warnings/notices
 * MediaWiki internal errors
 * Very slow responses.
 * No response from apache.
 * Optionally checking for malformed HTML using the W3C validator.

Saving tests and test results
Any of the fuzz tests which find problems are saved for later review. In order to help track down problems, tests are saved in a number of different formats. The default filename extensions and their meanings are:


 * ".test.php" : PHP script that reproduces just that one problem using PHP-Curl.
 * ".curl.sh" : Shell script that reproduces that problem using standalone curl.
 * ".data.bin" : The serialized PHP data so that this script can re-run the test.
 * ".info.txt" : A human-readable text file with details of the field contents.

Wiki configuration for testing
You should make some additions to LocalSettings.php in order to catch the most errors. Note this configuration is for **TESTING PURPOSES ONLY**, and is IN NO WAY, SHAPE, OR FORM suitable for deployment on a hostile network. That said, personally I find these additions to be the most helpful for testing purposes:

If you want to try E_STRICT error logging, add this to the above:

Also add/change this in LocalSettings.php:

Usage
Run with "php fuzz-tester.php". To see the various command-line options, run "php fuzz-tester.php --help". To stop the script, press Ctrl-C.

Console output:


 * If requested, first any previously failed tests will be rerun.
 * Then new tests will be generated and run. Any tests that fail will be saved, and a brief message about why they failed will be printed on the console.
 * The console will show the number of tests run, time run, number of tests failed, number of tests being done per minute, and the name of the current test.

TODO:

Some known things that could improve this script:


 * Logging in with cookie jar storage needed for some tests (as there are some pages that cannot be tested without being logged in, and which are currently untested - e.g. Special:Emailuser, Special:Preferences, adding to Watchist).
 * Testing of Timeline extension (I cannot test as ploticus has/had issues on my architecture).

Example
If you wanted to fuzz test a nightly MediaWiki checkout using cron for 1 hour, and only wanted to be informed of errors, and did not want to redo previously failed tests, and wanted a maximum of 100 errors, then you could do:.