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

qa: Address security issues identified by SonarLint #385

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/
package org.geoserver.cloud.restconfig;

import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.retry.annotation.EnableRetry;
Expand All @@ -16,8 +17,12 @@ public static void main(String[] args) {
try {
SpringApplication.run(RestConfigApplication.class, args);
} catch (RuntimeException e) {
e.printStackTrace();
System.exit(-1);
try {
LoggerFactory.getLogger(RestConfigApplication.class)
.error("Application run failed", e);
} finally {
System.exit(-1);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@
*/
package org.geoserver.cloud.wcs;

import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;

import org.geoserver.cloud.virtualservice.VirtualServiceVerifier;
import org.geoserver.ows.Dispatcher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.servlet.view.RedirectView;

import javax.servlet.http.HttpServletRequest;
Expand All @@ -39,30 +36,41 @@ public void getSchema(HttpServletRequest request, HttpServletResponse response)
classPathPublisher.handleRequest(request, response);
}

@RequestMapping(
method = {GET, POST},
path = {"/wcs", "/ows"})
public void handle(HttpServletRequest request, HttpServletResponse response) throws Exception {
geoserverDispatcher.handleRequest(request, response);
@GetMapping(path = {"/wcs", "/ows"})
public void handleGet(HttpServletRequest request, HttpServletResponse response)
throws Exception {
dispatch(request, response);
}

@RequestMapping(
method = {GET, POST},
path = {"/{virtualService}/wcs", "/{virtualService}/ows"})
@PostMapping(path = {"/wcs", "/ows"})
public void handlePost(HttpServletRequest request, HttpServletResponse response)
throws Exception {
dispatch(request, response);
}

@GetMapping(path = {"/{virtualService}/wcs", "/{virtualService}/ows"})
public void handleVirtualService(
@PathVariable(name = "virtualService") String virtualService,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {

virtualServiceVerifier.checkVirtualService(virtualService);
dispatch(request, response);
}

geoserverDispatcher.handleRequest(request, response);
@PostMapping(path = {"/{virtualService}/wcs", "/{virtualService}/ows"})
public void handleVirtualServicePost(
@PathVariable(name = "virtualService") String virtualService,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {

virtualServiceVerifier.checkVirtualService(virtualService);
dispatch(request, response);
}

@RequestMapping(
method = {GET, POST},
path = {"/{virtualService}/{layer}/wcs", "/{virtualService}/{layer}/ows"})
@GetMapping(path = {"/{virtualService}/{layer}/wcs", "/{virtualService}/{layer}/ows"})
public void handleVirtualServiceLayer(
@PathVariable(name = "virtualService") String virtualService,
@PathVariable(name = "layer") String layer,
Expand All @@ -71,6 +79,23 @@ public void handleVirtualServiceLayer(
throws Exception {

virtualServiceVerifier.checkVirtualService(virtualService, layer);
dispatch(request, response);
}

@PostMapping(path = {"/{virtualService}/{layer}/wcs", "/{virtualService}/{layer}/ows"})
public void handleVirtualServiceLayerPost(
@PathVariable(name = "virtualService") String virtualService,
@PathVariable(name = "layer") String layer,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {

virtualServiceVerifier.checkVirtualService(virtualService, layer);
dispatch(request, response);
}

private void dispatch(HttpServletRequest request, HttpServletResponse response)
throws Exception {
geoserverDispatcher.handleRequest(request, response);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/
package org.geoserver.cloud.wcs;

import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.retry.annotation.EnableRetry;
Expand All @@ -16,8 +17,11 @@ public static void main(String[] args) {
try {
SpringApplication.run(WcsApplication.class, args);
} catch (RuntimeException e) {
e.printStackTrace();
System.exit(-1);
try {
LoggerFactory.getLogger(WcsApplication.class).error("Application run failed", e);
} finally {
System.exit(-1);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/
package org.geoserver.cloud.web.app;

import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.event.ApplicationReadyEvent;
Expand All @@ -19,8 +20,11 @@ public static void main(String[] args) {
try {
SpringApplication.run(WebUIApplication.class, args);
} catch (RuntimeException e) {
e.printStackTrace();
System.exit(-1);
try {
LoggerFactory.getLogger(WebUIApplication.class).error("Application run failed", e);
} finally {
System.exit(-1);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@
*/
package org.geoserver.cloud.wfs.app;

import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;

import org.geoserver.cloud.virtualservice.VirtualServiceVerifier;
import org.geoserver.ows.Dispatcher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.servlet.view.RedirectView;

import javax.servlet.http.HttpServletRequest;
Expand All @@ -40,38 +37,66 @@ public void getSchema(HttpServletRequest request, HttpServletResponse response)
classPathPublisher.handleRequest(request, response);
}

@RequestMapping(
method = {GET, POST},
path = {"/wfs", "/ows"})
public void handle(HttpServletRequest request, HttpServletResponse response) throws Exception {
geoserverDispatcher.handleRequest(request, response);
@GetMapping(path = {"/wfs", "/ows"})
public void handleGet(HttpServletRequest request, HttpServletResponse response)
throws Exception {
dispatch(request, response);
}

@RequestMapping(
method = {GET, POST},
path = {"/{virtualService}/wfs", "/{virtualService}/ows"})
public void handleVirtualService(
@PostMapping(path = {"/wfs", "/ows"})
public void handlePost(HttpServletRequest request, HttpServletResponse response)
throws Exception {
dispatch(request, response);
}

@GetMapping(path = {"/{virtualService}/wfs", "/{virtualService}/ows"})
public void handleVirtualServiceGet(
@PathVariable(name = "virtualService") String virtualService,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {

virtualServiceVerifier.checkVirtualService(virtualService);
dispatch(request, response);
}

geoserverDispatcher.handleRequest(request, response);
@PostMapping(path = {"/{virtualService}/wfs", "/{virtualService}/ows"})
public void handleVirtualServicePost(
@PathVariable(name = "virtualService") String virtualService,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {

virtualServiceVerifier.checkVirtualService(virtualService);
dispatch(request, response);
}

@RequestMapping(
method = {GET, POST},
path = {"/{virtualService}/{layer}/wfs", "/{virtualService}/{layer}/ows"})
public void handleVirtualServiceLayer(
@GetMapping(path = {"/{virtualService}/{layer}/wfs", "/{virtualService}/{layer}/ows"})
public void handleVirtualServiceLayerGet(
@PathVariable(name = "virtualService") String virtualService,
@PathVariable(name = "layer") String layer,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {

virtualServiceVerifier.checkVirtualService(virtualService, layer);
dispatch(request, response);
}

@PostMapping(path = {"/{virtualService}/{layer}/wfs", "/{virtualService}/{layer}/ows"})
public void handleVirtualServiceLayerPost(
@PathVariable(name = "virtualService") String virtualService,
@PathVariable(name = "layer") String layer,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {

virtualServiceVerifier.checkVirtualService(virtualService, layer);
dispatch(request, response);
}

private void dispatch(HttpServletRequest request, HttpServletResponse response)
throws Exception {
geoserverDispatcher.handleRequest(request, response);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/
package org.geoserver.cloud.wms.app;

import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.retry.annotation.EnableRetry;
Expand All @@ -16,8 +17,11 @@ public static void main(String[] args) {
try {
SpringApplication.run(WmsApplication.class, args);
} catch (RuntimeException e) {
e.printStackTrace();
System.exit(-1);
try {
LoggerFactory.getLogger(WmsApplication.class).error("Application run failed", e);
} finally {
System.exit(-1);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@
*/
package org.geoserver.cloud.wms.controller;

import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;

import org.geoserver.cloud.virtualservice.VirtualServiceVerifier;
import org.geoserver.ows.Dispatcher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.servlet.view.RedirectView;

import javax.servlet.http.HttpServletRequest;
Expand Down Expand Up @@ -64,38 +61,66 @@ public void getStaticResource(HttpServletRequest request, HttpServletResponse re
classPathPublisher.handleRequest(request, response);
}

@RequestMapping(
method = {GET, POST},
path = {"/wms", "/ows"})
public void handle(HttpServletRequest request, HttpServletResponse response) throws Exception {
geoserverDispatcher.handleRequest(request, response);
@GetMapping(path = {"/wms", "/ows"})
public void handleGet(HttpServletRequest request, HttpServletResponse response)
throws Exception {
dispatch(request, response);
}

@RequestMapping(
method = {GET, POST},
path = {"/{virtualService}/wms", "/{virtualService}/ows"})
public void handleVirtualService(
@PostMapping(path = {"/wms", "/ows"})
public void handlePost(HttpServletRequest request, HttpServletResponse response)
throws Exception {
dispatch(request, response);
}

@GetMapping(path = {"/{virtualService}/wms", "/{virtualService}/ows"})
public void handleVirtualServiceGet(
@PathVariable(name = "virtualService") String virtualService,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {

virtualServiceVerifier.checkVirtualService(virtualService);
dispatch(request, response);
}

geoserverDispatcher.handleRequest(request, response);
@PostMapping(path = {"/{virtualService}/wms", "/{virtualService}/ows"})
public void handleVirtualServicePost(
@PathVariable(name = "virtualService") String virtualService,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {

virtualServiceVerifier.checkVirtualService(virtualService);
dispatch(request, response);
}

@RequestMapping(
method = {GET, POST},
path = {"/{virtualService}/{layer}/wms", "/{virtualService}/{layer}/ows"})
public void handleVirtualServiceLayer(
@GetMapping(path = {"/{virtualService}/{layer}/wms", "/{virtualService}/{layer}/ows"})
public void handleVirtualServiceLayerGet(
@PathVariable(name = "virtualService") String virtualService,
@PathVariable(name = "layer") String layer,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {

virtualServiceVerifier.checkVirtualService(virtualService, layer);
dispatch(request, response);
}

@PostMapping(path = {"/{virtualService}/{layer}/wms", "/{virtualService}/{layer}/ows"})
public void handleVirtualServiceLayerPost(
@PathVariable(name = "virtualService") String virtualService,
@PathVariable(name = "layer") String layer,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {

virtualServiceVerifier.checkVirtualService(virtualService, layer);
dispatch(request, response);
}

private void dispatch(HttpServletRequest request, HttpServletResponse response)
throws Exception {
geoserverDispatcher.handleRequest(request, response);
}
}
Loading
Loading