Issues (13)

Security Analysis    no request data  

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/MembersOnlyPage.php (11 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
0 ignored issues
show
File has mixed line endings; this may cause incorrect results
Loading history...
2
3
class MembersOnlyPage extends Page
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
    private static $add_action = 'Members Only Page';
0 ignored issues
show
The property $add_action is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
6
7
    private static $icon = 'mysite/images/treeicons/MembersOnlyPage';
0 ignored issues
show
The property $icon is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
8
9
    private static $default_parent = 'MembersOnlyPage';
0 ignored issues
show
The property $default_parent is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
10
11
    private static $allowed_children = array("MembersOnlyPage");
0 ignored issues
show
The property $allowed_children is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
12
13
    private static $group_code = "intranet-users";
14
    public static function set_group_code($v)
15
    {
16
        self::$group_code = $v;
17
    }
18
    public static function get_group_code()
19
    {
20
        return self::$group_code;
21
    }
22
23
    private static $group_name = "intranet users";
24
    public static function set_group_name($v)
25
    {
26
        self::$group_name = $v;
27
    }
28
    public static function get_group_name()
29
    {
30
        return self::$group_name;
31
    }
32
33
    private static $permission_code = "INTRANET_USERS";
34
    public static function set_permission_code($v)
35
    {
36
        self::$permission_code = $v;
37
    }
38
    public static function get_permission_code()
39
    {
40
        return self::$permission_code;
41
    }
42
43
    private static $defaults = array(
0 ignored issues
show
The property $defaults is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
44
        "ProvideComments" => 1,
45
        "ShowInSearch" => 0
46
    );
47
48
49
    public function getCMSFields()
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...
50
    {
51
        $fields = parent::getCMSFields();
52
        return $fields;
53
    }
54
55
    public function canView($member = null)
56
    {
57
        if ($member = Member::currentUser()) {
58
            if ($member->inGroup("ADMIN") || Permission::checkMember($member, self::$permission_code)) {
59
                return true;
60
            }
61
        }
62
        return false;
63
    }
64
65
    public function getShowInMenus()
66
    {
67
        return $this->canView();
68
    }
69
70
    public function ShowInMenus()
71
    {
72
        return $this->canView();
73
    }
74
75
    public function getShowInSearch()
76
    {
77
        return $this->canView();
78
    }
79
80
    public function ShowInSearch()
81
    {
82
        return $this->canView();
83
    }
84
85
    public function requireDefaultRecords()
86
    {
87
        parent::requireDefaultRecords();
88
        $intranetGroup = Group::get()->filter(array("Code" => $this->Config()->get("group_code")))->first();
89
        if ($intranetGroup && $intranetGroup->exists()) {
0 ignored issues
show
This if statement is empty and can be removed.

This check looks for the bodies of if statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These if bodies can be removed. If you have an empty if but statements in the else branch, consider inverting the condition.

if (rand(1, 6) > 3) {
//print "Check failed";
} else {
    print "Check succeeded";
}

could be turned into

if (rand(1, 6) <= 3) {
    print "Check succeeded";
}

This is much more concise to read.

Loading history...
90
            //do nothing
91
        } else {
92
            $intranetGroup = new Group();
93
            DB::alteration_message($this->Config()->get("group_name").' group created', "created");
94
        }
95
        if ($intranetGroup) {
96
            $intranetGroup->Code = $this->Config()->get("group_code");
97
            $intranetGroup->Title = $this->Config()->get("group_name");
98
            $intranetGroup->write();
99
            Permission::grant($intranetGroup->ID, $this->Config()->get("permission_code"));
100
            if (DB::query("
101
				SELECT *
102
				FROM Permission
103
				WHERE \"GroupID\" = '".$intranetGroup->ID."'
104
					AND \"Code\" LIKE '".$this->Config()->get("permission_code")."'")->numRecords() == 0
105
            ) {
106
                Permission::grant($intranetGroup->ID, $this->Config()->get("permission_code"));
107
                DB::alteration_message($this->Config()->get("group_name").' permissions granted', "created");
108
            }
109
        }
110
    }
111
}
112
113
class MembersOnlyPage_Controller extends Page_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...
114
{
115
    public function init()
116
    {
117
        parent::init();
118
        Requirements::themedCSS("MembersOnlyPage", "membersonlypages");
119
    }
120
}
121