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/EcommerceTaskCountryAndRegion.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
/**
4
 * create standard country and regions.
5
 *
6
 * @authors: Nicolaas [at] Sunny Side Up .co.nz
7
 * @package: ecommerce
8
 * @sub-package: tasks
9
 * @inspiration: Silverstripe Ltd, Jeremy
10
 **/
11
class EcommerceTaskCountryAndRegion extends BuildTask
12
{
13
    protected $title = 'Create standard countries and regions';
14
15
    protected $description = 'Adds all countries to the EcommerceCountry list';
16
17
    public function run($request)
18
    {
19
        $count = 0;
20
        $array = EcommerceCountry::get_country_dropdown();
21
        $allowedArray = EcommerceConfig::get('EcommerceCountry', 'allowed_country_codes');
22
        foreach ($array as $code => $name) {
23
            $ecommerceCountry = DataObject::get_one(
24
                'EcommerceCountry',
25
                array('Code' => Convert::raw2sql($code)),
26
                $cacheDataObjectGetOne = false
27
            );
28
            if ($ecommerceCountry) {
29
                //do nothing
30
                ++$count;
31
            } else {
32
                DB::alteration_message("adding $code to Ecommerce Country", 'created');
33
                $ecommerceCountry = EcommerceCountry::create();
34
                $ecommerceCountry->Code = $code;
0 ignored issues
show
The property Code does not exist on object<EcommerceCountry>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
35
            }
36
            if ($allowedArray && count($allowedArray)) {
37
                if (in_array($code, $allowedArray)) {
38
                    //do nothing
39
                    $ecommerceCountry->DoNotAllowSales = 0;
40
                } else {
41
                    $ecommerceCountry->DoNotAllowSales = 1;
42
                }
43
            }
44
            $ecommerceCountry->Name = $name;
45
            $ecommerceCountry->write();
46
        }
47
        DB::alteration_message("Created / Checked $count Ecommerce Countries", 'edited');
48
    }
49
}
50
51
/**
52
 * update EcommerceCountry.DoNotAllowSales to 1 so that you can not sell to any country.
53
 *
54
 * @authors: Nicolaas [at] Sunny Side Up .co.nz
55
 * @package: ecommerce
56
 * @sub-package: tasks
57
 * @inspiration: Silverstripe Ltd, Jeremy
58
 **/
59
class EcommerceTaskCountryAndRegion_DisallowAllCountries extends BuildTask
60
{
61
    protected $title = 'Disallows sale to all countries';
62
63
    protected $description = 'We add this task to reset all countries from Allow Sales to Disallow Sales - as a good starting point when selling to just a few countries';
64
65
    public function run($request)
66
    {
67
        $count = 0;
0 ignored issues
show
$count 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...
68
        $array = EcommerceCountry::get_country_dropdown();
0 ignored issues
show
$array 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...
69
        $allowedArray = EcommerceCountry::get()
70
            ->filter(array('DoNotAllowSales' => 0));
71
        if ($allowedArray->count()) {
72
            foreach ($allowedArray as $obj) {
73
                $obj->DoNotAllowSales = 1;
74
                $obj->write();
75
                DB::alteration_message('Disallowing sales to '.$obj->Name);
76
            }
77
        } else {
78
            DB::alteration_message('Could not find any countries that are allowed', 'created');
79
        }
80
    }
81
}
82
/**
83
 * update EcommerceCountry.DoNotAllowSales to 0 so that you can sell to all countries.
84
 *
85
 * @authors: Nicolaas [at] Sunny Side Up .co.nz
86
 * @package: ecommerce
87
 * @sub-package: tasks
88
 * @inspiration: Silverstripe Ltd, Jeremy
89
 **/
90
class EcommerceTaskCountryAndRegion_AllowAllCountries extends BuildTask
91
{
92
    protected $title = 'Allows sale to all countries';
93
94
    protected $description = 'We add this task to reset all countries from Allow Sales to Disallow Sales - as a good starting point when selling to just a few countries';
95
96
    public function run($request)
97
    {
98
        $count = 0;
0 ignored issues
show
$count 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...
99
        $array = EcommerceCountry::get_country_dropdown();
0 ignored issues
show
$array 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...
100
        $allowedArray = EcommerceCountry::get()
101
            ->filter(array('DoNotAllowSales' => 1));
102
        if ($allowedArray->count()) {
103
            foreach ($allowedArray as $obj) {
104
                $obj->DoNotAllowSales = 0;
105
                $obj->write();
106
                DB::alteration_message('Disallowing sales to '.$obj->Name);
107
            }
108
        } else {
109
            DB::alteration_message('Could not find any countries that are not allowed', 'created');
110
        }
111
    }
112
}
113