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/libraries/mabilis/Mabilis.class.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
/** * ************************************************
4
 * Image CMS Template Engine (Mabilis TPL)
5
 *
6
 * Simple template engine for Image CMS based on regular expressions search and replace.
7
 *
8
 * @author <[email protected]>
9
 * @version 0.3 PHP5
10
 * ************************************************ */
11
class Mabilis
12
{
13
14
    /**
15
     * @var Mabilis_Compiler
16
     */
17
    private $compiler;
18
19
    /**
20
     * @var Mabilis_Config
21
     */
22
    private $config;
23
24
    /**
25
     * Mabilis constructor.
26
     * @param array $config
27
     */
28
    public function __construct(&$config = []) {
29
30
        $this->load_config($config);
31
    }
32
33
    /**
34
     * Display or fetch template file
35
     * @param string $file
36
     * @param array $data
37
     * @param bool $return
38
     * @return string
0 ignored issues
show
Should the return type not be string|null?

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...
39
     */
40
    public function view($file, $data = [], $return = FALSE) {
41
42
        // Delete double .tpl.tpl
43
        //TODO remove this and find root of problem
44
        if (false !== strpos($file, '.tpl.tpl')) {
45
            $file = substr($file, 0, -4);
46
        }
47
48
        if (preg_match('/file:/', $file, $_Matches)) {
49
            $file_dir = preg_replace('/\/\//', '/', $file);
50
            $file_dir = preg_replace('/file\:/', '', $file_dir);
51
        } elseif (preg_match('/dir:/', $file, $_Matches)) {
52
            $file_dir = preg_replace('/\/\//', '/', $file);
53
            $file_dir = preg_replace('/dir\:/', '', $file_dir);
54
        } else {
55
            $file_dir = $this->config->tpl_path . $file;
56
        }
57
        $all_tpl_path = $this->config->tpl_path . 'shop/default/';
58
        //if (preg_match('/application\/modules/', $file_dir, $mm))
59
        if (strpos($file_dir, 'application\modules')) {
60
            $newFile = explode('application\modules', $file_dir);
61
            $new_file_dir = $all_tpl_path . 'modules' . $newFile[1];
62
63
            if (file_exists($new_file_dir)) {
64
                $file_dir = $new_file_dir;
65
            }
66
        }
67
68
        $compiled_file = $this->config->compile_path . md5($file_dir) . $this->config->compiled_ext;
69
70
        if (!file_exists($compiled_file) OR $this->config->force_compile == TRUE) {
71
            // Compile file
72
            $this->load_compiler();
73
            $this->compiler->compile($file_dir);
74
        }
75
76
        extract($data);
77
78
        ob_start();
79
80
        if (file_exists($compiled_file)) {
81
            include $compiled_file;
82
        } else {
83
            print '<p class="error">Error: ' . $compiled_file . ' does not exists!</p>';
84
        }
85
86
        // Time to live expried
87
        /* @var $mabilis_ttl integer */
88
        if ($mabilis_ttl <= time()) {
89
            @unlink($compiled_file);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
90
        }
91
92
        if ($this->config->use_filemtime == TRUE AND $mabilis_last_modified != @filemtime($file_dir)) {
93
            @unlink($compiled_file);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
94
        }
95
96
        if ($return == TRUE) {
97
            $buffer = ob_get_contents();
98
            ob_end_clean();
99
            return $buffer;
100
        }
101
102
        ob_end_flush();
103
    }
104
105
    /**
106
     * @param array $config
107
     * @return bool
108
     */
109
    public function load_config($config = []) {
110
111
        if (extension_loaded('zlib') AND $config['compress_output'] == TRUE) {
112
            if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) AND strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE) {
113
                ob_start('ob_gzhandler');
114
            }
115
        }
116
117
        if ($this->config == NULL) {
118
            include 'Config.class.php';
119
            $this->config = new Mabilis_Config($config);
120
        }
121
122
        return TRUE;
123
    }
124
125
    /**
126
     * @param string $param
127
     * @param string $value
128
     */
129
    public function set_config_value($param, $value) {
130
131
        $this->config->$param = $value;
132
    }
133
134
    /**
135
     * @param $param
136
     * @return mixed
137
     */
138
    public function get_config_value($param) {
139
140
        if (isset($this->config->$param)) {
141
            return $this->config->$param;
142
        }
143
    }
144
145
    /**
146
     * Load compiler class if not loaded yet
147
     */
148
    public function load_compiler() {
149
150
        if ($this->compiler == NULL) {
151
            include 'Mabilis.compiler.php';
152
            $this->compiler = new Mabilis_Compiler($this->config);
153
        }
154
155
        return TRUE;
156
    }
157
158
}
159
160
/* End of Mabilis.class.php */