Issues (1752)

Security Analysis    not enabled

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/Fwlib/Web/HtmlHelper.php (2 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 Fwlib\Web;
3
4
use Fwlib\Base\SingleInstanceTrait;
5
6
/**
7
 * Helper class for generate html output
8
 *
9
 *
10
 * Css and js reference(path) are stored here, for various class to access
11
 * shared css and js collection, then output them in result html. This class
12
 * only provide accessors, no html generation here.
13
 *
14
 * Root path should set at application beginning, is a path to public root,
15
 * used for generate path of other resources, these path usually used in url.
16
 *
17
 *
18
 * @copyright   Copyright 2015 Fwolf
19
 * @license     http://www.gnu.org/licenses/lgpl.html LGPL-3.0+
20
 */
21
class HtmlHelper
22
{
23
    use SingleInstanceTrait;
24
25
26
    /**
27
     * Css references
28
     *
29
     * Format: {name: {href, media}}
30
     *
31
     * For media type and query:
32
     * @see https://developer.mozilla.org/en-US/docs/Web/CSS/@media
33
     * @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Media_queries
34
     *
35
     * @var array
36
     */
37
    protected $css = [];
38
39
    /**
40
     * Javascript references
41
     *
42
     * @var string[]
43
     */
44
    protected $javascript = [];
45
46
    /**
47
     * @var string
48
     */
49
    protected $rootPath = '';
50
51
52
    /**
53
     * Add a css reference
54
     *
55
     * @param   string  $name
56
     * @param   string  $href
57
     * @param   string  $media
58
     * @return  static
59
     */
60
    public function addCss($name, $href, $media = 'all')
61
    {
62
        $this->css[$name] = [
63
            'href'  => $href,
64
            'media' => $media,
65
        ];
66
67
        return $this;
68
    }
69
70
71
    /**
72
     * Add a js reference
73
     *
74
     * @param   string  $name
75
     * @param   string  $path
76
     * @return  static
77
     */
78
    public function addJs($name, $path)
79
    {
80
        $this->javascript[$name] = $path;
81
82
        return $this;
83
    }
84
85
86
    /**
87
     * Clear all css reference
88
     *
89
     * @return  static
90
     */
91
    public function clearCss()
92
    {
93
        $this->css = [];
94
95
        return $this;
96
    }
97
98
99
    /**
100
     * Clear all js reference
101
     *
102
     * @return  static
103
     */
104
    public function clearJs()
105
    {
106
        $this->javascript = [];
107
108
        return $this;
109
    }
110
111
112
    /**
113
     * Getter of css reference
114
     *
115
     * @param   string  $name   Use '*' for all, or string name for single.
116
     * @return  array
117
     */
118 View Code Duplication
    public function getCss($name = '*')
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
119
    {
120
        if ('*' == $name) {
121
            return $this->css;
122
123
        } elseif (array_key_exists($name, $this->css)) {
124
            return $this->css[$name];
125
126
        } else {
127
            return null;
128
        }
129
    }
130
131
132
    /**
133
     * Getter of js reference
134
     *
135
     * @param   string  $name   Use '*' for all, or string name for single.
136
     * @return  array|string
137
     */
138 View Code Duplication
    public function getJs($name = '*')
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
139
    {
140
        if ('*' == $name) {
141
            return $this->javascript;
142
143
        } elseif (array_key_exists($name, $this->javascript)) {
144
            return $this->javascript[$name];
145
146
        } else {
147
            return null;
148
        }
149
    }
150
151
152
    /**
153
     * @return  string
154
     */
155
    public function getRootPath()
156
    {
157
        return $this->rootPath;
158
    }
159
160
161
    /**
162
     * Remove a css reference
163
     *
164
     * @param   string  $name
165
     * @return  static
166
     */
167
    public function removeCss($name)
168
    {
169
        unset($this->css[$name]);
170
171
        return $this;
172
    }
173
174
175
    /**
176
     * Remove a js reference
177
     *
178
     * @param   string  $name
179
     * @return  static
180
     */
181
    public function removeJs($name)
182
    {
183
        unset($this->javascript[$name]);
184
185
        return $this;
186
    }
187
188
189
    /**
190
     * @param   string  $rootPath
191
     * @return  static
192
     */
193
    public function setRootPath($rootPath)
194
    {
195
        if (!empty($rootPath) &&
196
            DIRECTORY_SEPARATOR != substr($rootPath, -1)
197
        ) {
198
            $rootPath .= DIRECTORY_SEPARATOR;
199
        }
200
201
        $this->rootPath = $rootPath;
202
203
        return $this;
204
    }
205
}
206