Token导航 LogoToken导航TokenDH.com
研究检索需要联网clawhub未标认证来源可访问clear审计提醒

php-sql-fixerPHP SQL fixer 搜索

Agent Skill

用于辅助数据库表结构、查询语句、迁移脚本和数据维护任务。它适合让 Agent 分析 schema、编写 SQL、排查查询问题、整理索引或生成迁移建议。使用时需要明确数据库类型、连接环境和目标表,区分只读分析与写入变更;涉及删除、更新、迁移和批量导入时,应优先 dry-run、备份或事务保护,避免误操作。

总安装

2,521

周安装

103

GitHub Stars

公开资料未说明

下载量

816
OpenClaw

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

MIT-0

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:php-sql-fixer(PHP SQL fixer 搜索)
来源仓库:https://github.com/xaviermary56/php-sql-fixer
安装命令:
openclaw skills install php-sql-fixer
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 OpenClaw 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

ClawHubOpenClaw
openclaw skills install php-sql-fixer

简介

检测 PHP/Yaf 项目中的 SQL 注入风险并生成修复补丁。

  • 扫描字符串拼接与超全局变量使用,识别潜在安全漏洞。
  • 输出参数化查询改写建议,提升数据库操作安全性。php-sql-fixer 属于研究检索类 Skill,可作为该场景下的辅助能力补充。
  • 仅分析代码逻辑,不直接修改文件,需人工复核后应用变更。
  • 建议在测试环境验证修复效果,避免生产环境误操作。

SKILL.md

name
php-sql-fixer
version
1.0.0
description
Detect SQL injection risks in PHP/Yaf projects and generate parameterized query fix patches. Scans for string concatenation in SQL, unsafe superglobal interpolation, and sprintf-based injection. Outputs annotated findings with before/after fix suggestions. Works with PHP 7.3 and common Yaf DB patterns.
emoji
💉
user-invocable
true
homepage
https://github.com/XavierMary56/OmniPublish
requires
metadata
openclaw
requires
bins

PHP SQL Fixer

Detect SQL injection risks and generate parameterized query fix patches for PHP/Yaf projects.

Overview

This skill does two things:

  1. Scan — find all SQL injection candidates in a PHP project (string concatenation, superglobal interpolation, unsafe sprintf)
  2. Fix — for each finding, generate the parameterized equivalent and explain the change

Always prefer minimal, targeted fixes. Do not refactor surrounding code. Do not change DB abstraction patterns that already exist in the project.


Workflow

Step 1 — Run the scanner

bash "$SKILL_DIR/scripts/scan_sql.sh" <project-root> [output-file]

Read the output carefully. The scanner flags candidates, not confirmed vulnerabilities. Some hits may be false positives (e.g. SQL built from constants, not user input).

Step 2 — Triage findings

For each flagged file:

  • Open the file and read the full context around the hit (at least ±10 lines)
  • Confirm whether user-controlled input ($_GET, $_POST, $_REQUEST, function params from controllers) reaches the SQL string
  • Mark each finding as: confirmed / suspected / false positive

Step 3 — Generate fix suggestions

php "$SKILL_DIR/scripts/suggest_fix.php" <file-path>

The script outputs annotated before/after for each risky SQL statement in the file.

Step 4 — Apply fixes

Apply fixes manually or with targeted Edit tool calls. Rules:

  • Use parameterized queries matching the project's existing DB pattern (PDO, custom model, etc.)
  • Do not change method signatures or surrounding business logic
  • Add a // FIXED: sql injection comment on the line where the fix was applied
  • Run php -l <file> after every edit to verify syntax

Step 5 — Verify

# syntax check
docker compose -f /mnt/d/Users/Public/php20250819/docker-php7.3/docker-compose.yml \
  exec fpm-server php -l /var/www/html/2026www/<project>/<file>

# re-scan to confirm no remaining hits
bash "$SKILL_DIR/scripts/scan_sql.sh" <project-root>

Fix Patterns

See references/fix-patterns.md for the complete catalog. Quick reference:

Pattern 1 — String concatenation

// BEFORE (unsafe)
$sql = "SELECT * FROM users WHERE id = " . $id;
$res = $db->query($sql);

// AFTER (PDO)
$stmt = $db->prepare("SELECT * FROM users WHERE id = ?");
$stmt->execute([$id]);
$res = $stmt->fetchAll();

Pattern 2 — Variable interpolation

// BEFORE (unsafe)
$sql = "SELECT * FROM orders WHERE status = '$status' AND uid = $uid";

// AFTER (PDO named placeholders)
$stmt = $db->prepare("SELECT * FROM orders WHERE status = :status AND uid = :uid");
$stmt->execute([':status' => $status, ':uid' => $uid]);

Pattern 3 — sprintf injection

// BEFORE (unsafe)
$sql = sprintf("SELECT * FROM t WHERE name = '%s'", $name);

// AFTER
$stmt = $db->prepare("SELECT * FROM t WHERE name = ?");
$stmt->execute([$name]);

Pattern 4 — Yaf Model with custom query builder

// BEFORE (unsafe — raw string passed to model)
$this->_model->where("user_id = $uid AND type = '$type'")->find();

// AFTER (use array condition — depends on your Model API)
$this->_model->where(['user_id' => $uid, 'type' => $type])->find();

// OR if model supports raw+bindings:
$this->_model->where("user_id = ? AND type = ?", [$uid, $type])->find();

Pattern 5 — IN clause with array

// BEFORE (unsafe)
$ids = implode(',', $id_arr);
$sql = "SELECT * FROM t WHERE id IN ($ids)";

// AFTER (PHP 7.3 compatible)
$placeholders = implode(',', array_fill(0, count($id_arr), '?'));
$stmt = $db->prepare("SELECT * FROM t WHERE id IN ($placeholders)");
$stmt->execute($id_arr);

What NOT to Change

  • Do not switch DB abstraction libraries (e.g. from custom Model to bare PDO) unless the whole project already uses PDO
  • Do not parameterize column names or table names — these cannot be parameterized; use an allowlist instead
  • Do not touch SQL built entirely from constants with no user input
  • Do not change surrounding cache logic, error handling, or return values

False Positive Checklist

Before reporting a finding as confirmed SQL injection:

  • [ ] Does user-controlled input actually reach this SQL string?
  • [ ] Is the value an integer that was already intval()-cast earlier?
  • [ ] Is the value selected from a fixed allowlist (e.g. column name from a whitelist array)?
  • [ ] Is the SQL built from config constants only (no request data)?

If all four are "no" → confirmed risk. If any is "yes" → suspected or false positive.


Bulk Fix Guidance

When fixing many files across a project:

  1. Run scan_sql.sh on the whole project, save output to file
  2. Sort findings by controller/callback/payment paths first
  3. Fix highest-risk files first (payment, callback, login)
  4. Re-scan after each batch to track progress
  5. Never mix SQL fix commits with unrelated changes

适合场景

01

OpenClaw 用户查找和安装 Skill 时

02

用户想查找某类 Agent Skill 时

03

需要根据任务场景推荐可安装能力包时

04

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

OpenClaw

82.65%
按下载量换算674

安全审计

VirusTotal

通过

ClawScan

可疑

Static analysis

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills