This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
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'); |
||
0 ignored issues
–
show
|
|||
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()); |
||
163 | } |
||
164 | } |
||
165 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.