Issues (7)

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.

src/AppserverIo/Properties/PropertiesUtil.php (2 issues)

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\Properties\PropertiesUtil
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      http://github.com/appserver-io/properties
18
 * @link      http://www.appserver.io
19
 */
20
21
namespace AppserverIo\Properties;
22
23
use AppserverIo\Properties\Filter\PropertyStreamFilter;
24
use AppserverIo\Properties\Filter\PropertyStreamFilterParams;
25
26
/**
27
 * Utility class providing some helper functionality to handle properties files.
28
 *
29
 * @author    Tim Wagner <[email protected]>
30
 * @copyright 2015 TechDivision GmbH <[email protected]>
31
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
32
 * @link      http://github.com/appserver-io/properties
33
 * @link      http://www.appserver.io
34
 */
35
class PropertiesUtil
36
{
37
38
    /**
39
     * The singleton instance.
40
     *
41
     * @var \AppserverIo\Properties\PropertiesUtil
42
     */
43
    protected static $instance;
44
45
    /**
46
     * This is a utility class, so protect it against direct
47
     * instantiation.
48
     */
49 1
    private function __construct()
50
    {
51 1
    }
52
53
    /**
54
     * This is a utility class, so protect it against cloning.
55
     *
56
     * @return void
57
     */
58
    private function __clone()
59
    {
60
    }
61
62
    /**
63
     * Return's the singleton instance and creates a new one if necessary.
64
     *
65
     * @return \AppserverIo\Properties\PropertiesUtil The singleton instance
66
     */
67 2
    public static function singleton()
68
    {
69
70
        // query whether or not we've already an instance created
71 2
        if (PropertiesUtil::$instance == null) {
72 1
            PropertiesUtil::$instance = new PropertiesUtil();
73 1
        }
74
75
        // return the singleton instance
76 2
        return PropertiesUtil::$instance;
77
    }
78
79
    /**
80
     * Replaces the variables declared in the properties with the
81
     * properties value itself.
82
     *
83
     * @param \AppserverIo\Properties\PropertiesInterface $properties The properties with the variables/values to replace
84
     * @param string                                      $pattern    The pattern that declares the variables (in valid sprintf format)
85
     *
86
     * @return void
87
     */
88 1
    public function replaceProperties(PropertiesInterface $properties, $pattern = PropertyStreamFilterParams::PATTERN)
0 ignored issues
show
The parameter $pattern is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
89
    {
90 1
        foreach ($properties as $key => $value) {
0 ignored issues
show
The expression $properties of type object<AppserverIo\Prope...es\PropertiesInterface> is not traversable.
Loading history...
91 1
            $properties->setProperty($key, $this->replacePropertiesInString($properties, $value));
92 1
        }
93 1
    }
94
95
    /**
96
     * Replaces the variables declared by the passed token with the
97
     * properties and returns the content.
98
     *
99
     * @param \AppserverIo\Properties\PropertiesInterface $properties The properties with the values to replace
100
     * @param string                                      $string     The string to replace the variables with the properties
101
     * @param string                                      $pattern    The pattern that declares the variables (in valid sprintf format)
102
     *
103
     * @return string The content of the file with the replaced variables
104
     */
105 2
    public function replacePropertiesInString(PropertiesInterface $properties, $string, $pattern = PropertyStreamFilterParams::PATTERN)
106
    {
107
108
        // open the stream
109 2
        $fp = fopen('php://temp', 'r+');
110
111
        // write/rewind the content into the string to allow using stream filters
112 2
        fputs($fp, $string);
113 2
        rewind($fp);
114
115
        // replace the properties and close the stream
116 2
        $replaced = $this->replacePropertiesInStream($properties, $fp, $pattern);
117 2
        fclose($fp);
118
119
        // return the string with the properties replaced
120 2
        return $replaced;
121
    }
122
123
    /**
124
     * Replaces the variables declared by the passed token with the
125
     * properties and returns the content.
126
     *
127
     * @param \AppserverIo\Properties\PropertiesInterface $properties The properties with the values to replace
128
     * @param resource                                    $fp         The file pointer to replace the variables with the properties
129
     * @param string                                      $pattern    The pattern that declares the variables (in valid sprintf format)
130
     *
131
     * @return string The content of the file with the replaced variables
132
     */
133 2
    public function replacePropertiesInStream(PropertiesInterface $properties, $fp, $pattern = PropertyStreamFilterParams::PATTERN)
134
    {
135
136
        // initialize the params for the stream filter
137 2
        $params = new PropertyStreamFilterParams($properties, $pattern);
138
139
        // register the filter
140 2
        stream_filter_register(PropertyStreamFilter::NAME, 'AppserverIo\Properties\Filter\PropertyStreamFilter');
141 2
        stream_filter_append($fp, PropertyStreamFilter::NAME, STREAM_FILTER_READ, $params);
142
143
        // replace the properties and close the stream
144 2
        return stream_get_contents($fp);
145
    }
146
}
147