Skip to content

Commit 67e1bc4

Browse files
committed
use SafeConstructor in snakeyaml to fix CVE
1 parent 99f1fdd commit 67e1bc4

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/DeserializationUtils.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.fasterxml.jackson.databind.JsonNode;
44
import io.swagger.v3.core.util.Yaml;
55
import io.swagger.v3.core.util.Json;
6+
import org.yaml.snakeyaml.constructor.SafeConstructor;
67

78
import java.io.IOException;
89

@@ -57,12 +58,12 @@ private static boolean isJson(String contents) {
5758
}
5859

5960
public static JsonNode readYamlTree(String contents) {
60-
org.yaml.snakeyaml.Yaml yaml = new org.yaml.snakeyaml.Yaml();
61+
org.yaml.snakeyaml.Yaml yaml = new org.yaml.snakeyaml.Yaml(new SafeConstructor());
6162
return Json.mapper().convertValue(yaml.load(contents), JsonNode.class);
6263
}
6364

6465
public static <T> T readYamlValue(String contents, Class<T> expectedType) {
65-
org.yaml.snakeyaml.Yaml yaml = new org.yaml.snakeyaml.Yaml();
66+
org.yaml.snakeyaml.Yaml yaml = new org.yaml.snakeyaml.Yaml(new SafeConstructor());
6667
return Json.mapper().convertValue(yaml.load(contents), expectedType);
6768
}
6869
}

0 commit comments

Comments
 (0)