Issues (2)

Security Analysis    no request data  

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/Tasks/Tasks.php (2 issues)

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
/**
3
 * Scabbia2 Tasks Component
4
 * https://github.com/eserozvataf/scabbia2
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 *
9
 * @link        https://github.com/eserozvataf/scabbia2-tasks for the canonical source repository
10
 * @copyright   2010-2016 Eser Ozvataf. (http://eser.ozvataf.com/)
11
 * @license     http://www.apache.org/licenses/LICENSE-2.0 - Apache License, Version 2.0
12
 */
13
14
namespace Scabbia\Tasks;
15
16
use Scabbia\Formatters\FormatterInterface;
17
use Scabbia\Formatters\Formatters;
18
use Scabbia\Tasks\TaskBase;
19
20
/**
21
 * A small command line implementation which helps us during the development of
22
 * Scabbia2 PHP Framework's itself and related production code
23
 *
24
 * @package     Scabbia\Tasks
25
 * @author      Eser Ozvataf <[email protected]>
26
 * @since       2.0.0
27
 */
28
class Tasks
29
{
30
    /** @type string base class */
31
    const BASE_CLASS = "\\Scabbia\\Tasks\\TaskBase";
32
33
34
    /** @type array  task namespaces */
35
    public static $namespaces = [
36
        "Scabbia"
37
    ];
38
39
40
    /**
41
     * Resolves given task name into class name
42
     *
43
     * @param string $uTask task name
44
     *
45
     * @return string resolved class name
46
     */
47
    public static function taskClassName($uTask)
48
    {
49
        $tOutput = "\\";
50
        $tCapital = true;
51
52
        for ($tPos = 0, $tLen = strlen($uTask); $tPos < $tLen; $tPos++) {
53
            $tChar = $uTask[$tPos];
54
55
            if ($tChar === ":") {
56
                $tOutput .= "\\";
57
                $tCapital = true;
58
                continue;
59
            }
60
61
            if ($tCapital) {
62
                $tOutput .= strtoupper($tChar);
63
                $tCapital = false;
64
                continue;
65
            }
66
67
            $tOutput .= $tChar;
68
        }
69
70
        $tClassName = "{$tOutput}Task";
71
        if (is_subclass_of($tClassName, self::BASE_CLASS)) {
0 ignored issues
show
Due to PHP Bug #53727, is_subclass_of might return inconsistent results on some PHP versions if self::BASE_CLASS can be an interface. If so, you could instead use ReflectionClass::implementsInterface.
Loading history...
72
            return $tClassName;
73
        }
74
75
        foreach (self::$namespaces as $tNamespace) {
76
            $tClassName = "\\{$tNamespace}{$tOutput}Task";
77
78
            if (is_subclass_of($tClassName, self::BASE_CLASS)) {
0 ignored issues
show
Due to PHP Bug #53727, is_subclass_of might return inconsistent results on some PHP versions if self::BASE_CLASS can be an interface. If so, you could instead use ReflectionClass::implementsInterface.
Loading history...
79
                return $tClassName;
80
            }
81
        }
82
83
        return null;
84
    }
85
86
    /**
87
     * Runs given task
88
     *
89
     * @param string             $uTask        name of the task
90
     * @param array              $uParameters  set of parameters
91
     * @param FormatterInterface $uFormatter   formatter class
92
     *
93
     * @return int exit code
94
     */
95
    public static function run($uTask, array $uParameters, $uFormatter = null)
96
    {
97
        if ($uFormatter === null) {
98
            $uFormatter = Formatters::getCurrent();
99
        }
100
101
        if ($tHelpCommand = ($uTask === "help")) {
102
            $uTask = array_shift($uParameters);
103
        }
104
105
        if ($uTask === null) {
106
            $uFormatter->write("Please specify a task");
107
            return 1;
108
        }
109
110
        $tClassName = self::taskClassName($uTask);
111
        if ($tClassName === null) {
112
            $uFormatter->write(sprintf("Task not found - %s", $uTask));
113
            return 1;
114
        }
115
116
        try {
117
            $tInstance = new $tClassName ();
118
            if ($tHelpCommand) {
119
                $tInstance->help($uFormatter);
120
                return 0;
121
            }
122
123
            return $tInstance->executeTask($uParameters, $uFormatter);
124
        } catch (\Exception $ex) {
125
            $uFormatter->write(sprintf("%s: %s", get_class($ex), $ex->getMessage()));
126
            return 1;
127
        }
128
    }
129
}
130