Ariadne-CMS /
ariadne
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | require_once("HTTP/WebDAV/Server.php"); |
||
| 3 | |||
| 4 | class Ariadne_WebDAV_Server extends HTTP_WebDAV_Server { |
||
| 5 | |||
| 6 | public function __construct( &$store, $config ) { |
||
| 7 | global $ariadne; |
||
| 8 | debug("webdav: initting server"); |
||
| 9 | parent::__construct(); |
||
| 10 | $this->store = $store; |
||
| 11 | $this->config = $config; |
||
| 12 | $this->root = &$config['root']; |
||
| 13 | debug("webdav: loading modules"); |
||
| 14 | |||
| 15 | $this->modules = array(); |
||
| 16 | include_once($ariadne."/modules/mod_webdav/files.php"); |
||
| 17 | $this->modules['files'] = new WebDAV_files($this); |
||
| 18 | |||
| 19 | debug("webdav: init done"); |
||
| 20 | } |
||
| 21 | |||
| 22 | View Code Duplication | function path_unescape($path) { |
|
| 23 | $result = ""; |
||
| 24 | if ($path) { |
||
| 25 | debug("webdav: escaped path: $path"); |
||
| 26 | $result = preg_replace_callback( |
||
| 27 | '/(_[0-9a-fA-F][0-9a-fA-F]|__)/', |
||
| 28 | function ( $matches ) { |
||
| 29 | // Two types of escaped characters can be here, the |
||
| 30 | // underscore or other characters. Check for the |
||
| 31 | // underscore first. |
||
| 32 | |||
| 33 | $char = $matches[0]; |
||
| 34 | if ($char[1] == "_") { |
||
| 35 | // It is the underscore, return it as a character. |
||
| 36 | return "_"; |
||
| 37 | } |
||
| 38 | |||
| 39 | // Assume it is an escaped character here. Find the |
||
| 40 | // numbers in hex, turn them back to decimal, get |
||
| 41 | // the corresponding character and return it. |
||
| 42 | |||
| 43 | return chr(hexdec(substr($char, 1, 2))); |
||
| 44 | }, |
||
| 45 | $path |
||
| 46 | ); |
||
| 47 | } |
||
| 48 | debug("webdav: unescaped path: $result"); |
||
| 49 | return $result; |
||
| 50 | } |
||
| 51 | |||
| 52 | public static function path_unescape_callback($char) { |
||
| 53 | // Two types of escaped characters can be here, the |
||
| 54 | // underscore or other characters. Check for the |
||
| 55 | // underscore first. |
||
| 56 | |||
| 57 | if ($char[1] == "_") { |
||
| 58 | // It is the underscore, return it as a character. |
||
| 59 | return "_"; |
||
| 60 | } |
||
| 61 | |||
| 62 | // Assume it is an escaped character here. Find the |
||
| 63 | // numbers in hex, turn them back to decimal, get |
||
| 64 | // the corresponding character and return it. |
||
| 65 | |||
| 66 | return chr(hexdec(substr($char, 1, 2))); |
||
| 67 | } |
||
| 68 | |||
| 69 | public function check_auth($type, $user, $pass) { |
||
|
0 ignored issues
–
show
|
|||
| 70 | global $AR, $ARCurrent, $auth_config; |
||
| 71 | debug("webdav:check_auth $type:$user:$pass;"); |
||
| 72 | $auth_class = "mod_auth_".$auth_config['method']; |
||
| 73 | |||
| 74 | debug("webdav:check_auth using $auth_class module"); |
||
| 75 | |||
| 76 | $mod_auth = new $auth_class($auth_config); |
||
| 77 | |||
| 78 | $result = null; |
||
| 79 | |||
| 80 | /* FIXME: make this configurable */ |
||
| 81 | if (preg_match('/^Microsoft Data Access Internet/i', $_SERVER['HTTP_USER_AGENT'])) { |
||
| 82 | debug("webdav:check_auth using sessions"); |
||
| 83 | $this->http_auth_realm = "Ariadne WebDAV: ".$ARCurrent->session->id; |
||
| 84 | if (!$ARCurrent->session || !$ARCurrent->session->id) { |
||
| 85 | ldStartSession(); |
||
| 86 | } |
||
| 87 | if ($ARCurrent->session->get('ARSessionTimedout', 1)) { |
||
| 88 | /* find a better solution than to just kill the session */ |
||
| 89 | $ARCurrent->session->kill(); |
||
| 90 | ldStartSession(); |
||
| 91 | } elseif ($user) { |
||
| 92 | $result = $mod_auth->checkLogin($user, $pass); |
||
| 93 | } |
||
| 94 | } else { |
||
| 95 | debug("webdav:check_auth no session support"); |
||
| 96 | $this->http_auth_realm = "Ariadne WebDAV"; |
||
| 97 | // do HTTP Basic Auth only, so no session stuff |
||
| 98 | global $LD_NO_SESSION_SUPPORT; |
||
| 99 | $LD_NO_SESSION_SUPPORT = true; |
||
| 100 | if ($user) { |
||
| 101 | $result = $mod_auth->checkLogin($user, $pass); |
||
| 102 | } |
||
| 103 | } |
||
| 104 | if ($result === true) { |
||
| 105 | debug("webdav:check_auth success"); |
||
| 106 | debug("webdav:check_auth user loaded: ".$AR->user->data->login); |
||
| 107 | return true; |
||
| 108 | } else { |
||
| 109 | debug("webdav:check_auth failed"); |
||
| 110 | return false; |
||
| 111 | } |
||
| 112 | } |
||
| 113 | |||
| 114 | public function get_info($list) { |
||
| 115 | $result = Array(); |
||
| 116 | $props = $list['props']; |
||
| 117 | if (is_array($props)) { |
||
| 118 | foreach ($props as $name => $val) { |
||
| 119 | debug("webdav:get_info $name:$val"); |
||
| 120 | if ($name == 'displayname') { |
||
| 121 | $val = static::path_unescape($val); |
||
| 122 | debug("webdav:get_info unescaped $val"); |
||
| 123 | } |
||
| 124 | $result['props'][] = $this->mkprop($name, htmlspecialchars($val)); |
||
| 125 | } |
||
| 126 | } |
||
| 127 | $result['path'] = htmlspecialchars(static::path_unescape(substr($list['path'], strlen($this->root)-1))); |
||
| 128 | return $result; |
||
| 129 | } |
||
| 130 | |||
| 131 | public function propfind(&$options, &$files) { |
||
| 132 | debug("webdav:propfind [end]"); |
||
| 133 | return $this->modules['files']->propfind($options, $files); |
||
| 134 | } |
||
| 135 | |||
| 136 | public function head($options) { |
||
| 137 | debug("webdav:head"); |
||
| 138 | return $this->modules['files']->head($options); |
||
| 139 | } |
||
| 140 | |||
| 141 | public function delete($options) { |
||
| 142 | debug("webdav:delete"); |
||
| 143 | return $this->modules['files']->delete($options); |
||
| 144 | } |
||
| 145 | |||
| 146 | public function lock( &$options ) { |
||
| 147 | debug("method lock called"); |
||
| 148 | } |
||
| 149 | |||
| 150 | public function checkLock($path) { |
||
| 151 | debug("method check lock"); |
||
| 152 | } |
||
| 153 | |||
| 154 | public function mkcol($options) { |
||
| 155 | debug("webdav:mkcol"); |
||
| 156 | return $this->modules['files']->mkcol($options); |
||
| 157 | } |
||
| 158 | |||
| 159 | public function get(&$options) { |
||
| 160 | debug("webdav:get"); |
||
| 161 | return $this->modules['files']->get($options); |
||
| 162 | } |
||
| 163 | |||
| 164 | |||
| 165 | public function move($options) { |
||
| 166 | debug("webdav:move"); |
||
| 167 | return $this->modules['files']->move($options); |
||
| 168 | } |
||
| 169 | |||
| 170 | public function put(&$params) { |
||
| 171 | debug("webdav:put"); |
||
| 172 | return $this->modules['files']->put($params); |
||
| 173 | } |
||
| 174 | |||
| 175 | public function proppatch(&$options) { |
||
| 176 | |||
| 177 | } |
||
| 178 | |||
| 179 | } // end class definition |
||
| 180 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: