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

Checking for invalid characters in SpringBootContextLoader.setActiveProfiles #36262

Closed
wants to merge 2 commits into from

Conversation

bbulgarelli
Copy link
Contributor

This PR relates to #34062. I created a loop at the beginning of the method that goes through the list of profiles and checks if there are any of these invalid characters: * & ! | ,. If so, an exception is thrown informing which profile is invalid and which characters are prohibited.
I also created the necessary tests to verify the method changes.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 6, 2023
@mhalbritter
Copy link
Contributor

mhalbritter commented Jul 21, 2023

Hey, thanks for that. What about the profile names ( and )? I think they should be prohibited, too.

, is interesting:

Of course it doesn't work in the

spring.profiles.active=a,b,

form. But it works in the

spring.profiles.active[0]=a
spring.profiles.active[1]=b
spring.profiles.active[2]=,

form. I still think it's a good idea to deny ,.

@mhalbritter mhalbritter added the status: waiting-for-feedback We need additional information before we can continue label Jul 21, 2023
Copy link

@mentallurg mentallurg left a comment

Choose a reason for hiding this comment

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

This pull request has multiple problems.

  1. This pull requests addresses a particular case only. What about ':', ';', '/', '', '?'? I suggest completely different approach: Allow letters, digits and hyphen only. Use functions Character.isAlphabetic(), Character.isDigit().

  2. Only a single case of profile usage is addressed, the list of active profile. But there are also other cases, when profile names are used, for instance, in the @Profile annotation. The same validation should be used everywhere.

  3. Documentation should be extended to describe what profile names will be considered valid.

@wilkinsona
Copy link
Member

It has been several months now without the requested feedback so I'm going to close this one. #34062 continues to track the enhancement that we'd like to make here.

@wilkinsona wilkinsona closed this Jan 31, 2024
@wilkinsona wilkinsona added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged labels Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants