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/Command/BaseCommand.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 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\Command;
18
19
use function Aviat\AnimeClient\loadToml;
20
21
use Aura\Session\SessionFactory;
22
use Aviat\AnimeClient\{
23
	AnimeClient,
24
	Model,
25
	Util
26
};
27
use Aviat\AnimeClient\API\{
28
	CacheTrait,
29
	Kitsu,
30
	MAL
31
};
32
use Aviat\Banker\Pool;
33
use Aviat\Ion\Config;
34
use Aviat\Ion\Di\{Container, ContainerAware};
35
use ConsoleKit\Command;
36
use ConsoleKit\Widgets\Box;
37
use Monolog\Handler\NullHandler;
38
use Monolog\Logger;
39
40
/**
41
 * Base class for console command setup
42
 */
43
class BaseCommand extends Command {
44
	use CacheTrait;
45
	use ContainerAware;
46
47
	/**
48
	 * Echo text in a box
49
	 *
50
	 * @param string $message
51
	 * @return void
52
	 */
53
	protected function echoBox($message)
54
	{
55
		echo "\n";
56
		$box = new Box($this->getConsole(), $message);
57
		$box->write();
58
		echo "\n";
59
	}
60
61
	/**
62
	 * Setup the Di container
63
	 *
64
	 * @return Container
65
	 */
66
	protected function setupContainer()
67
	{
68
		$APP_DIR = realpath(__DIR__ . '/../../app');
69
		$APPCONF_DIR = realpath("{$APP_DIR}/appConf/");
70
		$CONF_DIR = realpath("{$APP_DIR}/config/");
71
		require_once $APPCONF_DIR . '/base_config.php'; // $base_config
72
73
		$config = loadToml($CONF_DIR);
74
		$config_array = array_merge($base_config, $config);
0 ignored issues
show
The variable $base_config does not exist. Did you mean $config?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
75
76
		$di = function ($config_array) use ($APP_DIR) {
77
			$container = new Container();
78
79
			// -------------------------------------------------------------------------
80
			// Logging
81
			// -------------------------------------------------------------------------
82
83
			$app_logger = new Logger('animeclient');
84
			$app_logger->pushHandler(new NullHandler);
85
			$kitsu_request_logger = new Logger('kitsu-request');
86
			$kitsu_request_logger->pushHandler(new NullHandler);
87
			$mal_request_logger = new Logger('mal-request');
88
			$mal_request_logger->pushHandler(new NullHandler);
89
			$container->setLogger($app_logger, 'default');
90
			$container->setLogger($kitsu_request_logger, 'kitsu-request');
91
			$container->setLogger($mal_request_logger, 'mal-request');
92
93
			// Create Config Object
94
			$container->set('config', function() use ($config_array) {
95
				return new Config($config_array);
96
			});
97
98
			// Create Cache Object
99 View Code Duplication
			$container->set('cache', function($container) {
0 ignored issues
show
This code seems to be duplicated across 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...
100
				$logger = $container->getLogger();
101
				$config = $container->get('config')->get('cache');
102
				return new Pool($config, $logger);
103
			});
104
105
			// Create session Object
106
			$container->set('session', function() {
107
				return (new SessionFactory())->newInstance($_COOKIE);
108
			});
109
110
			// Models
111
			$container->set('kitsu-model', function($container) {
112
				$listItem = new Kitsu\ListItem();
113
				$listItem->setContainer($container);
114
				$model = new Kitsu\Model($listItem);
115
				$model->setContainer($container);
116
				$cache = $container->get('cache');
117
				$model->setCache($cache);
118
				return $model;
119
			});
120
			$container->set('mal-model', function($container) {
121
				$listItem = new MAL\ListItem();
122
				$listItem->setContainer($container);
123
				$model = new MAL\Model($listItem);
124
				$model->setContainer($container);
125
				return $model;
126
			});
127
			$container->set('util', function($container) {
128
				return new Util($container);
129
			});
130
131
			return $container;
132
		};
133
134
		return $di($config_array);
135
	}
136
}