Issues (37)

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/Metadata/AnnotationParser.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
3
namespace Flying\Struct\Metadata;
4
5
use Doctrine\Common\Annotations\AnnotationReader;
6
use Doctrine\Common\Annotations\AnnotationRegistry;
7
use Doctrine\Common\Annotations\Reader;
8
use Flying\Struct\Annotation\Annotation;
9
use Flying\Struct\Annotation\Property;
10
use Flying\Struct\Annotation\Struct;
11
use Flying\Struct\ConfigurationManager;
12
use Flying\Struct\Exception;
13
14
/**
15
 * Structures metadata parser implementation for parsing structure annotations
16
 */
17
class AnnotationParser extends AbstractMetadataParser
18
{
19
    /**
20
     * Annotations reader
21
     *
22
     * @var Reader
23
     */
24
    private $reader;
25
26
    /**
27
     * {@inheritdoc}
28
     * @throws \Flying\Struct\Exception
29
     * @throws \InvalidArgumentException
30
     */
31 182
    protected function parseMetadata(\ReflectionClass $reflection, StructMetadata $metadata)
32
    {
33 182
        $reader = $this->getReader();
34 182
        $annotations = $reader->getClassAnnotations($reflection);
35 182
        foreach ($annotations as $annotation) {
36 181
            $metadata->addProperty($this->convertToMetadata($annotation));
37 182
        }
38 181
    }
39
40
    /**
41
     * Get annotations reader
42
     *
43
     * @return Reader
44
     * @throws \InvalidArgumentException
45
     */
46 182
    public function getReader()
47
    {
48 182
        if (!$this->reader) {
49 182
            $this->reader = new AnnotationReader();
50 182
            AnnotationRegistry::registerLoader('class_exists');
0 ignored issues
show
Deprecated Code introduced by
The method Doctrine\Common\Annotati...istry::registerLoader() has been deprecated with message: this method is deprecated and will be removed in doctrine/annotations 2.0 autoloading should be deferred to the globally registered autoloader by then. For now, use @example AnnotationRegistry::registerLoader('class_exists')

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...
51 182
        }
52 182
        return $this->reader;
53
    }
54
55
    /**
56
     * Set annotations reader to use for parsing structure annotations
57
     *
58
     * @param Reader $reader
59
     *
60
     * @return $this
61
     */
62 1
    public function setReader(Reader $reader)
63
    {
64 1
        $this->reader = $reader;
65 1
        return $this;
66
    }
67
68
    /**
69
     * Convert given structure annotation into structure metadata
70
     *
71
     * @param Annotation $annotation Structure annotation to convert
72
     *
73
     * @return PropertyMetadata
74
     * @throws \InvalidArgumentException
75
     * @throws Exception
76
     */
77 181
    protected function convertToMetadata(Annotation $annotation)
78
    {
79 181
        if ($annotation instanceof Property) {
80 179
            $class = $this->resolvePropertyClass($annotation->getType());
81 179
            if (!is_string($class)) {
82 1
                throw new Exception('Unable to resolve structure property class for type: ' . $annotation->getType());
83
            }
84 178
            $property = new PropertyMetadata($annotation->getName(), $class, $annotation->getConfig());
85 178
            return $property;
86
        }
87
88 67
        if (!($annotation instanceof Struct)) {
89
            throw new Exception('Unknown structure annotation type');
90
        }
91
92 67
        if ($annotation->getClass()) {
93 67
            $class = $this->resolveStructClass($annotation->getClass());
94 67
            if (!is_string($class)) {
95 2
                throw new Exception('Unable to resolve structure class: ' . $annotation->getClass());
96
            }
97 65
            $struct = ConfigurationManager::getConfiguration()->getMetadataManager()->getMetadata($class);
98 65
            if (!$struct instanceof StructMetadata) {
99 1
                throw new Exception('Failed to get structure metadata for class: ' . $class);
100
            }
101 64
            $struct->setName($annotation->getName());
102 64
            $struct->setConfig($annotation->getConfig());
103 64
        } else {
104 15
            if (!count($annotation->getProperties())) {
105
                throw new Exception('Structure metadata should have either class name or explicitly defined list of structure properties');
106
            }
107 15
            $struct = new StructMetadata($annotation->getName(), null, $annotation->getConfig());
108 15
            foreach ($annotation->getProperties() as $p) {
109 15
                $struct->addProperty($this->convertToMetadata($p));
110 15
            }
111
        }
112 64
        return $struct;
113
    }
114
}
115