Issues (287)

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.

src/API/Kitsu/Auth.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 declare(strict_types=1);
2
/**
3
 * Anime List Client
4
 *
5
 * An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
6
 *
7
 * PHP version 7
8
 *
9
 * @package     AnimeListClient
10
 * @author      Timothy J. Warren <[email protected]>
11
 * @copyright   2015 - 2017  Timothy J. Warren
12
 * @license     http://www.opensource.org/licenses/mit-license.html  MIT License
13
 * @version     4.0
14
 * @link        https://github.com/timw4mail/HummingBirdAnimeClient
15
 */
16
17
namespace Aviat\AnimeClient\API\Kitsu;
18
19
use const Aviat\AnimeClient\SESSION_SEGMENT;
20
21
use Aviat\AnimeClient\AnimeClient;
22
use Aviat\AnimeClient\API\{
23
	CacheTrait,
24
	Kitsu as K
25
};
26
use Aviat\Ion\Di\{ContainerAware, ContainerInterface};
27
use Exception;
28
29
/**
30
 * Kitsu API Authentication
31
 */
32
class Auth {
33
	use CacheTrait;
34
	use ContainerAware;
35
36
	/**
37
	 * Anime API Model
38
	 *
39
	 * @var \Aviat\AnimeClient\API\Kitsu\Model
40
	 */
41
	protected $model;
42
43
	/**
44
	 * Session object
45
	 *
46
	 * @var Aura\Session\Segment
47
	 */
48
	protected $segment;
49
50
	/**
51
	 * Constructor
52
	 *
53
	 * @param ContainerInterface $container
0 ignored issues
show
Should the type for parameter $container not be \Aviat\Ion\Di\ContainerInterface?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
54
	 */
55
	public function __construct(ContainerInterface $container)
56
	{
57
		$this->setContainer($container);
58
		$this->setCache($container->get('cache'));
59
		$this->segment = $container->get('session')
60
			->getSegment(SESSION_SEGMENT);
61
		$this->model = $container->get('kitsu-model');
62
	}
63
64
	/**
65
	 * Make the appropriate authentication call,
66
	 * and save the resulting auth token if successful
67
	 *
68
	 * @param  string $password
69
	 * @return boolean
70
	 */
71
	public function authenticate($password)
72
	{
73
		$config = $this->container->get('config');
74
		$username = $config->get(['kitsu_username']);
75
76
		try
77
		{
78
			$auth = $this->model->authenticate($username, $password);
79
		}
80
		catch (Exception $e)
81
		{
82
			return FALSE;
83
		}
84
85
86
		if (FALSE !== $auth)
87
		{
88
			// Set the token in the cache for command line operations
89
			$cacheItem = $this->cache->getItem(K::AUTH_TOKEN_CACHE_KEY);
90
			$cacheItem->set($auth['access_token']);
91
			$cacheItem->save();
92
93
			$this->segment->set('auth_token', $auth['access_token']);
94
			return TRUE;
95
		}
96
97
		return FALSE;
98
	}
99
100
	/**
101
	 * Check whether the current user is authenticated
102
	 *
103
	 * @return boolean
104
	 */
105
	public function is_authenticated()
106
	{
107
		return ($this->get_auth_token() !== FALSE);
108
	}
109
110
	/**
111
	 * Clear authentication values
112
	 *
113
	 * @return void
114
	 */
115
	public function logout()
116
	{
117
		$this->segment->clear();
118
	}
119
120
	/**
121
	 * Retrieve the authentication token from the session
122
	 *
123
	 * @return string|false
124
	 */
125
	public function get_auth_token()
126
	{
127
		return $this->segment->get('auth_token', FALSE);
128
	}
129
}
130
// End of KitsuAuth.php