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/OAuth2/AccessToken.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: Patsura Dmitry https://github.com/ovr <[email protected]>
5
 */
6
7
namespace SocialConnect\OAuth2;
8
9
use SocialConnect\Provider\AccessTokenInterface;
10
use SocialConnect\Provider\Exception\InvalidAccessToken;
11
12
class AccessToken implements AccessTokenInterface
13
{
14
    /**
15
     * @var string
16
     */
17
    protected $token;
18
19
    /**
20
     * @var int|null
21
     */
22
    protected $expires;
23
24
    /**
25
     * @var integer|null
26
     */
27
    protected $uid;
28
29
    /**
30
     * @param array $token
31
     * @throws InvalidAccessToken
32
     */
33 70
    public function __construct(array $token)
34
    {
35 70
        if (!isset($token['access_token'])) {
36 1
            throw new InvalidAccessToken(
37 1
                'API returned data without access_token field'
38
            );
39
        }
40
41 69
        $this->token = $token['access_token'];
42
43
        // Show preference to 'expires_in' since it is defined in RFC6749 Section 5.1.
44
        // Defer to 'expires' if it is provided instead.
45 69
        if (isset($token['expires_in'])) {
46 1
            if (!is_numeric($token['expires_in'])) {
47
                throw new InvalidAccessToken('expires_in value must be an integer');
48
            }
49
50 1
            $this->expires = $token['expires_in'] != 0 ? time() + $token['expires_in'] : 0;
0 ignored issues
show
Documentation Bug introduced by ADmad
It seems like $token['expires_in'] != ...token['expires_in'] : 0 can also be of type double. However, the property $expires is declared as type integer|null. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
51 68
        } elseif (!empty($token['expires'])) {
52
            // Some providers supply the seconds until expiration rather than
53
            // the exact timestamp. Take a best guess at which we received.
54 1
            $expires = $token['expires'];
55 1
            if (!$this->isExpirationTimestamp($expires)) {
56
                $expires += time();
57
            }
58
59 1
            $this->expires = $expires;
60
        }
61
62 69
        if (isset($token['user_id'])) {
63 21
            $this->uid = $token['user_id'];
64
        }
65 69
    }
66
67
    /**
68
     * Check if a value is an expiration timestamp or second value.
69
     *
70
     * @param integer $value
71
     * @return bool
72
     */
73 1
    protected function isExpirationTimestamp($value)
74
    {
75
        // If the given value is larger than the original OAuth 2 draft date,
76
        // assume that it is meant to be a (possible expired) timestamp.
77 1
        $oauth2InceptionDate = 1349067600; // 2012-10-01
78 1
        return ($value > $oauth2InceptionDate);
79
    }
80
81
    /**
82
     * @return string
83
     */
84 69
    public function getToken()
85
    {
86 69
        return $this->token;
87
    }
88
89
    /**
90
     * @param int|null $uid
91
     */
92 3
    public function setUid($uid)
93
    {
94 3
        $this->uid = $uid;
95 3
    }
96
97
    /**
98
     * @return integer
99
     */
100 26
    public function getUserId()
101
    {
102 26
        return $this->uid;
103
    }
104
105
    /**
106
     * @return int|null
107
     */
108 3
    public function getExpires()
109
    {
110 3
        return $this->expires;
111
    }
112
}
113