MCPcopy Create free account
hub / github.com/cloudflare/cfssl / validProfile

Method validProfile

config/config.go:482–545  ·  view source on GitHub ↗

A valid profile must be a valid local profile or a valid remote profile. A valid local profile has defined at least key usages to be used, and a valid local default profile has defined at least a default expiration. A valid remote profile (default or not) has remote signer initialized. In addition,

(isDefault bool)

Source from the content-addressed store, hash-verified

480// key defined. A valid profile must not include a lint_error_level outside of
481// [0,8).
482func (p *SigningProfile) validProfile(isDefault bool) bool {
483 if p == nil {
484 return false
485 }
486
487 if p.AuthRemote.RemoteName == "" && p.AuthRemote.AuthKeyName != "" {
488 log.Debugf("invalid auth remote profile: no remote signer specified")
489 return false
490 }
491
492 if p.RemoteName != "" {
493 log.Debugf("validate remote profile")
494
495 if p.RemoteServer == "" {
496 log.Debugf("invalid remote profile: no remote signer specified")
497 return false
498 }
499
500 if p.AuthKeyName != "" && p.Provider == nil {
501 log.Debugf("invalid remote profile: auth key name is defined but no auth provider is set")
502 return false
503 }
504
505 if p.AuthRemote.RemoteName != "" {
506 log.Debugf("invalid remote profile: auth remote is also specified")
507 return false
508 }
509 } else if p.AuthRemote.RemoteName != "" {
510 log.Debugf("validate auth remote profile")
511 if p.RemoteServer == "" {
512 log.Debugf("invalid auth remote profile: no remote signer specified")
513 return false
514 }
515
516 if p.AuthRemote.AuthKeyName == "" || p.RemoteProvider == nil {
517 log.Debugf("invalid auth remote profile: no auth key is defined")
518 return false
519 }
520 } else {
521 log.Debugf("validate local profile")
522 if !isDefault {
523 if len(p.Usage) == 0 {
524 log.Debugf("invalid local profile: no usages specified")
525 return false
526 } else if _, _, unk := p.Usages(); len(unk) == len(p.Usage) {
527 log.Debugf("invalid local profile: no valid usages")
528 return false
529 }
530 } else {
531 if p.Expiry == 0 {
532 log.Debugf("invalid local profile: no expiry set")
533 return false
534 }
535 }
536 }
537
538 if p.LintErrLevel < 0 || p.LintErrLevel >= 8 {
539 log.Debugf("invalid profile: lint_error_level outside of range [0,8)")

Callers 5

TestInvalidProfileFunction · 0.80
TestRemoteProfilesFunction · 0.80
TestInvalidDefaultFunction · 0.80
TestDefaultConfigFunction · 0.80
ValidMethod · 0.80

Calls 2

UsagesMethod · 0.95
DebugfFunction · 0.92

Tested by 4

TestInvalidProfileFunction · 0.64
TestRemoteProfilesFunction · 0.64
TestInvalidDefaultFunction · 0.64
TestDefaultConfigFunction · 0.64