Skip to content

Commit 00729a9

Browse files
authored
[SONAR] cleanup some security warnings and hardening (#6837)
Add deprecation to some endpoints cleanup and jetty fix
1 parent 04ed14c commit 00729a9

37 files changed

+663
-317
lines changed

docker/integration-tests/unit-tests.Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ RUN chown -R ${JENKINS_USER}:${JENKINS_GROUP} ${DEPLOYMENT_PATH}/hop \
9090
# Download Additional drivers/dependencies
9191
ADD --chown=${JENKINS_USER}:${JENKINS_GROUP} https://repo1.maven.org/maven2/com/vertica/jdbc/vertica-jdbc/23.4.0-0/vertica-jdbc-23.4.0-0.jar /opt/hop/lib/jdbc/vertica-jdbc-23.4.0-0.jar
9292
ADD --chown=${JENKINS_USER}:${JENKINS_GROUP} https://repo1.maven.org/maven2/com/mysql/mysql-connector-j/9.2.0/mysql-connector-j-9.2.0.jar /opt/hop/lib/jdbc/mysql-connector-j-9.2.0.jar
93-
ADD --chown=${JENKINS_USER}:${JENKINS_GROUP} https://repo1.maven.org/maven2/org/openjdk/nashorn/nashorn-core/15.4/nashorn-core-15.4.jar /opt/hop/plugins/transforms/script/lib/nashorn-core-15.4.jar
9493

9594
# make volume available so that hop pipeline and workflow files can be provided easily
9695
VOLUME ["/files"]

docs/hop-user-manual/modules/ROOT/pages/hop-server/rest-api.adoc

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,22 @@ Hop Server has a rich set of web services that can be used to query and manage t
2424

2525
TIP: when specified, the id for a workflow or pipeline represents one execution of a workflow or pipeline on the server.
2626

27-
== addExport
27+
== addExport _(deprecated)_
28+
29+
[WARNING]
30+
====
31+
*Deprecated since 2.18.0.* Use `registerPackage` (`hop/registerPackage`) instead.
32+
The remote pipeline and workflow engines call `registerPackage` for all export operations.
33+
This endpoint will be removed in a future release.
34+
====
2835

2936
name::
3037
addExport
3138

3239
description::
3340
Upload a resources export file.
3441
Add a zipped pipeline or workflow to the body payload as a binary file.
42+
*Deprecated* — use `registerPackage` instead.
3543

3644
endPoint::
3745
GET `hop/addExport`
@@ -56,13 +64,20 @@ A zip file with the export is created on the server's file system.
5664
</webresult>
5765
----
5866

59-
== addPipeline
67+
== addPipeline _(deprecated)_
68+
69+
[WARNING]
70+
====
71+
*Deprecated since 2.18.0.* Use <<Register Pipeline,`registerPipeline`>> (`hop/registerPipeline`) instead.
72+
This endpoint is no longer used by the remote pipeline engine and will be removed in a future release.
73+
====
6074

6175
name::
6276
addPipeline
6377

6478
description::
65-
Add a pipeline for execution
79+
Add a pipeline for execution.
80+
*Deprecated* — use `registerPipeline` instead.
6681

6782
endPoint::
6883
GET `hop/addPipeline`
@@ -75,15 +90,22 @@ example request::
7590
`+http://localhost:8081/hop/addPipeline/xml=Y+` with XML payload
7691

7792
result::
78-
-
93+
-
94+
95+
== addWorkflow _(deprecated)_
7996

80-
== addWorkflow
97+
[WARNING]
98+
====
99+
*Deprecated since 2.18.0.* Use <<Register Workflow,`registerWorkflow`>> (`hop/registerWorkflow`) instead.
100+
This endpoint is no longer used by the remote workflow engine and will be removed in a future release.
101+
====
81102

82103
name::
83104
addWorkflow
84105

85106
description::
86-
Add a workflow for execution
107+
Add a workflow for execution.
108+
*Deprecated* — use `registerWorkflow` instead.
87109

88110
endPoint::
89111
GET `hop/addWorkflow`

engine/pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,6 @@
120120
</exclusion>
121121
</exclusions>
122122
</dependency>
123-
<dependency>
124-
<groupId>org.eclipse.jetty</groupId>
125-
<artifactId>jetty-jaas</artifactId>
126-
</dependency>
127123
<dependency>
128124
<groupId>org.eclipse.jetty</groupId>
129125
<artifactId>jetty-security</artifactId>
@@ -199,6 +195,10 @@
199195
</exclusion>
200196
</exclusions>
201197
</dependency>
198+
<dependency>
199+
<groupId>org.jspecify</groupId>
200+
<artifactId>jspecify</artifactId>
201+
</dependency>
202202
<dependency>
203203
<groupId>org.mozilla</groupId>
204204
<artifactId>rhino-all</artifactId>

engine/src/main/java/org/apache/hop/www/AddExportServlet.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,13 @@
5656
* a zip file. It ends up in a temporary file.
5757
*
5858
* <p>The servlet returns the name of the file stored.
59+
*
60+
* @deprecated Use {@link RegisterPackageServlet} ({@code /hop/registerPackage}) instead. The remote
61+
* pipeline and workflow engines call {@code registerPackage} for all export operations. This
62+
* endpoint will be removed in a future release.
5963
*/
60-
@HopServerServlet(id = "addExport", name = "Upload a resources export file")
64+
@Deprecated(since = "2.18.0")
65+
@HopServerServlet(id = "addExport", name = "Upload a resources export file (deprecated)")
6166
public class AddExportServlet extends BaseHttpServlet implements IHopServerPlugin {
6267
public static final String PARAMETER_LOAD = "load";
6368
public static final String PARAMETER_TYPE = "type";
@@ -84,7 +89,10 @@ public void doGet(HttpServletRequest request, HttpServletResponse response)
8489
logDebug("Addition of export requested");
8590
}
8691

87-
PrintWriter out = response.getWriter();
92+
PrintWriter out = getSafeWriter(response);
93+
if (out == null) {
94+
return;
95+
}
8896
InputStream in = request.getInputStream(); // read from the client
8997
if (log.isDetailed()) {
9098
logDetailed("Encoding: " + request.getCharacterEncoding());

engine/src/main/java/org/apache/hop/www/AddPipelineServlet.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,13 @@
4242
import org.apache.hop.pipeline.engine.IPipelineEngine;
4343
import org.apache.hop.pipeline.engine.PipelineEngineFactory;
4444

45-
@HopServerServlet(id = "addPipeline", name = "Add a pipeline for execution")
45+
/**
46+
* @deprecated Use {@link RegisterPipelineServlet} ({@code /hop/registerPipeline}) instead. This
47+
* endpoint is no longer called by the remote pipeline engine and will be removed in a future
48+
* release.
49+
*/
50+
@Deprecated(since = "2.18.0")
51+
@HopServerServlet(id = "addPipeline", name = "Add a pipeline for execution (deprecated)")
4652
public class AddPipelineServlet extends BaseHttpServlet implements IHopServerPlugin {
4753
@Serial private static final long serialVersionUID = -6850701762586992604L;
4854

@@ -67,8 +73,14 @@ public void doGet(HttpServletRequest request, HttpServletResponse response)
6773

6874
boolean useXML = "Y".equalsIgnoreCase(request.getParameter("xml"));
6975

70-
PrintWriter out = response.getWriter();
71-
BufferedReader in = request.getReader();
76+
PrintWriter out = getSafeWriter(response);
77+
if (out == null) {
78+
return;
79+
}
80+
BufferedReader in = getSafeReader(request, response);
81+
if (in == null) {
82+
return;
83+
}
7284
if (log.isDetailed()) {
7385
logDetailed("Encoding: " + request.getCharacterEncoding());
7486
}

engine/src/main/java/org/apache/hop/www/AddWorkflowServlet.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,13 @@
4242
import org.apache.hop.workflow.engine.IWorkflowEngine;
4343
import org.apache.hop.workflow.engine.WorkflowEngineFactory;
4444

45-
@HopServerServlet(id = "addWorkflow", name = "Add a workflow to the server")
45+
/**
46+
* @deprecated Use {@link RegisterWorkflowServlet} ({@code /hop/registerWorkflow}) instead. This
47+
* endpoint is no longer called by the remote workflow engine and will be removed in a future
48+
* release.
49+
*/
50+
@Deprecated(since = "2.18.0")
51+
@HopServerServlet(id = "addWorkflow", name = "Add a workflow to the server (deprecated)")
4652
public class AddWorkflowServlet extends BaseHttpServlet implements IHopServerPlugin {
4753
@Serial private static final long serialVersionUID = -6850701762586992604L;
4854

@@ -67,8 +73,14 @@ public void doGet(HttpServletRequest request, HttpServletResponse response)
6773

6874
boolean useXML = "Y".equalsIgnoreCase(request.getParameter("xml"));
6975

70-
PrintWriter out = response.getWriter();
71-
BufferedReader in = request.getReader(); // read from the client
76+
PrintWriter out = getSafeWriter(response);
77+
if (out == null) {
78+
return;
79+
}
80+
BufferedReader in = getSafeReader(request, response);
81+
if (in == null) {
82+
return;
83+
}
7284
if (log.isDetailed()) {
7385
logDetailed("Encoding: " + request.getCharacterEncoding());
7486
}
@@ -196,7 +208,7 @@ public void doGet(HttpServletRequest request, HttpServletResponse response)
196208

197209
protected String[] getAllArgumentStrings(Map<String, String> arguments) {
198210
if (Utils.isEmpty(arguments)) {
199-
return null;
211+
return new String[0];
200212
}
201213

202214
String[] argNames = arguments.keySet().toArray(new String[arguments.size()]);

engine/src/main/java/org/apache/hop/www/BaseHopServerPlugin.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import com.google.common.collect.FluentIterable;
2121
import com.google.common.collect.ImmutableMultimap;
22+
import jakarta.servlet.ServletException;
2223
import jakarta.servlet.http.HttpServletRequest;
2324
import jakarta.servlet.http.HttpServletResponse;
2425
import java.io.IOException;
@@ -40,8 +41,15 @@ public abstract class BaseHopServerPlugin extends BaseHttpServlet
4041
*/
4142
@Deprecated(since = "2.0")
4243
@Override
43-
public void doGet(HttpServletRequest req, final HttpServletResponse resp) throws IOException {
44-
service(req, resp);
44+
public void doGet(HttpServletRequest req, final HttpServletResponse resp)
45+
throws ServletException, IOException {
46+
try {
47+
service(req, resp);
48+
} catch (IOException e) {
49+
logError("I/O error servicing request for " + getContextPath(), e);
50+
sendSafeError(
51+
resp, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Unable to process server request.");
52+
}
4553
}
4654

4755
@Override
@@ -57,12 +65,6 @@ protected void service(HttpServletRequest req, HttpServletResponse resp) throws
5765
handleRequest(new HopServerRequestImpl(req, resp));
5866
}
5967

60-
@Override
61-
public abstract void handleRequest(IHopServerRequest request) throws IOException;
62-
63-
@Override
64-
public abstract String getContextPath();
65-
6668
@Override
6769
public String getService() {
6870
return getContextPath() + " (" + toString() + ")";

0 commit comments

Comments
 (0)