Issues (280)

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.

external/php/yui-php-cssmin-bundled/Utils.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
3
namespace Autoptimize\tubalmartin\CssMin;
4
5
class Utils
6
{
7
    /**
8
     * Clamps a number between a minimum and a maximum value.
9
     * @param int|float $n the number to clamp
10
     * @param int|float $min the lower end number allowed
11
     * @param int|float $max the higher end number allowed
12
     * @return int|float
13
     */
14
    public static function clampNumber($n, $min, $max)
15
    {
16
        return min(max($n, $min), $max);
17
    }
18
19
    /**
20
     * Clamps a RGB color number outside the sRGB color space
21
     * @param int|float $n the number to clamp
22
     * @return int|float
23
     */
24
    public static function clampNumberSrgb($n)
25
    {
26
        return self::clampNumber($n, 0, 255);
27
    }
28
29
    /**
30
     * Converts a HSL color into a RGB color
31
     * @param array $hslValues
32
     * @return array
33
     */
34
    public static function hslToRgb($hslValues)
35
    {
36
        $h = floatval($hslValues[0]);
37
        $s = floatval(str_replace('%', '', $hslValues[1]));
38
        $l = floatval(str_replace('%', '', $hslValues[2]));
39
40
        // Wrap and clamp, then fraction!
41
        $h = ((($h % 360) + 360) % 360) / 360;
42
        $s = self::clampNumber($s, 0, 100) / 100;
43
        $l = self::clampNumber($l, 0, 100) / 100;
44
45
        if ($s == 0) {
46
            $r = $g = $b = self::roundNumber(255 * $l);
47
        } else {
48
            $v2 = $l < 0.5 ? $l * (1 + $s) : ($l + $s) - ($s * $l);
49
            $v1 = (2 * $l) - $v2;
50
            $r = self::roundNumber(255 * self::hueToRgb($v1, $v2, $h + (1/3)));
51
            $g = self::roundNumber(255 * self::hueToRgb($v1, $v2, $h));
52
            $b = self::roundNumber(255 * self::hueToRgb($v1, $v2, $h - (1/3)));
53
        }
54
55
        return array($r, $g, $b);
56
    }
57
58
    /**
59
     * Tests and selects the correct formula for each RGB color channel
60
     * @param $v1
61
     * @param $v2
62
     * @param $vh
63
     * @return mixed
64
     */
65
    public static function hueToRgb($v1, $v2, $vh)
66
    {
67
        $vh = $vh < 0 ? $vh + 1 : ($vh > 1 ? $vh - 1 : $vh);
68
69 View Code Duplication
        if ($vh * 6 < 1) {
0 ignored issues
show
This code seems to be duplicated across 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...
70
            return $v1 + ($v2 - $v1) * 6 * $vh;
71
        }
72
73
        if ($vh * 2 < 1) {
74
            return $v2;
75
        }
76
77 View Code Duplication
        if ($vh * 3 < 2) {
0 ignored issues
show
This code seems to be duplicated across 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...
78
            return $v1 + ($v2 - $v1) * ((2 / 3) - $vh) * 6;
79
        }
80
81
        return $v1;
82
    }
83
84
    /**
85
     * Convert strings like "64M" or "30" to int values
86
     * @param mixed $size
87
     * @return int
88
     */
89
    public static function normalizeInt($size)
90
    {
91
        if (is_string($size)) {
92
            $letter = substr($size, -1);
93
            $size = intval($size);
94
            switch ($letter) {
95
                case 'M':
96
                case 'm':
97
                    return (int) $size * 1048576;
98
                case 'K':
99
                case 'k':
100
                    return (int) $size * 1024;
101
                case 'G':
102
                case 'g':
103
                    return (int) $size * 1073741824;
104
            }
105
        }
106
        return (int) $size;
107
    }
108
109
    /**
110
     * Converts a string containing and RGB percentage value into a RGB integer value i.e. '90%' -> 229.5
111
     * @param $rgbPercentage
112
     * @return int
113
     */
114
    public static function rgbPercentageToRgbInteger($rgbPercentage)
115
    {
116
        if (strpos($rgbPercentage, '%') !== false) {
117
            $rgbPercentage = self::roundNumber(floatval(str_replace('%', '', $rgbPercentage)) * 2.55);
118
        }
119
120
        return intval($rgbPercentage, 10);
121
    }
122
123
    /**
124
     * Converts a RGB color into a HEX color
125
     * @param array $rgbColors
126
     * @return array
127
     */
128
    public static function rgbToHex($rgbColors)
129
    {
130
        $hexColors = array();
131
132
        // Values outside the sRGB color space should be clipped (0-255)
133
        for ($i = 0, $l = count($rgbColors); $i < $l; $i++) {
134
            $hexColors[$i] = sprintf("%02x", self::clampNumberSrgb(self::rgbPercentageToRgbInteger($rgbColors[$i])));
135
        }
136
137
        return $hexColors;
138
    }
139
140
    /**
141
     * Rounds a number to its closest integer
142
     * @param $n
143
     * @return int
144
     */
145
    public static function roundNumber($n)
146
    {
147
        return intval(round(floatval($n)), 10);
148
    }
149
}
150