Issues (24)

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/Codeception/Helper/GraphQL.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
4
namespace SmartWeb\ModuleTesting\Codeception\Helper;
5
6
use Codeception\Exception\ModuleException;
7
use Codeception\Module;
8
use Codeception\Module\Laravel5;
9
use Illuminate\Support\Arr;
10
use function strpos;
11
12
13
/**
14
 * Class GraphQL
15
 *
16
 * @package SmartWeb\ModuleTesting\Codeception\Helper
17
 */
18
class GraphQL extends Module
19
{
20
    
21
    /**
22
     * @param string $table
23
     * @param array  $records
24
     */
25
    public function seeRecords(string $table, array $records)
26
    {
27
        $laravel5 = $this->getLaravel5Module();
28
        
29
        foreach ($records as $record) {
30
            $laravel5->seeRecord($table, $record);
31
        }
32
    }
33
    
34
    /**
35
     * @return Laravel5
36
     */
37
    protected function getLaravel5Module() : Laravel5
38
    {
39
        return $this->getModule('Laravel5');
40
    }
41
    
42
    /**
43
     * @param string[] ...$keys
44
     */
45
    public function assertResponseHasKeys(string... $keys)
46
    {
47
        $this->assertArrayHasDotKeys("Response should have key.", $this->getResponseContentAsArray(), ...$keys);
48
    }
49
    
50
    /**
51
     * @param string   $message
52
     * @param array    $array
53
     * @param string[] ...$keys
54
     */
55
    public function assertArrayHasDotKeys(string $message, array $array, string... $keys)
56
    {
57
        foreach ($keys as $key) {
58
            if (strpos($key, '.') == false) {
0 ignored issues
show
Bug Best Practice introduced by
It seems like you are loosely comparing \strpos($key, '.') of type integer to the boolean false. If you are specifically checking for 0, consider using something more explicit like === 0 instead.
Loading history...
59
                $this->assertArrayHasKey($key, $array, $message);
60
                continue;
61
            }
62
            
63
            $subKeyArray = $array;
64
            
65
            foreach (explode('.', $key) as $segment) {
66
                if (Arr::accessible($subKeyArray)) {
67
                    $subKeyArray = $subKeyArray[$segment];
68
                } else {
69
                    $this->assertArrayHasKey($segment, $subKeyArray, $message);
70
                    continue;
71
                }
72
            }
73
        }
74
    }
75
    
76
    /**
77
     * @param $text
78
     */
79
    public function seeResponseContains($text)
80
    {
81
        $this->assertContains($text, $this->getResponseContent(), "response contains");
82
    }
83
    
84
    /**
85
     * @return array
86
     */
87
    public function getResponseContentAsArray() : array
88
    {
89
        $jsonResponse = $this->getResponseContent();
90
        
91
        return json_decode($jsonResponse, true) ?? [];
92
    }
93
    
94
    /**
95
     * @return mixed
96
     */
97
    public function getResponseContent()
98
    {
99
        try {
100
            return $this->getLaravel5Module()->_getResponseContent();
101
        } catch (ModuleException $e) {
102
            $this->fail($e->getMessage());
103
            
104
            return null;
105
        }
106
    }
107
    
108
    /**
109
     * @param string $key
110
     *
111
     * @return mixed
112
     */
113
    public function getResponseKey(string $key)
114
    {
115
        return Arr::get($this->getResponseContentAsArray(), $key);
116
    }
117
    
118
}
119