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 (43)

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/forms/GridFieldDropdownAddNewButton.php (4 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
 * This component creates a dropdown of possible data object classes and a button to create a new instance.
5
 *
6
 */
7
class GridFieldDropdownAddNewButton extends GridFieldAddNewButton
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...
Expected 0 spaces between "GridFieldAddNewButton" and comma; 1 found
Loading history...
8
	implements GridField_ActionProvider {
0 ignored issues
show
The implements keyword must be on the same line as the class name
Loading history...
9
10
	/**
11
	 * Class names
12
	 *
13
	 * @var array
14
	 */
15
	protected $modelClasses = null;
16
17
	/**
18
	 * This is because this doesn't extend Object
19
	 *
20
	 */
21
	public static function create($baseClass, $classes, $targetFragment = 'buttons-before-left')
22
	{
23
		return new GridFieldDropdownAddNewButton($baseClass, $classes, $targetFragment);
24
	}
25
26
	/**
27
	 * @param string $baseClass
28
	 * @param array $classes Class or list of classes to create.
29
	 * @param string $targetFragment The fragment to render the button into
30
	 */
31
	public function __construct($baseClass, $classes, $targetFragment = 'buttons-before-left')
32
	{
33
		if (!is_array($classes)) {
34
			user_error('$classes is not an array', E_USER_ERROR);
35
		}
36
37
		$this->setClasses($classes);
38
39
		foreach($this->getClasses() as $class => $nice){
40
			if(!is_subclass_of($class, $baseClass)){
41
				user_error(sprintf('%s is not a subclass of %s', $class, $baseClass), E_USER_ERROR);
42
			}
43
		}
44
45
		parent::__construct($targetFragment);
46
	}
47
48
	/**
49
	 * Specify the classes to create
50
	 *
51
	 * @param array $classes
52
	 */
53
	public function setClasses($classes)
54
	{
55
		$this->modelClasses = $classes;
56
	}
57
58
	/**
59
	 * Get the classes of the objects to create
60
	 *
61
	 * @return array
62
	 */
63
	public function getClasses()
64
	{
65
		return $this->modelClasses;
66
	}
67
68
	/**
69
	 * Abstract method to fill out. Gets the HTML for this component
70
	 * @param $gridField GridField
71
	 */
72
	public function getHTMLFragments($gridField)
73
	{
74
		$state = $gridField->State->GridFieldDropdownAddNewButton;
75
		$classesSource = $this->getClasses();
76
77
		if(empty($classesSource)) {
78
			return [];
79
		} else if(count($classesSource) > 1) {
80
			$dropdown = DropdownField::create(
81
				"Class",
82
				"Class",
83
				$classesSource
84
			)->setFieldHolderTemplate("GridFieldDropdownAddNewButton_holder")
85
			->addExtraClass("gridfield-dropdown no-change-track");
86
87
			if (!$this->buttonName) {
88
				$this->buttonName = 'Add new';
89
			}
90
		} else {
91
			$class = key($classesSource);
92
			$dropdown = HiddenField::create(
93
				"Class",
94
				"Class",
95
				$class
96
			);
97
98
			if (!$this->buttonName) {
99
				$this->buttonName = sprintf('Add new %s', $class);
100
			}
101
		}
102
103
		$state->class = key($classesSource);
104
105
		$action = GridField_FormAction::create(
106
			$gridField,
107
			'add',
108
			$this->buttonName,
109
			'add',
110
			'add'
111
		)->setAttribute(
112
			'data-icon',
113
			'add'
114
		)->addExtraClass("no-ajax ss-ui-action-constructive dropdown-action");
115
116
		Requirements::css(CONTENTBLOCKS_DIR . "/css/GridFieldDropdownAddNewButton.css");
117
		Requirements::javascript(CONTENTBLOCKS_DIR . "/javascript/GridFieldDropdownAddNewButton.js");
118
119
		return [
120
			$this->targetFragment => ArrayData::create([
121
				'Fields' => ArrayList::create([
122
					$dropdown,
123
					$action,
124
				]),
125
			])->renderWith("GridFieldDropdownAddNewButton"),
126
		];
127
	}
128
129
	/**
130
	 * Provide actions to this component.
131
	 *
132
	 * @param GridField $gridField
133
	 * @return array
134
	**/
135
	public function getActions($gridField) {
136
		return ["add"];
137
	}
138
139
	/**
140
	 * Handles the add action
141
	 *
142
	 * @param GridField $gridField
143
	 * @param string $actionName
144
	 * @param mixed $arguments
145
	 * @param array $data
146
	**/
147
	public function handleAction(GridField $gridField, $actionName, $arguments, $data)
148
	{
149
		$response = $gridField->getForm()->controller->response;
150
151
		if(in_array(strtolower($actionName), $this->getActions($gridField))) {
152
			$class = null;
153
			$name = $gridField->getName();
154
			if (isset($data[$name]) && isset($data[$name]['GridState'])){
155
				$state = json_decode($data[$name]['GridState'], true);
156
				// Debug::dump($state);
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% 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...
157
				if (isset($state['GridFieldDropdownAddNewButton'])
158
				&& isset($state['GridFieldDropdownAddNewButton']['class'])) {
159
					$class = $state['GridFieldDropdownAddNewButton']['class'];
160
				}
161
			}
162
163
			if(!$class || !$this->isValidClass($class)) {
164
				return Controller::curr()->redirectBack();
165
			}
166
167
			$list = $gridField->getList();
168
			$object = $class::create();
169
			$object->write();
170
			$list->add($object);
171
172
			$url = Controller::join_links($gridField->link('item'), $object->ID);
173
174
			$response->redirect(Director::absoluteBaseURL() . $url);
175
			return $response;
176
		}
177
178
		return Controller::curr()->redirectBack();
179
	}
180
181
	/**
182
	 * Validates that a class is okay for creation
183
	 *
184
	 * @param string
185
	 * @return bool
186
	 */
187
	public function isValidClass($class)
188
	{
189
		if (!array_key_exists($class, $this->getClasses())) {
190
			return false;
191
		}
192
193
		return singleton($class)->canCreate();
194
	}
195
}
196