Issues (287)

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.

UnusedSniffs/Files/ClosingFileCommentSniff.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
 * CodeIgniter_Sniffs_Files_ClosingFileCommentSniff.
4
 *
5
 * PHP version 5
6
 *
7
 * @category  PHP
8
 * @package   PHP_CodeSniffer
9
 * @author    Thomas Ernest <[email protected]>
10
 * @copyright 2006 Thomas Ernest
11
 * @license   http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
12
 * @link      http://pear.php.net/package/PHP_CodeSniffer
13
 */
14
15
/**
16
 * CodeIgniter_Sniffs_Files_ClosingFileCommentSniff.
17
 *
18
 * Ensures that a comment containing the file name is available at the end of file.
19
 * Only other comments and whitespaces are allowed to follow this specific comment.
20
 *
21
 * It may be all kind of comment like multi-line and inline C-style comments as
22
 * well as PERL-style comments. Any number of white may separate comment delimiters
23
 * from comment content. However, content has to be equal to template
24
 * "End of file <file_name>". Comparison between content and template is
25
 * case-sensitive.
26
 *
27
 * @category  PHP
28
 * @package   PHP_CodeSniffer
29
 * @author    Thomas Ernest <[email protected]>
30
 * @copyright 2006 Thomas Ernest
31
 * @license   http://thomas.ernest.fr/developement/php_cs/licence GNU General Public License
32
 * @link      http://pear.php.net/package/PHP_CodeSniffer
33
 */
34
35
namespace CodeIgniter\Sniffs\Files;
36
37
use PHP_CodeSniffer\Files\File;
38
39
class ClosingFileCommentSniff extends AbstractClosingCommentSniff
40
{
41
42
    /**
43
     * Returns an array of tokens this test wants to listen for.
44
     *
45
     * @return array
46
     */
47
    public function register()
48
    {
49
        return array(
50
            T_OPEN_TAG,
51
        );
52
53
    }//end register()
54
55
56
    /**
57
     * Processes this test, when one of its tokens is encountered.
58
     *
59
     * @param File $phpcsFile The current file being scanned.
60
     * @param int                  $stackPtr  The position of the current token
61
     *                                        in the stack passed in $tokens.
62
     *
63
     * @return void
64
     */
65
    public function process(File $phpcsFile, $stackPtr)
66
    {
67
        // We are only interested if this is the first open tag.
68 View Code Duplication
        if ($stackPtr !== 0) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
69
            if ($phpcsFile->findPrevious(T_OPEN_TAG, ($stackPtr - 1)) !== false) {
70
                return;
71
            }
72
        }
73
74
        $fullFilename = $phpcsFile->getFilename();
75
        $filename = basename($fullFilename);
76
        $commentTemplate = "End of file $filename";
77
78
        $tokens = $phpcsFile->getTokens();
79
        $currentToken = count($tokens) - 1;
80
        $hasClosingFileComment = false;
81
        $isNotAWhitespaceOrAComment = false;
82 View Code Duplication
        while ($currentToken >= 0
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
83
            && ! $isNotAWhitespaceOrAComment
84
            && ! $hasClosingFileComment
85
        ) {
86
            $token = $tokens[$currentToken];
87
            $tokenCode = $token['code'];
88
            if (T_COMMENT === $tokenCode) {
89
                $commentString = self::_getCommentContent($token['content']);
90
                if (0 === strcmp($commentString, $commentTemplate)) {
91
                    $hasClosingFileComment = true;
92
                }
93
            } else if (T_WHITESPACE === $tokenCode) {
94
                // Whitespaces are allowed between the closing file comment,
95
                // other comments and end of file
96
            } else {
97
                $isNotAWhitespaceOrAComment = true;
98
            }
99
            $currentToken--;
100
        }
101
102
        if ( ! $hasClosingFileComment) {
103
            $error = 'No comment block marks the end of file instead of the closing PHP tag. Please add a comment block containing only "' . $commentTemplate . '".';
104
            $phpcsFile->addError($error, $currentToken);
105
        }
106
    }//end process()
107
}//end class
108
109
?>
110