Issues (9)

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/Parse/VersionRangeParser.php (1 issue)

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
 * @copyright   (c) 2014-2017 brian ridley
5
 * @author      brian ridley <[email protected]>
6
 * @license     http://opensource.org/licenses/MIT MIT
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace ptlis\SemanticVersion\Parse;
13
14
use ptlis\SemanticVersion\Parse\RangeParser\RangeParserInterface;
15
use ptlis\SemanticVersion\VersionRange\VersionRangeInterface;
16
17
/**
18
 * Parser accepting array of tokens and returning an array of comparators & versions.
19
 */
20
final class VersionRangeParser
21
{
22
    use ChunkBySeparator;
23
24
    /** @var LogicalOperatorProcessor */
25
    private $logicalOperatorProcessor;
26
27
    /** @var RangeParserInterface[] */
28
    private $rangeParserList;
29
30
    /** @var string[] Array of tokens representing logical operators */
31
    private $operatorTokenList = [
32
        Token::LOGICAL_AND,
33
        Token::LOGICAL_OR
34
    ];
35
36
37
    /**
38
     * Constructor
39
     *
40
     * @param LogicalOperatorProcessor $logicalOperatorProcessor
41
     * @param RangeParserInterface[] $rangeParserList
42
     */
43 32
    public function __construct(
44
        LogicalOperatorProcessor $logicalOperatorProcessor,
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $logicalOperatorProcessor exceeds the maximum configured length of 20.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
45
        array $rangeParserList
46
    ) {
47 32
        $this->logicalOperatorProcessor = $logicalOperatorProcessor;
48 32
        $this->rangeParserList = $rangeParserList;
49 32
    }
50
51
    /**
52
     * Parse a version range.
53
     *
54
     * @param Token[] $tokenList
55
     *
56
     * @return VersionRangeInterface
57
     */
58 32
    public function parseRange(array $tokenList)
59
    {
60 32
        $realResultList = [];
61 32
        $tokenClusterList = $this->chunk($tokenList, $this->operatorTokenList);
62 32
        foreach ($tokenClusterList as $tokenCluster) {
63 32
            $parsed = $this->attemptParse($tokenCluster);
64
65 32
            if (is_null($parsed)) {
66 7
                if (in_array($tokenCluster[0]->getType(), $this->operatorTokenList)) {
67 6
                    $realResultList[] = $tokenCluster[0];
68 6
                } else {
69 1
                    throw new \RuntimeException('Unable to parse version string');
70
                }
71 6
            } else {
72 31
                $realResultList[] = $parsed;
73
            }
74 31
        }
75
76 31
        return $this->logicalOperatorProcessor->run($realResultList);
77
    }
78
79
    /**
80
     * Attempt to parse the token list as a version range into an object implementing VersionRangeInterface
81
     *
82
     * Iterates through the provided range parsers checking to see if they can parse the token list. If they can then we
83
     * call the parse method and return a version range object, otherwise return null.
84
     *
85
     * @param Token[] $tokenList
86
     *
87
     * @return VersionRangeInterface|null
88
     */
89 32
    private function attemptParse(array $tokenList)
90
    {
91 32
        $parsed = null;
92 32
        foreach ($this->rangeParserList as $rangeParser) {
93 32
            if ($rangeParser->canParse($tokenList)) {
94 31
                $parsed = $rangeParser->parse($tokenList);
95 31
                break;
96
            }
97 32
        }
98
99 32
        return $parsed;
100
    }
101
}
102