-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add path regex check to locks #174
Open
oliviagolden0
wants to merge
12
commits into
master
Choose a base branch
from
path-check
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 9 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
dab4b37
regex path var check
oliviagolden0 baa135e
add testing
oliviagolden0 8337f7a
refactor
oliviagolden0 d622871
err check
oliviagolden0 49d49b5
refactor
oliviagolden0 32ede26
wording
oliviagolden0 5b115f6
wording
oliviagolden0 7e04d04
lock check
oliviagolden0 10d9909
rm lock
oliviagolden0 c5c4fc2
add lock
oliviagolden0 12725af
#
oliviagolden0 60b4667
Merge branch 'master' into path-check
oliviagolden0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ package rules | |
import ( | ||
"fmt" | ||
"os" | ||
"regexp" | ||
"strings" | ||
"time" | ||
|
||
|
@@ -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) { | ||
e.logger.Fatal("Path contains an invalid character") | ||
} else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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() { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 containThere was a problem hiding this comment.
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.