From d1ea2fba6aac17fa40a1ed16fdd8e3eff2c7c553 Mon Sep 17 00:00:00 2001 From: Corey Ogburn Date: Fri, 21 Jun 2024 13:07:29 -0600 Subject: [PATCH] Allow for shorter PublicIDs --- server/modules/elastic/elasticdetectionstore.go | 2 +- server/modules/elastic/elasticdetectionstore_test.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/server/modules/elastic/elasticdetectionstore.go b/server/modules/elastic/elasticdetectionstore.go index f13b7951..77fb7c28 100644 --- a/server/modules/elastic/elasticdetectionstore.go +++ b/server/modules/elastic/elasticdetectionstore.go @@ -68,7 +68,7 @@ func (store *ElasticDetectionstore) validateId(id string, label string) error { func (store *ElasticDetectionstore) validatePublicId(id string, label string) error { var err error - isValidId := regexp.MustCompile(`^[A-Za-z0-9-_]{5,128}$`).MatchString + isValidId := regexp.MustCompile(`^[A-Za-z0-9-_]{3,128}$`).MatchString if !isValidId(id) { err = fmt.Errorf("invalid ID for %s", label) } diff --git a/server/modules/elastic/elasticdetectionstore_test.go b/server/modules/elastic/elasticdetectionstore_test.go index 56d9a4cb..506652fd 100644 --- a/server/modules/elastic/elasticdetectionstore_test.go +++ b/server/modules/elastic/elasticdetectionstore_test.go @@ -122,6 +122,9 @@ func TestDetectionValidatePublicIdValid(t *testing.T) { err := store.validatePublicId("12345", "test") assert.NoError(t, err) + err = store.validatePublicId("123", "test") + assert.NoError(t, err) + err = store.validatePublicId("123456", "test") assert.NoError(t, err)