Issues (74)

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

Labels
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
namespace keeko\tools\command;
3
4
use keeko\framework\schema\PackageSchema;
5
use keeko\tools\helpers\IOHelper;
6
use keeko\tools\helpers\ServiceLoaderTrait;
7
use keeko\tools\services\CommandService;
8
use phootwork\lang\Text;
9
use Psr\Log\LogLevel;
10
use Symfony\Component\Console\Command\Command;
11
use Symfony\Component\Console\Input\ArrayInput;
12
use Symfony\Component\Console\Input\InputInterface;
13
use Symfony\Component\Console\Input\InputOption;
14
use Symfony\Component\Console\Logger\ConsoleLogger;
15
use Symfony\Component\Console\Output\OutputInterface;
16
use Symfony\Component\Console\Application;
17
18
abstract class AbstractKeekoCommand extends Command {
19
20
	use ServiceLoaderTrait;
21
	
22
	/** @var PackageSchema */
23
	protected $package;
24
25
	public function __construct($name = null) {
26
		parent::__construct($name);
27
	}
28
29
	/* (non-PHPdoc)
30
	 * @see \Symfony\Component\Console\Command\Command::initialize()
31
	 */
32
	protected function initialize(InputInterface $input, OutputInterface $output) {
33
		// io
34
		$io = new IOHelper();
35
		$io->setInput($input);
36
		$io->setOutput($output);
37
		$this->getHelperSet()->set($io);
38
		
39
		// logger
40
		$logger = new ConsoleLogger($output, [
41
			LogLevel::NOTICE => OutputInterface::VERBOSITY_VERBOSE,
42
			LogLevel::INFO   => OutputInterface::VERBOSITY_VERBOSE,
43
		]);
44
	
45
		// services
46
		$service = new CommandService($this, $logger);
47
		$this->loadServices($service);
48
		$this->package = $service->getPackageService()->getPackage();
49
	}
50
51
	/**
52
	 * @return CommandService
53
	 */
54
	public function getService() {
55
		// this is BULLSHIT!!
56
		// this should never be public
57
		// this is only because of the UI classes, some need access to the model service
58
		// see https://github.com/keeko/tools/issues/5 how this could be made more useful
59
		return $this->service;
60
	}
61
62
63
	protected function configure() {
64
		$this->configureGlobalOptions();
65
	}
66
67
	protected function configureGenerateOptions() {
68
		$this
69
			->addOption(
70
				'schema',
71
				's',
72
				InputOption::VALUE_OPTIONAL,
73
				'Path to the database schema (if ommited, res/database/schema.xml is used)',
74
				null
75
			)
76
			->addOption(
77
				'force',
78
				'f',
79
				InputOption::VALUE_NONE,
80
				'Forces to owerwrite'
81
			)
82
		;
83
	}
84
	
85
	protected function configureGlobalOptions() {
86
		$this
87
			->addOption(
88
				'workdir',
89
				'w',
90
				InputOption::VALUE_OPTIONAL,
91
				'Specify the working directory (if ommited, current working directory is used)',
92
				null
93
			)
94
		;
95
	}
96
	
97
	protected function runCommand($name, array $input = [], Application $app = null) {
98
		// return whether command has already executed
99
		if ($app === null) {
100
			$app = $this->getApplication();
101
		}
102
		$cmd = $app->find($name);
0 ignored issues
show
It seems like $app is not always an object, but can also be of type null. Maybe add an additional type check?

If a variable is not always an object, we recommend to add an additional type check to ensure your method call is safe:

function someFunction(A $objectMaybe = null)
{
    if ($objectMaybe instanceof A) {
        $objectMaybe->doSomething();
    }
}
Loading history...
103
104
		$input = new ArrayInput($this->sanitizeInput($input));
105
		$input->setInteractive(false);
106
		
107
		$cmd->run($input, $this->io->getOutput());
108
	}
109
	
110
	/**
111
	 * Prepares input as used for running a command
112
	 * 
113
	 * @param array $input
114
	 * @return array
115
	 */
116
	private function sanitizeInput(array $input) {
117
		// add verbose level
118
		if (!isset($input['--verbose'])) {
119
			$input['--verbose'] = $this->io->getInput()->getOption('verbose');
120
		}
121
122
		// check if at least one argument is present and if not add a blank one
123
		$hasArgs = false;
124
		foreach (array_keys($input) as $key) {
125
			if (!Text::create($key)->startsWith('--')) {
126
				$hasArgs = true;
127
			}
128
		}
129
		if (!$hasArgs) {
130
			$input[] = '';
131
		}
132
	
133
		return $input;
134
	}
135
136
}