feat: add instance-specific config#1659
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: reddevillg The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Code Review
This pull request introduces support for container instances and custom mounts within the Linglong runtime. Key changes include updates to the API schema, the addition of an --instance CLI flag, and enhanced runtime configuration merging logic to handle instance-specific overrides and mount points. Feedback highlights a violation of the noexcept contract in ResolveOptions methods due to potential memory allocations and a semantic issue where optional mount options were not being correctly preserved as nullopt when passed to the OCI specification.
Add support for defining custom mounts in runtime configuration files. Run with --instance will apply instance-specific runtime configurations and run in an isolate container environment. Signed-off-by: reddevillg <reddevillg@gmail.com>
deepin pr auto review这份代码变更主要实现了容器运行时的“实例化”配置与自定义挂载功能。通过引入 整体来看,代码结构清晰,逻辑连贯,并包含了较为完善的单元测试。但在安全性、代码质量和逻辑严谨性方面,还有以下需要关注和改进的地方: 1. 代码安全1.1 宿主机路径遍历漏洞
1.2 潜在的符号链接攻击
2. 代码逻辑2.1
2.2 JSON Schema 中的
2.3
3. 代码质量3.1 循环依赖风险
3.2 C++ 结构体初始化的健壮性 api::types::v1::Mount{ .destination = "/tmp/a", .source = "/host/a", .type = "bind" }这很现代,但
3.3 std::ofstream(dest) << "";这行代码尝试创建空文件,但没有检查文件是否创建成功。如果磁盘满或权限不足,这里会静默失败。
4. 代码性能4.1 不必要的深拷贝 auto instanceConfig = std::move((*merged.instances)[instance]);
std::vector<RuntimeConfigure> toMerge;
toMerge.emplace_back(std::move(merged));
toMerge.emplace_back(std::move(instanceConfig));
merged = MergeRuntimeConfig(toMerge);这里将
总结此 PR 的功能实现很完整,但最严重的问题是挂载源路径未做安全校验,这在容器场景下是高危漏洞。建议优先修复安全问题,其次优化 |
Add support for defining custom mounts in runtime configuration files.
Run with --instance will apply instance-specific runtime configurations and run in an isolate container environment.