Issues (3099)

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.

Command/GenerateDefaultSiteCommand.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 Kunstmaan\GeneratorBundle\Command;
4
5
use Kunstmaan\GeneratorBundle\Generator\DefaultSiteGenerator;
6
use Symfony\Component\Console\Input\ArrayInput;
7
use Symfony\Component\Console\Input\InputOption;
8
use Symfony\Component\Console\Output\ConsoleOutput;
9
10
/**
11
 * Generates a default website based on Kunstmaan bundles
12
 */
13
class GenerateDefaultSiteCommand extends KunstmaanGenerateCommand
14
{
15
    /**
16
     * @var BundleInterface
17
     */
18
    private $bundle;
19
20
    /**
21
     * @var string
22
     */
23
    private $prefix;
24
25
    /**
26
     * @var bool
27
     */
28
    private $demosite;
29
30
    /**
31
     * @see Command
32
     */
33
    protected function configure()
34
    {
35
        $this
36
            ->setHelp(<<<'EOT'
37
The <info>kuma:generate:site</info> command generates an website using the Kunstmaan bundles
38
39
<info>php bin/console kuma:generate:default-site --namespace=Namespace/NamedBundle</info>
40
41
Use the <info>--prefix</info> option to add a prefix to the table names of the generated entities
42
43
<info>php bin/console kuma:generate:default-site --namespace=Namespace/NamedBundle --prefix=demo_</info>
44
EOT
45
            )
46
            ->setDescription('Generates a basic website based on Kunstmaan bundles with default templates')
47
            ->addOption('namespace', '', InputOption::VALUE_OPTIONAL, 'The namespace to generate the default website in')
48
            ->addOption('prefix', '', InputOption::VALUE_OPTIONAL, 'The prefix to be used in the table names of the generated entities')
49
            ->addOption('demosite', '', InputOption::VALUE_NONE, 'Whether to generate a website with demo contents or a basic website')
50
            ->addOption('browsersync', '', InputOption::VALUE_OPTIONAL, 'The URI that will be used for browsersync to connect')
51
            ->addOption('articleoverviewpageparent', '', InputOption::VALUE_OPTIONAL, 'Shortnames of the pages that can have the article overview page as a child (comma separated)')
52
            ->setName('kuma:generate:default-site');
53
    }
54
55
    /**
56
     * {@inheritdoc}
57
     */
58
    protected function getWelcomeText()
59
    {
60
        return 'Welcome to the Kunstmaan default site generator';
61
    }
62
63
    /**
64
     * {@inheritdoc}
65
     */
66
    protected function doExecute()
67
    {
68
        $this->assistant->writeSection('Site generation');
69
        $this->assistant->writeLine(array("This command helps you to generate a default site setup.\n"));
70
71
        /**
72
         * Ask for which bundle we need to create the layout
73
         */
74
        $bundleNamespace = $this->assistant->getOptionOrDefault('namespace', null);
75
        $this->bundle = $this->askForBundleName('layout', $bundleNamespace);
76
77
        /*
78
         * Ask the database table prefix
79
         */
80
        $this->prefix = $this->askForPrefix(null, $this->bundle->getNamespace());
81
82
        /*
83
         * If we need to generate a full site, or only the basic structure
84
         */
85
        $this->demosite = $this->assistant->getOption('demosite');
86
87
        $browserSyncUrl = $this->assistant->getOptionOrDefault('browsersync', null);
88
89
        // First we generate the layout if it is not yet generated
90
        $command = $this->getApplication()->find('kuma:generate:layout');
91
        $arguments = array(
92
            'command' => 'kuma:generate:layout',
93
            '--namespace' => str_replace('\\', '/', $this->bundle->getNamespace()),
94
            '--demosite' => $this->demosite,
95
            '--browsersync' => $browserSyncUrl,
96
            '--subcommand' => true,
97
        );
98
        $input = new ArrayInput($arguments);
99
        $command->run($input, $this->assistant->getOutput());
100
101
        $rootDir = $this->getApplication()->getKernel()->getProjectDir().'/';
102
        $this->createGenerator()->generate($this->bundle, $this->prefix, $rootDir, $this->demosite);
103
104
        // Generate the default pageparts
105
        $command = $this->getApplication()->find('kuma:generate:default-pageparts');
106
        $arguments = array(
107
            'command' => 'kuma:generate:default-pageparts',
108
            '--namespace' => str_replace('\\', '/', $this->bundle->getNamespace()),
109
            '--prefix' => $this->prefix,
110
            '--contexts' => 'main',
111
            '--quiet' => true,
112
        );
113
        $output = new ConsoleOutput(ConsoleOutput::VERBOSITY_QUIET);
114
        $input = new ArrayInput($arguments);
115
        $command->run($input, $output);
116
        $this->assistant->writeLine('Generating default pageparts : <info>OK</info>');
117
118
        if ($this->demosite) {
119
            // Generate a blog
120
            $command = $this->getApplication()->find('kuma:generate:article');
121
            $pages = $this->assistant->getOptionOrDefault('articleoverviewpageparent', null);
122
            $arguments = array(
123
                'command' => 'kuma:generate:article',
124
                '--namespace' => str_replace('\\', '/', $this->bundle->getNamespace()),
125
                '--prefix' => $this->prefix,
126
                '--entity' => 'Blog',
127
                '--with-author' => true,
128
                '--with-category' => true,
129
                '--with-tag' => true,
130
                '--dummydata' => true,
131
                '--articleoverviewpageparent' => $pages,
132
            );
133
            $output = new ConsoleOutput(ConsoleOutput::VERBOSITY_NORMAL);
134
            $input = new ArrayInput($arguments);
135
            $command->run($input, $output);
136
137
            $this->assistant->writeLine('Generating blog : <info>OK</info>');
138
        }
139
140
        $this->assistant->writeSection('Site successfully created', 'bg=green;fg=black');
141
142
        return 0;
143
    }
144
145
    /**
146
     * {@inheritdoc}
147
     */
148
    protected function doInteract()
149
    {
150
    }
151
152
    /**
153
     * Get the generator.
154
     *
155
     * @return DefaultSiteGenerator
156
     */
157 View Code Duplication
    protected function createGenerator()
158
    {
159
        $filesystem = $this->getContainer()->get('filesystem');
160
        $registry = $this->getContainer()->get('doctrine');
161
162
        return new DefaultSiteGenerator($filesystem, $registry, '/defaultsite', $this->assistant, $this->getContainer());
0 ignored issues
show
$filesystem is of type object|null, but the function expects a object<Symfony\Component\Filesystem\Filesystem>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
$registry is of type object|null, but the function expects a object<Symfony\Bridge\Doctrine\RegistryInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
163
    }
164
}
165