fix: 修复后端竞态/安全/数据处理问题并移除冗余 outImage 列
首次激活改条件更新消除并发竞态;备份恢复补模型全集与版本校验防清库; 审核列表分页总数、操作日志未捕获 Promise、出库导入重复码、加密密钥可编辑、 溯源码盐以 env 为准、证书按 originKey reconcile、env 加载去重等修复; 新增 parseBigId 防非法入参 500、全局安全响应头、去除 SVG 上传、接入 throttler 限流、 入队失败补偿、hashData 稳定序列化、无效码负缓存、看板已激活口径调整; 移除冗余 TraceCode.outImage 列统一 outImages(迁移 drop_trace_code_out_image)。
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { createCipheriv, createDecipheriv, createHash, randomBytes } from 'crypto';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
@@ -25,7 +25,6 @@ const EDITABLE_KEYS = [
|
||||
'ossBucket',
|
||||
'ossAccessKeyId',
|
||||
'ossAccessKeySecret',
|
||||
'settingsEncryptionKey',
|
||||
'storageMigrationTarget',
|
||||
'storageMigrationFingerprint',
|
||||
'storageMigrationCopied',
|
||||
@@ -43,6 +42,8 @@ const ENCRYPTED_PREFIX = 'enc:v1:';
|
||||
|
||||
@Injectable()
|
||||
export class SettingsService {
|
||||
private readonly logger = new Logger(SettingsService.name);
|
||||
|
||||
constructor(
|
||||
private readonly prisma: PrismaService,
|
||||
private readonly config: ConfigService,
|
||||
@@ -167,7 +168,10 @@ export class SettingsService {
|
||||
const decipher = createDecipheriv('aes-256-gcm', await this.encryptionKey(), iv);
|
||||
decipher.setAuthTag(tag);
|
||||
return Buffer.concat([decipher.update(encrypted), decipher.final()]).toString('utf8');
|
||||
} catch {
|
||||
} catch (e) {
|
||||
// 解密失败通常意味着 SETTING_ENCRYPTION_KEY 与加密时不一致(配置损坏),
|
||||
// 显式告警而非静默返回空串,避免把「配置损坏」误当成「未配置」
|
||||
this.logger.warn(`密钥解密失败,可能是 SETTING_ENCRYPTION_KEY 已变更:${(e as Error).message}`);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user