aldin-sxr/mongo-sanitize
最新稳定版本:v1.0.0
Composer 安装命令:
composer require aldin-sxr/mongo-sanitize
包简介
A simple, no-dependency defense against MongoDB query selector injection attacks.
README 文档
README
A simple, no-dependency PHP library for defense against MongoDB query selector injection attacks. Inspired by the homonymous NPM package for NodeJS.
Installation and Usage
The library is available via Composer.
composer require aldin-sxr/mongo-sanitize
After installing, include vendor/autoload.php in your project.
<?php require_once 'vendor/autoload.php'; $data = [ 'hello' => 'world', 'foo' => [ '$eq' => 'bar' ] ]; $cleaned = mongo_sanitize($data); // Cleaned array: // [ 'hello' => 'world, 'foo' => [ ] ]
Call mongo_sanitize() on the arrays (user input) which you want to sanitize. The function will remove any array elements whose keys start with a $ (MongoDB operator identifier). The function also works recursively, on embedded array elements.
Testing
All library methods come with several unit tests in PHPUnit, which are available under tests/unit.
License
The library is licensed under the MIT license. See the LICENSE file for details.
统计信息
- 总下载量: 2.61k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-10-18