Skip to content

Conversation

@oliviagolden0
Copy link
Collaborator

@oliviagolden0 oliviagolden0 commented May 16, 2024

@oliviagolden0 oliviagolden0 marked this pull request as ready for review May 16, 2024 20:30
rules/engine.go Outdated
lockPattern string,
callback V3RuleTaskCallback,
options ...RuleOption)
options ...RuleOption) error
Copy link
Collaborator

@kramvan1 kramvan1 May 17, 2024

Choose a reason for hiding this comment

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

Humm, this would be a major hit to all services to handle this new error.

Maybe we should consider a e.logger.Fatal(...) or a panic("Rule ID option missing") instead? That way only those that have issues will affected.

And then will need to make this a major version bump and an announcement in the armada-dev channel.

callback V3RuleTaskCallback,
options ...RuleOption)
options ...RuleOption) error
AddPolling(namespacePattern string,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we might also have to check the AddPolling namespacePattern, but have not looked into that one yet.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

AddPolling calls AddRule so I think it should be okay unless the check should be higher up in the chain

func (e *v3Engine) AddPolling(namespacePattern string, preconditions DynamicRule, ttl int, callback V3RuleTaskCallback) error {

rules/engine.go Outdated
callback V3RuleTaskCallback,
options ...RuleOption) {
options ...RuleOption) error {
validPath := regexp.MustCompile(`^[[:alnum:] \:\/\"\'\_\.\,\*\=\-]*$`)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be pushed out to a static var, no need to do this every time.
Maybe add a cmt with it to spell out the char to make it easier to know what is valid?

rules/engine.go Outdated
callback V3RuleTaskCallback,
options ...RuleOption) {
e.addRuleWithIface(rule, lockPattern, callback, options...)
if !validPath.MatchString(lockPattern) {
Copy link
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
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.

rules/engine.go Outdated
e.addRuleWithIface(rule, lockPattern, callback, options...)
if !validPath.MatchString(lockPattern) {
e.logger.Fatal("Path contains an invalid character")
} else {
Copy link
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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants