Issues (1)

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.

OpensoftSimpleSerializerExtension.php (1 issue)

Labels
Severity

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 was originally received from JMSSerializerBundle; since then,
5
 * it has been modified, and does only in parts resemble the original source code.
6
 *
7
 * To the original source code, the following license applies:
8
 * Copyright 2011 Johannes M. Schmitt <[email protected]>
9
 *
10
 * Licensed under the Apache License, Version 2.0 (the "License");
11
 * you may not use this file except in compliance with the License.
12
 * You may obtain a copy of the License at
13
 *
14
 * http://www.apache.org/licenses/LICENSE-2.0
15
 *
16
 * Unless required by applicable law or agreed to in writing, software
17
 * distributed under the License is distributed on an "AS IS" BASIS,
18
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19
 * See the License for the specific language governing permissions and
20
 * limitations under the License.
21
 *
22
 * To all other portions of code, the following license applies:
23
 *
24
 * This file is part of the SimpleSerializerBundle package.
25
 *
26
 * Copyright (c) 2012 Farheap Solutions (http://www.farheap.com)
27
 *
28
 * For the full copyright and license information, please view the
29
 * LICENSE file that was distributed with this source code.
30
 */
31
32
namespace Opensoft\Bundle\SimpleSerializerBundle\DependencyInjection;
33
34
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
35
use Symfony\Component\HttpKernel\KernelInterface;
36
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
37
use Symfony\Component\DependencyInjection\ContainerBuilder;
38
use Symfony\Component\Config\FileLocator;
39
use Symfony\Component\DependencyInjection\Alias;
40
use Opensoft\Bundle\SimpleSerializerBundle\Exception\RuntimeException;
41
42
/**
43
 * @author Dmitry Petrov <[email protected]>
44
 */
45
class OpensoftSimpleSerializerExtension extends Extension
46
{
47
    /**
48
     * @var KernelInterface
49
     */
50
    private $kernel;
51
52
    /**
53
     * @param KernelInterface $kernel
54
     */
55
    public function __construct(KernelInterface $kernel)
56
    {
57
        $this->kernel = $kernel;
58
    }
59
60
    /**
61
     * {@inheritDoc}
62
     *
63
     * @param array $configs
64
     * @param ContainerBuilder $container
65
     */
66
    public function load(array $configs, ContainerBuilder $container)
67
    {
68
        $config = $this->processConfiguration($this->getConfiguration($configs, $container), $configs);
0 ignored issues
show
It seems like $this->getConfiguration($configs, $container) can be null; however, processConfiguration() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
69
70
        $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
71
        $loader->load('services.xml');
72
73
        // metadata
74
        if ('none' === $config['metadata']['cache']) {
75
            $container->removeAlias('opensoft_simple_serializer.metadata.cache');
76
        } else if ('file' === $config['metadata']['cache']) {
77
            $container
78
                ->getDefinition('opensoft_simple_serializer.metadata.cache.file')
79
                ->replaceArgument(0, $config['metadata']['file_cache']['dir'])
80
            ;
81
82
            $dir = $container->getParameterBag()->resolveValue($config['metadata']['file_cache']['dir']);
83
            if (!file_exists($dir)) {
84
                if (!$rs = @mkdir($dir, 0777, true)) {
85
                    throw new RuntimeException(sprintf('Could not create cache directory "%s".', $dir));
86
                }
87
            }
88
        } else {
89
            $container->setAlias('opensoft_simple_serializer.metadata.cache.file', new Alias($config['metadata']['cache'], false));
90
        }
91
        $container
92
            ->getDefinition('opensoft_simple_serializer.metadata.factory')
93
            ->replaceArgument(2, $config['metadata']['debug'])
94
        ;
95
96
97
        // directories
98
        $directories = array();
99
        $bundles = $container->getParameter('kernel.bundles');
100
        if ($config['metadata']['auto_detection']) {
101
            foreach ($bundles as $class) {
102
                $ref = new \ReflectionClass($class);
103
104
                $directories[$ref->getNamespaceName()] = dirname($ref->getFileName()) . '/Resources/config/simple-serializer';
105
            }
106
        }
107
        foreach ($config['metadata']['directories'] as $directory) {
108
            $directory['path'] = rtrim(str_replace('\\', '/', $directory['path']), '/');
109
110
            if ($directory['path'][0] === '@') {
111
                $bundleName = substr($directory['path'], 1, strpos($directory['path'], '/') - 1);
112
113
                if (!isset($bundles[$bundleName])) {
114
                    throw new RuntimeException(sprintf('The bundle "%s" has not been registered with AppKernel.
115
                    Available bundles: %s', $bundleName, implode(', ', array_keys($bundles))));
116
                }
117
118
                $ref = new \ReflectionClass($bundles[$bundleName]);
119
                $directory['path'] = dirname($ref->getFileName()) . substr($directory['path'], strlen('@'.$bundleName));
120
            }
121
122
            $directories[rtrim($directory['namespace_prefix'], '\\')] = rtrim($directory['path'], '\\/');
123
        }
124
        $container
125
            ->getDefinition('opensoft_simple_serializer.metadata.driver.file_locator')
126
            ->replaceArgument(0, $directories)
127
        ;
128
    }
129
130
    /**
131
     * {@inheritDoc}
132
     *
133
     * @param array $config
134
     * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
135
     * @return null|Configuration
136
     */
137
    public function getConfiguration(array $config, ContainerBuilder $container)
138
    {
139
        return new Configuration($this->kernel->isDebug());
140
    }
141
}
142