Issues (6)

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.

DependencyInjection/Compiler/AssetCompilerPass.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 Rj\FrontendBundle\DependencyInjection\Compiler;
4
5
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Definition;
8
use Symfony\Component\DependencyInjection\Reference;
9
10
class AssetCompilerPass implements CompilerPassInterface
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15 19
    public function process(ContainerBuilder $container)
16
    {
17 19
        $packages = [];
18 19
        $registeredPackages = $this->getRegisteredPackages($container);
19
20 18
        foreach ($this->getTaggedPackages($container) as $id => $tags) {
21 10
            if (empty($tags) || !isset($tags[0]['alias'])) {
22 1
                throw new \LogicException(
23 1
                    "The tag for the service with id '$id' must define an 'alias' attribute"
24
                );
25
            }
26
27 9
            $packageName = $tags[0]['alias'];
28
29 9
            if (isset($registeredPackages[$packageName])) {
30 1
                throw new \LogicException(
31 1
                    "A package named '$packageName' has already been registered"
32
                );
33
            }
34
35 8
            if (isset($packages[$packageName])) {
36 1
                throw new \LogicException(
37 1
                    "Multiple packages were found with alias '$packageName'. Package alias' must be unique"
38
                );
39
            }
40
41 8
            $packages[$packageName] = $id;
42
        }
43
44 15
        $this->addPackages($packages, $container);
45
46 15
        if ($container->hasDefinition($this->namespaceService('package.fallback'))) {
47 12
            $this->setDefaultPackage($container);
48
        }
49 15
    }
50
51
    /**
52
     * @param ContainerBuilder $container
53
     *
54
     * @return Definition[]
55
     */
56 18
    private function getTaggedPackages(ContainerBuilder $container)
57
    {
58 18
        return $container->findTaggedServiceIds($this->namespaceService('package.asset'));
59
    }
60
61
    /**
62
     * @param ContainerBuilder $container
63
     *
64
     * @return Definition
65
     */
66 19
    private function getPackagesService(ContainerBuilder $container)
67
    {
68 19
        if (!$container->hasDefinition('assets.packages')) {
69 1
            throw new \LogicException('The Asset component is not registered in the container');
70
        }
71
72 18
        return $container->getDefinition('assets.packages');
73
    }
74
75
    /**
76
     * @param Definition[]     $packages
77
     * @param ContainerBuilder $container
78
     */
79 15
    private function addPackages($packages, ContainerBuilder $container)
80
    {
81 15
        $packagesService = $this->getPackagesService($container);
82
83 15
        foreach ($packages as $name => $id) {
84 7
            $packagesService->addMethodCall(
85 7
                'addPackage',
86 7
                [$name, new Reference($id)]
0 ignored issues
show
$id is of type object<Symfony\Component...cyInjection\Definition>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
87
            );
88
        }
89 15
    }
90
91
    /**
92
     * @param ContainerBuilder $container
93
     */
94 12
    private function setDefaultPackage(ContainerBuilder $container)
95
    {
96 12
        $packagesService = $this->getPackagesService($container);
97 12
        $defaultPackage = $this->getRegisteredDefaultPackage($container);
98 12
        $fallbackPackageId = $this->namespaceService('package.fallback');
99
100 12
        $container->getDefinition($fallbackPackageId)->addMethodCall('setFallback', [$defaultPackage]);
101
102 12
        $packagesService->replaceArgument(0, new Reference($fallbackPackageId));
103 12
    }
104
105
    /**
106
     * Retrieve packages that have already been registered.
107
     *
108
     * @param ContainerBuilder $container
109
     *
110
     * @return array with the packages' name as keys
111
     */
112 19
    private function getRegisteredPackages(ContainerBuilder $container)
113
    {
114 19
        $arguments = $this->getPackagesService($container)->getArguments();
115
116 18
        if (!isset($arguments[1]) || count($arguments[1]) < 2) {
117 16
            return [];
118
        }
119
120 2
        $argPackages = $arguments[1];
121
122 2
        $packages = [];
123 2
        $argCount = count($argPackages);
124 2
        for ($i = 0; $i < $argCount; ++$i) {
125 2
            $packages[$argPackages[$i]] = $argPackages[++$i];
126
        }
127
128 2
        return $packages;
129
    }
130
131
    /**
132
     * @param ContainerBuilder $container
133
     *
134
     * @return Definition|null
135
     */
136 12
    private function getRegisteredDefaultPackage(ContainerBuilder $container)
137
    {
138 12
        $arguments = $this->getPackagesService($container)->getArguments();
139
140 12
        if (!isset($arguments[0])) {
141
            return null;
142
        }
143
144 12
        return $arguments[0];
145
    }
146
147
    /**
148
     * @param string $id
149
     *
150
     * @return string
151
     */
152 18
    private function namespaceService($id)
153
    {
154 18
        return "rj_frontend.$id";
155
    }
156
}
157