From 92d809cfe82c4123cb9e1e83db58fe1dfdd7064d Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Wed, 21 Mar 2018 05:51:47 +0100 Subject: [PATCH] src: whitespace and style sweep --- src/etc/inc/plugins.inc.d/monit.inc | 53 ++++++++++--------- src/etc/inc/plugins.inc.d/squid.inc | 51 +++++++++--------- src/etc/inc/plugins.inc.d/suricata.inc | 51 +++++++++--------- .../OPNsense/Cron/Api/SettingsController.php | 6 ++- .../mvc/app/library/OPNsense/Auth/Local.php | 14 ++--- .../library/OPNsense/Backup/BackupFactory.php | 2 +- .../mvc/app/library/OPNsense/Backup/Base.php | 15 ++++-- .../app/library/OPNsense/Backup/GDrive.php | 24 +++++---- .../OPNsense/Base/FieldTypes/BaseField.php | 2 +- .../Base/FieldTypes/ModelRelationField.php | 8 +-- .../OPNsense/Monit/Migrations/M1_0_0.php | 6 +-- 11 files changed, 126 insertions(+), 106 deletions(-) diff --git a/src/etc/inc/plugins.inc.d/monit.inc b/src/etc/inc/plugins.inc.d/monit.inc index b8f1a5382..6c1540a1c 100644 --- a/src/etc/inc/plugins.inc.d/monit.inc +++ b/src/etc/inc/plugins.inc.d/monit.inc @@ -1,30 +1,30 @@ gettext('Monit System Monitoring'), 'configd' => array( diff --git a/src/etc/inc/plugins.inc.d/squid.inc b/src/etc/inc/plugins.inc.d/squid.inc index 0d3f96679..4f235ac98 100644 --- a/src/etc/inc/plugins.inc.d/squid.inc +++ b/src/etc/inc/plugins.inc.d/squid.inc @@ -1,30 +1,30 @@ gettext('Web Proxy'), 'configd' => array( diff --git a/src/etc/inc/plugins.inc.d/suricata.inc b/src/etc/inc/plugins.inc.d/suricata.inc index f7c016f8f..85b47aa38 100644 --- a/src/etc/inc/plugins.inc.d/suricata.inc +++ b/src/etc/inc/plugins.inc.d/suricata.inc @@ -1,30 +1,30 @@ gettext('Intrusion Detection'), 'configd' => array( diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Cron/Api/SettingsController.php b/src/opnsense/mvc/app/controllers/OPNsense/Cron/Api/SettingsController.php index eba3c8390..4aaa594c9 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Cron/Api/SettingsController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Cron/Api/SettingsController.php @@ -76,9 +76,11 @@ class SettingsController extends ApiMutableModelControllerBase "another service, command and parameter may not be changed."); } if ($jobInfo["parameters"] != (string)$node->parameters) { - $result["validations"]["job.parameters"] = sprintf(gettext("This item has been created by " . + $result["validations"]["job.parameters"] = sprintf( + gettext("This item has been created by " . "another service, command and parameter may not be changed. (was: %s)"), - (string)$node->parameters); + (string)$node->parameters + ); } } diff --git a/src/opnsense/mvc/app/library/OPNsense/Auth/Local.php b/src/opnsense/mvc/app/library/OPNsense/Auth/Local.php index c68d75b8e..f07283feb 100644 --- a/src/opnsense/mvc/app/library/OPNsense/Auth/Local.php +++ b/src/opnsense/mvc/app/library/OPNsense/Auth/Local.php @@ -78,15 +78,17 @@ class Local extends Base implements IAuthConnector if (!empty($configObj->system->webgui->enable_password_policy_constraints)) { if (!empty($configObj->system->webgui->password_policy_length)) { if (strlen($new_password) < $configObj->system->webgui->password_policy_length) { - $result[] = sprintf(gettext("Password must have at least %d characters"), - $configObj->system->webgui->password_policy_length); + $result[] = sprintf( + gettext("Password must have at least %d characters"), + $configObj->system->webgui->password_policy_length + ); } } if (!empty($configObj->system->webgui->password_policy_complexity)) { - $pwd_has_upper = preg_match_all('/[A-Z]/',$new_password, $o) > 0; - $pwd_has_lower = preg_match_all('/[a-z]/',$new_password, $o) > 0; - $pwd_has_number = preg_match_all('/[0-9]/',$new_password, $o) > 0; - $pwd_has_special = preg_match_all('/[!@#$%^&*()\-_=+{};:,<.>]/',$new_password, $o) > 0; + $pwd_has_upper = preg_match_all('/[A-Z]/', $new_password, $o) > 0; + $pwd_has_lower = preg_match_all('/[a-z]/', $new_password, $o) > 0; + $pwd_has_number = preg_match_all('/[0-9]/', $new_password, $o) > 0; + $pwd_has_special = preg_match_all('/[!@#$%^&*()\-_=+{};:,<.>]/', $new_password, $o) > 0; if ($old_password == $new_password) { // equal password is not allowed $result[] = gettext("Current password equals new password"); diff --git a/src/opnsense/mvc/app/library/OPNsense/Backup/BackupFactory.php b/src/opnsense/mvc/app/library/OPNsense/Backup/BackupFactory.php index 8d3ffddcc..122736827 100644 --- a/src/opnsense/mvc/app/library/OPNsense/Backup/BackupFactory.php +++ b/src/opnsense/mvc/app/library/OPNsense/Backup/BackupFactory.php @@ -78,4 +78,4 @@ class BackupFactory return null; } } -} \ No newline at end of file +} diff --git a/src/opnsense/mvc/app/library/OPNsense/Backup/Base.php b/src/opnsense/mvc/app/library/OPNsense/Backup/Base.php index d9e978ce1..a98f50eab 100644 --- a/src/opnsense/mvc/app/library/OPNsense/Backup/Base.php +++ b/src/opnsense/mvc/app/library/OPNsense/Backup/Base.php @@ -29,7 +29,6 @@ namespace OPNsense\Backup; - /** * Backup stub file, contains shared logic for all backup strategies * @package OPNsense\Backup @@ -48,8 +47,11 @@ abstract class Base @unlink($file); file_put_contents("{$file}.dec", $data); - exec(sprintf('/usr/local/bin/openssl enc -e -aes-256-cbc -in %s -out %s -pass pass:%s', - escapeshellarg("{$file}.dec"), escapeshellarg("{$file}.enc"), escapeshellarg($pass) + exec(sprintf( + '/usr/local/bin/openssl enc -e -aes-256-cbc -in %s -out %s -pass pass:%s', + escapeshellarg("{$file}.dec"), + escapeshellarg("{$file}.enc"), + escapeshellarg($pass) )); @unlink("{$file}.dec"); @@ -75,8 +77,11 @@ abstract class Base @unlink($file); file_put_contents("{$file}.dec", base64_decode($data)); - exec(sprintf('/usr/local/bin/openssl enc -d -aes-256-cbc -in %s -out %s -pass pass:%s', - escapeshellarg("{$file}.dec"), escapeshellarg("{$file}.enc"), escapeshellarg($pass) + exec(sprintf( + '/usr/local/bin/openssl enc -d -aes-256-cbc -in %s -out %s -pass pass:%s', + escapeshellarg("{$file}.dec"), + escapeshellarg("{$file}.enc"), + escapeshellarg($pass) )); @unlink("{$file}.dec"); diff --git a/src/opnsense/mvc/app/library/OPNsense/Backup/GDrive.php b/src/opnsense/mvc/app/library/OPNsense/Backup/GDrive.php index d073d373f..8ba535bfa 100644 --- a/src/opnsense/mvc/app/library/OPNsense/Backup/GDrive.php +++ b/src/opnsense/mvc/app/library/OPNsense/Backup/GDrive.php @@ -28,8 +28,8 @@ */ namespace OPNsense\Backup; -use OPNsense\Core\Config; +use OPNsense\Core\Config; /** * Class google drive backup @@ -126,8 +126,10 @@ class Gdrive extends Base implements IBackupProvider } try { $client = new \Google\API\Drive(); - $client->login((string)$config->system->remotebackup->GDriveEmail, - (string)$config->system->remotebackup->GDriveP12key); + $client->login( + (string)$config->system->remotebackup->GDriveEmail, + (string)$config->system->remotebackup->GDriveP12key + ); } catch (Exception $e) { syslog(LOG_ERR, "error connecting to Google Drive"); return array(); @@ -164,26 +166,30 @@ class Gdrive extends Base implements IBackupProvider $bck_data_enc = $client->download($configfiles[array_keys($configfiles)[0]]); if (strpos(substr($bck_data_enc, 0, 100), '---') !== false) { // base64 string is wrapped into tags - $start_at = strpos($bck_data_enc, "---\n") + 4 ; + $start_at = strpos($bck_data_enc, "---\n") + 4; $end_at = strpos($bck_data_enc, "\n---"); $bck_data_enc = substr($bck_data_enc, $start_at, ($end_at-$start_at)); } - $bck_data = $this->decrypt($bck_data_enc, - (string)$config->system->remotebackup->GDrivePassword); + $bck_data = $this->decrypt( + $bck_data_enc, + (string)$config->system->remotebackup->GDrivePassword + ); if ($bck_data == $confdata) { $target_filename = null; } } catch (Exception $e) { syslog(LOG_ERR, "unable to download " . - $configfiles[array_keys($configfiles)[0]]->description . " from Google Drive (" . $e . ")" - ); + $configfiles[array_keys($configfiles)[0]]->description . " from Google Drive (" . $e . ")"); } } if (!is_null($target_filename)) { syslog(LOG_ERR, "backup configuration as " . $target_filename); try { $configfiles[$target_filename] = $client->upload( - (string)$config->system->remotebackup->GDriveFolderID, $target_filename, $confdata_enc); + (string)$config->system->remotebackup->GDriveFolderID, + $target_filename, + $confdata_enc + ); } catch (Exception $e) { syslog(LOG_ERR, "unable to upload " . $target_filename . " to Google Drive (" . $e . ")"); return array(); diff --git a/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/BaseField.php b/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/BaseField.php index 2448221b5..998547b80 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/BaseField.php +++ b/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/BaseField.php @@ -155,7 +155,7 @@ abstract class BaseField */ public function setParentModel(&$object) { - if (empty($this->internalParentModel)){ + if (empty($this->internalParentModel)) { // read only attribute, set from model $this->internalParentModel = $object; } diff --git a/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/ModelRelationField.php b/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/ModelRelationField.php index 569ea9ce2..c1a2bbd3f 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/ModelRelationField.php +++ b/src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/ModelRelationField.php @@ -60,12 +60,12 @@ class ModelRelationField extends BaseField /** * @var array|null model settings to use for validation */ - private $mdlStructure = null; + private $mdlStructure = null; /** * @var boolean selected options from the same model */ - private $internalOptionsFromThisModel = false; + private $internalOptionsFromThisModel = false; /** * @var string cache relations @@ -76,7 +76,7 @@ class ModelRelationField extends BaseField * load model option list * @param $force force option load if we already seen this model before */ - private function loadModelOptions($force=false) + private function loadModelOptions($force = false) { // only collect options once per source/filter combination, we use a static to save our unique option // combinations over the running application. @@ -106,7 +106,7 @@ class ModelRelationField extends BaseField $groups = array(); $searchItems = $modelObj->getNodeByReference($modelData['items']); - if (!empty($searchItems)){ + if (!empty($searchItems)) { foreach ($modelObj->getNodeByReference($modelData['items'])->__items as $node) { if (!isset($node->getAttributes()['uuid']) || $node->$displayKey == null) { continue; diff --git a/src/opnsense/mvc/app/models/OPNsense/Monit/Migrations/M1_0_0.php b/src/opnsense/mvc/app/models/OPNsense/Monit/Migrations/M1_0_0.php index d3f03caa9..8b0c1adac 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Monit/Migrations/M1_0_0.php +++ b/src/opnsense/mvc/app/models/OPNsense/Monit/Migrations/M1_0_0.php @@ -43,9 +43,9 @@ class M1_0_0 extends BaseModelMigration srand(); $model->general->httpdUsername = 'root'; $model->general->httpdPassword = substr( - str_shuffle(str_repeat('0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz', 32)), - rand(0, 16), - rand(17, 32) + str_shuffle(str_repeat('0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz', 32)), + rand(0, 16), + rand(17, 32) ); /* get number of cpus and calculate load average limits */