Skip to content
Open
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion rules/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package rules
import (
"fmt"
"os"
"regexp"
"strings"
"time"

Expand Down Expand Up @@ -166,11 +167,18 @@ func (e *v3Engine) SetWatcherWrapper(watcherWrapper WrapWatcher) {
e.watcherWrapper = watcherWrapper
}

// valid path patterns must be alphanumeric and may only contain select special characters (:/"'_.,*=-)
var validPath = regexp.MustCompile(`^[[:alnum:] \:\/\"\'\_\.\,\*\=\-]*$`)

func (e *v3Engine) AddRule(rule DynamicRule,
lockPattern string,
callback V3RuleTaskCallback,
options ...RuleOption) {
e.addRuleWithIface(rule, lockPattern, callback, options...)
if !validPath.MatchString(lockPattern) {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not including check that the path contains "lock" since /crawler/compliance-engine /armada-ingress/:region/clusters/:clusterid/ingress_update paths don't contain

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Humm, I think we should push to get that changed and then announce in armada-dev that this will be required from now on.

e.logger.Fatal("Path contains an invalid character")
} else {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for else, when above is fatal?

e.addRuleWithIface(rule, lockPattern, callback, options...)
}
}

func (e *baseEngine) Stop() {
Expand Down