Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduced protections against predictable RNG abuse #18

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

package org.elasticsearch.gradle.internal.util.ports;

import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand All @@ -28,7 +29,7 @@ public class ReservedPortRange {
public ReservedPortRange(int startPort, int endPort) {
this.startPort = startPort;
this.endPort = endPort;
current = startPort + new Random().nextInt(endPort - startPort);
current = startPort + new SecureRandom().nextInt(endPort - startPort);
}

public List<Integer> getAllocated() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

package org.elasticsearch.tdigest;

import java.security.SecureRandom;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
Expand All @@ -29,7 +30,7 @@
import static org.elasticsearch.tdigest.IntAVLTree.NIL;

public class AVLTreeDigest extends AbstractTDigest {
final Random gen = new Random();
final Random gen = new SecureRandom();
private final double compression;
private AVLGroupTree summary;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@

package org.elasticsearch.tdigest;

import java.security.SecureRandom;
import java.util.Arrays;
import java.util.Random;

/**
* Static sorting methods
*/
public class Sort {
private static final Random prng = new Random(); // for choosing pivots during quicksort
private static final Random prng = new SecureRandom(); // for choosing pivots during quicksort

/**
* Single-key stabilized quick sort on using an index array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package org.elasticsearch.xpack.sql.expression.function.scalar.datetime;

import com.carrotsearch.randomizedtesting.generators.RandomNumbers;
import java.security.SecureRandom;

import org.elasticsearch.core.PathUtils;
import org.elasticsearch.core.SuppressForbidden;
Expand Down Expand Up @@ -51,7 +52,7 @@ private static class TestRecord {

@SuppressForbidden(reason = "It is ok to use Random outside of an actual test")
private static Random rnd() {
return new Random();
return new SecureRandom();
}

public static void main(String[] args) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package org.elasticsearch.xpack.sql.expression.function.scalar.datetime;

import com.carrotsearch.randomizedtesting.generators.RandomNumbers;
import java.security.SecureRandom;

import org.elasticsearch.common.util.set.Sets;
import org.elasticsearch.core.PathUtils;
Expand Down Expand Up @@ -241,7 +242,7 @@ private String unitTestExporterScript() {

@SuppressForbidden(reason = "It is ok to use Random outside of an actual test")
private static Random rnd() {
return new Random();
return new SecureRandom();
}

public static void main(String[] args) throws Exception {
Expand Down
Loading