feat(P0②): 引擎ALTER安全通道 + AI安全门enforced
- AlterTableSqlGuard(legacy-core,纯静态白名单):只允许 加列/同族扩长/改可空,
拒 DROP COLUMN/RENAME/SET NOT NULL/多语句/跨族/小写绕过;放legacy-core避免反向依赖
- DataDicService.executeAlterSql 受控通道(过Guard再execute,defense-in-depth)
- MetaController POST /api/meta/entity/{table}/attributes 加列端点
(saveAttr元数据+alterAddColumnDdl镜像appendColumnDdl类型映射+evictByTable+补索引,恒可空)
- AiAgentService.applyLocalRelease 织入 AiToolRegistry.check:安全门 advisory→enforced
(local.apply工具身份,非本机/越权写路径403)
- 单测 Guard15/alter2/gate22(112基线无回归);scripts/p0-alter-acceptance.sh 真库验收
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -406,6 +406,16 @@ public class AiAgentService {
|
||||
|
||||
public AiApplyRun applyLocalRelease(String taskId, String changeSetId, String baseUrl) {
|
||||
getTask(taskId);
|
||||
// P0②(c) 安全门 enforced:把 AiToolRegistry 策略引擎织入真实写路径。此前 check() 仅挂在
|
||||
// /api/ai/tools/check-access 咨询端点(只读返决策),写路径仅靠 requireAdmin + localhost 兜底,
|
||||
// scope/localOnly/productionWrite 策略形同 advisory。这里以 local.apply 工具身份过门:
|
||||
// targetEnv=baseUrl,非本机 / 越权 → 403,localReleaseExecutor.apply 不被触发。
|
||||
AiToolAccessDecision gate = toolRegistry.check(new AiToolAccessRequest(
|
||||
"agent-developer", "local.apply", List.of("ai:local:apply"), baseUrl, false));
|
||||
if (gate == null || !gate.allowed()) {
|
||||
throw new ResponseStatusException(HttpStatus.FORBIDDEN,
|
||||
"本地应用被安全门拒绝: " + (gate == null ? "no-decision" : String.join("; ", gate.blockers())));
|
||||
}
|
||||
AiChangeSet changeSet = findChangeSet(taskId, changeSetId);
|
||||
if (!"READY_FOR_REVIEW".equals(changeSet.status())) {
|
||||
throw new ResponseStatusException(HttpStatus.CONFLICT, "变更包状态不可本地应用: " + changeSet.status());
|
||||
|
||||
Reference in New Issue
Block a user