Issues (4)

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.

Admin/CardAdmin.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 the Moo\FlashCardAdminBundle package.
5
 *
6
 * (c) Mohamed Alsharaf <[email protected]>
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 Moo\FlashCardAdminBundle\Admin;
13
14
use Sonata\AdminBundle\Admin\Admin;
15
use Sonata\AdminBundle\Datagrid\ListMapper;
16
use Sonata\AdminBundle\Datagrid\DatagridMapper;
17
use Sonata\AdminBundle\Form\FormMapper;
18
19
/**
20
 * CardAdmin is the card admin class for SonataAdminBundle.
21
 *
22
 * @author Mohamed Alsharaf <[email protected]>
23
 */
24
class CardAdmin extends Admin
25
{
26
    public $supportsPreviewMode = true;
27
28
    /**
29
     * Get template name based on the name of the page.
30
     *
31
     * @param  string $name
32
     * @return string
33
     */
34
    public function getTemplate($name)
35
    {
36
        switch ($name) {
37
            case 'preview':
38
                return 'MooFlashCardAdminBundle:CRUD:preview.html.twig';
39
            case 'show':
40
                return 'MooFlashCardAdminBundle:CRUD:show.html.twig';
41
            default:
42
                return parent::getTemplate($name);
43
        }
44
    }
45
46
    /**
47
     * Configure the fields to be shown in create/edit forms
48
     *
49
     * @param  \Sonata\AdminBundle\Form\FormMapper $formMapper
50
     * @return void
51
     */
52
    protected function configureFormFields(FormMapper $formMapper)
53
    {
54
        $formMapper
55
                ->with('General')
56
                ->add('title', 'text', array('label' => 'Card Title'))
57
                ->add('slug', 'text', array('required' => false))
58
                ->add('category', 'entity', array(
59
                    'class' => 'Moo\FlashCardBundle\Entity\Category'
60
                ))
61
                ->add('active')
62
                ->add('content', 'textarea')
63
                ->end()
64
                ->with('SEO')
65
                ->add('metaKeywords', 'text', array(
66
                    'required' => false,
67
                    'help'     => 'Card keywords seperated by a comma.'
68
                ))
69
                ->add('metaDescription', 'textarea', array('required' => false))
70
                ->end()
71
                ->with('Management')
72
                ->add('created', null, array('required' => false))
73
                ->add('updated', null, array('required' => false))
74
                ->end()
75
        ;
76
    }
77
78
    /**
79
     * Configure the fields to be shown in filter form.
80
     *
81
     * @param  \Sonata\AdminBundle\Datagrid\DatagridMapper $datagridMapper
82
     * @return void
83
     */
84 View Code Duplication
    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
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...
85
    {
86
        $datagridMapper
87
                ->add('title', 'doctrine_orm_callback', array(
88
                    'callback'   => array($this, 'getSearchFilter'),
89
                    'field_type' => 'text'
90
                ))
91
                ->add('category')
92
                ->add('active')
93
        ;
94
    }
95
96
    /**
97
     * Configure the columns in list page.
98
     *
99
     * @param  \Sonata\AdminBundle\Datagrid\ListMapper $listMapper
100
     * @return void
101
     */
102
    protected function configureListFields(ListMapper $listMapper)
103
    {
104
        $listMapper
105
                ->addIdentifier('title')
106
                ->add('category')
107
                ->add('active', null, array('editable' => true))
108
                // add custom action links
109
                ->add('_action', 'actions', array(
110
                    'actions' => array(
111
                        'show'   => array(),
112
                        'edit'   => array(
113
                            'subject' => 'EDit'
114
                        ),
115
                        'delete' => array(),
116
                    )
117
                ))
118
        ;
119
    }
120
121
    /**
122
     * Callback method to the filter form to search by the card title.
123
     *
124
     * @param  type    $queryBuilder
125
     * @param  string  $alias
126
     * @param  string  $field
127
     * @param  string  $value
128
     * @return boolean
129
     */
130 View Code Duplication
    public function getSearchFilter($queryBuilder, $alias, $field, $value)
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...
131
    {
132
        if ($value['value']) {
133
            $exp = new \Doctrine\ORM\Query\Expr();
134
            $queryBuilder->andWhere($exp->like($alias . '.title', $exp->literal('%' . $value['value'] . '%')));
135
136
            return true;
137
        }
138
139
        return false;
140
    }
141
142
    public function preUpdate($card)
143
    {
144
        $card->preUpdate();
145
    }
146
147
    public function prePersist($card)
148
    {
149
        $card->prePersist();
150
    }
151
152
}
153