Issues (131)

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.

Builder/BaseBuilder.php (1 issue)

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 Admingenerator\GeneratorBundle\Builder;
4
5
use Symfony\Component\Templating\TemplateNameParser;
6
use Symfony\Component\Config\FileLocator;
7
use Symfony\Bundle\FrameworkBundle\Templating\Loader\TemplateLocator;
8
use Symfony\Bundle\TwigBundle\Loader\FilesystemLoader;
9
use Symfony\Component\HttpFoundation\ParameterBag;
10
use TwigGenerator\Builder\BaseBuilder as GenericBaseBuilder;
11
use TwigGenerator\Builder\Generator as GenericBaseGenerator;
12
13
abstract class BaseBuilder extends GenericBaseBuilder
14
{
15
    /**
16
     * @var \Admingenerator\GeneratorBundle\Builder\Generator    The generator.
17
     */
18
    protected $generator;
19
20
    /**
21
     * @var array
22
     */
23
    protected $templatesToGenerate = array();
24
25
    /**
26
     * @var \Symfony\Component\HttpFoundation\ParameterBag
27
     */
28
    protected $variables;
29
30
    public function __construct()
31
    {
32
        parent::__construct();
33
        $this->variables = new ParameterBag(array());
34
        $this->twigFilters[] = '\\Doctrine\\Common\\Util\\Inflector::classify';
35
    }
36
37
    /**
38
     * Set files to generate
39
     *
40
     * @param array $templatesToGenerate (key => template file; value => output file name)
41
     */
42
    public function setTemplatesToGenerate(array $templatesToGenerate)
43
    {
44
        $this->templatesToGenerate = $templatesToGenerate;
45
    }
46
47
    /**
48
     * Add a file to generate
49
     *
50
     * @param string $template
51
     * @param string $outputName
52
     */
53
    public function addTemplateToGenerate($template, $outputName)
54
    {
55
        $this->templatesToGenerate[$template] = $outputName;
56
    }
57
58
    /**
59
     * Retrieve files to generate.
60
     *
61
     * @return array
62
     */
63
    public function getTemplatesToGenerate()
64
    {
65
        return $this->templatesToGenerate;
66
    }
67
68
    /**
69
     * Check if builder must generate multiple files
70
     * based on templatesToGenerate property.
71
     *
72
     * @return boolean
73
     */
74
    public function isMultiTemplatesBuilder()
75
    {
76
        $tmp = $this->getTemplatesToGenerate();
77
78
        return !empty($tmp);
79
    }
80
81
    /**
82
     * (non-PHPdoc)
83
     * @see \TwigGenerator\Builder\BaseBuilder::writeOnDisk()
84
     */
85
    public function writeOnDisk($outputDirectory)
86
    {
87
        if ($this->isMultiTemplatesBuilder()) {
88
            foreach ($this->getTemplatesToGenerate() as $templateName => $outputName) {
89
                $this->setOutputName($outputName);
90
                $this->setTemplateName($templateName);
91
                parent::writeOnDisk($outputDirectory);
92
            }
93
        } else {
94
            parent::writeOnDisk($outputDirectory);
95
        }
96
    }
97
98
    protected function getTwigEnvironment()
99
    {
100
        $locator = new TemplateLocator(new FileLocator($this->getTemplateDirs()));
101
        $templateNameParser = new TemplateNameParser();
102
        $loader = new FilesystemLoader($locator, $templateNameParser);
103
        $twig = new \Twig_Environment($loader, array(
0 ignored issues
show
Deprecated Code introduced by
The class Twig_Environment has been deprecated with message: since Twig 2.7, use "Twig\Environment" instead

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
104
            'autoescape' => false,
105
            'strict_variables' => true,
106
            'debug' => true,
107
            'cache' => $this->getGenerator()->getTempDir(),
108
        ));
109
110
        $this->loadTwigExtensions($twig);
111
        $this->loadTwigFilters($twig);
112
113
        return $twig;
114
    }
115
116
    /**
117
     * @return string the YamlKey
118
     */
119
    public function getYamlKey()
120
    {
121
        return $this->getSimpleClassName();
122
    }
123
124
    public function setVariables(array $variables)
125
    {
126
        $variables = new ParameterBag($variables);
127
        $this->variables = $variables;
128
    }
129
130
    /**
131
     * (non-PHPdoc)
132
     * @see Builder/Admingenerator\GeneratorBundle\Builder.BuilderInterface::getVariables()
133
     */
134
    public function getVariables()
135
    {
136
        return $this->variables->all();
137
    }
138
139
    /**
140
     * (non-PHPdoc)
141
     * @see Builder/Admingenerator\GeneratorBundle\Builder.BuilderInterface::hasVariable()
142
     * @param string $key
143
     * @return bool
144
     */
145
    public function hasVariable($key)
146
    {
147
        return $this->variables->has($key);
148
    }
149
150
    /**
151
     * (non-PHPdoc)
152
     * @see Builder/Admingenerator\GeneratorBundle\Builder.BuilderInterface::getVariable()
153
     */
154
    public function getVariable($key, $default = null, $deep = false)
155
    {
156
        return $this->variables->get($key, $default, $deep);
157
    }
158
159
    /**
160
     * Get model class from model param
161
     * @return string
162
     */
163
    public function getModelClass()
164
    {
165
        return $this->getSimpleClassName($this->getVariable('model'));
166
    }
167
168
    /**
169
     * Set the generator.
170
     *
171
     * @param \TwigGenerator\Builder\Generator $generator A generator.
172
     */
173
    public function setGenerator(GenericBaseGenerator $generator)
174
    {
175
        if (!$generator instanceof Generator) {
176
            throw new \LogicException(
177
                '$generator must be an instance of Admingenerator\GeneratorBundle\Builder\Generator, '
178
               .'other instances are not supported.'
179
            );
180
        }
181
182
        $this->generator = $generator;
183
    }
184
185
    /**
186
     * Return the generator.
187
     *
188
     * @return \Admingenerator\GeneratorBundle\Builder\Generator    The generator.
189
     */
190
    public function getGenerator()
191
    {
192
        return $this->generator;
193
    }
194
}
195