HenriWahl / Nagstamon

Nagios status monitor for your desktop.
https://nagstamon.de
Other
426 stars 179 forks source link

Setup invalid monitor url and 'cookies' -> fatal error, config lost #790

Open MilanDadok opened 2 years ago

MilanDadok commented 2 years ago

I found that changing in configuration dialog correct url of Icinga2Web (ie. from https://server/icingaweb2 to https://server/ for example) give fatal error and config file of server is lost from disk (3.8.0, 3.6.0 win64 installer)

Traceback (most recent call last):. File "Nagstamon\QUI__init__.py", line 4119, in get_status. File "Nagstamon\Servers\Generic.py", line 905, in GetStatus. File "Nagstamon\Servers\IcingaWeb2.py", line 100, in init_HTTP.AttributeError: 'NoneType' object has no attribute 'cookies' (it's from memory dump)

in Nagstamon/Servers/IcingaWeb2.py on line 99,100 there is if not self.no_cookie_auth: if len(self.session.cookies) == 0:

I thing that correct way in all servers implementation with cookies is if not self.no_cookie_auth: if 'cookies' not in dir(self.session) or len(self.session.cookies) == 0: or something like that

HenriWahl commented 2 years ago

Please check latest binaries from https://github.com/HenriWahl/Nagstamon/releases/tag/latest

MilanDadok commented 2 years ago

if self.session.get('cookies') and len(self.session.cookies) == 0: give me exception on every start (exe terminates silently)

Traceback (most recent call last): File "D:\InternetSources\nagstatmon\Nagstamon-master\Nagstamon\QUI__init__.py", line 4119, in get_status status = self.server.GetStatus() File "D:\InternetSources\nagstatmon\Nagstamon-master\Nagstamon\Servers\Generic.py", line 863, in GetStatus self.init_HTTP() File "D:\InternetSources\nagstatmon\Nagstamon-master\Nagstamon\Servers\IcingaWeb2.py", line 100, in init_HTTP if self.session.get('cookies') and len(self.session.cookies) == 0: File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\requests\sessions.py", line 555, in get return self.request('GET', url, **kwargs) File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\requests\sessions.py", line 528, in request prep = self.prepare_request(req) File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\requests\sessions.py", line 466, in prepare_request hooks=merge_hooks(request.hooks, self.hooks), File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\requests\models.py", line 316, in prepare self.prepare_url(url, params) File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\requests\models.py", line 390, in prepare_url raise MissingSchema(error) requests.exceptions.MissingSchema: Invalid URL 'cookies': No schema supplied. Perhaps you meant http://cookies?

next two version works for me as expected if 'cookies' not in dir(self.session) or len(self.session.cookies) == 0: if self.session == None or len(self.session.cookies) == 0: ie. invalid url -> authentication problem

HenriWahl commented 2 years ago

Can you create a pull request or show the exact lines you changed?

MilanDadok commented 2 years ago

always Nagstamon/Servers/IcingaWeb2.py line 100 for source file I'm using ZIP archive, for now I cannot create pull request ...

HenriWahl commented 2 years ago

Could you try the latest binary?

MilanDadok commented 2 years ago

Don't work, same exception self.session.get('cookies') - For me it looks like that function is trying to get content of uri 'cookies', not value of 'cookies' header of current http session ...

Traceback (most recent call last): File "D:\InternetSources\nagstatmon\Nagstamon-master\Nagstamon\QUI__init__.py", line 4119, in get_status status = self.server.GetStatus() File "D:\InternetSources\nagstatmon\Nagstamon-master\Nagstamon\Servers\Generic.py", line 863, in GetStatus self.init_HTTP() File "D:\InternetSources\nagstatmon\Nagstamon-master\Nagstamon\Servers\IcingaWeb2.py", line 100, in init_HTTP if not self.session.get('cookies') or len(self.session.cookies) == 0: File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\requests\sessions.py", line 555, in get return self.request('GET', url, **kwargs) File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\requests\sessions.py", line 528, in request prep = self.prepare_request(req) File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\requests\sessions.py", line 466, in prepare_request hooks=merge_hooks(request.hooks, self.hooks), File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\requests\models.py", line 316, in prepare self.prepare_url(url, params) File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\requests\models.py", line 390, in prepare_url raise MissingSchema(error) requests.exceptions.MissingSchema: Invalid URL 'cookies': No schema supplied. Perhaps you meant http://cookies?

HenriWahl commented 2 years ago

Stupid me... you are right. .get is an already existing method for HTTP-GET-requests... I changed to your proposal and currently the binaries are going to be built.

MilanDadok commented 2 years ago

From source files all works with python 3.6 from VS

But from exe- that is not runnable on Windows 8.1, Windows Server 2016, 2019 GetModuleHandleExW ( 0, "mscoree.dll", 0x000000c098c2f6f8 ) FALSE 126 0.0000068 After that ExitProcess(0) is called ...

Something is wrong with build ...

Milan Dadok

From: Henri Wahl @. Sent: Thursday, December 9, 2021 11:35 AM To: HenriWahl/Nagstamon @.> Cc: Dadok Milan @.>; Author @.> Subject: Re: [HenriWahl/Nagstamon] Setup invalid monitor url and 'cookies' -> fatal error, config lost (Issue #790)

Stupid me... you are right. .get is an already existing method for HTTP-GET-requests... I changed to your proposal and currently the binaries are going to be built.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/HenriWahl/Nagstamon/issues/790#issuecomment-989725262, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACRDTGFM4T6HEQZVS2ESOB3UQCA5PANCNFSM5JQW2NJA. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

Tento e-mail a informace v něm obsažené včetně přiložených příloh nejsou nabídkou na uzavření smlouvy či na změnu nebo zrušení již existujícího závazku, neboť tyto musejí být vždy provedeny písemnou formou, ledaže je výslovně v tomto e-mailu stanoveno nebo stranami písemně sjednáno jinak.

Tento e-mail a jeho případné přílohy mohou obsahovat důvěrné informace, které jsou určeny pouze příjemci, jehož jméno je zobrazeno v záhlaví textové části zprávy. Neoprávněné užití, zveřejnění, kopírování, šíření, úpravy a zpřístupnění obsahu této zprávy je zakázáno. Pokud Vám přišel tento e-mail omylem, informujte o tom prosím odesílatele a tuto zprávu, její přílohy a případné kopie neprodleně vymažte ze systému. Odesílatel neodpovídá za možné chyby, ztráty obsahu této zprávy či škody způsobené neúplným přenosem od odesílatele k adresátovi či adresátům.

This e-mail and information contained in this email including its attachments do not constitute an offer for the conclusion of a contract or for a change or cancellation of an existing obligation, as these must be always made in writing, unless this e-mail provides or the parties agree in writing otherwise.

This e-mail and its attachments may contain confidential information which is intended exclusively for its addressee(s), whose e-mail address(es) and name(s) are shown in the message heading. Any unauthorised use, publication, copying, dissemination, modifications or disclosure of the content of this message is prohibited. If you have received this e-mail by error, please inform the sender and delete this message, its attachments and copies, if any, from the system. The sender assumes no liability for any potential errors, lost content of this message or damage caused by the incomplete transmission from the sender to the addressee (s).

HenriWahl commented 2 years ago

Could you build the executable on such a machine?

HenriWahl commented 2 years ago

Any news?