Issues (4141)

Security Analysis    not enabled

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.

PagSeguroLibrary/helper/PagSeguroHelper.class.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
 * 2007-2014 [PagSeguro Internet Ltda.]
4
 *
5
 * NOTICE OF LICENSE
6
 *
7
 *Licensed under the Apache License, Version 2.0 (the "License");
8
 *you may not use this file except in compliance with the License.
9
 *You may obtain a copy of the License at
10
 *
11
 *http://www.apache.org/licenses/LICENSE-2.0
12
 *
13
 *Unless required by applicable law or agreed to in writing, software
14
 *distributed under the License is distributed on an "AS IS" BASIS,
15
 *WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 *See the License for the specific language governing permissions and
17
 *limitations under the License.
18
 *
19
 *  @author    PagSeguro Internet Ltda.
20
 *  @copyright 2007-2014 PagSeguro Internet Ltda.
21
 *  @license   http://www.apache.org/licenses/LICENSE-2.0
22
 */
23
24
/***
25
 * Helper functions
26
 */
27
class PagSeguroHelper
28
{
29
30
    /***
31
     * @param $date
32
     * @return bool|string
33
     */
34
    public static function formatDate($date)
35
    {
36
        $format = DateTime::ATOM;
37
        if ($date instanceof DateTime) {
38
            $d = $date->format($format);
39
        } elseif (is_numeric($date)) {
40
            $d = date($format, $date);
41
        } else {
42
            $d = (string) $date;
43
        }
44
        return $d;
45
    }
46
47
    /***
48
     * @param $value
49
     * @return string
50
     */
51
    public static function decimalFormat($value)
52
    {
53
        if (is_float($value)) {
54
            $value = (float) $value;
55
            $value = floor($value * 100) / 100;
56
            $value = (string) number_format($value, 2, '.', '');
57
        }
58
        return $value;
59
    }
60
61
    /***
62
     * @param $date
63
     * @param $days
64
     * @return bool|string
65
     */
66
    public static function subDays($date, $days)
67
    {
68
        $d = self::formatDate($date);
69
        $d = date_parse($d);
70
        $d = mktime($d['hour'], $d['minute'], $d['second'], $d['month'], $d['day'] - $days, $d['year']);
71
        return self::formatDate($d);
72
    }
73
74
    /***
75
     * @param $var
76
     * @param null $dump
77
     */
78
    public static function printError($var, $dump = null)
79
    {
80
        if (is_array($var) || is_object($var)) {
81
            echo "<pre>";
82
            if ($dump) {
83
                var_dump($var);
0 ignored issues
show
Security Debugging Code introduced by
var_dump($var); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
84
            } else {
85
                print_r($var);
86
            }
87
            echo "</pre>";
88
        }
89
    }
90
91
    /***
92
     * Remove left, right and inside extra spaces in string
93
     * @param string $string
94
     * @return string
95
     */
96
    public static function removeStringExtraSpaces($string)
97
    {
98
        return trim(preg_replace("/( +)/", " ", $string));
99
    }
100
101
    /***
102
     * Perform truncate of string value
103
     * @param string $string
104
     * @param int $limit
105
     * @param mixed $endchars
106
     * @return string
107
     */
108
    public static function truncateValue($string, $limit, $endchars = '...')
109
    {
110
111
        if (!is_array($string) && !is_object($string)) {
112
113
            $stringLength = strlen($string);
114
            $endcharsLength = strlen($endchars);
115
116
            if ($stringLength > (int) $limit) {
117
                $cut = (int) ($limit - $endcharsLength);
118
                $string = substr($string, 0, $cut) . $endchars;
119
            }
120
        }
121
        return $string;
122
    }
123
124
    /***
125
     * Return formatted string to send in PagSeguro request
126
     * @param string $string
127
     * @param int $limit
128
     * @param mixed $endchars
129
     * @return string
130
     */
131
    public static function formatString($string, $limit, $endchars = '...')
132
    {
133
        $string = PagSeguroHelper::removeStringExtraSpaces($string);
134
        return PagSeguroHelper::truncateValue($string, $limit, $endchars);
135
    }
136
137
    /***
138
     * Check if var is empty
139
     * @param string $value
140
     * @return boolean
141
     */
142
    public static function isEmpty($value)
143
    {
144
        return (!isset($value) || trim($value) == "");
145
    }
146
147
    /***
148
     * Check if notification post is empty
149
     * @param array $notification_data
150
     * @return boolean
151
     */
152
    public static function isNotificationEmpty(array $notification_data)
153
    {
154
        $isEmpty = true;
155
156
        if (isset($notification_data['notificationCode']) && isset($notification_data['notificationType'])) {
157
            $isEmpty = (PagSeguroHelper::isEmpty($notification_data['notificationCode']) ||
158
                            PagSeguroHelper::isEmpty($notification_data['notificationType'])
159
                       );
160
        }
161
162
        return $isEmpty;
163
    }
164
165
    /***
166
     * Remove all non digit character from string
167
     * @param string $value
168
     * @return string
169
     */
170
    public static function getOnlyNumbers($value)
171
    {
172
        return preg_replace('/\D/', '', $value);
173
    }
174
}
175