Skip to content
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

[JENKINS-74858] Added validation for Password length in FIPS mode #9995

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

tejasdrolia
Copy link

@tejasdrolia tejasdrolia commented Nov 20, 2024

See JENKINS-74858.

Made changes to ensure that an exisiting user is now unable to alter the password to less than 14 characters in length when operating in FIPS mode.

Testing done

Automated Unit Testing
Implemented unit tests to verify FIPS compliance for password changes:

  1. Ensured that passwords shorter than 14 characters are rejected when FIPS mode is enabled.
  2. Verified that mismatched passwords between user.password and user.password2 trigger appropriate errors.

Manual Testing
Did Manual testing to verify my changes to ensure that everything is working properly.


Without FIPS mode: Shorter password is being accepted.
Screenshot 2024-11-20 at 12 37 33 PM


With FIPS mode: Shorter password is not being accepted.
Screenshot 2024-11-20 at 12 41 00 PM
Screenshot 2024-11-20 at 12 41 09 PM

Proposed changelog entries

  • Added Password validation to ensure that existing users cannot create a password of less than 14 characters in length(when in FIPS mode).

Proposed upgrade guidelines

N/A

Submitter checklist

Desired reviewers

@mention

Before the changes are marked as ready-for-merge:

Maintainer checklist

Copy link

welcome bot commented Nov 20, 2024

Yay, your first pull request towards Jenkins core was created successfully! Thank you so much!

A contributor will provide feedback soon. Meanwhile, you can join the chats and community forums to connect with other Jenkins users, developers, and maintainers.

Copy link
Member

@daniel-beck daniel-beck left a comment

Choose a reason for hiding this comment

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

Would be nice if newly added tests covered the success case (long + matching password) in addition to not relying on mocks.

Comment on lines 33 to 34
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
Copy link
Member

Choose a reason for hiding this comment

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

This looks like unnecessary use of mocks, prefer WebClient.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed in recent commit

Copy link
Contributor

@fcojfernandez fcojfernandez left a comment

Choose a reason for hiding this comment

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

You have spotless issues, just execute mvn clean install -DskipTests to see and fix them

(haven't see them clearly in the CI logs, but they seem to be related to my comments about the empty line and the wildcard)

import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.startsWith;
import static org.hamcrest.Matchers.*;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do not use wildcards in the imports. Add as many imports as you need

import static org.junit.Assert.assertThrows;

Copy link
Contributor

Choose a reason for hiding this comment

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

Don't change the format of the file, please. Revert the deletion. This together with the wildcard makes me think you should review your IDE settings

Comment on lines +172 to +175
HtmlForm form = configurePage.getFormByName("config");
assertThrows(FailingHttpStatusCodeException.class, () -> {
j.submit(form);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

See the userLoginAfterEnablingFIPS method above in this test class. Probably you should check the log message as well. That method is doing

assertThat(getLogRecords(), hasItem(incorrectHashingLogEntry()));

Copy link
Author

Choose a reason for hiding this comment

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

Apparently , there are no logs events during the test execution.

@tejasdrolia tejasdrolia changed the title JENKINS-74858 | Added validation for Password length in FIPS mode [JENKINS-74858] Added validation for Password length in FIPS mode Nov 20, 2024
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.

4 participants