Issues (13)

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.

tests/GridRowsExtensionTest.php (5 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 WebOfTalent\GridRows\Tests;
4
5
use PageController;
6
use SilverStripe\Dev\FunctionalTest;
7
use SilverStripe\ORM\DataObject;
8
use SilverStripe\Dev\TestOnly;
9
10
class GridRowsExtensionTest extends FunctionalTest
11
{
12
    protected static $fixture_file = 'GridRowsExtensionTest.yml';
13
14
    protected $extraDataObjects = array(
15
        'GridRowItemTO'
16
    );
17
18
    public function setUp()
19
    {
20
        $this->requiredExtensions = array(
21
            'GridRowItemTO' => array('GridRowsExtension')
22
        );
23
24
        parent::setUp();
25
    }
26
27
28
    public function testSplitDataListMethodDoesNotExist()
29
    {
30
        $message = 'Method not found.  A grid cannot be formed from the method'
31
                 . ' GridRowItemsTHISMETHODDOESNOTEXIST';
32
        $this->setExpectedException('InvalidArgumentException', $message);
33
34
        $page = $this->objFromFixture('GridRowItemPageTO', 'page001');
35
        $page->doPublish();
36
        $controller = new GridRowItemPageTO_Controller();
37
        $controller->setDataModel($page);
38
39
        for ($columns=1; $columns < 15; $columns++) {
40
            $grid = $controller->SplitDataListIntoGridRows(
41
                'GridRowItemsTHISMETHODDOESNOTEXIST', // method from model
42
                $columns
43
            );
44
            $this->checkGrid($grid, $columns, 10);
45
        }
46
    }
47
48 View Code Duplication
    public function testSplitDataListFromModelIntoGridRows()
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...
49
    {
50
        $page = $this->objFromFixture('GridRowItemPageTO', 'page001');
51
        $page->doPublish();
52
        $controller = new GridRowItemPageTO_Controller();
53
        $controller->setDataModel($page);
54
55
        for ($columns=1; $columns < 15; $columns++) {
56
            $grid = $controller->SplitDataListIntoGridRows(
57
                'GridRowItems', // method from model
58
                $columns
59
            );
60
            $this->checkGrid($grid, $columns, 10);
61
        }
62
    }
63
64 View Code Duplication
    public function testSplitDataListFromControllerIntoGridRows()
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...
65
    {
66
        $page = $this->objFromFixture('GridRowItemPageTO', 'page001');
67
        $page->doPublish();
68
        $controller = new GridRowItemPageTO_Controller();
69
        $controller->setDataModel($page);
70
        for ($columns=1; $columns < 15; $columns++) {
71
            $grid = $controller->SplitDataListIntoGridRows(
72
                'GridItems', // method from controller
73
                $columns
74
            );
75
            $this->checkGrid($grid, $columns, 10);
76
        }
77
    }
78
79
    /*
80
    Check multiple number of columns with amounts from 1 to just over the
81
    total number of grid items, namely 12
82
     */
83
    public function testSplitClassNameDataListIntoGridRows()
84
    {
85
        $page = $this->objFromFixture('GridRowItemPageTO', 'page001');
86
        $page->doPublish();
87
        $controller = new PageController();
88
        $controller->setDataModel($page);
89
        for ($columns=1; $columns < 15; $columns++) {
90
            for ($i=1; $i < 15; $i++) {
91
                $grid = $controller->SplitClassNameDataListIntoGridRows(
92
                    'GridRowItemTO',
93
                    $columns,
94
                    $i,
95
                    $sort = 'LastEdited DESC'
96
                );
97
                $amount = $i > 12 ? 12: $i;
98
                $this->checkGrid($grid, $columns, $amount);
99
            }
100
        }
101
    }
102
103
104
    private function checkGrid($grid, $maxWidth, $amount)
105
    {
106
        $items = 0;
107
        $rows = 0;
108
        $widths = array();
109
        foreach ($grid->getIterator() as $row) {
110
            $rows++;
111
            $width = 0;
112
            foreach ($row->Columns->getIterator() as $column) {
113
                $items++;
114
                $width++;
115
            }
116
            array_push($widths, $width);
117
        }
118
119
        // last value will be <= max width
120
        $lastVal = array_pop($widths);
121
        $this->assertLessThanOrEqual($maxWidth, $lastVal);
122
123
        // All but the last row should equal the expected width, $maxWidth
124
        foreach ($widths as $width) {
125
            $this->assertEquals($maxWidth, $width);
126
        }
127
        $this->assertEquals($amount, $items);
128
    }
129
}
130
131
132
class GridRowItemTO extends DataObject implements TestOnly
133
{
134
    private static $db = array('Name' => 'Varchar');
0 ignored issues
show
The property $db is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
135
136
    private static $has_one = array('GridRowItemPage' => 'GridRowItemPageTO');
0 ignored issues
show
The property $has_one is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
137
}
138
139
class GridRowItemPageTO extends Page implements TestOnly
140
{
141
    private static $has_many = array('GridRowItems' => 'GridRowItemTO');
0 ignored issues
show
The property $has_many is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
142
}
143
144
class GridRowItemPageTO_Controller extends PageController implements TestOnly
145
{
146
147
    /*
148
    This is a test method on the *controller*
149
     */
150
    public function GridItems()
151
    {
152
        return $this->model->GridRowItems();
153
    }
154
}
155