Issues (21)

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/Fields/select.php (2 issues)

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
namespace Code4\Forms\Fields;
4
5
class select extends AbstractField {
6
7
    protected $_view = 'select';
8
    protected $_type = 'select';
9
10
    protected $options;
11
    protected $optionKeys;
12
13
    public function __construct($itemId, $config) {
14
15
        parent::__construct($itemId, $config);
16
17
        if (array_key_exists('options', $config)) {
18
            $this->options = $config['options'];
19
        }
20
21
        if (array_key_exists('option-keys', $config)) {
22
            $this->optionKeys = $config['option-keys'];
23
        }
24
25
        if (is_string($this->value)) {
26
            $this->value = [$this->value];
27
        }
28
    }
29
30
    /**
31
     * Sprawdzanie typu przesłanych opcji selecta
32
     * @param $options
33
     * @return $this|select
34
     */
35
    public function options($options) {
36
37
        switch(gettype($options)) {
38
            case "object":
39
                return $this->setOptionsFromObject($options);
40
                break;
0 ignored issues
show
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
41
            case "array":
42
                return $this->setOptionsFromArray($options);
43
                break;
0 ignored issues
show
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
44
            default:
45
                return $this;
46
        }
47
    }
48
49
    /**
50
     * Ustawiamy opcje selecta z pomocą dostarczonej tablicy
51
     * @param $array
52
     * @return $this
53
     */
54
    public function setOptionsFromArray($array) {
55
        $this->options = $array;
56
        return $this;
57
    }
58
59
    /**
60
     * Jeżeli przesłany został objekt (np. model Eloquent) to używając optionKeys wybieramy tylko potrzebne dane
61
     * @param $object
62
     * @return $this
63
     * @throws \Exception
64
     */
65
    public function setOptionsFromObject($object) {
66
67
        if (!is_array($this->optionKeys) || count($this->optionKeys) != 2) {
68
            throw new \Exception('Błędna opcja optionKeys dla elementu '.$this->id);
69
        }
70
71
        $value = $this->optionKeys[0];
72
        $text = $this->optionKeys[1];
73
74
        $options = [];
75
76
        foreach($object as $el) {
77
            $options[$el->$value] = $el->$text;
78
        }
79
80
        $this->options = $options;
81
82
        return $this;
83
    }
84
85
    /**
86
     * Metoda sprawdza czy w zapisanych wartościach znajduje się szukana
87
     * @param $val
88
     * @return string
89
     */
90
    public function getSelected($val) {
91
        if (is_array($this->value)) {
92
            if (in_array($val, $this->value)) {
93
                return "selected";
94
            }
95
        }
96
        return '';
97
    }
98
99
100
    /**
101
     * Ponieważ atrybut ma taką samą nazwę jak funkcja która ustawia opcje zwracamy je do widoku tą funkcją
102
     * @return mixed
103
     */
104
    public function getOptions() {
105
        return $this->options;
106
    }
107
108
}