MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / renderEvaluation

Function renderEvaluation

pkg/attestation/renderer/chainloop/v02.go:401–453  ·  view source on GitHub ↗
(ev *v1.PolicyEvaluation, includeSuppressed bool)

Source from the content-addressed store, hash-verified

399}
400
401func renderEvaluation(ev *v1.PolicyEvaluation, includeSuppressed bool) (*PolicyEvaluation, error) {
402 violations := make([]*PolicyViolation, 0, len(ev.Violations))
403 for _, vi := range ev.Violations {
404 if vi.GetSuppress() && !includeSuppressed {
405 continue
406 }
407
408 out := &PolicyViolation{
409 Subject: vi.Subject,
410 Message: vi.Message,
411 Suppress: vi.GetSuppress(),
412 }
413 if includeSuppressed {
414 switch f := vi.GetFinding().(type) {
415 case *v1.PolicyEvaluation_Violation_Vulnerability:
416 out.Vulnerability = f.Vulnerability
417 case *v1.PolicyEvaluation_Violation_Sast:
418 out.Sast = f.Sast
419 case *v1.PolicyEvaluation_Violation_LicenseViolation:
420 out.LicenseViolation = f.LicenseViolation
421 }
422 }
423 violations = append(violations, out)
424 }
425
426 policyRef, err := renderReference(ev.GetPolicyReference())
427 if err != nil {
428 return nil, err
429 }
430
431 groupRef, err := renderReference(ev.GetGroupReference())
432 if err != nil {
433 return nil, err
434 }
435
436 return &PolicyEvaluation{
437 Name: ev.Name,
438 MaterialName: ev.MaterialName,
439 Body: ev.Body,
440 Sources: ev.Sources,
441 Annotations: ev.Annotations,
442 Description: ev.Description,
443 With: ev.With,
444 Type: ev.Type.String(),
445 Violations: violations,
446 PolicyReference: policyRef,
447 SkipReasons: ev.SkipReasons,
448 Skipped: ev.Skipped,
449 GroupReference: groupRef,
450 Requirements: ev.Requirements,
451 Gate: ev.Gate,
452 }, nil
453}
454
455func renderReference(ref *v1.PolicyEvaluation_Reference) (*intoto.ResourceDescriptor, error) {
456 // skip empty references

Callers 1

groupEvaluationsFunction · 0.85

Calls 6

renderReferenceFunction · 0.85
StringMethod · 0.65
GetSuppressMethod · 0.45
GetFindingMethod · 0.45
GetPolicyReferenceMethod · 0.45
GetGroupReferenceMethod · 0.45

Tested by

no test coverage detected