Issues (195)

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.

Alpha/Task/CronManager.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
3
namespace Alpha\Task;
4
5
require_once './vendor/autoload.php';
6
7
use Alpha\Util\Logging\Logger;
8
use Alpha\Util\Config\ConfigProvider;
9
10
/**
11
 * The main class responsible for running custom cron tasks found under the [webapp]/Task
12
 * directory.  This class should be executed from Linux cron via the CLI.
13
 *
14
 * To run: cd to app.root, then "php vendor/alphadevx/alpha/Alpha/Task/CronManager.php"
15
 *
16
 * @since 1.0
17
 *
18
 * @author John Collins <[email protected]>
19
 * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
20
 * @copyright Copyright (c) 2019, John Collins (founder of Alpha Framework).
21
 * All rights reserved.
22
 *
23
 * <pre>
24
 * Redistribution and use in source and binary forms, with or
25
 * without modification, are permitted provided that the
26
 * following conditions are met:
27
 *
28
 * * Redistributions of source code must retain the above
29
 *   copyright notice, this list of conditions and the
30
 *   following disclaimer.
31
 * * Redistributions in binary form must reproduce the above
32
 *   copyright notice, this list of conditions and the
33
 *   following disclaimer in the documentation and/or other
34
 *   materials provided with the distribution.
35
 * * Neither the name of the Alpha Framework nor the names
36
 *   of its contributors may be used to endorse or promote
37
 *   products derived from this software without specific
38
 *   prior written permission.
39
 *
40
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
41
 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
42
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
43
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
44
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
45
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
46
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
47
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
48
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
49
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
50
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
51
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
52
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53
 * </pre>
54
 */
55
class CronManager
56
{
57
    /**
58
     * Trace logger.
59
     *
60
     * @var \Alpha\Util\Logging\Logger
61
     *
62
     * @since 1.0
63
     */
64
    private static $logger = null;
65
66
    /**
67
     * Constructor.
68
     *
69
     * @since 1.0
70
     */
71
    public function __construct()
72
    {
73
        $config = ConfigProvider::getInstance();
74
75
        self::$logger = new Logger('CronManager');
76
        self::$logger->setLogProviderFile($config->get('app.file.store.dir').'logs/tasks.log');
77
78
        self::$logger->debug('>>__construct()');
79
80
        self::$logger->info('New CronManager invoked');
81
82
        $taskList = self::getTaskClassNames();
83
84
        self::$logger->info('Found ['.count($taskList).'] tasks in the directory ['.$config->get('app.root').'src/Task]');
85
86
        foreach ($taskList as $taskClass) {
87
            $taskClass = $taskClass;
0 ignored issues
show
Why assign $taskClass to itself?

This checks looks for cases where a variable has been assigned to itself.

This assignement can be removed without consequences.

Loading history...
88
            self::$logger->info('Loading task ['.$taskClass.']');
89
            $task = new $taskClass();
90
91
            $startTime = microtime(true);
92
93
            self::$logger->info('Start time is ['.$startTime.'], maximum task run time is ['.$task->getMaxRunTime().']');
94
95
            // only continue to execute for the task max time
96
            set_time_limit($task->getMaxRunTime());
97
            $task->doTask();
98
99
            self::$logger->info('Done in ['.round(microtime(true)-$startTime, 5).'] seconds');
100
        }
101
102
        self::$logger->info('Finished processing all cron tasks');
103
104
        self::$logger->debug('<<__construct');
105
    }
106
107
    /**
108
     * Loops over the /tasks directory and builds an array of all of the task
109
     * class names in the system.
110
     *
111
     * @return array
112
     *
113
     * @since 1.0
114
     */
115
    public static function getTaskClassNames()
116
    {
117
        $config = ConfigProvider::getInstance();
118
119
        if (self::$logger == null) {
120
            self::$logger = new Logger('CronManager');
121
            self::$logger->setLogProviderFile($config->get('app.file.store.dir').'logs/tasks.log');
122
        }
123
        self::$logger->info('>>getTaskClassNames()');
124
125
        $classNameArray = array();
126
127
        if (file_exists($config->get('app.root').'src/Task')) {
128
            $handle = opendir($config->get('app.root').'src/Task');
129
130
            // loop over the custom task directory
131
            while (false !== ($file = readdir($handle))) {
132
                if (preg_match('/Task.php/', $file)) {
133
                    $classname = 'Task\\'.mb_substr($file, 0, -4);
134
135
                    array_push($classNameArray, $classname);
136
                }
137
            }
138
        }
139
140
        self::$logger->info('<<getTaskClassNames ['.var_export($classNameArray, true).']');
141
142
        return $classNameArray;
143
    }
144
}
145
146
// invoke a cron manager object
147
$processor = new CronManager();
148