Issues (35)

Security Analysis    not enabled

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/DataEnricher/Node.php (3 issues)

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 LegalThings\DataEnricher;
4
5
use LegalThings\DataEnricher\Processor;
6
use GuzzleHttp\Promise\PromiseInterface;
7
8
/**
9
 * An object with processing instructions
10
 */
11
class Node extends \stdClass
12
{
13
    /**
14
     * The processed data
15
     * @var mixed 
16
     */
17
    protected $i_result;
18
19
    /**
20
     * Class constructor
21
     * 
22
     * @param \stdClass $data
23
     */
24 7
    public function __construct(\stdClass $data)
25
    {
26 7
        $this->i_result = $data;
27
        
28 7
        foreach ($data as $key => $value) {
0 ignored issues
show
The expression $data of type object<stdClass> is not traversable.
Loading history...
29 7
            if ($key === 'i_result') {
30
                continue;
31
            }
32
            
33 7
            $this->$key = $value;
34 7
        }
35 7
    }
36
37
    
38
    /**
39
     * Replace nodes with their results
40
     * 
41
     * @param array|object $target
42
     */
43 3 View Code Duplication
    protected function applyNodeResults(&$target)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
44
    {
45 2
        if ($target instanceof self) {
46
            $target = $target->getResult();
47
            $this->applyNodeResults($target);
48 3
        } elseif (is_array($target) || is_object($target)) {
49 2
            foreach ($target as &$value) {         
50 2
                $this->applyNodeResults($value);
51 2
            }
52 2
        }
53 2
    }
54
    
55
    /**
56
     * Get the processed result
57
     * 
58
     * @return mixed
59
     */
60 2
    public function getResult()
61
    {
62 2
        if ($this->i_result instanceof PromiseInterface) {
63
            $this->i_result->wait();
64
            
65
            if ($this->i_result instanceof PromiseInterface) {
66
                throw new \LogicException("Promise result not replaced with data");
67
            }
68
        }
69
70 2
        $result = $this->i_result;
71
        
72 2
        $this->applyNodeResults($result);
73 2
        return $result;
74
    }
75
    
76
    /**
77
     * Set the result after processing
78
     * 
79
     * @param mixed $result
80
     */
81 2
    public function setResult($result)
82
    {
83 2
        $this->i_result = $result;
84 2
    }
85
86
    
87
    /**
88
     * Test if the node has an instruction for a processor
89
     * 
90
     * @param Processor $processor
91
     * @return boolean
92
     */
93 2
    public function hasInstruction(Processor $processor)
94
    {
95 2
        $prop = $processor->getProperty();
96 2
        return isset($this->$prop);
97
    }
98
    
99
    /**
100
     * Get an instruction for a processor
101
     * 
102
     * @param Processor $processor
103
     * @return mixed
104
     */
105 7
    public function getInstruction(Processor $processor)
106
    {
107 7
        $prop = $processor->getProperty();
108
        
109 7
        if (!isset($this->$prop)) {
110
            throw new \LogicException("Node doesn't have instruction property '$prop'");
111
        }
112
        
113 7
        return $this->resolve($this->$prop);
114
    }
115
116
    /**
117
     * Resolve nodes within the value
118
     * 
119
     * @param mixed $value
120
     * @return mixed
121
     */
122 7 View Code Duplication
    protected function resolve($value)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
123
    {
124 7
        while ($value instanceof self) {
125 6
            $value = $value->getResult();
126 6
        }
127
        
128 7
        if (is_array($value) || is_object($value)) {
129 4
            foreach ($value as &$item) {
130 4
                $item = $this->resolve($item);
131 4
            }
132 4
        }
133
        
134 7
        return $value;
135
    }
136
    
137
    /**
138
     * Apply processing to this node
139
     * 
140
     * @param Processor $processor
141
     */
142 2
    public function apply(Processor $processor)
143
    {
144 2
        if (!$this->hasInstruction($processor)) {
145 2
            return;
146
        }
147
        
148 2
        if ($this->i_result instanceof PromiseInterface) {
149
            $this->i_result->then(function() use ($processor) {
150
                $processor->applyToNode($this);
151
            });
152
        } else {
153 2
            $processor->applyToNode($this);
154
        }
155 2
    }
156
}
157