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/Activity/Notifications.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
namespace FlexyProject\GitHub\Receiver\Activity;
3
4
use DateTime;
5
use Symfony\Component\HttpFoundation\Request;
6
7
/**
8
 * The Notifications API class lets your view notifications of new comments are delivered to users and mark them as
9
 * read.
10
 *
11
 * @link    https://developer.github.com/v3/activity/notifications/
12
 * @package GitHub\Receiver\Activity
13
 */
14
class Notifications extends AbstractActivity
15
{
16
17
    /**
18
     * List your notifications
19
     *
20
     * @link https://developer.github.com/v3/activity/notifications/#list-your-notifications
21
     *
22
     * @param bool   $all
23
     * @param bool   $participating
24
     * @param string $since
25
     * @param string $before
26
     *
27
     * @return array
28
     * @throws \Exception
29
     */
30
    public function listNotifications(bool $all = false, bool $participating = false, string $since = 'now',
31
                                      string $before = null): array
32
    {
33
        return $this->getApi()->request($this->getApi()->sprintf('/notifications?:args', http_build_query([
34
            'all'           => $all,
35
            'participating' => $participating,
36
            'since'         => (new DateTime($since))->format(DateTime::ATOM),
37
            'before'        => (new DateTime($before))->format(DateTime::ATOM)
38
        ])));
39
    }
40
41
    /**
42
     * List your notifications in a repository
43
     *
44
     * @link https://developer.github.com/v3/activity/notifications/#list-your-notifications-in-a-repository
45
     *
46
     * @param bool   $all
47
     * @param bool   $participating
48
     * @param string $since
49
     * @param string $before
50
     *
51
     * @return array
52
     * @throws \Exception
53
     */
54
    public function listRepositoryNotifications(bool $all = false, bool $participating = false, string $since = 'now',
55
                                                string $before = null): array
56
    {
57
        return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/notifications?:args',
58
            $this->getActivity()->getOwner(), $this->getActivity()->getRepo(), http_build_query([
59
                'all'           => $all,
60
                'participating' => $participating,
61
                'since'         => (new DateTime($since))->format(DateTime::ATOM),
62
                'before'        => (new DateTime($before))->format(DateTime::ATOM)
63
            ])));
64
    }
65
66
    /**
67
     * Mark as read
68
     *
69
     * @link https://developer.github.com/v3/activity/notifications/#mark-as-read
70
     *
71
     * @param string $lastReadAt
72
     *
73
     * @return array
74
     */
75
    public function markAsRead(string $lastReadAt = 'now'): array
76
    {
77
        return $this->getApi()->request($this->getApi()->sprintf('/notifications?:args',
78
            http_build_query(['last_read_at' => (new DateTime($lastReadAt))->format(DateTime::ATOM)])),
79
            Request::METHOD_PUT);
80
    }
81
82
    /**
83
     * Mark notifications as read in a repository
84
     *
85
     * @link https://developer.github.com/v3/activity/notifications/#mark-notifications-as-read-in-a-repository
86
     *
87
     * @param string $lastReadAt
88
     *
89
     * @return array
90
     */
91
    public function markAsReadInRepository(string $lastReadAt = 'now'): array
92
    {
93
        return $this->getApi()->request($this->getApi()->sprintf('/repos/:owner/:repo/notifications?:args',
94
            $this->getActivity()->getOwner(), $this->getActivity()->getRepo(),
95
            http_build_query(['last_read_at' => (new DateTime($lastReadAt))->format(DateTime::ATOM)])),
96
            Request::METHOD_PUT);
97
    }
98
99
    /**
100
     * View a single thread
101
     *
102
     * @link https://developer.github.com/v3/activity/notifications/#view-a-single-thread
103
     *
104
     * @param int $id
105
     *
106
     * @return array
107
     */
108
    public function viewThread(int $id): array
109
    {
110
        return $this->getApi()->request($this->getApi()->sprintf('/notifications/threads/:id', (string)$id));
111
    }
112
113
    /**
114
     * Mark a thread as read
115
     *
116
     * @link https://developer.github.com/v3/activity/notifications/#mark-a-thread-as-read
117
     *
118
     * @param int $id
119
     *
120
     * @return array
121
     */
122
    public function markThreadAsRead(int $id): array
123
    {
124
        return $this->getApi()->request($this->getApi()->sprintf('/notifications/threads/:id', (string)$id),
125
            Request::METHOD_PATCH);
126
    }
127
128
    /**
129
     * Get a Thread Subscription
130
     *
131
     * @link https://developer.github.com/v3/activity/notifications/#get-a-thread-subscription
132
     *
133
     * @param int $id
134
     *
135
     * @return array
136
     */
137
    public function getThreadSubscription(int $id): array
138
    {
139
        return $this->getApi()->request($this->getApi()
140
                                             ->sprintf('/notifications/threads/:id/subscription', (string)$id));
141
    }
142
143
    /**
144
     * Set a Thread Subscription
145
     *
146
     * @link https://developer.github.com/v3/activity/notifications/#set-a-thread-subscription
147
     *
148
     * @param int  $id
149
     * @param bool $subscribed
150
     * @param bool $ignored
151
     *
152
     * @return array
153
     */
154
    public function setThreadSubscription(int $id, bool $subscribed = false, bool $ignored = false): array
155
    {
156
        return $this->getApi()->request($this->getApi()->sprintf('/notifications/threads/:id/subscription?:args', $id,
157
            http_build_query(['subscribed' => $subscribed, 'ignored' => $ignored])), Request::METHOD_PUT);
158
    }
159
160
    /**
161
     * Delete a Thread Subscription
162
     *
163
     * @link https://developer.github.com/v3/activity/notifications/#delete-a-thread-subscription
164
     *
165
     * @param int $id
166
     *
167
     * @return bool
168
     */
169 View Code Duplication
    public function deleteThreadSubscription(int $id): bool
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...
170
    {
171
        $this->getApi()->request($this->getApi()->sprintf('/notifications/threads/:id/subscription', (string)$id),
172
            Request::METHOD_DELETE);
173
174
        if ($this->getApi()->getHeaders()['Status'] == '204 No Content') {
175
            return true;
176
        }
177
178
        return false;
179
    }
180
}