DeletePolicy 删除策略
(policyID string)
| 526 | |
| 527 | // DeletePolicy 删除策略 |
| 528 | func (bpe *BasicPolicyEngine) DeletePolicy(policyID string) error { |
| 529 | bpe.mu.Lock() |
| 530 | defer bpe.mu.Unlock() |
| 531 | |
| 532 | _, exists := bpe.policies[policyID] |
| 533 | if !exists { |
| 534 | return fmt.Errorf("policy %s not found", policyID) |
| 535 | } |
| 536 | |
| 537 | delete(bpe.policies, policyID) |
| 538 | |
| 539 | // 记录审计日志 |
| 540 | if bpe.config.EnableAudit && bpe.auditLog != nil { |
| 541 | _ = bpe.auditLog.LogEvent(AuditEvent{ |
| 542 | Type: AuditTypePolicyDeleted, |
| 543 | Timestamp: time.Now(), |
| 544 | Message: fmt.Sprintf("Policy %s deleted", policyID), |
| 545 | Metadata: map[string]any{ |
| 546 | "policy_id": policyID, |
| 547 | "deleted_policy_id": policyID, |
| 548 | }, |
| 549 | }) |
| 550 | } |
| 551 | |
| 552 | return nil |
| 553 | } |
| 554 | |
| 555 | // GetPolicy 获取策略 |
| 556 | func (bpe *BasicPolicyEngine) GetPolicy(policyID string) (*SecurityPolicy, error) { |