@@ -14,6 +14,9 @@ import (
1414
1515var requiredLabels = []string {"name" , "vendor" , "version" , "release" , "summary" , "description" }
1616
17+ // todo-adam this may include maintainer, but we do not require that today, so need clarity if this is changing.
18+ var trademarkLabels = []string {"name" , "vendor" }
19+
1720var _ check.Check = & HasRequiredLabelsCheck {}
1821
1922// HasRequiredLabelsCheck evaluates the image manifest to ensure that the appropriate metadata
@@ -37,6 +40,13 @@ func (p *HasRequiredLabelsCheck) getDataForValidate(image cranev1.Image) (map[st
3740func (p * HasRequiredLabelsCheck ) validate (ctx context.Context , labels map [string ]string ) (bool , error ) {
3841 logger := logr .FromContextOrDiscard (ctx )
3942
43+ trademarkViolationLabels := []string {}
44+ for _ , label := range trademarkLabels {
45+ if ViolatesRedHatTrademark (labels [label ]) {
46+ trademarkViolationLabels = append (trademarkViolationLabels , label )
47+ }
48+ }
49+
4050 missingLabels := []string {}
4151 for _ , label := range requiredLabels {
4252 if labels [label ] == "" {
@@ -49,7 +59,11 @@ func (p *HasRequiredLabelsCheck) validate(ctx context.Context, labels map[string
4959 logger .V (log .DBG ).Info ("expected labels are missing" , "missingLabels" , missingLabels )
5060 }
5161
52- return len (missingLabels ) == 0 , nil
62+ if len (trademarkViolationLabels ) > 0 {
63+ logger .V (log .DBG ).Info ("labels violate Red Hat trademark" , "trademarkViolationLabels" , trademarkViolationLabels )
64+ }
65+
66+ return len (missingLabels ) == 0 && len (trademarkViolationLabels ) == 0 , nil
5367}
5468
5569func (p * HasRequiredLabelsCheck ) Name () string {
@@ -58,7 +72,8 @@ func (p *HasRequiredLabelsCheck) Name() string {
5872
5973func (p * HasRequiredLabelsCheck ) Metadata () check.Metadata {
6074 return check.Metadata {
61- Description : "Checking if the required labels (name, vendor, version, release, summary, description) are present in the container metadata." ,
75+ Description : "Checking if the required labels (name, vendor, version, release, summary, description) are present in the container metadata." +
76+ "and that they do not violate Red Hat trademark." ,
6277 Level : "good" ,
6378 KnowledgeBaseURL : certDocumentationURL ,
6479 CheckURL : certDocumentationURL ,
@@ -67,7 +82,8 @@ func (p *HasRequiredLabelsCheck) Metadata() check.Metadata {
6782
6883func (p * HasRequiredLabelsCheck ) Help () check.HelpText {
6984 return check.HelpText {
70- Message : "Check Check HasRequiredLabel encountered an error. Please review the preflight.log file for more information." ,
71- Suggestion : "Add the following labels to your Dockerfile or Containerfile: name, vendor, version, release, summary, description" ,
85+ Message : "Check HasRequiredLabel encountered an error. Please review the preflight.log file for more information." ,
86+ Suggestion : "Add the following labels to your Dockerfile or Containerfile: name, vendor, version, release, summary, description" +
87+ "and validate that they do not violate Red Hat trademark." ,
7288 }
7389}
0 commit comments