Issues (3)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  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.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  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.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  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.
  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.
  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.
  Header Injection
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/Policy/CollectionResolver.php (1 issue)

1
<?php
2
3
/**
4
 * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
5
 * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
6
 *
7
 * Licensed under The MIT License
8
 * For full copyright and license information, please see the LICENSE.txt
9
 * Redistributions of files must retain the above copyright notice.
10
 *
11
 * @copyright     Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
12
 * @link          https://cakephp.org CakePHP(tm) Project
13
 * @since         1.0.0
14
 * @license       https://opensource.org/licenses/mit-license.php MIT License
15
 */
16
17
declare(strict_types=1);
18
19
namespace Phauthentic\Authorization\Policy;
20
21
use InvalidArgumentException;
22
use Phauthentic\Authorization\Policy\Exception\MissingPolicyException;
23
24
/**
25
 * `ResolverCollection` is used for aggregating multiple resolvers when more than
26
 * one resolver is necessary. The collection will iterate over configured resolvers
27
 * and try to resolve a policy on each one. The first successfully resolved policy
28
 * will be returned.
29
 *
30
 * Configured resolvers must throw `Authorization\Policy\Exception\MissingPolicyException`
31
 * if a policy cannot be resolved.
32
 *
33
 * Example configuration:
34
 *
35
 * ```
36
 * $collection = new ResolverCollection([
37
 *     new OrmResolver(),
38
 *     new MapResolver([
39
 *         Service::class => ServicePolicy::class
40
 *     ])
41
 * ]);
42
 *
43
 * $service = new AuthenticationService($collection);
44
 * ```
45
 */
46
class CollectionResolver implements ResolverInterface
47
{
48
    /**
49
     * Policy resolver instances.
50
     *
51
     * @var \Phauthentic\Authorization\Policy\ResolverCollectionInterface
52
     */
53
    protected $collection;
54
55
    /**
56
     * Constructor. Takes an array of policy resolver instances.
57
     *
58
     * @param \Phauthentic\Authorization\Policy\ResolverCollectionInterface $collection
59
     */
60 2
    public function __construct(ResolverCollectionInterface $collection)
61
    {
62 2
        $this->collection = $collection;
63 2
    }
64
65
    /**
66
     * {@inheritDoc}
67
     */
68 2
    public function getPolicy($resource)
69
    {
70 2
        foreach ($this->collection as $resolver) {
71
            try {
72 2
                return $resolver->getPolicy($resource);
73 2
            } catch (MissingPolicyException $e) {
74
                // Ignore this case because we'll try the next resolver
75
            } catch (InvalidArgumentException $e) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
76
            }
77
        }
78
79
        $class = get_class($resource);
80
        $message = sprintf('Policy for `%s` has not been defined.', $class);
81
82
        throw new MissingPolicyException($message);
83
    }
84
}
85