Issues (14)

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/extensions/HeaderGalleryExtension.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
/**
4
 * StartGeneratedWithDataObjectAnnotator
5
 * @method DataList|HeaderGalleryImage[] HeaderGallery
6
 * EndGeneratedWithDataObjectAnnotator
7
 */
8
class HeaderGalleryExtension extends DataExtension
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
11
    private static $has_many = array(
0 ignored issues
show
The property $has_many 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
        'HeaderGallery' => 'HeaderGalleryImage'
13
    );
14
15
    /**
16
     * Limit the number of displayed header images
17
     * If set to 1 we have a single upload field
18
     * @var int
19
     */
20
    private static $limit_header_images = 0;
0 ignored issues
show
The property $limit_header_images 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...
21
22
    private static $delete_permission = "CMS_ACCESS_CMSMain";
0 ignored issues
show
The property $delete_permission 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...
23
24
25
    public function updateCMSFields(FieldList $fields)
26
    {
27
        /**
28
         * @var GridFieldConfig $conf
29
         */
30
        $conf = GridFieldConfig_RecordEditor::create(10);
31
        $conf->addComponent(new GridFieldSortableRows('SortOrder'));
32
        $conf->addComponent(new GridFieldGalleryTheme('Attachment'));
33
        $conf->addComponent(new GridFieldBulkUpload());
34
        $conf->getComponentByType('GridFieldBulkUpload')->setUfSetup('setFolderName', 'header');
0 ignored issues
show
The method setUfSetup() does not seem to exist on object<GridFieldComponent>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
35
36
        if (class_exists('GridFieldPaginatorWithShowAll')) {
37
            $conf->removeComponentsByType('GridFieldPaginator');
38
            $conf->addComponent(new GridFieldPaginatorWithShowAll(10));
39
        }
40
41
        $fields->addFieldToTab(
42
            "Root." . _t('HeaderGalleryExtension.GalleryTabName', 'Header Gallery'),
43
            Gridfield::create(
44
                'HeaderGallery',
45
                _t('HeaderGalleryExtension.GalleryFieldTitle', 'Gallery in header'),
46
                $this->owner->HeaderGallery(),
47
                $conf
48
            )
49
        );
50
    }
51
52
    /**
53
     * Helper for getting the header gallery in the template
54
     * Tries to find the current gallery, falls back to parent pages and home-page or SiteConfig if it has a standard gallery
55
     * @return null|void
56
     */
57
    public function getHeaderPics()
58
    {
59
        $owner = $this->getGalleryOwner();
60
61
        if (!$owner->ID) {
62
            return;
63
        }
64
65
        if (isset($owner->ID) && $owner->HeaderGallery()->count() > 0) {
66
            return $owner->HeaderGallery();
67
        }
68
69
        if ($owner->ParentID && $gallery = $this->getGalleryOfParent($owner)) {
70
            return $gallery;
71
        }
72
73
        return $this->getDefaultHeaderPics();
74
    }
75
76
    public function getGalleryOwner()
77
    {
78
        $owner = $this->owner;
79
80
        //overwrite owner in Translatable or Subsite setups
81
        $this->owner->extend('updateGalleryOwner', $owner);
82
83
        return $owner;
84
    }
85
86
    public function getGalleryOfParent($owner)
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...
87
    {
88
        $Parent = $owner->Parent();
89
90
        return (is_object($Parent) && $Parent->ID != 0)
91
            ? $Parent->getHeaderPics()
92
            : null;
93
    }
94
95
    /**
96
     * Helper to get the default header pics from e.g. SiteConfig
97
     * @return DataList|null|SS_Limitable
98
     */
99
    public function getDefaultHeaderPics()
100
    {
101
        $default = null;
102
103
        $this->owner->extend('updateDefaultHeaderPics', $default);
104
105
        if (!$default && class_exists('SiteConfig')) {
106
            $siteconfig = SiteConfig::current_site_config();
107
            if ($siteconfig->hasMethod('HeaderGallery')) {
108
                $default = $this->LimitGalleryItems($siteconfig->HeaderGallery());
109
            }
110
        }
111
112
        return $default;
113
    }
114
115
    /**
116
     * limits the number of displayed items
117
     *
118
     * @param DataList $galleryList
119
     * @return DataList|SS_Limitable
120
     */
121
    protected function LimitGalleryItems(DataList $galleryList)
122
    {
123
        $limit = Config::inst()->get('HeaderGalleryExtension', 'limit_header_images');
124
125
        return $limit ? $galleryList->limit($limit) : $galleryList;
126
    }
127
}
128