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 (142)

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/Document/RevisionManager.php (4 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 Sokil\Mongo\Document;
4
5
use Sokil\Mongo\Document;
6
use Sokil\Mongo\Expression;
7
8
class RevisionManager
9
{
10
11
    /**
12
     * Suffix added to collection name to get name of revisions collection
13
     * @var string
14
     */
15
    const REVISION_COLLECTION_SUFFIX = '.revisions';
16
    
17
    /**
18
     *
19
     * @var \Sokil\Mongo\Document
20
     */
21
    private $document;
22
23
    private $revisionsCollection;
24
25
    public function __construct(Document $document = null)
26
    {
27
        $this->document = $document;
28
    }
29
30
    /**
31
     * Start listening for changes in document
32
     */
33
    public function listen()
34
    {
35
        $revisionsCollection = $this->getRevisionsCollection();
36
        $document = $this->document;
37
38
        $createRevisionCallback = function () use ($revisionsCollection, $document) {
39
            // create new revision
40
            $revisionsCollection
41
                ->createDocument()
42
                ->setDocumentData($document->getOriginalData())
43
                ->save();
44
        };
45
46
        $this->document->onBeforeUpdate($createRevisionCallback, PHP_INT_MAX);
47
        $this->document->onBeforeDelete($createRevisionCallback, PHP_INT_MAX);
48
    }
49
50
    /**
51
     * @return \Sokil\Mongo\Collection
52
     */
53
    private function getRevisionsCollection()
54
    {
55
        if ($this->revisionsCollection) {
56
            return $this->revisionsCollection;
57
        }
58
59
        $collection = $this->document->getCollection();
60
        $revisionsCollectionName = $collection->getName() . self::REVISION_COLLECTION_SUFFIX;
61
62
        $this->revisionsCollection = $collection
63
            ->getDatabase()
64
            ->map($revisionsCollectionName, array(
65
                'documentClass' => '\Sokil\Mongo\Revision',
66
            ))
67
            ->getCollection($revisionsCollectionName);
68
69
        return $this->revisionsCollection;
70
    }
71
72
    public function getRevisions($limit = null, $offset = null)
73
    {
74
        $cursor = $this
0 ignored issues
show
Documentation Bug introduced by
The method where does not exist on object<Sokil\Mongo\Cursor>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
75
            ->getRevisionsCollection()
76
            ->find()
77
            ->where('__documentId__', $this->document->getId());
78
79
        if ($limit) {
80
            $cursor->limit($limit);
81
        }
82
83
        if ($offset) {
84
            $cursor->skip($offset);
85
        }
86
87
        return $cursor->findAll();
88
    }
89
90
    /**
91
     * Get revision by id
92
     *
93
     * @param int|string|\MongoId $id
94
     * @return \Sokil\Mongo\Revision
95
     */
96
    public function getRevision($id)
97
    {
98
        return $this
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->getRevisionsColle...->byId($id)->findOne(); of type Sokil\Mongo\Document|array|null adds the type array to the return on line 98 which is incompatible with the return type documented by Sokil\Mongo\Document\RevisionManager::getRevision of type Sokil\Mongo\Revision|null.
Loading history...
Deprecated Code introduced by
The method Sokil\Mongo\Cursor::findOne() has been deprecated with message: since v.1.22.2. Use ::one instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
99
            ->getRevisionsCollection()
100
            ->find()
101
            ->byId($id)
102
            ->findOne();
103
    }
104
105
    public function getRevisionsCount()
106
    {
107
        return $this
0 ignored issues
show
Documentation Bug introduced by
The method where does not exist on object<Sokil\Mongo\Cursor>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
108
            ->getRevisionsCollection()
109
            ->find()
110
            ->where('__documentId__', $this->document->getId())
111
            ->count();
112
    }
113
114
    public function clearRevisions()
115
    {
116
        $documentId = $this->document->getId();
117
        $this
118
            ->getRevisionsCollection()
119
            ->batchDelete(function (Expression $expression) use ($documentId) {
120
                /* @var $expression \Sokil\Mongo\Expression */
121
                return $expression->where('__documentId__', $documentId);
122
            });
123
124
        return $this;
125
    }
126
}
127