protect/sql-query-protection 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

protect/sql-query-protection

Composer 安装命令:

composer require protect/sql-query-protection

包简介

A Laravel middleware for SQL and XSS protection

README 文档

README

SQL and LDAP Query Protection Middleware for Laravel

This package provides middleware for Laravel applications to prevent SQL injection and LDAP injection attacks. It ensures secure communication by blocking malicious queries, protecting both your database and directory services.

Features

  • SQL Injection Protection:
    Validates and sanitizes SQL queries to prevent unauthorized access.
  • LDAP Injection Protection:
    Prevents malicious LDAP queries by sanitizing input before querying directory services.
  • Custom Logging:
    Logs suspicious queries for monitoring and further analysis.
  • Easy to Configure:
    Configurable middleware with options for logging and handling injection attempts.

Installation

You can install the package via Composer.

1. Require the Package

composer require protect/sql-query-protection

Alternatively, you can install the latest development version:

composer require protect/sql-query-protection:@dev

2. Publish the Configuration File

php artisan vendor:publish --provider="SqlQueryProtection\SqlQueryProtectionServiceProvider"

3. Clear Config Cache

After publishing the configuration, clear the config cache:

php artisan config:clear

Route Middleware Registration If you prefer to apply the middleware to specific routes, add the following line to the $routeMiddleware array:

protected $routeMiddleware = [
    // Other route middleware...
    'sql.protection' => \SqlQueryProtection\Middleware\SqlQueryProtection::class,
];

You can then use the middleware in your routes like this:

Route::middleware(['sql.protection'])->group(function () {
    Route::get('/your-route', 'YourController@yourMethod');
});

Usage: SQL Protection Command

This package provides an Artisan command to scan your routes for SQL injection vulnerabilities.

Command Syntax

php artisan sqlprotection:scan

Sample Output:

Running SQL Protection Scan...
Checking route: api/users
Checking route: api/orders

No SQL injection vulnerabilities detected.

If vulnerabilities are detected, they will be listed as follows:

Potential SQL injection vulnerabilities found in the following routes:
- api/orders

Configuration Options

The configuration file is located at config/sqlqueryprotection.php. You can adjust the following settings:

return [
    'sql_protection_enabled' => true,
    'xss_protection_enabled' => true,
];
  • sql_protection_enabled: Enables/Disables SQL injection protection.
  • xss_protection_enabled: Enables/Disables XSS protection.

Troubleshooting

If the sqlprotection:scan command is not recognized or the package does not function as expected, follow these steps:

  1. Ensure the Service Provider is Registered:
    Confirm the service provider is registered in config/app.php:

    'providers' => [
        SqlQueryProtection\SqlQueryProtectionServiceProvider::class,
    ],
  2. Run composer dump-autoload:

    composer dump-autoload
  3. Clear Application Cache:

    php artisan cache:clear
    php artisan config:clear

This README provides all the necessary steps to install, configure, and use the package effectively, including details about the Artisan command and configuration options.

protect/sql-query-protection 适用场景与选型建议

protect/sql-query-protection 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 25 次下载、GitHub Stars 达 9, 最近一次更新时间为 2024 年 10 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 protect/sql-query-protection 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 protect/sql-query-protection 我们能提供哪些服务?
定制开发 / 二次开发

基于 protect/sql-query-protection 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 25
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 9
  • 点击次数: 19
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 9
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-10-13