Skip to content

Commit

Permalink
feat: add validation for application name (#5123)
Browse files Browse the repository at this point in the history
* feat: add validation for application name

* improve error message

---------

Co-authored-by: Oliver Feldmann <oliver.feldmann@sap.com>
  • Loading branch information
srinikitha09 and o-liver authored Oct 9, 2024
1 parent 4153672 commit 129e20d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/transportrequest/cts/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ package cts

import (
"fmt"
"regexp"
"strings"

"github.com/SAP/jenkins-library/pkg/command"
"github.com/SAP/jenkins-library/pkg/log"
"github.com/SAP/jenkins-library/pkg/piperutils"
"strings"
)

type fileUtils interface {
Expand Down Expand Up @@ -60,6 +62,7 @@ const (
abapUserKey = "ABAP_USER"
abapPasswordKey = "ABAP_PASSWORD"
defaultConfigFileName = "ui5-deploy.yaml"
pattern = "^[a-zA-Z0-9_]+$"
)

// WithConnection ...
Expand Down Expand Up @@ -189,6 +192,10 @@ func getFioriDeployStatement(
log.Entry().Debug("No application package found in piper config.")
}
if len(app.Name) > 0 {
re := regexp.MustCompile(pattern)
if !re.MatchString(app.Name) {
fmt.Errorf("application name '%s' contains spaces or special characters. It is not according to the '%s'", app.Name, pattern)
}
log.Entry().Debugf("application name '%s' used from piper config", app.Name)
cmd = append(cmd, "--name", app.Name)
} else {
Expand Down

0 comments on commit 129e20d

Please sign in to comment.