Issues (447)

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.

Twig/DataTableTwigExtension.php (2 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
namespace Knp\RadBundle\Twig;
4
5
class DataTableTwigExtension extends \Twig_Extension
6
{
7
8
    private $container;
9
10
    public function __construct($container)
11
    {
12
        $this->container = $container;
13
    }
14
15
    public function getFunctions()
16
    {
17
        return array(
18
            new \Twig_SimpleFunction('bootstrap_datatable', array($this, 'getDataTableRender'), array('is_safe' => array('html'))),
19
            new \Twig_SimpleFunction('bootstrap_datatable_row', array($this, 'getDataTableRowRender'), array('is_safe' => array('html'))),
20
        );
21
    }
22
23
    public function getFilters()
24
    {
25
        return array(
26
            new \Twig_SimpleFilter('toArray', array($this, 'toArrayFilter')),
27
            new \Twig_SimpleFilter('toHeadersArray', array($this, 'toHeadersFilter')),
28
        );
29
    }
30
31
    public function getDataTableRender($elements, $options = array())
32
    {
33
        $options = array_merge(array('bootstrap' => "Default"), $options);
34
35
        return $this
36
            ->container
37
            ->get('templating')
38
            ->render(
39
                'KnpRadBundle:Twig:Datatable/' . $options['bootstrap'] . '/datatable.html.twig',
40
                array('elements' => $elements, 'options' => $options)
41
            )
42
        ;
43
    }
44
45
    public function getDataTableRowRender($element, $headers, $options = array())
46
    {
47
        $options = array_merge(array('bootstrap' => "Default"), $options);
48
49
        $routes = isset($options['routes'])
50
            ? $options['routes']
51
            : array()
52
        ;
53
54
        return $this
55
            ->container
56
            ->get('templating')
57
            ->render(
58
                'KnpRadBundle:Twig:Datatable/' . $options['bootstrap'] . '/datatable_row.html.twig',
59
                array(
60
                    'element' => $element,
61
                    'headers' => $headers,
62
                    'options' => $options,
63
                    'routes'  => $routes
64
                )
65
            )
66
        ;
67
    }
68
69
    public function toHeadersFilter($els, $options = array ())
70
    {
71
72
        $fields = isset($options['fields'])
73
            ? $options['fields']
74
            : array()
75
        ;
76
77
        $headers = array();
78
79
        foreach ($els as $el) {
80
81
            if (is_object($el)) {
82
83
                foreach ($this->getGettersWithoutParameters($el) as $method) {
84
                    preg_match('#get(?P<name>.*)#', $method->name, $matches);
85
                    $name = strtolower($matches['name']);
86
                    if (!in_array($name, $headers) && (0 === count($fields) || array_key_exists($name, $fields))) {
87
                        $headers[$name] = array_key_exists($name, $fields)
88
                            ? $fields[$name]
89
                            : $name
90
                        ;
91
                    }
92
                }
93
94
            } elseif (is_array($el)) {
0 ignored issues
show
Blank line found at start of control structure
Loading history...
95
96
                foreach ($el as $key => $value) {
97
                    if (!in_array($key, $headers) && (0 === count($fields) || array_key_exists($key, $fields))) {
98
                        $headers[$key] = array_key_exists($key, $fields)
99
                            ? $fields[$key]
100
                            : $key
101
                        ;
102
                    }
103
                }
104
105
            }
106
107
        }
108
109
        return $headers;
110
111
    }
112
113
    public function toArrayFilter($el, $options = array ())
114
    {
115
116
        $fields = isset($options['fields'])
117
            ? $options['fields']
118
            : array()
119
        ;
120
121
        $values = array();
122
123
        if (is_object($el)) {
124
125
            foreach ($this->getGettersWithoutParameters($el) as $method) {
126
                preg_match('#get(?P<name>.*)#', $method->name, $matches);
127
128
                $name = strtolower($matches['name']);
129
                if (0 === count($fields) || array_key_exists($name, $fields)) {
130
                    $value = $el->{$method->name}();
131
                    if (!is_object($value) && !is_array($value)) {
132
                        $values[$name] = $value;
133
                    }
134
                }
135
            }
136
137
        } elseif (is_array($el)) {
0 ignored issues
show
Blank line found at start of control structure
Loading history...
138
139
            foreach ($el as $key => $value) {
140
                if (!is_object($value) && !is_array($value)) {
141
                    $values[$key] = $value;
142
                }
143
            }
144
145
        }
146
147
        return $values;
148
    }
149
150
    public function getGettersWithoutParameters($el)
151
    {
152
        $rfl = new \ReflectionClass($el);
153
154
        return array_filter(
155
            $rfl->getMethods(\ReflectionMethod::IS_PUBLIC),
156
            function ($method) {
157
                return preg_match('#get.*#', $method->name) && 0 === count($method->getParameters());
158
            }
159
160
        );
161
    }
162
163
    public function getName()
164
    {
165
        return 'knp_rad.twig.datatable';
166
    }
167
168
}
169