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/ScopeController.php (11 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
 * ScopeController.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 scopes
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 ScopeController extends Controller
33
{
34
35
    public $isDefault = false;
36
    public $definition;
37
38
    /**
39
     * @inheritdoc
40
     */
41
    public function options($actionID)
42
    {
43
        return [
44
            // 'id',
45
            'isDefault',
46
            'definition',
47
        ];
48
    }
49
50
    /**
51
     * Create new Oauth scope
52
     * @param $id
53
     * @return int
54
     * @throws \yii\base\InvalidConfigException
55
     * @throws \yii\base\UnknownClassException
56
     * @since 1.0.0
57
     */
58
    public function actionCreate($id)
59
    {
60
        $scope = Yii::createObject('sweelix\oauth2\server\interfaces\ScopeModelInterface');
61
        /* @var \sweelix\oauth2\server\interfaces\ScopeModelInterface $scope */
62
        $scope->id = $id;
0 ignored issues
show
Accessing id on the interface sweelix\oauth2\server\in...ces\ScopeModelInterface 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...
63
        $scope->isDefault = (bool)$this->isDefault;
0 ignored issues
show
Accessing isDefault on the interface sweelix\oauth2\server\in...ces\ScopeModelInterface 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...
64
        $scope->definition = $this->definition;
0 ignored issues
show
Accessing definition on the interface sweelix\oauth2\server\in...ces\ScopeModelInterface 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...
65
        if ($scope->save() === true) {
66
            $this->stdout('Scope created :' . "\n");
67
            $this->stdout(' - id: ' . $scope->id . "\n");
0 ignored issues
show
Accessing id on the interface sweelix\oauth2\server\in...ces\ScopeModelInterface 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...
68
            $this->stdout(' - isDefault: ' . ($scope->isDefault ? 'Yes' : 'No') . "\n");
0 ignored issues
show
Accessing isDefault on the interface sweelix\oauth2\server\in...ces\ScopeModelInterface 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
            $this->stdout(' - definition: ' . $scope->definition . "\n");
0 ignored issues
show
Accessing definition on the interface sweelix\oauth2\server\in...ces\ScopeModelInterface 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
            return ExitCode::OK;
71
        } else {
72
            $this->stdout('Scope cannot be created.' . "\n");
73
            return ExitCode::UNSPECIFIED_ERROR;
74
        }
75
    }
76
77
    /**
78
     * Update Oauth Scope
79
     * @param $id
80
     * @return int
81
     * @throws \yii\base\InvalidConfigException
82
     * @throws \yii\base\UnknownClassException
83
     */
84
    public function actionUpdate($id)
85
    {
86
        $scope = Yii::createObject('sweelix\oauth2\server\interfaces\ScopeModelInterface');
87
        $scopeClass = get_class($scope);
88
        /* @var \sweelix\oauth2\server\interfaces\ScopeModelInterface $scope */
89
        $scope = $scopeClass::findOne($id);
90
        if ($scope !== null) {
91
            $scope->isDefault = $this->isDefault;
0 ignored issues
show
Accessing isDefault on the interface sweelix\oauth2\server\in...ces\ScopeModelInterface 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...
92
            $scope->definition = $this->definition;
0 ignored issues
show
Accessing definition on the interface sweelix\oauth2\server\in...ces\ScopeModelInterface 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...
93
            if ($scope->save() === true) {
94
                $this->stdout('Scope updated :' . "\n");
95
                $this->stdout(' - id: ' . $scope->id . "\n");
0 ignored issues
show
Accessing id on the interface sweelix\oauth2\server\in...ces\ScopeModelInterface 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...
96
                $this->stdout(' - isDefault: ' . ($scope->isDefault ? 'Yes' : 'No') . "\n");
0 ignored issues
show
Accessing isDefault on the interface sweelix\oauth2\server\in...ces\ScopeModelInterface 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...
97
                $this->stdout(' - definition: ' . $scope->definition . "\n");
0 ignored issues
show
Accessing definition on the interface sweelix\oauth2\server\in...ces\ScopeModelInterface 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...
98
                return ExitCode::OK;
99
            } else {
100
                $this->stdout('Scope ' . $id . ' cannot be updated' . "\n");
101
                return ExitCode::UNSPECIFIED_ERROR;
102
            }
103
        } else {
104
            $this->stdout('Scope ' . $id . ' does not exist' . "\n");
105
            return ExitCode::UNSPECIFIED_ERROR;
106
        }
107
    }
108
109
    /**
110
     * Delete Oauth Scope
111
     * @param $id
112
     * @return int
113
     * @throws \yii\base\InvalidConfigException
114
     * @throws \yii\base\UnknownClassException
115
     */
116
    public function actionDelete($id)
117
    {
118
        $scope = Yii::createObject('sweelix\oauth2\server\interfaces\ScopeModelInterface');
119
        $scopeClass = get_class($scope);
120
        /* @var \sweelix\oauth2\server\interfaces\ScopeModelInterface $scope */
121
        $scope = $scopeClass::findOne($id);
122
        if ($scope !== null) {
123
            if ($scope->delete() === true) {
124
                $this->stdout('Scope ' . $id . ' deleted' . "\n");
125
                return ExitCode::OK;
126
            } else {
127
                $this->stdout('Scope ' . $id . ' cannot be deleted' . "\n");
128
                return ExitCode::UNSPECIFIED_ERROR;
129
            }
130
        } else {
131
            $this->stdout('Scope ' . $id . ' does not exist' . "\n");
132
            return ExitCode::UNSPECIFIED_ERROR;
133
        }
134
    }
135
}