Issues (3099)

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.

GeneratorBundle/DataFixtures/ORM/UserFixtures.php (1 issue)

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 Kunstmaan\GeneratorBundle\DataFixtures\ORM;
4
5
use Doctrine\Common\DataFixtures\AbstractFixture;
6
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
7
use Doctrine\Common\Persistence\ObjectManager;
8
use Kunstmaan\AdminBundle\Entity\User;
9
use Symfony\Component\Console\Output\ConsoleOutput;
10
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
11
use Symfony\Component\DependencyInjection\ContainerInterface;
12
use Symfony\Component\HttpKernel\Kernel;
13
14
/**
15
 * Fixture for creating the admin and guest user
16
 */
17
class UserFixtures extends AbstractFixture implements OrderedFixtureInterface, ContainerAwareInterface
18
{
19
    const REFERENCE_ADMIN_USER = 'adminuser';
20
21
    /** @var ContainerInterface */
22
    private $container;
23
24
    /**
25
     * Sets the Container.
26
     *
27
     * @param ContainerInterface|null $container A ContainerInterface instance or null
28
     *
29
     * @api
30
     */
31
    public function setContainer(ContainerInterface $container = null)
32
    {
33
        $this->container = $container;
34
    }
35
36
    /**
37
     * Load data fixtures with the passed EntityManager
38
     *
39
     * @param ObjectManager $manager
40
     */
41
    public function load(ObjectManager $manager)
42
    {
43
        $password = substr(rtrim(strtr(base64_encode(random_bytes(32)), '+/', '-_'), '='), 0, 8);
44
45
        $user1 = $this->createUser(
46
            $manager,
47
            'admin',
48
            $password,
49
            '[email protected]',
50
            $this->container->getParameter('kunstmaan_admin.default_admin_locale'),
51
            array('ROLE_SUPER_ADMIN'),
52
            array($manager->merge($this->getReference(GroupFixtures::REFERENCE_SUPERADMINS_GROUP))),
0 ignored issues
show
Deprecated Code introduced by
The method Doctrine\Persistence\ObjectManager::merge() has been deprecated with message: Merge operation is deprecated and will be removed in Persistence 2.0. Merging should be part of the business domain of an application rather than a generic operation of ObjectManager.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
53
            true,
54
            false
55
        );
56
        $user1->setCreatedBy('CMS installation');
57
        $manager->flush();
58
59
        $output = new ConsoleOutput();
60
        $output->writeln(array(
61
            "<comment>  > User 'admin' created with password '$password'</comment>",
62
        ));
63
64
        if (Kernel::VERSION_ID < 40000) {
65
            $file = $this->container->get('kernel')->getProjectDir() . '/app/config/config.yml';
66
            $contents = file_get_contents($file);
67
            $contents = str_replace('-adminpwd-', $password, $contents);
68
            file_put_contents($file, $contents);
69
        }
70
71
        $this->setReference(self::REFERENCE_ADMIN_USER, $user1);
72
    }
73
74
    /**
75
     * Create a user
76
     *
77
     * @param ObjectManager $manager  The object manager
78
     * @param string        $username The username
79
     * @param string        $password The plain password
80
     * @param string        $email    The email of the user
81
     * @param string        $locale   The locale (language) of the user
82
     * @param array         $roles    The roles the user has
83
     * @param array         $groups   The groups the user belongs to
84
     * @param bool          $enabled  Enable login for the user
85
     * @param bool          $changed  Disable password changed for the user
86
     *
87
     * @return User
88
     */
89
    private function createUser(
90
        ObjectManager $manager,
91
        $username,
92
        $password,
93
        $email,
94
        $locale,
95
        array $roles = array(),
96
        array $groups = array(),
97
        $enabled = false,
98
        $changed = false
99
    ) {
100
        $user = $this->container->get('fos_user.user_manager')->createUser();
101
        $user->setUsername($username);
102
        $user->setPlainPassword($password);
103
        $user->setRoles($roles);
104
        $user->setEmail($email);
105
        $user->setEnabled($enabled);
106
        $user->setAdminLocale($locale);
107
        $user->setPasswordChanged($changed);
108
        foreach ($groups as $group) {
109
            $user->addGroup($group);
110
        }
111
112
        $manager->persist($user);
113
114
        return $user;
115
    }
116
117
    /**
118
     * Get the order of this fixture
119
     *
120
     * @return int
121
     */
122
    public function getOrder()
123
    {
124
        return 3;
125
    }
126
}
127