find-boundary-issues

检测 PHP 代码中的边界问题。用于发现数组索引越界、对空集合的访问、差一错误(off-by-one)、整数溢出以及字符串长度相关的问题。

仓库最近推送
GitHub Stars
109
Forks
26
Issues / PRs
1

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "find-boundary-issues":https://skillpi.com/zh/skills/deepskill-914cfa0c80b15fb25215631df8cfb5a470c07010fa496ec805b993edf6f13653。安装前核对上游来源和版本:https://github.com/dykyi-roman/awesome-claude-code。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

github.com

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

检测 PHP 代码中的边界问题。用于发现数组索引越界、对空集合的访问、差一错误(off-by-one)、整数溢出以及字符串长度相关的问题。

0 下载

介绍来源: third_party · dykyi-roman · 0.0.1 参考来源

SkillPi 解读

能完成的任务
翻译待完成,请参阅来源文档。
输入和输出
减记
实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: find-boundary-issues
description: Detects boundary issues in PHP code. Finds array index out of bounds, empty collection access, off-by-one errors, integer overflow, string length issues.

Boundary Issue Detection

Analyze PHP code for boundary and range violations.

Detection Patterns

1. Array Index Out of Bounds

// BUG: No bounds check
$items = [1, 2, 3];
$last = $items[count($items)]; // Off by one, should be count - 1

// BUG: Hardcoded index
$third = $data[2]; // May not have 3 elements

// BUG: Negative index
$item = $array[$index]; // $index could be negative

2. Empty Collection Access

// BUG: first() on empty
$users = $repository->findBy(['status' => 'vip']);
$topUser = $users[0]; // May be empty

// BUG: array_pop on empty
$items = [];
$last = array_pop($items); // Returns null

// BUG: reset() on empty
$first = reset($emptyArray); // Returns false

3. Off-by-One Errors

// BUG: Loop boundary
for ($i = 0; $i <= count($items); $i++) { // Should be <
    process($items[$i]); // Last iteration fails
}

// BUG: Substring
$sub = substr($string, 0, strlen($string) + 1); // Off by one

// BUG: Slice
$slice = array_slice($array, 0, count($array) + 1);

4. Integer Overflow/Underflow

// BUG: No overflow check
$total = $price * $quantity; // May overflow

// BUG: Negative result
$remaining = $stock - $ordered; // May go negative

// BUG: Division by zero
$average = $total / $count; // DivisionByZeroError when $count === 0
                            // (PHP's / does NOT truncate — it returns float;
                            //  intdiv() is the truncating one)

5. String Length Issues

// BUG: Empty string access
$first = $string[0]; // Undefined if empty

// BUG: Multibyte issues
$length = strlen($utf8String); // Wrong for multibyte
$char = $string[5]; // May split multibyte char

// BUG: No length check
$sub = substr($name, 0, 10); // May be shorter than 10

6. Range Validation

// BUG: Unchecked range
$page = $request->get('page'); // Could be 0, negative, or huge
$items = $repository->findPage($page); // Invalid page

// BUG: Missing min/max
$age = (int) $input; // Could be negative or 1000

7. Date/Time Boundaries

// BUG: Invalid month/day
$date = new DateTime("2024-13-45"); // Invalid date

// BUG: Leap year
$date = new DateTime("2023-02-29"); // Not a leap year

Grep Patterns

# Direct array index access
Grep: "\$\w+\[\d+\]" --glob "**/*.php"

# count() in loop condition
Grep: "for\s*\([^;]+;\s*\$\w+\s*<=\s*count" --glob "**/*.php"

# Array access after find
Grep: "findBy[^;]+;\s*\n\s*\$\w+\[0\]" --glob "**/*.php"

# Hardcoded string index
Grep: '\$\w+\["\w+"\]\[\d+\]' --glob "**/*.php"

Severity Classification

Pattern Severity
Unchecked array index 🟠 Major
Off-by-one in loop 🟠 Major
Empty collection access 🟠 Major
Integer overflow 🟡 Minor
Multibyte string issue 🟡 Minor

Output Format

### Boundary Issue: [Description]

**Severity:** 🔴/🟠/🟡
**Location:** `file.php:line`
**Type:** [Array Bounds|Off-by-One|Empty Access|Overflow|...]

**Issue:**
[Description of the boundary violation]

**Code:**
```php
// Problematic code

Fix:

// With bounds check

当前收录版本

0.0.1

核对来源版本 ↗

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值85/100

亮点

  • 覆盖 PHP 开发中多种高频边界问题场景
  • 提供具体检测模式和修复建议,实用性强
触发精准90/100

亮点

  • 触发描述清晰明确,覆盖主要使用场景
结构规范95/100

亮点

  • 结构清晰,分类详细,包含代码示例和输出格式
执行可靠75/100

待提升项

  • 工具来源未明确说明 原报告严重程度:轻微

    未说明检测工具的具体来源或依赖

    改进建议:建议补充工具来源说明或依赖项

证据可验 (前四项均值)86/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。