Issues (168)

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/query/Relational.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
 * Created by PhpStorm.
4
 * User: VITALYIEGOROV
5
 * Date: 08.12.15
6
 * Time: 22:14
7
 */
8
namespace samsoncms\api\query;
9
10
use samsoncms\api\Material;
11
use samsonframework\orm\QueryInterface;
12
13
/**
14
 * Generic SamsonCMS query for retrieving entities that have relation between each other
15
 * through other relational entity.
16
 *
17
 * @package samsoncms\api
18
 */
19
class Relational
20
{
21
    /** @var string Related entity primary field */
22
    protected $relationPrimary;
23
24
    /** @var string Relation entity identifier */
25
    protected $relationIdentifier;
26
27
    /** @var QueryInterface Database query instance */
28
    protected $query;
29
30
    /** @var string Entity identifier */
31
    protected $identifier;
32
33
    /** @var string Entity primary field name */
34
    protected $primaryField;
35
36
    /** @var array Collection of entity identifiers for filtering */
37
    protected $filteringIDs = array();
38
39
    /**
40
     * Get current entity instances collection by their identifiers.
41
     * Method can accept different query executors.
42
     *
43
     * @param string|array $entityIDs Entity identifier or their collection
44
     * @param string $executor Method name for query execution
45
     * @return mixed[] Collection of entity instances
46
     */
47
    public function byIDs($entityIDs, $executor)
48
    {
49
        return $this->query
50
            ->entity($this->identifier)
51
            ->where($this->primaryField, $entityIDs)
52
            ->where(Material::F_DELETION, 1)
53
            ->$executor();
54
    }
55
56
    /**
57
     * Entity constructor.
58
     * @param QueryInterface $query Database query instance
59
     * @param string $identifier Entity identifier
60
     * @param string $primary Entity primary identifier
61
     * @param string $relationPrimary Relation entity primary field name
62
     * @param string $relationIdentifier Relation entity identifier
63
     * @param array $filteringIDs Collection of entity identifiers for filtering
64
     */
65
    public function __construct(
66
        QueryInterface $query,
67
        $identifier,
68
        $primary,
69
        $relationPrimary,
70
        $relationIdentifier,
71
        $filteringIDs = array()
72
    ) {
73
        $this->query = $query;
74
        $this->identifier = $identifier;
75
        $this->relationIdentifier = $relationIdentifier;
76
        $this->relationPrimary = $relationPrimary;
77
        $this->filteringIDs = $filteringIDs;
78
        $this->primaryField = $primary;
79
    }
80
81
    /**
82
     * Get current entity identifiers collection by navigation identifier.
83
     *
84
     * @param string $relationID Relation entity identifier
85
     * @param mixed $relationValue Relation entity value
86
     * @param array $filteringIDs Collection of entity identifiers for filtering query
87
     * @return array Collection of entity identifiers filtered by navigation identifier.
88
     */
89
    public function idsByRelationID($relationID, $relationValue = null, array $filteringIDs = array())
90
    {
91
        // Prepare query
92
        $this->query
93
            ->entity($this->relationIdentifier)
94
            ->where($this->relationPrimary, $relationID)
95
            ->where(Material::F_DELETION, 1);
96
97
        // Add entity identifier filter if passed
98
        $this->filteringIDs = array_merge($this->filteringIDs, $filteringIDs);
99
        if (sizeof($this->filteringIDs)) {
100
            $this->query->where($this->primaryField, $this->filteringIDs);
101
        }
102
103
        // Perform database query and get only material identifiers collection
104
        return $this->query->fields($this->primaryField);
105
    }
106
107
    /**
108
     * Retrieve entities from database.
109
     *
110
     * @param string|array $relationID Relation entity identifier or collection
111
     * @param mixed $relationValue Relation entity value
112
     * @param string $executor Query execution function name
113
     * @return mixed[] Collection of entity instances for this relation identifier
114
     */
115
    protected function retrieve($relationID, $relationValue, $executor)
116
    {
117
        $return = array();
118
        /** @var array $ids Collection of entity identifiers filtered by additional field */
119
        if (sizeof($ids = $this->idsByRelationID($relationID, $relationValue, $this->filteringIDs))) {
0 ignored issues
show
It seems like $relationID defined by parameter $relationID on line 115 can also be of type array; however, samsoncms\api\query\Relational::idsByRelationID() does only seem to accept string, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
120
            $return = $this->byIDs($ids, $executor);
121
        }
122
123
        return $return;
124
    }
125
126
    /**
127
     * Get current entity instances collection by navigation identifier.
128
     *
129
     * @param string $relationID Relation entity identifier
130
     * @param mixed $relationValue Relation entity value
131
     * @return mixed[] Collection of entity instances
132
     */
133
    public function byRelationID($relationID, $relationValue = null)
134
    {
135
        return $this->retrieve($relationID, $relationValue, 'exec');
136
    }
137
138
    /**
139
     * Get current entity instances amount by navigation identifier.
140
     *
141
     * @param string $relationID Relation entity identifier
142
     * @param mixed $relationValue Relation entity value
143
     * @return integer Amount of entities related to Navigation identifier
144
     */
145
    public function amountByRelationID($relationID, $relationValue = null)
146
    {
147
        return $this->retrieve($relationID, $relationValue, 'count');
148
    }
149
}
150