Issues (9)

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/ProxyFeatureContext.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
use Behat\Behat\Context\Context;
4
use Behat\Behat\Context\SnippetAcceptingContext;
5
use Behat\Gherkin\Node\PyStringNode;
6
use Behat\Gherkin\Node\TableNode;
7
use Symfony\Component\Process\PhpExecutableFinder;
8
use Symfony\Component\Process\Process;
9
10
class ProxyFeatureContext implements Context, SnippetAcceptingContext {
0 ignored issues
show
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...
11
12
	private $phpBin = '';
13
	private $process;
14
	private $workingDir = '';
15
16
17
18
	/**
19
	 * Initializes context.
20
	 */
21
	public function __construct() {
22
23
	}
24
25
26
27
	/**
28
	 * Cleans test folders in the temporary directory.
29
	 *
30
	 * @BeforeSuite
31
	 * @AfterSuite
32
	 */
33
	public static function cleanTestFolders() {
34
		if (is_dir($dir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'behat')) {
35
			self::clearDirectory($dir);
36
		}
37
	}
38
39
	/**
40
	 * Prepares test folders in the temporary directory.
41
	 *
42
	 * @BeforeScenario
43
	 */
44
	public function prepareTestFolders() {
45
		$dir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'behat' . DIRECTORY_SEPARATOR . md5(microtime() * rand(0, 10000));
46
47
		mkdir($dir . '/features/bootstrap/i18n', 0777, true);
48
49
		$phpFinder = new PhpExecutableFinder();
50
		if (false === $php = $phpFinder->find()) {
51
			throw new \RuntimeException('Unable to find the PHP executable.');
52
		}
53
		$this->workingDir = $dir;
54
		$this->phpBin = $php;
55
		$this->process = new Process(null);
56
	}
57
58
59
60
	/**
61
	 * @Given /^(?:there is )?a file named "([^"]*)" with:$/
62
	 */
63
	public function aFileNamedWith($filename, PyStringNode $content) {
64
		$content = strtr((string) $content, array("'''" => '"""'));
65
		$this->createFile($this->workingDir . '/' . $filename, $content);
66
	}
67
68
	/**
69
	 * Runs behat command with provided parameters
70
	 *
71
	 * @When /^I run "behat(?: ((?:\"|[^"])*))?"$/
72
	 * @When /^I run behat$/
73
	 *
74
	 * @param   string $argumentsString
75
	 */
76
	public function iRunBehat($argumentsString = '') {
77
		$argumentsString = strtr($argumentsString, array('\'' => '"'));
78
79
		$this->process->setWorkingDirectory($this->workingDir);
80
		$command = sprintf(
81
			'%s %s %s %s',
82
			$this->phpBin,
83
			escapeshellarg(BEHAT_BIN_PATH),
84
			$argumentsString,
85
			strtr('--no-colors --no-snippets --strict --format=progress --format-settings=\'{"timer": false}\'', array(
86
				'\'' => '"',
87
				'"' => '\"',
88
			))
89
		);
90
		$this->process->setCommandLine($command);
91
92
		// Don't reset the LANG variable on HHVM, because it breaks HHVM itself
93
		if (!defined('HHVM_VERSION')) {
94
			$env = $this->process->getEnv();
95
			$env['LANG'] = 'en'; // Ensures that the default language is en, whatever the OS locale is.
96
			$this->process->setEnv($env);
97
		}
98
99
		$this->process->start();
100
		$this->process->wait();
101
	}
102
103
	/**
104
	 * @Then /^it should (pass|fail) with:$/
105
	 */
106
	public function itShouldPassWith($shouldPassFail, PyStringNode $string) {
107
		$shouldPass = $shouldPassFail == 'pass';
108
		$passed = $this->getExitCode() === 0;
109
110
		$output = trim($this->getOutput());
111
112
		$did = $passed ? 'passed' : 'failed';
113
		$should = $shouldPass ? 'pass' : 'fail';
114
115
		if ($this->getExitCode() == (int) $shouldPass) {
116
			echo $output;
117
			throw new \Exception("Scenario $did, but should $should");
118
		}
119
120
		if ($this->cleanOutput($output) != $this->cleanOutput($string)) {
121
			echo $output;
122
			throw new \Exception("Scenario $did, but with wrong output");
123
		}
124
	}
125
126
127
128
	/**
129
	 *
130
	 */
131
	protected function cleanOutput($output) {
132
		return preg_replace('#([\r\n]+)[ \t]+#', '$1', trim($output));
133
	}
134
135
	/**
136
	 *
137
	 */
138
	private function getOutput() {
139
		$output = $this->process->getErrorOutput() . $this->process->getOutput();
140
141
		// Normalize the line endings in the output
142
		if ("\n" !== PHP_EOL) {
143
			$output = str_replace(PHP_EOL, "\n", $output);
144
		}
145
146
		// Replace wrong warning message of HHVM
147
		$output = str_replace('Notice: Undefined index: ', 'Notice: Undefined offset: ', $output);
148
149
		return trim(preg_replace("/ +$/m", '', $output));
150
	}
151
152
	/**
153
	 *
154
	 */
155
	private function getExitCode() {
156
		return $this->process->getExitCode();
157
	}
158
159
	/**
160
	 *
161
	 */
162
	private function createFile($filename, $content) {
163
		$path = dirname($filename);
164
		if (!is_dir($path)) {
165
			mkdir($path, 0777, true);
166
		}
167
168
		file_put_contents($filename, $content);
169
	}
170
171
	/**
172
	 *
173
	 */
174
	private static function clearDirectory($path) {
175
		$files = scandir($path);
176
		array_shift($files);
177
		array_shift($files);
178
179
		foreach ($files as $file) {
180
			$file = $path . DIRECTORY_SEPARATOR . $file;
181
			if (is_dir($file)) {
182
				self::clearDirectory($file);
183
			} else {
184
				unlink($file);
185
			}
186
		}
187
188
		rmdir($path);
189
	}
190
191
}
192