Issues (6)

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.

source/RuntimeContentBasedTemplate.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
 * @author stev leibelt <[email protected]>
4
 * @since: 2015-10-02
5
 */
6
namespace Net\Bazzline\Component\Template;
7
8
use InvalidArgumentException;
9
use RuntimeException;
10
11
class RuntimeContentBasedTemplate extends AbstractTemplate implements DelimiterInterface
12
{
13
    /** @var string */
14
    private $closingDelimiter;
15
16
    /** @var null|string */
17
    private $content;
18
19
    /** @var string */
20
    private $openingDelimiter;
21
22
    /**
23
     * @param array $variables
24
     * @param null|string $content
25
     * @param string $openingDelimiter
26
     * @param string $closingDelimiter
27
     * @throws InvalidArgumentException
28
     */
29
    public function __construct($variables = array(), $content = null, $openingDelimiter = '{', $closingDelimiter = '}')
30
    {
31
        parent::__construct($variables);
32
33
        $this->setPropertiesIfProvided($content, $closingDelimiter, $openingDelimiter);
0 ignored issues
show
It seems like $content defined by parameter $content on line 29 can also be of type string; however, Net\Bazzline\Component\T...tPropertiesIfProvided() does only seem to accept null, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
34
    }
35
36
    /**
37
     * @param array $variables
38
     * @param null|string $content
39
     * @param null|string $openingDelimiter
40
     * @param null|string $closingDelimiter
41
     * @return string
42
     * @throws InvalidArgumentException
43
     * @throws RuntimeException
44
     */
45
    public function __invoke($variables = array(), $content = null, $openingDelimiter = null, $closingDelimiter = null)
46
    {
47
        $this->setPropertiesIfProvided($content, $closingDelimiter, $openingDelimiter);
0 ignored issues
show
It seems like $content defined by parameter $content on line 45 can also be of type string; however, Net\Bazzline\Component\T...tPropertiesIfProvided() does only seem to accept null, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
48
49
        return parent::__invoke($variables);
50
    }
51
52
    /**
53
     * @param string $closingDelimiter
54
     */
55
    public function setClosingDelimiter($closingDelimiter)
56
    {
57
        $this->closingDelimiter = $closingDelimiter;
58
    }
59
60
    /**
61
     * @param string $content
62
     * @throws InvalidArgumentException
63
     */
64
    public function setContent($content)
65
    {
66
        $content = (string) $content;
67
68
        if (strlen($content) < 1) {
69
            throw new InvalidArgumentException(
70
                'content must have a string length of at least one character'
71
            );
72
        }
73
74
        $this->content = $content;
75
    }
76
77
    /**
78
     * @param string $openingDelimiter
79
     */
80
    public function setOpeningDelimiter($openingDelimiter)
81
    {
82
        $this->openingDelimiter = $openingDelimiter;
83
    }
84
85
    /**
86
     * @return string
87
     * @throws RuntimeException
88
     */
89
    protected function getContent()
90
    {
91
        if (is_null($this->content)) {
92
            throw new RuntimeException(
93
                'no content provided'
94
            );
95
        }
96
97
        return $this->content;
98
    }
99
100
    /**
101
     * @return array
102
     */
103 View Code Duplication
    protected function getVariables()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
104
    {
105
        $prefix     = $this->openingDelimiter;
106
        $suffix     = $this->closingDelimiter;
107
        $variables  = parent::getVariables();
108
        $array      = array();  //@todo find a better name
109
110
        foreach ($variables as $key => $value) {
111
            $array[$prefix . $key . $suffix] = $value;
112
        }
113
114
        return $array;
115
    }
116
117
    /**
118
     * @param null $content
119
     * @param null|string $closingDelimiter
120
     * @param null|string $openingDelimiter
121
     * @throws InvalidArgumentException
122
     */
123
    private function setPropertiesIfProvided($content = null, $closingDelimiter = null, $openingDelimiter = null)
124
    {
125
        if (!is_null($content)) {
126
            $this->setContent($content);
127
        }
128
129
        if (!is_null($closingDelimiter)) {
130
            $this->setClosingDelimiter($closingDelimiter);
131
        }
132
133
        if (!is_null($openingDelimiter)) {
134
            $this->setOpeningDelimiter($openingDelimiter);
135
        }
136
    }
137
}
138