Issues (199)

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/commands/JwtController.php (16 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
 * JwtController.php
4
 *
5
 * PHP version 5.6+
6
 *
7
 * @author Philippe Gaultier <[email protected]>
8
 * @copyright 2010-2017 Philippe Gaultier
9
 * @license http://www.sweelix.net/license license
10
 * @version 1.2.0
11
 * @link http://www.sweelix.net
12
 * @package sweelix\oauth2\server\commands
13
 */
14
15
namespace sweelix\oauth2\server\commands;
16
17
use yii\console\Controller;
18
use Yii;
19
use yii\console\ExitCode;
20
21
/**
22
 * Manage oauth jwts
23
 *
24
 * @author Philippe Gaultier <[email protected]>
25
 * @copyright 2010-2017 Philippe Gaultier
26
 * @license http://www.sweelix.net/license license
27
 * @version 1.2.0
28
 * @link http://www.sweelix.net
29
 * @package sweelix\oauth2\server\commands
30
 * @since 1.0.0
31
 */
32
class JwtController extends Controller
33
{
34
    public $clientId;
35
    public $subject;
36
37
    /**
38
     * @var string alias to public key file
39
     */
40
    public $publicKey;
41
42
    /**
43
     * @inheritdoc
44
     */
45
    public function options($actionID)
46
    {
47
        return [
48
            'clientId',
49
            'subject',
50
            'publicKey',
51
        ];
52
    }
53
54
    /**
55
     * Create new Oauth Jwt
56
     * @param string $clientId Should be clientId
57
     * @param string $subject
58
     * @param string $publicKey
59
     * @return int
60
     * @throws \yii\base\InvalidConfigException
61
     * @throws \yii\base\UnknownClassException
62
     * @since 1.0.0
63
     */
64
    public function actionCreate($clientId, $subject, $publicKey)
65
    {
66
        $jwt = Yii::createObject('sweelix\oauth2\server\interfaces\JwtModelInterface');
67
        /* @var \sweelix\oauth2\server\interfaces\JwtModelInterface $jwt */
68
        $jwt->clientId = $clientId;
0 ignored issues
show
Accessing clientId on the interface sweelix\oauth2\server\interfaces\JwtModelInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
69
        $jwt->subject = $subject;
0 ignored issues
show
Accessing subject on the interface sweelix\oauth2\server\interfaces\JwtModelInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
70
        if ($this->publicKey !== null) {
71
            $this->publicKey = Yii::getAlias($this->publicKey);
0 ignored issues
show
Documentation Bug introduced by
It seems like \Yii::getAlias($this->publicKey) can also be of type boolean. However, the property $publicKey is declared as type string. 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...
72
            if (file_exists($this->publicKey) === true) {
73
                $jwt->publicKey = file_get_contents($this->publicKey);
0 ignored issues
show
Accessing publicKey on the interface sweelix\oauth2\server\interfaces\JwtModelInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
74
            }
75
        } else {
76
            $jwt->publicKey = $publicKey;
0 ignored issues
show
Accessing publicKey on the interface sweelix\oauth2\server\interfaces\JwtModelInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
77
        }
78
        if ($jwt->save() === true) {
79
            $this->stdout('Jwt created :' . "\n");
80
            $this->stdout(' - id: ' . $jwt->id . "\n");
0 ignored issues
show
Accessing id on the interface sweelix\oauth2\server\interfaces\JwtModelInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
81
            $this->stdout(' - clientId: ' . $jwt->clientId . "\n");
0 ignored issues
show
Accessing clientId on the interface sweelix\oauth2\server\interfaces\JwtModelInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
82
            $this->stdout(' - subject: ' . $jwt->subject . "\n");
0 ignored issues
show
Accessing subject on the interface sweelix\oauth2\server\interfaces\JwtModelInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
83
            $this->stdout(' - publicKey: ' . $jwt->publicKey . "\n");
0 ignored issues
show
Accessing publicKey on the interface sweelix\oauth2\server\interfaces\JwtModelInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
84
            return ExitCode::OK;
85
        } else {
86
            $this->stdout('Jwt cannot be created.' . "\n");
87
            return ExitCode::UNSPECIFIED_ERROR;
88
        }
89
    }
90
91
    /**
92
     * Update Oauth jwt
93
     * @param string $id Jwt id
94
     * @return int
95
     * @throws \yii\base\InvalidConfigException
96
     * @throws \yii\base\UnknownClassException
97
     */
98
    public function actionUpdate($id)
99
    {
100
        $jwt = Yii::createObject('sweelix\oauth2\server\interfaces\JwtModelInterface');
101
        $jwtClass = get_class($jwt);
102
        /* @var \sweelix\oauth2\server\interfaces\JwtModelInterface $jwt */
103
        $jwt = $jwtClass::findOne($id);
104
        if ($jwt !== null) {
105
            $jwt->clientId = $this->clientId;
0 ignored issues
show
Accessing clientId on the interface sweelix\oauth2\server\interfaces\JwtModelInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
106
            $jwt->subject = $this->subject;
0 ignored issues
show
Accessing subject on the interface sweelix\oauth2\server\interfaces\JwtModelInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
107
            $jwt->publicKey = $this->publicKey;
0 ignored issues
show
Accessing publicKey on the interface sweelix\oauth2\server\interfaces\JwtModelInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
108
            if ($jwt->save() === true) {
109
                $this->stdout('Jwt updated :' . "\n");
110
                $this->stdout(' - id: ' . $jwt->id . "\n");
0 ignored issues
show
Accessing id on the interface sweelix\oauth2\server\interfaces\JwtModelInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
111
                $this->stdout(' - clientId: ' . $jwt->clientId . "\n");
0 ignored issues
show
Accessing clientId on the interface sweelix\oauth2\server\interfaces\JwtModelInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
112
                $this->stdout(' - subject: ' . $jwt->subject . "\n");
0 ignored issues
show
Accessing subject on the interface sweelix\oauth2\server\interfaces\JwtModelInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
113
                $this->stdout(' - publicKey: ' . $jwt->publicKey . "\n");
0 ignored issues
show
Accessing publicKey on the interface sweelix\oauth2\server\interfaces\JwtModelInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
114
                return ExitCode::OK;
115
            } else {
116
                $this->stdout('Jwt ' . $id . ' cannot be updated' . "\n");
117
                return ExitCode::UNSPECIFIED_ERROR;
118
            }
119
        } else {
120
            $this->stdout('Jwt ' . $id . ' does not exist' . "\n");
121
            return ExitCode::UNSPECIFIED_ERROR;
122
        }
123
    }
124
125
    /**
126
     * Delete Oauth jwt
127
     * @param string $id Jwt id
128
     * @return int
129
     * @throws \yii\base\InvalidConfigException
130
     * @throws \yii\base\UnknownClassException
131
     */
132
    public function actionDelete($id)
133
    {
134
        $jwt = Yii::createObject('sweelix\oauth2\server\interfaces\JwtModelInterface');
135
        $jwtClass = get_class($jwt);
136
        /* @var \sweelix\oauth2\server\interfaces\JwtModelInterface $jwt */
137
        $jwt = $jwtClass::findOne($id);
138
        if ($jwt !== null) {
139
            if ($jwt->delete() === true) {
140
                $this->stdout('Jwt ' . $id . ' deleted' . "\n");
141
                return ExitCode::OK;
142
            } else {
143
                $this->stdout('Jwt ' . $id . ' cannot be deleted' . "\n");
144
                return ExitCode::UNSPECIFIED_ERROR;
145
            }
146
        } else {
147
            $this->stdout('Jwt ' . $id . ' does not exist' . "\n");
148
            return ExitCode::UNSPECIFIED_ERROR;
149
        }
150
    }
151
}
152