Issues (5)

Security Analysis    no request data  

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.

src/Botonomous/AbstractConfig.php (1 issue)

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
namespace Botonomous;
4
5
use Botonomous\utility\ArrayUtility;
6
use Botonomous\utility\StringUtility;
7
8
/**
9
 * Class AbstractConfig.
10
 */
11
abstract class AbstractConfig
12
{
13
    protected static $configs;
14
15
    /**
16
     * @param       $key
17
     * @param array $replacements
18
     * @param null  $plugin
19
     *
20
     * @throws \Exception
21
     *
22
     * @return mixed
23
     */
24 108
    public function get(string $key, array $replacements = [], $plugin = null)
25
    {
26 108
        $configs = static::$configs;
27
28
        // overwrite $configs if $plugin is presented
29 108
        if ($plugin !== null) {
30
            try {
31 3
                $configs = $this->getPluginConfigs($plugin);
32 1
            } catch (\Exception $e) {
33 1
                throw $e;
34
            }
35
        }
36
37 107
        if (!array_key_exists($key, $configs)) {
38 1
            throw new BotonomousException("Key: '{$key}' does not exist in configs");
39
        }
40
41 106
        $found = $configs[$key];
42
43 106
        return (new StringUtility())->applyReplacements($found, $replacements);
44
    }
45
46
    /**
47
     * @param $plugin
48
     *
49
     * @throws \Exception
50
     *
51
     * @return self
0 ignored issues
show
Should the return type not be \self?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
52
     */
53 4
    private function getPluginConfigObject($plugin): self
54
    {
55 4
        $pluginConfigClass = __NAMESPACE__.'\\plugin\\'.strtolower($plugin)
56 4
            .'\\'.ucfirst($plugin).'Config';
57
58 4
        if (!class_exists($pluginConfigClass)) {
59 2
            throw new BotonomousException("Config file: '{$pluginConfigClass}.php' does not exist");
60
        }
61
62 2
        return new $pluginConfigClass();
63
    }
64
65
    /**
66
     * @param $plugin
67
     *
68
     * @throws \Exception
69
     *
70
     * @return array
71
     */
72 3
    public function getPluginConfigs($plugin)
73
    {
74
        try {
75 3
            return $this->getPluginConfigObject($plugin)->getConfigs();
76 1
        } catch (\Exception $e) {
77 1
            throw $e;
78
        }
79
    }
80
81
    /**
82
     * @return array
83
     */
84 2
    public function getConfigs(): array
85
    {
86 2
        return static::$configs;
87
    }
88
89
    /**
90
     * @param      $key
91
     * @param      $value
92
     * @param null $plugin
93
     *
94
     * @throws \Exception
95
     */
96 38
    public function set($key, $value, $plugin = null)
97
    {
98 38
        if ($plugin !== null) {
99
            try {
100 2
                $this->getPluginConfigObject($plugin)->set($key, $value);
101 1
            } catch (\Exception $e) {
102 1
                throw $e;
103
            }
104
        }
105
106 37
        is_array($key) ? (new ArrayUtility())->setNestedArrayValue(static::$configs, $key, $value)
107 20
            : static::$configs[$key] = $value;
108 37
    }
109
}
110