Skip to content

Commit 021b882

Browse files
authored
Merge pull request #322 from TreeBASE/copilot/fix-dependabot-alerts
Update dependencies to address security vulnerabilities
2 parents 3acf5af + 5359a99 commit 021b882

File tree

70 files changed

+1184
-478
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1184
-478
lines changed

oai-pmh_data_provider/data_provider_web/pom.xml

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,13 @@
124124
<groupId>struts</groupId>
125125
<artifactId>struts</artifactId>
126126
<version>1.2.9</version>
127+
<exclusions>
128+
<!-- Exclude old ANTLR 2.7.2 - Hibernate 5 requires 2.7.7 -->
129+
<exclusion>
130+
<groupId>antlr</groupId>
131+
<artifactId>antlr</artifactId>
132+
</exclusion>
133+
</exclusions>
127134
</dependency>
128135
<dependency>
129136
<groupId>opensymphony</groupId>
@@ -134,6 +141,21 @@
134141
<groupId>displaytag</groupId>
135142
<artifactId>displaytag</artifactId>
136143
<version>1.1.1</version>
144+
<exclusions>
145+
<!-- Exclude old SLF4J versions -->
146+
<exclusion>
147+
<groupId>org.slf4j</groupId>
148+
<artifactId>slf4j-api</artifactId>
149+
</exclusion>
150+
<exclusion>
151+
<groupId>org.slf4j</groupId>
152+
<artifactId>slf4j-log4j12</artifactId>
153+
</exclusion>
154+
<exclusion>
155+
<groupId>org.slf4j</groupId>
156+
<artifactId>jcl104-over-slf4j</artifactId>
157+
</exclusion>
158+
</exclusions>
137159
</dependency>
138160
<dependency>
139161
<groupId>struts-menu</groupId>
@@ -160,7 +182,20 @@
160182
<exclusion>
161183
<groupId>javax.servlet</groupId>
162184
<artifactId>jstl</artifactId>
163-
</exclusion>
185+
</exclusion>
186+
<!-- Exclude old SLF4J versions -->
187+
<exclusion>
188+
<groupId>org.slf4j</groupId>
189+
<artifactId>slf4j-api</artifactId>
190+
</exclusion>
191+
<exclusion>
192+
<groupId>org.slf4j</groupId>
193+
<artifactId>slf4j-log4j12</artifactId>
194+
</exclusion>
195+
<exclusion>
196+
<groupId>org.slf4j</groupId>
197+
<artifactId>jcl104-over-slf4j</artifactId>
198+
</exclusion>
164199
</exclusions>
165200
</dependency>
166201
<dependency>
@@ -244,6 +279,12 @@
244279
<groupId>javax.servlet</groupId>
245280
<artifactId>servlet-api</artifactId>
246281
<version>2.4</version>
282+
</dependency>
283+
<!-- Velocity 1.7 compatible with Spring 4.x -->
284+
<dependency>
285+
<groupId>org.apache.velocity</groupId>
286+
<artifactId>velocity</artifactId>
287+
<version>1.7</version>
247288
</dependency>
248289
<dependency>
249290
<groupId>velocity-tools</groupId>
@@ -265,6 +306,20 @@
265306
<artifactId>treebase-core</artifactId>
266307
<version>1.0-SNAPSHOT</version>
267308
</dependency>
309+
310+
<!-- SLF4J 2.0.16 for compatibility with Log4j 2.24.3 -->
311+
<dependency>
312+
<groupId>org.slf4j</groupId>
313+
<artifactId>slf4j-api</artifactId>
314+
<version>2.0.16</version>
315+
</dependency>
316+
317+
<!-- Log4j 2.x SLF4J binding -->
318+
<dependency>
319+
<groupId>org.apache.logging.log4j</groupId>
320+
<artifactId>log4j-slf4j2-impl</artifactId>
321+
<version>2.24.3</version>
322+
</dependency>
268323

