Issues (72)

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/BrowseContinentsPage.php (7 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
class BrowseContinentsPage extends BrowseAbstractPage
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
{
5
6
    /**
7
     * Standard SS static
8
     **/
9
    public static $icon = "geobrowser/images/treeicons/BrowseContinentsPage";
10
11
12
    /**
13
     * Standard SS static
14
     **/
15
    public static $allowed_children = array("BrowseCountriesPage");
16
17
    /**
18
     * Standard SS static
19
     **/
20
    public static $default_child = "BrowseCountriesPage";
21
22
    /**
23
     * Standard SS static
24
     **/
25
    public static $default_parent = "BrowseWorldPage";
26
27
        /**
28
     * Standard SS Static
29
     **/
30
    public static $can_be_root = false;
31
    
32
    /**
33
     * Standard SS Static
34
     **/
35
    public static $defaults = array(
36
        "ShowInMenus" => true
37
    );
38
    
39
    /**
40
     * name of the level
41
     **/
42
    public function GeoLevelName()
43
    {
44
        return "Continents";
45
    }
46
47
    /**
48
     * number of the level
49
     **/
50
    public function GeoLevelNumber()
51
    {
52
        return 0;
53
    }
54
55
    /**
56
     * Standard SS Method
57
     * setup records
58
     **/
59
    public function requireDefaultRecords()
0 ignored issues
show
requireDefaultRecords uses the super-global variable $_GET which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
60
    {
61
        $bt = defined('DB::USE_ANSI_SQL') ? "\"" : "`";
62
        parent::requireDefaultRecords();
63
        $parents = DataObject::get("BrowseContinentsPage");
64
        if ($parents && isset($_GET["geobuild"]) && $_GET["geobuild"] && $this->allowBrowseChildren()) {
65 View Code Duplication
            foreach ($parents as $parent) {
0 ignored issues
show
This code seems to be duplicated across 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...
66
                if ($parent->CreateChildren && $parent->HiddenDataID) {
67
                    echo "<li>creating countries for ".$parent->Title."<ul>";
68
                    $countries = $this->getDataFromTable("countries", "ContinentID = ".$parent->HiddenDataID, "Country");
69
                    foreach ($countries as $country) {
70
                        if (!DataObject::get_one("BrowseCountriesPage", "{$bt}HiddenDataID{$bt} = ".$country["CountryID"])) {
71
                            $page = new BrowseCountriesPage();
72
                            $page->CreateCountry($country, $parent);
73
                            $page->destroy();
74
                        }
75
                    }
76
                    echo "</ul></li>";
77
                }
78
            }
79
        }
80
    }
81
    
82
    /**
83
     * create a continent
84
     * @param array - $contentint, continent data
85
     * @param Object - $parent, a BrowseWorldPage object that will be the parent page of the Continent.
86
     **/
87
    public function CreateContinent(array $continent, BrowseWorldPage $parent)
0 ignored issues
show
CreateContinent uses the super-global variable $_GET which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
88
    {
89
        $bt = defined('DB::USE_ANSI_SQL') ? "\"" : "`";
0 ignored issues
show
$bt 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...
90
        if ($parent && isset($continent["Continent"])) {
91
            $name = htmlentities($continent["Continent"]);
92
            if ($name) {
93
                if (isset($_GET["geobuild"])) {
94
                    echo "<li>creating ".$name."</li>";
95
                }
96
                $this->ParentID = $parent->ID;
97
                $this->Title = $name;
98
                $this->MetaTitle = $name;
99
                $this->MenuTitle = $name;
100
                $this->HiddenDataID = $continent["ContinentID"];
101
                $this->CreateChildren = $parent->CreateAllChildren;
102
                $this->CreateAllChildren = $parent->CreateAllChildren;
103
                $this->writeToStage('Stage');
104
                $this->publish('Stage', 'Live');
105
                $this->flushCache();
106
            } else {
107
                if (isset($_GET["geobuild"])) {
108
                    debug::show("name does not exist");
109
                }
110
            }
111
        } else {
112
            if (isset($_GET["geobuild"])) {
113
                debug::show("Parent does not exist");
114
            }
115
        }
116
    }
117
}
118
119
class BrowseContinentsPage_Controller extends BrowseAbstractPage_Controller
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
120
{
121
}
122