Skip to content

Commit

Permalink
[FSSDK-10734] update regex to allow = character (#426)
Browse files Browse the repository at this point in the history
* add doc in config.yaml for secure env datafileURL template

* update regex to allow special characters

* update unit test

* update regex

* update config unit test
  • Loading branch information
pulak-opti authored Oct 4, 2024
1 parent 071d437 commit e80529d
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,14 @@ client:
## the maximum time between events being dispatched
flushInterval: 30s
## Template URL for SDK datafile location. The template should specify a "%s" token for SDK key substitution.
## For secure environments, the datafileURLTemplate should be set to "https://config.optimizely.com/datafiles/auth/%s.json"
datafileURLTemplate: "https://cdn.optimizely.com/datafiles/%s.json"
## URL for dispatching events.
eventURL: "https://logx.optimizely.com/v1/events"
## Validation Regex on the request SDK Key
## By default Agent assumes only alphanumeric characters as part of the SDK Key string.
## https://github.com/google/re2/wiki/Syntax
sdkKeyRegex: "^\\w+(:\\w+)?$"
sdkKeyRegex: "^[\\w=]+(:[\\w=]+)?$"
## configure optional User profile service
userProfileService:
default: ""
Expand Down
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func NewDefaultConfig() *AgentConfig {
DatafileURLTemplate: "https://cdn.optimizely.com/datafiles/%s.json",
EventURL: "https://logx.optimizely.com/v1/events",
// https://github.com/google/re2/wiki/Syntax
SdkKeyRegex: "^\\w+(:\\w+)?$",
SdkKeyRegex: "^[\\w=]+(:[\\w=]+)?$",
UserProfileService: UserProfileServiceConfigs{
"default": "",
"services": map[string]interface{}{},
Expand Down
2 changes: 1 addition & 1 deletion config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func TestDefaultConfig(t *testing.T) {
assert.Equal(t, 30*time.Second, conf.Client.FlushInterval)
assert.Equal(t, "https://cdn.optimizely.com/datafiles/%s.json", conf.Client.DatafileURLTemplate)
assert.Equal(t, "https://logx.optimizely.com/v1/events", conf.Client.EventURL)
assert.Equal(t, "^\\w+(:\\w+)?$", conf.Client.SdkKeyRegex)
assert.Equal(t, "^[\\w=]+(:[\\w=]+)?$", conf.Client.SdkKeyRegex)
assert.Equal(t, "", conf.Client.UserProfileService["default"])
assert.Equal(t, false, conf.Client.ODP.Disable)
assert.Equal(t, 1*time.Second, conf.Client.ODP.EventsFlushInterval)
Expand Down
1 change: 1 addition & 0 deletions pkg/optimizely/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,7 @@ func (s *DefaultLoaderTestSuite) TestDefaultRegexValidator() {
{":", false},
{"abc:def:hij", false},
{"abc:", false},
{"123sdkKey:accesTokenWith=", true},
}

conf := config.NewDefaultConfig()
Expand Down

0 comments on commit e80529d

Please sign in to comment.