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.

code/GridRowsExtension.php (3 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;
4
5
use SilverStripe\Core\Injector\Injector;
6
use SilverStripe\ORM\ArrayList;
7
use SilverStripe\ORM\DataExtension;
8
/**
9
 * Helper methods to lay out DataObjects in a grid of rows and colums to a
10
 * required size.  These methods are intended to be called from a template
11
 */
12
class GridRowsExtension extends DataExtension
13
{
14
    /*
15
    If you are laying out using some form of grid, e.g. HTML table (ugh) or
16
    bootstraps span classes it is useful to have the DataList split by row.
17 3
    Here the DataList is generated from a method accessible to the current
18
    controller
19 3
20 3
    See README.md for a worked example
21
22
    */
23 3
    public function SplitDataListIntoGridRows($itemsInGridMethod, $numberOfCols)
0 ignored issues
show
Method name "GridRowsExtension::SplitDataListIntoGridRows" is not in camel caps format
Loading history...
24 1
    {
25 1
        $methodFound = false;
26 1
        $itemsInGrid = null;
27
28 3
        // Check first the controller and then the model for the method to call
29
        if ($this->owner->hasMethod($itemsInGridMethod)) {
30
            $itemsInGrid = $this->owner->$itemsInGridMethod();
31
            $methodFound = true;
32
        }
33 3
34
        if (!$methodFound && method_exists($this->owner->model, $itemsInGridMethod)) {
35 2
            $itemsInGrid = $this->owner->model->$itemsInGridMethod();
36 2
            $methodFound = true;
0 ignored issues
show
$methodFound is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
37
        }
38
39 1
        if ($itemsInGrid == null) {
40
            $message = 'Method not found.  A grid cannot be formed from the '
41
                     . 'method ' . $itemsInGridMethod;
42
            throw new \InvalidArgumentException($message);
43
        }
44
45
        return $this->createGrid($itemsInGrid, $numberOfCols);
46
    }
47
48
    /*
49
    If you are laying out using some form of grid, e.g. HTML table (ugh) or
50 1
    bootstraps span classes it is useful to have the DataList split by row.
51
    This is what this method does.
52
53 1
    See USAGE.md for a worked example
54 1
55 1
    */
56
    public function SplitClassNameDataListIntoGridRows(
0 ignored issues
show
Method name "GridRowsExtension::SplitClassNameDataListIntoGridRows" is not in camel caps format
Loading history...
57
        $className,
58
        $numberOfCols,
59
        $limit = 10,
60
        $sort = 'LastEdited DESC'
61
    ) {
62 2
        $clazz = Injector::inst()->create($className);
63
        $itemsInGrid = $clazz->get()->limit($limit)->sort($sort);
64 2
        return $this->createGrid($itemsInGrid, $numberOfCols);
65 2
    }
66 2
67 2
    /*
68 2
    The actual method that splits the DataList into an ArrayList of rows that
69 2
    contain an ArrayList of Columns
70 2
    */
71 2
    private function createGrid($itemsInGrid, $numberOfCols)
72 2
    {
73 2
        $position = 1;
74 2
        $columns = new ArrayList();
75 2
        $result = new ArrayList();
76 2
        foreach ($itemsInGrid as $key => $item) {
77
            $columns->push($item);
78 2
            if (($position) >= $numberOfCols) {
79 2
                $position = 1;
80 2
                $row = new ArrayList();
81 2
                $row->Columns = $columns;
82 2
                $result->push($row);
83 2
                $columns = new ArrayList();
84 2
            } else {
85
                $position = $position + 1;
86
            }
87 1
        }
88
        if ($columns->Count() > 0) {
89
            $row = new ArrayList();
90
            $row->Columns = $columns;
91
            $result->push($row);
92
        }
93
        return $result;
94
    }
95
}
96