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 | * @author Nikita Melnikov <[email protected]> |
||
4 | * @link https://github.com/shogodev/argilla/ |
||
5 | * @copyright Copyright © 2003-2014 Shogo |
||
6 | * @license http://argilla.ru/LICENSE |
||
7 | * @package frontend.commands |
||
8 | */ |
||
9 | |||
10 | Yii::import('backend.components.*'); |
||
11 | Yii::import('backend.components.db.*'); |
||
12 | Yii::import('frontend.share.*'); |
||
13 | Yii::import('frontend.extensions.upload.*'); |
||
14 | Yii::import('frontend.extensions.upload.components.*'); |
||
15 | |||
16 | class ModuleCleanerCommand extends CConsoleCommand |
||
17 | { |
||
18 | /** |
||
19 | * Получение списка модулей |
||
20 | */ |
||
21 | public function actionList() |
||
22 | { |
||
23 | $path = Yii::getPathOfAlias('backend.modules'); |
||
24 | |||
25 | $directoryIterator = new DirectoryIterator($path); |
||
26 | |||
27 | echo '-----------------------------------'.PHP_EOL; |
||
28 | echo 'Modules:'.PHP_EOL; |
||
29 | echo '-----------------------------------'.PHP_EOL; |
||
30 | |||
31 | foreach( $directoryIterator as $fileInfo ) |
||
32 | { |
||
33 | /** |
||
34 | * @var DirectoryIterator $fileInfo |
||
35 | */ |
||
36 | if( $fileInfo->isDot() ) continue; |
||
37 | |||
38 | echo 'Name: '.$fileInfo->getFilename().'; Path:'; |
||
39 | echo $fileInfo->getRealPath().PHP_EOL; |
||
40 | echo '-----------------------------------'.PHP_EOL; |
||
41 | } |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * Полное удаление модуля |
||
46 | * Удаление всех таблиц моделей модуля |
||
47 | * Удаление директории |
||
48 | * |
||
49 | * @param string $module |
||
50 | * |
||
51 | * @return int |
||
52 | */ |
||
53 | public function actionDelete($module) |
||
54 | { |
||
55 | if( !$this->moduleExists($module) ) |
||
56 | { |
||
57 | echo 'Модуль '.$module.' не доступен '.PHP_EOL; |
||
58 | return 0; |
||
59 | } |
||
60 | elseif( $this->confirm('Вы действительно хотите удалить модуль '.$module) ) |
||
61 | { |
||
62 | Yii::import('backend.modules.'.$module.'.*'); |
||
63 | |||
64 | $moduleName = ucfirst($module).'Module'; |
||
65 | |||
66 | if( class_exists($moduleName) === false ) |
||
67 | { |
||
68 | echo 'Класс модуля '.$moduleName.' не существует'.PHP_EOL; |
||
69 | return 0; |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * @var BModule $moduleClass |
||
74 | */ |
||
75 | $moduleClass = new $moduleName($module, null); |
||
76 | foreach( $moduleClass->moduleDependencies as $dependency ) |
||
77 | { |
||
78 | if( $this->moduleExists($dependency) ) |
||
79 | { |
||
80 | echo 'Невозможно удалить модуль, так как он зависит от '.$dependency.PHP_EOL; |
||
81 | return 0; |
||
82 | } |
||
83 | } |
||
84 | |||
85 | $this->clearDb($module); |
||
86 | $this->deleteModuleDirectory($module); |
||
87 | } |
||
88 | else |
||
89 | return 0; |
||
90 | } |
||
91 | |||
92 | /** |
||
93 | * Проверка на существование модуля |
||
94 | * |
||
95 | * @param string $module |
||
96 | * |
||
97 | * @return bool |
||
98 | */ |
||
99 | protected function moduleExists($module) |
||
100 | { |
||
101 | $path = Yii::getPathOfAlias('backend.modules'); |
||
102 | $modulePath = $path.DIRECTORY_SEPARATOR.$module; |
||
103 | |||
104 | return file_exists($modulePath) && is_dir($modulePath); |
||
105 | } |
||
106 | |||
107 | protected function clearDb($module) |
||
108 | { |
||
109 | Yii::import('backend.modules.'.$module.'.models.*'); |
||
110 | $path = Yii::getPathOfAlias('backend.modules.'.$module.'.models'); |
||
111 | |||
112 | $db = Yii::app()->db; |
||
113 | $db->createCommand('SET foreign_key_checks = 0')->execute(); |
||
114 | |||
115 | foreach( CFileHelper::findFiles($path) as $modelFile ) |
||
116 | { |
||
117 | $classPathParts = explode('/', $modelFile); |
||
118 | $classFile = end($classPathParts); |
||
119 | $classFileParts = explode('.', $classFile); |
||
120 | $className = $classFileParts[0]; |
||
121 | |||
122 | echo 'Найдена модель '.$className.PHP_EOL; |
||
123 | |||
124 | /** |
||
125 | * @var BActiveRecord $model |
||
126 | */ |
||
127 | $model = new $className(); |
||
128 | $table = $model->tableName(); |
||
129 | |||
130 | if( $this->confirm('Вы действительно хотите удалить таблицу '.$table.'?') ) |
||
131 | $db->createCommand()->dropTable($table); |
||
132 | } |
||
133 | |||
134 | $db->createCommand('SET foreign_key_checks = 1')->execute(); |
||
135 | } |
||
136 | |||
137 | /** |
||
138 | * @param string $module |
||
139 | * |
||
140 | * @return bool |
||
141 | */ |
||
142 | protected function deleteModuleDirectory($module) |
||
143 | { |
||
144 | $basePath = Yii::getPathOfAlias('backend.modules.'.$module); |
||
145 | $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($basePath), |
||
146 | RecursiveIteratorIterator::CHILD_FIRST); |
||
147 | $pathInfo = new SplFileInfo($basePath); |
||
148 | |||
149 | echo '-----------------------------------'.PHP_EOL; |
||
150 | |||
151 | if( !$pathInfo->isWritable() ) |
||
152 | { |
||
153 | echo 'Невозможно удалить модуль '.$module.'. Нет прав на запись'.PHP_EOL; |
||
154 | return false; |
||
155 | } |
||
156 | |||
157 | foreach( $iterator as $path ) |
||
158 | { |
||
159 | /** |
||
160 | * @var SplFileInfo $path |
||
161 | */ |
||
162 | $pathName = $path->__toString(); |
||
0 ignored issues
–
show
|
|||
163 | |||
164 | if( $path->isDir() ) |
||
165 | { |
||
166 | if( $path->getFilename() === '.' || $path->getFilename() === '..' ) |
||
167 | continue; |
||
168 | |||
169 | rmdir($pathName); |
||
170 | } |
||
171 | else |
||
172 | unlink($pathName); |
||
173 | |||
174 | echo 'Удалено: '.$pathName.PHP_EOL; |
||
175 | } |
||
176 | |||
177 | rmdir($basePath); |
||
178 | |||
179 | echo '-----------------------------------'.PHP_EOL; |
||
180 | |||
181 | return true; |
||
182 | } |
||
183 | } |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.