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

Move random string generation to one place #5950

Closed

Conversation

henning-gerhardt
Copy link
Collaborator

There was two places where random strings are created in two different ways. Instead of a self written solution on one place and a library usage this change move the library usage to a central place and replace the self written solution.

@henning-gerhardt henning-gerhardt force-pushed the unify_random_string_creation branch from 3cd64bd to f80183a Compare February 29, 2024 09:57
@stweil
Copy link
Member

stweil commented Mar 4, 2024

Wouldn't it be better to eliminate the function generateRandomString completely?

@henning-gerhardt
Copy link
Collaborator Author

Creating a random string is a needed functionality in the application - why do you want to remove it?

@stweil
Copy link
Member

stweil commented Mar 5, 2024

Yes, it is a needed functionality. But it does not require local functions when there is a library function RandomStringUtils.random which does the same and can be used instead of the local functions.

@henning-gerhardt
Copy link
Collaborator Author

Using RandomStringUtil.random with a secure random device needs a more complicated method call which must be replicated on all places. That is the reason why a wrapper method is needed. In the Helper class such "wrapper" method are placed and my change is doing this.

@solth solth requested a review from stweil March 18, 2024 15:20
@henning-gerhardt henning-gerhardt force-pushed the unify_random_string_creation branch from f80183a to 0625a06 Compare March 19, 2024 07:38
@henning-gerhardt henning-gerhardt force-pushed the unify_random_string_creation branch from 0625a06 to b13f8e3 Compare April 2, 2024 07:38
@henning-gerhardt henning-gerhardt force-pushed the unify_random_string_creation branch from b13f8e3 to 1a232e4 Compare April 12, 2024 11:09
@solth
Copy link
Member

solth commented May 3, 2024

@stweil do you approve this pull request with the explanation given above by @henning-gerhardt ?

@stweil
Copy link
Member

stweil commented May 3, 2024

@stweil do you approve this pull request with the explanation given above by @henning-gerhardt ?

Do we really need a cryptographically strong random number generator in class UserGenerator? As far as I see that class is only useful for tests, so I think the code could be simplified by using simple methods from class RandomStringUtils.

Then there remains a single location which still uses a secure random device. I am not sure whether it is required there, maybe it isn't. But at least there is no need for wrapper functions.

@henning-gerhardt henning-gerhardt force-pushed the unify_random_string_creation branch from 1a232e4 to abc83bf Compare May 13, 2024 10:15
@henning-gerhardt
Copy link
Collaborator Author

Do we really need a cryptographically strong random number generator in class UserGenerator? As far as I see that class is only useful for tests, so I think the code could be simplified by using simple methods from class RandomStringUtils.

The RandomStringUtils class is using a weak random generator source by default. This was the reason why this change (and an already merged pull request) was made. Using weak random generators in tests is not a good choice as tests should even use a strong / secure generator source if they are available.

@stweil
Copy link
Member

stweil commented May 13, 2024

Why should tests use strong and secure random generator sources? I think that tests are even an example where such generator sources are undesired because they use resources (entropy) although there is no need for increased security in tests. In addition pseudo random generator sources have advantages for tests because they optionally allow reproducible tests if the same seed is used.

@henning-gerhardt
Copy link
Collaborator Author

Okay, then I will close this pull request as the change is not needed or not wanted.

@henning-gerhardt henning-gerhardt deleted the unify_random_string_creation branch May 13, 2024 11:23
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