diff --git a/CHANGELOG.md b/CHANGELOG.md index 318a7c796..1cd4fddc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +### Fixed +- Check Environment Variable value for Allowed Change Ref Types ([#1252](https://github.com/opendevstack/ods-core/issues/1252)) + ## [4.3.0] - 2023-07-03 ### Added diff --git a/jenkins/webhook-proxy/main.go b/jenkins/webhook-proxy/main.go index df6f58b3a..e6604dd9c 100644 --- a/jenkins/webhook-proxy/main.go +++ b/jenkins/webhook-proxy/main.go @@ -39,7 +39,7 @@ const ( allowedExternalProjectsEnvVar = "ALLOWED_EXTERNAL_PROJECTS" allowedExternalProjectsDefault = "opendevstack" allowedChangeRefTypesEnvVar = "ALLOWED_CHANGE_REF_TYPES" - allowedChangeRefTypesDefault = "BRANCH" + allowedChangeRefTypesDefault = "branch" namespaceSuffix = "-cd" letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" ) @@ -204,7 +204,7 @@ func main() { var allowedChangeRefTypes []string envAllowedChangeRefTypes := strings.ToLower(os.Getenv(allowedChangeRefTypesEnvVar)) - if len(allowedChangeRefTypes) == 0 { + if len(envAllowedChangeRefTypes) == 0 { allowedChangeRefTypes = strings.Split(allowedChangeRefTypesDefault, ",") log.Println( "INFO:", @@ -402,7 +402,7 @@ func (s *Server) HandleRoot() http.HandlerFunc { } else { kind = "forward" } - if !includes(s.AllowedChangeRefTypes, req.Changes[0].Ref.Type) { + if !includes(s.AllowedChangeRefTypes, strings.ToLower(req.Changes[0].Ref.Type)) { log.Println(requestID, fmt.Sprintf( "Skipping change ref type %s as %s does not include it", req.Changes[0].Ref.Type,