fix/refactor: 更新中心扫描与多项安全加固(经专业审计)

更新中心扫描修复:
- updateCenter.ts: 抽出 runSystemUpdateThenLoad, open/refresh 共用,
  打开时即刷新双源(aptss ssupdate + apm update), 失败仅告警不阻断扫描
- shell-caller.sh: ssupdate 分支 exit $? 恒 0 吞掉刷新失败, 改为 exit $exit_code
- update-center/query.ts: 移除 nextVersion===currentVersion 误删真实更新项逻辑,
  信任 aptss 上游 upgradable 判断

安全加固:
- AppDetailModal.vue: 新增 sanitizeMoreContent 剥除 HTML 标签后再 v-html, 防 XSS
- InstalledAppsModal.vue: ALLOWED_LOCAL_ICON_PREFIXES 收紧为具体子目录, 缩小
  本地文件读取面
- install-manager.ts: filename 用 path.basename 防路径遍历; 包名/文件名 PKGNAME_PATTERN 校验
- index.ts: 临时目录改用 spark-store-${pid} 隔离, will-quit 清理对应目录

经 7 维度专业审计(安全/功能/类型/可维护/资源/性能/兼容)通过。
This commit is contained in:
xiyidaiwa
2026-08-10 21:42:36 +08:00
parent 0be6f8ad11
commit 3f22207505
7 changed files with 180 additions and 134 deletions
+17 -3
View File
@@ -296,7 +296,7 @@
</h3>
<div
class="text-sm leading-relaxed text-slate-600 dark:text-slate-300 space-y-2"
v-html="displayApp.more.replace(/\n/g, '<br>')"
v-html="sanitizeMoreContent(displayApp.more)"
></div>
</div>
<div
@@ -386,7 +386,6 @@
</div>
</Transition>
<!-- 元数据详情弹窗 -->
<Transition
enter-active-class="duration-200 ease-out"
@@ -586,6 +585,19 @@ import {
// import { buildReviewAppKey, buildReviewTags } from "../modules/appIdentity";
import type { App, AppReview, ReviewTags } from "../global/typedefinition";
/**
* 净化后端返回的应用描述(v-html 前严格去除所有标签)。
* 程序先将用户内容中的所有 HTML 标签剥离,再将 \n 转为 <br>。
* <br> 是纯程序生成,不含任何用户输入,可安全放入 v-html。
*/
const sanitizeMoreContent = (raw: string): string => {
if (!raw) return "";
// 去除所有 HTML 标签,避免 XSS(包括 <script>/onerror/等)
const stripped = raw.replace(/<[^>]*>/g, "");
// 将 \n 转为安全的 <br>
return stripped.replace(/\n/g, "<br>");
};
const attrs = useAttrs();
const props = defineProps<{
@@ -846,7 +858,9 @@ const handleRemove = () => {
// 双来源安装时,"打开"需先让用户选择打开 APM 还是 Spark 版
const openChoiceVisible = ref(false);
const openOrigins = (app: App | null): Array<"spark" | "apm"> =>
app?.origins && app.origins.length > 0 ? app.origins : [app?.origin ?? "spark"];
app?.origins && app.origins.length > 0
? app.origins
: [app?.origin ?? "spark"];
const onOpenClick = () => {
const app = displayApp.value;