Issues (12)

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/OAuth1/Provider/Atlassian.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
 * SocialConnect project
4
 * @author: Andreas Heigl https://github.com/heiglandreas <[email protected]>
5
 */
6
7
namespace SocialConnect\OAuth1\Provider;
8
9
use SocialConnect\Common\Http\Client\Client;
10
use SocialConnect\Common\Http\Client\ClientInterface;
11
use SocialConnect\OAuth1\Signature\MethodRSASHA1;
12
use SocialConnect\Provider\AccessTokenInterface;
13
use SocialConnect\Provider\Consumer;
14
use SocialConnect\Provider\Exception\InvalidResponse;
15
use SocialConnect\OAuth1\AbstractProvider;
16
use SocialConnect\Common\Entity\User;
17
use SocialConnect\Common\Hydrator\ObjectMap;
18
use SocialConnect\Provider\Session\SessionInterface;
19
20
class Atlassian extends AbstractProvider
21
{
22
    const NAME = 'atlassian';
23
24
    /**
25
     * @var string The Base-URI of the Atlassian instance
26
     */
27
    private $baseUri;
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function getBaseUri()
33
    {
34
        return $this->baseUri;
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function getAuthorizeUri()
41
    {
42
        return $this->getBaseUri() . '/plugins/servlet/oauth/authorize';
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function getRequestTokenUri()
49
    {
50
        return $this->getBaseUri() . '/plugins/servlet/oauth/request-token';
51
    }
52
53
    /**
54
     * @return string
55
     */
56
    public function getRequestTokenAccessUri()
57
    {
58
        return $this->getBaseUri() . '/plugins/servlet/oauth/access-token';
59
    }
60
61
62
    /**
63
     * {@inheritdoc}
64
     */
65
    public function getName()
66
    {
67
        return self::NAME;
68
    }
69
70
    /**
71
     * Atlassian constructor.
72
     *
73
     * Required configuration parameters are:
74
     *
75
     * * baseUri The base URI of your self-hosted atlassian product
76
     * * applicationSecret The path to the private key file used for signing.
77
     * * applicationId The ID shared with your Atlassian instance
78
     *
79
     * @param \SocialConnect\Common\Http\Client\ClientInterface $httpClient
80
     * @param \SocialConnect\Provider\Session\SessionInterface  $session
81
     * @param \SocialConnect\Provider\Consumer           $consumer
82
     * @param array                                             $parameters
83
     */
84 3
    public function __construct(ClientInterface $httpClient, SessionInterface $session, Consumer $consumer, array $parameters)
85
    {
86 3
        if (!isset($parameters['baseUri'])) {
87 1
            throw new \InvalidArgumentException('There is no "baseUri" given in the configuration');
88
        }
89 2
        $this->baseUri = $parameters['baseUri'];
90 2
        if (($lastSlash = strrpos($this->baseUri, '/')) == strlen($this->baseUri) - 1) {
91 1
            $this->baseUri = substr($this->baseUri, 0, $lastSlash);
92
        }
93
94 2
        parent::__construct($httpClient, $session, $consumer, $parameters);
95
96
        // needs to be set after calling the parent constructor as there the
97
        // signature is set as well.
98 2
        $this->signature = new MethodRSASHA1($consumer->getSecret());
99 2
    }
100
101
    /**
102
     * {@inheritdoc}
103
     */
104
    public function getIdentity(AccessTokenInterface $accessToken)
105
    {
106
        $this->consumerToken = $accessToken;
0 ignored issues
show
Documentation Bug introduced by Andreas Heigl
It seems like $accessToken of type object<SocialConnect\Pro...r\AccessTokenInterface> is incompatible with the declared type object<SocialConnect\OAuth1\Token> of property $consumerToken.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
107
108
        $parameters = [
109
            'oauth_consumer_key' => $this->consumer->getKey(),
110
            'oauth_token' => $this->consumerToken->getToken(),
111
        ];
112
113
        $response = $this->oauthRequest(
114
            $this->getBaseUri() . '/rest/prototype/1/user/current',
115
            Client::GET,
116
            $parameters
117
        );
118
119
        $redirectMax = 30;
120
        $redirectCount = 0;
121
        while ($response->hasHeader('Location')) {
122
            if ($redirectMax < $redirectCount++) {
123
                throw new \RangeException('Too many redirects');
124
            }
125
126
            $response = $this->oauthRequest(
127
                $response->getHeader('Location'),
128
                Client::GET,
129
                $parameters
130
            );
131
        }
132
133
        if (!$response->isSuccess()) {
134
            throw new InvalidResponse(
135
                'API response with error code',
136
                $response
137
            );
138
        }
139
140
        $result = $response->json();
141
        if (!$result) {
142
            throw new InvalidResponse(
143
                'API response is not a valid JSON object',
144
                $response
145
            );
146
        }
147
148
        if (!isset($result->name) || !$result->name) {
149
            throw new InvalidResponse(
150
                'API response without user inside JSON',
151
                $response
152
            );
153
        }
154
155
        $hydrator = new ObjectMap([
156
            'name' => 'username',
157
            'displayName' => 'fullname',
158
            'displayableEmail' => 'email',
159
        ]);
160
161
        return $hydrator->hydrate(new User(), $result);
162
    }
163
}
164