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

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.

lib/Onurb/Bundle/YumlBundle/Yuml/YumlClient.php (1 issue)

Labels
Severity

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 Onurb\Bundle\YumlBundle\Yuml;
4
5
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
6
use Doctrine\Common\Persistence\Mapping\ClassMetadataFactory as ClassMetadataFactoryInterface;
7
use Doctrine\ORM\EntityManagerInterface;
8
use Doctrine\ORM\Mapping\ClassMetadataFactory;
9
use Onurb\Bundle\YumlBundle\Curl\Curl;
10
use Onurb\Bundle\YumlBundle\Curl\CurlInterface;
11
use Onurb\Doctrine\ORMMetadataGrapher\YUMLMetadataGrapher as MetadataGrapher;
12
use Onurb\Doctrine\ORMMetadataGrapher\YUMLMetadataGrapherInterface as MetadataGrapherInterface;
13
14
/**
15
 * Utility to generate Yuml compatible strings from metadata graphs
16
 * Adaptation of DoctrineORMModule\Yuml\YumlController for ZendFramework-Zend-Developer-Tools
17
 *
18
 * @license MIT
19
 * @link    http://www.doctrine-project.org/
20
 * @author  Bruno Heron <[email protected]>
21
 * @author  Marco Pivetta <[email protected]>
22
 **/
23
class YumlClient implements YumlClientInterface
24
{
25
    const YUML_POST_URL = 'https://yuml.me/diagram/%STYLE%/class';
26
    const YUML_REDIRECT_URL = 'https://yuml.me/';
27
28
    protected $entityManager;
29
30
    protected $metadataFactory;
31
32
    protected $metadataGrapher;
33
34
    /**
35
     * @param EntityManagerInterface $entityManager
36
     * @param ClassMetadataFactoryInterface|null $classMetadataFactory
37
     * @param MetadataGrapherInterface|null $metadataGrapher
38
     */
39 4
    public function __construct(
40
        EntityManagerInterface          $entityManager,
41
        ClassMetadataFactoryInterface   $classMetadataFactory = null,
42
        MetadataGrapherInterface        $metadataGrapher = null
43
    ) {
44 4
        $this->entityManager = $entityManager;
45 4
        $this->metadataFactory = $classMetadataFactory ? $classMetadataFactory : new ClassMetadataFactory();
46 4
        $this->metadataFactory->setEntityManager($this->entityManager);
0 ignored issues
show
It seems like you code against a concrete implementation and not the interface Doctrine\Common\Persiste...ng\ClassMetadataFactory as the method setEntityManager() does only exist in the following implementations of said interface: Doctrine\ORM\Mapping\ClassMetadataFactory, Doctrine\ORM\Tools\Disco...tedClassMetadataFactory.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
47 4
        $this->metadataGrapher = $metadataGrapher ? $metadataGrapher : new MetadataGrapher();
48 4
    }
49
50
51
    /**
52
     * Get doctrine metadata as yuml.
53
     *
54
     * @param bool $showDetail
55
     * @param array $colors
56
     * @param array $notes
57
     * @return string
58
     */
59 1
    public function makeDslText($showDetail = false, $colors = array(), $notes = array())
60
    {
61 1
        return $this->metadataGrapher->generateFromMetadata(
62 1
            $this->getClasses(),
63 1
            $showDetail,
64 1
            $colors,
65 1
            $notes
66
        );
67
    }
68
69
    /**
70
     * Use yuml.me to generate an image from yuml.
71
     *
72
     * @param string $dsl_text
73
     * @param string $style the yuml style plain, boring or scruffy
74
     * @param string $extension the file extension to redirect to
75
     * @param string $direction the direction of the graph (LR,RL, TB)
76
     * @param string $scale the graph scale : huge, big, normal, small or tiny.
77
     *
78
     * @return string The url of the generated image.
79
     */
80 1
    public function getGraphUrl($dsl_text, $style, $extension, $direction, $scale)
81
    {
82 1
        $curl = new Curl($this->makePostUrl($style, $direction, $scale));
83 1
        $curl->setPosts(array('dsl_text' => $dsl_text));
84
85 1
        return self::YUML_REDIRECT_URL . $this->makeExtensionUrl($curl->getResponse(), $extension);
86
    }
87
88
    /**
89
     * @param string $graphUrl
90
     * @param string $filename
91
     * @return mixed
92
     */
93 1
    public function downloadImage($graphUrl, $filename, CurlInterface $curl = null)
94
    {
95 1
        $curl = $curl ? $curl : new Curl($graphUrl);
96 1
        $curl->setOutput($filename);
97
98 1
        return $curl->getResponse();
99
    }
100
101
    /**
102
     * @return ClassMetadata[]
103
     */
104 1
    private function getMetadata()
105
    {
106 1
        return $this->metadataFactory->getAllMetadata();
107
    }
108
109
    /**
110
     * @return array
111
     */
112 1
    private function getClasses()
113
    {
114 1
        $classes = array();
115
        /** @var ClassMetadata $class */
116 1
        foreach ($this->getMetadata() as $class) {
117 1
            $classes[$class->getName()] = $class;
118
        }
119 1
        ksort($classes);
120
121 1
        return $classes;
122
    }
123
124
    /**
125
     * @param string $style
126
     * @return string
127
     */
128 1
    private function makePostUrl($style, $direction, $scale)
129
    {
130 1
        return str_replace('%STYLE%', $this->makeStyle($style, $direction, $scale), self::YUML_POST_URL);
131
    }
132
133
    /**
134
     * @param string $return
135
     * @param string $extension
136
     * @return string
137
     */
138 1
    private function makeExtensionUrl($return, $extension)
139
    {
140 1
        return explode('.', $return)[0] . '.' . $this->checkExtension($extension);
141
    }
142
143 1
    private function makeStyle($style, $direction, $scale)
144
    {
145 1
        return $this->checkStyle($style) . $this->makeDirection($direction) . $this->makeScale($scale);
146
    }
147
148
    /**
149
     * @param string $direction
150
     * @return string
151
     */
152 1
    private function makeDirection($direction)
153
    {
154
        switch ($direction) {
155 1
            case 'LR':
156 1
            case 'RL':
157 1
                return ';dir:' . $direction;
158
            default:
159 1
                return '';
160
        }
161
    }
162
163
    /**
164
     * @param string $scale
165
     * @return string
166
     */
167 1
    private function makeScale($scale)
168
    {
169
        switch ($scale) {
170 1
            case 'huge':
171 1
                return ';scale:180';
172 1
            case 'big':
173 1
                return ';scale:120';
174 1
            case 'small':
175 1
                return ';scale:80';
176 1
            case 'tiny':
177 1
                return ';scale:60';
178
            default:
179 1
                return '';
180
        }
181
    }
182
183
    /**
184
     * @param string $extension
185
     * @return string
186
     */
187 1
    private function checkExtension($extension)
188
    {
189
        switch ($extension) {
190 1
            case 'jpg':
191 1
            case 'svg':
192 1
            case 'pdf':
193 1
            case 'json':
194 1
                return $extension;
195
            default:
196 1
                return 'png';
197
        }
198
    }
199
200 1
    private function checkStyle($style)
201
    {
202
        switch ($style) {
203 1
            case 'boring':
204 1
            case 'scruffy':
205 1
                return $style;
206
            default:
207 1
                return 'plain';
208
        }
209
    }
210
}
211