Issues (3)

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/Section.php (1 issue)

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
namespace Tuum\View;
3
4
class Section
5
{
6
    /**
7
     * do not render section if the section has this value.
8
     */
9
    const NO_SECTION_RENDER = false;
10
11
    /**
12
     * @var array
13
     */
14
    private $section_data = [];
15
16
    /**
17
     * @var int
18
     */
19
    private $ob_level = 0;
20
    
21
    /**
22
     * start capturing a section.
23
     */
24
    public function start()
25
    {
26
        $this->ob_level ++;
27
        ob_start();
28
    }
29
30
    /**
31
     * end capture with name.
32
     *
33
     * @param $name
34
     */
35
    public function saveAs($name)
36
    {
37
        $this->section_data[$name] = ob_get_clean();
38
        $this->ob_level--;
39
        if ($this->ob_level) {
40
            echo $this->section_data[$name];
41
        }
42
    }
43
44
    /**
45
     * get a captured section.
46
     *
47
     * @param string $name
48
     * @return string
49
     */
50
    public function get($name)
51
    {
52
        return array_key_exists($name, $this->section_data) ? $this->section_data[$name] : '';
53
    }
54
55
    /**
56
     * @param string       $name
57
     * @param string|mixed $data
58
     * @return $this
59
     */
60
    public function set($name, $data)
61
    {
62
        $this->section_data[$name] = $data;
63
64
        return $this;
65
    }
66
67
    /**
68
     * @param string $name
69
     */
70
    public function markNotToRender($name)
71
    {
72
        $this->section_data[$name] = self::NO_SECTION_RENDER;
73
    }
74
75
    /**
76
     * @param string $name
77
     * @return bool
78
     */
79
    public function exists($name)
0 ignored issues
show
The parameter $name is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
80
    {
81
        $names = func_get_args();
82
        foreach ($names as $name) {
83
            if (array_key_exists($name, $this->section_data)) {
84
                return true;
85
            }
86
        }
87
88
        return false;
89
    }
90
91
    /**
92
     * render the part of template as $name section.
93
     * will not render if the section is marked as NO_RENDER
94
     *
95
     * @param string $name
96
     */
97
    public function renderAs($name)
98
    {
99
        if ($this->get($name) !== self::NO_SECTION_RENDER) {
100
            echo ob_get_clean();
101
        } else {
102
            ob_end_clean();
103
        }
104
    }
105
106
    /**
107
     * render the part of a template only if section $name does not exist.
108
     *
109
     * @param string $name
110
     */
111
    public function replaceBy($name)
112
    {
113
        $content = $this->get($name);
114
        if ($content === self::NO_SECTION_RENDER) {
115
            ob_end_clean();
116
117
            return; // do not render anything.
118
        } elseif ($content) {
119
            ob_end_clean();
120
            echo $content;
121
        } else {
122
            echo ob_get_clean();
123
        }
124
    }
125
}