7
7
import com .akto .dao .test_editor .auth .Parser ;
8
8
import com .akto .dao .test_editor .filter .ConfigParser ;
9
9
import com .akto .dao .test_editor .info .InfoParser ;
10
+ import com .akto .dao .test_editor .settings .SettingsParser ;
10
11
import com .akto .dao .test_editor .strategy .StrategyParser ;
11
- import com .akto .dto .test_editor .Auth ;
12
- import com .akto .dto .test_editor .ConfigParserResult ;
13
- import com .akto .dto .test_editor .ExecutorConfigParserResult ;
14
- import com .akto .dto .test_editor .Info ;
15
- import com .akto .dto .test_editor .SeverityParserResult ;
16
- import com .akto .dto .test_editor .Strategy ;
17
- import com .akto .dto .test_editor .TestConfig ;
12
+ import com .akto .dto .test_editor .*;
18
13
import com .fasterxml .jackson .core .type .TypeReference ;
19
14
import com .fasterxml .jackson .databind .ObjectMapper ;
20
15
import com .fasterxml .jackson .dataformat .yaml .YAMLFactory ;
@@ -51,27 +46,37 @@ public static TestConfig parseConfig(Map<String, Object> config) throws Exceptio
51
46
return testConfig ;
52
47
}
53
48
49
+ Object settingsMap = config .get ("attributes" );
50
+ TemplateSettings attributes = null ;
51
+ if (settingsMap != null ) {
52
+ SettingsParser settingsParser = new SettingsParser ();
53
+ attributes = settingsParser .parse (settingsMap );
54
+ if (attributes == null ) {
55
+ return new TestConfig (id , info , null , null , null , null , null , null , null );
56
+ }
57
+ }
58
+
54
59
Object authMap = config .get ("auth" );
55
60
Auth auth = null ;
56
61
if (authMap != null ) {
57
62
Parser authParser = new Parser ();
58
63
auth = authParser .parse (authMap );
59
64
if (auth == null ) {
60
- return new TestConfig (id , info , null , null , null , null , null , null );
65
+ return new TestConfig (id , info , null , null , null , null , null , null , attributes );
61
66
}
62
67
}
63
68
64
69
Object filterMap = config .get ("api_selection_filters" );
65
70
if (filterMap == null ) {
66
71
// todo: should not be null, throw error
67
- return new TestConfig (id , info , auth , null , null , null , null , null );
72
+ return new TestConfig (id , info , auth , null , null , null , null , null , attributes );
68
73
}
69
74
70
75
ConfigParser configParser = new ConfigParser ();
71
76
ConfigParserResult filters = configParser .parse (filterMap );
72
77
if (filters == null ) {
73
78
// todo: throw error
74
- new TestConfig (id , info , auth , null , null , null , null , null );
79
+ new TestConfig (id , info , auth , null , null , null , null , null , attributes );
75
80
}
76
81
77
82
Map <String , List <String >> wordListMap = new HashMap <>();
@@ -80,32 +85,32 @@ public static TestConfig parseConfig(Map<String, Object> config) throws Exceptio
80
85
wordListMap = (Map ) config .get ("wordLists" );
81
86
}
82
87
} catch (Exception e ) {
83
- return new TestConfig (id , info , null , null , null , null , null , null );
88
+ return new TestConfig (id , info , null , null , null , null , null , null , attributes );
84
89
}
85
90
86
91
Object executionMap = config .get ("execute" );
87
92
if (executionMap == null ) {
88
93
// todo: should not be null, throw error
89
- return new TestConfig (id , info , auth , filters , wordListMap , null , null , null );
94
+ return new TestConfig (id , info , auth , filters , wordListMap , null , null , null , attributes );
90
95
}
91
96
92
97
com .akto .dao .test_editor .executor .ConfigParser executorConfigParser = new com .akto .dao .test_editor .executor .ConfigParser ();
93
98
ExecutorConfigParserResult executeOperations = executorConfigParser .parseConfigMap (executionMap );
94
99
if (executeOperations == null ) {
95
100
// todo: throw error
96
- new TestConfig (id , info , auth , filters , wordListMap , null , null , null );
101
+ new TestConfig (id , info , auth , filters , wordListMap , null , null , null , attributes );
97
102
}
98
103
99
104
Object validationMap = config .get ("validate" );
100
105
if (validationMap == null ) {
101
106
// todo: should not be null, throw error
102
- return new TestConfig (id , info , auth , filters , wordListMap , executeOperations , null , null );
107
+ return new TestConfig (id , info , auth , filters , wordListMap , executeOperations , null , null , attributes );
103
108
}
104
109
105
110
ConfigParserResult validations = configParser .parse (validationMap );
106
111
if (validations == null ) {
107
112
// todo: throw error
108
- new TestConfig (id , info , auth , filters , wordListMap , executeOperations , null , null );
113
+ new TestConfig (id , info , auth , filters , wordListMap , executeOperations , null , null , attributes );
109
114
}
110
115
111
116
List <Object > apiSeverityTemp = new ArrayList <>();
@@ -135,7 +140,7 @@ public static TestConfig parseConfig(Map<String, Object> config) throws Exceptio
135
140
strategy = strategyParser .parse (strategyObject );
136
141
}
137
142
138
- testConfig = new TestConfig (id , info , auth , filters , wordListMap , executeOperations , validations , strategy );
143
+ testConfig = new TestConfig (id , info , auth , filters , wordListMap , executeOperations , validations , strategy , attributes );
139
144
testConfig .setDynamicSeverityList (dynamicSeverityList );
140
145
return testConfig ;
141
146
}
0 commit comments