Issues (191)

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.

lib/ILess/Node.php (1 issue)

Labels
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
3
/*
4
 * This file is part of the ILess
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace ILess;
11
12
use ILess\Node\CompilableInterface;
13
use ILess\Node\GenerateCSSInterface;
14
use ILess\Node\VisitableInterface;
15
use ILess\Output\OutputInterface;
16
use ILess\Output\StandardOutput;
17
use ILess\Visitor\VisitorInterface;
18
19
/**
20
 * Base node.
21
 */
22
abstract class Node implements VisitableInterface,
23
    GenerateCSSInterface, CompilableInterface
24
{
25
    /**
26
     * The value.
27
     *
28
     * @var Node|string
29
     */
30
    public $value;
31
32
    /**
33
     * ILess\Debug information.
34
     *
35
     * @var DebugInfo
36
     */
37
    public $debugInfo;
38
39
    /**
40
     * The node type. Each node should define the type.
41
     *
42
     * @var string
43
     */
44
    protected $type;
45
46
    /**
47
     * Current file info.
48
     *
49
     * @var FileInfo
50
     */
51
    public $currentFileInfo;
52
53
    /**
54
     * @var bool
55
     */
56
    public $compileFirst = false;
57
58
    /**
59
     * Constructor.
60
     *
61
     * @param mixed $value
62
     */
63
    public function __construct($value)
64
    {
65
        $this->value = $value;
66
    }
67
68
    /**
69
     * Returns the node type.
70
     *
71
     * @return string
72
     */
73
    public function getType()
74
    {
75
        return $this->type;
76
    }
77
78
    /**
79
     * Checks if given method exists.
80
     *
81
     * @param mixed $var The variable name
82
     * @param string $methodName The method name
83
     *
84
     * @return bool
85
     */
86
    public static function methodExists($var, $methodName)
87
    {
88
        return is_object($var) && method_exists($var, $methodName);
89
    }
90
91
    /**
92
     * Checks if given property exists.
93
     *
94
     * @param mixed $var The variable to check
95
     * @param string $property The property name
96
     *
97
     * @return bool
98
     */
99
    public static function propertyExists($var, $property)
100
    {
101
        return is_object($var) && property_exists($var, $property);
102
    }
103
104
    /**
105
     * Returns debug information for the node.
106
     *
107
     * @param Context $context The context
108
     * @param Node $node The context node
109
     * @param string $lineSeparator Line separator
110
     *
111
     * @return string
112
     */
113
    public static function getDebugInfo(Context $context, Node $node, $lineSeparator = '')
114
    {
115
        $result = '';
116
117
        if ($node->debugInfo && $context->dumpLineNumbers && !$context->compress) {
118
            switch ((string) $context->dumpLineNumbers) {
119
                case DebugInfo::FORMAT_COMMENT;
120
                    $result = $node->debugInfo->getAsComment();
121
                    break;
122
123
                case DebugInfo::FORMAT_MEDIA_QUERY;
124
                    $result = $node->debugInfo->getAsMediaQuery();
125
                    break;
126
127
                case DebugInfo::FORMAT_ALL;
128
                case '1':
129
                    $result = sprintf('%s%s%s',
130
                        $node->debugInfo->getAsComment(), $lineSeparator,
131
                        $node->debugInfo->getAsMediaQuery()
132
                    );
133
                    break;
134
            }
135
        }
136
137
        return $result;
138
    }
139
140
    /**
141
     * Outputs the ruleset rules.
142
     *
143
     * @param Context $context
144
     * @param OutputInterface $output
145
     * @param array $rules
146
     */
147
    public static function outputRuleset(Context $context, OutputInterface $output, array $rules)
148
    {
149
        ++$context->tabLevel;
150
        $rulesCount = count($rules);
151
152
        // compression
153
        if ($context->compress) {
154
            $output->add('{');
155
            for ($i = 0; $i < $rulesCount; ++$i) {
156
                $rules[$i]->generateCSS($context, $output);
157
            }
158
            $output->add('}');
159
            --$context->tabLevel;
160
161
            return;
162
        }
163
164
        // Non-compressed
165
        $tabSetStr = "\n" . str_repeat('  ', $context->tabLevel - 1);
166
        $tabRuleStr = $tabSetStr . '  ';
167
168
        // Non-compressed
169
        if (!$rulesCount) {
170
            $output->add(' {' . $tabSetStr . '}');
171
        } else {
172
            $output->add(' {' . $tabRuleStr);
173
            $rules[0]->generateCSS($context, $output);
174
            for ($i = 1; $i < $rulesCount; ++$i) {
175
                $output->add($tabRuleStr);
176
                $rules[$i]->generateCSS($context, $output);
177
            }
178
179
            $output->add($tabSetStr . '}');
180
        }
181
182
        --$context->tabLevel;
183
    }
184
185
    /**
186
     * Convert to string.
187
     *
188
     * @return string
189
     */
190
    public function toString()
191
    {
192
        return (string) $this->value;
193
    }
194
195
    /**
196
     * Convert to string.
197
     *
198
     * @return string
199
     */
200
    public function __toString()
201
    {
202
        return $this->toString();
203
    }
204
205
    /**
206
     * {@inheritdoc}
207
     */
208
    public function toCSS(Context $context)
209
    {
210
        $output = new StandardOutput();
211
        $this->generateCSS($context, $output);
212
213
        return $output->toString();
214
    }
215
216
    /**
217
     * {@inheritdoc}
218
     */
219
    public function accept(VisitorInterface $visitor)
220
    {
221
        $this->value = $visitor->visit($this->value);
222
    }
223
224
    /**
225
     * Generate the CSS and put it in the output container.
226
     *
227
     * @param Context $context The context
228
     * @param OutputInterface $output The output
229
     */
230
    public function generateCSS(Context $context, OutputInterface $output)
231
    {
232
        $output->add($this->value);
0 ignored issues
show
It seems like $this->value can also be of type object<ILess\Node>; however, ILess\Output\OutputInterface::add() does only seem to accept string, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
233
    }
234
235
    /**
236
     * Compiles the node.
237
     *
238
     * @param Context $context The context
239
     * @param array|null $arguments Array of arguments
240
     * @param bool|null $important Important flag
241
     *
242
     * @return Node
243
     */
244
    public function compile(Context $context, $arguments = null, $important = null)
245
    {
246
        return $this;
247
    }
248
249
    /**
250
     * @return bool
251
     */
252
    public function isRulesetLike()
253
    {
254
        return false;
255
    }
256
257
    /**
258
     * @return bool
259
     */
260
    public function compileFirst()
261
    {
262
        return $this->compileFirst;
263
    }
264
}
265