加固(发布前审查): 补重复列守卫、有效二维码不再反复重开
按发布前独立审查(gpt-6.1-sol)的结论处理,无需返工的项一并加固:
- convergeSemiAutoTaskState 增加列去重守卫:同一列同时出现在类型化字段和 `extra` 里时,
按原实现会拼出 `col = $1, col = $2` 直接 500;现在提前抛
`semi_auto_task_patch_column_duplicated` 并带列名。
- 首次绑定已有有效二维码时,未显式要求刷新的调用直接复用(`first_bind_qr_pending` 且无
forceRebind/intent 时不再调用 startHuyaBinding),避免任何轮询或重入路径反复重开码;
「扫错角色」「已识别待确认角色」等需要换一个角色的状态仍是显式刷新,行为不变。
- 审查中提到的「截图资产可能接受失效文件」已确认不成立:getFileAssetByObjectKey 按
`status = 'active'` 查询;浏览器登录态下发的 RBAC 也已确认由
`router.use('/semi-auto', requireAdminRoles([...]))` 覆盖。
This commit is contained in:
@@ -690,7 +690,10 @@ export async function startPublicBinding(
|
|||||||
decision.allowedActions.includes('start_rebind') ||
|
decision.allowedActions.includes('start_rebind') ||
|
||||||
decision.allowedActions.includes('refresh_rebind_qr')
|
decision.allowedActions.includes('refresh_rebind_qr')
|
||||||
// 首次绑定允许自动出码(页面进入第一步就要码);换绑必须由客户显式点「重新扫码换绑」触发。
|
// 首次绑定允许自动出码(页面进入第一步就要码);换绑必须由客户显式点「重新扫码换绑」触发。
|
||||||
const wantsFirstBinding = canStartFirstBinding
|
// 已经有一张有效二维码时,未显式要求刷新的调用直接复用,避免任何轮询/重入路径反复重开码。
|
||||||
|
const explicitRefresh = input.intent === 'rebind' || input.forceRebind === true
|
||||||
|
const reuseFirstBindingQr = decision.flowState === 'first_bind_qr_pending' && !explicitRefresh
|
||||||
|
const wantsFirstBinding = canStartFirstBinding && !reuseFirstBindingQr
|
||||||
const wantsRebind = (input.intent === 'rebind' || input.forceRebind === true) && canStartRebind
|
const wantsRebind = (input.intent === 'rebind' || input.forceRebind === true) && canStartRebind
|
||||||
if (!wantsFirstBinding && !wantsRebind) {
|
if (!wantsFirstBinding && !wantsRebind) {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -459,6 +459,14 @@ export async function convergeSemiAutoTaskState(
|
|||||||
pushParam(meta.column, value)
|
pushParam(meta.column, value)
|
||||||
}
|
}
|
||||||
for (const [column, value] of Object.entries(patch.extra || {})) {
|
for (const [column, value] of Object.entries(patch.extra || {})) {
|
||||||
|
if (assignments.some((item) => item.startsWith(`${column} = `))) {
|
||||||
|
// 同一列在类型化字段与 extra 里同时出现会拼出 `col = $1, col = $2`,PG 直接报错。
|
||||||
|
throw createHttpError('半自动任务状态补丁包含重复列', {
|
||||||
|
statusCode: 500,
|
||||||
|
errorCode: 'semi_auto_task_patch_column_duplicated',
|
||||||
|
context: { column },
|
||||||
|
})
|
||||||
|
}
|
||||||
if (!EXTRA_WRITABLE_COLUMNS.has(column)) {
|
if (!EXTRA_WRITABLE_COLUMNS.has(column)) {
|
||||||
throw createHttpError('半自动任务状态补丁包含未登记列', {
|
throw createHttpError('半自动任务状态补丁包含未登记列', {
|
||||||
statusCode: 500,
|
statusCode: 500,
|
||||||
|
|||||||
Reference in New Issue
Block a user