GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

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.

Convert/MeasureConverter.php (5 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 Akeneo\Bundle\MeasureBundle\Convert;
4
5
use Akeneo\Bundle\MeasureBundle\Exception\UnknownFamilyMeasureException;
6
use Akeneo\Bundle\MeasureBundle\Exception\UnknownMeasureException;
7
use Akeneo\Bundle\MeasureBundle\Exception\UnknownOperatorException;
8
9
/**
10
 * Aims to convert measures
11
 *
12
 * @author    Romain Monceau <[email protected]>
13
 * @copyright 2012 Akeneo SAS (http://www.akeneo.com)
14
 * @license   http://opensource.org/licenses/MIT MIT
15
 */
16
class MeasureConverter
17
{
18
    /**
19
     * @var array
20
     */
21
    protected $config;
22
23
    /**
24
     * @var string
25
     */
26
    protected $family;
27
28
    /**
29
     * Constructor
30
     *
31
     * @param array $config Configuration parameters
32
     */
33
    public function __construct($config = [])
34
    {
35
        $this->config = $config['measures_config'];
36
    }
37
38
    /**
39
     * Set a family for the converter
40
     * @param string $family
41
     *
42
     * @throws UnknownFamilyMeasureException
43
     * @return MeasureConverter
44
     *
45
     */
46 View Code Duplication
    public function setFamily($family)
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...
47
    {
48
        if (!isset($this->config[$family])) {
49
            throw new UnknownFamilyMeasureException();
50
        }
51
52
        $this->family = $family;
53
54
        return $this;
55
    }
56
57
    /**
58
     * Convert a value from a base measure to a final measure
59
     * @param string $baseUnit  Base unit for value
60
     * @param string $finalUnit Result unit for value
61
     * @param double $value     Value to convert
62
     *
63
     * @return double
64
     */
65
    public function convert($baseUnit, $finalUnit, $value)
66
    {
67
        $standardValue = $this->convertBaseToStandard($baseUnit, $value);
68
69
        $result = $this->convertStandardToResult($finalUnit, $standardValue);
70
71
        return $result;
72
    }
73
74
    /**
75
     * Convert a value in a base unit to the standard unit
76
     * @param string $baseUnit Base unit for value
77
     * @param double $value    Value to convert
78
     *
79
     * @throws UnknownOperatorException
80
     * @throws UnknownMeasureException
81
     * @return double
82
     *
83
     */
84 View Code Duplication
    public function convertBaseToStandard($baseUnit, $value)
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...
85
    {
86
        if (!isset($this->config[$this->family]['units'][$baseUnit])) {
87
            throw new UnknownMeasureException(
88
                sprintf(
89
                    'Could not find metric unit "%s" in family "%s"',
90
                    $baseUnit,
91
                    $this->family
92
                )
93
            );
94
        }
95
        $conversionConfig = $this->config[$this->family]['units'][$baseUnit]['convert'];
96
        $convertedValue = $value;
97
98
        foreach ($conversionConfig as $operation) {
99
            foreach ($operation as $operator => $operand) {
100
                $convertedValue = $this->applyOperation($convertedValue, $operator, $operand);
101
            }
102
        }
103
104
        return $convertedValue;
105
    }
106
107
    /**
108
     * Apply operation between value and operand by using operator
109
     *
110
     * @param double $value    Value to convert
111
     * @param string $operator Operator to apply
112
     * @param double $operand  Operand to use
113
     *
114
     * @return double
115
     */
116 View Code Duplication
    protected function applyOperation($value, $operator, $operand)
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...
117
    {
118
        $processedValue = $value;
119
120
        switch ($operator) {
121
            case "div":
122
                if ($operand !== 0) {
123
                    $processedValue = $processedValue / $operand;
124
                }
125
                break;
126
            case "mul":
127
                $processedValue = $processedValue * $operand;
128
                break;
129
            case "add":
130
                $processedValue = $processedValue + $operand;
131
                break;
132
            case "sub":
133
                $processedValue = $processedValue - $operand;
134
                break;
135
            default:
136
                throw new UnknownOperatorException();
137
        }
138
139
        return $processedValue;
140
    }
141
142
    /**
143
     * Convert a value in a standard unit to a final unit
144
     * @param string $finalUnit Final unit for value
145
     * @param double $value     Value to convert
146
     *
147
     * @throws UnknownOperatorException
148
     * @throws UnknownMeasureException
149
     * @return double
150
     *
151
     */
152 View Code Duplication
    public function convertStandardToResult($finalUnit, $value)
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...
153
    {
154
        if (!isset($this->config[$this->family]['units'][$finalUnit])) {
155
            throw new UnknownMeasureException(
156
                sprintf(
157
                    'Could not find metric unit "%s" in family "%s"',
158
                    $finalUnit,
159
                    $this->family
160
                )
161
            );
162
        }
163
        $conversionConfig = $this->config[$this->family]['units'][$finalUnit]['convert'];
164
        $convertedValue = $value;
165
166
        // calculate result with conversion config (calculs must be reversed and operation inversed)
167
        foreach (array_reverse($conversionConfig) as $operation) {
168
            foreach ($operation as $operator => $operand) {
169
                $convertedValue = $this->applyReversedOperation($convertedValue, $operator, $operand);
170
            }
171
        }
172
173
        return $convertedValue;
174
    }
175
176
    /**
177
     * Apply reversed operation between value and operand by using operator
178
     *
179
     * @param double $value    Value to convert
180
     * @param string $operator Operator to apply
181
     * @param double $operand  Operand to use
182
     *
183
     * @return double
184
     */
185 View Code Duplication
    protected function applyReversedOperation($value, $operator, $operand)
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...
186
    {
187
        $processedValue = $value;
188
189
        switch ($operator) {
190
            case "div":
191
                $processedValue = $processedValue * $operand;
192
                break;
193
            case "mul":
194
                if ($operand !== 0) {
195
                    $processedValue = $processedValue / $operand;
196
                }
197
                break;
198
            case "add":
199
                $processedValue = $processedValue - $operand;
200
                break;
201
            case "sub":
202
                $processedValue = $processedValue + $operand;
203
                break;
204
            default:
205
                throw new UnknownOperatorException();
206
        }
207
208
        return $processedValue;
209
    }
210
}
211