Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix allowed change ref types environment read #1253

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions jenkins/webhook-proxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const (
allowedExternalProjectsEnvVar = "ALLOWED_EXTERNAL_PROJECTS"
allowedExternalProjectsDefault = "opendevstack"
allowedChangeRefTypesEnvVar = "ALLOWED_CHANGE_REF_TYPES"
allowedChangeRefTypesDefault = "BRANCH"
allowedChangeRefTypesDefault = "branch"
namespaceSuffix = "-cd"
letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
)
Expand Down Expand Up @@ -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:",
Expand Down Expand Up @@ -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,
Expand Down
Loading