Removes commons lang usage#693
Conversation
| protected UserDetails authenticate2(String username, String password) throws AuthenticationException { | ||
| // Check if the password length is less than 14 characters | ||
| if(FIPS140.useCompliantAlgorithms() && StringUtils.length(password) < 14) { | ||
| if(FIPS140.useCompliantAlgorithms() && password.length() < 14) { |
There was a problem hiding this comment.
I don't think it can be null based on the call stack.
Thanks @mawinter69 Co-Authored-By: Markus Winter <m.winter@sap.com>
Thanks @mawinter69 Co-Authored-By: Markus Winter <m.winter@sap.com>
|
just checked the build - failed test seems to be a flaky (?) build on windows has already passed. Perhaps @alecharp could resolve this merge conflict, there by causing a new commit - thus kicking off a new build. If all good, maybe we can merge this PR. (I am looking to the commons-lang2 removal) |
Co-authored-by: James Nord <jtnord@users.noreply.github.com> Co-authored-by: Markus Winter <m.winter@sap.com>
There was a problem hiding this comment.
spotbugs failing the build here,
Redundant nullcheck of bindName, which is known to be non-null in hudson.plugins.active_directory.ActiveDirectoryDomain$DescriptorImpl.doValidateTest(String, String, String, String, String, TlsConfiguration, GroupLookupStrategy, boolean, boolean, boolean)
- Add null check for bindPassword before .length() in FIPS check - Remove redundant null check on bindName in doValidateTest (already guarded by early return for null/blank bindName) - Remove now-unused IOException import
| this.name = name; | ||
| // Gives exception if Password is set lees than 14 chars long in FIPS mode. | ||
| if(FIPS140.useCompliantAlgorithms() && StringUtils.length(bindPassword) < 14) { | ||
| if(FIPS140.useCompliantAlgorithms() && (bindName == null || bindPassword == null || bindPassword.length() < 14)) { |
There was a problem hiding this comment.
| if(FIPS140.useCompliantAlgorithms() && (bindName == null || bindPassword == null || bindPassword.length() < 14)) { | |
| if(FIPS140.useCompliantAlgorithms() && (bindPassword == null || bindPassword.length() < 14)) { |
I contemplated about keeping the bindName == null check and making it part of the IllegalArgumentException but instead of combining it with the password check perhaps better to put another check for it.
There was a problem hiding this comment.
given that bindName is only then used with fixEmpty(bindName) in this constructor code (other methods have appropriate checks), there is no need to introduce the null check again.
the fixEmpty honors null, doesn't result in NPE.
Safe to accept the suggestion removing bindName == null in here.
|
|
||
| String bindPassword_ = Secret.toString(bindPassword); | ||
| if(FIPS140.useCompliantAlgorithms() && StringUtils.length(bindPassword_) < 14) { | ||
| if(FIPS140.useCompliantAlgorithms() && bindPassword_.length() < 14) { |
There was a problem hiding this comment.
| if(FIPS140.useCompliantAlgorithms() && bindPassword_.length() < 14) { | |
| if(FIPS140.useCompliantAlgorithms() && (bindPassword_ == null || bindPassword_.length() < 14)) { |
returns 0 if null https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/StringUtils.html#length(java.lang.CharSequence).
| @RequirePOST | ||
| public FormValidation doCheckBindPassword(@QueryParameter String bindPassword) { | ||
| if(FIPS140.useCompliantAlgorithms() && StringUtils.length(bindPassword) < 14) { | ||
| if(FIPS140.useCompliantAlgorithms() && bindPassword.length() < 14) { |
There was a problem hiding this comment.
| if(FIPS140.useCompliantAlgorithms() && bindPassword.length() < 14) { | |
| if(FIPS140.useCompliantAlgorithms() && (bindPassword == null || bindPassword.length() < 14)) { |
null check required.
| } catch (Exception e) { | ||
| return FormValidation.error(e, e.getMessage()); | ||
| } | ||
| } else { |
There was a problem hiding this comment.
this was a dead else block, when bindName == null the code wouldn't have reached here, instead returned at L354.
Superseed #691.
This removes entirely any usage of commons lang.
The API plugin is still a transitive dependency coming from ionicons-api and configuration-as-code dependencies. Excluding it from the latter is breaking the build.
Testing done
I ran
mvn verifylocally.Submitter checklist