Issues (104)

Security Analysis    not enabled

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/Metadata/RelationshipMetadata.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 As3\Modlr\Metadata;
4
5
use As3\Modlr\Exception\MetadataException;
6
7
/**
8
 * Defines metadata for a relationship field.
9
 * Should be loaded using the MetadataFactory, not instantiated directly.
10
 *
11
 * @author Jacob Bare <[email protected]>
12
 */
13
class RelationshipMetadata extends FieldMetadata
14
{
15
    /**
16
     * The entity type this is related to.
17
     *
18
     * @var string
19
     */
20
    public $entityType;
21
22
    /**
23
     * The relationship type: one or many
24
     *
25
     * @var string
26
     */
27
    public $relType;
28
29
    /**
30
     * Determines if this is an inverse (non-owning) relationship.
31
     *
32
     * @var bool
33
     */
34
    public $isInverse = false;
35
36
    /**
37
     * The inverse field.
38
     *
39
     * @var bool
40
     */
41
    public $inverseField;
42
43
    /**
44
     * Determines if the relationship related to a polymorphic entity.
45
     *
46
     * @var bool
47
     */
48
    public $polymorphic = false;
49
50
    /**
51
     * Child entity types the related entity owns.
52
     * Only used for polymorphic relationships.
53
     */
54
    public $ownedTypes = [];
55
56
    /**
57
     * Constructor.
58
     *
59
     * @param   string  $key        The relationship field key.
60
     * @param   string  $relType    The relationship type.
61
     * @param   string  $entityType The entity type key.
62
     * @param   bool    $mixin
63
     */
64
    public function __construct($key, $relType, $entityType, $mixin = false)
65
    {
66
        parent::__construct($key, $mixin);
67
        $this->setRelType($relType);
68
        $this->entityType = $entityType;
69
    }
70
71
    /**
72
     * Gets the entity type that this field is related to.
73
     *
74
     * @return  string
75
     */
76
    public function getEntityType()
77
    {
78
        return $this->entityType;
79
    }
80
81
    /**
82
     * Gets the relationship type.
83
     *
84
     * @return  string
85
     */
86
    public function getRelType()
87
    {
88
        return $this->relType;
89
    }
90
91
    /**
92
     * Determines if this is a one (single) relationship.
93
     *
94
     * @return  bool
95
     */
96
    public function isOne()
97
    {
98
        return 'one' === $this->getRelType();
99
    }
100
101
    /**
102
     * Determines if this is a many relationship.
103
     *
104
     * @return bool
105
     */
106
    public function isMany()
107
    {
108
        return 'many' === $this->getRelType();
109
    }
110
111
    /**
112
     * Determines whether the relationship is polymorphic.
113
     *
114
     * @return  bool
115
     */
116
    public function isPolymorphic()
117
    {
118
        return $this->polymorphic;
119
    }
120
121
    public function setPolymorphic($bit = true)
122
    {
123
        $this->polymorphic = (Boolean) $bit;
124
        return $this;
125
    }
126
127
    /**
128
     * Sets the relationship type: one or many.
129
     *
130
     * @param   string  $relType
131
     * @return  self
132
     */
133
    public function setRelType($relType)
134
    {
135
        $relType = strtolower($relType);
136
        $this->validateType($relType);
137
        $this->relType = $relType;
138
        return $this;
139
    }
140
141
    /**
142
     * Validates the relationship type.
143
     *
144
     * @param   string  $relType
145
     * @return  bool
146
     * @throws  MetadataException
147
     */
148 View Code Duplication
    protected function validateType($relType)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
149
    {
150
        $valid = ['one', 'many'];
151
        if (!in_array($relType, $valid)) {
152
            throw MetadataException::invalidRelType($relType, $valid);
153
        }
154
        return true;
155
    }
156
}
157