21
21
import org .opensearch .securityanalytics .rules .utils .Either ;
22
22
import org .opensearch .test .OpenSearchTestCase ;
23
23
import org .yaml .snakeyaml .Yaml ;
24
+ import org .yaml .snakeyaml .constructor .SafeConstructor ;
24
25
25
26
import java .util .Collections ;
26
27
import java .util .List ;
29
30
public class SigmaDetectionsTests extends OpenSearchTestCase {
30
31
31
32
public void testSigmaDetectionsFromDict () throws SigmaError {
32
- Yaml yaml = new Yaml ();
33
+ Yaml yaml = new Yaml (new SafeConstructor () );
33
34
Map <String , Object > detectionsMap = yaml .load (
34
35
" selection:\n " +
35
36
" EventID: 16\n " +
@@ -61,7 +62,7 @@ public void testSigmaDetectionsFromDict() throws SigmaError{
61
62
}
62
63
63
64
public void testSigmaDetectionsFromDictNoDetections () {
64
- Yaml yaml = new Yaml ();
65
+ Yaml yaml = new Yaml (new SafeConstructor () );
65
66
Map <String , Object > detectionsMap = yaml .load (
66
67
" condition: selection" );
67
68
Exception exception = assertThrows (SigmaDetectionError .class , () -> {
@@ -75,7 +76,7 @@ public void testSigmaDetectionsFromDictNoDetections() {
75
76
}
76
77
77
78
public void testSigmaDetectionsFromDictNoCondition () {
78
- Yaml yaml = new Yaml ();
79
+ Yaml yaml = new Yaml (new SafeConstructor () );
79
80
Map <String , Object > detectionsMap = yaml .load (
80
81
" selection:\n " +
81
82
" EventID: 16\n " +
@@ -93,7 +94,7 @@ public void testSigmaDetectionsFromDictNoCondition() {
93
94
}
94
95
95
96
public void testDetectionItemAllModifiedKeyPlainValuesPostProcess () throws SigmaError {
96
- Yaml yaml = new Yaml ();
97
+ Yaml yaml = new Yaml (new SafeConstructor () );
97
98
Map <String , Object > detectionsMap = yaml .load (
98
99
" selection:\n " +
99
100
" field|all: [\" val1\" , \" val2\" , 123]\n " +
@@ -111,7 +112,7 @@ public void testDetectionItemAllModifiedKeyPlainValuesPostProcess() throws Sigma
111
112
}
112
113
113
114
public void testDetectionItemAllModifiedUnboundPlainValuesPostProcess () throws SigmaError {
114
- Yaml yaml = new Yaml ();
115
+ Yaml yaml = new Yaml (new SafeConstructor () );
115
116
Map <String , Object > detectionsMap = yaml .load (
116
117
" selection:\n " +
117
118
" \" |all\" : [\" val1\" , \" val2\" , 123]\n " +
@@ -129,7 +130,7 @@ public void testDetectionItemAllModifiedUnboundPlainValuesPostProcess() throws S
129
130
}
130
131
131
132
public void testDetectionItemAllModifiedKeySpecialValuesPostProcess () throws SigmaError {
132
- Yaml yaml = new Yaml ();
133
+ Yaml yaml = new Yaml (new SafeConstructor () );
133
134
Map <String , Object > detectionsMap = yaml .load (
134
135
" selection:\n " +
135
136
" field|all: [\" val1*\" , \" val2\" , 123]\n " +
0 commit comments