Skip to content

Commit

Permalink
regex path var check
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviagolden0 committed May 15, 2024
1 parent 298d3d3 commit dab4b37
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions rules/lock/lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package lock

import (
"errors"
"fmt"
"regexp"
"time"

"golang.org/x/net/context"
Expand Down Expand Up @@ -54,6 +56,10 @@ type v3Locker struct {
}

func (v3l *v3Locker) Lock(key string, options ...Option) (RuleLock, error) {
validPath := regexp.MustCompile(`^[[:alnum:] \"\'\_\.\,\*\=\-]+$`)
if !validPath.MatchString(key) {
return nil, fmt.Errorf("Path variable contains an invalid character")
}
return v3l.lockWithTimeout(key, v3l.lockTimeout)
}
func (v3l *v3Locker) lockWithTimeout(key string, timeout int) (RuleLock, error) {
Expand Down

0 comments on commit dab4b37

Please sign in to comment.