Issues (65)

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/Context/AuthContext.php (1 issue)

Severity

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 Vivait\AuthBundle\Features\Context;
4
5
use Behat\Behat\Context\BehatContext;
6
use Behat\Gherkin\Node\TableNode;
7
use Doctrine\Common\Persistence\ObjectManager;
8
use Doctrine\ORM\EntityRepository;
9
use Vivait\AuthBundle\Entity\Tenant;
10
use Vivait\AuthBundle\Entity\User;
11
use Vivait\AuthBundle\Entity\UserRepository;
12
use Behat\Symfony2Extension\Context\KernelDictionary;
13
use Behat\Behat\Context\Step;
14
use Vivait\BehatAliceLoader\AliceContext;
15
16
class AuthContext extends BehatContext {
17
	use KernelDictionary;
18
19
	protected $current_user;
20
	protected $users = array();
21
22
	/**
23
	 * Gets current_user
24
	 * @return mixed
25
	 */
26
	public function getCurrentUser() {
27
		return $this->current_user;
28
	}
29
30
	/**
31
	 * Gets users
32
	 * @return array
33
	 */
34
	public function getUsers() {
35
		return $this->users;
36
	}
37
38
	/**
39
	 * Sets users
40
	 *
41
	 * @param array $users
42
	 *
43
	 * @return $this
44
	 */
45
	public function setUsers( $users ) {
46
		$this->users = $users;
47
48
		return $this;
49
	}
50
51
	/**
52
	 * @return ObjectManager|object
53
	 */
54
	protected function getManager()
55
	{
56
		$container = $this->getContainer();
57
		$em        = $container->get('doctrine')->getManager();
58
		return $em;
59
	}
60
61
	/**
62
	 * @param $username
63
	 */
64
	protected function getUserPassword($username) {
0 ignored issues
show
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
65
		if (!isset($this->users[$username]['password'])) {
66
			throw new \OutOfBoundsException('Invalid user '. $username);
67
		}
68
69
		return $this->users[ $username ]['password'];
70
	}
71
72
	/**
73
	 * @Given /^I am authenticated as "([^"]*)"$/
74
	 * @Given /^I am authenticated as "([^"]*)" using "([^"]*)"$/
75
	 */
76
	public function iAmAuthenticatedAs($username, $password = null) {
77
		if ($password === null) {
78
			$password = $this->getUserPassword($username);
79
		}
80
81
		$container = $this->getContainer();
82
		$em = $container->get('doctrine')->getManager();
83
		$this->current_user = $em
84
			->getRepository('VivaitAuthBundle:User')
85
			->findOneBy([
86
				'username' => $username
87
			]);
88
89
		return array(
90
			new Step\Given('I am on "/login"'),
91
			new Step\When('I fill in "_username" with "'. $username .'"'),
92
			new Step\When('I fill in "_password" with "'. $password .'"'),
93
			new Step\When('I press "Sign in"'),
94
			new Step\Then('I should not see "Login Failed"'),
95
		);
96
	}
97
98
	/**
99
	 * @Given /^there are the following users:$/
100
	 */
101
	public function thereAreTheFollowingUsers(TableNode $table) {
102
		foreach ($table->getHash() as $row) {
103
			$this->users[$row['username']] = $row;
104
		}
105
106
		/* @var $alice AliceContext */
107
		$alice = $this->getMainContext()->getSubcontextByClassName('Vivait\BehatAliceLoader\AliceContext');
108
109
		if ($alice) {
110
			/* @var $users User[] */
111
			$users = $alice->thereAreTheFollowing('VivaitAuthBundle:User', $table);
112
113
			foreach ($users as $user) {
114
				$user->hashPassword($this->getContainer()->get('security.encoder_factory'));
115
116
				if (!$user->getTenants()->count()) {
117
					$tenant = $this->getManager()->getRepository('VivaitAuthBundle:Tenant')->findDefaultTenant();
118
					$tenant->addUser( $user );
119
					$this->getManager()->persist( $tenant );
120
				}
121
122
				$this->getManager()->persist( $user );
123
			}
124
125
			$this->getManager()->flush();
126
		}
127
	}
128
129
	/**
130
	 * @return UserRepository
131
	 */
132
	protected function getUserRepository()
133
	{
134
		$em = $this->getManager();
135
		return $em->getRepository('VivaitAuthBundle:User');
136
	}
137
138
	/**
139
	 * @return EntityRepository
140
	 */
141
	protected function getGroupRepository()
142
	{
143
		$em = $this->getManager();
144
		return $em->getRepository('VivaitAuthBundle:Group');
145
	}
146
147
	/**
148
	 * @return EntityRepository
149
	 */
150
	protected function getTenantRepository()
151
	{
152
		$em = $this->getManager();
153
		return $em->getRepository('VivaitAuthBundle:Tenant');
154
	}
155
156
}