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.

Helper/Security/Acl/Permission/MaskBuilderTest.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\AdminBundle\Tests\Helper\Security\Acl\Permission;
4
5
use Exception;
6
use Kunstmaan\AdminBundle\Helper\Security\Acl\Permission\MaskBuilder;
7
use PHPUnit\Framework\TestCase;
8
9
/**
10
 * MaskBuilderTest
11
 */
12
class MaskBuilderTest extends TestCase
13
{
14
    /**
15
     * @param mixed $invalidMask
16
     *
17
     * @dataProvider getInvalidConstructorData
18
     */
19
    public function testSlugify($invalidMask)
20
    {
21
        $this->expectException(\InvalidArgumentException::class);
22
        new MaskBuilder($invalidMask);
23
    }
24
25
    public function testGetCodeThrowsException()
26
    {
27
        $this->expectException(Exception::class);
28
        $builder = new MaskBuilder();
29
        $builder->getCode(MaskBuilder::MASK_IDDQD);
30
    }
31
32
    public function testResolveMaskThrowsException()
33
    {
34
        $this->expectException(Exception::class);
35
        $builder = new MaskBuilder();
36
        $builder->resolveMask('fail!');
37
    }
38
39
    /**
40
     * Provides data to the {@link testSlugify} function
41
     *
42
     * @return array
0 ignored issues
show
Consider making the return type a bit more specific; maybe use array[].

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
43
     */
44
    public function getInvalidConstructorData()
45
    {
46
        return array(
47
            array(234.463),
48
            array('asdgasdf'),
49
            array(array()),
50
            array(new \stdClass()),
51
        );
52
    }
53
54
    public function testConstructorWithoutArguments()
55
    {
56
        $builder = new MaskBuilder();
57
58
        $this->assertEquals(0, $builder->get());
59
    }
60
61
    public function testConstructor()
62
    {
63
        $builder = new MaskBuilder(123456);
64
65
        $this->assertEquals(123456, $builder->get());
66
    }
67
68
    public function testAddAndRemove()
69
    {
70
        $builder = new MaskBuilder();
71
72
        $builder
73
            ->add('view')
74
            ->add('eDiT')
75
            ->add('puBLisH');
76
        $mask = $builder->get();
77
78
        $this->assertEquals(MaskBuilder::MASK_VIEW, $mask & MaskBuilder::MASK_VIEW);
79
        $this->assertEquals(MaskBuilder::MASK_EDIT, $mask & MaskBuilder::MASK_EDIT);
80
        $this->assertEquals(MaskBuilder::MASK_PUBLISH, $mask & MaskBuilder::MASK_PUBLISH);
81
        $this->assertEquals(0, $mask & MaskBuilder::MASK_DELETE);
82
        $this->assertEquals(0, $mask & MaskBuilder::MASK_UNPUBLISH);
83
84
        $builder->remove('edit')->remove('PUblish');
85
        $mask = $builder->get();
86
        $this->assertEquals(0, $mask & MaskBuilder::MASK_EDIT);
87
        $this->assertEquals(0, $mask & MaskBuilder::MASK_PUBLISH);
88
        $this->assertEquals(MaskBuilder::MASK_VIEW, $mask & MaskBuilder::MASK_VIEW);
89
    }
90
91
    public function testGetPattern()
92
    {
93
        $builder = new MaskBuilder();
94
        $this->assertEquals(MaskBuilder::ALL_OFF, $builder->getPattern());
95
96
        $builder->add('view');
97
        $this->assertEquals(str_repeat('.', 31).'V', $builder->getPattern());
98
99
        $builder->add('publish');
100
        $this->assertEquals(str_repeat('.', 27).'P...V', $builder->getPattern());
101
102
        $builder->add(1 << 10);
103
        $this->assertEquals(str_repeat('.', 21).MaskBuilder::ON.'.....P...V', $builder->getPattern());
104
    }
105
106
    public function testReset()
107
    {
108
        $builder = new MaskBuilder();
109
        $this->assertEquals(0, $builder->get());
110
111
        $builder->add('view');
112
        $this->assertTrue($builder->get() > 0);
113
114
        $builder->reset();
115
        $this->assertEquals(0, $builder->get());
116
    }
117
118
    public function testAddWithInvalidMask()
119
    {
120
        $this->expectException(\InvalidArgumentException::class);
121
        $builder = new MaskBuilder();
122
        $builder->add(null);
123
    }
124
125
    public function testRemoveWithInvalidMask()
126
    {
127
        $this->expectException(\InvalidArgumentException::class);
128
        $builder = new MaskBuilder();
129
        $builder->remove(null);
130
    }
131
132
    public function testGetCode()
133
    {
134
        $code = MaskBuilder::getCode(MaskBuilder::MASK_DELETE);
135
        $this->assertEquals(MaskBuilder::CODE_DELETE, $code);
136
137
        $code = MaskBuilder::getCode(MaskBuilder::MASK_UNPUBLISH);
138
        $this->assertEquals(MaskBuilder::CODE_UNPUBLISH, $code);
139
    }
140
141
    public function testGetCodeWithInvalidMask()
142
    {
143
        $this->expectException(\InvalidArgumentException::class);
144
        MaskBuilder::getCode(null);
145
    }
146
147
    public function testHas()
148
    {
149
        $builder = new MaskBuilder();
150
        $builder->add('edit')
151
            ->add('view');
152
153
        $this->assertEquals(true, $builder->has(MaskBuilder::MASK_EDIT));
154
        $this->assertEquals(true, $builder->has('view'));
155
        $this->assertEquals(false, $builder->has(MaskBuilder::MASK_UNPUBLISH));
156
        $this->assertEquals(false, $builder->has('publish'));
157
    }
158
159
    public function testHasWithInvalidMask()
160
    {
161
        $this->expectException(\InvalidArgumentException::class);
162
        $builder = new MaskBuilder();
163
        $builder->add('edit')
164
            ->add('view');
165
166
        $builder->has(null);
167
    }
168
}
169