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 (152)

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.

src/Common/Resource/AbstractResource.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 declare(strict_types=1);
2
3
namespace OpenStack\Common\Resource;
4
5
use OpenStack\Common\Transport\Serializable;
6
use OpenStack\Common\Transport\Utils;
7
use Psr\Http\Message\ResponseInterface;
8
9
/**
10
 * Represents a top-level abstraction of a remote API resource. Usually a resource represents a discrete
11
 * entity such as a Server, Container, Load Balancer. Apart from a representation of state, a resource can
12
 * also execute RESTFul operations on itself (updating, deleting, listing) or on other models.
13
 *
14
 * @package OpenStack\Common\Resource
15
 */
16
abstract class AbstractResource implements ResourceInterface, Serializable
17
{
18
    /**
19
     * The JSON key that indicates how the API nests singular resources. For example, when
20
     * performing a GET, it could respond with ``{"server": {"id": "12345"}}``. In this case,
21
     * "server" is the resource key, since the essential state of the server is nested inside.
22
     *
23
     * @var string
24
     */
25
    protected $resourceKey;
26
27
    /**
28
     * An array of aliases that will be checked when the resource is being populated. For example,
29
     *
30
     * 'FOO_BAR' => 'fooBar'
31
     *
32
     * will extract FOO_BAR from the response, and save it as 'fooBar' in the resource.
33
     *
34
     * @var array
35
     */
36
    protected $aliases = [];
37
38
    /**
39
     * Populates the current resource from a response object.
40
     *
41
     * @param ResponseInterface $response
42
     *
43
     * @return AbstractResource
44
     */
45
    public function populateFromResponse(ResponseInterface $response): self
46
    {
47
        if (strpos($response->getHeaderLine('Content-Type'), 'application/json') === 0) {
48
            $json = Utils::jsonDecode($response);
49
            if (!empty($json)) {
50
                $this->populateFromArray(Utils::flattenJson($json, $this->resourceKey));
51
            }
52
        }
53
54
        return $this;
55
    }
56
57
    /**
58
     * Populates the current resource from a data array.
59
     *
60
     * @param array $array
61
     *
62
     * @return mixed|void
63 74
     */
64
    public function populateFromArray(array $array): self
65 74
    {
66 61
        $aliases = $this->getAliases();
67 61
68 61
        foreach ($array as $key => $val) {
69 61
            $alias = $aliases[$key] ?? false;
70 61
71
            if ($alias instanceof Alias) {
72 74
                $key = $alias->propertyName;
73
                $val = $alias->getValue($this, $val);
74
            }
75
76
            if (property_exists($this, $key)) {
77
                $this->{$key} = $val;
78
            }
79
        }
80
81
        return $this;
82 133
    }
83
84 133
    /**
85
     * Constructs alias objects
86 133
     *
87 133
     * @return Alias[]
88
     */
89 133
    protected function getAliases(): array
90 131
    {
91 128
        $aliases = [];
92 128
93
        foreach ((array)$this->aliases as $alias => $property) {
94 131
            $aliases[$alias] = new Alias($property);
95 131
        }
96 133
97 133
        return $aliases;
98
    }
99 128
100 2
    /**
101 128
     * Internal method which retrieves the values of provided keys.
102 6
     *
103 6
     * @param array $keys
104 6
     *
105 6
     * @return array
106 6
     */
107 128
    protected function getAttrs(array $keys)
108 28
    {
109 127
        $output = [];
110 11
111 11
        foreach ($keys as $key) {
112
            if (property_exists($this, $key) && $this->$key !== null) {
113 128
                $output[$key] = $this->$key;
114
            }
115
        }
116 124
117
        return $output;
118 124
    }
119 124
120 124 View Code Duplication
    public function model(string $class, $data = null): ResourceInterface
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...
121
    {
122
        $model = new $class();
123 12
124
        // @codeCoverageIgnoreStart
125 12
        if (!$model instanceof ResourceInterface) {
126 12
            throw new \RuntimeException(sprintf('%s does not implement %s', $class, ResourceInterface::class));
127 12
        }
128 12
        // @codeCoverageIgnoreEnd
129
130 12
        if ($data instanceof ResponseInterface) {
131
            $model->populateFromResponse($data);
132
        } elseif (is_array($data)) {
133 131
            $model->populateFromArray($data);
134
        }
135 131
136
        return $model;
137 131
    }
138 3
139
    public function serialize(): \stdClass
140
    {
141 128
        $output = new \stdClass();
142 128
143 128
        foreach ((new \ReflectionClass($this))->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) {
144
            $name = $property->getName();
145
            $val = $this->{$name};
146
147
            $fn = function ($val) {
148
                return ($val instanceof Serializable) ? $val->serialize() : $val;
149
            };
150
151
            if (is_array($val)) {
152
                foreach ($val as $sk => $sv) {
153 65
                    $val[$sk] = $fn($sv);
154
                }
155 65
            }
156
157 65
            $output->{$name} = $fn($val);
158 65
        }
159 65
160 65
        return $output;
161 65
    }
162
}
163