Test Setup Failed
Push — master ( 72cf12...6f7bb7 )
by
unknown
12:37 queued 14s
created

server.php (1 issue)

Severity
1
<?php
2
/*
3
 * SPDX-License-Identifier: AGPL-3.0-only
4
 * SPDX-FileCopyrightText: Copyright 2016 - 2018 Kopano b.v.
5
 * SPDX-FileCopyrightText: Copyright 2020-2024 grommunio GmbH
6
 *
7
 * This is the entry point through which all requests are processed.
8
 */
9
10
namespace grommunio\DAV;
11
12
use Sabre\CalDAV\CalendarRoot;
13
use Sabre\CalDAV\ICSExportPlugin;
14
use Sabre\CardDAV\AddressBookRoot;
15
use Sabre\CardDAV\Plugin;
16
use Sabre\DAV\Server;
17
use Sabre\DAV\Version;
18
use Sabre\DAVACL\PrincipalCollection;
19
20
// require composer auto-loader
21
require __DIR__ . '/vendor/autoload.php';
22
23
// Configure & create main logger
24
GLogger::configure(__DIR__ . '/glogger.ini');
25
$logger = new GLogger('main');
26
27
// don't log any Sabre asset requests (images etc)
28
if (isset($_REQUEST['sabreAction']) && $_REQUEST['sabreAction'] == 'asset') {
29
	$logger->resetConfiguration();
30
}
31
32
// log the start data
33
$logger->debug('------------------ Start');
34
$logger->debug('%s %s', $_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI']);
35
$logger->debug('grommunio-dav version %s', GDAV_VERSION);
36
$logger->debug('SabreDAV version %s', Version::VERSION);
37
38
$gdavBackend = new GrommunioDavBackend(new GLogger('dav'));
39
$authBackend = new AuthBasicBackend($gdavBackend);
40
$authBackend->setRealm(SABRE_AUTH_REALM);
41
$principalBackend = new PrincipalsBackend($gdavBackend);
42
$gCarddavBackend = new GrommunioCardDavBackend($gdavBackend, new GLogger('card'));
43
$gCaldavBackend = new GrommunioCalDavBackend($gdavBackend, new GLogger('cal'));
44
45
// Setting up the directory tree
46
$nodes = [
47
	new PrincipalCollection($principalBackend),
48
	new AddressBookRoot($principalBackend, $gCarddavBackend),
49
	new CalendarRoot($principalBackend, $gCaldavBackend),
50
];
51
52
// initialize the server
53
$server = new Server($nodes);
54
$server->setBaseUri(DAV_ROOT_URI);
55
$server->setLogger($logger->getGPSR3Logger());
56
57
$authPlugin = new \Sabre\DAV\Auth\Plugin($authBackend, SABRE_AUTH_REALM);
0 ignored issues
show
The call to Sabre\DAV\Auth\Plugin::__construct() has too many arguments starting with grommunio\DAV\SABRE_AUTH_REALM. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

57
$authPlugin = /** @scrutinizer ignore-call */ new \Sabre\DAV\Auth\Plugin($authBackend, SABRE_AUTH_REALM);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
58
$server->addPlugin($authPlugin);
59
60
// add our version to the headers
61
$server->httpResponse->addHeader('X-GDAV-Version', GDAV_VERSION);
62
63
// log the incoming request (only if authenticated)
64
$logger->LogIncoming($server->httpRequest);
65
66
$aclPlugin = new DAVACL();
67
$aclPlugin->allowUnauthenticatedAccess = false;
68
$server->addPlugin($aclPlugin);
69
70
$schedulePlugin = new GrommunioSchedulePlugin($gdavBackend, new GLogger('schedule'));
71
$server->addPlugin($schedulePlugin);
72
73
$imipPlugin = new GrommunioIMipPlugin($gdavBackend, new GLogger('imip'));
74
$server->addPlugin($imipPlugin);
75
76
$server->addPlugin(new ICSExportPlugin());
77
$server->addPlugin(new \Sabre\CardDAV\Plugin());
78
79
// TODO: do we need $caldavPlugin for anything?
80
$caldavPlugin = new \Sabre\CalDAV\Plugin();
81
$server->addPlugin($caldavPlugin);
82
83
if (strlen(SYNC_DB) > 0) {
84
	$server->addPlugin(new \Sabre\DAV\Sync\Plugin());
85
}
86
87
if (DEVELOPER_MODE) {
88
	$server->addPlugin(new \Sabre\DAV\Browser\Plugin(false));
89
}
90
91
$server->start();
92
93
// Log outgoing data
94
$logger->LogOutgoing($server->httpResponse);
95
96
$logger->debug(
97
	"httpcode='%s' memory='%s/%s' time='%ss'",
98
	http_response_code(),
99
	$logger->FormatBytes(memory_get_peak_usage(false)),
100
	$logger->FormatBytes(memory_get_peak_usage(true)),
101
	number_format(microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"], 2)
102
);
103
$logger->debug('------------------ End');
104