Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Too verbose logs when model not found #793

Open
leolivier opened this issue Apr 23, 2023 · 1 comment · May be fixed by #869
Open

Too verbose logs when model not found #793

leolivier opened this issue Apr 23, 2023 · 1 comment · May be fixed by #869
Labels
2. developing enhancement New feature or request good first issue Good for newcomers

Comments

@leolivier
Copy link

Hi
For any PROPFIND and REPORT request (for CalDav/CardDav), I get some warnings like this:

{"reqId":"Ra8Dv8pIEVFztLxllaLX","level":2,"time":"2023-04-23T11:54:41+02:00","remoteAddr":"192.168.1.254","user":"olivier","app":"suspicious_login","method":"PROPFIND","url":"/remote.php/dav/principals/users/olivier/","message":"Could not predict suspiciousness: No models found","userAgent":"Thunderbird CalDAV/CardDAV","version":"26.0.1.1","data":{"app":"suspicious_login"}}

This is bloating the logs for nothing.
I tried $ occ suspiciouslogin:predict olivier 192.168.1.254 but got:

In ModelStore.php line 93:

  No models found

In QBMapper.php line 284:

  Did expect one result but found none when executing: query "SELECT * FROM `*PREFIX*suspicious_login_model` WHERE `address_type` = :dcValue1 ORDER BY `created_at` desc LIMIT 1";

suspiciouslogin:predict [--v6] [--] <uid> <ip> [<model>]

in my config.php, the trusted_proxies is defined to

  'trusted_proxies' =>
  array (
    0 => '192.168.1.254',
    1 => '192.168.1.8',
  ),

the proxy settings in Apache is:

  ProxyPass "/.well-known/carddav" "${NCInternalURI}/remote.php/dav"
  ProxyPass "/.well-known/caldav" "${NCInternalURI}/remote.php/dav"
  ProxyPass "/.well-known/webfinger" "${NCInternalURI}/index.php/.well-known/webfinger"
  ProxyPass "/.well-known/nodeinfo" "${NCInternalURI}/index.php/.well-known/nodeinfo"

I think this configuration is ok.
So, is there a way to remove these unnecessary logs?

@joshtrichards joshtrichards added the enhancement New feature or request label Feb 15, 2024
@joshtrichards
Copy link
Member

Looks like we are kinda-sorta double logging it too (depending on local loglevel:

} catch (DoesNotExistException $e) {
$this->logger->debug("No models found. Can't load latest");
throw new ServiceException("No models found", 0, $e);
}

The issue is we're overloading the use of ServiceException probably a bit I guess:

} catch (ServiceException $ex) {
$this->logger->warning("Could not predict suspiciousness: " . $ex->getMessage());
// This most likely means there is no trained model yet, so we return early here
return;
}

public function predict(string $uid, string $ip, AClassificationStrategy $strategy, int $modelId = null): bool {
try {
if ($modelId === null) {
$this->logger->debug("loading latest model");
$estimator = $this->modelStore->loadLatest($strategy);
} else {
$this->logger->debug("loading model $modelId");
$estimator = $this->modelStore->load($modelId);
}
} catch (RuntimeException $e) {
throw new ServiceException("Could not load model $modelId to classify UID $uid and IP $ip: " . $e->getMessage(), $e->getCode(), $e);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2. developing enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants