Issues (7)

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/FontResizer.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
class FontResizer extends Extension
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
    protected static $font_size_change = 0.1;
6
    public static function set_font_size_change($v)
7
    {
8
        self::$font_size_change = floatval($v);
9
    }
10
11
    protected static $max_font_size = 1.7;
12
    public static function set_max_font_size($v)
13
    {
14
        self::$max_font_size = floatval($v);
15
    }
16
17
    protected static $min_font_size = 0.7;
18
    public static function set_min_font_size($v)
19
    {
20
        self::$min_font_size = floatval($v);
21
    }
22
23
    public static $allowed_actions = array("increasefontsize", "decreasefontsize", "resetfontsize");
24
25
    // *** TEMPLATE FUNCTIONS
26
27
    public function CurrentFontSizeInPercentages($currentSize = 0)
28
    {
29
        Requirements::themedCSS("fontresizer");
30
        Requirements::javascript("fontresizer/javascript/fontresizer.js");
31
        Requirements::customScript("fontresizer.setMin(".(self::$min_font_size*100).");fontresizer.setMax(".(self::$max_font_size*100).");");
0 ignored issues
show
'fontresizer.setMin(' . ..._font_size * 100 . ');' is of type string, but the function expects a object<The>.

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...
32
        if (!$currentSize) {
33
            $currentSize = $this->currentFontSize();
34
        }
35
        return $currentSize * 100;
36
    }
37
38
    public function HasAlteredFont()
39
    {
40
        if ($this->currentFontSize() != 1) {
0 ignored issues
show
This if statement, and the following return statement can be replaced with return $this->currentFontSize() != 1;.
Loading history...
41
            return true;
42
        }
43
        return false;
44
    }
45
46
47
    // *** ACTIONS
48
49
    public function increasefontsize()
50
    {
51
        return $this->fontAction(1 * self::$font_size_change);
52
    }
53
54
    public function decreasefontsize()
55
    {
56
        return $this->fontAction(-1 * self::$font_size_change);
57
    }
58
59
    public function resetfontsize()
60
    {
61
        Session::clear("fontsize");
62
        return $this->fontAction(0);
63
    }
64
65
66
    // *** INTERNAL FUNCTIONS
67
68
    protected function fontAction($change)
69
    {
70
        $currentSize = $this->currentFontSize();
71
        $currentSize = floatval($currentSize) + $change;
72
        Session::set("fontsize", $currentSize);
73
        if (Director::is_ajax()) {
74
            return $this->CurrentFontSizeInPercentages($currentSize);
75
        } else {
76
            Director::redirectBack();
0 ignored issues
show
Deprecated Code introduced by
The method Director::redirectBack() has been deprecated with message: 2.5 Use Controller->redirectBack()

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
77
        }
78
        return array();
79
    }
80
81
82
    protected function currentFontSize()
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
83
    {
84
        $currentSize = Session::get("fontsize");
85
        if (!$currentSize) {
86
            $currentSize = 1;
87
        }
88
        if ($currentSize < self::$min_font_size) {
89
            $currentSize = self::$min_font_size;
90
        }
91
        if ($currentSize > self::$max_font_size) {
92
            $currentSize = self::$max_font_size;
93
        }
94
        //make percentage
95
        return $currentSize;
96
    }
97
}
98