Issues (211)

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.

src/Forms/GridFieldQueuedJobExecute.php (2 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 Symbiote\QueuedJobs\Forms;
4
5
use SilverStripe\Forms\GridField\GridField;
6
use SilverStripe\Forms\GridField\GridField_ActionProvider;
7
use SilverStripe\Forms\GridField\GridField_ColumnProvider;
8
use SilverStripe\Forms\GridField\GridField_FormAction;
9
use Symbiote\QueuedJobs\Services\QueuedJob;
10
use SilverStripe\View\Requirements;
11
12
/**
13
 * This class is a {@link GridField} component that adds a delete action for objects.
14
 *
15
 * This component also supports unlinking a relation instead of deleting the object.
16
 * Use the {@link $removeRelation} property set in the constructor.
17
 *
18
 * <code>
19
 * $action = new GridFieldDeleteAction(); // delete objects permanently
20
 * $action = new GridFieldDeleteAction(true); // removes the relation to object, instead of deleting
21
 * </code>
22
 *
23
 * @package queuedjobs
24
 * @subpackage forms
25
 */
26
class GridFieldQueuedJobExecute implements GridField_ColumnProvider, GridField_ActionProvider
27
{
28
29
    protected $action = 'execute';
30
31
    /**
32
     * @var array
33
     */
34
    protected $icons = array(
35
        'execute' => 'navigation',
36
        'pause'   => 'minus-circle_disabled',
37
        'resume'  => 'arrow-circle-double',
38
    );
39
40
    /**
41
     * Call back to see if the record's action icon should be shown.
42
     *
43
     * @var closure
44
     */
45
    protected $viewCheck;
46
47
    /**
48
     * @param string   $action
49
     * @param callable $check
50
     */
51
    public function __construct($action = 'execute', $check = null)
52
    {
53
        $this->action = $action;
54
        if (!$check) {
55
            $check = function ($record) {
56
                return $record->JobStatus == QueuedJob::STATUS_WAIT || $record->JobStatus == QueuedJob::STATUS_NEW;
57
            };
58
        }
59
60
        $this->viewCheck = $check;
0 ignored issues
show
Documentation Bug introduced by
It seems like $check of type object<Closure> is incompatible with the declared type object<Symbiote\QueuedJobs\Forms\closure> of property $viewCheck.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
61
    }
62
63
    /**
64
     * Add a column 'Delete'
65
     *
66
     * @param GridField $gridField
67
     * @param array     $columns
68
     */
69
    public function augmentColumns($gridField, &$columns)
70
    {
71
        if (!in_array('Actions', $columns)) {
72
            $columns[] = 'Actions';
73
        }
74
    }
75
76
    /**
77
     * Return any special attributes that will be used for FormField::createTag()
78
     *
79
     * @param GridField $gridField
80
     * @param DataObject $record
81
     * @param string $columnName
82
     * @return array
83
     */
84
    public function getColumnAttributes($gridField, $record, $columnName)
85
    {
86
        return array('class' => 'col-buttons');
87
    }
88
89
    /**
90
     * Add the title
91
     *
92
     * @param GridField $gridField
93
     * @param string $columnName
94
     * @return array
95
     */
96
    public function getColumnMetadata($gridField, $columnName)
97
    {
98
        if ($columnName == 'Actions') {
99
            return array('title' => '');
100
        }
101
    }
102
103
    /**
104
     * Which columns are handled by this component
105
     *
106
     * @param GridField $gridField
107
     * @return array
108
     */
109
    public function getColumnsHandled($gridField)
110
    {
111
        return array('Actions');
112
    }
113
114
    /**
115
     * Which GridField actions are this component handling
116
     *
117
     * @param GridField $gridField
118
     * @return array
119
     */
120
    public function getActions($gridField)
121
    {
122
        return array('execute', 'pause', 'resume');
123
    }
124
125
    /**
126
     * @param GridField $gridField
127
     * @param DataObject $record
128
     * @param string $columnName
129
     * @return string|void - the HTML for the column
130
     */
131
    public function getColumnContent($gridField, $record, $columnName)
132
    {
133
        $icon = $this->icons[$this->action];
134
135
        if ($this->viewCheck) {
136
            $func = $this->viewCheck;
137
            if (!$func($record)) {
138
                return;
139
            }
140
        }
141
142
        $field = GridField_FormAction::create(
143
            $gridField,
144
            'ExecuteJob' . $record->ID,
145
            false,
146
            $this->action,
147
            array('RecordID' => $record->ID)
148
        );
149
        $field->addExtraClass('gridfield-button-job' . $this->action)
150
            ->setAttribute('title', ucfirst($this->action))
151
            ->setAttribute('data-icon', $icon);
152
        return $field->Field();
153
    }
154
155
    /**
156
     * Handle the actions and apply any changes to the GridField
157
     *
158
     * @param GridField $gridField
159
     * @param string $actionName
160
     * @param mixed $arguments
161
     * @param array $data - form data
162
     * @return void
163
     */
164
    public function handleAction(GridField $gridField, $actionName, $arguments, $data)
165
    {
166
        $actions = $this->getActions(null);
0 ignored issues
show
null is of type null, but the function expects a object<SilverStripe\Forms\GridField\GridField>.

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...
167
        if (in_array($actionName, $actions)) {
168
            $item = $gridField->getList()->byID($arguments['RecordID']);
169
            if (!$item) {
170
                return;
171
            }
172
            $item->$actionName();
173
            Requirements::clear();
174
        }
175
    }
176
}
177