Issues (19)

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/DashboardController.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
2
3
namespace FOA\CronBundle\Controller;
4
5
use Symfony\Component\HttpFoundation\Response;
6
use FOA\CronBundle\Form\Type\CronType;
7
use FOA\CronBundle\Manager\Cron;
8
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
9
use Oro\Bundle\SecurityBundle\Annotation\AclAncestor;
10
use Symfony\Component\HttpFoundation\Request;
11
use Symfony\Component\HttpFoundation\RedirectResponse;
12
13
/**
14
 * Display dashboard and manage CRUD operations
15
 * @author Novikov Viktor
16
 */
17
class DashboardController extends Controller
18
{
19
    /**
20
     * Displays the current crontab and a form to add a new one.
21
     *
22
     * @AclAncestor("foa_cron_management_index")
23
     *
24
     * @return \Symfony\Component\HttpFoundation\Response
25
     */
26
    public function indexAction()
27
    {
28
        $cronManager = $this->get('foa.cron_bundle.cron_manager');
29
        $this->addFlash('message', $cronManager->getOutput());
30
        $this->addFlash('error', $cronManager->getError());
31
32
        $form = $this->createForm(new CronType(), new Cron());
33
34
        return $this->render('FOACronBundle:Dashboard:index.html.twig', [
35
            'crons' => $cronManager->getCrons(),
36
            'raw'   => $cronManager->getRaw(),
37
            'form'  => $form->createView(),
38
        ]);
39
    }
40
41
    /**
42
     * Add a cron to the cron table
43
     *
44
     * @param Request $request
45
     *
46
     * @return RedirectResponse|Response
47
     */
48 View Code Duplication
    public function addAction(Request $request)
0 ignored issues
show
This method seems to be duplicated in 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...
49
    {
50
        $cronManager = $this->get('foa.cron_bundle.cron_manager');
51
        $cron = new Cron();
52
        $this->addFlash('message', $cronManager->getOutput());
53
        $this->addFlash('error', $cronManager->getError());
54
        $form = $this->createForm(new CronType(), $cron);
55
56
        $form->handleRequest($request);
57
        if ($form->isValid()) {
58
            $cronManager->add($cron);
59
            $this->addFlash('message', $cronManager->getOutput());
60
            $this->addFlash('error', $cronManager->getError());
61
62
            return $this->redirect($this->generateUrl('foa_cron_index'));
63
        }
64
65
        return $this->render('FOACronBundle:Dashboard:index.html.twig', [
66
            'crons' => $cronManager->getCrons(),
67
            'raw'   => $cronManager->getRaw(),
68
            'form'  => $form->createView(),
69
        ]);
70
    }
71
72
    /**
73
     * Edit a cron
74
     *
75
     * @param $id - the line of the cron in the cron table
76
     *
77
     * @return RedirectResponse|Response
78
     */
79 View Code Duplication
    public function editAction($id)
0 ignored issues
show
This method seems to be duplicated in 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...
80
    {
81
        $cronManager = $this->get('foa.cron_bundle.cron_manager');
82
        $this->addFlash('message', $cronManager->getOutput());
83
        $this->addFlash('error', $cronManager->getError());
84
        $cron = $cronManager->getById($id);
85
        $form = $this->createForm(new CronType(), $cron);
86
87
        $request = $this->get('request');
88
        $form->handleRequest($request);
89
        if ($form->isValid()) {
90
            $cronManager->write();
91
92
            $this->addFlash('message', $cronManager->getOutput());
93
            $this->addFlash('error', $cronManager->getError());
94
95
            return $this->redirect($this->generateUrl('foa_cron_index'));
96
        }
97
98
        return $this->render('FOACronBundle:Dashboard:edit.html.twig', [
99
            'id'   => $id,
100
            'form' => $form->createView(),
101
        ]);
102
    }
103
104
    /**
105
     * Wake up a cron from the cron table
106
     *
107
     * @param $id - the line of the cron in the cron table
108
     *
109
     * @return RedirectResponse
110
     */
111
    public function wakeupAction($id)
112
    {
113
        $this->suspendTask($id, false);
114
115
        return $this->redirect($this->generateUrl('foa_cron_index'));
116
    }
117
118
    /**
119
     * Suspend a cron from the cron table
120
     *
121
     * @param $id - the line of the cron in the cron table
122
     *
123
     * @return RedirectResponse
124
     */
125
    public function suspendAction($id)
126
    {
127
        $this->suspendTask($id, true);
128
129
        return $this->redirect($this->generateUrl('foa_cron_index'));
130
    }
131
132
    /**
133
     * Suspend a task from the cron table
134
     *
135
     * @param int $id - the line of the cron in the cron table
136
     * @param bool $state
137
     */
138
    protected function suspendTask($id, $state)
139
    {
140
        $cronManager = $this->get('foa.cron_bundle.cron_manager');
141
        $this->addFlash('message', $cronManager->getOutput());
142
        $this->addFlash('error', $cronManager->getError());
143
144
        $cron = $cronManager->getById($id);
145
        $cron->setSuspended($state);
146
147
        $cronManager->write();
148
        $this->addFlash('message', $cronManager->getOutput());
149
        $this->addFlash('error', $cronManager->getError());
150
    }
151
152
    /**
153
     * Remove a cron from the cron table
154
     *
155
     * @param $id - the line of the cron in the cron table
156
     *
157
     * @return RedirectResponse
158
     */
159
    public function removeAction($id)
160
    {
161
        $cronManager = $this->get('foa.cron_bundle.cron_manager');
162
        $this->addFlash('message', $cronManager->getOutput());
163
        $this->addFlash('error', $cronManager->getError());
164
        $cronManager->remove($id);
165
        $this->addFlash('message', $cronManager->getOutput());
166
        $this->addFlash('error', $cronManager->getError());
167
168
        return $this->redirect($this->generateUrl('foa_cron_index'));
169
    }
170
171
    /**
172
     * Adds a flash to the flash bag where flashes are array of messages
173
     *
174
     * @param $type
175
     * @param $message
176
     */
177
    protected function addFlash($type, $message)
178
    {
179
        if (empty($message)) {
180
            return;
181
        }
182
183
        $session = $this->get('session');
184
        $session->getFlashBag()->add($type, $message);
185
    }
186
}
187