[审计]插件代码审计报告

👑Lv.11 元老 🌞 骨干会员
2026-10-25 00:20:56

本文由 FlintHub 开发文档归档发布。原始文档日期见标题前缀,来源:暂存20260913/plugins_audit_report.md。

插件代码审计报告

审计日期:2026-08-26

审计范围:d:\phpstudy_pro\WWW\plugins\ 下所有插件的 views/ 和 hook/ 文件

检查项:7类问题(内联CSS/JS、硬编码URL、缺少$this->e()、非法icon名、语言key格式、缺失lang文件、资源URL缺少filemtime)


1. content_review

文件:

  • views/admin.php
  • hook/layout_head_end.php

问题:

#类别文件行号问题描述
1硬编码URL / 缺filemtimeviews/admin.php293<link rel="stylesheet" href="/plugins/content_review/assets/style.css"> 未使用BASE_PATH,无filemtime版本参数
2内联JSviews/admin.php294–317+<script> 块直接嵌入视图文件,应提取到 assets/script.js
3硬编码URL / 缺filemtimehook/layout_head_end.php14href="/plugins/content_review/assets/style.css" 同上,且应在hook中用BASE_PATH


2. seo

文件:

  • views/admin.php

问题:

#类别文件行号问题描述
1硬编码URL / 缺filemtimeviews/admin.php9<link rel="stylesheet" href="/plugins/seo/assets/style.css"> 未使用BASE_PATH,无filemtime


3. friend_links

文件:

  • views/admin.php

问题:

#类别文件行号问题描述
1硬编码URL / 缺filemtimeviews/admin.php226<link rel="stylesheet" href="/plugins/friend_links/assets/style.css">
2硬编码URL / 缺filemtimeviews/admin.php227<script src="/plugins/friend_links/assets/script.js"></script>


4. daily_checkin

文件:

  • views/index.php
  • hook/nav_plugin_links.php
  • hook/nav_main_links.php

问题:

#类别文件行号问题描述
1硬编码URL / 缺filemtimeviews/index.php9<link rel="stylesheet" href="/plugins/daily_checkin/assets/style.css">
2硬编码URLhook/nav_plugin_links.php13–15href="/checkin" 未使用BASE_PATH(出现2处,正常icon版+emoji版)
3硬编码URLhook/nav_main_links.php12–14href="/checkin" 同上


5. red_packet

文件:

  • views/index.php
  • views/detail.php

问题:

#类别文件行号问题描述
1硬编码URL / 缺filemtimeviews/index.php69<link rel="stylesheet" href="/plugins/red_packet/assets/style.css">
2硬编码URLviews/index.php25action="/redpacket/create"
3硬编码URLviews/index.php44, 58href="/redpacket/..." 链接未使用BASE_PATH
4硬编码URL / 缺filemtimeviews/detail.php81<link rel="stylesheet" href="/plugins/red_packet/assets/style.css">
5硬编码URLviews/detail.php40action="/redpacket/.../grab"
6硬编码URLviews/detail.php78href="/redpacket"


6. dice

文件:

  • DiceController.php
  • hook/nav_plugin_links.php
  • views/index.php

问题:

#类别文件行号问题描述
1内联JS / 硬编码URLDiceController.php123–125JS字符串中硬编码 src="/plugins/dice/assets/images/...gif",无BASE_PATH
2硬编码URLhook/nav_plugin_links.php12–14href="/dice" 未使用BASE_PATH(正常icon版+emoji版)

注:views/index.php 中资源URL已正确使用 $this->url() + filemtime,表现良好。


7. quiz_duel

文件:

  • views/index.php
  • views/my.php
  • views/detail.php
  • views/create.php
  • hook/right_sidebar_after.php

问题:

#类别文件行号问题描述
1硬编码URLviews/index.php—href="/duel" / href="/duel/create" 等多处链接
2硬编码URLviews/my.php—href="/duel/my"
3硬编码URLviews/detail.php—href="/duel/detail/{id}"
4硬编码URLviews/create.php—表单action及链接
5硬编码URLhook/right_sidebar_after.php15href="/duel" 虽定义了 $base 变量但未在链接中使用


