Issues (6)

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/Rows/Processor.php (5 issues)

1
<?php
2
3
namespace Phperf\Pipeline\Rows;
4
5
use ArrayIterator;
6
use IteratorIterator;
7
8
class Processor extends IteratorIterator
9
{
10
    protected $rows = array();
11
    private $skipFields = array();
12
13
    public function skipField($field)
14
    {
15
        $this->skipFields[$field] = $field;
16
        return $this;
17
    }
18
19
    private $changeKeys = array();
20
21
    public function changeKey($fieldFrom, $fieldTo)
22
    {
23
        $this->changeKeys[$fieldFrom] = $fieldTo;
24
        return $this;
25
    }
26
27
28
    private $combineFields = array();
29
30
    public function combine($fieldKey, $fieldValue)
31
    {
32
        $this->combineFields[$fieldKey] = $fieldValue;
33
        return $this;
34
    }
35
36
    /** @var \Closure */
37
    private $callback;
38
    public function map(callable $callback)
39
    {
40
        $this->callback = $callback;
41
        return $this;
42
    }
43
44
    private $combineOffset = array();
45
46
    /**
47
     * @param integer $offsetKey
48
     * @param integer $offsetValue
49
     * @return $this
50
     */
51
    public function combineOffset($offsetKey, $offsetValue)
52
    {
53
        $this->combineOffset [$offsetKey] = $offsetValue;
54
        return $this;
55
    }
56
57
    /**
58
     * Processor constructor.
59
     * @param array|\Iterator $rows
60
     */
61
    public function __construct($rows)
62
    {
63
        if (is_array($rows)) {
64
            parent::__construct(new ArrayIterator($rows));
65
        } else {
66
            parent::__construct($rows);
67
        }
68
    }
69
70
    public function current()
71
    {
72
        $row = parent::current();
73
        if ($this->callback) {
74
            $row = $this->callback->__invoke($row);
75
        }
76
77
        if ($this->skipFields) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->skipFields of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
78
            foreach ($this->skipFields as $field) {
79
                if (isset($row[$field])) {
80
                    unset($row[$field]);
81
                }
82
            }
83
        }
84
85
        $keys = null;
86
87
        if ($this->combineOffset) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->combineOffset of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
88
            foreach ($this->combineOffset as $offsetKey => $offsetValue) {
89
                $keys = array_keys($row);
90
                $row[$row[$keys[$offsetKey]]] = $row[$keys[$offsetValue]];
91
                unset($row[$keys[$offsetKey]]);
92
                unset($row[$keys[$offsetValue]]);
93
            }
94
        }
95
96
        if ($this->combineFields) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->combineFields of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
97
            foreach ($this->combineFields as $fieldKey => $fieldValue) {
98
                $row[$row[$fieldKey]] = $row[$fieldValue];
99
                unset($row[$fieldKey]);
100
                unset($row[$fieldValue]);
101
            }
102
        }
103
104
        if ($this->changeKeys) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $this->changeKeys of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
105
            if (!$keys) {
106
                $keys = array_keys($row);
107
            }
108
            foreach ($keys as &$key) {
109
                if (isset($this->changeKeys[$key])) {
110
                    $key = $this->changeKeys[$key];
111
                }
112
            }
113
            unset($key);
114
            $row = array_combine($keys, $row);
115
        }
116
117
        return $row;
118
    }
119
120
121
    /**
122
     * @param array|\Iterator $rows
123
     * @return static
124
     */
125
    static function create($rows)
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
126
    {
127
        return new static($rows);
128
    }
129
130
131
    public function exportArray()
132
    {
133
        $result = array();
134
        foreach ($this as $row) {
135
            $result [] = $row;
136
        }
137
        return $result;
138
    }
139
140
}