Issues (83)

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.

lib/GitHub/Receiver/PullRequests.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
namespace FlexyProject\GitHub\Receiver;
3
4
use FlexyProject\GitHub\AbstractApi;
5
use Symfony\Component\HttpFoundation\Request;
6
7
/**
8
 * This class give you access to the Pull Request API who allows you to list, view, edit, create, and even merge pull
9
 * requests.
10
 *
11
 * @link    https://developer.github.com/v3/pulls/
12
 * @package FlexyProject\GitHub\Receiver
13
 */
14
class PullRequests extends AbstractReceiver
15
{
16
17
    /** Available sub-Receiver */
18
    const REVIEW_COMMENTS = 'ReviewComments';
19
20
    /**
21
     * List pull requests
22
     *
23
     * @link https://developer.github.com/v3/pulls/#list-pull-requests
24
     *
25
     * @param string $state
26
     * @param string $head
27
     * @param string $base
28
     * @param string $sort
29
     * @param string $direction
30
     *
31
     * @return array
32
     * @throws \Exception
33
     */
34
    public function listPullRequests(string $state = AbstractApi::STATE_OPEN, string $head = null, string $base = null,
35
                                     string $sort = AbstractApi::SORT_CREATED,
36
                                     string $direction = AbstractApi::DIRECTION_ASC): array
37
    {
38
        return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/pulls?:args', $this->getOwner(),
39
            $this->getRepo(), http_build_query([
40
                'state'     => $state,
41
                'head'      => $head,
42
                'base'      => $base,
43
                'sort'      => $sort,
44
                'direction' => $direction
45
            ])));
46
    }
47
48
    /**
49
     * Get a single pull request
50
     *
51
     * @link https://developer.github.com/v3/pulls/#get-a-single-pull-request
52
     *
53
     * @param int $number
54
     *
55
     * @return array
56
     * @throws \Exception
57
     */
58
    public function getSinglePullRequest(int $number): array
59
    {
60
        return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/pulls/:number', $this->getOwner(),
61
            $this->getRepo(), $number));
62
    }
63
64
    /**
65
     * Create a pull request
66
     *
67
     * @link https://developer.github.com/v3/pulls/#create-a-pull-request
68
     *
69
     * @param string $title
70
     * @param string $head
71
     * @param string $base
72
     * @param string $body
73
     *
74
     * @return array
75
     * @throws \Exception
76
     */
77
    public function createPullrequest(string $title, string $head, string $base, string $body): array
78
    {
79
        return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/pulls', $this->getOwner(),
80
            $this->getRepo()), Request::METHOD_POST, [
81
                'title' => $title,
82
                'head'  => $head,
83
                'base'  => $base,
84
                'body'  => $body
85
            ]);
86
    }
87
88
    /**
89
     * Update a pull request
90
     *
91
     * @link https://developer.github.com/v3/pulls/#update-a-pull-request
92
     *
93
     * @param int    $number
94
     * @param string $title
95
     * @param string $body
96
     * @param string $state
97
     *
98
     * @return array
99
     * @throws \Exception
100
     */
101 View Code Duplication
    public function updatePullRequest(int $number, string $title = null, string $body = null,
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...
102
                                      string $state = null): array
103
    {
104
        return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/pulls/:number', $this->getOwner(),
105
            $this->getRepo(), $number), Request::METHOD_PATCH, [
106
                'title' => $title,
107
                'body'  => $body,
108
                'state' => $state
109
            ]);
110
    }
111
112
    /**
113
     * List commits on a pull request
114
     *
115
     * @link https://developer.github.com/v3/pulls/#list-commits-on-a-pull-request
116
     *
117
     * @param int $number
118
     *
119
     * @return array
120
     * @throws \Exception
121
     */
122
    public function listCommits(int $number): array
123
    {
124
        return $this->getApi()->request($this->getApi()
125
                                             ->sprintf('/repos/:owner/:repo/pulls/:number/commits', $this->getOwner(),
126
                                                 $this->getRepo(), $number));
127
    }
128
129
    /**
130
     * List pull requests files
131
     *
132
     * @link https://developer.github.com/v3/pulls/#list-pull-requests-files
133
     *
134
     * @param int $number
135
     *
136
     * @return array
137
     * @throws \Exception
138
     */
139
    public function listPullRequestsFiles(int $number): array
140
    {
141
        return $this->getApi()->request($this->getApi()
142
                                             ->sprintf('/repos/:owner/:repo/pulls/:number/files', $this->getOwner(),
143
                                                 $this->getRepo(), $number));
144
    }
145
146
    /**
147
     * Get if a pull request has been merged
148
     *
149
     * @link https://developer.github.com/v3/pulls/#get-if-a-pull-request-has-been-merged
150
     *
151
     * @param int $number
152
     *
153
     * @return bool
154
     * @throws \Exception
155
     */
156
    public function checkPullRequestsMerged(int $number): bool
157
    {
158
        $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/pulls/:number/merge', $this->getOwner(),
159
            $this->getRepo(), $number));
160
161
        if ($this->getApi()->getHeaders()['Status'] == '204 No Content') {
162
            return true;
163
        }
164
165
        return false;
166
    }
167
168
    /**
169
     * Merge a pull request (Merge Button)
170
     *
171
     * @link https://developer.github.com/v3/pulls/#merge-a-pull-request-merge-button
172
     *
173
     * @param int    $number
174
     * @param string $commitMessage
175
     * @param string $sha
176
     *
177
     * @return array
178
     * @throws \Exception
179
     */
180 View Code Duplication
    public function mergePullRequest(int $number, string $commitMessage = null, string $sha = null): array
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...
181
    {
182
        return $this->getApi()->request($this->getApi()
183
                                             ->sprintf('/repos/:owner/:repo/pulls/:number/merge', $this->getOwner(),
184
                                                 $this->getRepo(), $number), Request::METHOD_PUT, [
185
                'commit_message' => $commitMessage,
186
                'sha'            => $sha
187
            ]);
188
    }
189
}