Skip to content

Commit

Permalink
Switch to SafeConstructor for YAML everywhere.
Browse files Browse the repository at this point in the history
  • Loading branch information
brendandburns committed Jan 28, 2023
1 parent 0670319 commit d4fe343
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.ArrayList;
import java.util.HashMap;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.SafeConstructor;

public class FilePersister implements ConfigPersister {
File configFile;
Expand Down Expand Up @@ -50,7 +51,7 @@ public void save(
// Note this is imperfect, should protect against other processes writing this file too...
synchronized (configFile) {
try (FileWriter fw = new FileWriter(configFile)) {
Yaml yaml = new Yaml();
Yaml yaml = new Yaml(new SafeConstructor());
yaml.dump(config, fw);
fw.flush();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
import io.kubernetes.client.openapi.JSON;
import java.util.Map;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.SafeConstructor;

public class Dynamics {

static final JSON internalJSONCodec = new JSON();
static final Yaml internalYamlCodec = new Yaml();
static final Yaml internalYamlCodec = new Yaml(new SafeConstructor());

public static DynamicKubernetesObject newFromJson(String jsonContent) {
return newFromJson(internalJSONCodec.getGson(), jsonContent);
Expand Down

0 comments on commit d4fe343

Please sign in to comment.