fix(diary): 系统性修复 DTO 输入验证 — 42 项审计发现中输入验证类全部修复
DTO 字段级验证: - version 字段全部添加 range(min=0) 防止负数 - 标签内容验证: 单个标签最长 30 字符,不允许空白 - 班级码正则: 仅允许字母数字,拒绝特殊字符 - 贴纸包 price 添加 range(min=0) 防止负价格 - thumbnail_url/image_url 添加 length(max=500) 限制 - 同步请求 data payload 限制 1MB/条 Handler validate() 调用补齐: - delete_journal: DeleteJournalReq 添加 Validate derive + handler 调用 - bind_child / unbind_child / delete_child_data: 补齐 req.validate() 调用 - join_class: 添加 validate_code() 字母数字检查 - sync_journals: 添加 validate_changes_data() payload 大小检查 审计覆盖: 5a-C01/02/03 + 5a-H02/03/04 + B-03 + 7b-C02
This commit is contained in:
@@ -94,6 +94,8 @@ where
|
||||
{
|
||||
require_permission(&ctx, "diary.parent.bind")?;
|
||||
|
||||
req.validate().map_err(|e| AppError::Validation(e.to_string()))?;
|
||||
|
||||
let binding = ParentService::bind_child(
|
||||
ctx.tenant_id,
|
||||
ctx.user_id,
|
||||
@@ -259,6 +261,8 @@ where
|
||||
{
|
||||
require_permission(&ctx, "diary.parent.bind")?;
|
||||
|
||||
req.validate().map_err(|e| AppError::Validation(e.to_string()))?;
|
||||
|
||||
let count = ParentService::delete_child_data(
|
||||
ctx.tenant_id,
|
||||
ctx.user_id,
|
||||
@@ -301,6 +305,8 @@ where
|
||||
{
|
||||
require_permission(&ctx, "diary.parent.bind")?;
|
||||
|
||||
req.validate().map_err(|e| AppError::Validation(e.to_string()))?;
|
||||
|
||||
ParentService::unbind_child(ctx.tenant_id, ctx.user_id, req.child_id, &state.db).await?;
|
||||
|
||||
Ok(Json(ApiResponse {
|
||||
|
||||
Reference in New Issue
Block a user