fix(tiller): enforce release name length on uninstall

If a selector is created from invalid values it will return nil.

Which is EVERYTHING!!!

closes: #2115
pull/2120/head
Adam Reese 8 years ago
parent d127852833
commit d4061b5b60

@ -24,6 +24,7 @@ import (
"io/ioutil" "io/ioutil"
"log" "log"
"strconv" "strconv"
"strings"
"time" "time"
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
@ -31,6 +32,7 @@ import (
kberrs "k8s.io/kubernetes/pkg/api/errors" kberrs "k8s.io/kubernetes/pkg/api/errors"
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion" "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion"
kblabels "k8s.io/kubernetes/pkg/labels" kblabels "k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/util/validation"
rspb "k8s.io/helm/pkg/proto/hapi/release" rspb "k8s.io/helm/pkg/proto/hapi/release"
) )
@ -119,6 +121,9 @@ func (cfgmaps *ConfigMaps) List(filter func(*rspb.Release) bool) ([]*rspb.Releas
func (cfgmaps *ConfigMaps) Query(labels map[string]string) ([]*rspb.Release, error) { func (cfgmaps *ConfigMaps) Query(labels map[string]string) ([]*rspb.Release, error) {
ls := kblabels.Set{} ls := kblabels.Set{}
for k, v := range labels { for k, v := range labels {
if errs := validation.IsValidLabelValue(v); len(errs) != 0 {
return nil, fmt.Errorf("invalid label value: %q: %s", v, strings.Join(errs, "; "))
}
ls[k] = v ls[k] = v
} }

@ -957,6 +957,10 @@ func (s *ReleaseServer) UninstallRelease(c ctx.Context, req *services.UninstallR
return nil, errMissingRelease return nil, errMissingRelease
} }
if len(req.Name) > releaseNameMaxLen {
return nil, fmt.Errorf("release name %q exceeds max length of %d", req.Name, releaseNameMaxLen)
}
rels, err := s.env.Releases.History(req.Name) rels, err := s.env.Releases.History(req.Name)
if err != nil { if err != nil {
log.Printf("uninstall: Release not loaded: %s", req.Name) log.Printf("uninstall: Release not loaded: %s", req.Name)

Loading…
Cancel
Save