Issues (25)

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.

tests/Command/Member/ChangeGroupsCommandTest.php (1 issue)

Severity

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 SilverLeague\Console\Tests\Command\Member;
4
5
use SilverLeague\Console\Tests\Command\AbstractCommandTest;
6
use SilverStripe\Security\Member;
7
use Symfony\Component\Console\Helper\QuestionHelper;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Output\OutputInterface;
10
use Symfony\Component\Console\Question\ChoiceQuestion;
11
12
/**
13
 * Change a member's assigned groups
14
 *
15
 * @coversDefaultClass \SilverLeague\Console\Command\Member\ChangeGroupsCommand
16
 * @package silverstripe-console
17
 * @author  Robbie Averill <[email protected]>
18
 */
19
class ChangeGroupsCommandTest extends AbstractCommandTest
20
{
21
    /**
22
     * Delete fixtured members after tests have run
23
     */
24
    protected function tearDown()
25
    {
26
        parent::tearDown();
27
28
        $testMember = Member::get()->filter(['Email' => '[email protected]'])->first();
29
        if ($testMember && $testMember->exists()) {
30
            $testMember->delete();
31
        }
32
    }
33
34
    /**
35
     * {@inheritDoc}
36
     */
37
    protected function getTestCommand()
38
    {
39
        return 'member:change-groups';
40
    }
41
42
    /**
43
     * Test that an error message is returned if the Member does not exist
44
     *
45
     * @covers ::execute
46
     */
47
    public function testReportMemberNotFound()
48
    {
49
        $tester = $this->executeTest(['email' => '[email protected]']);
50
        $this->assertContains('Member with email "[email protected]" was not found', $tester->getDisplay());
51
    }
52
53
    /**
54
     * Test that when a Group is chosen from the multiselect list, the user is assigned to that Group or Groups
55
     *
56
     * @covers ::execute
57
     */
58
    public function testAddToGroups()
59
    {
60
        $member = $this->createMember();
0 ignored issues
show
$member is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
61
62
        $this->mockQuestionHelper();
63
        $tester = $this->executeTest(['email' => '[email protected]']);
64
        $this->assertContains('Groups updated.', $tester->getDisplay());
65
66
        $memberCodes = Member::get()
67
            ->filter('Email', '[email protected]')
68
            ->first()
69
            ->Groups()
70
            ->column('Code');
71
72
        $this->assertSame(['content-authors'], $memberCodes);
73
    }
74
75
    /**
76
     * Creates a dummy user for testing with
77
     *
78
     * @return Member
79
     */
80
    protected function createMember()
81
    {
82
        $member = Member::create();
83
        $member->Email = '[email protected]';
84
        $member->Password = 'Opensesame1';
85
        $member->write();
86
        return $member;
87
    }
88
89
    /**
90
     * Mock a QuestionHelper and tell it to return a predefined choice for which Group to assign
91
     *
92
     * @return QuestionHelper
93
     */
94
    protected function mockQuestionHelper()
95
    {
96
        $mock = $this
97
            ->getMockBuilder(QuestionHelper::class)
98
            ->setMethods(['ask'])
99
            ->getMock();
100
101
        $mock
102
            ->expects($this->once())
103
            ->method('ask')
104
            ->with(
105
                $this->isInstanceOf(InputInterface::class),
106
                $this->isInstanceOf(OutputInterface::class),
107
                $this->callback(
108
                    function ($argument) {
109
                        return $argument instanceof ChoiceQuestion
110
                            && $argument->isMultiselect()
111
                            && !empty($argument->getChoices());
112
                    }
113
                )
114
            )
115
            ->willReturn(['content-authors']);
116
117
        $this->command->getApplication()->getHelperSet()->set($mock, 'question');
118
    }
119
}
120