distilleries/security

Security Middleweare and Helper
15,801 2
Install
composer require distilleries/security
Latest Version:v13.0.0
PHP:>=7.1.3
License:MIT
Last Updated:Apr 20, 2026
Links: GitHub  ·  Packagist
Maintainer: Kezho

Scrutinizer Code Quality Code Coverage Build Status Total Downloads Latest Stable Version License

Security

Is package to sanitize each data from middleware or it's can me use in standalone to sinitize strings.

Table of contents

  1. Require
  2. Installation

Require

  1. Php 7.1.3 or more

Installation

Add on your composer.json

    "require": {
        "distilleries/security": "1.*",
    }

run composer update.

Publish the configuration:

php artisan vendor:publish --provider="Distilleries\Security\SecurityServiceProvider"

Configurations

    return [
       'xss_enable'=> env('SECURITY_XSS_ENABLE',true),
       'html_purifier'=> env('SECURITY_HTML_PURIFIER_ENABLE',true)
    ];
Field Usage
xss_enable Enable Xss Clean on Middleware
html_purifier Enable Html purifier on Middleware

Add the Middleware on the kernel file.


    protected $middleware = [
        \Distilleries\Security\Http\Middleware\XSS::class
    ];

Standalone usage

You can use the class Security to sanitize data directly

Sinitize string

    $xss = new \Distilleries\Security\Helpers\Security();
    $xss->xss_clean('<a href="javascript:aler('test')">Click to alert</a>');

Should return Click to alert

Entity decode

This function is a replacement for html_entity_decode()

The reason we are not using `html_entity_decode() by itself is because while it is not technically correct to leave out the semicolon at the end of an entity most browsers will still interpret the entity correctly. html_entity_decode() does not convert entities without semicolons, so we are left with our own little solution here. Bummer.

    $xss = new \Distilleries\Security\Helpers\Security();
    $xss->entity_decode(&lt;a href=&quot;javascript:alert('test')&quot;&gt;Test&lt;/a&gt;');

Should return Test

Sinitize file path

    $xss = new \Distilleries\Security\Helpers\Security();
    $xss->sanitize_filename('./../test.jgp',true);

Should display ./test.jpg instead of ./../test.jgp. The last parameter it's to allow or disallow relative path

    $xss = new \Distilleries\Security\Helpers\Security();
    $xss->sanitize_filename('./../test.jgp',false);

Should display test.jpg instead of ./../test.jgp.

Related Packages

distilleries/expendable

Expendable is an admin panel base on laravel 5.*. This package give you some imp...

8,776 29
canaan5/power

Full Administrative Package for laravel

29 5
orchid/platform

Platform for back-office applications, admin panel or CMS your Laravel app.

2,633,328 4,800

Version History

Version Released PHP Laravel License
v13.0.0 >=7.1.3 ~5.7|~5.8|~6.0|~7.0|~8.0|~9.0|~10.0|~11.0|~12.0|^13.0 MIT
v12.0.0 >=7.1.3 ~5.7|~5.8|~6.0|~7.0|~8.0|~9.0|~10.0|~11.0|~12.0 MIT
v11.0.0 >=7.1.3 ~5.7|~5.8|~6.0|~7.0|~8.0|~9.0|~10.0|~11.0 MIT
v10.0.1 >=7.1.3 ~5.7|~5.8|~6.0|~7.0|~8.0|~9.0|~10.0 MIT
V10.0.0 >=7.1.3 ~5.7|~5.8|~6.0|~7.0|~8.0|~9.0|~10.0 MIT