Issues (25)

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/Api/ChangeStream/VersionList.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
 * This file is part of the puli/repository package.
5
 *
6
 * (c) Bernhard Schussek <[email protected]>
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 Puli\Repository\Api\ChangeStream;
13
14
use ArrayAccess;
15
use ArrayIterator;
16
use BadMethodCallException;
17
use Countable;
18
use IteratorAggregate;
19
use OutOfBoundsException;
20
use Puli\Repository\Api\Resource\PuliResource;
21
use Webmozart\Assert\Assert;
22
23
/**
24
 * Contains different versions of a resource.
25
 *
26
 * @since  1.0
27
 *
28
 * @author Titouan Galopin <[email protected]>
29
 * @author Bernhard Schussek <[email protected]>
30
 */
31
class VersionList implements IteratorAggregate, ArrayAccess, Countable
32
{
33
    /**
34
     * @var string
35
     */
36
    private $path;
37
38
    /**
39
     * @var array
40
     */
41
    private $versions;
42
43
    /**
44
     * Creates a new version list.
45
     *
46
     * @param string         $path     The Puli path.
47
     * @param PuliResource[] $versions The versions of the resource, starting
48
     *                                 with the first.
49
     */
50 142
    public function __construct($path, array $versions)
51
    {
52 142
        Assert::stringNotEmpty($path, 'The Puli path must be a non-empty string. Got: %s');
53 140
        Assert::allIsInstanceOf($versions, 'Puli\Repository\Api\Resource\PuliResource');
54 139
        Assert::greaterThanEq(count($versions), 1, 'Expected at least one version.');
55
56 138
        $this->path = $path;
57 138
        $this->versions = array_values($versions);
58 138
    }
59
60
    /**
61
     * Returns the path of the versioned resources.
62
     *
63
     * @return string The Puli path.
64
     */
65 4
    public function getPath()
66
    {
67 4
        return $this->path;
68
    }
69
70
    /**
71
     * Returns the current version of the resource.
72
     *
73
     * @return PuliResource The current version.
74
     */
75 19
    public function getCurrent()
76
    {
77 19
        return $this->get($this->getCurrentVersion());
78
    }
79
80
    /**
81
     * Returns the current version number.
82
     *
83
     * @return int The current version number.
84
     */
85 20
    public function getCurrentVersion()
86
    {
87 20
        return count($this->versions) - 1;
88
    }
89
90
    /**
91
     * Returns the first version of the resource.
92
     *
93
     * @return PuliResource The first version.
94
     */
95 28
    public function getFirst()
96
    {
97 28
        return $this->get($this->getFirstVersion());
98
    }
99
100
    /**
101
     * Returns the first version number.
102
     *
103
     * @return int The first version number.
104
     */
105 29
    public function getFirstVersion()
106
    {
107 29
        return 0;
108
    }
109
110
    /**
111
     * Returns whether a specific version exists.
112
     *
113
     * @param int $version The version number starting at 0.
114
     *
115
     * @return bool Whether the version exists.
116
     */
117 1
    public function contains($version)
118
    {
119 1
        return isset($this->versions[$version]);
120
    }
121
122
    /**
123
     * Returns a specific version of the resource.
124
     *
125
     * @param int $version The version number starting at 0.
126
     *
127
     * @return PuliResource The resource.
128
     *
129
     * @throws OutOfBoundsException If the version number does not exist.
130
     */
131 111
    public function get($version)
132
    {
133 111
        if (!isset($this->versions[$version])) {
134 1
            throw new OutOfBoundsException(sprintf(
135 1
                'The version %s of path %s does not exist.',
136
                $version,
137 1
                $this->path
138
            ));
139
        }
140
141 110
        return $this->versions[$version];
142
    }
143
144
    /**
145
     * Returns all version numbers.
146
     *
147
     * @return int[] The version numbers.
0 ignored issues
show
Should the return type not be array<integer|string>?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
148
     */
149 95
    public function getVersions()
150
    {
151 95
        return array_keys($this->versions);
152
    }
153
154
    /**
155
     * Returns the list as array indexed by version numbers.
156
     *
157
     * @return PuliResource[] The resource versions indexed by their version numbers.
158
     */
159 1
    public function toArray()
160
    {
161 1
        return $this->versions;
162
    }
163
164
    /**
165
     * {@inheritdoc}
166
     */
167 1
    public function getIterator()
168
    {
169 1
        return new ArrayIterator($this->versions);
170
    }
171
172
    /**
173
     * {@inheritdoc}
174
     */
175 1
    public function offsetExists($offset)
176
    {
177 1
        return $this->contains($offset);
178
    }
179
180
    /**
181
     * {@inheritdoc}
182
     */
183 1
    public function offsetGet($offset)
184
    {
185 1
        return $this->get($offset);
186
    }
187
188
    /**
189
     * {@inheritdoc}
190
     */
191
    public function offsetSet($offset, $value)
192
    {
193
        throw new BadMethodCallException('List entries may not be changed.');
194
    }
195
196
    /**
197
     * {@inheritdoc}
198
     */
199
    public function offsetUnset($offset)
200
    {
201
        throw new BadMethodCallException('List entries may not be removed.');
202
    }
203
204
    /**
205
     * {@inheritdoc}
206
     */
207 26
    public function count()
208
    {
209 26
        return count($this->versions);
210
    }
211
}
212