Issues (87)

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/Aop/Framework/AbstractInterceptor.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
declare(strict_types=1);
4
/*
5
 * Go! AOP framework
6
 *
7
 * @copyright Copyright 2011, Lisachenko Alexander <[email protected]>
8
 *
9
 * This source file is subject to the license that is bundled
10
 * with this source code in the file LICENSE.
11
 */
12
13
namespace Go\Aop\Framework;
14
15
use Closure;
16
use Go\Aop\Intercept\Interceptor;
17
use Go\Core\AspectKernel;
18
use ReflectionFunction;
19
use ReflectionMethod;
20
use Serializable;
21
22
/**
23
 * Base class for all framework interceptor implementations
24
 *
25
 * This class describe an action taken by the interceptor at a particular joinpoint.
26
 * Different types of interceptors include "around", "before" and "after" advices.
27
 *
28
 * Around interceptor is an advice that surrounds a joinpoint such as a method invocation. This is the most powerful
29
 * kind of advice. Around advices will perform custom behavior before and after the method invocation. They are
30
 * responsible for choosing whether to proceed to the joinpoint or to shortcut executing by returning their own return
31
 * value or throwing an exception.
32
 *
33
 * After and before interceptors are simple closures that will be invoked after and before main invocation.
34
 *
35
 * Framework models an interceptor as an PHP-closure, maintaining a chain of interceptors "around" the joinpoint:
36
 *   public function (Joinpoint $joinPoint)
37
 *   {
38
 *      echo 'Before action';
39
 *      // call chain here with Joinpoint->proceed() method
40
 *      $result = $joinPoint->proceed();
41
 *      echo 'After action';
42
 *
43
 *      return $result;
44
 *   }
45
 */
46
abstract class AbstractInterceptor implements Interceptor, OrderedAdvice, Serializable
47
{
48
    /**
49
     * Local cache of advices for faster unserialization on big projects
50
     *
51
     * @var array<Closure>
52
     */
53
    protected static array $localAdvicesCache = [];
0 ignored issues
show
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_ARRAY, expecting T_FUNCTION or T_CONST
Loading history...
54
55
    /**
56
     * Pointcut expression string which was used for this interceptor
57
     */
58
    protected string $pointcutExpression;
59
60
    /**
61
     * Closure to call
62
     */
63
    protected Closure $adviceMethod;
64
65
    /**
66
     * Advice order
67
     */
68
    private int $adviceOrder;
69
70
    /**
71
     * Default constructor for interceptor
72
     */
73 12
    public function __construct(Closure $adviceMethod, int $adviceOrder = 0, string $pointcutExpression = '')
74
    {
75 12
        $this->adviceMethod       = $adviceMethod;
76 12
        $this->adviceOrder        = $adviceOrder;
77 12
        $this->pointcutExpression = $pointcutExpression;
78 12
    }
79
80
    /**
81
     * Serialize advice method into array
82
     */
83 1
    public static function serializeAdvice(Closure $adviceMethod): array
84
    {
85 1
        $refAdvice = new ReflectionFunction($adviceMethod);
86
87
        return [
88 1
            'method' => $refAdvice->name,
89 1
            'class'  => $refAdvice->getClosureScopeClass()->name
90
        ];
91
    }
92
93
    /**
94
     * Unserialize an advice
95
     *
96
     * @param array $adviceData Information about advice
97
     */
98
    public static function unserializeAdvice(array $adviceData): Closure
99
    {
100
        $aspectName = $adviceData['class'];
101
        $methodName = $adviceData['method'];
102
103
        if (!isset(static::$localAdvicesCache["$aspectName->$methodName"])) {
104
            $aspect    = AspectKernel::getInstance()->getContainer()->getAspect($aspectName);
105
            $refMethod = new ReflectionMethod($aspectName, $methodName);
106
            $advice    = $refMethod->getClosure($aspect);
107
108
            static::$localAdvicesCache["$aspectName->$methodName"] = $advice;
109
        }
110
111
        return static::$localAdvicesCache["$aspectName->$methodName"];
112
    }
113
114
    /**
115
     * Returns the advice order
116
     */
117
    public function getAdviceOrder(): int
118
    {
119
        return $this->adviceOrder;
120
    }
121
122
    /**
123
     * Getter for extracting the advice closure from Interceptor
124
     */
125 2
    public function getRawAdvice(): Closure
126
    {
127 2
        return $this->adviceMethod;
128
    }
129
130
    /**
131
     * Serializes an interceptor into string representation
132
     */
133 2
    final public function serialize(): string
134
    {
135 2
        $vars = array_filter(get_object_vars($this));
136 2
137
        $vars['adviceMethod'] = static::serializeAdvice($this->adviceMethod);
138 2
139
        return serialize($vars);
140
    }
141
142
    /**
143
     * Unserialize an interceptor from the string
144
     *
145
     * @param string $serialized The string representation of the object.
146 1
     */
147
    final public function unserialize($serialized): void
148 1
    {
149 1
        $vars = unserialize($serialized, ['allowed_classes' => false]);
150 1
151 1
        $vars['adviceMethod'] = static::unserializeAdvice($vars['adviceMethod']);
152
        foreach ($vars as $key => $value) {
153 1
            $this->$key = $value;
154
        }
155
    }
156
}
157