File tree Expand file tree Collapse file tree 3 files changed +15
-2
lines changed
util/src/main/java/io/kubernetes/client/util Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Original file line number Diff line number Diff line change 470
470
<replacement >INVALID IMPORTS (GUAVA)</replacement >
471
471
</replaceRegex >
472
472
</format >
473
+ <!-- prevents empty SnakeYaml constructor -->
474
+ <format >
475
+ <includes >
476
+ <include >src/**/*.java</include >
477
+ </includes >
478
+ <replaceRegex >
479
+ <name >Forbids new Yaml()</name >
480
+ <searchRegex >^.*new Yaml\(\).*$</searchRegex >
481
+ <replacement >INVALID CONSTRUCTOR (SNAKEYAML)</replacement >
482
+ </replaceRegex >
483
+ </format >
473
484
</formats >
474
485
<java >
475
486
<removeUnusedImports /> <!-- self-explanatory -->
Original file line number Diff line number Diff line change 18
18
import java .util .ArrayList ;
19
19
import java .util .HashMap ;
20
20
import org .yaml .snakeyaml .Yaml ;
21
+ import org .yaml .snakeyaml .constructor .SafeConstructor ;
21
22
22
23
public class FilePersister implements ConfigPersister {
23
24
File configFile ;
@@ -50,7 +51,7 @@ public void save(
50
51
// Note this is imperfect, should protect against other processes writing this file too...
51
52
synchronized (configFile ) {
52
53
try (FileWriter fw = new FileWriter (configFile )) {
53
- Yaml yaml = new Yaml ();
54
+ Yaml yaml = new Yaml (new SafeConstructor () );
54
55
yaml .dump (config , fw );
55
56
fw .flush ();
56
57
}
Original file line number Diff line number Diff line change 17
17
import io .kubernetes .client .openapi .JSON ;
18
18
import java .util .Map ;
19
19
import org .yaml .snakeyaml .Yaml ;
20
+ import org .yaml .snakeyaml .constructor .SafeConstructor ;
20
21
21
22
public class Dynamics {
22
23
23
24
static final JSON internalJSONCodec = new JSON ();
24
- static final Yaml internalYamlCodec = new Yaml ();
25
+ static final Yaml internalYamlCodec = new Yaml (new SafeConstructor () );
25
26
26
27
public static DynamicKubernetesObject newFromJson (String jsonContent ) {
27
28
return newFromJson (internalJSONCodec .getGson (), jsonContent );
You can’t perform that action at this time.
0 commit comments