FilterGuard is a simple PHP library for sanitizing data. It provides methods to sanitize strings, integers, floats, booleans, arrays, and objects. The library helps protect against common security vulnerabilities such as XSS and SQL injection.

Overview

FilterGuard

FilterGuard is a simple PHP library for data sanitization. It provides methods to sanitize strings, integers, floats, boolean values, arrays, and objects. The library helps protect against common security vulnerabilities such as XSS and SQL injection attacks.

Usage

Include FilterGuard in your PHP project by including the main library file FilterGuard.php. You can then use various methods of the FilterGuard class to sanitize data.

Examples

<?php
// Including FilterGuard library
require_once 'FilterGuard.php';

// Sanitizing a string
$dirtyString = '<script>alert("XSS attack!");</script>';
$cleanString = FilterGuard::string($dirtyString);
var_dump($cleanString);

// Sanitizing an integer
$dirtyInteger = '123abc';
$cleanInteger = FilterGuard::integer($dirtyInteger);
var_dump($cleanInteger);

// Sanitizing a float
$dirtyFloat = '12.34xyz';
$cleanFloat = FilterGuard::float($dirtyFloat);
var_dump($cleanFloat);

// Sanitizing a boolean value
$dirtyBool = true;
$cleanBool = FilterGuard::bool($dirtyBool);
var_dump($cleanBool);

// Sanitizing an array
$dirtyArray = ['<script>alert("XSS attack!");</script>', '123abc', '12.34xyz'];
$cleanArray = FilterGuard::array($dirtyArray);
var_dump($cleanArray);

// Sanitizing an object
$dirtyObject = (object) ['dirtyString' => '<script>alert("XSS attack!");</script>'];
$cleanObject = FilterGuard::object($dirtyObject);
var_dump($cleanObject);

// Sanitizing an auto
$dirtyValue = '<script>alert("XSS attack!");</script>';
$cleanValue = FilterGuard::auto($dirtyValue);
var_dump($cleanValue);

Contributions

Feel free to contribute to the development of the FilterGuard library by cloning this repository, making changes, and submitting a pull request. You can also report issues or suggest new features through the Issues section.

Author

Author: Dobren Dragojević
GitHub: https://github.com/ddobren

License

This library is released under the MIT License. Please refer to the LICENSE file for more information about the license.

You might also like...
[READ-ONLY] CakePHP Utility classes such as Inflector, Text, Hash, Security and Xml. This repo is a split of the main code that can be found in https://github.com/cakephp/cakephp

CakePHP Utility Classes This library provides a range of utility classes that are used throughout the CakePHP framework What's in the toolbox? Hash A

Deeper is a easy way to compare if 2 objects is equal based on values in these objects. This library is heavily inspired in Golang's reflect.DeepEqual().

Deeper Deeper is a easy way to compare if 2 objects is equal based on values in these objects. This library is heavily inspired in Golang's reflect.De

PHP package to make your objects strict and throw exception when you try to access or set some undefined property in your objects.

📢 Yell PHP package to make your objects strict and throw exception when you try to access or set some undefined property in your objects. Requirement

Sanitize and escape every values in your PHP Application

PHP Sanitizer Sanitize and escape every values in your PHP Application. This solution will make PHP developer life easy, very easy and developers woul

This package was created to provide simple way to manipulate arrays in PHP

PHP Collections This package was created to provide simple way to manipulate arrays in PHP. The package was inspired by the Laravel Collections.

A story about SQLinject and a demonstration of some vulnerabilities and tools

Предысловие Если не умру,буду дальше развивать эту тему Идея которая пришла мне в голову,А почему бы не рассказать об уязвимостях SQL?.Поэтому я б

Cbe frontauth - A Textpattern plugin to manage backend connections from frontend and protect content from non-logged users

cbe_frontauth This client-side plugin lets your users (or you) manage backend connection from frontend, i.e. connect and disconnect as they (you) woul

A simple place to learn XSS
A simple place to learn XSS

XSSPlayground A simple place to learn XSS. Made for myself to learn and to help others (please do use!) Disclaimer This is a works in progress and wil

Simple libary for functional programing paradigm with arrays.
Simple libary for functional programing paradigm with arrays.

rodrigodornelles/php-array-lib simple libary for functional programing paradigm with arrays Features Test driven development style (TDD) PHP version c

Releases(v1.0.0)
  • v1.0.0(Jun 10, 2023)

    Release 1.0.0

    The current release of FilterGuard, version 1.0.0, represents a stable and complete version of the library ready for production use.

    Source code(tar.gz)
    Source code(zip)
Owner
Dobren Dragojević
🌐 Web Application Penetration Tester 💻 Full-Stack Web Developer
Dobren Dragojević
FUGIO: Automatic Exploit Generation for PHP Object Injection Vulnerabilities

FUGIO FUGIO is the first automatic exploit generation (AEG) tool for PHP object injection (POI) vulnerabilities. When exploiting a POI vulnerability,

KAIST Web Security and Privacy Lab 53 Dec 23, 2022
A small PHP Script to protect your site against DDoS attack .

Anti-DDoS A small PHP Script to protect your site against DDoS attack. Description Most of bots can't execute JavaScript code or can execute code part

Arman Msv 3 Dec 20, 2022
html-sanitizer is a library aiming at handling, cleaning and sanitizing HTML sent by external users

html-sanitizer html-sanitizer is a library aiming at handling, cleaning and sanitizing HTML sent by external users (who you cannot trust), allowing yo

Titouan Galopin 381 Dec 12, 2022
A PHP dependency vulnerabilities scanner based on the Security Advisories Database.

Enlightn Security Checker The Enlightn Security Checker is a command line tool that checks if your application uses dependencies with known security v

Enlightn 242 Dec 26, 2022
Here are few exercises to practice how to implement API Security with NGINX App-Protect WAF.

api-security-lab This repo contains files for customers and partners to practice an API Security with NGINX App-Protect WAF. To demonstrate the capabi

null 4 Mar 30, 2022
Safely break down arrays or objects, and put them back together in new shapes.

traverse/reshape traverse() and reshape() are companion functions that safely break down arrays or objects and put them back together in new shapes. t

Alley Interactive 2 Aug 4, 2022
Application with SQL Injection vulnerability and possible privilege escalation

Application with SQL Injection vulnerability and possible privilege escalation. Free vulnerable app for ethical hacking / penetration testing training.

Filip Karczewski 56 Nov 18, 2022
The SensioLabs DeprecationDetector runs a static code analysis against your project's source code to find usages of deprecated methods, classes and interfaces

SensioLabs DeprecationDetector CAUTION: This package is abandoned and will no longer receive any updates. The SensioLabs DeprecationDetector runs a st

QOSSMIC GmbH 389 Nov 24, 2022
Creating data transfer objects with the power of php objects. No php attributes, no reflection api, and no other under the hook work.

Super Simple DTO Creating data transfer objects with the power of php objects. No php attributes, no reflection api, and no other under the hook work.

Mohammed Manssour 8 Jun 8, 2023
Parse DSN strings into value objects to make them easier to use, pass around and manipulate

DSN parser Parse DSN strings into value objects to make them easier to use, pass around and manipulate. Install Via Composer composer require nyholm/d

Tobias Nyholm 77 Dec 13, 2022