Issues (31)

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/AppBundle/Controller/ProjectController.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
/**
4
 * This file is part of Packy.
5
 *
6
 * (c) Peter Nijssen
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace AppBundle\Controller;
13
14
use AppBundle\Entity\Project;
15
use AppBundle\Form\Type\ProjectFormType;
16
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
17
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
18
use Symfony\Component\HttpFoundation\RedirectResponse;
19
use Symfony\Component\HttpFoundation\Request;
20
use Symfony\Component\HttpFoundation\Response;
21
22
class ProjectController extends Controller
23
{
24
    /**
25
     * Project overview page.
26
     *
27
     * @return Response A Response instance
28
     */
29
    public function overviewAction()
30
    {
31
        $projectRepository = $this->get('packy.repository.project');
32
        $projects = $projectRepository->findAll();
33
34
        return $this->render(
35
            'AppBundle:Project:overview.html.twig',
36
            [
37
                'projects' => $projects,
38
            ]
39
        );
40
    }
41
42
    /**
43
     * Add project.
44
     *
45
     * @param Request $request A Request instance
46
     *
47
     * @return Response A Response instance
48
     */
49 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...
50
    {
51
        $project = new Project();
52
        $projectForm = $this->createForm(ProjectFormType::class, $project);
53
54
        if ($request->isMethod('POST')) {
55
            $projectForm->handleRequest($request);
56
            if ($projectForm->isValid()) {
57
                $projectManager = $this->get('packy.repository.project');
58
                $projectManager->create($project);
59
60
                return $this->redirect($this->generateUrl('packy_project_overview'));
61
            }
62
        }
63
64
        return $this->render(
65
            'AppBundle:Project:form.html.twig',
66
            [
67
                'project' => $project,
68
                'projectForm' => $projectForm->createView(),
69
            ]
70
        );
71
    }
72
73
    /**
74
     * @ParamConverter("project", class="AppBundle:Project", options={"id" = "projectId"})
75
     *
76
     * Analyze project
77
     *
78
     * @param Project $project
79
     *
80
     * @return Response A Response instance
81
     */
82
    public function analyzeAction(Project $project)
83
    {
84
        $dependencyRepository = $this->get('packy.repository.dependency');
85
86
        $dependencyManagers = $this->get('packy.dependency_managers');
87
        $dependencyManagers = $dependencyManagers->getAll();
88
89
        //@TODO: Refactor
90
        $vendors = [];
91
        foreach ($dependencyManagers as $manager) {
92
            $name = $manager->getName();
93
            $dependencies = $dependencyRepository->findAllByManager($project, $name);
94
            if (!empty($dependencies)) {
95
                $vendors[$name] = $dependencies;
96
            }
97
        }
98
99
        //@TODO: BIG Refactor
100
        $stats = [
101
            'outdated' => [],
102
            'unstable' => [],
103
            'stable' => [],
104
        ];
105
106
        foreach ($vendors as $name => $dependencies) {
107
            foreach ($stats as &$stat) {
108
                $stat[$name] = 0;
109
            }
110
111
            unset($stat);
112
113
            foreach ($stats as $type => $stat) {
114
                foreach ($dependencies as $dependency) {
115
                    if ($dependency->getStatus() == $type) {
116
                        $stats[$type][$name] += 1;
117
                    }
118
                }
119
            }
120
        }
121
122
        return $this->render(
123
            'AppBundle:Project:analyze.html.twig',
124
            [
125
                'project' => $project,
126
                'vendors' => $vendors,
127
                'stats' => $stats,
128
            ]
129
        );
130
    }
131
132
    /**
133
     * @ParamConverter("project", class="AppBundle:Project", options={"id" = "projectId"})
134
     *
135
     * Edit project
136
     *
137
     * @param Request $request A Request instance
138
     * @param Project $project
139
     *
140
     * @return Response A Response instance
141
     */
142 View Code Duplication
    public function editAction(Request $request, Project $project)
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...
143
    {
144
        $projectForm = $this->createForm(ProjectFormType::class, $project);
145
146
        if ($request->isMethod('POST')) {
147
            $projectForm->handleRequest($request);
148
            if ($projectForm->isValid()) {
149
                $projectRepository = $this->get('packy.repository.project');
150
                $projectRepository->update($project);
151
152
                return $this->redirect($this->generateUrl('packy_project_overview'));
153
            }
154
        }
155
156
        return $this->render(
157
            'AppBundle:Project:form.html.twig',
158
            [
159
                'project' => $project,
160
                'projectForm' => $projectForm->createView(),
161
            ]
162
        );
163
    }
164
165
    /**
166
     * @ParamConverter("project", class="AppBundle:Project", options={"id" = "projectId"})
167
     *
168
     * Delete project
169
     *
170
     * @param Project $project
171
     *
172
     * @return RedirectResponse A Response instance
173
     */
174
    public function deleteAction(Project $project)
175
    {
176
        $projectRepository = $this->get('packy.repository.project');
177
        $projectRepository->delete($project);
178
179
        return $this->redirect($this->generateUrl('packy_project_overview'));
180
    }
181
}
182