jokob-sk / NetAlertX

🖧🔍 WIFI / LAN intruder detector. Scans for devices connected to your network and alerts you if new and unknown devices are found.
GNU General Public License v3.0
3.13k stars 187 forks source link

python 'cryptography' clash pip3 install vs server/cryptography #809

Closed ingoratsdorf closed 1 month ago

ingoratsdorf commented 2 months ago

Is there an existing issue for this?

Current Behavior

the current install script install the pypi cryptography module that seem to be clashing with the cryptography file in /app/server:

ImportError: cannot import name 'decrypt_data' from 'cryptography' (/myenv/lib/python3.12/site-packages/cryptogra> Sep 27 01:26:46 netalertx rc.local[676]: from cryptography import decrypt_data Sep 27 01:26:46 netalertx rc.local[676]: File "/app/server/plugin_utils.py", line 8, in Sep 27 01:26:46 netalertx rc.local[676]: from plugin_utils import getPluginObject Sep 27 01:26:46 netalertx rc.local[676]: File "/app/front/plugins/_publisher_mqtt/mqtt.py", line 26, in

Expected Behavior

No error

Steps To Reproduce

Use bare metal installer, run start script, watch logs and see above error.

If I remove cryptography and empty all python caches, all runs normal. The 'decrypt_data' procedure is not defined in the pip3 install, only in the handcrafted version in /app/server/cryptography.py

app.conf

No response

docker-compose.yml

N/A

What branch are you running?

Production

app.log

No response

Debug enabled

jokob-sk commented 2 months ago

Thansk @ingoratsdorf , just pushed a quick fix, renamed cryptography.py to crypto_utils.py - hope this solves it.

ingoratsdorf commented 2 months ago

That should solve it indeed. But from the looks, you don't seem to be needing cryptography anywhere?

jokob-sk commented 2 months ago

I'm using (as far as I remember lol) the library to encrypt and decrypt data for the SYNC plugin to communicate between 2 NetAlertX instances. Maybe I don't have to do it and there is an easier way - open to PRs/suggestions.

https://github.com/jokob-sk/NetAlertX/blob/6e36f7d7aa0435e07b7f1a846e7c24ba57734b94/front/plugins/sync/sync.py#L273

ingoratsdorf commented 2 months ago

Nah, I checked the source code and you are only using it in:

  1. \front\plugins\sync\sync.py as the /server/cryptography.py/encrypt_data
  2. \server\plugin_utils.py as the /server/cryptography.py/encrypt_data

The reference in \server\cryptography.py to fernet is commented out

Soooo, not in use ;-)

jokob-sk commented 2 months ago

Ha - true - thanks, removed :)