mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-16 01:24:38 +00:00
src: whitespace and style sweep
This commit is contained in:
parent
2eb5ac913a
commit
92d809cfe8
@ -1,30 +1,30 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
Copyright (C) 2017 EURO-LOG AG
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
* Copyright (C) 2017 EURO-LOG AG
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* register service
|
||||
@ -33,8 +33,11 @@
|
||||
function monit_services()
|
||||
{
|
||||
global $config;
|
||||
|
||||
$services = array();
|
||||
if (isset($config['OPNsense']['monit']['general']['enabled']) && $config['OPNsense']['monit']['general']['enabled'] == 1) {
|
||||
|
||||
if (isset($config['OPNsense']['monit']['general']['enabled']) &&
|
||||
$config['OPNsense']['monit']['general']['enabled'] == 1) {
|
||||
$services[] = array(
|
||||
'description' => gettext('Monit System Monitoring'),
|
||||
'configd' => array(
|
||||
|
||||
@ -1,30 +1,30 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
Copyright (C) 2016 Deciso B.V.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
* Copyright (C) 2016 Deciso B.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
function squid_services()
|
||||
{
|
||||
@ -32,7 +32,8 @@ function squid_services()
|
||||
|
||||
$services = array();
|
||||
|
||||
if (isset($config['OPNsense']['proxy']['general']['enabled']) && $config['OPNsense']['proxy']['general']['enabled'] == 1) {
|
||||
if (isset($config['OPNsense']['proxy']['general']['enabled']) &&
|
||||
$config['OPNsense']['proxy']['general']['enabled'] == 1) {
|
||||
$services[] = array(
|
||||
'description' => gettext('Web Proxy'),
|
||||
'configd' => array(
|
||||
|
||||
@ -1,30 +1,30 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
Copyright (C) 2016 Deciso B.V.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
* Copyright (C) 2016 Deciso B.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
function suricata_services()
|
||||
{
|
||||
@ -32,7 +32,8 @@ function suricata_services()
|
||||
|
||||
$services = array();
|
||||
|
||||
if (isset($config['OPNsense']['IDS']['general']['enabled']) && $config['OPNsense']['IDS']['general']['enabled'] == 1) {
|
||||
if (isset($config['OPNsense']['IDS']['general']['enabled']) &&
|
||||
$config['OPNsense']['IDS']['general']['enabled'] == 1) {
|
||||
$services[] = array(
|
||||
'description' => gettext('Intrusion Detection'),
|
||||
'configd' => array(
|
||||
|
||||
@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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");
|
||||
|
||||
@ -78,4 +78,4 @@ class BackupFactory
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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");
|
||||
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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 */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user