Issues (125)

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.

tests/MapUtilTest.php (6 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 MapUtilTest extends SapphireTest
4
{
5
    /*
6
    Other tests:
7
    1) List, ArrayList, DataList, null for get_map
8
    2) Negative and zero map sizes
9
    3) Invalid map type
10
11
12
    public function setUpOnce() {
13
        $this->requiredExtensions = array(
14
            'Member' => array('MapExtension')
15
        );
16
        parent::setupOnce();
17
    }
18
*/
19 11
    public function setUp()
20
    {
21 11
        MapUtil::reset();
22 11
        parent::setUp();
23 11
    }
24
25 1
    public function test_set_api_key_string()
0 ignored issues
show
Method name "MapUtilTest::test_set_api_key_string" is not in camel caps format
Loading history...
26
    {
27 1
        MapUtil::set_api_key('PRETENDAPIKEY');
28 1
        $html = $this->htmlForMap();
29 1
        $this->assertContains(
30 1
            ' data-google-map-key="PRETENDAPIKEY" data-google-map-lang="en"',
31
            $html
32 1
        );
33
34 1
        $html = $this->htmlForMap();
35 1
        $this->assertNotContains(
36 1
            ' data-google-map-key="PRETENDAPIKEY" data-google-map-lang="en"',
37
            $html
38 1
        );
39 1
    }
40
41 1
    public function test_set_api_key_host_array()
0 ignored issues
show
Method name "MapUtilTest::test_set_api_key_host_array" is not in camel caps format
Loading history...
42
    {
43 1
        $url = Director::absoluteBaseURL();
44
        // remove http and https
45 1
        $url = str_replace('http://', '', $url);
46 1
        $url = str_replace('https://', '', $url);
47 1
        $parts = explode('/', $url);
48 1
        $host = $parts[0];
49 1
        $key = array($host => 'PRETENDAPIKEY');
50 1
        MapUtil::set_api_key($key);
0 ignored issues
show
$key is of type array<?,string>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
51 1
        $html = $this->htmlForMap();
52 1
        $this->assertContains(
53 1
            ' data-google-map-key="PRETENDAPIKEY" data-google-map-lang="en"',
54
            $html
55 1
        );
56
57 1
        $html = $this->htmlForMap();
58 1
        $this->assertNotContains(
59 1
            ' data-google-map-key="PRETENDAPIKEY" data-google-map-lang="en"',
60
            $html
61 1
        );
62 1
    }
63
64 1
    public function test_set_map_size()
0 ignored issues
show
Method name "MapUtilTest::test_set_map_size" is not in camel caps format
Loading history...
65
    {
66 1
        MapUtil::set_map_size('890px', '24em');
67 1
        $html = $this->htmlForMap();
68 1
        $this->assertContains(' style="width:890px; height: 24em;"', $html);
69 1
    }
70
71 1
    public function testSanitizeEmptyString()
72
    {
73 1
        $this->assertEquals(
74 1
            '',
75 1
            MapUtil::sanitize('')
76 1
        );
77 1
    }
78
79 1
    public function testSanitizeAlreadySanitized()
80
    {
81 1
        $this->assertEquals(
82 1
            'This is already sanitized',
83 1
            MapUtil::sanitize('This is already sanitized')
84 1
        );
85 1
    }
86
87 1
    public function testSanitizeSlashN()
88
    {
89 1
        $this->assertEquals(
90 1
            'String to be sanitized',
91 1
            MapUtil::sanitize("String\n to be sanitized")
92 1
        );
93 1
    }
94
95 1
    public function testSanitizeSlashT()
96
    {
97 1
        $this->assertEquals(
98 1
            'String to be sanitized',
99 1
            MapUtil::sanitize("String\t to be sanitized")
100 1
        );
101 1
    }
102
103 1
    public function testSanitizeSlashR()
104
    {
105 1
        $this->assertEquals(
106 1
            'String to be sanitized',
107 1
            MapUtil::sanitize("String\r to be sanitized")
108 1
        );
109 1
    }
110
111
    /**
112
     * A single marker for the Member should appear in the UJS map data.
113
     */
114 1
    public function testSingularMappableItemMarkerUJSExists()
115
    {
116 1
        Member::add_extension('MapExtension');
117 1
        $member = new Member();
118 1
        $member->Lat = 12.847;
119 1
        $member->Lon = 29.24;
120
121
        // because we are not writing, set this manually
122 1
        $member->MapPinEdited = true;
123 1
        $list = new ArrayList();
124 1
        $list->push($member);
125 1
        $map = MapUtil::get_map($list, array());
126 1
        $html = $map->forTemplate();
127 1
        $markerExpected = 'data-mapmarkers=\'[{"latitude":12.847,"longitude":29.24,"html":"MEMBER: ","category":"default","icon":false}]\'';
128 1
        $this->assertContains($markerExpected, $html);
129 1
        Member::remove_extension('MapExtension');
130 1
    }
131
132 5
    private function htmlForMap()
133
    {
134 5
        $map = MapUtil::get_map(new ArrayList(), array());
135 5
        $html = $map->forTemplate();
136
137 5
        return $html;
138
    }
139
140 1
    public function test_set_center()
0 ignored issues
show
Method name "MapUtilTest::test_set_center" is not in camel caps format
Loading history...
141
    {
142 1
        MapUtil::set_center('Klong Tan, Bangkok, Thailand');
143 1
        $html = $this->htmlForMap();
144
        //coordinates of Klong Tan in Bangkok
145 1
        $expected = 'data-centre=\'{"lat":13.7243075,"lng":100.5718086}';
146 1
        $this->assertContains($expected, $html);
147 1
    }
148
149 1
    public function test_set_map_type()
0 ignored issues
show
Method name "MapUtilTest::test_set_map_type" is not in camel caps format
Loading history...
150
    {
151
        $mapTypes = array(
152 1
            'road' => 'road',
153 1
            'satellite' => 'satellite',
154 1
            'hybrid' => 'hybrid',
155 1
            'terrain' => 'terrain',
156 1
            'google.maps.MapTypeId.ROADMAP' => 'road',
157 1
            'google.maps.MapTypeId.SATELLITE' => 'satellite',
158 1
            'google.maps.MapTypeId.G_HYBRID_MAP' => 'hybrid',
159 1
            'google.maps.MapTypeId.G_PHYSICAL_MAP' => 'terrain',
160 1
            'custom_layer' => 'custom_layer',
161
162 1
        );
163
164 1
        foreach (array_keys($mapTypes) as $mapType) {
165 1
            MapUtil::set_map_type($mapType);
166 1
            $expected = "data-maptype='".$mapTypes[$mapType]."'";
167 1
            $html = $this->htmlForMap();
168 1
            $this->assertContains($expected, $html);
169 1
        }
170 1
    }
171
}
172