Issues (245)

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/Parser/TraitParser.php (3 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
 * \AppserverIo\Doppelgaenger\Parser\TraitParser
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Bernhard Wick <[email protected]>
15
 * @copyright 2015 TechDivision GmbH - <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/appserver-io/doppelgaenger
18
 * @link      http://www.appserver.io/
19
 */
20
21
namespace AppserverIo\Doppelgaenger\Parser;
22
23
use AppserverIo\Doppelgaenger\Entities\Definitions\TraitDefinition;
24
use AppserverIo\Doppelgaenger\Exceptions\GeneratorException;
25
use AppserverIo\Psr\MetaobjectProtocol\Dbc\Annotations\Invariant;
26
27
/**
28
 * Parser which is used to parse trait definitions.
29
 * Does inherit from the class parser, as both have a lot in common
30
 *
31
 * @author    Bernhard Wick <[email protected]>
32
 * @copyright 2015 TechDivision GmbH - <[email protected]>
33
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
34
 * @link      https://github.com/appserver-io/doppelgaenger
35
 * @link      http://www.appserver.io/
36
 */
37
class TraitParser extends AbstractStructureParser
38
{
39
40
    /**
41
     * We want to be able to parse properties
42
     */
43
    use PropertyParserTrait;
44
45
    /**
46
     * Token representing the structure this parser is used for
47
     *
48
     * @var integer TOKEN
49
     */
50
    const TOKEN = T_TRAIT;
51
52
    /**
53
     * Will return the token representing the structure the parser is used for e.g. T_CLASS
54
     *
55
     * @return integer
56
     */
57
    public function getToken()
58
    {
59
        return self::TOKEN;
60
    }
61
62
    /**
63
     * Will return the constants within the main token array.
64
     * Traits cannot have constants sadly...
65
     *
66
     * @return array
67
     */
68
    public function getConstants()
69
    {
70
        return array();
71
    }
72
73
    /**
74
     * Returns a TraitDefinition from a token array.
75
     *
76
     * This method will use a set of other methods to parse a token array and retrieve any
77
     * possible information from it. This information will be entered into a ClassDefinition object.
78
     *
79
     * @param array   $tokens       The token array containing structure tokens
80
     * @param boolean $getRecursive Do we have to get the ancestral conditions as well? Makes no sense currently
81
     *
82
     * @return \AppserverIo\Doppelgaenger\Interfaces\StructureDefinitionInterface
83
     *
84
     * @throws \AppserverIo\Doppelgaenger\Exceptions\GeneratorException
85
     */
86
    protected function getDefinitionFromTokens($tokens, $getRecursive = false)
87
    {
88
        // First of all we need a new TraitDefinition to fill
89 View Code Duplication
        if (is_null($this->currentDefinition)) {
90
            $this->currentDefinition = new TraitDefinition();
91
0 ignored issues
show
Blank line found at end of control structure
Loading history...
92
        } elseif (!$this->currentDefinition instanceof TraitDefinition) {
93
            throw new GeneratorException(sprintf(
94
                'The structure definition %s does not seem to be a trait definition.',
95
                $this->currentDefinition->getQualifiedName()
96
            ));
97
        }
98
99
        // Save the path of the original definition for later use
100
        $this->currentDefinition->setPath($this->file);
101
102
        // File based namespaces do not make much sense, so hand it over here.
103
        $this->currentDefinition->setNamespace($this->getNamespace());
104
        $this->currentDefinition->setName($this->getName($tokens));
105
        $this->currentDefinition->setUsedStructures($this->getUsedStructures());
106
107
        // For our next step we would like to get the doc comment (if any)
108
        $this->currentDefinition->setDocBlock($this->getDocBlock($tokens, $this->getToken()));
109
110
        // Get start and end line
111
        $this->currentDefinition->setStartLine($this->getStartLine($tokens));
112
        $this->currentDefinition->setEndLine($this->getEndLine($tokens));
113
114
        // So we got our docBlock, now we can parse the invariant annotations from it
115
        $annotationParser = new AnnotationParser($this->file, $this->config, $this->tokens, $this->currentDefinition);
116
        $this->currentDefinition->setInvariantConditions(
117
            $annotationParser->getConditions(
0 ignored issues
show
It seems like $annotationParser->getCo...\Invariant::ANNOTATION) targeting AppserverIo\Doppelgaenge...Parser::getConditions() can also be of type false; however, AppserverIo\Doppelgaenge...etInvariantConditions() does only seem to accept object<AppserverIo\Doppe...es\Lists\AssertionList>, did you maybe forget to handle an error condition?
Loading history...
118
                $this->currentDefinition->getDocBlock(),
119
                Invariant::ANNOTATION
120
            )
121
        );
122
123
        // Only thing still missing are the methods, so ramp up our FunctionParser
124
        $functionParser = new FunctionParser(
125
            $this->file,
126
            $this->config,
127
            $this->structureDefinitionHierarchy,
128
            $this->structureMap,
129
            $this->currentDefinition,
130
            $this->tokens
131
        );
132
133
        $this->currentDefinition->setFunctionDefinitions(
134
            $functionParser->getDefinitionListFromTokens(
0 ignored issues
show
It seems like $functionParser->getDefi...$tokens, $getRecursive) targeting AppserverIo\Doppelgaenge...initionListFromTokens() can also be of type false; however, AppserverIo\Doppelgaenge...etFunctionDefinitions() does only seem to accept object<AppserverIo\Doppe...FunctionDefinitionList>, did you maybe forget to handle an error condition?
Loading history...
135
                $tokens,
136
                $getRecursive
137
            )
138
        );
139
140
        // Lets get the attributes the class might have
141
        $this->currentDefinition->setAttributeDefinitions($this->getAttributes($tokens));
142
143
        // Before exiting we will add the entry to the current structure definition hierarchy
144
        $this->structureDefinitionHierarchy->insert($this->currentDefinition);
145
146
        return $this->currentDefinition;
147
    }
148
}
149