Issues (108)

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.

EventSubscriber/BlockFormTypeSubscriberTest.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 OpenOrchestra\FunctionalTests\BackofficeBundle\EventSubscriber;
4
5
use OpenOrchestra\FunctionalTests\Utils\AbstractAuthenticatedTest;
6
use OpenOrchestra\DisplayBundle\DisplayBlock\Strategies\ConfigurableContentStrategy;
7
use OpenOrchestra\DisplayBundle\DisplayBlock\Strategies\ContentListStrategy;
8
use OpenOrchestra\DisplayBundle\DisplayBlock\Strategies\VideoStrategy;
9
use OpenOrchestra\ModelBundle\Document\Block;
10
use OpenOrchestra\ModelInterface\Model\BlockInterface;
11
use Symfony\Component\Form\FormFactoryInterface;
12
use OpenOrchestra\ModelInterface\Repository\ReadContentRepositoryInterface;
13
use OpenOrchestra\ModelInterface\Repository\RepositoryTrait\KeywordableTraitInterface;
14
15
/**
16
 * Class BlockFormTypeSubscriberTest
17
 *
18
 * @group backofficeTest
19
 */
20
class BlockFormTypeSubscriberTest extends AbstractAuthenticatedTest
21
{
22
    /**
23
     * @var FormFactoryInterface
24
     */
25
    protected $formFactory;
26
    protected $keywords;
27
    protected $keywordRepository;
28
29
    /**
30
     * Set up the test
31
     */
32
    public function setUp()
33
    {
34
        parent::setUp();
35
        $this->keywordRepository = static::$kernel->getContainer()->get('open_orchestra_model.repository.keyword');
36
        $this->formFactory = static::$kernel->getContainer()->get('form.factory');
37
    }
38
39
    /**
40
     * Test video block : checkbox unique to uncheck
41
     */
42
    public function testVideoBlock()
43
    {
44
        $block = new Block();
45
        $block->setComponent(VideoStrategy::NAME);
46
        $block->addAttribute('videoType', 'youtube');
47
        $block->addAttribute('youtubeFs', true);
0 ignored issues
show
true is of type boolean, but the function expects a string.

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...
48
        $formType =  static::$kernel->getContainer()->get('open_orchestra_backoffice.generate_form_manager')->getFormType($block);
49
        $form = $this->formFactory->create($formType, $block, array('csrf_protection' => false));
50
51
        $form->submit(array(
52
            'style' => 'default',
53
            'videoType' => 'youtube',
54
            'youtubeVideoId' => 'videoId',
55
            'youtubeAutoplay' => true,
56
        ));
57
58
        $this->assertTrue($form->isSynchronized());
59
        /** @var BlockInterface $data */
60
        $data = $form->getConfig()->getData();
61
        $this->assertBlock($data);
62
        $this->assertSame('videoId', $data->getAttribute('youtubeVideoId'));
63
        $this->assertTrue($data->getAttribute('youtubeAutoplay'));
64
        $this->assertFalse($data->getAttribute('youtubeFs'));
65
    }
66
67
    /**
68
     * @param string $component
69
     * @param array  $value
70
     *
71
     * @dataProvider provideComponentAndData
72
     */
73
    public function testMultipleBlock($component, $value)
74
    {
75
        $block = new Block();
76
        $block->setComponent($component);
77
        $formType =  static::$kernel->getContainer()->get('open_orchestra_backoffice.generate_form_manager')->getFormType($block);
78
79
        $form = $this->formFactory->create($formType, $block, array('csrf_protection' => false));
80
81
        $submittedValue = array_merge(array('style' => 'default'), $value);
82
        $form->submit($submittedValue);
83
84
        $this->assertTrue($form->isSynchronized());
85
        /** @var BlockInterface $data */
86
        $data = $form->getConfig()->getData();
87
        $this->assertBlock($data);
88
        foreach ($value as $key => $sendData) {
89
            $this->assertSame($sendData, $data->getAttribute($key));
90
        }
91
    }
92
93
    /**
94
     * @return array
95
     */
96
    public function provideComponentAndData()
97
    {
98
        return array(
99
            array(ContentListStrategy::NAME, array(
100
                'contentNodeId' => 'root',
101
                'contentSearch' => array(
102
                  'contentType' => 'news',
103
                  'choiceType' => 'choice_and',
104
                  'keywords' => null,
105
                ),
106
                'characterNumber' => 150
107
            )),
108
            array(ConfigurableContentStrategy::NAME, array(
109
                'contentSearch' => array(
110
                    'contentType' => 'car',
111
                    'choiceType' => ReadContentRepositoryInterface::CHOICE_AND,
112
                    'keywords' => null,
113
                    'contentId' => null,
114
                )
115
            ))
116
        );
117
    }
118
119
    /**
120
     * @param string $component
121
     * @param array  $value
122
     *
123
     * @dataProvider provideComponentAndDataAndTransformedValue
124
     */
125
    public function testMultipleBlockWithDataTransformation($component, $value)
126
    {
127
        $block = new Block();
128
        $block->setComponent($component);
129
        $formType =  static::$kernel->getContainer()->get('open_orchestra_backoffice.generate_form_manager')->getFormType($block);
130
131
        $form = $this->formFactory->create($formType, $block, array('csrf_protection' => false));
132
        $submittedValue = array_merge(array('style' => 'default'), $value);
133
        $value['contentSearch']['keywords'] = $this->replaceKeywordLabelById($value['contentSearch']['keywords']);
134
        $form->submit($submittedValue);
135
136
        $this->assertTrue($form->isSynchronized());
137
        /** @var BlockInterface $data */
138
        $data = $form->getConfig()->getData();
139
        $this->assertBlock($data);
140
        foreach ($value as $key => $receivedData) {
141
            $this->assertSame($receivedData, $data->getAttribute($key));
142
        }
143
    }
144
145
    /**
146
     * @return array
147
     */
148
    public function provideComponentAndDataAndTransformedValue()
149
    {
150
        return array(
151
            array(ContentListStrategy::NAME, array(
152
                'contentNodeId' => 'root',
153
                'characterNumber' => 150,
154
                'contentSearch' => array(
155
                    'contentType' => 'news',
156
                    'choiceType' => ReadContentRepositoryInterface::CHOICE_AND,
157
                    'keywords' => 'lorem AND ipsum',
158
                    )
159
            )),
160
        );
161
    }
162
163
    /**
164
     * @param $data
165
     */
166
    protected function assertBlock($data)
167
    {
168
        $this->assertInstanceOf('OpenOrchestra\ModelInterface\Model\BlockInterface', $data);
169
        $this->assertSame('default', $data->getStyle());
170
    }
171
172
    /**
173
     * @param string $condition
174
     *
175
     * @return array
176
     */
177 View Code Duplication
    protected function replaceKeywordLabelById($condition)
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...
178
    {
179
        $conditionWithoutOperator = preg_replace(explode('|', KeywordableTraitInterface::OPERATOR_SPLIT), ' ', $condition);
180
        $conditionArray = explode(' ', $conditionWithoutOperator);
181
182
        foreach ($conditionArray as $keyword) {
183
            if ($keyword != '') {
184
                $keywordDocument = $this->keywordRepository->findOneByLabel($keyword);
185
                if (!is_null($keywordDocument)) {
186
                    $condition = str_replace($keyword, $keywordDocument->getId(), $condition);
187
                } else {
188
                    return '';
189
                }
190
            }
191
        }
192
193
        return $condition;
194
    }
195
}
196