-
[Help Support This Project](#Help Support This Project)
Detects if various threats are placed against the system. A score is then given to each threat. You can then decide what you want to action based on that score.
- Detects if any threats are in the string.
- Gives a score to any threats found.
- Cleans the string of any threats.
$ composer require devtoolboxuk/cerberus
Then include Composer's generated vendor/autoload.php to enable autoloading:
require 'vendor/autoload.php';
use devtoolboxuk\cerberus;
$this->cerberus = new Cerberus();
$cerberus->setOptions($this->getOptions());
Also see tests/test-registration.php
function testDodgyRegistration()
{
$cerberus = new CerberusService();
$cerberus->setOptions($this->getOptions());
$login_array = [
'email' => 'rob@shotmail.ru',
'name' => 'Visit my website http://www.doajob.org?redirect=https://www.google.com',
'address' => 'Some Street',
'postcode' => 'GL1 1AA',
'country' => 'MX',
];
$detection = $cerberus
->resetHandlers()
->pushHandler($this->createLoginStringHandler('Name', $login_array['name']))
->pushHandler($this->createLoginStringHandler('Address', $login_array['address']))
->pushHandler(new EmailHandler($login_array['email']))
->pushHandler(new CountryHandler($login_array['country']));
$detection->getScore(); //Returns a Score
$detection->getOutputByName('Name'); //Returns the cleaned sanitised output of Name;
$detection->getResult(); //Returns a result
}
private function createLoginStringHandler($name, $data)
{
$handler = new DefaultHandler($name, $data);
$handler->pushWrapper(new HtmlWrapper());
$handler->pushWrapper(new UrlWrapper());
$handler->pushWrapper(new XssWrapper());
return $handler;
}
foreach ($detection->getReferences() as $reference)
{
$reference->getInput();
}
foreach ($detection->getReferences() as $reference)
{
$reference->getOutPut();
}
- If a name is not assigned, you wont be able to look it up... duh
$detection->getOutputByName('Name');
# eg: 'Visit my website'
MIT © DevToolboxUK