evilsocket / opensnitch

OpenSnitch is a GNU/Linux interactive application firewall inspired by Little Snitch.
GNU General Public License v3.0
9.86k stars 488 forks source link

UI does not update when removing rules #921

Closed 852Kerfunkle closed 8 months ago

852Kerfunkle commented 1 year ago

Describe the bug When removing rules in the UI, the list sometimes does not update after removal.

Include the following information:

To Reproduce Steps to reproduce the behavior:

  1. Open the UI
  2. Go to Rules
  3. Remove one rule, with the context menu or pressing del - the list might update the first time.
  4. Remove another rule, list doesn't update.

Navigating to another list and back forces it to update.

Thanks, especially for making this!

gustavo-iniguez-goya commented 1 year ago

Hi @852Kerfunkle ,

On Ubuntu 23 and Debian works as expected, I'll try to reproduce it on Fedora.

If you open an outbound connection (telnet 1.1.1.1, curl 1.1.1.1, etc), is the list of rules refreshed?

852Kerfunkle commented 1 year ago

Hey @gustavo-iniguez-goya,

yes, it does seem to refresh when making an outbount connection (at least when it adds a new rule).

Just when tried to reproduce it, at first, I wasn't able to, everything was working as it should.

But then, I navigate to the Events tab and back to Rules and it immediately stopped working again. Also, now the list does not update on outbound connections, whether it creates a new rule or not.

Hope this helps.

gustavo-iniguez-goya commented 1 year ago

thank you! I'll try to reproduce it.

gustavo-iniguez-goya commented 1 year ago

unfortunately @852Kerfunkle , no matter what I tried, it always seems to work for me.

The only thing that comes to my mind is to suggest that you launch it from a terminal, try to reproduce the issue, and observe if any errors are printed to the terminal when the GUI fails to update the list.

gustavo-iniguez-goya commented 1 year ago

well, taking a look at the code, when deleting a rule the list will only be refreshed when there's network activity.

Can you add a line to refresh the list when deleting a rule and see if the list is refreshed?

Bewlow _del_rule(): https://github.com/evilsocket/opensnitch/blob/c6decf1bad27b2dfa1c89800332322eb8eb21875/ui/opensnitch/dialogs/stats.py#L803-L806

This line: self._refresh_active_table()

852Kerfunkle commented 1 year ago

While you took a good look at the code, I was losing my mind a little about not being able to reproduce it again myself, looking at recent changes to the system, etc :sweat_smile:

This might very well be it. It will make the change locally and report back in a couple days/weeks if I still noticed it happening.

Thank you!

852Kerfunkle commented 1 year ago

Well, I somehow managed to get the UI into a state where the rule list does not update when new rules are added on outbound connections...

I was luckily running it from a terminal, she here's the log (which unfortunately is not helpful, at all):

Themes not available. Install qt-material if you want to change GUI's appearance: pip3 install qt-material.
     ~ OpenSnitch GUI - 1.6.0rc5 ~
    protobuf: 3.19.6 - grpc: 1.48.4
-------------------------------------------------- 

Loading translations: /usr/lib/python3/dist-packages/opensnitch/i18n locale: en_GB
Using server address: unix:///tmp/osui.sock
is new file, or IN MEMORY, setting initial schema version
setting schema version to: 2
setting schema version to: 2
schema version: 2
db schema is up to date
exception loading ipasn db: No module named 'pyasn'
Install python3-pyasn to display IP's network name.
new node connected, listening for client responses... /tmp/osui.sock
INFO: Manually refreshing table after deleting rule 'allow-always-list-usr-bin-ncat-xxx-xxx-xxx-xxx-xxx80'.
INFO: Manually refreshing table after deleting rule 'allow-always-list-usr-bin-ncat-xxx-xxx-xxx-xxx-xxx83'.
INFO: Manually refreshing table after deleting rule 'allow-always-list-usr-bin-ncat-xxx-xxx-xxx-xxx-xxx82'.

Added some logging to refreshing the list, so I can confirm it's working. The change is an improvement, as it definitely updates on removal now, but it's still possible to get into a state where it doesn't update on added rules.

852Kerfunkle commented 1 year ago

And, it somehow went back into a working state (list updating on added rules) while I typed the comment.

Could it be some kind of window focus related issue? Because all I did was tab out and tab back into the UI.

gustavo-iniguez-goya commented 1 year ago

mmh, maybe it's related to Wayland. Try launching the GUI as follow: $ QT_QPA_PLATFORM=xcb opensnitch-ui That will force to use X11 instead of Wayland.

Anyway, I've added the line to refresh the list.

852Kerfunkle commented 1 year ago

I'm using GNOME on xorg, I should probably have put that in the report.

gustavo-iniguez-goya commented 8 months ago

Hey, I think this issue have been fixed here: 177d67d0a6dc99b58abebb6080589f6e5385d708 . The fix will be availble on next release.

If you reproduced it with > v1.6.4 reopen the issue please, in order to investigate it again.