actpred: 代码审计(16项发现全部修复)+ 文档更新
审计报告: docs/reviews/actpred_CODE_AUDIT_20260808.md - P0(2项): episode索引错位(dataset.py)、推理归一化静默失败(predict.py) - P1(6项): 空训练集校验、图像自然排序、空样本防御、形状校验、 MobileNet下载错误提示、stats路径校验 - P2(8项): README示例修正、公共属性、glob优化、版本约束、 单元测试(17项)、GPU安装说明、BooleanOptionalAction、ONNX验证 新增文件: actpred/test_actpred.py (17项单元测试, 全部通过) 更新文档: README.md配置表扩充、INDEX.md、审计报告修复总结
This commit is contained in:
1 parent
1e34348d6c
commit
3d03f7a1ce
19 files changed
+850
-177
No files matched your search
+15
-26
@@ -51,6 +51,7 @@ namespace qing {
|
||||
public:
|
||||
Generator() {
|
||||
key = generate_rsa_key();
|
||||
if (!key) throw Crypto_Basic::CryptoExp("RSA 密钥对生成失败");
|
||||
}
|
||||
|
||||
// 保存私钥为 PKCS#8 格式(AES-256-CBC 加密),支持密码保护
|
||||
@@ -153,7 +154,7 @@ namespace qing {
|
||||
BIO_ptr bio(BIO_new(BIO_s_mem()));
|
||||
if (!bio) {
|
||||
HANDLE_SSL_ERROR();
|
||||
return "";
|
||||
throw Crypto_Basic::CryptoExp("导出 PEM 时无法创建 BIO");
|
||||
}
|
||||
|
||||
int ret;
|
||||
@@ -169,7 +170,7 @@ namespace qing {
|
||||
|
||||
if (ret != 1) {
|
||||
HANDLE_SSL_ERROR();
|
||||
return "";
|
||||
throw Crypto_Basic::CryptoExp("导出 PEM 失败");
|
||||
}
|
||||
|
||||
char* data;
|
||||
@@ -246,18 +247,7 @@ namespace qing {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
pem_password_cb* cb = nullptr;
|
||||
if (password) {
|
||||
cb = [](char* buf, int size, int rwflag, void* u) -> int {
|
||||
if (!u) return 0;
|
||||
const char* pass = (const char*)u;
|
||||
int len = strlen(pass);
|
||||
if (len > size) len = size;
|
||||
memcpy(buf, pass, len);
|
||||
return len;
|
||||
};
|
||||
}
|
||||
|
||||
pem_password_cb* cb = password ? &password_callback : nullptr;
|
||||
EVP_PKEY* pkey = PEM_read_bio_PrivateKey(bio.get(), nullptr, cb, (void*)password);
|
||||
if (!pkey) {
|
||||
HANDLE_SSL_ERROR();
|
||||
@@ -274,18 +264,7 @@ namespace qing {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
pem_password_cb* cb = nullptr;
|
||||
if (password) {
|
||||
cb = [](char* buf, int size, int rwflag, void* u) -> int {
|
||||
if (!u) return 0;
|
||||
const char* pass = (const char*)u;
|
||||
int len = strlen(pass);
|
||||
if (len > size) len = size;
|
||||
memcpy(buf, pass, len);
|
||||
return len;
|
||||
};
|
||||
}
|
||||
|
||||
pem_password_cb* cb = password ? &password_callback : nullptr;
|
||||
EVP_PKEY* pkey = PEM_read_bio_PrivateKey(bio.get(), nullptr, cb, (void*)password);
|
||||
if (!pkey) {
|
||||
HANDLE_SSL_ERROR();
|
||||
@@ -294,6 +273,16 @@ namespace qing {
|
||||
return EVP_PKEY_ptr(pkey);
|
||||
}
|
||||
|
||||
// 密码回调(共享,消除重复 lambda)
|
||||
static int password_callback(char* buf, int size, int rwflag, void* u) {
|
||||
if (!u) return 0;
|
||||
const char* pass = static_cast<const char*>(u);
|
||||
int len = static_cast<int>(strlen(pass));
|
||||
if (len > size) len = size;
|
||||
memcpy(buf, pass, len);
|
||||
return len;
|
||||
}
|
||||
|
||||
// RSA 解密(OAEP)
|
||||
static std::vector<unsigned char> rsa_decrypt(EVP_PKEY* private_key,
|
||||
const std::vector<unsigned char>& ciphertext) {
|
||||
|
||||
Reference in new issue
Block a user