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

Add security-constraint to web.xml #5827

Merged
merged 1 commit into from
Nov 22, 2023

Conversation

nielsm5
Copy link
Sponsor Member

@nielsm5 nielsm5 commented Nov 21, 2023

No description provided.

@nielsm5 nielsm5 linked an issue Nov 21, 2023 that may be closed by this pull request
Copy link

sonarcloud bot commented Nov 21, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

63.2% 63.2% Coverage
0.0% 0.0% Duplication

warning The version of Java (11.0.21) you have used to run this analysis is deprecated and we will stop accepting it soon. Please update to at least Java 17.
Read more here

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

@@ -103,8 +115,13 @@ private void addEndpoints(List<String> urlMappings) {
log.info("registering public endpoint with url [{}]", publicUrl);
publicEndpoints.add(publicUrl);
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
} else {
} else if(config.getSecurityRoles().isEmpty()) {
log.info("registering public endpoint with url pattern [{}]", url);
publicEndpoints.add(url);
} else {
log.info("registering private endpoint with url pattern [{}]", url);
privateEndpoints.add(url);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

is de huidge opzet met in het else block weer een if/else statement echt nodig?

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

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

De eerste if past de url aan, deze zet hem direct.

Copy link
Contributor

Choose a reason for hiding this comment

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

Dat snap, ik geef ook niet de suggestie om de if's te combineren...

image

Naar mijn idee is het if/else statement in het else block overbodig and kan het als volgt geschreven worden:

if(url.charAt(0) == '!') {
				String publicUrl = url.substring(1);
				log.info("registering public endpoint with url [{}]", publicUrl);
				publicEndpoints.add(publicUrl);
			} else if(config.getSecurityRoles().isEmpty()) {
			    log.info("registering public endpoint with url pattern [{}]", url);
			    publicEndpoints.add(url);
		    } else {
			    log.info("registering private endpoint with url pattern [{}]", url);
			    privateEndpoints.add(url);
		    }	

effectief doet dit hetzelfde...

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

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

Ik denk dat

boolean isExcludedUrl = url.charAt(0) == '!';
if(isExcludedUrl || config.getSecurityRoles().isEmpty()) {
	String publicUrl = isExcludedUrl ? url.substring(1) : url;
	log.info("registering public endpoint with url [{}]", publicUrl);
	publicEndpoints.add(publicUrl);
} else {
	log.info("registering private endpoint with url pattern [{}]", url);
	privateEndpoints.add(url);
}

dan misschien nog net iets netter is. Ik zal dit in een volgend pr meenemen.

@nielsm5 nielsm5 merged commit e2aaca5 into 7.9-release Nov 22, 2023
7 of 9 checks passed
@nielsm5 nielsm5 deleted the backport/securityElementWebFragment branch November 22, 2023 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

server health endpoint is protected
4 participants