Issues (6)

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/GoogleDfpSlotHelper.php (2 issues)

Labels

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
 * Google DFP Slot Helper class
5
 *
6
 *
7
 * @package SilverStripe-Google-DFP
8
 * @copyright 2017 Fractas Labs
9
 * @license https://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
10
 * @link https://github.com/fractaslabs/silverstripe-google-dfp
11
 */
12
class GoogleDfpSlotHelper extends Object
13
{
14
    private static $id;
15
16
    private static $enable_in_dev = false;
17
18
    public function GoogleDfpID()
19
    {
20
        return Config::inst()->get('GoogleDfpSlotHelper', 'publisher_id');
21
    }
22
23
    public static function enable_in_dev()
24
    {
25
        return Config::inst()->get('GoogleDfpSlotHelper', 'enable_in_dev');
26
    }
27
28
    /**
29
     * Check if ads should be enabled
30
     * By default they are enabled in "live" enviroment
31
     *
32
     * @return boolean
33
     */
34
    public static function enabled()
35
    {
36
        if (Director::isLive()) {
37
            return true;
38
        } elseif (Director::isDev() && self::enable_in_dev()) {
39
            return true;
40
        }
41
42
        return false;
43
    }
44
45
    /**
46
     *
47
     * ID - unique identifier of banner
48
     * Layout - Controller ClassName where banner should be rendered
49
     * Alias - name of banner (used to distinguish )
50
     * AdUnitPath - Full path of the ad unit with the network code and ad unit code.
51
     * Size - An exact size of banner creative
52
     * OutOfPage - if banner is "wallpaper" or "floater" type specify as "true"
53
     * DfpTargetPage - current Page ID
54
     * DfpTargetCategory - Parent Title of current Page ID
55
     * DfpTargetCategoryParent - GrandParent Title of current Page ID (if has)
56
     *
57
     * @return mixed
58
     */
59
    public static function slot_list()
60
    {
61
        $list = Config::inst()->get('GoogleDfpSlotHelper', 'layouts');
62
        if (!is_array($list)) {
63
            return false;
64
        }
65
66
        $out = ArrayList::create();
67
        $controller = Controller::curr();
68
        $dfpTargetPage = $controller->ID;
69
        $dfpTargetCategory = $controller->Parent()->Title ? $controller->Parent()->Title : $controller->Title;
0 ignored issues
show
The method Parent() does not exist on Controller. Did you maybe mean parentClass()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
70
        $dfpTargetCategoryParent = $controller->Parent()->Parent()->Title ? $controller->Parent()->Parent()->Title : null;
0 ignored issues
show
The method Parent() does not exist on Controller. Did you maybe mean parentClass()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
71
72
        foreach ($list as $key => $item) {
73
            foreach ($item as $slotKey => $slot) {
74
                $out->add(ArrayData::create(array(
75
                    'ID' => $slotKey,
76
                    'Layout' => $key,
77
                    'Alias' => isset($slot['alias']) ? $slot['alias'] : null,
78
                    'AdUnitPath' => isset($slot['adUnitPath']) ? $slot['adUnitPath'] : null,
79
                    'Size' => isset($slot['size']) ? $slot['size'] : null,
80
                    'OutOfPage' => isset($slot['outOfPage']) ? $slot['outOfPage'] : false,
81
                    'DfpTargetPage' => $dfpTargetPage,
82
                    'DfpTargetCategory' => $dfpTargetCategory,
83
                    'DfpTargetCategoryParent' => $dfpTargetCategoryParent,
84
                    'DfpTargetRos' => $key,
85
                )));
86
            }
87
        }
88
89
        return $out;
90
    }
91
92
    /**
93
     * Get one banner by ID
94
     *
95
     *
96
     * @param $id
97
     */
98
    public static function slot_by_id($id = false)
99
    {
100
        return self::slot_list()
101
                ->filter(array('ID' => $id, 'Layout' => Controller::curr()->ClassName))
102
                ->first();
103
    }
104
105
    /**
106
     * Get one banner by Alias name
107
     *
108
     *
109
     * @param $alias
110
     */
111
    public static function slot_by_alias($alias = false)
112
    {
113
        return self::slot_list()
114
                ->filter(array('Alias' => $alias, 'Layout' => Controller::curr()->ClassName))
115
                ->first();
116
    }
117
}
118