Issues (27)

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/FaqHolderPage.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
2
3
/**
4
 *@author nicolaas[at]sunnysideup.co.nz
5
 *@description: holds FAQs and displays them nicely.
6
 *
7
 */
8
class FaqHolderPage 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...
9
{
10
    private static $icon = "mysite/images/treeicons/FaqHolderPage";
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...
11
12
    private static $description =  "A list of Frequently Asked Questions" ;
0 ignored issues
show
The property $description 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...
13
14
    //private static $default_parent = '';
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
15
16
    private static $default_child = 'FaqOnePage';
0 ignored issues
show
The property $default_child 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...
17
18
    private static $allowed_children = array('FaqHolderPage', 'FaqOnePage');
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...
19
20
    /**
21
     * Standard SS variable.
22
     */
23
    private static $singular_name = "FAQ Holder Page";
0 ignored issues
show
The property $singular_name 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...
24
    public function i18n_singular_name()
25
    {
26
        return _t("FAQHolderPage.SINGULARNAME", "FAQ Holder Page");
27
    }
28
29
    /**
30
     * Standard SS variable.
31
     */
32
    private static $plural_name = "FAQ Holder Pages";
0 ignored issues
show
The property $plural_name 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...
33
    public function i18n_plural_name()
34
    {
35
        return _t("FAQHolderPage.PLURALNAME", "FAQ Holder Pages");
36
    }
37
38
    /**
39
     * The holder page class in use.
40
     * You can extends this Class and change this value.
41
     * @var String
42
     */
43
    protected $holderPage = "FAQHolderPage";
44
45
    /**
46
     * The item page class in use.
47
     * You can extends this Class and change this value.
48
     * @var String
49
     */
50
    protected $entryPage = "FAQOnePage";
51
52
    /**
53
     * Returns children FAQHolderPage pages of this FAQHolderPage.
54
     *
55
     * @param Int $maxRecursiveLevel - maximum depth , e.g. 1 = one level down - so no Child Groups are returned...
56
     * @param Int $numberOfRecursions - current level of depth. DONT provide this variable...
57
     * @return ArrayList (FAQHolderPages)
58
     */
59
    public function ChildGroups($maxRecursiveLevel = 99, $numberOfRecursions = 0)
60
    {
61
        $arrayList = ArrayList::create();
62
        if ($numberOfRecursions < $maxRecursiveLevel) {
63
            $className = $this->getHolderPage();
64
            $children = $className::get()->filter(array("ParentID" => $this->ID));
65
            if ($children->count()) {
66
                foreach ($children as $child) {
67
                    $arrayList->push($child);
68
                    $arrayList->merge($child->ChildGroups($maxRecursiveLevel, $numberOfRecursions++));
69
                }
70
            }
71
        }
72
73
        return $arrayList;
74
    }
75
76
    /**
77
     * sets the classname for pages that are holder pages
78
     * @param String $name
79
     */
80
    public function setHolderPage($name)
81
    {
82
        $this->holderPage = $name;
83
    }
84
85
    /**
86
     * gets the classname for pages that are holder pages
87
     * @return String
88
     */
89
    public function getHolderPage()
90
    {
91
        return $this->holderPage;
92
    }
93
94
    /**
95
     * sets the classname for pages that are individual items
96
     * @param String $name
97
     */
98
    public function setEntryName($name)
99
    {
100
        $this->entryPage;
101
    }
102
103
    /**
104
     * gets the classname for pages that are individual items
105
     * @return String
106
     */
107
    public function getEntryName()
108
    {
109
        return $this->entryPage;
110
    }
111
}
112
113
class FaqHolderPage_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::javascript(THIRDPARTY_DIR."/jquery/jquery.js");
119
        Requirements::javascript("faqs/javascript/FaqHolderPage.js");
120
        Requirements::themedCSS("FaqHolderPage", "faqs");
121
    }
122
123
    /**
124
     * returns all underlying FaqOnePage pages...
125
     * for use in templates
126
     * @return DataList | Null
127
     */
128
    public function Entries()
129
    {
130
        $array = array($this->ID => $this->ID);
131
        if ($childGroups = $this->ChildGroups(4)) {
132
            if ($childGroups->count()) {
133
                foreach ($childGroups->map("ID", "ID") as $id) {
134
                    $array[$id] = $id;
135
                }
136
            }
137
        }
138
        $stage = '';
139
        if (Versioned::current_stage() == "Live") {
140
            $stage = "_Live";
141
        }
142
        $className = $this->dataRecord->getEntryName();
143
        return $className::get()
144
            ->filter(array("ParentID" => $array, "ShowInSearch" => 1))
145
            ->leftJoin("SiteTree".$stage, "SiteTree".$stage.".ParentID = MyParent.ID", "MyParent")
146
            ->leftJoin("SiteTree".$stage, "MyParent.ParentID = MyGrandParent.ID", "MyGrandParent")
147
            ->leftJoin("SiteTree".$stage, "MyGrandParent.ParentID = MyGreatGrandParent.ID", "MyGreatGrandParent")
148
            ->leftJoin("SiteTree".$stage, "MyGreatGrandParent.ParentID = MyGreatGreatGrandParent.ID", "MyGreatGreatGrandParent")
149
            ->sort(
150
                "
151
                MyGreatGreatGrandParent.Sort,
152
                MyGreatGrandParent.Sort,
153
                MyGrandParent.Sort,
154
                MyParent.Sort,
155
                SiteTree".$stage.".Sort"
156
            );
157
    }
158
159
    public function MyParentHolder()
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...
160
    {
161
        $className = $this->dataRecord->getHolderPage();
162
        return $className::get()->byID($this->ParentID);
163
    }
164
}
165