Issues (2)

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/Entity/Descriptor.php (2 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
 * This file is part of the adlogix/guzzle-atlassian-connect-middleware package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace Adlogix\GuzzleAtlassianConnect\Entity;
10
11
class Descriptor
12
{
13
    const SCOPE_NONE = "none";
14
    const SCOPE_READ = "read";
15
    const SCOPE_WRITE = "write";
16
    const SCOPE_DELETE = "delete";
17
    const SCOPE_ADMIN = "admin";
18
    const SCOPE_ACT_AS_USER = "act_a_user";
19
20
    const SCOPE_JIRA_PROJECT_ADMIN = "project_admin";
21
    const SCOPE_CONFLUENCE_SPACE_ADMIN = "space_admin";
22
23
    /**
24
     * @var array
25
     */
26
    private $descriptor = [
27
        'authentication' => [
28
            'type' => 'jwt'
29
        ],
30
        'scopes'         => []
31
    ];
32
33
34
    /**
35
     * Descriptor constructor.
36
     *
37
     * @param string $baseUrl
38
     * @param string $key
39
     */
40
    public function __construct($baseUrl, $key)
41
    {
42
        $this->descriptor['baseUrl'] = $baseUrl;
43
        $this->descriptor['key'] = $key;
44
    }
45
46
    /**
47
     * @param string $name
48
     *
49
     * @return $this
50
     */
51
    public function setName($name)
52
    {
53
        $this->descriptor["name"] = $name;
54
        return $this;
55
    }
56
57
    /**
58
     * @param string $description
59
     *
60
     * @return $this
61
     */
62
    public function setDescription($description)
63
    {
64
        $this->descriptor['description'] = $description;
65
        return $this;
66
    }
67
68
    /**
69
     * @param string $scope
70
     *
71
     * @return $this
72
     * @throws \Exception
73
     */
74 View Code Duplication
    public function addScope($scope)
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...
75
    {
76
        $this->validateScopeValue($scope);
77
78
        if (false !== $this->getScopeKey($scope)) {
79
            return $this;
80
        }
81
82
        $this->descriptor['scopes'][] = $scope;
83
        return $this;
84
    }
85
86
    /**
87
     * @param string $scope
88
     *
89
     * @return bool
90
     */
91
    private function validateScopeValue($scope)
92
    {
93
        switch ($scope) {
94
            case self::SCOPE_ACT_AS_USER:
95
            case self::SCOPE_ADMIN:
96
            case self::SCOPE_NONE:
97
            case self::SCOPE_READ:
98
            case self::SCOPE_WRITE:
99
            case self::SCOPE_DELETE:
100
            case self::SCOPE_JIRA_PROJECT_ADMIN:
101
            case self::SCOPE_CONFLUENCE_SPACE_ADMIN:
102
                return true;
103
        }
104
        throw new \InvalidArgumentException(sprintf("Unknown scope %s", $scope));
105
    }
106
107
    /**
108
     * @param $scope
109
     *
110
     * @return mixed
111
     */
112
    private function getScopeKey($scope)
113
    {
114
        $key = array_search($scope, $this->descriptor['scopes']);
115
        return $key;
116
    }
117
118
    /**
119
     * @param string $scope
120
     *
121
     * @return $this
122
     * @throws \Exception
123
     */
124 View Code Duplication
    public function removeScope($scope)
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...
125
    {
126
        $this->validateScopeValue($scope);
127
128
        $key = $this->getScopeKey($scope);
129
        if (false === $key) {
130
            return $this;
131
        }
132
133
        unset($this->descriptor['scopes'][$key]);
134
        return $this;
135
    }
136
137
    /**
138
     * @return array
139
     */
140
    public function getArray()
141
    {
142
        return $this->descriptor;
143
    }
144
145
    /**
146
     * @return string
147
     */
148
    public function getJson()
149
    {
150
        return json_encode($this->descriptor);
151
    }
152
153
    /**
154
     * @return $this
155
     */
156
    public function enableLicensing()
157
    {
158
        $this->descriptor['enableLicensing'] = true;
159
        return $this;
160
    }
161
162
    /**
163
     * @return $this
164
     */
165
    public function disableLicensing()
166
    {
167
        $this->descriptor['enableLicensing'] = false;
168
        return $this;
169
    }
170
171
    /**
172
     * @param int $version
173
     *
174
     * @return $this
175
     */
176
    public function setApiVersion($version)
177
    {
178
        $this->descriptor['apiVersion'] = $version;
179
        return $this;
180
    }
181
182
    /**
183
     * @param string $name
184
     * @param string $url
185
     *
186
     * @return $this
187
     */
188
    public function addLink($name, $url)
189
    {
190
        $this->descriptor['links'][$name] = $url;
191
        return $this;
192
    }
193
194
    /**
195
     * @param string $name
196
     *
197
     * @return $this
198
     */
199
    public function removeLink($name)
200
    {
201
        unset($this->descriptor['links'][$name]);
202
        return $this;
203
    }
204
205
    /**
206
     * @param string $name
207
     * @param string $url
208
     *
209
     * @return $this
210
     */
211
    public function setVendor($name, $url = '')
212
    {
213
        $this->descriptor['vendor'] = [
214
            'name' => $name,
215
            'url'  => $url
216
        ];
217
        return $this;
218
    }
219
220
    /**
221
     * @param string $installed
222
     * @param string $enabled
223
     * @param string $disabled
224
     * @param string $uninstalled
225
     *
226
     * @return $this
227
     */
228
    public function setLifecycleWebhooks($installed, $enabled, $disabled = null, $uninstalled = null)
229
    {
230
        $this->descriptor['lifecycle'] = [
231
            'installed' => $installed,
232
            'enabled'   => $enabled,
233
        ];
234
235
        if (null !== $disabled) {
236
            $this->descriptor['lifecycle']['disabled'] = $disabled;
237
        }
238
239
        if (null !== $uninstalled) {
240
            $this->descriptor['lifecycle']['uninstalled'] = $uninstalled;
241
        }
242
243
        return $this;
244
    }
245
246
    /**
247
     * @param string $name
248
     * @param array  $description
249
     *
250
     * @return $this
251
     */
252
    public function addModule($name, array $description)
253
    {
254
        if (!isset($this->descriptor['modules'])) {
255
            $this->descriptor['modules'] = [];
256
        }
257
        $this->descriptor['modules'][$name] = $description;
258
259
        return $this;
260
    }
261
262
    /**
263
     * @param string $name
264
     *
265
     * @return $this
266
     */
267
    public function removeModule($name)
268
    {
269
        unset($this->descriptor['modules'][$name]);
270
        return $this;
271
    }
272
}
273