Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Check for DNS compliance for bucket names #316

Merged
merged 1 commit into from
Sep 29, 2020
Merged
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
14 changes: 13 additions & 1 deletion pkg/controller/cluster/main-controller.go
Original file line number Diff line number Diff line change
@@ -398,7 +398,11 @@ func (c *Controller) BucketSrvHandler(w http.ResponseWriter, r *http.Request) {
http.Error(w, err.Error(), http.StatusForbidden)
return
}

ok, error := validateBucketName(bucket)
if !ok {
http.Error(w, error.Error(), http.StatusBadRequest)
return
}
// Create the service for the bucket name
service := services.ServiceForBucket(tenant, bucket)
_, err = c.kubeClientSet.CoreV1().Services(namespace).Create(r.Context(), service, metav1.CreateOptions{})
@@ -415,6 +419,14 @@ func (c *Controller) BucketSrvHandler(w http.ResponseWriter, r *http.Request) {
}
}

func validateBucketName(bucket string) (bool, error) {
// Additional check on top of existing checks done by minio due to limitation of service creation in k8s
if strings.Contains(bucket, ".") {
return false, fmt.Errorf("invalid bucket name: . in bucket name: %s", bucket)
}
return true, nil
}

// GetenvHandler - GET /webhook/v1/getenv/{namespace}/{name}?key={env}
func (c *Controller) GetenvHandler(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)