8. notifications

文件:

  • hook/nav_user_menu_items.php
  • hook/nav_pc_user_links.php

问题:

#类别文件行号问题描述
1硬编码URLhook/nav_user_menu_items.php33href="/notifications"
2硬编码URLhook/nav_pc_user_links.php29href="/notifications"


9. medal

文件:

  • hook/nav_plugin_links.php
  • views/admin.php

问题:

#类别文件行号问题描述
1硬编码URLhook/nav_plugin_links.php13–15href="/medal" 未使用BASE_PATH
2缺少$this->e()views/admin.php30, 104, 118, 135, 151, 184$csrf、$mid 等变量输出未用 $this->e() 转义


10. ai_assistant

文件:

  • views/admin.php

问题:

#类别文件行号问题描述
1非法icon名views/admin.php22$this->icon('robot', 16) — 'robot' 不在 TemplateCompiler 图标映射表中,将返回空白占位符 &#xf128;


11. user_profile

文件:

  • views/front.php

问题:

#类别文件行号问题描述
1缺少$this->e()views/front.php37<input name="csrf" value="<?php echo $csrfToken; ?>"> 未转义(虽为hex安全值,但与规范不一致)


12. mod_system

文件:

  • views/_reports_panel.php
  • views/_config_panel.php

问题:

#类别文件行号问题描述
1缺少$this->e()views/_reports_panel.php47, 50, 90, 181, 187, 193$csrfToken、$defaultBanDays 等变量输出未用 $this->e() 转义
2缺少$this->e()views/_config_panel.php20<input name="csrf" value="<?php echo $csrfToken; ?>"> 未转义


13. invite

文件:

  • views/index.php

问题:

#类别文件行号问题描述
1缺少$this->e()views/index.php30<input name="csrf" value="<?php echo $csrfToken; ?>"> 未转义
2缺少$this->e()views/index.php55<td><?php echo $status; ?></td> 未转义


各插件合规情况汇总

插件内联CSS/JS硬编码URL缺$this->e()非法icon语言key格式缺失lang文件缺filemtime
content_review❌❌————❌
seo——————❌
friend_links—❌————❌
daily_checkin—❌————❌
red_packet—❌————❌
dice❌❌————✅
quiz_duel—❌—————
notifications—❌—————
medal—❌❌————
ai_assistant———❌———
user_profile——❌————
mod_system——❌————
invite——❌————


良好示例(供参考)

以下插件的代码实现符合规范,可作为其他插件的参考:

插件文件正确做法
task_centerhook/layout_head_end.php<?php echo \defined('BASE_PATH') ? BASE_PATH : ''; ?>/plugins/task_center/assets/style.css + filemtime
qaviews/*.php正确使用 BASE_PATH + filemtime
single_pageviews/*.php正确使用 BASE_PATH
code_repoviews/*.php使用 $base 变量封装 BASE_PATH
post_favoritehook/layout_head_end.php正确使用 filemtime
points_mallhook/layout_head_end.php正确使用 filemtime
mod_systemPlugin.php在插件初始化时正确使用 filemtime 注册资源
code_auditviews/*.php正确使用 filemtime
diceviews/index.phphref="<?php echo $this->url('/plugins/dice/assets/style.css?v=' . (@filemtime(__DIR__ . '/../assets/style.css') ?: 1)); ?>"


修复优先级建议

高优先级(安全风险):

  1. mod_system / invite / medal / user_profile — 缺少 $this->e() 转义,存在XSS风险
  2. ai_assistant — 非法icon名称导致图标不显示

中优先级(功能兼容性):

  1. 所有插件的硬编码 /plugins/xxx/ URL — 影响子目录部署(BASE_PATH场景)
  2. content_review / dice — 内联JS应移至 assets/ 目录

低优先级(规范性):

  1. 所有缺少 filemtime 版本参数的资源URL — 影响浏览器缓存更新
  2. seo / friend_links / daily_checkin / red_packet / quiz_duel / notifications — 仅硬编码URL问题
轻量级、高性能、零 MySQL 依赖的PHP社区系统。
| 浏览 1 次 | 回复 0 次

全部回复 (0)

暂无回复

请 登录