pgaultier /
yii2-oauth2
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
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
|
|||
| 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
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
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
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
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
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
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
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
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
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
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 | } |
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: