This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /** |
||
4 | * \AppserverIo\Doppelgaenger\Entities\PointcutExpression |
||
5 | * |
||
6 | * NOTICE OF LICENSE |
||
7 | * |
||
8 | * This source file is subject to the Open Software License (OSL 3.0) |
||
9 | * that is available through the world-wide-web at this URL: |
||
10 | * http://opensource.org/licenses/osl-3.0.php |
||
11 | * |
||
12 | * PHP version 5 |
||
13 | * |
||
14 | * @author Bernhard Wick <[email protected]> |
||
15 | * @copyright 2015 TechDivision GmbH - <[email protected]> |
||
16 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
||
17 | * @link https://github.com/appserver-io/doppelgaenger |
||
18 | * @link http://www.appserver.io/ |
||
19 | */ |
||
20 | |||
21 | namespace AppserverIo\Doppelgaenger\Entities; |
||
22 | |||
23 | use AppserverIo\Doppelgaenger\Dictionaries\ReservedKeywords; |
||
24 | use AppserverIo\Doppelgaenger\Entities\Pointcuts\PointcutFactory; |
||
25 | use AppserverIo\Doppelgaenger\Interfaces\CodifyableInterface; |
||
26 | use AppserverIo\Psr\MetaobjectProtocol\Aop\Annotations\Advices\Around; |
||
27 | |||
28 | /** |
||
29 | * Definition of a pointcut as a combination of a joinpoint and advices |
||
30 | * |
||
31 | * @author Bernhard Wick <[email protected]> |
||
32 | * @copyright 2015 TechDivision GmbH - <[email protected]> |
||
33 | * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
||
34 | * @link https://github.com/appserver-io/doppelgaenger |
||
35 | * @link http://www.appserver.io/ |
||
36 | * |
||
37 | * @see https://www.eclipse.org/aspectj/doc/next/progguide/quick.html |
||
38 | * @see https://www.eclipse.org/aspectj/doc/next/progguide/semantics-pointcuts.html |
||
39 | */ |
||
40 | class PointcutExpression implements CodifyableInterface |
||
41 | { |
||
42 | |||
43 | /** |
||
44 | * Joinpoint at which the enclosed advices have to be weaved |
||
45 | * |
||
46 | * @var \AppserverIo\Doppelgaenger\Entities\Joinpoint|null $joinpoint |
||
47 | */ |
||
48 | protected $joinpoint; |
||
49 | |||
50 | /** |
||
51 | * Pointcut(tree) representing the logical structure of the given string expression |
||
52 | * |
||
53 | * @var \AppserverIo\Doppelgaenger\Interfaces\PointcutInterface $pointcut |
||
54 | */ |
||
55 | protected $pointcut; |
||
56 | |||
57 | /** |
||
58 | * Original string definition of the pointcut |
||
59 | * |
||
60 | * @var string $string |
||
61 | */ |
||
62 | protected $string; |
||
63 | |||
64 | /** |
||
65 | * Default constructor |
||
66 | * |
||
67 | * @param string $rawString Raw string the pointcuts expressions can be filtered from |
||
68 | */ |
||
69 | public function __construct($rawString) |
||
70 | { |
||
71 | $this->joinpoint = null; |
||
72 | $this->string = $rawString; |
||
73 | |||
74 | $pointcutFactory = new PointcutFactory(); |
||
75 | $this->pointcut = $pointcutFactory->getInstance($rawString); |
||
76 | } |
||
77 | |||
78 | /** |
||
79 | * Getter for the $joinpoints property |
||
80 | * |
||
81 | * @return \AppserverIo\Doppelgaenger\Entities\Joinpoint|null |
||
82 | */ |
||
83 | public function getJoinpoint() |
||
84 | { |
||
85 | return $this->joinpoint; |
||
86 | } |
||
87 | |||
88 | /** |
||
89 | * Getter for the $pointcut property |
||
90 | * |
||
91 | * @return \AppserverIo\Doppelgaenger\Interfaces\PointcutInterface |
||
92 | */ |
||
93 | public function getPointcut() |
||
94 | { |
||
95 | return $this->pointcut; |
||
96 | } |
||
97 | |||
98 | /** |
||
99 | * Getter for the $string property |
||
100 | * |
||
101 | * @return string |
||
102 | */ |
||
103 | public function getString() |
||
104 | { |
||
105 | return $this->string; |
||
106 | } |
||
107 | |||
108 | /** |
||
109 | * Setter for the $joinpoints property |
||
110 | * |
||
111 | * @param \AppserverIo\Doppelgaenger\Entities\Joinpoint $joinpoint Joinpoint instance to set |
||
112 | * |
||
113 | * @return null |
||
114 | */ |
||
115 | public function setJoinpoint(Joinpoint $joinpoint) |
||
116 | { |
||
117 | $this->joinpoint = $joinpoint; |
||
118 | } |
||
119 | |||
120 | /** |
||
121 | * Setter for the $pointcut property |
||
122 | * |
||
123 | * @param \AppserverIo\Doppelgaenger\Interfaces\PointcutInterface $pointcut Pointcut of this expression |
||
124 | * |
||
125 | * @return null |
||
126 | */ |
||
127 | public function setPointcut($pointcut) |
||
128 | { |
||
129 | $this->pointcut = $pointcut; |
||
130 | } |
||
131 | |||
132 | /** |
||
133 | * Setter for the $string property |
||
134 | * |
||
135 | * @param string $string Expression string |
||
136 | * |
||
137 | * @return null |
||
138 | */ |
||
139 | public function setString($string) |
||
140 | { |
||
141 | $this->string = $string; |
||
142 | } |
||
143 | |||
144 | /** |
||
145 | * Return a string representation of the logic behind pointcut expression |
||
146 | * |
||
147 | * @return string |
||
148 | */ |
||
149 | public function toCode() |
||
150 | { |
||
151 | // around advices need to have their result saved |
||
152 | $assignTo = null; |
||
153 | if (!is_null($this->getJoinpoint()) && $this->getJoinpoint()->getCodeHook() === Around::ANNOTATION) { |
||
154 | $assignTo = ReservedKeywords::RESULT; |
||
155 | } |
||
156 | |||
157 | // do we even have an useful condition? |
||
158 | $condition = $this->getPointcut()->getConditionString(); |
||
159 | if ($condition === 'true' || empty($condition)) { |
||
160 | return $this->getPointcut()->getExecutionString($assignTo); |
||
161 | |||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
162 | } else { |
||
163 | return 'if (' . $condition .') { |
||
164 | ' . $this->getPointcut()->getExecutionString($assignTo) . ' |
||
165 | }'; |
||
166 | } |
||
167 | } |
||
168 | } |
||
169 |