Issues (2013)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  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.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  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.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  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.
  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.
  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.
  Header Injection
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.

class/xoopseditor/xinha/contrib/compress.php (5 issues)

1
<?
0 ignored issues
show
Security Best Practice introduced by
It is not recommended to use PHP's short opening tag <?, better use <?php, or <?= in case of outputting.

Short opening tags are disabled in PHP?s default configuration. In such a case, all content of this file is output verbatim to the browser without being parsed, or executed.

As a precaution to avoid these problems better use the long opening tag <?php.

Loading history...
2
3
die('Run this script to batch-compress the current Xinha snapshot. To run the script, open the file and comment out the die() command');
4
$repository_url = 'http://svn.xinha.org/trunk';
5
$version        = '';
6
$date           = date('r');
7
error_reporting(E_ALL);
8
ini_set('show_errors', 1);
9
10
$return = [];
11
function scan($dir, $durl = '', $min_size = '0')
12
{
13
    static $seen = [];
14
    global $return;
15
    $files = [];
16
17
    $dir = realpath($dir);
18
    if (isset($seen[$dir])) {
19
        return $files;
20
    }
21
    $seen[$dir] = true;
22
    $dh         = @opendir($dir);
23
24
    while ($dh && ($file = readdir($dh))) {
25
        if ('.' !== $file && '..' !== $file) {
26
            $path = realpath($dir . '/' . $file);
27
            $url  = $durl . '/' . $file;
28
29
            if (preg_match("/\.svn|lang/", $path)) {
30
                continue;
31
            }
32
33
            if (is_dir($path)) {
34
                scan($path);
35
            } elseif (is_file($path)) {
36
                if (!preg_match("/\.js$/", $path) || filesize($path) < $min_size) {
37
                    continue;
38
                }
39
                $return[] = $path;
40
            }
41
        }
42
    }
43
    @closedir($dh);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition for closedir(). This can introduce security issues, and is generally not recommended. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unhandled  annotation

43
    /** @scrutinizer ignore-unhandled */ @closedir($dh);

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...
It seems like $dh can also be of type false; however, parameter $dir_handle of closedir() does only seem to accept resource, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

43
    @closedir(/** @scrutinizer ignore-type */ $dh);
Loading history...
Are you sure the usage of closedir($dh) is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
44
45
    return $files;
46
}
47
48
scan('../');
49
$cwd = getcwd();
50
51
$root_dir = realpath($cwd . '/..');
52
53
print 'Processing ' . count($return) . ' files<br />';
54
55
$prefix = '/* This compressed file is part of Xinha. For uncompressed sources, forum, and bug reports, go to xinha.org */';
56
if ($version) {
57
    $prefix .= "\n/* This file is part of version $version released $date */";
58
}
59
60
$core_prefix = '
61
  /*--------------------------------------------------------------------------
62
    --  Xinha (is not htmlArea) - http://xinha.org
63
    --
64
    --  Use of Xinha is granted by the terms of the htmlArea License (based on
65
    --  BSD license)  please read license.txt in this package for details.
66
    --
67
    --  Copyright (c) 2005-2008 Xinha Developer Team and contributors
68
    --  
69
    --  Xinha was originally based on work by Mihai Bazon which is:
70
    --      Copyright (c) 2003-2004 dynarch.com.
71
    --      Copyright (c) 2002-2003 interactivetools.com, inc.
72
    --      This copyright notice MUST stay intact for use.
73
    -------------------------------------------------------------------------*/
74
';
75
foreach ($return as $file) {
76
    set_time_limit(60);
77
    print "Processed $file<br />";
78
    flush();
79
    $file_url = $repository_url . str_replace($root_dir, '', $file);
80
81
    copy($file, $file . '_uncompr.js');
82
83
    $file_prefix = $prefix . "\n/* The URL of the most recent version of this file is $file_url */";
84
85
    exec('echo "' . (preg_match('/XinhaCore.js$/', $file) ? $file_prefix . $core_prefix : $file_prefix) . "\" > $file && java -jar ${cwd}/dojo_js_compressor.jar -c ${file}_uncompr.js >> $file 2>&1");
86
    if (preg_match('/js: ".*?", line \d+:/', file_get_contents($file)) || preg_match('/sh: java: command not found/', file_get_contents($file))) {
87
        unlink($file);
88
        rename($file . '_uncompr.js', $file);
89
    } else {
90
        unlink($file . '_uncompr.js');
91
    }
92
}
93
print "Operation complete."
94
?>
0 ignored issues
show
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
95
96
97