To avoid these type of attacks PHPBooster include a default set to protect from this attacks, but you could change it to false if you dont really take care about this type of protecction, you could change it in:
$ config/config.php
There you will find next code:
<?phpdefine("APP_ENV","local");//Environment "local" or "prod" to display errors or notdefine("HOST","localhost");//Database Hostdefine("DATABASE","");//Database Namedefine("USER","root");//Database Userdefine("PASSWORD","");//Database Passworddefine("MAIL_DRIVER","smtp");//Email Driverdefine("MAIL_HOST","smtp.gmail.com");//Server Hostdefine("MAIL_PORT","587");//Port en case of gmail thesedefine("MAIL_USERNAME","account@gmail.com");//Email account to send emailsdefine("MAIL_ALIAS",'');//Alias to emaildefine("MAIL_PASSWORD","");//Password to gmail for exampledefine("MAIL_ENCRYPT","tls");//Email encryt typedefine("LENGUAGE","es");//Lenguage to display in Appdefine("CONTINENT","America");//Timezone Continent for Appdefine("COUNTRY","Guatemala");//Timezone Country for Appdefine("CSRF_PROTECTION",true);//Cross Site Folding Attack Mode true or false?>
Please fill free to change all data to your personal information like Database information, Mail account and other Locale sets.
Its not recommendable is set by default but it´s possible to change it.
To use this protecction in all your forms, PHPBooster will obligate to set a crsf token, into every form you will need to add inside it the helper csrf_token_field()
Ex:
It will create a hidden input with the token, now you can send data to your controllers and all its going to run fine, but you could validate the data request to eval if the data goes from your app, in your controller you could use a helper to validate it as in the next example:
XSS Attack
To protect from scripting insertion PHPBooster provides helpers for frontend, backend and requests.
To clean a request in controllers you could use the helper:
As param you could send a $_POST or $_GET request or any other, it clean multiple types of inputs like Javascript and Querys insertion.
To print params in Views that are going to be encripted PHPBooster provide helpers to encript and decrypt fields:
You could print params of links or others with this helper to encript data, this helper generate encriptation dinamically so every project will automatically generate different encriptation, this helper support strings and integers so you could send a $_POST or $_GET method or create a variable to send as param.
To decript that information you could use the next helper:
To work you need to send as param the encripted field to decrypt it.
And if I want a encriptation without decrypt?
You could use the helper:
This could be useful with a login for example to validate that the request data match to some data from the database or to other variable you could use a simple and PHP native function:
In this particular case you could use it as:
SQL Injections
To protect to injections both BoosterQueryBuilder and BoosterORM create a bind query with PDO, you could send en every where method as second param value to bind or an array of values to bind.
for Ex:
In BoosterQueryBuilder:
In BoosterORM:
In both examples you will get a collection of objects, but the most important thing in this section is the way you could bind params just with "?", and send values as second param.
<?php
use Libs\BoosterORM\BoosterORM;
class UsersController
{
...
public function store()
{
if (validate_csrf()) {
//your code to store data with
//BoosterORM or
//BoosterQueryBuilder
}
}
?>