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

Method CreateEvaluationResult

service/evaluation/evaluation.go:418–450  ·  view source on GitHub ↗

CreateEvaluationResult is a method implementation of the assessment interface

(ctx context.Context, req *evaluation.CreateEvaluationResultRequest)

Source from the content-addressed store, hash-verified

416
417// CreateEvaluationResult is a method implementation of the assessment interface
418func (svc *Service) CreateEvaluationResult(ctx context.Context, req *evaluation.CreateEvaluationResultRequest) (res *evaluation.EvaluationResult, err error) {
419 // Validate request
420 err = api.Validate(req)
421 if err != nil {
422 return nil, err
423 }
424
425 // We only allow manually created statuses
426 if req.Result.Status != evaluation.EvaluationStatus_EVALUATION_STATUS_COMPLIANT_MANUALLY &&
427 req.Result.Status != evaluation.EvaluationStatus_EVALUATION_STATUS_NOT_COMPLIANT_MANUALLY {
428 return nil, status.Errorf(codes.InvalidArgument, "only manually set statuses are allowed")
429 }
430
431 // The ValidUntil field must be checked separately as it is an optional field and not checked by the request
432 // validation. It is only mandatory when manually creating a result.
433 if req.Result.ValidUntil == nil {
434 return nil, status.Errorf(codes.InvalidArgument, "validity must be set")
435 }
436
437 // Check, if this request has access to the certification target according to our authorization strategy.
438 if !svc.authz.CheckAccess(ctx, service.AccessCreate, req) {
439 return nil, service.ErrPermissionDenied
440 }
441
442 res = req.Result
443 res.Id = uuid.NewString()
444 err = svc.storage.Create(res)
445 if err != nil {
446 return nil, status.Errorf(codes.Internal, "database error: %v", err)
447 }
448
449 return res, nil
450}
451
452// addJobToScheduler adds a job for the given control to the scheduler and sets the scheduler interval to the given interval
453func (svc *Service) addJobToScheduler(ctx context.Context, auditScope *orchestrator.AuditScope, catalog *orchestrator.Catalog, interval int) (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 4

ValidateFunction · 0.92
ErrorfMethod · 0.80
CheckAccessMethod · 0.65
CreateMethod · 0.65

Tested by 1