Issues (7)

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.

features/bootstrap/FeatureContext.php (2 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
declare(strict_types = 1);
4
5
use Behat\Behat\Context\Context;
6
use Behat\Gherkin\Node\PyStringNode;
7
use Behat\Gherkin\Node\TableNode;
8
use Behat\Behat\Tester\Exception\PendingException;
9
use iio\libmergepdf\Merger;
10
use iio\libmergepdf\Pages;
11
use Smalot\PdfParser\Parser as PdfParser;
12
13
final class FeatureContext implements Context
14
{
15
    /** @var Merger */
16
    private $merger;
17
18
    /** @var string */
19
    private $generatedPdf = '';
20
21
    /** @var ?\Exception */
22
    private $mergeException;
23
24
    public function __construct(string $driverName)
25
    {
26
        $driverClass = "iio\libmergepdf\Driver\\$driverName";
27
28
        /** @var \iio\libmergepdf\Driver\DriverInterface $driver */
29
        $driver = new $driverClass;
30
31
        $this->merger = new Merger($driver);
32
    }
33
34
    /**
35
     * @Given the :driver driver
36
     */
37
    public function theDriver(string $driver)
38
    {
39
        $driverClass = "iio\libmergepdf\Driver\\$driver";
40
        $this->merger = new Merger(new $driverClass);
41
    }
42
43
    /**
44
     * @Given a pdf
45
     */
46
    public function aPdf()
47
    {
48
        $this->aPdfOfVersion('1.4');
49
    }
50
51
    /**
52
     * @Given a pdf with pages :pages
53
     */
54
    public function aPdfWithPages($pages)
55
    {
56
        $this->aPdfOfVersionWithPages('1.4', $pages);
57
    }
58
59
    /**
60
     * @Given a pdf of version :version
61
     */
62
    public function aPdfOfVersion(string $version)
63
    {
64
        $this->aPdfOfVersionWithPages($version, '');
65
    }
66
67
    /**
68
     * @Given a pdf of version :version with pages :pages
69
     */
70
    public function aPdfOfVersionWithPages(string $version, string $pages)
71
    {
72
        $this->merger->addFile(__DIR__ . "/../files/$version.pdf", new Pages($pages));
73
    }
74
75
    /**
76
     * @Given a pdf with a header including text HEADER
77
     */
78
    public function aPdfWithAHeaderIncludingTextHeader()
79
    {
80
        $this->merger->addFile(__DIR__ . "/../files/header.pdf");
81
    }
82
83
    /**
84
     * @Given a blank pdf
85
     */
86
    public function aBlankPdf()
87
    {
88
        $this->merger->addFile(__DIR__ . "/../files/blank.pdf");
89
    }
90
91
    /**
92
     * @When I merge
93
     */
94
    public function iMerge()
95
    {
96
        try {
97
            $this->generatedPdf = $this->merger->merge();
98
            $this->mergeException = null;
99
        } catch (\Exception $e) {
100
            $this->mergeException = $e;
101
        }
102
    }
103
104
    /**
105
     * @Then there is no error
106
     */
107
    public function thereIsNoError()
108
    {
109
        if ($this->mergeException) {
110
            throw $this->mergeException;
111
        }
112
    }
113
114
    /**
115
     * @Then there is an error
116
     */
117
    public function thereIsAnError()
118
    {
119
        if (!$this->mergeException) {
120
            throw new \Exception('Expecting error during merge');
121
        }
122
    }
123
124
    /**
125
     * @Then a pdf is generated
126
     */
127
    public function aPdfIsGenerated()
128
    {
129
        $this->thereIsNoError();
130
        (new PdfParser)->parseContent($this->generatedPdf);
131
    }
132
133
    /**
134
     * @Then a pdf with :expectedCount pages is generated
135
     */
136
    public function aPdfWithPagesIsGenerated(string $expectedCount)
137
    {
138
        $this->thereIsNoError();
139
140
        $pageCount = @count((new PdfParser)->parseContent($this->generatedPdf)->getPages());
141
142
        if ($pageCount != $expectedCount) {
143
            throw new Exception("A pdf with $pageCount pages was created, expected $expectedCount pages.");
144
        }
145
    }
146
147
    /**
148
     * @Then a pdf including text :expectedText is generated
149
     */
150 View Code Duplication
    public function aPdfIncludingTextIsGenerated(string $expectedText)
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...
151
    {
152
        $this->thereIsNoError();
153
154
        $text = @(new PdfParser)->parseContent($this->generatedPdf)->getText();
155
156
        $regexp = preg_quote($expectedText, '/');
157
158
        if (!preg_match("/$regexp/", $text)) {
159
            throw new Exception("A pdf with text '$text' was created, expected '$expectedText'.");
160
        }
161
    }
162
163
    /**
164
     * @Then a pdf not including text :unexpectedText is generated
165
     */
166 View Code Duplication
    public function aPdfNotIncludingTextIsGenerated(string $unexpectedText)
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...
167
    {
168
        $this->thereIsNoError();
169
170
        $text = @(new PdfParser)->parseContent($this->generatedPdf)->getText();
171
172
        $regexp = preg_quote($unexpectedText, '/');
173
174
        if (preg_match("/$regexp/", $text)) {
175
            throw new Exception("A pdf with unexpected text '$unexpectedText' was created.");
176
        }
177
    }
178
}
179