Akash3121 commented on code in PR #938: URL: https://github.com/apache/incubator-xtable/pull/938#discussion_r4052353164
########## xtable-utilities/src/main/java/org/apache/xtable/utilities/StrictBooleanStringDeserializer.java: ########## @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.xtable.utilities; + +import java.io.IOException; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; + +/** Deserializes only the literal value {@code true} as enabled. */ +public class StrictBooleanStringDeserializer extends StdDeserializer<String> { + + public StrictBooleanStringDeserializer() { + super(String.class); + } + + @Override + public String deserialize(JsonParser parser, DeserializationContext context) throws IOException { + if (parser.currentToken() == JsonToken.VALUE_NULL) { + return null; + } + return Boolean.toString(Boolean.TRUE.toString().equalsIgnoreCase(parser.getText())); Review Comment: Fixed by making the existing field-level deserializer strict. It now accepts only case-insensitive true or false, canonicalizes the value, and throws InvalidFormatException for values such as ture, yes, on, and 1; the resulting error path identifies allowUnsupportedDeletionVectors. I retained the custom deserializer because the currently pinned Jackson YAML stack coerces yes , on , and numeric 1 to true for a plain Boolean , which could accidentally enable this unsafe override. Added focused coverage for both utility configuration formats, including valid, invalid, missing, and null values. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
