MCPcopy Create free account
hub / github.com/astercloud/aster / DeletePolicy

Method DeletePolicy

pkg/security/policy.go:528–553  ·  view source on GitHub ↗

DeletePolicy 删除策略

(policyID string)

Source from the content-addressed store, hash-verified

526
527// DeletePolicy 删除策略
528func (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 获取策略
556func (bpe *BasicPolicyEngine) GetPolicy(policyID string) (*SecurityPolicy, error) {

Callers 1

Calls 2

deleteFunction · 0.85
LogEventMethod · 0.65

Tested by 1