feat(sora): 新增 Sora 平台支持并修复高危安全和性能问题
新增功能: - 新增 Sora 账号管理和 OAuth 认证 - 新增 Sora 视频/图片生成 API 网关 - 新增 Sora 任务调度和缓存机制 - 新增 Sora 使用统计和计费支持 - 前端增加 Sora 平台配置界面 安全修复(代码审核): - [SEC-001] 限制媒体下载响应体大小(图片 20MB、视频 200MB),防止 DoS 攻击 - [SEC-002] 限制 SDK API 响应大小(1MB),防止内存耗尽 - [SEC-003] 修复 SSRF 风险,添加 URL 验证并强制使用代理配置 BUG 修复(代码审核): - [BUG-001] 修复 for 循环内 defer 累积导致的资源泄漏 - [BUG-002] 修复图片并发槽位获取失败时已持有锁未释放的永久泄漏 性能优化(代码审核): - [PERF-001] 添加 Sentinel Token 缓存(3 分钟有效期),减少 PoW 计算开销 技术细节: - 使用 io.LimitReader 限制所有外部输入的大小 - 添加 urlvalidator 验证防止 SSRF 攻击 - 使用 sync.Map 实现线程安全的包级缓存 - 优化并发槽位管理,添加 releaseAll 模式防止泄漏 影响范围: - 后端:新增 Sora 相关数据模型、服务、网关和管理接口 - 前端:新增 Sora 平台配置、账号管理和监控界面 - 配置:新增 Sora 相关配置项和环境变量 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
124
backend/ent/soracachefile/soracachefile.go
Normal file
124
backend/ent/soracachefile/soracachefile.go
Normal file
@@ -0,0 +1,124 @@
|
||||
// Code generated by ent, DO NOT EDIT.
|
||||
|
||||
package soracachefile
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
)
|
||||
|
||||
const (
|
||||
// Label holds the string label denoting the soracachefile type in the database.
|
||||
Label = "sora_cache_file"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldTaskID holds the string denoting the task_id field in the database.
|
||||
FieldTaskID = "task_id"
|
||||
// FieldAccountID holds the string denoting the account_id field in the database.
|
||||
FieldAccountID = "account_id"
|
||||
// FieldUserID holds the string denoting the user_id field in the database.
|
||||
FieldUserID = "user_id"
|
||||
// FieldMediaType holds the string denoting the media_type field in the database.
|
||||
FieldMediaType = "media_type"
|
||||
// FieldOriginalURL holds the string denoting the original_url field in the database.
|
||||
FieldOriginalURL = "original_url"
|
||||
// FieldCachePath holds the string denoting the cache_path field in the database.
|
||||
FieldCachePath = "cache_path"
|
||||
// FieldCacheURL holds the string denoting the cache_url field in the database.
|
||||
FieldCacheURL = "cache_url"
|
||||
// FieldSizeBytes holds the string denoting the size_bytes field in the database.
|
||||
FieldSizeBytes = "size_bytes"
|
||||
// FieldCreatedAt holds the string denoting the created_at field in the database.
|
||||
FieldCreatedAt = "created_at"
|
||||
// Table holds the table name of the soracachefile in the database.
|
||||
Table = "sora_cache_files"
|
||||
)
|
||||
|
||||
// Columns holds all SQL columns for soracachefile fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldTaskID,
|
||||
FieldAccountID,
|
||||
FieldUserID,
|
||||
FieldMediaType,
|
||||
FieldOriginalURL,
|
||||
FieldCachePath,
|
||||
FieldCacheURL,
|
||||
FieldSizeBytes,
|
||||
FieldCreatedAt,
|
||||
}
|
||||
|
||||
// ValidColumn reports if the column name is valid (part of the table columns).
|
||||
func ValidColumn(column string) bool {
|
||||
for i := range Columns {
|
||||
if column == Columns[i] {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
var (
|
||||
// TaskIDValidator is a validator for the "task_id" field. It is called by the builders before save.
|
||||
TaskIDValidator func(string) error
|
||||
// MediaTypeValidator is a validator for the "media_type" field. It is called by the builders before save.
|
||||
MediaTypeValidator func(string) error
|
||||
// DefaultSizeBytes holds the default value on creation for the "size_bytes" field.
|
||||
DefaultSizeBytes int64
|
||||
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
|
||||
DefaultCreatedAt func() time.Time
|
||||
)
|
||||
|
||||
// OrderOption defines the ordering options for the SoraCacheFile queries.
|
||||
type OrderOption func(*sql.Selector)
|
||||
|
||||
// ByID orders the results by the id field.
|
||||
func ByID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByTaskID orders the results by the task_id field.
|
||||
func ByTaskID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldTaskID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByAccountID orders the results by the account_id field.
|
||||
func ByAccountID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldAccountID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByUserID orders the results by the user_id field.
|
||||
func ByUserID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldUserID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByMediaType orders the results by the media_type field.
|
||||
func ByMediaType(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldMediaType, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByOriginalURL orders the results by the original_url field.
|
||||
func ByOriginalURL(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldOriginalURL, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCachePath orders the results by the cache_path field.
|
||||
func ByCachePath(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCachePath, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCacheURL orders the results by the cache_url field.
|
||||
func ByCacheURL(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCacheURL, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// BySizeBytes orders the results by the size_bytes field.
|
||||
func BySizeBytes(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldSizeBytes, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCreatedAt orders the results by the created_at field.
|
||||
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
|
||||
}
|
||||
Reference in New Issue
Block a user