mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-22 12:56:53 +00:00
Whitelist randomUUID in Painless (#45148)
This whitelists randomUUID with the understanding that it's possible for /dev/random to cause blocking on *nix systems. Users that need randomUUID should switch their random generator source to /dev/urandom if this is a concern for them.
This commit is contained in:
parent
00235bbecd
commit
54552edaf6
@ -1031,6 +1031,7 @@ class java.util.UUID {
|
||||
UUID fromString(String)
|
||||
long getLeastSignificantBits()
|
||||
long getMostSignificantBits()
|
||||
UUID randomUUID()
|
||||
UUID nameUUIDFromBytes(byte[])
|
||||
long node()
|
||||
long timestamp()
|
||||
|
@ -21,6 +21,7 @@ package org.elasticsearch.painless;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class BasicAPITests extends ScriptTestCase {
|
||||
|
||||
@ -149,4 +150,20 @@ public class BasicAPITests extends ScriptTestCase {
|
||||
"return ChronoUnit.MILLIS.between(d, t);"
|
||||
));
|
||||
}
|
||||
|
||||
public void testRandomUUID() {
|
||||
assertTrue(
|
||||
Pattern.compile("\\p{XDigit}{8}(-\\p{XDigit}{4}){3}-\\p{XDigit}{12}").matcher(
|
||||
(String)exec(
|
||||
"UUID a = UUID.randomUUID();" +
|
||||
"String s = a.toString(); " +
|
||||
"UUID b = UUID.fromString(s);" +
|
||||
"if (a.equals(b) == false) {" +
|
||||
" throw new RuntimeException('uuids did not match');" +
|
||||
"}" +
|
||||
"return s;"
|
||||
)
|
||||
).matches()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user