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.

features/bootstrap/FeatureContext.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
use Behat\Behat\Context\Context;
4
use Behat\Behat\Context\SnippetAcceptingContext;
5
use Behat\Gherkin\Node\PyStringNode;
6
use PHPUnit_Framework_Assert as Assert;
7
use TomPHP\HalClient\Client;
8
use TomPHP\HalClient\Exception\HalClientException;
9
use TomPHP\HalClient\Exception\UnknownContentTypeException;
10
use TomPHP\HalClient\HttpClient;
11
use TomPHP\HalClient\HttpClient\DummyHttpClient;
12
use TomPHP\HalClient\HttpClient\GuzzleHttpClient;
13
use TomPHP\HalClient\Processor\HalJsonProcessor;
14
use TomPHP\HalClient\Resource\Node;
15
16
/**
17
 * Defines application features from the specific context.
18
 */
19
class FeatureContext implements Context, SnippetAcceptingContext
0 ignored issues
show
Deprecated Code introduced by
The interface Behat\Behat\Context\SnippetAcceptingContext has been deprecated with message: will be removed in 4.0. Use --snippets-for CLI option instead

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
20
{
21
    /** @var HttpClient */
22
    private $httpClient;
23
24
    /** @var Client */
25
    private $client;
26
27
    /** @var Response */
28
    private $response;
29
30
    /** @var HalClientException */
31
    private $error;
32
33
    /** @var Node */
34
    private $result;
35
36
    /** @var string */
37
    private $urlPrefix = '';
38
39
    /**
40
     * Initializes context.
41
     *
42
     * Every scenario gets its own context instance.
43
     * You can also pass arbitrary arguments to the
44
     * context constructor through behat.yml.
45
     */
46
    public function __construct($client)
47
    {
48
        if ($client === 'guzzle') {
49
            $this->httpClient = new GuzzleHttpClient();
50
            $this->urlPrefix  = 'http://localhost:1080';
51
        } else {
52
            $this->httpClient = new DummyHttpClient();
53
        }
54
55
        $this->client = new Client($this->httpClient, [
56
            new HalJsonProcessor(),
57
        ]);
58
    }
59
60
    /**
61
     * @Given a :method endpoint :url which returns content type :contentType and body:
62
     */
63
    public function aEndpointWhichReturnsContentTypeAndBody($method, $url, $contentType, PyStringNode $body)
64
    {
65
        $this->httpClient->createEndpoint($method, $url, $contentType, (string) $body);
66
    }
67
68
    /**
69
     * @When I make a GET request to :url
70
     */
71
    public function iMakeAGetRequestTo($url)
72
    {
73
        try {
74
            $this->response = $this->client->get($this->urlPrefix.$url);
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->client->get($this->urlPrefix . $url) of type resource is incompatible with the declared type object<Response> of property $response.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
75
        } catch (HalClientException $error) {
76
            $this->error = $error;
77
        }
78
    }
79
80
    /**
81
     * @When I make a GET request to link :linkName from the response
82
     */
83
    public function iMakeAGetRequestToLinkFromTheResponse($linkName)
84
    {
85
        $this->response = $this->response->getLink($linkName)->get();
86
    }
87
88
    /**
89
     * @Then I should get a bad content type error
90
     */
91
    public function iShouldGetABadContentTypeError()
92
    {
93
        Assert::assertInstanceOf(UnknownContentTypeException::class, $this->error);
94
    }
95
96
    /**
97
     * @Then the response field :field should contain :value
98
     */
99
    public function theResponseFieldShouldContain($field, $value)
100
    {
101
        Assert::assertEquals($value, $this->response->$field->getValue());
102
    }
103
104
    /**
105
     * @Then the response field :fieldName in embedded resource :resourceName should contain :value
106
     */
107
    public function theResponseFieldInEmbeddedResourceShouldContain($resourceName, $fieldName, $value)
108
    {
109
        Assert::assertEquals($value, $this->response->getResource($resourceName)->$fieldName->getValue());
110
    }
111
112
    /**
113
     * @Then the field :level2 in response field :level1 should contain :value
114
     */
115
    public function theResponseFieldInResponseFieldShouldContain($level1, $level2, $value)
116
    {
117
        Assert::assertEquals($value, $this->response->$level1->$level2->getValue());
118
    }
119
120
    /**
121
     * @Then the field :fieldName at index :index in response field :resourceName should contain :value
122
     */
123
    public function theFieldAtIndexInResponseFieldShouldContain($fieldName, $resourceName, $value, $index)
124
    {
125
        Assert::assertEquals($value, $this->response->{$resourceName}[$index]->$fieldName->getValue());
126
    }
127
128
    /**
129
     * @Then the field :fieldName at index :index in resource field :resourceName should contain :value
130
     */
131
    public function theFieldAtIndexInResourceFieldShouldContain($fieldName, $resourceName, $value, $index)
132
    {
133
        Assert::assertEquals($value, $this->response->getResource($resourceName)[$index]->$fieldName->getValue());
134
    }
135
136
    /**
137
     * @Then I should find :count field with :fieldName matching :fieldValue in the :collection collection
138
     */
139
    public function iShouldFindFieldWithMatchingInTheCollection($fieldName, $fieldValue, $collection, $count)
140
    {
141
        $result = $this->response->$collection->findMatching([$fieldName => $fieldValue]);
142
143
        Assert::assertCount((int) $count, $result);
144
145
        $this->result = $result[0];
146
    }
147
148
    /**
149
     * @Then the field should have :name :value
150
     */
151
    public function theFieldShouldHave($name, $value)
152
    {
153
        Assert::assertEquals($value, $this->result->$name->getValue());
154
    }
155
}
156