Merge pull request elastic/elasticsearch#4380 from danielmitterdorfer/strict-booleans
This PR removes all leniency in the conversion of Strings to booleans: "true" is converted to the boolean value true, "false" is converted to the boolean value false. Everything else raises an error. Relates elastic/elasticsearchelastic/elasticsearch#22200 Original commit: elastic/x-pack-elasticsearch@a505df1f5d
This commit is contained in:
commit
6ed83cc8ea
|
@ -53,7 +53,7 @@ public class JiraAccount {
|
|||
try {
|
||||
URI uri = new URI(url);
|
||||
Scheme protocol = Scheme.parse(uri.getScheme());
|
||||
if ((protocol == Scheme.HTTP) && (Booleans.isExplicitTrue(settings.get(ALLOW_HTTP_SETTING)) == false)) {
|
||||
if ((protocol == Scheme.HTTP) && (Booleans.isTrue(settings.get(ALLOW_HTTP_SETTING)) == false)) {
|
||||
throw new SettingsException("invalid jira [" + name + "] account settings. unsecure scheme [" + protocol + "]");
|
||||
}
|
||||
this.url = uri;
|
||||
|
|
|
@ -628,11 +628,11 @@ public class Security implements ActionPlugin, IngestPlugin, NetworkPlugin {
|
|||
String errorMessage = LoggerMessageFormat.format("the [action.auto_create_index] setting value [{}] is too" +
|
||||
" restrictive. disable [action.auto_create_index] or set it to " +
|
||||
"[{}{}]", (Object) value, SecurityTemplateService.SECURITY_INDEX_NAME, auditIndex);
|
||||
if (Booleans.isExplicitFalse(value)) {
|
||||
if (Booleans.isFalse(value)) {
|
||||
throw new IllegalArgumentException(errorMessage);
|
||||
}
|
||||
|
||||
if (Booleans.isExplicitTrue(value)) {
|
||||
if (Booleans.isTrue(value)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -448,11 +448,11 @@ public class Watcher implements ActionPlugin, ScriptPlugin {
|
|||
String errorMessage = LoggerMessageFormat.format("the [action.auto_create_index] setting value [{}] is too" +
|
||||
" restrictive. disable [action.auto_create_index] or set it to " +
|
||||
"[{}, {}, {}*]", (Object) value, Watch.INDEX, TriggeredWatchStore.INDEX_NAME, HistoryStore.INDEX_PREFIX);
|
||||
if (Booleans.isExplicitFalse(value)) {
|
||||
if (Booleans.isFalse(value)) {
|
||||
throw new IllegalArgumentException(errorMessage);
|
||||
}
|
||||
|
||||
if (Booleans.isExplicitTrue(value)) {
|
||||
if (Booleans.isTrue(value)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -250,6 +250,18 @@ public class WatcherXContentParser implements XContentParser {
|
|||
return parser.booleanValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecated")
|
||||
public boolean isBooleanValueLenient() throws IOException {
|
||||
return parser.isBooleanValueLenient();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecated")
|
||||
public boolean booleanValueLenient() throws IOException {
|
||||
return parser.booleanValueLenient();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] binaryValue() throws IOException {
|
||||
return parser.binaryValue();
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
"filter" : {
|
||||
"email" : {
|
||||
"type" : "pattern_capture",
|
||||
"preserve_original" : 1,
|
||||
"preserve_original" : true,
|
||||
"patterns" : [
|
||||
"([^@]+)",
|
||||
"(\\p{L}+)",
|
||||
|
|
|
@ -116,7 +116,7 @@ public class SettingsFilterTests extends ESTestCase {
|
|||
}
|
||||
|
||||
private String randomBooleanSetting() {
|
||||
return randomFrom("true", "1", "on", "yes", "false", "0", "off", "no");
|
||||
return randomFrom("true", "false");
|
||||
}
|
||||
|
||||
private void configureUnfilteredSetting(String settingName, String value) {
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
"filter" : {
|
||||
"email" : {
|
||||
"type" : "pattern_capture",
|
||||
"preserve_original" : 1,
|
||||
"preserve_original" : true,
|
||||
"patterns" : [
|
||||
"([^@]+)",
|
||||
"(\\p{L}+)",
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
"filter" : {
|
||||
"email" : {
|
||||
"type" : "pattern_capture",
|
||||
"preserve_original" : 1,
|
||||
"preserve_original" : true,
|
||||
"patterns" : [
|
||||
"([^@]+)",
|
||||
"(\\p{L}+)",
|
||||
|
|
Loading…
Reference in New Issue