CreateEvaluationResult is a method implementation of the assessment interface
(ctx context.Context, req *evaluation.CreateEvaluationResultRequest)
| 416 | |
| 417 | // CreateEvaluationResult is a method implementation of the assessment interface |
| 418 | func (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 |
| 453 | func (svc *Service) addJobToScheduler(ctx context.Context, auditScope *orchestrator.AuditScope, catalog *orchestrator.Catalog, interval int) (err error) { |