Issues (1177)

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.

application/modules/feedback/feedback.php (3 issues)

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
use cmsemail\email;
4
5
if (!defined('BASEPATH')) {
6
    exit('No direct script access allowed');
7
}
8
9
/**
10
 * Image CMS
11
 *
12
 * Feedback module
13
 */
14
class Feedback extends MY_Controller
15
{
16
17
    public $username_max_len = 30;
18
19
    public $message_max_len = 600;
20
21
    public $theme_max_len = 150;
22
23
    public $admin_mail = 'admin@localhost';
24
25
    public $message = '';
26
27
    protected $formErrors = [];
28
29
    public function __construct() {
30
        parent::__construct();
31
        $this->load->module('core');
32
        $this->load_settings();
33
34
        $this->formErrors = [
35
                             'required'    => lang('Field is required'),
36
                             'min_length'  => lang('Length is less than the minimum'),
37
                             'valid_email' => lang('Email is not valid'),
38
                             'max_length'  => lang('Length greater than the maximum'),
39
                            ];
40
        $lang = new MY_Lang();
41
        $lang->load('feedback');
42
    }
43
44
    public function autoload() {
45
46
    }
47
48
    public function captcha_check($code) {
49
        if (!$this->dx_auth->captcha_check($code)) {
0 ignored issues
show
The if-else statement can be simplified to return (bool) $this->dx_...->captcha_check($code);.
Loading history...
50
            return FALSE;
51
        } else {
52
            return TRUE;
53
        }
54
    }
55
56 View Code Duplication
    public function recaptcha_check() {
57
        $result = $this->dx_auth->is_recaptcha_match();
58
        if (!$result) {
59
            $this->form_validation->set_message('recaptcha_check', lang('Improper protection code', 'feedback'));
60
        }
61
62
        return $result;
63
    }
64
65
    // Index function
66
67
    public function index() {
68
        $this->template->registerMeta('ROBOTS', 'NOINDEX, NOFOLLOW');
69
70
        $this->core->set_meta_tags(lang('Feedback', 'feedback'));
71
72
        $this->load->library('form_validation');
73
74
        // Create captcha
75
        $this->dx_auth->captcha();
76
        $tpl_data['cap_image'] = $this->dx_auth->get_captcha_image();
0 ignored issues
show
Coding Style Comprehensibility introduced by
$tpl_data was never initialized. Although not strictly required by PHP, it is generally a good practice to add $tpl_data = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
77
78
        $this->template->add_array($tpl_data);
79
80
        if (count($this->input->post()) > 0) {
81
            $this->form_validation->set_rules('name', lang('Your name', 'feedback'), 'trim|required|min_length[3]|max_length[' . $this->username_max_len . ']|xss_clean');
82
            $this->form_validation->set_rules('email', lang('Email', 'feedback'), 'trim|required|valid_email|xss_clean');
83
            $this->form_validation->set_rules('theme', lang('Subject', 'feedback'), 'trim|max_length[' . $this->theme_max_len . ']|xss_clean');
84
            $this->form_validation->set_rules('message', lang('Message', 'feedback'), 'trim|required|max_length[' . $this->message_max_len . ']|xss_clean');
85
86 View Code Duplication
            if ($this->dx_auth->use_recaptcha) {
87
                $this->form_validation->set_rules('recaptcha_response_field', lang('Protection code', 'feedback'), 'trim|xss_clean|required|callback_recaptcha_check');
88
            } else {
89
                $this->form_validation->set_rules('captcha', lang('Protection code', 'feedback'), 'trim|required|xss_clean|callback_captcha_check');
90
            }
91
92
            if ($this->form_validation->run($this) == FALSE) { // there are errors
93
                $this->form_validation->set_error_delimiters('', '');
94
                CMSFactory\assetManager::create()->setData('validation', $this->form_validation);
95
                form_error();
96
            } else { // form is validate
97
98
                $feedback_variables = [
99
                                       'Theme'       => $this->input->post('theme'),
100
                                       'userName'    => $this->input->post('name'),
101
                                       'userEmail'   => $this->input->post('email'),
102
                                       'userMessage' => $this->input->post('message'),
103
                                      ];
104
                 email::getInstance()->sendEmail($this->input->post('email'), 'feedback', $feedback_variables);
105
                CMSFactory\assetManager::create()->appendData('message_sent', TRUE);
0 ignored issues
show
TRUE is of type boolean, but the function expects a string|integer|double.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
106
107
            }
108
        }
109
110
        CMSFactory\assetManager::create()->render('feedback');
111
    }
112
113
    private function load_settings() {
114
        $this->db->limit(1);
115
        $this->db->where('name', 'feedback');
116
        $query = $this->db->get('components')->row_array();
117
118
        $settings = unserialize($query['settings']);
119
120
        if (is_int($settings['message_max_len'])) {
121
            $this->message_max_len = $settings['message_max_len'];
122
        }
123
124
        if ($settings['email']) {
125
            $this->admin_mail = $settings['email'];
126
        }
127
    }
128
129
}
130
131
/* End of file sample_module.php */