Issues (27)

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.

Tests/Entity/PageTest.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
/*
4
* This file is part of the OrbitaleCmsBundle package.
5
*
6
* (c) Alexandre Rock Ancelet <[email protected]>
7
*
8
* For the full copyright and license information, please view the LICENSE
9
* file that was distributed with this source code.
10
*/
11
12
namespace Orbitale\Bundle\CmsBundle\Tests\Entity;
13
14
use Doctrine\ORM\EntityManager;
15
use Orbitale\Bundle\CmsBundle\Tests\Fixtures\AbstractTestCase;
16
use Orbitale\Bundle\CmsBundle\Tests\Fixtures\TestBundle\Entity\Page;
17
18
class PageTest extends AbstractTestCase
19
{
20
    public function getDummyPage(): Page
21
    {
22
        $page = new Page();
23
24
        $page
25
            ->setHomepage(true)
26
            ->setSlug('home')
27
            ->setTitle('My homepage')
28
            ->setHost('localhost')
29
            ->setContent('Hello world!')
30
        ;
31
32
        return $page;
33
    }
34
35
    public function testOneHomepage()
36
    {
37
        $homepage = $this->getDummyPage();
38
39
        $kernel = static::getKernel();
40
41
        /** @var EntityManager $em */
42
        $em = $kernel->getContainer()->get('doctrine')->getManager();
43
        $em->persist($homepage);
44
        $em->flush();
45
46
        /** @var Page $homepage */
47
        $homepage = $em->getRepository(get_class($homepage))->find($homepage->getId());
48
49
        static::assertEquals($homepage->getTitle(), (string) $homepage);
50
51
        static::assertFalse($homepage->isEnabled()); // Base value in entity
52
        static::assertTrue($homepage->isHomepage());
53
        static::assertEquals('localhost', $homepage->getHost());
54
        static::assertInstanceOf('DateTime', $homepage->getCreatedAt());
55
56
        $homepage->setParent($homepage);
57
        static::assertNull($homepage->getParent());
58
    }
59
60
    public function testLifecycleCallbacks()
61
    {
62
        $homepage = $this->getDummyPage();
63
64
        $child = $this->getDummyPage()->setSlug('child');
65
66
        $homepage->addChild($child);
67
        $child->setParent($homepage);
68
69
        $kernel = static::getKernel();
70
71
        /** @var EntityManager $em */
72
        $em = $kernel->getContainer()->get('doctrine')->getManager();
73
        $em->persist($homepage);
74
        $em->persist($child);
75
        $em->flush();
76
77
        static::assertEquals([$child], $homepage->getChildren()->toArray());
78
79
        /** @var Page $homepage */
80
        $homepage = $em->getRepository(get_class($homepage))->findOneBy(['id' => $homepage->getId()]);
81
82
        static::assertNotNull($homepage);
83
84
        if (null !== $homepage) {
85
            $em->remove($homepage);
86
            $em->flush();
87
        }
88
89
        $homepage = $em->getRepository(get_class($homepage))->findOneBy(['id' => $homepage->getId()]);
90
91
        static::assertNull($homepage);
92
        static::assertNull($child->getParent());
93
    }
94
95 View Code Duplication
    public function testRemoval()
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...
96
    {
97
        $page = new Page();
98
        $page
99
            ->setTitle('Default page')
100
            ->setSlug('default')
101
            ->setEnabled(true)
102
        ;
103
104
        $child = new Page();
105
        $child
106
            ->setTitle('Child page')
107
            ->setSlug('child')
108
            ->setEnabled(true)
109
            ->setParent($page)
110
        ;
111
        $page->addChild($child);
112
113
        $kernel = static::getKernel();
114
115
        /** @var EntityManager $em */
116
        $em = $kernel->getContainer()->get('doctrine')->getManager();
117
        $em->persist($page);
118
        $em->persist($child);
119
        $em->flush();
120
121
        $page = $em->getRepository(get_class($page))->find($page->getId());
122
123
        $children = $page->getChildren();
124
        /** @var Page $first */
125
        $first = $children[0];
126
        static::assertEquals($child->getId(), $first->getId());
127
128
        $page->removeChild($child);
129
        $child->setParent(null);
130
131
        $em->remove($page);
0 ignored issues
show
It seems like $page defined by $em->getRepository(get_c...)->find($page->getId()) on line 121 can also be of type null; however, Doctrine\ORM\EntityManager::remove() does only seem to accept object, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
132
        $em->flush();
133
134
        $child = $em->getRepository(get_class($child))->find($child->getId());
135
136
        static::assertNull($child->getParent());
137
    }
138
139
    public function testPageSlugIsTransliterated()
140
    {
141
        $page = new Page();
142
        $page->setTitle('Default page');
143
144
        $page->updateSlug();
145
146
        static::assertEquals('default-page', $page->getSlug());
147
    }
148
}
149