summaryrefslogtreecommitdiffstats
path: root/lib/private/installer.php
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-01-30 17:31:51 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2015-02-11 23:37:51 +0100
commit9ecb36e81f703c5e7aae36c046f441e03f27cbdb (patch)
tree0c69c92981bf5e9e84cec7062254e9935d626e58 /lib/private/installer.php
parentd74662df7df72ad9ec238b78223acc0e7f65311f (diff)
downloadnextcloud-server-9ecb36e81f703c5e7aae36c046f441e03f27cbdb.tar.gz
nextcloud-server-9ecb36e81f703c5e7aae36c046f441e03f27cbdb.zip
integrate code checker in the installer
Diffstat (limited to 'lib/private/installer.php')
-rw-r--r--lib/private/installer.php58
1 files changed, 8 insertions, 50 deletions
diff --git a/lib/private/installer.php b/lib/private/installer.php
index e77504f4c12..e50b5cea452 100644
--- a/lib/private/installer.php
+++ b/lib/private/installer.php
@@ -308,7 +308,7 @@ class OC_Installer{
}
$info=OC_App::getAppInfo($extractDir.'/appinfo/info.xml', true);
// check the code for not allowed calls
- if(!$isShipped && !OC_Installer::checkCode($info['id'], $extractDir)) {
+ if(!$isShipped && !OC_Installer::checkCode($extractDir)) {
OC_Helper::rmdirr($extractDir);
throw new \Exception($l->t("App can't be installed because of not allowed code in the App"));
}
@@ -529,58 +529,16 @@ class OC_Installer{
* @param string $folder the folder of the app to check
* @return boolean true for app is o.k. and false for app is not o.k.
*/
- public static function checkCode($appname, $folder) {
- $blacklist=array(
- // classes replaced by the public api
- 'OC_API::',
- 'OC_App::',
- 'OC_AppConfig::',
- 'OC_Avatar',
- 'OC_BackgroundJob::',
- 'OC_Config::',
- 'OC_DB::',
- 'OC_Files::',
- 'OC_Helper::',
- 'OC_Hook::',
- 'OC_Image::',
- 'OC_JSON::',
- 'OC_L10N::',
- 'OC_Log::',
- 'OC_Mail::',
- 'OC_Request::',
- 'OC_Response::',
- 'OC_Template::',
- 'OC_User::',
- 'OC_Util::',
- );
+ public static function checkCode($folder) {
// is the code checker enabled?
- if(OC_Config::getValue('appcodechecker', false)) {
- // check if grep is installed
- $grep = \OC_Helper::findBinaryPath('grep');
- if (!$grep) {
- OC_Log::write('core',
- 'grep not installed. So checking the code of the app "'.$appname.'" was not possible',
- OC_Log::ERROR);
- return true;
- }
-
- // iterate the bad patterns
- foreach($blacklist as $bl) {
- $cmd = 'grep --include \\*.php -ri '.escapeshellarg($bl).' '.$folder.'';
- $result = exec($cmd);
- // bad pattern found
- if($result<>'') {
- OC_Log::write('core',
- 'App "'.$appname.'" is using a not allowed call "'.$bl.'". Installation refused.',
- OC_Log::ERROR);
- return false;
- }
- }
- return true;
-
- }else{
+ if(!OC_Config::getValue('appcodechecker', false)) {
return true;
}
+
+ $codeChecker = new \OC\App\CodeChecker();
+ $errors = $codeChecker->analyseFolder($folder);
+
+ return empty($errors);
}
}