GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (115)

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.

src/BlockManager.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
namespace SheaDawson\Blocks;
4
5
use SilverStripe\ORM\ArrayLib;
6
use SilverStripe\SiteConfig\SiteConfig;
7
use SilverStripe\Core\Config\Config;
8
use SilverStripe\Core\ClassInfo;
9
use SilverStripe\Forms\FormField;
10
use SilverStripe\View\SSViewer;
11
use SilverStripe\View\ViewableData;
12
13
/**
14
 * BlockManager.
15
 *
16
 * @author Shea Dawson <[email protected]>
17
 */
18
class BlockManager extends ViewableData
19
{
20
	/**
21
	 * Use default ContentBlock class.
22
	 *
23
	 * @var bool
24
	 **/
25
	private static $use_default_blocks = true;
0 ignored issues
show
The property $use_default_blocks 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...
26
27
	/**
28
	 * Show a block area preview button in CMS
29
	 *
30
	 * @var bool
31
	 **/
32
	private static $block_area_preview = true;
0 ignored issues
show
The property $block_area_preview 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
34
	public function __construct()
35
	{
36
		parent::__construct();
37
	}
38
39
	/**
40
	 * Gets an array of all areas defined for blocks.
41
	 *
42
	 * @param bool   $keyAsValue
43
	 *
44
	 * @return array $areas
45
	 **/
46
	public function getAreas($keyAsValue = true)
47
	{
48
		$areas = $this->config()->get('areas');
49
50
		$areas = $keyAsValue ? ArrayLib::valuekey(array_keys($areas)) : $areas;
51
		if (count($areas)) {
52
			foreach ($areas as $k => $v) {
53
				$areas[$k] = $keyAsValue ? FormField::name_to_label($k) : $v;
54
			}
55
		}
56
57
		return $areas;
58
	}
59
60
	/**
61
	 * Gets an array of all areas defined that are compatible with pages of type $class.
62
	 *
63
	 * @param string $class
64
	 *
65
	 * @return array $areas
66
	 **/
67
	public function getAreasForPageType($class)
68
	{
69
		$areas = $this->getAreas(false);
70
71
		if (!$areas) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $areas of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
72
			return false;
73
		}
74
75
		foreach ($areas as $area => $config) {
76
			if (!is_array($config)) {
77
				continue;
78
			}
79
80 View Code Duplication
			if (isset($config['except'])) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
81
				$except = $config['except'];
82
				if (is_array($except)
83
					? in_array($class, $except)
84
					: $except == $class
85
				) {
86
					unset($areas[$area]);
87
					continue;
88
				}
89
			}
90
91 View Code Duplication
			if (isset($config['only'])) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
92
				$only = $config['only'];
93
				if (is_array($only)
94
					? !in_array($class, $only)
95
					: $only != $class
96
				) {
97
					unset($areas[$area]);
98
					continue;
99
				}
100
			}
101
		}
102
103
		if (count($areas)) {
104
			foreach ($areas as $k => $v) {
105
				$areas[$k] = _t('Block.BlockAreaName.'.$k, FormField::name_to_label($k));
106
			}
107
108
			return $areas;
109
		} else {
110
			return $areas;
111
		}
112
	}
113
114
	public function getBlockClasses()
115
	{
116
		$classes = ArrayLib::valuekey(ClassInfo::subclassesFor("SheaDawson\Blocks\model\Block"));
117
		array_shift($classes);
118
		foreach ($classes as $k => $v) {
119
			$classes[$k] = singleton($k)->singular_name();
120
		}
121
122
		$config = $this->config()->get('options');
123
124
		if (isset($config['use_default_blocks']) && !$config['use_default_blocks']) {
125
	        unset($classes['ContentBlock']);
126
	    } else if (!$config['use_default_blocks']) {
127
	        unset($classes['ContentBlock']);
128
	    }
129
130
		$disabledArr = Config::inst()->get("BlockManager", 'disabled_blocks') ? Config::inst()->get("BlockManager", 'disabled_blocks') : [];
131
		if (isset($config['disabled_blocks'])) {
132
		    $disabledArr = array_merge($disabledArr, $config['disabled_blocks']);
133
		}
134
		if (count($disabledArr)) {
135
			foreach ($disabledArr as $k => $v) {
136
				unset($classes[$v]);
137
			}
138
		}
139
140
		return $classes;
141
	}
142
143
	/*
144
	 * Usage of BlockSets configurable from yaml
145
	 */
146
	public function getUseBlockSets()
147
	{
148
		$config = $this->config()->get('options');
149
150
		return isset($config['use_blocksets']) ? $config['use_blocksets'] : true;
151
	}
152
153
	/*
154
	 * Exclusion of blocks from page types defined in yaml
155
	 */
156
	public function getExcludeFromPageTypes()
157
	{
158
		$config = $this->config()->get('options');
159
160
		return isset($config['exclude_from_page_types']) ? $config['exclude_from_page_types'] : [];
161
	}
162
163
	/*
164
	 * getWhiteListedPageTypes optionally configured by the developer
165
	 */
166
	public function getWhiteListedPageTypes()
167
	{
168
		$config = $this->config()->get('options');
169
		return isset($config['pagetype_whitelist']) ? $config['pagetype_whitelist'] : [];
170
	}
171
172
	/*
173
	 * getBlackListedPageTypes optionally configured by the developer
174
	 * Includes blacklisted page types defined in the old exclude_from_page_types array
175
	 */
176
	public function getBlackListedPageTypes()
177
	{
178
		$config = $this->config()->get('options');
179
		$legacy = isset($config['exclude_from_page_types']) ? $config['exclude_from_page_types'] : [];
180
		$current = isset($config['pagetype_blacklist']) ? $config['pagetype_blacklist'] : [];
181
		return array_merge($legacy, $current);
182
	}
183
184
	/*
185
	 * Usage of extra css classes configurable from yaml
186
	 */
187
	public function getUseExtraCSSClasses()
188
	{
189
		$config = $this->config()->get('options');
190
191
		return isset($config['use_extra_css_classes']) ? $config['use_extra_css_classes'] : false;
192
	}
193
194
	/*
195
	 * Prefix for the default CSSClasses
196
	 */
197
	public function getPrefixDefaultCSSClasses()
198
	{
199
		$config = $this->config()->get('options');
200
201
		return isset($config['prefix_default_css_classes']) ? $config['prefix_default_css_classes'] : false;
202
	}
203
}
204