Issues (4)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/Gwa/AbstractResolver.php (1 issue)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
namespace Gwa\Wordpress;
3
4
use Gwa\Wordpress\WpBridge\Traits\WpBridgeTrait;
5
6
abstract class AbstractResolver
7
{
8
    use WpBridgeTrait;
9
10
    /**
11
     * Folder path to wordpress, with trailing slash.
12
     *
13
     * @var string
14
     */
15
    protected $wpDirectoryPath = '';
16
17
    /**
18
     * Wordpress folder name.
19
     *
20
     * @var string
21
     */
22
    protected $wpFolderName = '';
23
24
    /**
25
     * MultisiteDirectoryResolver.
26
     *
27
     * @param string $wpdir
28
     */
29
    public function __construct($wpdir)
30
    {
31
        $this->wpDirectoryPath = substr($wpdir, -1) === '/' ? $wpdir : $wpdir.'/';
32
        $this->setWpFolderName();
33
    }
34
35
    /**
36
     * Set the right links in Adminbar.
37
     *
38
     * @param string $path
39
     * @param string $scheme
40
     *
41
     * @return string
42
     */
43
    public function fixNetworkAdminUrlFilter($path = '', $scheme = 'admin')
0 ignored issues
show
The parameter $scheme is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
44
    {
45
        if (strpos($path, $this->wpDirectoryPath)) {
46
            return $path;
47
        }
48
49
        $wordpressUrl = [
50
            '/(wp-admin)/',
51
            '/(wp-login\.php)/',
52
            '/(wp-activate\.php)/',
53
            '/(wp-signup\.php)/',
54
        ];
55
56
        $multiSiteUrl = [
57
            $this->wpFolderName.'/wp-admin',
58
            $this->wpFolderName.'/wp-login.php',
59
            $this->wpFolderName.'/wp-activate.php',
60
            $this->wpFolderName.'/wp-signup.php',
61
        ];
62
63
        return preg_replace($wordpressUrl, $multiSiteUrl, $path, 1);
64
    }
65
66
    /**
67
     * Fix double backslashes in app folder.
68
     *
69
     * @param string
70
     */
71
    public function fixWpDoubleSlashFilter($urls)
72
    {
73
        foreach ($urls as &$url) {
74
            if ($url) {
75
                $url = str_replace('//app', '/app', $url);
76
            }
77
        }
78
79
        return $urls;
80
    }
81
82
    /**
83
     * Fixes the protocol in urls. Replaces leading double slashes //
84
     * with the full protocol; https or http depending on context.
85
     *
86
     * @param string
87
     *
88
     * @return array
89
     */
90
    public function fixWpProtocolFilter($urls)
91
    {
92
        $protocol = $this->getSiteProtocol();
93
94
        foreach ($urls as $k => &$v) {
95
            if ((strpos($k, 'url') !== false) && (substr($v, 0, 2) === '//')) {
96
                $v = $protocol.ltrim($v, '//');
97
            }
98
        }
99
100
        return $urls;
101
    }
102
103
    /**
104
     * Get the correct protocol.
105
     *
106
     * @return string
107
     */
108
    protected function getSiteProtocol()
109
    {
110
        return $this->getWpBridge()->isSsl() ? 'https://' : 'http://';
111
    }
112
113
    /**
114
     * Init all filter.
115
     */
116
    public function init()
117
    {
118
        $this->getWpBridge()->addFilter('network_admin_url', [$this, 'fixNetworkAdminUrlFilter'], 10, 2);
119
120
        $this->getWpBridge()->addFilter('script_loader_src', [$this, 'fixStyleScriptPathFilter'], 10, 2);
121
        $this->getWpBridge()->addFilter('style_loader_src', [$this, 'fixStyleScriptPathFilter'], 10, 2);
122
123
        $this->getWpBridge()->addFilter('upload_dir', [$this, 'fixWpDoubleSlashFilter'], 10, 1);
124
        $this->getWpBridge()->addFilter('upload_dir', [$this, 'fixWpProtocolFilter'], 10, 1);
125
    }
126
127
    /**
128
     * Set wordpress folder name.
129
     *
130
     * @param string
131
     */
132
    protected function setWpFolderName()
133
    {
134
        $dirs = explode('/', $this->wpDirectoryPath);
135
136
        $this->wpFolderName = $dirs[count($dirs) - 2];
137
    }
138
}
139