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

Method CreateAuditScope

service/orchestrator/audit_scope.go:45–73  ·  view source on GitHub ↗
(ctx context.Context, req *orchestrator.CreateAuditScopeRequest)

Source from the content-addressed store, hash-verified

43)
44
45func (svc *Service) CreateAuditScope(ctx context.Context, req *orchestrator.CreateAuditScopeRequest) (res *orchestrator.AuditScope, err error) {
46 // Validate request
47 err = api.Validate(req)
48 if err != nil {
49 return nil, err
50 }
51
52 // Check, if this request has access to the certification target according to our authorization strategy.
53 if !svc.authz.CheckAccess(ctx, service.AccessCreate, req) {
54 return nil, service.ErrPermissionDenied
55 }
56
57 // Create the Audit Scope
58 err = svc.storage.Create(&req.AuditScope)
59 if err != nil && errors.Is(err, persistence.ErrConstraintFailed) {
60 return nil, status.Errorf(codes.InvalidArgument, "invalid catalog or certification target")
61 }
62 if err != nil {
63 return nil, status.Errorf(codes.Internal, "database error: %v", err)
64 }
65
66 go svc.informToeHooks(ctx, &orchestrator.AuditScopeChangeEvent{Type: orchestrator.AuditScopeChangeEvent_TYPE_AUDIT_SCOPE_CREATED, AuditScope: req.AuditScope}, nil)
67
68 res = req.AuditScope
69
70 logging.LogRequest(log, logrus.DebugLevel, logging.Create, req, fmt.Sprintf("and Catalog '%s'", req.AuditScope.GetCatalogId()))
71
72 return
73}
74
75// GetAuditScope implements method for getting a AuditScope, e.g. to show its state in the UI
76func (svc *Service) GetAuditScope(ctx context.Context, req *orchestrator.GetAuditScopeRequest) (response *orchestrator.AuditScope, 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 7

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

Tested by 1