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.

NodeBundle/Tests/unit/Entity/StructureNodeTest.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 Kunstmaan\NodeBundle\Tests\Entity;
4
5
use Kunstmaan\NodeBundle\Entity\AbstractPage;
6
use Kunstmaan\NodeBundle\Entity\HasNodeInterface;
7
use Kunstmaan\NodeBundle\Entity\StructureNode;
8
use Kunstmaan\NodeBundle\Form\PageAdminType;
9
use Kunstmaan\NodeBundle\Helper\RenderContext;
10
use PHPUnit\Framework\TestCase;
11
use Symfony\Component\DependencyInjection\Container;
12
use Symfony\Component\DependencyInjection\ContainerInterface;
13
use Symfony\Component\HttpFoundation\Request;
14
15
class TestStructureNode extends StructureNode
16
{
17
    public function getPossibleChildTypes()
18
    {
19
        return [];
20
    }
21
22
    public function service(ContainerInterface $container, Request $request, RenderContext $context)
23
    {
24
        $context['test'] = 'test';
25
    }
26
}
27
28
class TestNode extends AbstractPage
29
{
30
    public function getPossibleChildTypes()
31
    {
32
        return [];
33
    }
34
}
35
36
/**
37
 * Class StructureNodeTest
38
 */
39
class StructureNodeTest extends TestCase
40
{
41
    public function testIsStructureNode()
42
    {
43
        $structureNode = new TestStructureNode();
44
        $this->assertTrue($structureNode->isStructureNode());
45
46
        $node = new TestNode();
47
        $this->assertFalse($node->isStructureNode());
48
    }
49
50
    public function testIsOnline()
51
    {
52
        $structureNode = new TestStructureNode();
53
        $this->assertFalse($structureNode->isOnline());
54
    }
55
56
    public function testGetSetPageTitle()
57
    {
58
        $node = new TestStructureNode();
59
        $node->setTitle('The Title');
60
        $this->assertEquals('The Title', $node->getPageTitle());
61
        $this->assertEquals('The Title', $node->getTitle());
62
        $this->assertEquals('The Title', $node->__toString());
63
    }
64
65
    public function testGetSetParent()
66
    {
67
        $entity = $this->createMock(HasNodeInterface::class);
68
        $node = new TestStructureNode();
69
        $node->setParent($entity);
70
        $this->assertInstanceOf(\get_class($entity), $node->getParent());
71
    }
72
73
    public function testGetDefaultAdminType()
74
    {
75
        $node = new TestStructureNode();
76
        $this->assertEquals(PageAdminType::class, $node->getDefaultAdminType());
77
    }
78
79
    /**
80
     * @group legacy
81
     */
82
    public function testService()
83
    {
84
        $renderContext = new RenderContext();
85
86
        $node = new TestStructureNode();
87
        $node->service(new Container(), new Request(), $renderContext);
0 ignored issues
show
The call to the method Kunstmaan\NodeBundle\Tes...tructureNode::service() seems un-needed as the method has no side-effects.

PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.

Let’s take a look at an example:

class User
{
    private $email;

    public function getEmail()
    {
        return $this->email;
    }

    public function setEmail($email)
    {
        $this->email = $email;
    }
}

If we look at the getEmail() method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:

$user = new User();
$user->getEmail(); // This line could safely be removed as it has no effect.

On the hand, if we look at the setEmail(), this method _has_ side-effects. In the following case, we could not remove the method call:

$user = new User();
$user->setEmail('email@domain'); // This line has a side-effect (it changes an
                                 // instance variable).
Loading history...
88
89
        $this->assertArrayHasKey('test', $renderContext->getArrayCopy());
90
    }
91
}
92