diff --git a/pilosa.go b/pilosa.go index 481c8ff07..f7eb33f43 100644 --- a/pilosa.go +++ b/pilosa.go @@ -53,8 +53,7 @@ var ( ErrInvalidView = errors.New("invalid view") ErrInvalidCacheType = errors.New("invalid cache type") - ErrName = errors.New("invalid index or field name, must match [a-z][a-z0-9_-]* and contain at most 230 characters") - ErrLabel = errors.New("invalid row or column label, must match [A-Za-z0-9_-]") + ErrName = errors.New("invalid index or field name, must match [a-z][a-z0-9_-]* and contain at most 230 characters") // ErrFragmentNotFound is returned when a fragment does not exist. ErrFragmentNotFound = errors.New("fragment not found") diff --git a/transaction.go b/transaction.go index ba7063907..2af2c76df 100644 --- a/transaction.go +++ b/transaction.go @@ -17,6 +17,7 @@ package pilosa import ( "context" "encoding/json" + "regexp" "sync" "time" @@ -24,6 +25,8 @@ import ( "github.com/pkg/errors" ) +var txIDRegexp = regexp.MustCompile("^[A-Za-z0-9_-]*$") + // Transaction contains information related to a block of work that // needs to be tracked and spans multiple API calls. type Transaction struct { @@ -93,6 +96,10 @@ func (tm *TransactionManager) Start(ctx context.Context, id string, timeout time tm.mu.Lock() defer tm.mu.Unlock() + if !txIDRegexp.Match([]byte(id)) { + return nil, errors.New("invalid transaction ID, must match [A-Za-z0-9_-]") + } + trnsMap, err := tm.store.List() if err != nil { return nil, errors.Wrap(err, "listing transactions in Start")