magneticstain / Inquisition

An advanced and versatile open-source network anomaly detection platform
MIT License
8 stars 4 forks source link

Investigate Why Config Update Failure Still Returns True in Tuning API #127

Closed magneticstain closed 5 years ago

magneticstain commented 5 years ago

When a config update runs into the user case described in issue #126 , the API (via the web UI) still shows a success message: Request:

POST /api/v1/tuning/
't=cfg&s=state_tracking&k=enableHazyStateTracking&v=1

Response:

{"status":"success","data_source":"default","data":true}

Error Msg:

[Mon Nov 12 04:52:11.246437 2018] [:error] [pid 31578] [client 71.233.0.82:60582] PHP Warning:  file_put_contents(/opt/inquisition/conf/main.cfg): failed to open stream: Permission denied in /opt/inquisition/web/lib/Config.php on line 164
magneticstain commented 5 years ago

Additionally, once the permissions are "fixed", the following error is logged:

[Mon Nov 12 04:53:52.579226 2018] [:error] [pid 32228] [client 71.233.0.82:60596] [ SEV: CRIT ] :: could not find config file :: [ FILENAME: /opt/inquisition/conf/main.cfg ]
[Mon Nov 12 04:53:52.580155 2018] [:error] [pid 32228] [client 71.233.0.82:60596] PHP Fatal error:  Uncaught Exception: could not read configuration file in /opt/inquisition/web/lib/Config.php:21\nStack trace:\n#0 /opt/inquisition/web/api/v1/tuning/index.php(18): Config->__construct()\n#1 {main}\n  thrown in /opt/inquisition/web/lib/Config.php on line 21

This is on Debian 9 w/ Apache 2.4.

magneticstain commented 5 years ago

Reviewing the file permission log, I see it's a warning not an exception, which cannot be caught and handled within code. That should now be fixed via the install script, which is the best case we can offer here I think.