Issues (18)

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.

RemoteMethodInvocation/LocalContextConnection.php (2 issues)

Labels

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
 * AppserverIo\PersistenceContainerClient\Context\LocalContextConnection
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Tim Wagner <[email protected]>
15
 * @copyright 2015 TechDivision GmbH <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/appserver-io/rmi
18
 * @link      http://www.appserver.io
19
 */
20
21
namespace AppserverIo\RemoteMethodInvocation;
22
23
use AppserverIo\Collections\CollectionInterface;
24
use AppserverIo\Psr\Application\ApplicationInterface;
25
use AppserverIo\Psr\EnterpriseBeans\BeanContextInterface;
26
27
/**
28
 * Connection implementation to invoke a local method call.
29
 *
30
 * @author    Tim Wagner <[email protected]>
31
 * @copyright 2015 TechDivision GmbH <[email protected]>
32
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
33
 * @link      https://github.com/appserver-io/rmi
34
 * @link      http://www.appserver.io
35
 *
36
 * @deprecated Use \AppserverIo\RemoteMethodInvocation\LocalProxy instead
37
 */
38
class LocalContextConnection implements ConnectionInterface
39
{
40
41
    /**
42
     * The storage for the sessions.
43
     *
44
     * @var \AppserverIo\Collections\CollectionInterface
45
     */
46
    protected $sessions = null;
47
48
    /**
49
     * The application instance.
50
     *
51
     * @var \AppserverIo\Psr\Application\ApplicationInterface
52
     */
53
    protected $application;
54
55
    /**
56
     * The bean manager instance to load the local bean instance with.
57
     *
58
     * @var \AppserverIo\Psr\EnterpriseBeans\BeanContextInterface
59
     */
60
    protected $beanManager;
61
62
    /**
63
     * The local bean instance we're the proxy for.
64
     *
65
     * @var object
66
     */
67
    protected $instance;
68
69
    /**
70
     * Injects the application instance for the local connection.
71
     *
72
     * @param \AppserverIo\Psr\Application\ApplicationInterface $application The application instance
73
     *
74
     * @return void
75
     */
76
    public function injectApplication(ApplicationInterface $application)
77
    {
78
        $this->application = $application;
79
    }
80
81
    /**
82
     * Returns the application instance.
83
     *
84
     * @return \AppserverIo\Psr\Application\ApplicationInterface The application instance
85
     */
86
    public function getApplication()
87
    {
88
        return $this->application;
89
    }
90
91
    /**
92
     * Injects the collection for the sessions.
93
     *
94
     * @param \AppserverIo\Collections\CollectionInterface $sessions The collection for the sessions
95
     *
96
     * @return void
97
     */
98
    public function injectSessions(CollectionInterface $sessions)
99
    {
100
        $this->sessions = $sessions;
101
    }
102
103
    /**
104
     * Returns the collection with the sessions.
105
     *
106
     * @return \AppserverIo\Collections\CollectionInterface The collection with the sessions
107
     */
108
    public function getSessions()
109
    {
110
        return $this->sessions;
111
    }
112
113
    /**
114
     * Sends the remote method call to the container instance.
115
     *
116
     * @param \AppserverIo\RemoteMethodInvocation\RemoteMethodInterface $remoteMethod The remote method instance
117
     *
118
     * @return mixed The response from the container
119
     * @see AppserverIo\RemoteMethodInvocation\ConnectionInterface::send()
120
     */
121
    public function send(RemoteMethodInterface $remoteMethod)
122
    {
123
        return $this->getApplication()->search(BeanContextInterface::IDENTIFIER)->invoke($remoteMethod, $this->getSessions());
0 ignored issues
show
The method search() does not seem to exist on object<AppserverIo\Psr\A...n\ApplicationInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
124
    }
125
126
    /**
127
     * Initializes a new session instance.
128
     *
129
     * @return \AppserverIo\RemoteMethodInvocation\SessionInterface The session instance
130
     * @see \AppserverIo\RemoteMethodInvocation\ConnectionInterface::createContextSession()
131
     */
132
    public function createContextSession()
133
    {
134
        $this->sessions->add($session = new ContextSession($this));
0 ignored issues
show
It seems like you code against a concrete implementation and not the interface AppserverIo\Collections\CollectionInterface as the method add() does only exist in the following implementations of said interface: AppserverIo\Collections\ArrayList, AppserverIo\Collections\Dictionary, AppserverIo\Collections\HashMap, AppserverIo\Collections\IdentityDictionary, AppserverIo\Collections\TreeMap, AppserverIo\RemoteMethodInvocation\ContextSession.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
135
        return $session;
136
    }
137
}
138