Skip to content

Commit 0fe4daa

Browse files
committed
bump Apache Commons lang3 to 3.18.0
1 parent c15d8b3 commit 0fe4daa

File tree

7 files changed

+38
-35
lines changed

7 files changed

+38
-35
lines changed

opengrok-indexer/src/test/java/org/opengrok/indexer/web/DummyHttpServletRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public long getCreationTime() {
7777

7878
@Override
7979
public String getId() {
80-
return RandomStringUtils.random(32, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.");
80+
return RandomStringUtils.secure().next(32, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.");
8181
}
8282

8383
@Override

opengrok-web/src/main/java/org/opengrok/web/api/v1/suggester/parser/SuggesterQueryDataParser.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
2222
*/
2323
package org.opengrok.web.api.v1.suggester.parser;
2424

@@ -110,11 +110,11 @@ private static ProcessedQueryData processQuery(final String text, final int care
110110

111111
logger.log(Level.FINEST, "Processing suggester query: {0} at {1}", new Object[] {text, caretPosition});
112112

113-
String randomIdentifier = RandomStringUtils.
114-
randomAlphabetic(IDENTIFIER_LENGTH).toLowerCase(); // OK no ROOT
113+
String randomIdentifier = RandomStringUtils.secure().
114+
nextAlphabetic(IDENTIFIER_LENGTH).toLowerCase(); // OK no ROOT
115115
while (text.contains(randomIdentifier)) {
116-
randomIdentifier = RandomStringUtils.
117-
randomAlphabetic(IDENTIFIER_LENGTH).toLowerCase(); // OK no ROOT
116+
randomIdentifier = RandomStringUtils.secure().
117+
nextAlphabetic(IDENTIFIER_LENGTH).toLowerCase(); // OK no ROOT
118118
}
119119

120120
String newText = new StringBuilder(text).insert(caretPosition, randomIdentifier).toString();

plugins/src/test/java/opengrok/auth/plugin/FalsePluginTest.java

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

2020
/*
2121
* Copyright (c) 2020, Chris Fraire <[email protected]>.
22+
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
2223
*/
2324
package opengrok.auth.plugin;
2425

@@ -62,27 +63,27 @@ void shouldUnload() {
6263
@Test
6364
void shouldNotAllowRandomUserForAnyProject() {
6465
DummyHttpServletRequest req = new DummyHttpServletRequest();
65-
req.setAttribute(UserPlugin.REQUEST_ATTR, new User(RandomStringUtils.randomAlphanumeric(8)));
66+
req.setAttribute(UserPlugin.REQUEST_ATTR, new User(RandomStringUtils.secure().nextAlphanumeric(8)));
6667

67-
Project randomProject = new Project(RandomStringUtils.randomAlphanumeric(10));
68+
Project randomProject = new Project(RandomStringUtils.secure().nextAlphanumeric(10));
6869
boolean projectAllowed = plugin.isAllowed(req, randomProject);
6970
assertFalse(projectAllowed, "should not allow rando for random project 1");
7071

71-
randomProject = new Project(RandomStringUtils.randomAlphanumeric(10));
72+
randomProject = new Project(RandomStringUtils.secure().nextAlphanumeric(10));
7273
projectAllowed = plugin.isAllowed(req, randomProject);
7374
assertFalse(projectAllowed, "should not allow rando for random project 2");
7475
}
7576

7677
@Test
7778
void shouldNotAllowRandomUserForAnyGroup() {
7879
DummyHttpServletRequest req = new DummyHttpServletRequest();
79-
req.setAttribute(UserPlugin.REQUEST_ATTR, new User(RandomStringUtils.randomAlphanumeric(8)));
80+
req.setAttribute(UserPlugin.REQUEST_ATTR, new User(RandomStringUtils.secure().nextAlphanumeric(8)));
8081

81-
Group randomGroup = new Group(RandomStringUtils.randomAlphanumeric(10));
82+
Group randomGroup = new Group(RandomStringUtils.secure().nextAlphanumeric(10));
8283
boolean projectAllowed = plugin.isAllowed(req, randomGroup);
8384
assertFalse(projectAllowed, "should not allow rando for random group 1");
8485

85-
randomGroup = new Group(RandomStringUtils.randomAlphanumeric(10));
86+
randomGroup = new Group(RandomStringUtils.secure().nextAlphanumeric(10));
8687
projectAllowed = plugin.isAllowed(req, randomGroup);
8788
assertFalse(projectAllowed, "should not allow rando for random group 2");
8889
}

plugins/src/test/java/opengrok/auth/plugin/TruePluginTest.java

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

2020
/*
2121
* Copyright (c) 2020, Chris Fraire <[email protected]>.
22+
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
2223
*/
2324
package opengrok.auth.plugin;
2425

@@ -62,27 +63,27 @@ void shouldUnload() {
6263
@Test
6364
void shouldAllowRandomUserForAnyProject() {
6465
DummyHttpServletRequest req = new DummyHttpServletRequest();
65-
req.setAttribute(UserPlugin.REQUEST_ATTR, new User(RandomStringUtils.randomAlphanumeric(8)));
66+
req.setAttribute(UserPlugin.REQUEST_ATTR, new User(RandomStringUtils.secure().nextAlphanumeric(8)));
6667

67-
Project randomProject = new Project(RandomStringUtils.randomAlphanumeric(10));
68+
Project randomProject = new Project(RandomStringUtils.secure().nextAlphanumeric(10));
6869
boolean projectAllowed = plugin.isAllowed(req, randomProject);
6970
assertTrue(projectAllowed, "should allow rando for random project 1");
7071

71-
randomProject = new Project(RandomStringUtils.randomAlphanumeric(10));
72+
randomProject = new Project(RandomStringUtils.secure().nextAlphanumeric(10));
7273
projectAllowed = plugin.isAllowed(req, randomProject);
7374
assertTrue(projectAllowed, "should allow rando for random project 2");
7475
}
7576

7677
@Test
7778
void shouldAllowRandomUserForAnyGroup() {
7879
DummyHttpServletRequest req = new DummyHttpServletRequest();
79-
req.setAttribute(UserPlugin.REQUEST_ATTR, new User(RandomStringUtils.randomAlphanumeric(8)));
80+
req.setAttribute(UserPlugin.REQUEST_ATTR, new User(RandomStringUtils.secure().nextAlphanumeric(8)));
8081

81-
Group randomGroup = new Group(RandomStringUtils.randomAlphanumeric(10));
82+
Group randomGroup = new Group(RandomStringUtils.secure().nextAlphanumeric(10));
8283
boolean projectAllowed = plugin.isAllowed(req, randomGroup);
8384
assertTrue(projectAllowed, "should allow rando for random group 1");
8485

85-
randomGroup = new Group(RandomStringUtils.randomAlphanumeric(10));
86+
randomGroup = new Group(RandomStringUtils.secure().nextAlphanumeric(10));
8687
projectAllowed = plugin.isAllowed(req, randomGroup);
8788
assertTrue(projectAllowed, "should allow rando for random group 2");
8889
}

plugins/src/test/java/opengrok/auth/plugin/UserWhiteListPluginTest.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
/*
2121
* Copyright (c) 2020, Chris Fraire <[email protected]>.
22-
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
22+
* Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved.
2323
*/
2424
package opengrok.auth.plugin;
2525

@@ -141,7 +141,7 @@ void shouldThrowOnLoadIfUnreadableFileSpecified(String param) {
141141
init(param);
142142
HashMap<String, Object> unreadablePluginParameters = new HashMap<>();
143143
unreadablePluginParameters.put(UserWhiteListPlugin.FILE_PARAM,
144-
RandomStringUtils.randomAlphanumeric(24));
144+
RandomStringUtils.secure().nextAlphanumeric(24));
145145

146146
IllegalArgumentException caughtException = null;
147147
try {
@@ -188,8 +188,9 @@ void shouldStripWhitespaceFromWhitelists(String param) throws IOException {
188188
}
189189

190190
// Make sure there as some entries with trailing spaces in the file.
191-
Stream<String> stream = Files.lines(tmpFile.toPath());
192-
assertTrue(stream.anyMatch(s -> s.startsWith(" ") || s.endsWith(" ")));
191+
try (Stream<String> stream = Files.lines(tmpFile.toPath())) {
192+
assertTrue(stream.anyMatch(s -> s.startsWith(" ") || s.endsWith(" ")));
193+
}
193194

194195
pluginParameters.put(UserWhiteListPlugin.FILE_PARAM, tmpFile.toString());
195196
plugin.load(pluginParameters);
@@ -221,11 +222,11 @@ void shouldAllowWhitelistedUserForAnyProject(String param) {
221222
}
222223
req.setAttribute(UserPlugin.REQUEST_ATTR, user);
223224

224-
Project randomProject = new Project(RandomStringUtils.randomAlphanumeric(10));
225+
Project randomProject = new Project(RandomStringUtils.secure().nextAlphanumeric(10));
225226
boolean projectAllowed = plugin.isAllowed(req, randomProject);
226227
assertTrue(projectAllowed, "should allow OK entity for random project 1");
227228

228-
randomProject = new Project(RandomStringUtils.randomAlphanumeric(10));
229+
randomProject = new Project(RandomStringUtils.secure().nextAlphanumeric(10));
229230
projectAllowed = plugin.isAllowed(req, randomProject);
230231
assertTrue(projectAllowed, "should allow OK entity for random project 2");
231232
}
@@ -237,13 +238,13 @@ void shouldNotAllowRandomUserForAnyProject(String param) {
237238
plugin.load(validPluginParameters);
238239

239240
DummyHttpServletRequest req = new DummyHttpServletRequest();
240-
req.setAttribute(UserPlugin.REQUEST_ATTR, new User(RandomStringUtils.randomAlphanumeric(8)));
241+
req.setAttribute(UserPlugin.REQUEST_ATTR, new User(RandomStringUtils.secure().nextAlphanumeric(8)));
241242

242-
Project randomProject = new Project(RandomStringUtils.randomAlphanumeric(10));
243+
Project randomProject = new Project(RandomStringUtils.secure().nextAlphanumeric(10));
243244
boolean projectAllowed = plugin.isAllowed(req, randomProject);
244245
assertFalse(projectAllowed, "should not allow random user for random project 1");
245246

246-
randomProject = new Project(RandomStringUtils.randomAlphanumeric(10));
247+
randomProject = new Project(RandomStringUtils.secure().nextAlphanumeric(10));
247248
projectAllowed = plugin.isAllowed(req, randomProject);
248249
assertFalse(projectAllowed, "should not allow random user for random project 2");
249250
}
@@ -263,11 +264,11 @@ void shouldAllowWhitelistedUserForAnyGroup(String param) {
263264
}
264265
req.setAttribute(UserPlugin.REQUEST_ATTR, user);
265266

266-
Group randomGroup = new Group(RandomStringUtils.randomAlphanumeric(10));
267+
Group randomGroup = new Group(RandomStringUtils.secure().nextAlphanumeric(10));
267268
boolean groupAllowed = plugin.isAllowed(req, randomGroup);
268269
assertTrue(groupAllowed, "should allow OK entity for random group 1");
269270

270-
randomGroup = new Group(RandomStringUtils.randomAlphanumeric(10));
271+
randomGroup = new Group(RandomStringUtils.secure().nextAlphanumeric(10));
271272
groupAllowed = plugin.isAllowed(req, randomGroup);
272273
assertTrue(groupAllowed, "should allow OK entity for random group 2");
273274
}
@@ -279,13 +280,13 @@ void shouldNotAllowRandomUserForAnyGroup(String param) {
279280
plugin.load(validPluginParameters);
280281

281282
DummyHttpServletRequest req = new DummyHttpServletRequest();
282-
req.setAttribute(UserPlugin.REQUEST_ATTR, new User(RandomStringUtils.randomAlphanumeric(8)));
283+
req.setAttribute(UserPlugin.REQUEST_ATTR, new User(RandomStringUtils.secure().nextAlphanumeric(8)));
283284

284-
Group randomGroup = new Group(RandomStringUtils.randomAlphanumeric(10));
285+
Group randomGroup = new Group(RandomStringUtils.secure().nextAlphanumeric(10));
285286
boolean projectAllowed = plugin.isAllowed(req, randomGroup);
286287
assertFalse(projectAllowed, "should not allow random group 1");
287288

288-
randomGroup = new Group(RandomStringUtils.randomAlphanumeric(10));
289+
randomGroup = new Group(RandomStringUtils.secure().nextAlphanumeric(10));
289290
projectAllowed = plugin.isAllowed(req, randomGroup);
290291
assertFalse(projectAllowed, "should not allow random group 2");
291292
}

plugins/src/test/java/opengrok/auth/plugin/util/DummyHttpServletRequestLdap.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved.
2222
*/
2323
package opengrok.auth.plugin.util;
2424

@@ -69,7 +69,7 @@ public String getId() {
6969
if ((user = (User) getAttribute(UserPlugin.REQUEST_ATTR)) != null) {
7070
return user.getUsername();
7171
}
72-
return RandomStringUtils.randomAlphanumeric(5);
72+
return RandomStringUtils.secure().nextAlphanumeric(5);
7373
}
7474

7575
@Override

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Portions Copyright (c) 2018, 2020, Chris Fraire <[email protected]>.
7272
<junit.version>5.10.0</junit.version>
7373
<hamcrest.version>2.2</hamcrest.version>
7474
<maven-surefire.version>3.0.0-M5</maven-surefire.version>
75-
<apache-commons-lang3.version>3.13.0</apache-commons-lang3.version>
75+
<apache-commons-lang3.version>3.18.0</apache-commons-lang3.version>
7676
<micrometer.version>1.14.1</micrometer.version>
7777
<mockito.version>5.17.0</mockito.version>
7878
<commons-io.version>2.14.0</commons-io.version>

0 commit comments

Comments
 (0)