@@ -182,12 +182,13 @@ class BaskervilleConfig(Config):
182182 - kafka : optional - depends on the chosen pipeline
183183
184184 """
185- database = None
186- elastic = None
187- misp = None
188- engine = None
189- kafka = None
190- spark = None
185+ database : 'DatabaseConfig' = None
186+ elastic : 'ElasticConfig' = None
187+ misp : 'MispConfig' = None
188+ engine : 'EngineConfig' = None
189+ kafka : 'KafkaConfig' = None
190+ spark : 'SparkConfig' = None
191+ user_details : 'UserDetailsConfig' = None
191192
192193 def __init__ (self , config ):
193194 super (BaskervilleConfig , self ).__init__ (config )
@@ -203,6 +204,8 @@ def __init__(self, config):
203204 self .kafka = KafkaConfig (self .kafka )
204205 if self .spark :
205206 self .spark = SparkConfig (self .spark )
207+ if self .user_details :
208+ self .user_details = UserDetailsConfig (self .user_details )
206209
207210 def validate (self ):
208211 logger .debug ('Validating BaskervilleConfig...' )
@@ -226,6 +229,10 @@ def validate(self):
226229 self .spark .validate ()
227230 else :
228231 logger .debug ('No spark config' )
232+ if self .user_details :
233+ self .user_details .validate ()
234+ else :
235+ logger .error ('No user_details config' )
229236
230237 self ._is_validated = True
231238 self ._is_valid = len (self .errors ) == 0
@@ -961,9 +968,6 @@ class DataParsingConfig(Config):
961968 group_by_cols = ('client_request_host' , 'client_ip' )
962969 timestamp_column = '@timestamp'
963970
964- def __init__ (self , config_dict ):
965- super ().__init__ (config_dict )
966-
967971 def validate (self ):
968972 logger .debug ('Validating DataParsingConfig...' )
969973 from baskerville .models .log_parsers import LOG_PARSERS
@@ -994,3 +998,31 @@ def validate(self):
994998
995999 self ._is_validated = True
9961000 return self
1001+
1002+
1003+ class UserDetailsConfig (Config ):
1004+ username = ''
1005+ password = ''
1006+ organization_uuid = ''
1007+
1008+ def validate (self ):
1009+ logger .debug ('Validating UserDetailsConfig...' )
1010+ if not self .username :
1011+ self .add_error (ConfigError (
1012+ f'Please, provide a username' ,
1013+ ['username' ],
1014+ exception_type = ValueError
1015+ ))
1016+ if not self .password :
1017+ self .add_error (ConfigError (
1018+ f'Please, provide a password' ,
1019+ ['password' ],
1020+ exception_type = ValueError
1021+ ))
1022+ if not self .organization_uuid :
1023+ self .add_error (ConfigError (
1024+ f'Please, provide an organization_uuid' ,
1025+ ['organization_uuid' ],
1026+ exception_type = ValueError
1027+ ))
1028+
0 commit comments