Issues (6)

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/Module/CleanUpModule.php (6 issues)

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\Zero\Module;
3
4
use Gwa\Wordpress\WpBridge\Traits\WpBridgeTrait;
5
use Gwa\Wordpress\Zero\Module\AbstractThemeModule;
6
7
class CleanUpModule extends AbstractThemeModule
8
{
9
    use WpBridgeTrait;
10
11
    /**
12
     * The default WordPress head is a mess. Let's clean it up.
13
     */
14
    public function wpHeadCleanup()
15
    {
16
        // index link
17
        $this->getWpBridge()->removeAction('wp_head', 'index_rel_link');
18
        // previous link
19
        $this->getWpBridge()->removeAction('wp_head', 'parent_post_rel_link', 10, 0);
20
        // start link
21
        $this->getWpBridge()->removeAction('wp_head', 'start_post_rel_link', 10, 0);
22
        // remove WP version from css
23
        $this->getWpBridge()->addFilter('style_loader_src', [$this, 'removeWpVerCssJs'], 9999);
24
        // remove Wp version from scripts
25
        $this->getWpBridge()->addFilter('script_loader_src', [$this, 'removeWpVerCssJs'], 9999);
26
    }
27
28
    public function removeRssVersion()
29
    {
30
        return '';
31
    }
32
33
    public function removeWpVerCssJs($src)
34
    {
35
        if (strpos($src, 'ver=')) {
36
            $src = $this->getWpBridge()->removeQueryArg('ver', $src);
37
        }
38
39
        return $src;
40
    }
41
42
    /**
43
     * Clean the output of attributes of images in editor.
44
     * Courtesy of SitePoint. http://www.sitepoint.com/wordpress-change-img-tag-html/
45
     *
46
     * @param string $class
47
     * @param string $id
48
     * @param string $align
49
     * @param string $size
50
     *
51
     * @return string
52
     */
53
    public function imageTagClassClean($class, $id, $align, $size)
0 ignored issues
show
The parameter $class 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...
The parameter $id 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...
The parameter $size 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...
54
    {
55
        return 'align'.esc_attr($align);
56
    }
57
58
    /**
59
     * Remove width and height in editor, for a better responsive world.
60
     *
61
     * @param string $html
62
     * @param string $id
63
     * @param string $alt
64
     * @param string $title
65
     *
66
     * @return string
67
     */
68
    public function imageEditorRemoveHightAndWidth($html, $id, $alt, $title)
0 ignored issues
show
The parameter $id 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...
The parameter $alt 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...
69
    {
70
        return preg_replace([
71
            '/\s+width="\d+"/i',
72
            '/\s+height="\d+"/i',
73
            '/alt=""/i'
74
        ], [
75
            '',
76
            '',
77
            '',
78
            'alt="'.$title.'"'
79
        ], $html);
80
    }
81
82
    /**
83
     * Remove image attributes
84
     *
85
     * @param  string $html
86
     *
87
     * @return string
88
     */
89
    public function removeImageAttributes($html)
90
    {
91
        $html = preg_replace('/(width|height)="\d*"\s/', '', $html);
92
93
        return $html;
94
    }
95
96
    public function shortcodeParagraphFix($content)
97
    {
98
        // Suchen und Ersetzen Strings festlegen
99
        $array = [
100
            '<p>[' => '[',
101
            ']</p>' => ']',
102
            ']<br />' => ']'
103
        ];
104
105
        return strtr($content, $array);
106
    }
107
108 1
    protected function getActionMap()
109
    {
110
        return [
111
            [
112 1
                'hooks'  => 'init',
113 1
                'class'  => $this,
114 1
                'method' => 'wpHeadCleanup',
115 1
                'prio'   => 10,
116 1
                'args'   => 1,
117 1
            ],
118 1
        ];
119
    }
120
121
    /**
122
     * Override in concrete subclass.
123
     *
124
     * @return array
0 ignored issues
show
Consider making the return type a bit more specific; maybe use array[].

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
125
     */
126 1
    protected function getFilterMap()
127
    {
128
        return [
129
            [
130 1
                'hooks'  => 'the_generator',
131 1
                'class'  => $this,
132 1
                'method' => 'removeRssVersion',
133 1
                'prio'   => 10,
134 1
                'args'   => 1,
135 1
            ], [
136 1
                'hooks'  => 'get_image_tag_class',
137 1
                'class'  => $this,
138 1
                'method' => 'imageTagClassClean',
139 1
                'prio'   => 0,
140 1
                'args'   => 4,
141 1
            ], [
142 1
                'hooks'  => 'get_image_tag',
143 1
                'class'  => $this,
144 1
                'method' => 'imageEditorRemoveHightAndWidth',
145 1
                'prio'   => 0,
146 1
                'args'   => 4,
147 1
            ], [
148 1
                'hooks'  => 'the_content',
149 1
                'class'  => $this,
150 1
                'method' => 'shortcodeParagraphFix',
151 1
                'prio'   => 10,
152 1
                'args'   => 1,
153 1
            ], [
154 1
                'hooks'  => ['post_thumbnail_html', 'removeImageAttributes'],
155 1
                'class'  => $this,
156 1
                'method' => 'removeImageAttributes',
157 1
                'prio'   => 10,
158 1
                'args'   => 1,
159 1
            ],
160 1
        ];
161
    }
162
}
163