deltachat / mailadm

mail account administration tool for temporary and other account creation/modification
https://mailadm.readthedocs.io/
Mozilla Public License 2.0
15 stars 1 forks source link

ValueError if someone writes to admin group without being part of the admin group from the bot's perspective #68

Open missytake opened 1 year ago

missytake commented 1 year ago

expected behavior:

if the bot missed a vg-member-added message, and the member who the bot doesn't recognize writes to the group, it should complain with a message like "I don't see as part of the group - please re-add them if they can be trusted."

actual behavior:

If the bot missed a vg-member-added message, and the added member writes to the admin group, the bot crashes:

176651.47 [events-bot] DC_EVENT_INFO data1=0 data2=src/imap/idle.rs:76: INBOX: Idle-wait timeout or interruption                                                                                                                             
176651.47 [events-bot] DC_EVENT_INFO data1=0 data2=src/job.rs:350: loading job                                                                                                                                                               
176651.48 [events-bot] DC_EVENT_INFO data1=0 data2=src/imap.rs:905: 0 mails read from "INBOX".                                                                                                                                               
176651.48 [events-bot] DC_EVENT_INCOMING_MSG_BUNCH data1=0 data2=0                                                                                                                                                                           
176651.48 [events-bot] DC_EVENT_INFO data1=0 data2=src/imap/scan_folders.rs:28: Starting full folder scan                                                                                                                                    
176651.55 [events-bot] DC_EVENT_CONNECTIVITY_CHANGED data1=0 data2=0                                                                                                                                                                         
176651.56 [events-bot] DC_EVENT_INFO data1=0 data2=src/receive_imf.rs:99: Receiving message, seen=false...                                                                                                                                   
176651.60 [events-bot] DC_EVENT_INFO data1=0 data2=src/decrypt.rs:46: Detected Autocrypt-mime message                                                                                                                                        
176651.61 [events-bot] DC_EVENT_WARNING data1=0 data2=src/mimeparser.rs:311: decryption failed: missing key                                                                                                                                  
176651.61 [events-bot] DC_EVENT_INFO data1=0 data2=src/receive_imf.rs:121: received message has Message-Id: Gr.6_j3n9_tr34.3pZxpwJ8yot@testrun.org                                                                                           
176651.62 [events-bot] DC_EVENT_INFO data1=0 data2=src/receive_imf.rs:1375: Assigning message to Chat#15 as it's a reply to Gr.6_j3n9_tr34.FKSpWFm2w59@example.org                                                                        
176651.62 [events-bot] DC_EVENT_WARNING data1=0 data2=src/receive_imf.rs:974: verification problem: This message is not encrypted.                                                                                                           
176651.63 [events-bot] DC_EVENT_INFO data1=0 data2=src/receive_imf.rs:1217: Message has 1 parts and is assigned to chat #Chat#15.                                                                                                            
176651.65 [events-bot] DC_EVENT_INFO data1=0 data2=src/contact.rs:1518: Recently seen loop waiting for 0h 5m 36s or interupt                                                                                                                 
176651.65 [events-bot] DC_EVENT_INCOMING_MSG data1=15 data2=51                                                                                                                                                                               
process_incoming message: [This message is not encrypted.. See 'Info' for more details]                                                                                                                                                      
The admin group is broken. Try `mailadm setup-bot`. Group ID: 15                                                                                                                                                                             
176651.69 [events-bot] call ac_incoming_message kwargs={'message': <Message incoming sys=False '[This mess' id=51 sender=10/tmp.ek4ap@testrun.org chat=15/Admin group on example.org>} failed                                             
Exception                                                                                                                                                                                                                                    
Traceback:                                                                                                                                                                                                                                   
Traceback (most recent call last):                                                                                                                                                                                                           
  File "/usr/lib/python3.9/site-packages/deltachat/events.py", line 268, in swallow_and_log_exception                                                                                                                                        
    yield                                                                                                                                                                                                                                    
  File "/usr/lib/python3.9/site-packages/deltachat/events.py", line 263, in _inner_run                                                                                                                                                       
    hook(**kwargs)                                                                                                                                                                                                                           
  File "/usr/lib/python3.9/site-packages/pluggy/_hooks.py", line 265, in __call__                                                                                                                                                            
    return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)                                                                                                                                                              
  File "/usr/lib/python3.9/site-packages/pluggy/_manager.py", line 80, in _hookexec                                                                                                                                                          
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)                                                                                                                                                                     
  File "/usr/lib/python3.9/site-packages/pluggy/_callers.py", line 60, in _multicall                                                                                                                                                         
    return outcome.get_result()                                                                                                                                                                                                              
  File "/usr/lib/python3.9/site-packages/pluggy/_result.py", line 60, in get_result                                                                                                                                                          
    raise ex[1].with_traceback(ex[2])                                                                                                                                                                                                        
  File "/usr/lib/python3.9/site-packages/pluggy/_callers.py", line 39, in _multicall                                                                                                                                                         
    res = hook_impl.function(*args)                                                                                                                                                                                                          
  File "/usr/lib/python3.9/site-packages/mailadm/bot.py", line 46, in ac_incoming_message                                                                                                                                                    
    if not self.is_admin_group_message(message):                                                                                                                                                                                             
  File "/usr/lib/python3.9/site-packages/mailadm/bot.py", line 146, in is_admin_group_message                                                                                                                                                
    raise ValueError                                                                                                                                                                                                                         
ValueError                                                                                                                                                                                                                                   
link2xt commented 1 year ago

I think proper solution for this should start with removing raise ValueError. The bot should not crash (together with a web server by the way) due to encryption problems.