mirror of
https://gitee.com/spark-store-project/spark-store
synced 2026-09-21 14:10:11 +08:00
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:
+19
-18
@@ -133,23 +133,30 @@ export const createUpdateCenterStore = (): UpdateCenterStore => {
|
||||
isBound = false;
|
||||
};
|
||||
|
||||
// 先刷新软件源,再加载更新列表;刷新失败仅告警,不阻断扫描
|
||||
const runSystemUpdateThenLoad = async (
|
||||
storeFilter: StoreFilter,
|
||||
load: (filter: StoreFilter) => Promise<UpdateCenterSnapshot>,
|
||||
): Promise<void> => {
|
||||
try {
|
||||
await window.ipcRenderer.invoke(
|
||||
"update-center-run-system-update",
|
||||
storeFilter,
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("[UpdateCenter] system update failed", error);
|
||||
}
|
||||
const nextSnapshot = await load(storeFilter);
|
||||
applySnapshot(nextSnapshot);
|
||||
};
|
||||
|
||||
const open = async (storeFilter: StoreFilter = "both"): Promise<void> => {
|
||||
lastStoreFilter = storeFilter;
|
||||
resetSessionState();
|
||||
isOpen.value = true;
|
||||
loading.value = true;
|
||||
try {
|
||||
// 打开更新中心时先刷新软件源,避免使用旧的 apt 缓存导致扫不到更新
|
||||
try {
|
||||
await window.ipcRenderer.invoke(
|
||||
"update-center-run-system-update",
|
||||
storeFilter,
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("[UpdateCenter] open: system update failed", error);
|
||||
}
|
||||
const nextSnapshot = await window.updateCenter.open(storeFilter);
|
||||
applySnapshot(nextSnapshot);
|
||||
await runSystemUpdateThenLoad(storeFilter, window.updateCenter.open);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
@@ -161,13 +168,7 @@ export const createUpdateCenterStore = (): UpdateCenterStore => {
|
||||
lastStoreFilter = storeFilter;
|
||||
loading.value = true;
|
||||
try {
|
||||
// 先运行系统更新(aptss update / apm update),确保本地包信息最新
|
||||
await window.ipcRenderer.invoke(
|
||||
"update-center-run-system-update",
|
||||
storeFilter,
|
||||
);
|
||||
const nextSnapshot = await window.updateCenter.refresh(storeFilter);
|
||||
applySnapshot(nextSnapshot);
|
||||
await runSystemUpdateThenLoad(storeFilter, window.updateCenter.refresh);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user