Issues (14)

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/OpenCubes.php (4 issues)

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
namespace BenTools\OpenCubes;
4
5
use BenTools\OpenCubes\Component\BreakDown\BreakDownComponent;
6
use BenTools\OpenCubes\Component\BreakDown\BreakDownComponentFactory;
7
use BenTools\OpenCubes\Component\BreakDown\BreakDownUriManager;
8
use BenTools\OpenCubes\Component\BreakDown\BreakDownUriManagerInterface;
9
use BenTools\OpenCubes\Component\ComponentFactoryInterface;
10
use BenTools\OpenCubes\Component\ComponentInterface;
11
use BenTools\OpenCubes\Component\Filter\FilterComponent;
12
use BenTools\OpenCubes\Component\Filter\FilterComponentFactory;
13
use BenTools\OpenCubes\Component\Filter\FilterUriManager;
14
use BenTools\OpenCubes\Component\Filter\FilterUriManagerInterface;
15
use BenTools\OpenCubes\Component\Pager\PagerComponent;
16
use BenTools\OpenCubes\Component\Pager\PagerComponentFactory;
17
use BenTools\OpenCubes\Component\Pager\PagerUriManager;
18
use BenTools\OpenCubes\Component\Pager\PagerUriManagerInterface;
19
use BenTools\OpenCubes\Component\Sort\SortComponent;
20
use BenTools\OpenCubes\Component\Sort\SortComponentFactory;
21
use BenTools\OpenCubes\Component\Sort\SortUriManager;
22
use BenTools\OpenCubes\Component\Sort\SortUriManagerInterface;
23
use Psr\Http\Message\UriInterface;
24
25
final class OpenCubes
26
{
27
    /**
28
     * @var ComponentFactoryInterface[]
29
     */
30
    private $factories = [];
31
32
    /**
33
     * OpenCubes constructor.
34
     * @param iterable $factories
35
     */
36
    public function __construct(iterable $factories = [])
37
    {
38
        foreach ($factories as $factory) {
39
            $this->registerFactory($factory);
40
        }
41
    }
42
43
    /**
44
     * @param ComponentFactoryInterface $factory
45
     */
46
    public function registerFactory(ComponentFactoryInterface $factory): void
47
    {
48
        array_unshift($this->factories, $factory);
49
    }
50
51
    /**
52
     * @param string            $componentName
53
     * @param array             $options
54
     * @param UriInterface|null $uri
55
     * @return ComponentInterface
56
     * @throws \RuntimeException
57
     */
58
    public function getComponent(string $componentName, array $options = [], UriInterface $uri = null): ComponentInterface
59
    {
60
        $uri = $uri ?? current_location();
61
62
        foreach ($this->factories as $factory) {
63
            if ($factory->supports($componentName)) {
64
                return $factory->createComponent($uri, $options);
65
            }
66
        }
67
68
        throw new \RuntimeException(sprintf('Component "%s" could not be instanciated.', $componentName));
69
    }
70
71
    /**
72
     * Instanciate with default configuration.
73
     *
74
     * @param array                             $options
75
     * @param PagerUriManagerInterface|null     $pagerUriManager
0 ignored issues
show
There is no parameter named $pagerUriManager. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
76
     * @param SortUriManagerInterface|null      $sortUriManager
0 ignored issues
show
There is no parameter named $sortUriManager. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
77
     * @param FilterUriManagerInterface|null    $filterUriManager
0 ignored issues
show
There is no parameter named $filterUriManager. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
78
     * @param BreakDownUriManagerInterface|null $breakDownUriManager
0 ignored issues
show
There is no parameter named $breakDownUriManager. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
79
     * @return OpenCubes
80
     */
81
    public static function create(
82
        array $options = [],
83
        ...$args
84
    ): self {
85
86
        $pagerUriManager = (function (array $args) use ($options): PagerUriManagerInterface {
87
            foreach ($args as $arg) {
88
                if ($arg instanceof PagerUriManagerInterface) {
89
                    return $arg;
90
                }
91
            }
92
93
            return new PagerUriManager($options[PagerComponent::getName() . '_uri'] ?? []);
94
        })($args);
95
96
        $sortUriManager = (function (array $args) use ($options, $pagerUriManager): SortUriManagerInterface {
97
            foreach ($args as $arg) {
98
                if ($arg instanceof SortUriManagerInterface) {
99
                    return $arg;
100
                }
101
            }
102
103
            return new SortUriManager($options[SortComponent::getName() . '_uri'] ?? [], $pagerUriManager);
104
        })($args);
105
106
        $filterUriManager = (function (array $args) use ($options, $pagerUriManager): FilterUriManagerInterface {
107
            foreach ($args as $arg) {
108
                if ($arg instanceof FilterUriManagerInterface) {
109
                    return $arg;
110
                }
111
            }
112
113
            return new FilterUriManager($options[FilterComponent::getName() . '_uri'] ?? [], $pagerUriManager);
114
        })($args);
115
116
        $breakDownUriManager = (function (array $args) use ($options, $pagerUriManager, $sortUriManager): BreakDownUriManagerInterface {
117
            foreach ($args as $arg) {
118
                if ($arg instanceof BreakDownUriManagerInterface) {
119
                    return $arg;
120
                }
121
            }
122
123
            return new BreakDownUriManager($options[BreakDownComponent::getName() . '_uri'] ?? [], $pagerUriManager, $sortUriManager);
124
        })($args);
125
126
        return new self([
127
            new PagerComponentFactory($options[PagerComponent::getName()] ?? [], $pagerUriManager),
128
            new SortComponentFactory($options[SortComponent::getName()] ?? [], $sortUriManager),
129
            new FilterComponentFactory($options[FilterComponent::getName()] ?? [], $filterUriManager),
130
            new BreakDownComponentFactory($options[BreakDownComponent::getName()] ?? [], $breakDownUriManager),
131
        ]);
132
    }
133
}
134