269324
</dependencies>
270325

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
package org.cipres.treebase.web.compat;
2+
3+
import javax.servlet.http.HttpServletRequest;
4+
import javax.servlet.http.HttpServletResponse;
5+
6+
import org.springframework.validation.Validator;
7+
import org.springframework.web.bind.ServletRequestDataBinder;
8+
import org.springframework.web.servlet.ModelAndView;
9+
import org.springframework.web.servlet.mvc.AbstractController;
10+
11+
/**
12+
* Compatibility class to bridge Spring 3.x AbstractCommandController to Spring 4.x
13+
* This class provides a similar API to the removed Spring 3.x AbstractCommandController
14+
* by extending AbstractController and implementing command binding manually
15+
*/
16+
public abstract class AbstractCommandController extends AbstractController {
17+
18+
private Class<?> commandClass;
19+
private String commandName = "command";
20+
private Validator validator;
21+
22+
public void setCommandClass(Class<?> commandClass) {
23+
this.commandClass = commandClass;
24+
}
25+
26+
public Class<?> getCommandClass() {
27+
return commandClass;
28+
}
29+
30+
public void setCommandName(String commandName) {
31+
this.commandName = commandName;
32+
}
33+
34+
public String getCommandName() {
35+
return commandName;
36+
}
37+
38+
public void setValidator(Validator validator) {
39+
this.validator = validator;
40+
}
41+
42+
public Validator getValidator() {
43+
return validator;
44+
}
45+
46+
@Override
47+
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
48+
Object command = createCommand();
49+
ServletRequestDataBinder binder = createBinder(request, command);
50+
binder.bind(request);
51+
org.springframework.validation.BindException errors = new org.springframework.validation.BindException(binder.getBindingResult());
52+
53+
// Validate if validator is set
54+
if (validator != null) {
55+
validator.validate(command, errors);
56+
}
57+
58+
return handle(request, response, command, errors);
59+
}
60+
61+
protected Object createCommand() throws Exception {
62+
if (commandClass != null) {
63+
return commandClass.newInstance();
64+
}
65+
return new Object();
66+
}
67+
68+
protected ServletRequestDataBinder createBinder(HttpServletRequest request, Object command) throws Exception {
69+
ServletRequestDataBinder binder = new ServletRequestDataBinder(command, getCommandName());
70+
initBinder(request, binder);
71+
return binder;
72+
}
73+
74+
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
75+
// Override to customize binder
76+
}
77+
78+
/**
79+
* Template method for handling the command.
80+
* Subclasses must override this method to process the bound command object.
81+
* This version includes binding errors for validation.
82+
*/
83+
protected ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object command, org.springframework.validation.BindException errors) throws Exception {
84+
// Default implementation calls the 3-parameter version for backwards compatibility
85+
return handle(request, response, command);
86+
}
87+
88+
/**
89+
* Template method for handling the command.
90+
* Subclasses can override this method to process the bound command object.
91+
* Override the 4-parameter version if you need access to binding errors.
92+
*/
93+
protected ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object command) throws Exception {
94+
throw new UnsupportedOperationException("Subclasses must override either handle(request, response, command) or handle(request, response, command, errors)");
95+
}
96+
}

oai-pmh_data_provider/data_provider_web/src/main/java/org/cipres/treebase/web/controllers/OAIPMHController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
import org.springframework.validation.BindException;
1414
import org.springframework.web.servlet.ModelAndView;
15-
import org.springframework.web.servlet.mvc.AbstractCommandController;
15+
import org.cipres.treebase.web.compat.AbstractCommandController;
1616
import org.treebase.oai.web.command.Identify;
1717
import org.treebase.oai.web.command.OAIPMHCommand;
1818
import org.treebase.oai.web.util.IdentifyUtil;
Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,13 @@
11
package org.treebase.oai;
22

3-
import junit.framework.Test;
4-
import junit.framework.TestSuite;
5-
6-
3+
import org.junit.runner.RunWith;
4+
import org.junit.runners.Suite;
5+
import org.junit.runners.Suite.SuiteClasses;
6+
7+
@RunWith(Suite.class)
8+
@SuiteClasses({
9+
org.treebase.oai.web.PackageTestSuite.class
10+
})
711
public class PackageTestSuite {
8-
9-
10-
public static void main(String[] args) {
11-
junit.textui.TestRunner.run(suite());
12-
}
13-
14-
15-
public static Test suite() {
16-
TestSuite suite = new TestSuite("Tests in package " + PackageTestSuite.class.getName());
17-
18-
suite.addTest(org.treebase.oai.web.PackageTestSuite.suite());
19-
20-
return suite;
21-
}
12+
// JUnit 4 suite - test classes are specified in @SuiteClasses annotation
2213
}
23-
Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,15 @@
11
package org.treebase.oai.web;
22

