Skip to content

Commit d0c9842

Browse files
authored
Fix for the empty white list in the configuration (#57)
1 parent 959cbcc commit d0c9842

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/baskerville/models/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ class EngineConfig(Config):
270270
sliding_window = 360
271271
low_rate_attack_period = [600, 3600]
272272
low_rate_attack_total_request = [400, 2000]
273-
white_list = []
273+
white_list = None
274274

275275
def __init__(self, config, parent=None):
276276
super(EngineConfig, self).__init__(config, parent)

src/baskerville/models/pipeline_tasks/tasks.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,8 +1254,9 @@ def __init__(self, config, steps=()):
12541254

12551255
def initialize(self):
12561256
# super(SaveStats, self).initialize()
1257-
self.df_white_list = self.spark.createDataFrame(
1258-
[[ip] for ip in self.config.engine.white_list], ['ip']).withColumn('white_list', F.lit(1))
1257+
if self.config.engine.white_list:
1258+
self.df_white_list = self.spark.createDataFrame([[ip] for ip in self.config.engine.white_list],
1259+
['ip']).withColumn('white_list', F.lit(1))
12591260

12601261
def classify_anomalies(self):
12611262
self.logger.info('Anomaly thresholding...')
@@ -1327,6 +1328,8 @@ def detect_low_rate_attack(self, df):
13271328
return df
13281329

13291330
def apply_white_list(self, df):
1331+
if not self.df_white_list:
1332+
return df
13301333
df = df.join(self.df_white_list, on='ip', how='left')
13311334
white_listed = df.where((F.col('white_list') == 1) & (F.col('prediction') == 1))
13321335
if white_listed.count() > 0:

0 commit comments

Comments
 (0)