Issues (164)

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.

Controller/RunningBalanceCliController.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 JhFlexiTime\Controller;
4
5
use JhFlexiTime\Service\RunningBalanceService;
6
use Zend\Mvc\Controller\AbstractActionController;
7
use Zend\Console\Request as ConsoleRequest;
8
use Doctrine\Common\Persistence\ObjectManager;
9
use JhUser\Repository\UserRepositoryInterface;
10
use JhUser\Repository\RoleRepositoryInterface;
11
use Zend\Console\Adapter\AdapterInterface;
12
use Zend\Console\ColorInterface;
13
14
/**
15
 * Class RoleController
16
 * @package JhUser\Controller
17
 * @author Aydin Hassan <[email protected]>
18
 */
19
class RunningBalanceCliController extends AbstractActionController
20
{
21
    /**
22
     * @var \JhUser\Repository\UserRepositoryInterface
23
     */
24
    protected $userRepository;
25
26
    /**
27
     * @var \JhFlexiTime\Service\RunningBalanceService
28
     */
29
    protected $runningBalanceService;
30
31
    /**
32
     * @param UserRepositoryInterface $userRepository
33
     * @param RunningBalanceService $runningBalanceService
34
     * @param AdapterInterface $console
35
     */
36
    public function __construct(
37
        UserRepositoryInterface $userRepository,
38
        RunningBalanceService $runningBalanceService,
39
        AdapterInterface $console
40
    ) {
41
        $this->userRepository           = $userRepository;
42
        $this->runningBalanceService    = $runningBalanceService;
43
        $this->console                  = $console;
0 ignored issues
show
The property console does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
44
    }
45
46
    /**
47
     * Recaulculate running balance,
48
     * for either a single user or all users
49
     *
50
     * @throws \RuntimeException
51
     */
52
    public function reCalcRunningBalanceAction()
53
    {
54
        $request    = $this->getRequest();
55
        $email      = $request->getParam('userEmail');
56
57
        if ($email) {
58
            $user = $this->userRepository->findOneByEmail($email);
59
60
            if (!$user) {
61
                throw new \RuntimeException(sprintf('User with email: "%s" could not be found', $email));
62
            }
63
64
            $this->console->writeLine("Recalculating Running Balance for $email", ColorInterface::GREEN);
65
            $this->runningBalanceService->reIndexIndividualUserRunningBalance($user);
66
        } else {
67
            $this->console->writeLine("Recalculating Running Balance for all Users", ColorInterface::GREEN);
68
            $this->runningBalanceService->reIndexAllUsersRunningBalance();
69
70
        }
71
72
        $this->console->writeLine("Finished! ", ColorInterface::GREEN);
73
    }
74
75
    /**
76
     * Calculate the balance for the previous month,
77
     * for each user, and add it on to their running balance
78
     */
79
    public function calcPrevMonthBalanceAction()
80
    {
81
        $this->console->writeLine(
82
            "Calculating Running Balance for all Users for previous month",
83
            ColorInterface::GREEN
84
        );
85
        $this->runningBalanceService->indexPreviousMonthBalance();
86
        $this->console->writeLine("Finished! ", ColorInterface::GREEN);
87
    }
88
89
    /**
90
     * Set a Users Initial Balance
91
     * + then recalculate their running balance
92
     *
93
     * @throws \RuntimeException
94
     */
95
    public function setUserStartingBalanceAction()
96
    {
97
        $request    = $this->getRequest();
98
        $balance    = $request->getParam('balance');
99
        $email      = $request->getParam('userEmail');
100
101
        $user = $this->userRepository->findOneByEmail($email);
102
103
        if (!$user) {
104
            throw new \RuntimeException(sprintf('User with email: "%s" could not be found', $email));
105
        }
106
107
        $this->runningBalanceService->setUserStartingBalance($user, $balance);
108
        //recalculate balance
109
        $this->runningBalanceService->reIndexIndividualUserRunningBalance($user);
110
        $this->console->writeLine(
111
            sprintf("Successfully set User '%s' balance to '%s'! ", $email, $balance),
112
            ColorInterface::GREEN
113
        );
114
115
    }
116
}
117