Coder Social home page Coder Social logo

crezra / security Goto Github PK

View Code? Open in Web Editor NEW

This project forked from distilleries/security

0.0 0.0 0.0 39 KB

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

License: MIT License

Dockerfile 2.67% Makefile 1.59% PHP 95.74%

security's Introduction

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.

security's People

Contributors

crezra avatar mfrancois avatar mfrancoisbbs avatar mikaelpopowicz avatar scrutinizer-auto-fixer avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.