Issues (9)

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.

tests/GridField/GridFieldPaymentActionsTest.php (1 issue)

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 Bummzack\SsOmnipayUI\Tests\GridField;
4
5
use Bummzack\SsOmnipayUI\GridField\GridFieldCaptureAction;
6
use Bummzack\SsOmnipayUI\GridField\GridFieldRefundAction;
7
use Bummzack\SsOmnipayUI\GridField\GridFieldVoidAction;
8
use SilverStripe\Control\Controller;
9
use SilverStripe\Core\Config\Config;
10
use SilverStripe\Dev\CSSContentParser;
11
use SilverStripe\Dev\SapphireTest;
12
use SilverStripe\Forms\FieldList;
13
use SilverStripe\Forms\Form;
14
use SilverStripe\Forms\GridField\GridField;
15
use SilverStripe\Forms\GridField\GridFieldConfig;
16
use SilverStripe\Omnipay\GatewayInfo;
17
use SilverStripe\Omnipay\Model\Payment;
18
use SilverStripe\ORM\ArrayList;
19
use SilverStripe\ORM\DataList;
20
21
/**
22
 * Test payment actions in GridFields
23
 */
24
class GridFieldPaymentActionsTest extends SapphireTest
25
{
26
27
    /** @var ArrayList */
28
    protected $list;
29
30
    /** @var GridField */
31
    protected $gridField;
32
33
    /** @var Form */
34
    protected $form;
35
36
    /** @var string */
37
    protected static $fixture_file = 'GridFieldTestPayments.yml';
38
39
    public function setUp()
40
    {
41
        parent::setUp();
42
        $this->list = new DataList(Payment::class);
0 ignored issues
show
Documentation Bug introduced by
It seems like new \SilverStripe\ORM\Da...y\Model\Payment::class) of type object<SilverStripe\ORM\DataList> is incompatible with the declared type object<SilverStripe\ORM\ArrayList> of property $list.

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...
43
        $config = GridFieldConfig::create()
44
            ->addComponent(new GridFieldCaptureAction())
45
            ->addComponent(new GridFieldRefundAction())
46
            ->addComponent(new GridFieldVoidAction());
47
        $this->gridField = new GridField('testfield', 'testfield', $this->list, $config);
48
49
50
        $ctrl = new Controller();
51
        $ctrl::config()->set('url_segment', 'mock');
52
        $this->form = new Form(
53
            $ctrl,
54
            'mockform',
55
            new FieldList(array($this->gridField)),
56
            new FieldList()
57
        );
58
    }
59
60
    public function testButtons()
61
    {
62
        $content = new CSSContentParser($this->gridField->FieldHolder());
63
64
        // There should be a total of 5 items in the GridField (see fixture file)
65
        $this->assertEquals(5, count($content->getBySelector('tr.ss-gridfield-item')));
66
67
        // Two of the payments should have capture buttons
68
        $this->assertEquals(2, count($content->getBySelector('.gridfield-button-capture')));
69
70
        // Two payments should have a refund button
71
        $this->assertEquals(2, count($content->getBySelector('.gridfield-button-refund')));
72
73
        // Two payments should have a void button
74
        $this->assertEquals(2, count($content->getBySelector('.gridfield-button-void')));
75
76
        // Disallow actions for Manual Gateway
77
        Config::modify()->merge(GatewayInfo::class, 'Manual', array(
78
           'can_capture' => false,
79
           'can_refund' => false,
80
           'can_void' => false
81
        ));
82
83
        $content = new CSSContentParser($this->gridField->FieldHolder());
84
85
        // Now only one payment should have a capture button
86
        $this->assertEquals(1, count($content->getBySelector('.gridfield-button-capture')));
87
88
        // Now only one payment should have a refund button
89
        $this->assertEquals(1, count($content->getBySelector('.gridfield-button-refund')));
90
91
        // Now only one payment should have a void button
92
        $this->assertEquals(1, count($content->getBySelector('.gridfield-button-void')));
93
94
        // Update the authorized PaymentExpress_PxPay payment to Void
95
        $payment = $this->objFromFixture(Payment::class, 'payment3');
96
        $payment->Status = 'Void';
97
        $payment->write();
98
99
        $content = new CSSContentParser($this->gridField->FieldHolder());
100
        // Now no payment should have a capture button
101
        $this->assertEquals(0, count($content->getBySelector('.gridfield-button-capture')));
102
103
        // One payment should still have a refund button
104
        $this->assertEquals(1, count($content->getBySelector('.gridfield-button-refund')));
105
106
        // Now no payment should have a void button
107
        $this->assertEquals(0, count($content->getBySelector('.gridfield-button-void')));
108
    }
109
}
110