Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,17 @@
<replacement>INVALID IMPORTS (GUAVA)</replacement>
</replaceRegex>
</format>
<!-- prevents empty SnakeYaml constructor -->
<format>
<includes>
<include>src/**/*.java</include>
</includes>
<replaceRegex>
<name>Forbids new Yaml()</name>
<searchRegex>^.*new Yaml\(\).*$</searchRegex>
<replacement>INVALID CONSTRUCTOR (SNAKEYAML)</replacement>
</replaceRegex>
</format>
</formats>
<java>
<removeUnusedImports /> <!-- self-explanatory -->
Expand Down
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