Issues (244)

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.

src/N98/Util/OperatingSystem.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
 * this file is part of magerun
4
 *
5
 * @author Tom Klingenberg <https://github.com/ktomk>
6
 */
7
8
namespace N98\Util;
9
10
/**
11
 * Class OperatingSystem
12
 *
13
 * @package N98\Util
14
 */
15
class OperatingSystem
16
{
17
    /**
18
     * @var int
19
     */
20
    const UID_ROOT = 0;
21
22
    /**
23
     * Returns true if operating system is
24
     * based on GNU linux.
25
     *
26
     * @return boolean
27
     */
28
    public static function isLinux()
29
    {
30
        return (bool) stristr(PHP_OS, 'linux');
31
    }
32
33
    /**
34
     * Returns true if operating system is
35
     * based on Microsoft Windows.
36
     *
37
     * @return boolean
38
     */
39
    public static function isWindows()
40
    {
41
        return strtolower(substr(PHP_OS, 0, 3)) === 'win';
42
    }
43
44
    /**
45
     * Returns true if operating system is
46
     * based on novell netware.
47
     *
48
     * @return boolean
49
     */
50
    public static function isNetware()
51
    {
52
        return (bool) stristr(PHP_OS, 'netware');
53
    }
54
55
    /**
56
     * Returns true if operating system is
57
     * based on apple MacOS.
58
     *
59
     * @return boolean
60
     */
61
    public static function isMacOs()
62
    {
63
        return stristr(PHP_OS, 'darwin') || stristr(PHP_OS, 'mac');
64
    }
65
66
    /**
67
     * @param string $program
68
     * @return bool
69
     */
70
    public static function isProgramInstalled($program)
71
    {
72
        if (self::isWindows()) {
73
            return WindowsSystem::isProgramInstalled($program);
74
        }
75
76
        $out = null;
77
        $return = null;
78
        @exec('which ' . $program, $out, $return);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
79
80
        return $return === 0;
81
    }
82
83
    /**
84
     * Home directory of the current user
85
     *
86
     * @return string|false false in case there is no environment variable related to the home directory
87
     */
88
    public static function getHomeDir()
89
    {
90
        if (self::isWindows()) {
91
            return getenv('USERPROFILE');
92
        }
93
94
        return getenv('HOME');
95
    }
96
97
    /**
98
     * Test for Root UID on a POSIX system if posix_getuid() is available.
99
     *
100
     * Returns false negatives if posix_getuid() is not available.
101
     *
102
     * @return bool
103
     */
104
    public static function isRoot()
105
    {
106
        return function_exists('posix_getuid') && posix_getuid() === self::UID_ROOT;
107
    }
108
109
    /**
110
     * get current working directory
111
     *
112
     * @return string the current working directory on success, or false on failure.
113
     */
114
    public static function getCwd()
115
    {
116
        return getcwd();
117
    }
118
119
    /**
120
     * Retrieve path to php binary
121
     *
122
     * @return string
123
     */
124
    public static function getPhpBinary()
125
    {
126
        // PHP_BINARY (>= php 5.4)
127
        if (defined('PHP_BINARY')) {
128
            return PHP_BINARY;
129
        }
130
131
        if (self::isWindows()) {
132
            return 'php';
133
        }
134
135
        return '/usr/bin/env php';
136
    }
137
}
138