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

Function ValidateCSAF

internal/schemavalidators/schemavalidators.go:338–363  ·  view source on GitHub ↗

ValidateCSAF validates the given object against a CSAF schema version. The schema version is determined by the "csaf_version" field in the object.

(data interface{})

Source from the content-addressed store, hash-verified

336// ValidateCSAF validates the given object against a CSAF schema version.
337// The schema version is determined by the "csaf_version" field in the object.
338func ValidateCSAF(data interface{}) error {
339 csafOnce.Do(initCSAFSchemas)
340
341 var errs error
342 err := compiledCSAFSchemas[CSAFVersion2_1].Validate(data)
343 if err != nil {
344 if err := errorIsJSONFormat(err); err != nil {
345 return err
346 }
347
348 errs = multierror.Append(errs, err)
349 } else {
350 return nil
351 }
352
353 err = compiledCSAFSchemas[CSAFVersion2_0].Validate(data)
354 if err != nil {
355 if err := errorIsJSONFormat(err); err != nil {
356 errs = multierror.Append(errs, err)
357 return errs
358 }
359 return multierror.Append(errs, err)
360 }
361
362 return nil
363}
364
365// ValidateChainloopRunnerContext validates the runner context schema.
366// The schema version is determined by the "id" field in the object.

Callers 2

CraftMethod · 0.92
TestValidateCSAF_2_0Function · 0.92

Calls 4

errorIsJSONFormatFunction · 0.85
DoMethod · 0.80
AppendMethod · 0.80
ValidateMethod · 0.45

Tested by 1

TestValidateCSAF_2_0Function · 0.74