Issues (66)

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/Repo/SimpleRepoFacadeTest.php (10 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 tests\DevBoardLib\GithubObjectApiFacade\Repo;
4
5
use DevBoardLib\GithubObjectApiFacade\Repo\Branch\Converter\GithubBranchConverter;
6
use DevBoardLib\GithubObjectApiFacade\Repo\Commit\Converter\GithubCommitConverter;
7
use DevBoardLib\GithubObjectApiFacade\Repo\CommitStatus\Converter\GithubCommitStatusConverter;
8
use DevBoardLib\GithubObjectApiFacade\Repo\Issue\Converter\GithubIssueConverter;
9
use DevBoardLib\GithubObjectApiFacade\Repo\Milestone\Converter\GithubMilestoneConverter;
10
use DevBoardLib\GithubObjectApiFacade\Repo\PullRequest\Converter\GithubPullRequestConverter;
11
use DevBoardLib\GithubObjectApiFacade\Repo\Repo\Converter\GithubRepoConverter;
12
use DevBoardLib\GithubObjectApiFacade\Repo\SimpleRepoFacade;
13
use DevBoardLib\GithubObjectApiFacade\Repo\Tag\Converter\GithubTagConverter;
14
use Mockery as m;
15
use tests\DevBoardLib\GithubObjectApiFacade\JsonSampleDataProvider;
16
17
/**
18
 * Class SimpleRepoFacadeTest.
19
 *
20
 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
21
 */
22
class SimpleRepoFacadeTest extends \PHPUnit_Framework_TestCase
23
{
24
    public function testFetchDetails()
25
    {
26
        $wrapped = m::mock('DevBoardLib\GithubApiFacade\Repo\RepoFacade');
27
        $wrapped->shouldReceive('fetchDetails')
28
            ->andReturn($this->getDataProvider()->getRepoDetails());
29
30
        $target = $this->createFacade($wrapped);
31
32
        self::assertInstanceOf(
33
            'DevBoardLib\GithubCore\Repo\GithubRepoSource',
34
            $target->fetchDetails()
35
        );
36
    }
37
38 View Code Duplication
    public function testFetchBranch()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
39
    {
40
        $wrapped = m::mock('DevBoardLib\GithubApiFacade\Repo\RepoFacade');
41
        $wrapped->shouldReceive('fetchBranch')
42
            ->with('master')
43
            ->andReturn($this->getDataProvider()->getBranch());
44
45
        $target = $this->createFacade($wrapped);
46
47
        self::assertInstanceOf(
48
            'DevBoardLib\GithubCore\Branch\GithubBranchSource',
49
            $target->fetchBranch('master')
50
        );
51
    }
52
53 View Code Duplication
    public function testFetchAllBranches()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
54
    {
55
        $wrapped = m::mock('DevBoardLib\GithubApiFacade\Repo\RepoFacade');
56
        $wrapped->shouldReceive('fetchAllBranches')
57
            ->andReturn($this->getDataProvider()->getAllBranches());
58
59
        $target   = $this->createFacade($wrapped);
60
        $branches = $target->fetchAllBranches();
61
62
        foreach ($branches as $branch) {
63
            self::assertInstanceOf(
64
                'DevBoardLib\GithubCore\Branch\GithubBranchSource',
65
                $branch
66
            );
67
        }
68
    }
69
70 View Code Duplication
    public function testFetchAllTags()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
71
    {
72
        $wrapped = m::mock('DevBoardLib\GithubApiFacade\Repo\RepoFacade');
73
        $wrapped->shouldReceive('fetchAllTags')
74
            ->andReturn($this->getDataProvider()->getAllTagNames());
75
76
        $target   = $this->createFacade($wrapped);
77
        $branches = $target->fetchAllTags();
78
79
        foreach ($branches as $branch) {
80
            self::assertInstanceOf(
81
                'DevBoardLib\GithubCore\Tag\GithubTagSource',
82
                $branch
83
            );
84
        }
85
    }
86
87 View Code Duplication
    public function testFetchCommit()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
88
    {
89
        $wrapped = m::mock('DevBoardLib\GithubApiFacade\Repo\RepoFacade');
90
        $wrapped->shouldReceive('fetchCommit')
91
            ->with('sha123')
92
            ->andReturn($this->getDataProvider()->getCommit());
93
94
        $target = $this->createFacade($wrapped);
95
96
        self::assertInstanceOf(
97
            'DevBoardLib\GithubCore\Commit\GithubCommitSource',
98
            $target->fetchCommit('sha123')
99
        );
100
    }
101
102
    /**
103
     */
104 View Code Duplication
    public function testFetchCommitStatus()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
105
    {
106
        $wrapped = m::mock('DevBoardLib\GithubApiFacade\Repo\RepoFacade');
107
        $wrapped->shouldReceive('fetchCommitStatus')
108
            ->with('sha123')
109
            ->andReturn($this->getDataProvider()->getCommitStatus());
110
111
        $target = $this->createFacade($wrapped);
112
113
        foreach ($target->fetchCommitStatus('sha123') as $status) {
114
            self::assertInstanceOf(
115
                'DevBoardLib\GithubCore\CommitStatus\GithubCommitStatusSource',
116
                $status
117
            );
118
        }
119
    }
120
121 View Code Duplication
    public function testFetchCommitStatuses()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
122
    {
123
        $wrapped = m::mock('DevBoardLib\GithubApiFacade\Repo\RepoFacade');
124
        $wrapped->shouldReceive('fetchCommitStatuses')
125
            ->with('sha123')
126
            ->andReturn($this->getDataProvider()->getCommitStatuses());
127
128
        $target = $this->createFacade($wrapped);
129
130
        foreach ($target->fetchCommitStatuses('sha123') as $status) {
131
            self::assertInstanceOf(
132
                'DevBoardLib\GithubCore\CommitStatus\GithubCommitStatusSource',
133
                $status
134
            );
135
        }
136
    }
137
    //
138
    //
139
    //
140
    //
141
142 View Code Duplication
    public function testFetchAllPullRequests()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
143
    {
144
        $wrapped = m::mock('DevBoardLib\GithubApiFacade\Repo\RepoFacade');
145
        $wrapped->shouldReceive('fetchAllPullRequests')
146
            ->andReturn($this->getDataProvider()->getAllPullRequests());
147
148
        $target       = $this->createFacade($wrapped);
149
        $pullRequests = $target->fetchAllPullRequests();
150
151
        foreach ($pullRequests as $pullRequest) {
152
            self::assertInstanceOf(
153
                'DevBoardLib\GithubCore\PullRequest\GithubPullRequestSource',
154
                $pullRequest
155
            );
156
        }
157
    }
158
159 View Code Duplication
    public function testFetchAllMilestones()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
160
    {
161
        $wrapped = m::mock('DevBoardLib\GithubApiFacade\Repo\RepoFacade');
162
        $wrapped->shouldReceive('fetchAllMilestones')
163
            ->andReturn($this->getDataProvider()->getAllMilestones());
164
165
        $target = $this->createFacade($wrapped);
166
167
        $milestones = $target->fetchAllMilestones();
168
169
        foreach ($milestones as $milestone) {
170
            self::assertInstanceOf(
171
                'DevBoardLib\GithubCore\Milestone\GithubMilestoneSource',
172
                $milestone
173
            );
174
        }
175
    }
176
177 View Code Duplication
    public function testFetchAllIssues()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
178
    {
179
        $wrapped = m::mock('DevBoardLib\GithubApiFacade\Repo\RepoFacade');
180
181
        $wrapped->shouldReceive('fetchAllIssues')
182
            ->andReturn($this->getDataProvider()->getAllIssues());
183
184
        $target = $this->createFacade($wrapped);
185
186
        $issues = $target->fetchAllIssues();
187
188
        foreach ($issues as $issue) {
189
            self::assertInstanceOf(
190
                'DevBoardLib\GithubCore\Issue\GithubIssueSource',
191
                $issue
192
            );
193
        }
194
    }
195
196
    /**
197
     * @param $wrapped
198
     *
199
     * @return SimpleRepoFacade
200
     */
201
    protected function createFacade($wrapped)
202
    {
203
        return new SimpleRepoFacade(
204
            $wrapped,
205
            new GithubRepoConverter($this->provideTestRepo()),
0 ignored issues
show
The call to GithubRepoConverter::__construct() has too many arguments starting with $this->provideTestRepo().

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
206
            new GithubBranchConverter($this->provideTestRepo()),
207
            new GithubTagConverter($this->provideTestRepo()),
208
            new GithubPullRequestConverter($this->provideTestRepo()),
209
            new GithubCommitConverter($this->provideTestRepo()),
210
            new GithubCommitStatusConverter($this->provideTestRepo()),
211
            new GithubIssueConverter($this->provideTestRepo()),
212
            new GithubMilestoneConverter($this->provideTestRepo())
213
        );
214
    }
215
216
    /**
217
     * @return JsonSampleDataProvider
218
     */
219
    protected function getDataProvider()
220
    {
221
        return new JsonSampleDataProvider();
222
    }
223
224
    /**
225
     * @return m\MockInterface
226
     */
227
    protected function provideTestRepo()
228
    {
229
        $repo   = m::mock('DevBoardLib\GithubCore\Repo\GithubRepo');
230
        $repoId = m::mock('DevBoardLib\GithubCore\Repo\GithubRepoId');
231
232
        $repo->shouldReceive('getId')->andReturn($repoId);
233
234
        return $repo;
235
    }
236
}
237