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

debug: collect message on a SessionNotAvailableException case #48794

Draft
wants to merge 1 commit into
base: stable28
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
// slash which is required by URL generation.
if (isset($_SERVER['REQUEST_URI']) && $_SERVER['REQUEST_URI'] === \OC::$WEBROOT &&
substr($_SERVER['REQUEST_URI'], -1) !== '/') {
header('Location: '.\OC::$WEBROOT.'/');

Check failure on line 204 in lib/base.php

View workflow job for this annotation

GitHub Actions / static-code-analysis-security

TaintedHeader

lib/base.php:204:12: TaintedHeader: Detected tainted header (see https://psalm.dev/256)
exit();
}
}
Expand Down Expand Up @@ -283,7 +283,7 @@
throw new Exception('Not installed');
} else {
$url = OC::$WEBROOT . '/index.php';
header('Location: ' . $url);

Check failure on line 286 in lib/base.php

View workflow job for this annotation

GitHub Actions / static-code-analysis-security

TaintedHeader

lib/base.php:286:12: TaintedHeader: Detected tainted header (see https://psalm.dev/256)
}
exit();
}
Expand Down Expand Up @@ -447,6 +447,8 @@

$cryptoWrapper = Server::get(\OC\Session\CryptoWrapper::class);
$session = $cryptoWrapper->wrapSession($session);
$e = new \Exception('Stacktrace for initializing Internal/Encrypted session');
\OCP\Log\logger('core')->warning('SnaeDebug: Updating UserSession with persistent Internal/Encrypted backend', [ 'exception' => $e ]);
self::$server->setSession($session);

// if session can't be started break with http 500 error
Expand Down
8 changes: 8 additions & 0 deletions lib/private/App/AppManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
use OC\AppConfig;
use OC\AppFramework\Bootstrap\Coordinator;
use OC\ServerNotAvailableException;
use OC\Session\CryptoSessionData;
use OCP\Activity\IManager as IActivityManager;
use OCP\App\AppPathNotFoundException;
use OCP\App\Events\AppDisableEvent;
Expand Down Expand Up @@ -210,6 +211,13 @@ public function loadApps(array $types = []): bool {
foreach ($apps as $app) {
if (!$this->isAppLoaded($app) && ($types === [] || $this->isType($app, $types))) {
try {
if (in_array('session', $types, true)) {
$e = new \Exception('Stacktrace for loading session-type app');
\OCP\Log\logger('core')->warning('SnaeDebug: Loading session app ' . $app, [ 'exception' => $e ]);
} else if (method_exists($this->userSession, 'getSession') && !$this->userSession->getSession() instanceof CryptoSessionData) {
$e = new \Exception('Stacktrace for early loading of non session-type app');
\OCP\Log\logger('core')->warning('SnaeDebug: Loading app early: ' . $app, [ 'exception' => $e, 'session' => get_class($this->userSession->getSession()) ]);
}
$this->loadApp($app);
} catch (\Throwable $e) {
$this->logger->emergency('Error during app loading: ' . $e->getMessage(), [
Expand Down
9 changes: 8 additions & 1 deletion lib/private/legacy/OC_User.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,14 @@ public static function loginWithApache(\OCP\Authentication\IApacheBackend $backe
'filesystem' => true,
]);
$tokenProvider->updateToken($token);
} catch (InvalidTokenException|WipeTokenException|SessionNotAvailableException) {
} catch (InvalidTokenException|WipeTokenException|SessionNotAvailableException $e) {
// swallow the exceptions as we do not deal with them here
// simply skip updating the token when is it missing
\OCP\Log\logger('core')->warning('SnaeDebug: Potential error case', [
'uid' => $uid,
'session_class' => get_class($userSession->getSession()),
'exception' => $e,
]);
}
}

Expand Down Expand Up @@ -255,6 +260,8 @@ public static function loginWithApache(\OCP\Authentication\IApacheBackend $backe
* null: not handled / no backend available
*/
public static function handleApacheAuth() {
$e = new \Exception('Stacktrace for invoking apache auth');
\OCP\Log\logger('core')->warning('SnaeDebug: ApacheAuth was invoked', [ 'exception' => $e ]);
$backend = self::findFirstActiveUsedBackend();
if ($backend) {
OC_App::loadApps();
Expand Down
Loading