GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (9)

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.

src/Swift_PdoSpool.php (5 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
 *
4
 * @copyright 2015 LibreWorks contributors
5
 * @license   http://opensource.org/licenses/MIT MIT License
6
 */
7
8
/**
9
 * A Swift spool that uses PDO.
10
 *
11
 * @copyright 2015 LibreWorks contributors
12
 * @license   http://opensource.org/licenses/MIT MIT License
13
 */
14
class Swift_PdoSpool extends Swift_ConfigurableSpool
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
This class is not in CamelCase format.

Classes in PHP are usually named in CamelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. The whole name starts with a capital letter as well.

Thus the name database provider becomes DatabaseProvider.

Loading history...
15
{
16
    /**
17
     * @var \PDO The database driver
18
     */
19
    protected $pdo;
20
    protected $table;
21
    protected $pkey;
22
    protected $messageField;
23
    protected $timeField;
24
25
    /**
26
     * Creates a new PdoSpool
27
     *
28
     * @param \PDO $pdo The database driver
29
     * @param string $table The table name
30
     * @param string $pkey The primary key field
31
     * @param string $messageField The field to add serialized message data
32
     * @param string $timeField The integer field to store message timestamp
33
     */
34 2
    public function __construct(\PDO $pdo, $table, $pkey, $messageField, $timeField)
35
    {
36 2
        $this->pdo = $pdo;
37 2
        $this->table = $this->checkBlank($table);
38 2
        $this->pkey = $this->checkBlank($pkey);
39 2
        $this->messageField = $this->checkBlank($messageField);
40 2
        $this->timeField = $this->checkBlank($timeField);
41 1
    }
42
43 1
    private function checkBlank($value)
44
    {
45 1
        $value = trim($value);
46 1
        if (strlen($value) == 0) {
47 1
            throw new \InvalidArgumentException("This parameter cannot be blank");
48
        }
49 1
        return $value;
50
    }
51
52
    /**
53
     * Tests if this Spool mechanism has started.
54
     *
55
     * @return bool
56
     */
57 1
    public function isStarted()
58
    {
59 1
        return true;
60
    }
61
62
    /**
63
     * Starts this Spool mechanism.
64
     */
65
    public function start()
66
    {
67
    }
68
69
    /**
70
     * Stops this Spool mechanism.
71
     */
72
    public function stop()
73
    {
74
    }
75
76
    /**
77
     * Queues a message.
78
     *
79
     * @param Swift_Mime_SimpleMessage $message The message to store
80
     *
81
     * @throws Swift_IoException
82
     *
83
     * @return bool
84
     */
85 1
    public function queueMessage(Swift_Mime_SimpleMessage $message)
86
    {
87
        try {
88 1
            $stmt = $this->pdo->prepare("INSERT INTO " . $this->table . " ("
89 1
                . $this->messageField . ") VALUES (?)");
90 1
            $stmt->bindValue(1, serialize($message), PDO::PARAM_STR);
91 1
            $stmt->execute();
92 1
            return true;
93
        } catch (\Exception $e) {
94
            throw new Swift_IoException("Could not enqueue message", 0, $e);
95
        }
96
    }
97
98
    /**
99
     * Execute a recovery if for any reason a process is sending for too long.
100
     *
101
     * @param int $timeout in second Defaults is for very slow smtp responses
102
     */
103 1
    public function recover($timeout = 900)
0 ignored issues
show
The parameter $timeout is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
104
    {
105
        try {
106 1
            $stmt = $this->pdo->prepare('UPDATE ' . $this->table . ' SET '
107 1
                . $this->timeField . ' = NULL WHERE ' . $this->timeField . ' <= ?');
108 1
            $stmt->bindValue(1, time() - 900, PDO::PARAM_INT);
109 1
            $stmt->execute();
110
        } catch (\Exception $e) {
111
            throw new Swift_IoException("Could not update email sent on date", 0, $e);
112
        }
113 1
    }
114
115
    /**
116
     * Sends messages using the given transport instance.
117
     *
118
     * @param Swift_Transport $transport        A transport instance
119
     * @param string[]        $failedRecipients An array of failures by-reference
120
     *
121
     * @return int The number of sent e-mails
122
     */
123 1
    public function flushQueue(Swift_Transport $transport, &$failedRecipients = null)
124
    {
125 1
        if (!$transport->isStarted()) {
126
            $transport->start();
127
        }
128 1
        $limit = $this->getMessageLimit();
129 1
        $limit = $limit > 0 ? $limit : null;
130 1
        $failedRecipients = (array) $failedRecipients;
131 1
        $count = 0;
132 1
        $time = time();
133 1
        $timeLimit = $this->getTimeLimit();
134
        try {
135 1
            $results = $this->pdo->query('SELECT ' . $this->pkey . ' as pkey, '
136 1
                . $this->messageField . ' as email FROM ' . $this->table . ' WHERE '
137 1
                . $this->timeField . ' IS NULL');
138 1
            $ustmt = $this->pdo->prepare('UPDATE ' . $this->table . ' SET '
139 1
                . $this->timeField . ' = ? WHERE ' . $this->pkey . ' = ?');
140 1
            $dstmt = $this->pdo->prepare('DELETE FROM ' . $this->table . ' WHERE '
141 1
                . $this->pkey . ' = ?');
142 1
            foreach ($results->fetchAll(PDO::FETCH_COLUMN) as $result) {
143 1
                $id = $result[0];
144 1
                $ustmt->execute(array(time(), $result[0]));
145 1
                $message = unserialize($result[1]);
146 1
                $count += $transport->send($message, $failedRecipients);
0 ignored issues
show
It seems like $failedRecipients defined by (array) $failedRecipients on line 130 can also be of type array; however, Swift_Transport::send() does only seem to accept array<integer,string>|null, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
147 1
                $dstmt->execute(array($id));
148 1
                if ($limit && $count >= $limit) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $limit of type integer|null is loosely compared to true; this is ambiguous if the integer can be zero. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For integer values, zero is a special case, in particular the following results might be unexpected:

0   == false // true
0   == null  // true
123 == false // false
123 == null  // false

// It is often better to use strict comparison
0 === false // false
0 === null  // false
Loading history...
149
                    break;
150
                }
151 1
                if ($timeLimit && (time() - $time) >= $timeLimit) {
152 1
                    break;
153
                }
154
            }
155 1
            return $count;
156
        } catch (\Exception $e) {
157
            throw new Swift_IoException("Could not access database", 0, $e);
158
        }
159
    }
160
}
161