3-
import junit.framework.Test;
4-
import junit.framework.TestSuite;
5-
6-
3+
import org.junit.runner.RunWith;
4+
import org.junit.runners.Suite;
5+
import org.junit.runners.Suite.SuiteClasses;
6+
7+
@RunWith(Suite.class)
8+
@SuiteClasses({
9+
org.treebase.oai.web.command.PackageTestSuite.class,
10+
org.treebase.oai.web.controller.PackageTestSuite.class,
11+
org.treebase.oai.web.util.PackageTestSuite.class
12+
})
713
public class PackageTestSuite {
8-
9-
10-
public static void main(String[] args) {
11-
junit.textui.TestRunner.run(suite());
12-
}
13-
14-
15-
public static Test suite() {
16-
TestSuite suite = new TestSuite("Tests in package " + PackageTestSuite.class.getName());
17-
18-
//suite.addTestSuite(ContextManagerTest.class);
19-
//suite.addTestSuite(RangeExpressionTest.class);
20-
//suite.addTestSuite(TreebaseIDStringTest.class);
21-
//suite.addTestSuite(TreebaseUtilTest.class);
22-
23-
suite.addTest(org.treebase.oai.web.command.PackageTestSuite.suite());
24-
suite.addTest(org.treebase.oai.web.controller.PackageTestSuite.suite());
25-
suite.addTest(org.treebase.oai.web.util.PackageTestSuite.suite());
26-
27-
return suite;
28-
}
14+
// JUnit 4 suite - test classes are specified in @SuiteClasses annotation
2915
}

oai-pmh_data_provider/data_provider_web/src/test/java/org/treebase/oai/web/command/IdentifyTest.java

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,24 @@
22

33
import java.util.Date;
44

5-
import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
5+
import org.junit.Test;
6+
import org.junit.runner.RunWith;
7+
import org.springframework.beans.factory.annotation.Autowired;
8+
import org.springframework.test.context.ContextConfiguration;
9+
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
610

11+
import static org.junit.Assert.assertNotNull;
712

8-
public class IdentifyTest extends AbstractDependencyInjectionSpringContextTests {
13+
@RunWith(SpringJUnit4ClassRunner.class)
14+
@ContextConfiguration(locations = {"classpath:applicationContext.xml"})
15+
public class IdentifyTest {
916

17+
@Autowired
1018
private Identify identify;
1119

12-
public void setIdentify(Identify identify) {
13-
this.identify = identify;
14-
}
15-
16-
@Override
17-
protected String[] getConfigLocations() {
18-
return new String[]{"applicationContext.xml"};
19-
}
20-
20+
@Test
2121
public void testLoadIdentify() {
22-
23-
this.assertNotNull(identify);
24-
22+
assertNotNull(identify);
2523
}
2624

27-
2825
}
Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
package org.treebase.oai.web.command;
22

3-
import junit.framework.Test;
4-
import junit.framework.TestSuite;
5-
3+
import org.junit.runner.RunWith;
4+
import org.junit.runners.Suite;
5+
import org.junit.runners.Suite.SuiteClasses;
6+
7+
@RunWith(Suite.class)
8+
@SuiteClasses({
9+
IdentifyTest.class
10+
})
611
public class PackageTestSuite {
7-
8-
public static Test suite() {
9-
TestSuite suite = new TestSuite("Test for org.cipres.treebase.auxdata");
10-
11-
suite.addTestSuite(IdentifyTest.class);
12-
13-
14-
15-
return suite;
16-
}
17-
12+
// JUnit 4 suite - test classes are specified in @SuiteClasses annotation
1813
}

0 commit comments

Comments
 (0)