// Copyright 2022 Google LLC
//
// Licensed 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.
//
////////////////////////////////////////////////////////////////////////////////

import com.code_intelligence.jazzer.api.FuzzedDataProvider;

import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.SafeConstructor;
import org.yaml.snakeyaml.error.YAMLException;

public class YamlFuzzer {
  public static void fuzzerTestOneInput(FuzzedDataProvider data) {
    try{
      Yaml yaml = new Yaml(new SafeConstructor());
      yaml.load(data.consumeRemainingAsString());
    }
    catch (YAMLException | IllegalArgumentException e){
      return;
    }
  }
}

@@ -727,16 +727,57 @@
 vider;%0A%0A
+import org.yaml.snakeyaml.LoaderOptions;%0A
 import o
@@ -1003,18 +1003,243 @@
 %0A    try
+ 
 %7B%0A
+      LoaderOptions options = new LoaderOptions();%0A      options.setAllowDuplicateKeys(false);%0A      options.setMaxAliasesForCollections(5);%0A      options.setAllowRecursiveKeys(false);%0A      options.setNestingDepthLimit(3);%0A
       Ya
@@ -1277,16 +1277,23 @@
 tructor(
+options
 ));%0A    
@@ -1343,20 +1343,16 @@
 );%0A    %7D
-%0A   
  catch (
@@ -1394,16 +1394,17 @@
 ption e)
+ 
 %7B%0A      

Configure SnakeYAML (#8441)