MCPcopy Create free account
hub / github.com/clouditor/clouditor / RemoveAuditScope

Method RemoveAuditScope

service/orchestrator/audit_scope.go:161–190  ·  view source on GitHub ↗

RemoveAuditScope implements method for removing a AuditScope

(ctx context.Context, req *orchestrator.RemoveAuditScopeRequest)

Source from the content-addressed store, hash-verified

159
160// RemoveAuditScope implements method for removing a AuditScope
161func (svc *Service) RemoveAuditScope(ctx context.Context, req *orchestrator.RemoveAuditScopeRequest) (response *emptypb.Empty, err error) {
162 // Validate request
163 err = api.Validate(req)
164 if err != nil {
165 return nil, err
166 }
167
168 // Check, if this request has access to the certification target according to our authorization strategy.
169 if !svc.authz.CheckAccess(ctx, service.AccessDelete, req) {
170 return nil, service.ErrPermissionDenied
171 }
172
173 err = svc.storage.Delete(&orchestrator.AuditScope{}, "certification_target_id = ? AND catalog_id = ?", req.CertificationTargetId, req.CatalogId)
174 if errors.Is(err, persistence.ErrRecordNotFound) {
175 return nil, status.Errorf(codes.NotFound, "Audit Scope not found")
176 } else if err != nil {
177 return nil, status.Errorf(codes.Internal, "database error: %v", err)
178 }
179
180 // Since we don't have a AuditScope object, we create one to be able to inform the hook about the deleted AuditScope.
181 auditScope := &orchestrator.AuditScope{
182 CertificationTargetId: req.GetCertificationTargetId(),
183 CatalogId: req.GetCatalogId(),
184 }
185 go svc.informToeHooks(ctx, &orchestrator.AuditScopeChangeEvent{Type: orchestrator.AuditScopeChangeEvent_TYPE_AUDIT_SCOPE_REMOVED, AuditScope: auditScope}, nil)
186
187 logging.LogRequest(log, logrus.DebugLevel, logging.Remove, req, fmt.Sprintf("and Catalog '%s'", req.GetCatalogId()))
188
189 return &emptypb.Empty{}, nil
190}
191
192// informToeHooks informs the registered hook function either of a event change for the Audit Scope or Control Monitoring Status
193func (s *Service) informToeHooks(ctx context.Context, event *orchestrator.AuditScopeChangeEvent, err error) {

Callers 1

Implementers 5

Serviceservice/assessment/assessment.go
Serviceservice/discovery/discovery.go
Serviceservice/evidence/evidence_store.go
Serviceservice/evaluation/evaluation.go
Serviceservice/orchestrator/orchestrator.go

Calls 8

informToeHooksMethod · 0.95
ValidateFunction · 0.92
LogRequestFunction · 0.92
ErrorfMethod · 0.80
CheckAccessMethod · 0.65
DeleteMethod · 0.65
GetCatalogIdMethod · 0.45

Tested by 1