mirror of
https://github.com/vastsa/FileCodeBox.git
synced 2026-11-28 11:07:17 +08:00
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3c135eb29f | ||
|
|
0d82fbe26a | ||
|
|
eb2db8f507 | ||
|
|
18d344cc9b |
No files matched your search
@@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
".": "2.5.6"
|
".": "2.6.1"
|
||||||
}
|
}
|
||||||
+10
-4
@@ -1567,10 +1567,16 @@ class ConfigService:
|
|||||||
detail="storage_limit 不能小于 0",
|
detail="storage_limit 不能小于 0",
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
# 只校验"发生变化"的值:升级前存入的旧格式 background(相对路径、含空格
|
||||||
validate_background_url(next_config.get("background", ""))
|
# 或括号)在旧版本是合法的,若每次保存都重新校验,存量部署会连无关设置项
|
||||||
except ValueError as exc:
|
# 都保存不了(一律 400)。渲染侧仍然 html 转义,而任何修改都必须通过校验。
|
||||||
raise HTTPException(status_code=400, detail=str(exc))
|
current_background = str(settings.background or "")
|
||||||
|
candidate_background = str(next_config.get("background") or "")
|
||||||
|
if candidate_background != current_background:
|
||||||
|
try:
|
||||||
|
validate_background_url(candidate_background)
|
||||||
|
except ValueError as exc:
|
||||||
|
raise HTTPException(status_code=400, detail=str(exc))
|
||||||
|
|
||||||
if admin_password_changed:
|
if admin_password_changed:
|
||||||
next_config["jwt_secret"] = generate_jwt_secret()
|
next_config["jwt_secret"] = generate_jwt_secret()
|
||||||
|
|||||||
+3
-1
@@ -174,7 +174,9 @@ def verify_password(password: str, hashed: str) -> bool:
|
|||||||
p=int(p),
|
p=int(p),
|
||||||
maxmem=_SCRYPT_MAXMEM,
|
maxmem=_SCRYPT_MAXMEM,
|
||||||
).hex()
|
).hex()
|
||||||
except (ValueError, TypeError):
|
# 默认解释器对超范围的 n/r/p 抛 TypeError/ValueError;部分构建会抛
|
||||||
|
# OverflowError,一并视为校验失败,避免坏掉的存量哈希影响登录路径。
|
||||||
|
except (ValueError, TypeError, OverflowError):
|
||||||
return False
|
return False
|
||||||
return hmac.compare_digest(password_hash, stored_hash)
|
return hmac.compare_digest(password_hash, stored_hash)
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
version: "3"
|
version: "3"
|
||||||
services:
|
services:
|
||||||
file-code-box:
|
file-code-box:
|
||||||
image: lanol/filecodebox:2.5.6 # x-release-please-version
|
image: lanol/filecodebox:2.6.1 # x-release-please-version
|
||||||
volumes:
|
volumes:
|
||||||
- fcb-data:/app/data:rw
|
- fcb-data:/app/data:rw
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|||||||
@@ -1,5 +1,38 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [2.6.1](https://github.com/vastsa/FileCodeBox/compare/v2.6.0...v2.6.1) (2026-09-14)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* don't let a legacy background value block settings saves ([eb2db8f](https://github.com/vastsa/FileCodeBox/commit/eb2db8f507e3198e0ae45b976bdd90eab2f7d1ed))
|
||||||
|
* 存量 background 值不再阻塞后台设置保存([#514](https://github.com/vastsa/FileCodeBox/issues/514) 升级回归) ([0d82fbe](https://github.com/vastsa/FileCodeBox/commit/0d82fbe26ad06ca77af7b2b5aa05f514e8362295))
|
||||||
|
|
||||||
|
## [2.6.0](https://github.com/vastsa/FileCodeBox/compare/v2.5.6...v2.6.0) (2026-09-14)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* declare missing config keys (opendal_scheme, chunk_expire_hours) and add config schema guard ([c5d525d](https://github.com/vastsa/FileCodeBox/commit/c5d525df08bb9534d1efb3ab5ff9357b52240fe9))
|
||||||
|
* rename all config keys to snake_case with DB migration 007 ([5121db6](https://github.com/vastsa/FileCodeBox/commit/5121db6edcdac57318d058e28d7249efb9ea4d03))
|
||||||
|
* upgrade password hashing to memory-hard scrypt with transparent rehash ([443cfe7](https://github.com/vastsa/FileCodeBox/commit/443cfe7472693bb954845f4cc4ac77e3abfcbd23))
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* FileCodes.expired_count defaults to -1 (time-based) instead of instantly-expired 0 (D4) ([3c93718](https://github.com/vastsa/FileCodeBox/commit/3c93718d4b2f3a8e93978c7eb7a4a3b2553b0855))
|
||||||
|
* save_file accepts plain binary streams; repair admin local file share (D2) ([bb95017](https://github.com/vastsa/FileCodeBox/commit/bb95017aa398e80e5eca512aa9a330aaeeceb364))
|
||||||
|
* serialize KeyValue JSON read-modify-write sections behind a process lock (D5) ([0038636](https://github.com/vastsa/FileCodeBox/commit/0038636a2a5fc8e73f944c38789dce8de0354c3a))
|
||||||
|
* snake_case the public config contract (D7 follow-up) ([800bac0](https://github.com/vastsa/FileCodeBox/commit/800bac01285dd6eb827e28460996997dbb80e2c3))
|
||||||
|
* validate background config as http(s) URL to close CSS quote-breakout in 2023 theme ([4cab625](https://github.com/vastsa/FileCodeBox/commit/4cab625d5ab2fe5921f8f621ebe015623afb6fb8))
|
||||||
|
|
||||||
|
|
||||||
|
### Performance Improvements
|
||||||
|
|
||||||
|
* cache settings refresh behind a 2s TTL, force refresh on write paths (D6) ([61d72ab](https://github.com/vastsa/FileCodeBox/commit/61d72ab6ccba5df121945ef825de2967c45888b4))
|
||||||
|
* dashboard counters and storage quota use SQL aggregation (D3) ([baecebd](https://github.com/vastsa/FileCodeBox/commit/baecebd81efc9677acac29d5335e281d6bb5a252))
|
||||||
|
* make is_config_initialized cheap — no scrypt on the per-request probe (D1) ([ec424dd](https://github.com/vastsa/FileCodeBox/commit/ec424dd9093d94b69ec3a118f321cd1f85c7dd54))
|
||||||
|
|
||||||
## [2.5.6](https://github.com/vastsa/FileCodeBox/compare/v2.5.5...v2.5.6) (2026-09-01)
|
## [2.5.6](https://github.com/vastsa/FileCodeBox/compare/v2.5.5...v2.5.6) (2026-09-01)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
<!-- Current release: 2.5.6 x-release-please-version -->
|
<!-- Current release: 2.6.1 x-release-please-version -->
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -42,7 +42,7 @@ docker run -d --restart unless-stopped \
|
|||||||
--log-opt max-size=10m \
|
--log-opt max-size=10m \
|
||||||
--log-opt max-file=3 \
|
--log-opt max-file=3 \
|
||||||
--name filecodebox \
|
--name filecodebox \
|
||||||
lanol/filecodebox:2.5.6 # x-release-please-version
|
lanol/filecodebox:2.6.1 # x-release-please-version
|
||||||
```
|
```
|
||||||
|
|
||||||
Open `http://localhost:12345` and complete the first-run setup.
|
Open `http://localhost:12345` and complete the first-run setup.
|
||||||
|
|||||||
+1
-1
@@ -42,7 +42,7 @@ docker run -d --restart unless-stopped \
|
|||||||
--log-opt max-size=10m \
|
--log-opt max-size=10m \
|
||||||
--log-opt max-file=3 \
|
--log-opt max-file=3 \
|
||||||
--name filecodebox \
|
--name filecodebox \
|
||||||
lanol/filecodebox:2.5.6 # x-release-please-version
|
lanol/filecodebox:2.6.1 # x-release-please-version
|
||||||
```
|
```
|
||||||
|
|
||||||
打开 `http://localhost:12345`,按引导完成首次初始化。
|
打开 `http://localhost:12345`,按引导完成首次初始化。
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ docker run -d --restart unless-stopped \
|
|||||||
--log-opt max-size=10m \
|
--log-opt max-size=10m \
|
||||||
--log-opt max-file=3 \
|
--log-opt max-file=3 \
|
||||||
--name filecodebox \
|
--name filecodebox \
|
||||||
lanol/filecodebox:2.5.6 # x-release-please-version
|
lanol/filecodebox:2.6.1 # x-release-please-version
|
||||||
```
|
```
|
||||||
|
|
||||||
访问 `http://localhost:12345`,完成首次初始化。生产环境建议固定版本号;`latest` 指向最新正式版。
|
访问 `http://localhost:12345`,完成首次初始化。生产环境建议固定版本号;`latest` 指向最新正式版。
|
||||||
|
|||||||
+1
-1
@@ -32,7 +32,7 @@ docker run -d --restart unless-stopped \
|
|||||||
--log-opt max-size=10m \
|
--log-opt max-size=10m \
|
||||||
--log-opt max-file=3 \
|
--log-opt max-file=3 \
|
||||||
--name filecodebox \
|
--name filecodebox \
|
||||||
lanol/filecodebox:2.5.6 # x-release-please-version
|
lanol/filecodebox:2.6.1 # x-release-please-version
|
||||||
```
|
```
|
||||||
|
|
||||||
Open `http://localhost:12345` and complete first-run setup. Pin a version in production; `latest` tracks the newest stable release.
|
Open `http://localhost:12345` and complete first-run setup. Pin a version in production; `latest` tracks the newest stable release.
|
||||||
|
|||||||
@@ -73,5 +73,63 @@ class ConfigServiceBackgroundGuardTests(SettingsOverrideMixin, unittest.TestCase
|
|||||||
await close_db()
|
await close_db()
|
||||||
|
|
||||||
|
|
||||||
|
class LegacyBackgroundUpgradeTests(SettingsOverrideMixin, unittest.TestCase):
|
||||||
|
"""存量部署升级:旧版本合法、新校验不接受的值,不得阻塞设置保存。"""
|
||||||
|
|
||||||
|
def test_unchanged_legacy_background_does_not_block_unrelated_save(self):
|
||||||
|
asyncio.run(self._unchanged_legacy_allows_save())
|
||||||
|
|
||||||
|
async def _unchanged_legacy_allows_save(self):
|
||||||
|
await init_memory_db()
|
||||||
|
try:
|
||||||
|
from apps.base.config import refresh_settings
|
||||||
|
from apps.base.models import KeyValue
|
||||||
|
|
||||||
|
# 旧版本合法(相对路径 + 空格),新的 http(s) 校验会拒绝
|
||||||
|
legacy = "/static/bg image.png"
|
||||||
|
await KeyValue.create(
|
||||||
|
key="settings", value={"background": legacy, "name": "old"}
|
||||||
|
)
|
||||||
|
await refresh_settings(force=True)
|
||||||
|
|
||||||
|
service = ConfigService()
|
||||||
|
# 修复前这里会 400,导致存量部署连无关设置项都保存不了
|
||||||
|
await service.update_config({"name": "new"})
|
||||||
|
|
||||||
|
record = await KeyValue.filter(key="settings").first()
|
||||||
|
self.assertEqual(record.value.get("background"), legacy, "旧值应原样保留")
|
||||||
|
self.assertEqual(record.value.get("name"), "new")
|
||||||
|
finally:
|
||||||
|
await close_db()
|
||||||
|
|
||||||
|
def test_changing_background_is_still_validated(self):
|
||||||
|
asyncio.run(self._change_still_validated())
|
||||||
|
|
||||||
|
async def _change_still_validated(self):
|
||||||
|
await init_memory_db()
|
||||||
|
try:
|
||||||
|
from fastapi import HTTPException
|
||||||
|
|
||||||
|
from apps.base.config import refresh_settings
|
||||||
|
from apps.base.models import KeyValue
|
||||||
|
|
||||||
|
await KeyValue.create(key="settings", value={"background": "/legacy/bg.png"})
|
||||||
|
await refresh_settings(force=True)
|
||||||
|
|
||||||
|
service = ConfigService()
|
||||||
|
# 修改为恶意值仍然被拒
|
||||||
|
with self.assertRaises(HTTPException) as ctx:
|
||||||
|
await service.update_config(
|
||||||
|
{"background": "x') ;background:url(https://evil.com/)"}
|
||||||
|
)
|
||||||
|
self.assertEqual(ctx.exception.status_code, 400)
|
||||||
|
# 修改为合法值可以通过
|
||||||
|
await service.update_config({"background": "https://ok.example/bg.png"})
|
||||||
|
record = await KeyValue.filter(key="settings").first()
|
||||||
|
self.assertEqual(record.value.get("background"), "https://ok.example/bg.png")
|
||||||
|
finally:
|
||||||
|
await close_db()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
@@ -53,6 +53,11 @@ class PasswordHashSchemeTests(unittest.TestCase):
|
|||||||
self.assertFalse(verify_password("x", "scrypt$n$r$p$salt$zzz"))
|
self.assertFalse(verify_password("x", "scrypt$n$r$p$salt$zzz"))
|
||||||
self.assertFalse(verify_password("x", "sha256$only-two"))
|
self.assertFalse(verify_password("x", "sha256$only-two"))
|
||||||
self.assertFalse(verify_password("x", ""))
|
self.assertFalse(verify_password("x", ""))
|
||||||
|
# 超范围的 n/r/p:解释器抛 TypeError/ValueError(部分构建抛 OverflowError),
|
||||||
|
# 都必须被吞掉并判为不匹配,而不是让登录及每个请求 500
|
||||||
|
self.assertFalse(
|
||||||
|
verify_password("x", "scrypt$99999999999999999999999999$8$1$aa$bb")
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class TransparentRehashTests(SettingsOverrideMixin, unittest.TestCase):
|
class TransparentRehashTests(SettingsOverrideMixin, unittest.TestCase):
|
||||||
|
|||||||
Reference in new issue
Block a user