openappsec / waf-comparison-project

Testing datasets and tools to compare WAF efficacy
https://www.openappsec.io
Apache License 2.0
144 stars 24 forks source link

analyzer key mismatches #2

Closed acpeakhour closed 1 year ago

acpeakhour commented 1 year ago

When running analyzer.py, there are errors:

The columns in the _dff dataframe differ to what is referenced in the code:

Index(['WAF Name', 'FalsePositiveRate', 'FalseNegativeRate', 'TruePositiveRate', 'TruenegativeRate', 'BalancedAccuracy'], dtype='object')

Changing the code to match gives further errors in the plotly graph generation, they are referencing the incorrect names also:

File "/home/accassar/src/waf-comparison-project/analyzer.py", line 127, in analyze_results() File "/home/accassar/src/waf-comparison-project/analyzer.py", line 122, in analyze_results create_2d_graph(_dff) File "/home/accassar/src/waf-comparison-project/analyzer.py", line 87, in create_2d_graph fig = px.scatter( File "/home/accassar/src/waf-comparison-project/venv/lib/python3.9/site-packages/plotly/express/_chart_types.py", line 66, in scatter return make_figure(args=locals(), constructor=go.Scatter) File "/home/accassar/src/waf-comparison-project/venv/lib/python3.9/site-packages/plotly/express/_core.py", line 2003, in make_figure args = build_dataframe(args, constructor) File "/home/accassar/src/waf-comparison-project/venv/lib/python3.9/site-packages/plotly/express/_core.py", line 1412, in build_dataframe df_output, wide_id_vars = process_args_into_dataframe( File "/home/accassar/src/waf-comparison-project/venv/lib/python3.9/site-packages/plotly/express/_core.py", line 1208, in process_args_into_dataframe raise ValueError(err_msg) ValueError: Value of 'x' is not the name of a column in 'data_frame'. Expected one of ['WAF Name', 'FalsePositiveRate', 'FalseNegativeRate', 'TruePositiveRate', 'TruenegativeRate', 'BalancedAccuracy'] but received: True Negative Rate

python3 analyzer.py

Traceback (most recent call last): File "/home/accassar/src/waf-comparison-project/analyzer.py", line 126, in analyze_results() File "/home/accassar/src/waf-comparison-project/analyzer.py", line 116, in analyze_results create_graph(_dff, metric='False Positive Rate', is_ascending=False) File "/home/accassar/src/waf-comparison-project/analyzer.py", line 58, in create_graph _df_sorted = _df.sort_values(metric, ascending=is_ascending).copy() File "/home/accassar/src/waf-comparison-project/venv/lib/python3.9/site-packages/pandas/core/frame.py", line 6758, in sort_values k = self._get_label_or_level_values(by, axis=axis) File "/home/accassar/src/waf-comparison-project/venv/lib/python3.9/site-packages/pandas/core/generic.py", line 1778, in _get_label_or_level_values raise KeyError(key) KeyError: 'False Positive Rate'

Boris-Rozenfeld commented 1 year ago

Hi, @acpeakhour, thank you for noticing, this issue was already fixed in the following commit.

Please pull the the new version and run the analyzer again (running the whole runner is not necessary) with the command: python3 analyzer.py