Issues (36)

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/step/AbstractStep.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
namespace einfach\operation\step;
4
5
use const einfach\operation\response\RESPONSE_TYPE_ERROR;
6
use const einfach\operation\response\RESPONSE_TYPE_OK;
7
use function einfach\operation\response\isValidResponse;
8
use function einfach\operation\response\isOk;
9
use function einfach\operation\response\isError;
10
use einfach\operation\Result;
11
12
abstract class AbstractStep
13
{
14
    /**
15
     * @var callable
16
     */
17
    public $function;
18
    protected $name;
19
    /**
20
     * Indicates was this step performed or not
21
     *
22
     * @var bool
23
     */
24
    protected $skipped;
25
    protected $opt;
26
27 26
    public function __construct(callable $callable, string $name = null, array $opt = [])
28
    {
29 26
        $this->function = $callable;
30 26
        $this->name = $name;
31 26
        $this->skipped = false;
32 26
        $this->opt = $opt;
33 26
    }
34
35 24
    public function isSkipped() : bool
36
    {
37 24
        return true == $this->skipped;
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
38
    }
39
40 7
    public function skip() : bool
41
    {
42 7
        return $this->skipped = true;
43
    }
44
45 7
    public function functionSignature() : string
46
    {
47 7
        is_callable($this->function, false, $functionName);
48 7
        return $functionName;
49
    }
50
51
    /**
52
     * Step name, respecting custom name
53
     */
54 8
    public function name() : string
55
    {
56 8
        return $this->name ?? $this->functionSignature();
57
    }
58
59 5
    public function signature($template = "%-10s | %s") : string
60
    {
61 5
        $className = (new \ReflectionClass($this))->getShortName();
62 5
        return sprintf($template, $className, $this->name());
63
    }
64
65
    /**
66
     * Transform all results into valid resut array form
67
     * It could be Result object instance for nested steps
68
     */
69 17
    protected function normalizeStepResponse($result) : array
70
    {
71 17
        $stepResult = $result;
72
        
73 17
        if (is_a($result, Result::class)) {
74
             $stepResult = [
75 5
                    'params' => $result->params(),
76 5
                    'type' => ($result->isSuccess()) ? RESPONSE_TYPE_OK : RESPONSE_TYPE_ERROR
77
                ];
78
        }
79
80 17
        if (!isValidResponse($stepResult)) {
81
            $actualResult = var_export($stepResult, true);
82
            throw new \Exception("Step '{$this->name()}' returned incorrectly formatted result. \
83
            Maybe you forgot to return `ok(\$params)` or `error(\$params)`. \
84
            Current return: {$actualResult}");
85
        }
86
87 17
        if (isOk($stepResult)) {
88 9
            $appendParams = $stepResult['appendParams'] ?? [];
89 9
            $stepResult['params'] = $stepResult['params'] ?? [];
90 9
            $stepResult['params'] = array_merge($stepResult['params'], $appendParams);
91 9
            unset($stepResult['appendParams']);
92 8
        } elseif (isError($stepResult)) {
93 8
            $appendError = $stepResult['appendError'] ?? [];
94 8
            $stepResult['params']['__errors'] = $stepResult['params']['__errors'] ?? [];
95 8
            if ($appendError) {
96 4
                $stepResult['params']['__errors'] = $stepResult['params']['__errors'] + $appendError;
97
            }
98 8
            unset($stepResult['appendError']);
99
        }
100
101 17
        return $stepResult;
102
    }
103
104
    abstract public function __invoke(&$params, string $track);
105
}
106