Issues (126)

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/Db/AbstractDaoService.php (2 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
declare(strict_types=1);
3
/**
4
 * Minotaur
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
7
 * use this file except in compliance with the License. You may obtain a copy of
8
 * the License at
9
 *
10
 * http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15
 * License for the specific language governing permissions and limitations under
16
 * the License.
17
 *
18
 * @copyright 2015-2017 Appertly
19
 * @license   Apache-2.0
20
 */
21
namespace Minotaur\Db;
22
23
use Labrys\Getter;
24
25
/**
26
 * Abstract DAO-backed Service
27
 */
28
abstract class AbstractDaoService implements EntityRepo
29
{
30
    /**
31
     * @var \Minotaur\Acl\Gatekeeper
32
     */
33
    protected $gatekeeper;
34
    /**
35
     * @var string
36
     */
37
    protected $readPermission;
38
39
    /**
40
     * Creates a new AbstractDaoService.
41
     *
42
     * @param $gatekeeper - The security gatekeeper
43
     * @param $readPermission - The ACL permission for read access
44
     */
45
    public function __construct(
46
        \Minotaur\Acl\Gatekeeper $gatekeeper,
47
        string $readPermission = 'read'
48
    ) {
49
        $this->gatekeeper = $gatekeeper;
50
        $this->readPermission = $readPermission;
51
    }
52
53
    /**
54
     * Gets the DAO.
55
     *
56
     * @return - The backing DAO
0 ignored issues
show
The doc-type - could not be parsed: Unknown type name "-" at position 0. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
57
     */
58
    abstract protected function getDao(): EntityRepo;
59
60
    /**
61
     * @inheritDoc
62
     */
63
    public function getType(): string
64
    {
65
        return $this->getDao()->getType();
66
    }
67
68
    /**
69
     * @inheritDoc
70
     */
71
    public function countAll(array $criteria): int
72
    {
73
        return $this->getDao()->countAll($criteria);
74
    }
75
76
    /**
77
     * @inheritDoc
78
     */
79
    public function findOne(array $criteria)
80
    {
81
        return $this->getDao()->findOne($criteria);
82
    }
83
84
    /**
85
     * @inheritDoc
86
     */
87
    public function findAll(array $criteria, \Caridea\Http\Pagination $pagination = null, bool $totalCount = false): iterable
88
    {
89
        return $this->getDao()->findAll($criteria, $pagination, $totalCount);
90
    }
91
92
    /**
93
     * @inheritDoc
94
     * @throws \Caridea\Acl\Exception\Forbidden If the user has no access
95
     */
96
    public function findById($id)
97
    {
98
        $dao = $this->getDao();
99
        $entity = $dao->findById($id);
100
        if ($entity !== null) {
101
            $this->gatekeeper->assert($this->readPermission, $dao->getType(), $id);
102
        }
103
        return $entity;
104
    }
105
106
    /**
107
     * @inheritDoc
108
     * @throws \Caridea\Acl\Exception\Forbidden If the user has no access
109
     */
110
    public function get($id)
111
    {
112
        return $this->getAndAssert($id, $this->readPermission);
113
    }
114
115
    /**
116
     * @inheritDoc
117
     * @throws \Caridea\Acl\Exception\Forbidden If the user has no access
118
     */
119
    public function getAll(iterable $ids): iterable
120
    {
121
        $dao = $this->getDao();
122
        $all = $dao->getAll($ids);
123
        $this->gatekeeper->assertAll($this->readPermission, $dao->getType(), $ids);
124
        return $all;
125
    }
126
127
    /**
128
     * @inheritDoc
129
     */
130
    public function getInstanceMap(iterable $entities): array
131
    {
132
        return $this->getDao()->getInstanceMap($entities);
133
    }
134
135
    /**
136
     * Gets the entity and asserts an ACL permission.
137
     *
138
     * @param $id - The entity id
139
     * @param $verb - The verb (e.g. 'read', 'write')
140
     * @return - The entity
0 ignored issues
show
The doc-type - could not be parsed: Unknown type name "-" at position 0. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
141
     * @throws \Caridea\Dao\Exception\Unreachable If the connection fails
142
     * @throws \Caridea\Dao\Exception\Unretrievable If the document doesn't exist
143
     * @throws \Caridea\Dao\Exception\Generic If any other database problem occurs
144
     * @throws \Caridea\Acl\Exception\Forbidden If the user has no access
145
     */
146
    protected function getAndAssert($id, string $verb)
147
    {
148
        $dao = $this->getDao();
149
        $entity = $dao->get($id);
150
        $this->gatekeeper->assert($verb, $dao->getType(), $id);
151
        return $entity;
152
    }
153
}
154