Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Commit

Permalink
#1465 Utility for checking directory names (#145) (#146)
Browse files Browse the repository at this point in the history
* Add a helper function for checking dir names
  • Loading branch information
agrimmer authored Mar 10, 2020
1 parent dcdd0e0 commit 33a5741
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pkg/utils/keptnUtils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package utils
import (
"log"
"regexp"
"strings"

"github.com/keptn/go-utils/pkg/configuration-service/utils"
"github.com/keptn/go-utils/pkg/models"
Expand Down Expand Up @@ -49,3 +50,17 @@ func ValidateKeptnEntityName(name string) bool {
processedString := reg.FindString(name)
return len(processedString) == len(name)
}

// ValididateUnixDirectoryName checks whether the provided dirName contains
// any special character according to
// https://www.cyberciti.biz/faq/linuxunix-rules-for-naming-file-and-directory-names/
func ValididateUnixDirectoryName(dirName string) bool {
return !(dirName == "." ||
dirName == ".." ||
strings.Contains(dirName, "/") ||
strings.Contains(dirName, ">") ||
strings.Contains(dirName, "<") ||
strings.Contains(dirName, "|") ||
strings.Contains(dirName, ":") ||
strings.Contains(dirName, "&"))
}

0 comments on commit 33a5741

Please sign in to comment.