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/AssetExtensionLoader.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
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 19 and the first side effect is on line 6.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
namespace Rj\FrontendBundle\DependencyInjection;
4
5
if (!class_exists('Symfony\Component\DependencyInjection\ChildDefinition')) {
6
    class_alias(
7
        'Symfony\Component\DependencyInjection\DefinitionDecorator',
8
        'Symfony\Component\DependencyInjection\ChildDefinition'
9
    );
10
}
11
12
use Rj\FrontendBundle\Util\Util;
13
use Symfony\Component\Config\Loader\LoaderInterface;
14
use Symfony\Component\DependencyInjection\ChildDefinition;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\Definition;
17
use Symfony\Component\DependencyInjection\Reference;
18
19
class AssetExtensionLoader
20
{
21
    /**
22
     * @var string
23
     */
24
    private $alias;
25
26
    /**
27
     * @var ContainerBuilder
28
     */
29
    private $container;
30
31
    /**
32
     * @param string           $alias
33
     * @param ContainerBuilder $container
34
     */
35 20
    public function __construct($alias, ContainerBuilder $container)
36
    {
37 20
        $this->alias = $alias;
38 20
        $this->container = $container;
39 20
    }
40
41
    /**
42
     * @param array           $config
43
     * @param LoaderInterface $loader
44
     */
45 20
    public function load(array $config, LoaderInterface $loader)
46
    {
47 20
        $loader->load('asset.yml');
48
49 20
        if ($config['override_default_package']) {
50 19
            $loader->load('fallback.yml');
51
52 19
            $defaultPackage = $this->createPackage('default', [
53 19
                'prefix' => $config['prefix'],
54 19
                'manifest' => $config['manifest'],
55
            ]);
56
57 19
            $defaultPackageId = $this->getPackageId('default');
58 19
            $this->container->setDefinition($defaultPackageId, $defaultPackage);
59
60 19
            $this->container->getDefinition($this->namespaceService('package.fallback'))
61 19
                ->addArgument($config['fallback_patterns'])
62 19
                ->addArgument(new Reference($defaultPackageId));
63
        }
64
65 20
        foreach ($config['packages'] as $name => $packageConfig) {
66 10
            $packageTag = $this->namespaceService('package.asset');
67 10
            $package = $this->createPackage($name, $packageConfig)
68 10
                ->addTag($packageTag, ['alias' => $name]);
69
70 10
            $this->container->setDefinition($this->getPackageId($name), $package);
71
        }
72 20
    }
73
74
    /**
75
     * @param string $name
76
     * @param array  $config
77
     *
78
     * @return Definition
79
     */
80 19
    private function createPackage($name, array $config)
81
    {
82 19
        $prefixes = $config['prefix'];
83 19
        $isUrl = Util::containsUrl($prefixes);
84
85 19
        $packageDefinition = $isUrl
86 4
            ? new ChildDefinition($this->namespaceService('asset.package.url'))
87 19
            : new ChildDefinition($this->namespaceService('asset.package.path'))
88
        ;
89
90 19
        if ($config['manifest']['enabled']) {
91 4
            $versionStrategy = $this->createManifestVersionStrategy($name, $config['manifest']);
92
        } else {
93 17
            $versionStrategy = new Reference($this->namespaceService('version_strategy.empty'));
94
        }
95
96
        return $packageDefinition
97 19
            ->addArgument($isUrl ? $prefixes : $prefixes[0])
98 19
            ->addArgument($versionStrategy)
99 19
            ->setPublic(false);
100
    }
101
102
    /**
103
     * @param string $name
104
     *
105
     * @return string
106
     */
107 19
    private function getPackageId($name)
108
    {
109 19
        return $this->namespaceService("_package.$name");
110
    }
111
112
    /**
113
     * @param string $packageName
114
     * @param array  $config
115
     *
116
     * @return Reference
117
     */
118 4
    private function createManifestVersionStrategy($packageName, $config)
119
    {
120 4
        $loader = new ChildDefinition($this->namespaceService('manifest.loader.'.$config['format']));
121
        $loader
122 4
            ->addArgument($config['path'])
123 4
            ->addArgument($config['root_key'])
124
        ;
125
126 4
        $loaderId = $this->namespaceService("_package.$packageName.manifest_loader");
127 4
        $this->container->setDefinition($loaderId, $loader);
128
129 4
        $cachedLoader = new ChildDefinition($this->namespaceService('manifest.loader.cached'));
130 4
        $cachedLoader->addArgument(new Reference($loaderId));
131
132 4
        $cachedLoaderId = $this->namespaceService("_package.$packageName.manifest_loader_cached");
133 4
        $this->container->setDefinition($cachedLoaderId, $cachedLoader);
134
135 4
        $versionStrategy = new ChildDefinition($this->namespaceService('version_strategy.manifest'));
136 4
        $versionStrategy->addArgument(new Reference($cachedLoaderId));
137
138 4
        $versionStrategyId = $this->namespaceService("_package.$packageName.version_strategy");
139 4
        $this->container->setDefinition($versionStrategyId, $versionStrategy);
140
141 4
        return new Reference($versionStrategyId);
142
    }
143
144
    /**
145
     * @param string $id
146
     *
147
     * @return string
148
     */
149 19
    private function namespaceService($id)
150
    {
151 19
        return $this->alias.'.'.$id;
152
    }
153
}
154