arangoml / fastgraphml

Given an input graph (ArangoDB or PyG) it generates graph embeddings using Low-Code framework built on top of PyG.
66 stars 7 forks source link

Bandit B101 - assert used #13

Closed cw00dw0rd closed 1 year ago

cw00dw0rd commented 1 year ago

Creating an issue to preserve conversation with @sachinsharma9780 regarding the Bandit security issue with the use of assert in non-test code.

Here is the error produced:

>> Issue: [B101:assert_used] Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
   Severity: Low   Confidence: High
   CWE: CWE-703 (https://cwe.mitre.org/data/definitions/703.html)
   Location: fastgraphml/graph_embeddings/downstream_tasks/similarity_search.py:64:8
   More Info: https://bandit.readthedocs.io/en/0.0.0/plugins/b101_assert_used.html
63          else:
64              assert (
65                  search_type == "exact" or search_type == "approx"
66              ), "pass search type either exact or approx"

Upon reading further into https://bandit.readthedocs.io/en/0.0.0/plugins/b101_assert_used.html as assert can be removed from code while compiling in some instances it seems reasonable to abide by the rule and replace assert with something else, in this case, perhaps an exception.

I can make the change and will close the issue unless we have any other reason to keep assert?