4 Commits

Author SHA1 Message Date
39724e6e73 fix(audit): 修复3个审计发现的bug
- migrateCloudConfigs 缺 } 导致 notify_config/cloud_type_uid 嵌套在 promotion_account 内不迁移
- cloud_configs_v2 INSERT/SELECT 缺 cloud_type_uid/cookie_uid 导致数据丢失
- deploy.sh 密码嵌入改成 docker exec -e 传参(防特殊字符注入)
2026-05-19 14:23:26 +08:00
288d30698a hotfix: 补回system_configs表缺失的); 2026-05-19 05:21:28 +08:00
a9dc056506 hotfix: 移除push_users表多余的);(导致SQL语法错误→容器重启) 2026-05-19 05:13:24 +08:00
9ef58b5724 fix: push_users表 + cookie_uid列 + __uid正则修复 + deploy.sh重写 2026-05-19 05:06:17 +08:00
5 changed files with 16 additions and 6 deletions

View File

@@ -1 +1 @@
0.4.9 0.4.13

View File

@@ -1 +1 @@
0.4.9 0.4.13

Binary file not shown.

View File

@@ -35,9 +35,9 @@ function decryptCookie(encrypted: string): string {
function extractCookieUid(cookie: string): string { function extractCookieUid(cookie: string): string {
if (!cookie) return ''; if (!cookie) return '';
let m = cookie.match(/__uid=([a-zA-Z0-9+/=_-]+)/); let m = cookie.match(/__uid=([^;]+)/);
if (m) return m[1]; if (m) return m[1];
m = cookie.match(/b-user-id=([a-zA-Z0-9-]+)/); m = cookie.match(/b-user-id=([^;]+)/);
if (m) return m[1]; if (m) return m[1];
return ''; return '';
} }

View File

@@ -40,6 +40,7 @@ function runMigrations(db: Database.Database): void {
cloud_type TEXT NOT NULL, cloud_type TEXT NOT NULL,
cookie TEXT, cookie TEXT,
cloud_type_uid TEXT DEFAULT NULL, cloud_type_uid TEXT DEFAULT NULL,
cookie_uid TEXT DEFAULT NULL,
nickname TEXT, nickname TEXT,
is_active INTEGER NOT NULL DEFAULT 1, is_active INTEGER NOT NULL DEFAULT 1,
storage_used TEXT, storage_used TEXT,
@@ -109,6 +110,13 @@ function runMigrations(db: Database.Database): void {
description TEXT, description TEXT,
updated_at TEXT NOT NULL DEFAULT (datetime('now', 'localtime')) updated_at TEXT NOT NULL DEFAULT (datetime('now', 'localtime'))
); );
CREATE TABLE IF NOT EXISTS push_users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
account TEXT NOT NULL UNIQUE,
notify_config TEXT,
created_at TEXT NOT NULL DEFAULT (datetime('now','localtime')),
updated_at TEXT NOT NULL DEFAULT (datetime('now','localtime'))
);
CREATE TABLE IF NOT EXISTS content_cache ( CREATE TABLE IF NOT EXISTS content_cache (
id INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER PRIMARY KEY AUTOINCREMENT,
@@ -209,6 +217,7 @@ function migrateCloudConfigs(db: Database.Database): void {
cookie TEXT, cookie TEXT,
cloud_type_uid TEXT DEFAULT NULL, cloud_type_uid TEXT DEFAULT NULL,
nickname TEXT, nickname TEXT,
cookie_uid TEXT DEFAULT NULL,
is_active INTEGER NOT NULL DEFAULT 1, is_active INTEGER NOT NULL DEFAULT 1,
storage_used TEXT, storage_used TEXT,
storage_total TEXT, storage_total TEXT,
@@ -221,8 +230,8 @@ function migrateCloudConfigs(db: Database.Database): void {
created_at TEXT NOT NULL DEFAULT (datetime('now', 'localtime')), created_at TEXT NOT NULL DEFAULT (datetime('now', 'localtime')),
updated_at TEXT NOT NULL DEFAULT (datetime('now', 'localtime')) updated_at TEXT NOT NULL DEFAULT (datetime('now', 'localtime'))
); );
INSERT INTO cloud_configs_v2 (id, cloud_type, cookie, nickname, is_active, storage_used, storage_total, checkin_status, last_checkin_at, checkin_message, consecutive_failures, last_used_at, total_saves, created_at, updated_at) INSERT INTO cloud_configs_v2 (id, cloud_type, cookie, cloud_type_uid, cookie_uid, nickname, is_active, storage_used, storage_total, checkin_status, last_checkin_at, checkin_message, consecutive_failures, last_used_at, total_saves, created_at, updated_at)
SELECT id, cloud_type, cookie, nickname, is_active, storage_used, storage_total, COALESCE(checkin_status,'none'), last_checkin_at, checkin_message, COALESCE(consecutive_failures,0), last_used_at, COALESCE(total_saves,0), created_at, updated_at FROM cloud_configs; SELECT id, cloud_type, cookie, cloud_type_uid, cookie_uid, nickname, is_active, storage_used, storage_total, COALESCE(checkin_status,'none'), last_checkin_at, checkin_message, COALESCE(consecutive_failures,0), last_used_at, COALESCE(total_saves,0), created_at, updated_at FROM cloud_configs;
DROP TABLE cloud_configs; DROP TABLE cloud_configs;
ALTER TABLE cloud_configs_v2 RENAME TO cloud_configs; ALTER TABLE cloud_configs_v2 RENAME TO cloud_configs;
`); `);
@@ -248,6 +257,7 @@ function migrateCloudConfigs(db: Database.Database): void {
if (!hasPromotionAccount) { if (!hasPromotionAccount) {
db.exec("ALTER TABLE cloud_configs ADD COLUMN promotion_account TEXT DEFAULT NULL"); db.exec("ALTER TABLE cloud_configs ADD COLUMN promotion_account TEXT DEFAULT NULL");
console.log('[DB] cloud_configs migration: promotion_account column added'); console.log('[DB] cloud_configs migration: promotion_account column added');
}
// v0.3.5: notify_config for per-cloud push notification settings // v0.3.5: notify_config for per-cloud push notification settings
const hasNotifyConfig = db.prepare("SELECT sql FROM sqlite_master WHERE name='cloud_configs' AND sql LIKE '%notify_config%'").get(); const hasNotifyConfig = db.prepare("SELECT sql FROM sqlite_master WHERE name='cloud_configs' AND sql LIKE '%notify_config%'").get();