Issues (111)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

app/Console/Commands/MigrateSettings.php (4 issues)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * MigrateSettings.php
4
 *
5
 * Command line to migrate settings from LibreNMS v1
6
 *
7
 * This program is free software: you can redistribute it and/or modify
8
 * it under the terms of the GNU General Public License as published by
9
 * the Free Software Foundation, either version 3 of the License, or
10
 * (at your option) any later version.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
15
 * GNU General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU General Public License
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 *
20
 * @package    LibreNMS
21
 * @link       http://librenms.org
22
 * @copyright  2016 Tony Murray
23
 * @author     Tony Murray <[email protected]>
24
 */
25
26
namespace App\Console\Commands;
27
28
use App\Models\DbConfig;
29
use Config;
30
use Illuminate\Console\Command;
31
use Settings;
32
33
class MigrateSettings extends Command
34
{
35
    /**
36
     * The name and signature of the console command.
37
     *
38
     * @var string
39
     */
40
    protected $signature = 'librenms:migrate-settings
41
    {--force} : Force the migration. WARNING: May lose some of your settings.
42
    {--dry-run} : Print changes that would be made, but do not commit them.';
43
44
    /**
45
     * The console command description.
46
     *
47
     * @var string
48
     */
49
    protected $description = 'Import settings from config.php that existed in the database previously into the database.  (The database now overrides config.php)';
50
51
    /**
52
     * Create a new command instance.
53
     */
54 87
    public function __construct()
55
    {
56 87
        parent::__construct();
57 87
    }
58
59
    /**
60
     * Execute the console command.
61
     *
62
     * @return mixed
63
     */
64 5
    public function handle()
65
    {
66 5
        if (Settings::get('settings.migrated')) {
67 2
            $this->info(trans('commands.migrate-settings.migrated'));
0 ignored issues
show
It seems like trans('commands.migrate-settings.migrated') targeting trans() can also be of type object<Illuminate\Contra...Translation\Translator>; however, Illuminate\Console\Command::info() does only seem to accept string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
68 2
            if (!$this->option('force')) {
69 1
                return;
70
            }
71 1
            $this->warn(trans('commands.migrate-settings.migrated_warning'));
0 ignored issues
show
It seems like trans('commands.migrate-...ings.migrated_warning') targeting trans() can also be of type object<Illuminate\Contra...Translation\Translator>; however, Illuminate\Console\Command::warn() does only seem to accept string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
72
        }
73
74 5
        $settings = DbConfig::pluck('config_name');
75
76 5
        foreach ($settings as $key) {
77 3
            $config_key = '_config.'.$key;
78
79 3
            if (Config::has($config_key)) {
80 2
                $old = Settings::get($key);
81 2
                $new = Config::get($config_key);
82
83 2
                if ($old !== $new) {
84 2
                    $this->info(trans('commands.migrate-settings.migrating', ['setting' => $key, 'old' => $old, 'new' => $new]));
0 ignored issues
show
It seems like trans('commands.migrate-...> $old, 'new' => $new)) targeting trans() can also be of type object<Illuminate\Contra...Translation\Translator>; however, Illuminate\Console\Command::info() does only seem to accept string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
85
86 2
                    if (!$this->option('dry-run')) {
87
                        // we aren't authenticated so we can't write through the Settings facade
88 3
                        DbConfig::updateOrCreate(['config_name' => $key], ['config_value' => $new]);
89
                    }
90
                }
91
            }
92
        }
93
94 5
        if ($this->option('dry-run')) {
95 1
            $this->warn(trans('commands.migrate-settings.nochanges'));
0 ignored issues
show
It seems like trans('commands.migrate-settings.nochanges') targeting trans() can also be of type object<Illuminate\Contra...Translation\Translator>; however, Illuminate\Console\Command::warn() does only seem to accept string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
96
        } else {
97 4
            Settings::flush(); // clear the settings cache
98 4
            DbConfig::updateOrCreate(['config_name' => 'settings.migrated'], ['config_value' => true]);
99
        }
100 5
    }
101
}
102