Skip to content

Commit

Permalink
Address security issues identified by SonarLint
Browse files Browse the repository at this point in the history
  • Loading branch information
groldan committed Dec 2, 2023
1 parent e3ec42c commit 1b2344c
Show file tree
Hide file tree
Showing 14 changed files with 261 additions and 92 deletions.
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

0 comments on commit 1b2344c

Please sign in to comment.