Add validation to include/exlude jobs regular expressions#450
Conversation
| } | ||
|
|
||
| @RequirePOST | ||
| public FormValidation doCheckIncluded(@QueryParameter("included") final String included) { |
Check warning
Code scanning / Jenkins Security Scan
Stapler: Missing permission check
| } | ||
|
|
||
| @RequirePOST | ||
| public FormValidation doCheckExcluded(@QueryParameter("excluded") final String excluded) { |
Check warning
Code scanning / Jenkins Security Scan
Stapler: Missing permission check
9efa308 to
94211bd
Compare
3db94aa to
98e20c1
Compare
5f3a210 to
d20b98e
Compare
d20b98e to
b8e26e6
Compare
0404aa5 to
0260867
Compare
f362037 to
f5fcdc1
Compare
drodriguezhdez
left a comment
There was a problem hiding this comment.
Dropped some comments
| String excludedEnvVar = System.getenv(EXCLUDED_PROPERTY); | ||
| if(StringUtils.isBlank(excludedEnvVar)){ | ||
| if (StringUtils.isNotBlank(excludedEnvVar)) { | ||
| this.excluded = DatadogUtilities.cstrToList(excludedEnvVar, Pattern::compile); |
There was a problem hiding this comment.
If a user has already a stored value that does not compile, this will throw an exception and won't be able to load the configuration, right?
Is it possible to have a unit test to check how this behaves?
There was a problem hiding this comment.
This is a good point, added a unit test to ensure the config can still be loaded in this case
| this.excluded = DatadogUtilities.cstrToList(jobs, Pattern::compile); | ||
| } | ||
|
|
||
| public boolean isJobIncluded(@Nonnull final String jobName) { |
There was a problem hiding this comment.
Don't we need a isJobExcluded somewhere?
There was a problem hiding this comment.
Yep, it's there on line 566
Requirements for Contributing to this repository
What does this PR do?
Adds validation to regular expressions for including/excluding jobs from tracing: regexes that cannot be compiled will not be saved.
Also updates the configuration to store compiled regexes, rather than strings (otherwise splitting the string and compiling the expressions is done on every job listener invocation, which is computationally expensive).
Description of the Change
Alternate Designs
Possible Drawbacks
Verification Process
Additional Notes
Release Notes
Review checklist (to be filled by reviewers)
changelog/label attached. If applicable it should have thebackward-incompatiblelabel attached.do-not-merge/label attached.kind/andseverity/labels attached at least.