Skip to content

Commit 3088f04

Browse files
authored
Mitigate #757: when creating the AuthTestMockServer, do not use a privileged port number (less than 1024). (#800)
1 parent 2a75e2e commit 3088f04

File tree

9 files changed

+27
-18
lines changed

9 files changed

+27
-18
lines changed

bolt-aws-lambda/src/test/java/util/PortProvider.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public class PortProvider {
1111
private PortProvider() {
1212
}
1313

14+
private static final int MINIMUM = 1024;
1415
private static final SecureRandom RANDOM = new SecureRandom();
1516
private static final ConcurrentMap<String, Integer> PORTS = new ConcurrentHashMap<>();
1617

@@ -21,8 +22,8 @@ public static int getPort(String name) {
2122
private static int randomPort() {
2223
while (true) {
2324
int randomPort = RANDOM.nextInt(9999);
24-
if (randomPort < 1000) {
25-
randomPort += 1000;
25+
if (randomPort < MINIMUM) {
26+
randomPort += MINIMUM;
2627
}
2728
if (isAvailable(randomPort)) {
2829
return randomPort;

bolt-helidon/src/test/java/util/PortProvider.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public class PortProvider {
1111
private PortProvider() {
1212
}
1313

14+
private static final int MINIMUM = 1024;
1415
private static final SecureRandom RANDOM = new SecureRandom();
1516
private static final ConcurrentMap<String, Integer> PORTS = new ConcurrentHashMap<>();
1617

@@ -21,8 +22,8 @@ public static int getPort(String name) {
2122
private static int randomPort() {
2223
while (true) {
2324
int randomPort = RANDOM.nextInt(9999);
24-
if (randomPort < 1000) {
25-
randomPort += 1000;
25+
if (randomPort < MINIMUM) {
26+
randomPort += MINIMUM;
2627
}
2728
if (isAvailable(randomPort)) {
2829
return randomPort;

bolt-http4k/src/test/java/util/PortProvider.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public class PortProvider {
1111
private PortProvider() {
1212
}
1313

14+
private static final int MINIMUM = 1024;
1415
private static final SecureRandom RANDOM = new SecureRandom();
1516
private static final ConcurrentMap<String, Integer> PORTS = new ConcurrentHashMap<>();
1617

@@ -21,8 +22,8 @@ public static int getPort(String name) {
2122
private static int randomPort() {
2223
while (true) {
2324
int randomPort = RANDOM.nextInt(9999);
24-
if (randomPort < 1000) {
25-
randomPort += 1000;
25+
if (randomPort < MINIMUM) {
26+
randomPort += MINIMUM;
2627
}
2728
if (isAvailable(randomPort)) {
2829
return randomPort;

bolt-ktor/src/test/kotlin/util/PortProvider.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public class PortProvider {
1111
private PortProvider() {
1212
}
1313

14+
private static final int MINIMUM = 1024;
1415
private static final SecureRandom RANDOM = new SecureRandom();
1516
private static final ConcurrentMap<String, Integer> PORTS = new ConcurrentHashMap<>();
1617

@@ -21,8 +22,8 @@ public static int getPort(String name) {
2122
private static int randomPort() {
2223
while (true) {
2324
int randomPort = RANDOM.nextInt(9999);
24-
if (randomPort < 1000) {
25-
randomPort += 1000;
25+
if (randomPort < MINIMUM) {
26+
randomPort += MINIMUM;
2627
}
2728
if (isAvailable(randomPort)) {
2829
return randomPort;

bolt-micronaut/src/test/java/util/PortProvider.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public class PortProvider {
1111
private PortProvider() {
1212
}
1313

14+
private static final int MINIMUM = 1024;
1415
private static final SecureRandom RANDOM = new SecureRandom();
1516
private static final ConcurrentMap<String, Integer> PORTS = new ConcurrentHashMap<>();
1617

@@ -21,8 +22,8 @@ public static int getPort(String name) {
2122
private static int randomPort() {
2223
while (true) {
2324
int randomPort = RANDOM.nextInt(9999);
24-
if (randomPort < 1000) {
25-
randomPort += 1000;
25+
if (randomPort < MINIMUM) {
26+
randomPort += MINIMUM;
2627
}
2728
if (isAvailable(randomPort)) {
2829
return randomPort;

bolt-socket-mode/src/test/java/util/PortProvider.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public class PortProvider {
1111
private PortProvider() {
1212
}
1313

14+
private static final int MINIMUM = 1024;
1415
private static final SecureRandom RANDOM = new SecureRandom();
1516
private static final ConcurrentMap<String, Integer> PORTS = new ConcurrentHashMap<>();
1617

@@ -21,8 +22,8 @@ public static int getPort(String name) {
2122
private static int randomPort() {
2223
while (true) {
2324
int randomPort = RANDOM.nextInt(9999);
24-
if (randomPort < 1000) {
25-
randomPort += 1000;
25+
if (randomPort < MINIMUM) {
26+
randomPort += MINIMUM;
2627
}
2728
if (isAvailable(randomPort)) {
2829
return randomPort;

bolt/src/test/java/util/PortProvider.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public class PortProvider {
1111
private PortProvider() {
1212
}
1313

14+
private static final int MINIMUM = 1024;
1415
private static final SecureRandom RANDOM = new SecureRandom();
1516
private static final ConcurrentMap<String, Integer> PORTS = new ConcurrentHashMap<>();
1617

@@ -21,8 +22,8 @@ public static int getPort(String name) {
2122
private static int randomPort() {
2223
while (true) {
2324
int randomPort = RANDOM.nextInt(9999);
24-
if (randomPort < 1000) {
25-
randomPort += 1000;
25+
if (randomPort < MINIMUM) {
26+
randomPort += MINIMUM;
2627
}
2728
if (isAvailable(randomPort)) {
2829
return randomPort;

slack-api-client/src/test/java/util/PortProvider.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public class PortProvider {
1111
private PortProvider() {
1212
}
1313

14+
private static final int MINIMUM = 1024;
1415
private static final SecureRandom RANDOM = new SecureRandom();
1516
private static final ConcurrentMap<String, Integer> PORTS = new ConcurrentHashMap<>();
1617

@@ -21,8 +22,8 @@ public static int getPort(String name) {
2122
private static int randomPort() {
2223
while (true) {
2324
int randomPort = RANDOM.nextInt(9999);
24-
if (randomPort < 1000) {
25-
randomPort += 1000;
25+
if (randomPort < MINIMUM) {
26+
randomPort += MINIMUM;
2627
}
2728
if (isAvailable(randomPort)) {
2829
return randomPort;

slack-app-backend/src/test/java/util/PortProvider.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public class PortProvider {
1111
private PortProvider() {
1212
}
1313

14+
private static final int MINIMUM = 1024;
1415
private static final SecureRandom RANDOM = new SecureRandom();
1516
private static final ConcurrentMap<String, Integer> PORTS = new ConcurrentHashMap<>();
1617

@@ -21,8 +22,8 @@ public static int getPort(String name) {
2122
private static int randomPort() {
2223
while (true) {
2324
int randomPort = RANDOM.nextInt(9999);
24-
if (randomPort < 1000) {
25-
randomPort += 1000;
25+
if (randomPort < MINIMUM) {
26+
randomPort += MINIMUM;
2627
}
2728
if (isAvailable(randomPort)) {
2829
return randomPort;

0 commit comments

Comments
 (0)