Issues (196)

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/model/decorator/GoogleMapLocationsDOD.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
/**
4
 * Additions to Site Tree
5
 *
6
 *
7
 *
8
 *
9
 */
10
11
class GoogleMapLocationsDOD extends SiteTreeExtension
12
{
13
    private static $db = array(
14
        "HasGeoInfo" => "Boolean"
15
    );
16
17
    private static $has_many = array(
18
        "GeoPoints" => "GoogleMapLocationsObject"
19
    );
20
21
    /**
22
     * list of pages types without a map
23
     * @var Array
24
     */
25
    private static $page_classes_without_map = array();
26
27
    /**
28
     * list of pages types with a map
29
     * @var Array
30
     */
31
    private static $page_classes_with_map = array();
32
33
    /**
34
     * @param FieldList
35
     */
36
    public function updateCMSFields(FieldList $fields)
37
    {
38
        if ($this->classHasGoogleMap()) {
39
            $fields->addFieldToTab("Root", new Tab("Map"));
40
            $fields->addFieldToTab(
41
                "Root.Map",
42
                $hasGeoInfoBox = CheckboxField::create(
43
                    "HasGeoInfo",
44
                    _t("GoogleMapLocationsDOD.HAS_ADDRESSES", "Has Address(es)?")
45
                )
46
            );
47
            if (!$this->owner->HasGeoInfo) {
48
                $hasGeoInfoBox->setDescription(
49
                    _t("GoogleMap.HasGeoInfoSTART", "tick and save this page to start data-entry ...")
50
                );
51
            }
52
            if ($this->owner->HasGeoInfo) {
53
                $dataObject = new GoogleMapLocationsObject();
0 ignored issues
show
$dataObject 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...
54
                $source = $this->owner->GeoPoints();
55
                $GeoPointsField = new GridField(
56
                    "GeoPoints",
57
                    "Locations",
58
                    $source,
59
                    GridFieldConfig_RelationEditor::create()
60
                );
61
                $fields->addFieldToTab("Root.Map", $GeoPointsField);
62
            }
63
        }
64
        return $fields;
65
    }
66
67
    /**
68
     * returns the HTML for a info window on a map for this page.
69
     * @return String (HTML)
70
     */
71
    public function AjaxInfoWindowLink()
72
    {
73
        if ($this->owner->hasMethod("CustomAjaxInfoWindow")) {
74
            return $this->owner->CustomAjaxInfoWindow();
75
        }
76
        if ($this->owner->hasMethod("ajaxinfowindowreturn")) {
77
            return '
78
				<div class="viewMoreInformationHolder">
79
					<a href="'.$this->owner->Link().'" onclick="return !loadAjaxInfoWindow(this,\''.$this->owner->Link().'ajaxinfowindowreturn/\');">'. Config::inst()->get("GoogleMap", "ajax_info_window_text") .'</a>
80
					<div class="loadAjaxInfoWindowSpan"></div>
81
				</div>';
82
        }
83
    }
84
85
    /**
86
     * Page Type has a Google Map
87
     * @return Boolean
88
     */
89
    public function ClassHasGoogleMap()
90
    {
91
        //assumptions:
92
        //1. in general YES
93
        //2. if list of WITH is shown then it must be in that
94
        //3. otherwise check if it is specifically excluded (WITHOUT)
95
        $result = true;
96
        $inc =  Config::inst()->get("GoogleMapLocationsDOD", "page_classes_with_map");
97
        $exc =  Config::inst()->get("GoogleMapLocationsDOD", "page_classes_without_map");
98
        if (is_array($inc) && count($inc)) {
99
            $result = false;
100
            if (in_array($this->owner->ClassName, $inc)) {
101
                $result = true;
102
            }
103
        } elseif (is_array($exc) && count($exc) && in_array($this->owner->ClassName, $exc)) {
104
            $result = false;
105
        }
106
        return $result;
107
    }
108
109
    /**
110
     * Recursively search children of current page to find a particular classtype
111
     *
112
     * @param $parentPage DataObject The Object of which you want to find the children
113
     * @param $classType String The text string to match `ClassName` field
114
     *
115
     * @return ArrayList of items if Class $classType
116
     */
117
    public function getChildrenOfType($parentPage, $classType = null)
118
    {
119
        $children = $parentPage->AllChildren();
120
        if (!isset($childrenOfType)) {
0 ignored issues
show
The variable $childrenOfType seems only to be defined at a later point. As such the call to isset() seems to always evaluate to false.

This check marks calls to isset(...) or empty(...) that are found before the variable itself is defined. These will always have the same result.

This is likely the result of code being shifted around. Consider removing these calls.

Loading history...
121
            $childrenOfType = new ArrayList();
122
        }
123
        if ($children) {
124
            foreach ($children as $item) {
125
                $childrenOfType->merge($this->getChildrenOfType($item, $classType));
126
            }
127
        }
128
        if ((isset($classType) && $CurrentPage->ClassName == $classType) || (!isset($classType))) {
0 ignored issues
show
The variable $CurrentPage does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
129
            if ($parentPage->HasGeoInfo) {
130
                $childrenOfType->push($parentPage);
131
            }
132
        }
133
        return ($childrenOfType) ? $childrenOfType : new ArrayList();
134
    }
135
}
136