fix(安全/健壮性): 全工作区审查修复——鉴权兜底扩展+路径穿越+忙等+泄漏
- AdminApiGuardFilter 兜底扩展到 /api/collect-data、/api/price-track:无需鉴权的 工具接口纳入 JWT/内部令牌校验(原匿名可达即越权读写他人数据) - pricetrack asinFiles 改为仅允许上传临时目录内文件(canonical 前缀校验), 修复请求路径直接 new File 可读服务器任意 csv/xlsx 的穿越 - dedupe 删除导入逐行 REQUIRES_NEW 事务改 500 条一批 IN 删除,50 万行导入 由 50 万个事务收敛为千级 - 前端记住密码 XOR 硬编码密钥改 WebCrypto AES-GCM(密钥随机生成独立存储), 登录流程接口改 async 并保证自动登录恢复时序 - 任务进度轮询失败按指数退避(原固定 5s 无限撞);下载进度终态条目 2 分钟 自动清理(原永久堆积);AmazonConsolePage statusTimer 卸载清理
This commit is contained in:
+24
-6
@@ -867,6 +867,7 @@ public class DedupeTotalDataService {
|
||||
}
|
||||
|
||||
Set<String> seenInFile = new HashSet<>();
|
||||
List<String> pendingDeletes = new ArrayList<>();
|
||||
int totalRows = Math.max(sheet.getLastRowNum(), 0);
|
||||
if (maxImportRows > 0 && totalRows > maxImportRows) {
|
||||
throw new BusinessException("导入行数超过上限: " + maxImportRows);
|
||||
@@ -919,12 +920,11 @@ public class DedupeTotalDataService {
|
||||
continue;
|
||||
}
|
||||
|
||||
int deletedThisRow = newRequiresNewTemplate().execute(
|
||||
status -> deleteByDataValue(dataValue, scope, groupId));
|
||||
if (deletedThisRow > 0) {
|
||||
deletedCount += deletedThisRow;
|
||||
} else {
|
||||
skippedCount++;
|
||||
// 批量删除:攒批 + IN 一次删,避免 50 万行 = 50 万个 REQUIRES_NEW 事务的 N+1
|
||||
pendingDeletes.add(dataValue);
|
||||
if (pendingDeletes.size() >= DELETE_BATCH_SIZE) {
|
||||
deletedCount += deleteBatchByDataValues(pendingDeletes, scope, groupId);
|
||||
pendingDeletes = new ArrayList<>();
|
||||
}
|
||||
if (progress != null) {
|
||||
progress.setProcessedRows(rowNum);
|
||||
@@ -933,6 +933,9 @@ public class DedupeTotalDataService {
|
||||
progress.setSkippedCount(skippedCount);
|
||||
}
|
||||
}
|
||||
if (!pendingDeletes.isEmpty()) {
|
||||
deletedCount += deleteBatchByDataValues(pendingDeletes, scope, groupId);
|
||||
}
|
||||
|
||||
DedupeTotalDataImportVo vo = new DedupeTotalDataImportVo();
|
||||
vo.setTotalRows(totalRows);
|
||||
@@ -1016,6 +1019,21 @@ public class DedupeTotalDataService {
|
||||
return dedupeTotalDataMapper.delete(query);
|
||||
}
|
||||
|
||||
/** 批量删除大小:单事务 IN 删除的阈值,兼顾锁窗口与事务日志。 */
|
||||
private static final int DELETE_BATCH_SIZE = 500;
|
||||
|
||||
/** 整批一个独立事务按 IN 一次删除;返回实际删除行数(计入 deletedCount,不再额外计 skipped)。 */
|
||||
private int deleteBatchByDataValues(List<String> dataValues, AccessScope scope, Long groupId) {
|
||||
List<String> batch = List.copyOf(dataValues);
|
||||
Integer deleted = newRequiresNewTemplate().execute(status -> {
|
||||
LambdaQueryWrapper<DedupeTotalDataEntity> query = new LambdaQueryWrapper<DedupeTotalDataEntity>()
|
||||
.in(DedupeTotalDataEntity::getDataValue, batch);
|
||||
applyGroupScope(query, scope, groupId);
|
||||
return dedupeTotalDataMapper.delete(query);
|
||||
});
|
||||
return deleted == null ? 0 : deleted;
|
||||
}
|
||||
|
||||
private AccessScope resolveAccessScope(Long operatorId) {
|
||||
AdminUserEntity operator = getOperator(operatorId);
|
||||
if (isSuperAdmin(operator)) {
|
||||
|
||||
Reference in New Issue
Block a user