Issues (2002)

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.

code/tasks/EcommerceTaskReviewSearches.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
 * @authors: Nicolaas [at] Sunny Side Up .co.nz
5
 * @package: ecommerce
6
 * @sub-package: tasks
7
 **/
8
class EcommerceTaskReviewSearches extends BuildTask
9
{
10
    /**
11
     * number of days shown.
12
     *
13
     * @int
14
     */
15
    protected $defaultMaxRows = 999;
16
    /**
17
     * number of days shown.
18
     *
19
     * @int
20
     */
21
    protected $defaultDays = 100;
22
23
    /**
24
     * minimum number of searches for
25
     * a particular keyword in order to show it at all.
26
     *
27
     * @int
28
     */
29
    protected $defaultMinimum = 5;
30
31
    /**
32
     * show up to XXX days ago.
33
     *
34
     * @int
35
     */
36
    protected $endingDaysBack = 0;
37
38
    /**
39
     * Standard (required) SS variable for BuildTasks.
40
     *
41
     * @var string
42
     */
43
    protected $title = 'Search Statistics';
44
45
    /**
46
     * Standard (required) SS variable for BuildTasks.
47
     *
48
     * @var string
49
     */
50
    protected $description = '
51
        What did people search for on the website, you can use the days, min and ago GET variables to query different sets.';
52
53
    public function run($request)
54
    {
55
        $maxRows = intval(preg_replace('/[^\d.]/', '', $request->getVar('maxrows')));
56
        $maxRows = intval($maxRows - 0);
57
        if (!$maxRows) {
58
            $maxRows = $this->defaultMaxRows;
59
        }
60
        $days = intval($request->getVar('days') - 0);
61
        if (!$days) {
62
            $days = $this->defaultDays;
63
        }
64
        $countMin = intval($request->getVar('min') - 0);
65
        if (!$countMin) {
66
            $countMin = $this->defaultMinimum;
67
        }
68
        $endingDaysBack = intval($request->getVar('ago') - 0);
69
        if (!$endingDaysBack) {
70
            $endingDaysBack = $this->endingDaysBack;
71
        }
72
        $field = EcommerceSearchHistoryFormField::create('stats', $this->title)
73
            ->setNumberOfDays($days)
74
            ->setMinimumCount($countMin)
75
            ->setMaxRows($maxRows)
76
            ->setEndingDaysBack($endingDaysBack);
77
        echo $field->forTemplate();
78
        $arrayNumberOfDays = array(30, 365);
0 ignored issues
show
$arrayNumberOfDays 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...
79
80
        $fields = FieldList::create(
81
            HeaderField::create(
82
                'ShowResultsFor',
83
                'Show results for ...'
84
            ),
85
            NumericField::create(
86
                'days',
87
                'Number of days',
88
                isset($_GET['days']) ? $_GET['days'] : $this->defaultDays
89
            )->setRightTitle('For example, enter 10 to get results from a 10 day period.'),
90
            NumericField::create(
91
                'maxrows',
92
                'Maximum Number of Rows?',
93
                isset($_GET['maxrows']) ? $_GET['maxrows'] : $this->defaultMaxRows
94
            )->setRightTitle('For example, enter 10 to get results from a 10 day period.'),
95
            NumericField::create(
96
                'ago',
97
                'Up to how many days go',
98
                isset($_GET['ago']) ? $_GET['ago'] : $this->endingDaysBack
99
            )->setRightTitle('For example, entering 365 days means you get all statistics the specified number of days up to one year ago.'),
100
            NumericField::create(
101
                'min',
102
                'Count treshold',
103
                isset($_GET['min']) ? $_GET['min'] : $this->defaultMinimum
104
            )->setRightTitle('Minimum number of searches for it to show up in the statistics. For example, enter five to show only phrases that were searched for at least five times during the specified period.')
105
        );
106
        $actions = FieldList::create(FormAction::create("run")->setTitle("show results"));
107
        $form = Form::create($this, "SearchFields", $fields, $actions, null);
108
        $form->setAttribute('method', 'get');
109
        $form->setAttribute('action', $this->Link());
110
        echo $form->forTemplate();
111
        echo '<style>
112
            div.field {margin-bottom: 20px;}
113
            .right {font-style:italics; color: #555;}
114
        </style>';
115
    }
116
117
    public function Link($action = null)
0 ignored issues
show
The parameter $action is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
118
    {
119
        return '/dev/tasks/EcommerceTaskReviewSearches/';
120
    }
121
}
122