Issues (621)

Security Analysis    not enabled

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/FileWorkflowApplicable.php (3 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
 * WorkflowApplicable extension specifically for File objects, which don't have the same CMS
4
 * UI structure so need to be handled a little differently. Additionally, it doesn't really 
5
 * work without custom code to handle the triggering of workflow, and in general is not
6
 * ready for production use just yet. 
7
 *
8
 * @author  [email protected]
9
 * @license BSD License (http://silverstripe.org/bsd-license/)
10
 * @package advancedworkflow
11
 */
12
class FileWorkflowApplicable extends WorkflowApplicable {
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...
13
	
14
	public function updateSummaryFields(&$fields) {
15
		$fields['ID'] = 'ID';
16
		$fields['ParentID'] = 'ParentID';
17
	}
18
19
	public function updateCMSFields(FieldList $fields) {
20
		if (!$this->owner->ID) {
21
			return $fields;
22
		}
23
		parent::updateCMSFields($fields);
24
25
		// add the workflow fields directly. It's a requirement of workflow on file objects
26
		// that CMS admins mark the workflow step as being editable for files to be administerable
27
		$active = $this->workflowService->getWorkflowFor($this->owner);
28
		if ($active) {
29
			$current = $active->CurrentAction();
30
			$wfFields = $active->getWorkflowFields();
31
			
32
			// loading data in a somewhat hack way
33
			$form = new Form($this, 'DummyForm', $wfFields, new FieldList());
0 ignored issues
show
$this is of type this<FileWorkflowApplicable>, but the function expects a object<Controller>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
34
			$form->loadDataFrom($current);
35
36
			$fields->findOrMakeTab(
37
				'Root.WorkflowActions',
38
				_t('Workflow.WorkflowActionsTabTitle', 'Workflow Actions')
39
			);
40
			$fields->addFieldsToTab('Root.WorkflowActions', $wfFields);
0 ignored issues
show
$wfFields is of type object<FieldList>, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
41
		}
42
	}
43
44
	public function onAfterWrite() {
45
		parent::onAfterWrite();
46
		
47
		$workflow = $this->workflowService->getWorkflowFor($this->owner);
48
		$rawData = $this->owner->toMap();
49
		if ($workflow && $this->owner->TransitionID) {
50
			// we want to transition, so do so if that's a valid transition to take. 
51
			$action = $workflow->CurrentAction();
52
			if (!$this->canEditWorkflow()) {
53
				return;
54
			}
55
56
			$allowedFields = $workflow->getWorkflowFields()->saveableFields();
57
			unset($allowedFields['TransitionID']);
58
59
			$allowed = array_keys($allowedFields);
60
			
61
			foreach ($allowed as $field) {
62
				if (isset($rawData[$field])) {
63
					$action->$field = $rawData[$field];
64
				}
65
			}
66
			
67
			$action->write();
68
69
			if (isset($rawData['TransitionID']) && $rawData['TransitionID']) {
70
				// unset the transition ID so this doesn't get re-executed
71
				$this->owner->TransitionID = null;
72
				$this->workflowService->executeTransition($this->owner, $rawData['TransitionID']);
73
			} else {
74
				// otherwise, just try to execute the current workflow to see if it
75
				// can now proceed based on user input
76
				$workflow->execute();
77
			}
78
		}
79
	}
80
}