Issues (789)

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.

app/presenters/AuthPresenter.php (4 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
namespace App\Presenters;
4
5
use Skautis;
6
use SkautisAuth;
7
use App\Services\SkautIS\AuthService;
8
use App\Services\SkautIS\UserService;
9
use Tracy\Debugger;
10
11
/**
12
 * SkautIS Auth presenters.
13
 */
14
class AuthPresenter extends BasePresenter
15
{
16
17
	/**
18
	 * @var AuthService
19
	 */
20
	protected $authService;
21
22
	/**
23
	 * @var UserService
24
	 */
25
	protected $userService;
26
27
	/**
28
	 * @var User
29
	 */
30
	protected $user;
31
32
	/**
33
	 * @param AuthService $authService
34
	 * @param UserService $userService
35
	 */
36
	public function __construct(
37
		AuthService $authService,
38
		UserService $userService
39
	) {
40
		$this->setAuthService($authService);
41
		$this->setUserService($userService);
42
	}
43
44
	/**
45
	 * @return void
46
	 */
47
	protected function startup()
48
	{
49
		parent::startup();
50
	}
51
52
	/**
53
	 * @param  string $id
54
	 * @return void
55
	 */
56
	public function actionLogin($id)
57
	{
58
		$this->{$id . 'Login'}();
59
	}
60
61
	/**
62
	 * @param  string $id
63
	 * @return void
64
	 */
65
	public function actionLogout($id)
66
	{
67
		$this->{$id . 'Logout'}();
68
	}
69
70
	/**
71
	 * @param  string $id
72
	 * @return void
73
	 */
74
	public function actionSkautis($id)
75
	{
76
		$this->{'handleSkautis' . $id}();
77
	}
78
79
	/**
80
	 * Redirects to login page
81
	 *
82
	 * @param  	string  $backlink
83
	 * @return  void
84
	 */
85
	protected function skautisLogin($backlink = null)
86
	{
87
		$this->redirectUrl($this->getAuthService()->getLoginUrl($backlink));
88
	}
89
90
	/**
91
	 * Handle log out from SkautIS
92
	 * SkautIS redirects to this action after log out
93
	 *
94
	 * @param   void
95
	 * @return  void
96
	 */
97
	protected function skautisLogout()
98
	{
99
		$this->redirectUrl($this->getAuthService()->getLogoutUrl());
100
	}
101
102
	/**
103
	 * Handle SkautIS login process
104
	 *
105
	 * @param   string  $ReturnUrl
106
	 * @return  void
107
	 */
108
	protected function handleSkautisLogin($ReturnUrl = NULL)
0 ignored issues
show
Coding Style Naming introduced by
The parameter $ReturnUrl is not named in camelCase.

This check marks parameter names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
109
	{
110
		$post = $this->getHttpRequest()->post;
0 ignored issues
show
Accessing post on the interface Nette\Http\IRequest suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
111
		//$post = $this->router->getPost();
112
		// if token is not set - get out from here - must log in
113
		if (!isset($post['skautIS_Token'])) {
114
			$this->redirect(":Login:");
115
		}
116
		//Debugger::log("AuthP: ".$post['skautIS_Token']." / ". $post['skautIS_IDRole'] . " / " . $post['skautIS_IDUnit'], "auth");
117
		try {
118
			$this->getAuthService()->setInit($post);
119
			//$this->container->getService('authService')->setInit($post);
120
121
			if (!$this->getUserService()->isLoggedIn()) {
122
			//if (!$this->container->getService('userService')->isLoggedIn()) {
123
				throw new \Skautis\Wsdl\AuthenticationException("Nemáte platné přihlášení do skautISu");
124
			}
125
			$me = $this->getUserService()->getPersonalDetail();
126
			//$me = $this->container->getService('userService')->getPersonalDetail();
127
128
			$this->getUser()->setExpiration('+ 29 minutes'); // nastavíme expiraci
129
			$this->getUser()->setAuthenticator(new SkautisAuth\SkautisAuthenticator());
130
			$this->getUser()->login($me);
131
132
			if (isset($ReturnUrl)) {
133
				$this->context->application->restoreRequest($ReturnUrl);
0 ignored issues
show
The property $context is declared private in Nette\Application\UI\Presenter. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
134
			}
135
		} catch (\Skautis\Wsdl\AuthenticationException $e) {
136
			$this->flashMessage($e->getMessage(), "danger");
137
			$this->redirect(":Auth:Login");
138
		}
139
		$this->presenter->redirect(':Registration:');
140
	}
141
142
	/**
143
	 * Log out from SkautIS
144
	 *
145
	 * @param   void
146
	 * @return  void
147
	 */
148
	protected function handleSkautisLogout()
149
	{
150
		$this->getUserService()->logout(TRUE);
0 ignored issues
show
Documentation Bug introduced by
The method logout does not exist on object<App\Services\SkautIS\UserService>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
151
		$this->getUserService()->resetLoginData();
152
		$this->presenter->flashMessage("Byl jsi úspěšně odhlášen ze SkautISu.");
153
		/*
154
		if ($this->request->post['skautIS_Logout']) {
155
			$this->presenter->flashMessage("Byl jsi úspěšně odhlášen ze SkautISu.");
156
		} else {
157
			$this->presenter->flashMessage("Odhlášení ze skautISu se nezdařilo", "danger");
158
		}
159
		*/
160
		$this->redirect(":Login:");
161
		//$this->redirectUrl($this->service->getLogoutUrl());
162
	}
163
164
	/**
165
	 * @return AuthService
166
	 */
167
	protected function getAuthService()
168
	{
169
		return $this->authService;
170
	}
171
172
	/**
173
	 * @param  AuthService $service
174
	 * @return $this
175
	 */
176
	protected function setAuthService(AuthService $service)
177
	{
178
		$this->authService = $service;
179
180
		return $this;
181
	}
182
183
	/**
184
	 * @return UserService
185
	 */
186
	protected function getUserService()
187
	{
188
		return $this->userService;
189
	}
190
191
	/**
192
	 * @param  UserService $service
193
	 * @return $this
194
	 */
195
	protected function setUserService(UserService $service)
196
	{
197
		$this->userService = $service;
198
199
		return $this;
200
	}
201
202
}
203